improvement(hitl): add webhook notification and resume, add webhook block#2673
improvement(hitl): add webhook notification and resume, add webhook block#2673
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
87d8a79 to
90e8db1
Compare
Greptile Summary
Important Files Changed
Confidence score: 4/5
Sequence DiagramsequenceDiagram
participant User
participant HumanInTheLoopBlock
participant NotificationTools
participant WebhookRequest
participant Database
participant ResumeAPI
participant PauseResumeManager
User->>HumanInTheLoopBlock: Execute workflow with HITL block
HumanInTheLoopBlock->>Database: Generate pause context and persist execution
HumanInTheLoopBlock->>HumanInTheLoopBlock: Generate resume URLs (UI and API)
HumanInTheLoopBlock->>NotificationTools: Execute notification tools with resume links
NotificationTools->>WebhookRequest: Send webhook with resume endpoint
WebhookRequest->>External Service: POST webhook payload with signature
External Service-->>WebhookRequest: Acknowledge webhook
HumanInTheLoopBlock-->>User: Return pause response with resume URLs
User->>ResumeAPI: POST resume with input data
ResumeAPI->>Database: Validate workflow access and pause context
ResumeAPI->>PauseResumeManager: Enqueue or start resume execution
PauseResumeManager->>Database: Update pause status to resuming
PauseResumeManager->>PauseResumeManager: Execute workflow from pause point
PauseResumeManager->>Database: Update execution status to completed
PauseResumeManager-->>ResumeAPI: Return execution result
ResumeAPI-->>User: Return resume confirmation
|
|
|
||
| export interface WebhookRequestParams { | ||
| url: string | ||
| body?: any |
There was a problem hiding this comment.
style: Consider using unknown instead of any for better type safety
| body?: any | |
| body?: unknown |
Context Used: Context from dashboard - TypeScript conventions and type safety (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/sim/tools/http/types.ts
Line: 23:23
Comment:
**style:** Consider using `unknown` instead of `any` for better type safety
```suggestion
body?: unknown
```
**Context Used:** Context from `dashboard` - TypeScript conventions and type safety ([source](https://app.greptile.com/review/custom-context?memory=b4f0be8d-a787-4d5a-9098-a66b1449df25))
<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>
How can I resolve this? If you propose a fix, please make it concise.| const workflow = access.workflow! | ||
| const workflow = access.workflow | ||
|
|
||
| let payload: any = {} |
There was a problem hiding this comment.
style: Consider using unknown instead of any for better type safety
| let payload: any = {} | |
| let payload: unknown = {} |
Context Used: Context from dashboard - TypeScript conventions and type safety (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/sim/app/api/resume/[workflowId]/[executionId]/[contextId]/route.ts
Line: 32:32
Comment:
**style:** Consider using `unknown` instead of `any` for better type safety
```suggestion
let payload: unknown = {}
```
**Context Used:** Context from `dashboard` - TypeScript conventions and type safety ([source](https://app.greptile.com/review/custom-context?memory=b4f0be8d-a787-4d5a-9098-a66b1449df25))
<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>
How can I resolve this? If you propose a fix, please make it concise.| if (!fieldName) continue | ||
|
|
||
| hitlOutputs[fieldName] = { | ||
| type: (field?.type || 'any') as any, |
There was a problem hiding this comment.
style: Type assertion as any bypasses TypeScript's type checking. Consider defining a proper union type for supported field types instead of using any.
Context Used: Context from dashboard - TypeScript conventions and type safety (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/sim/lib/workflows/blocks/block-outputs.ts
Line: 244:244
Comment:
**style:** Type assertion `as any` bypasses TypeScript's type checking. Consider defining a proper union type for supported field types instead of using `any`.
**Context Used:** Context from `dashboard` - TypeScript conventions and type safety ([source](https://app.greptile.com/review/custom-context?memory=b4f0be8d-a787-4d5a-9098-a66b1449df25))
<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>
How can I resolve this? If you propose a fix, please make it concise.| blockTags = isSelfReference | ||
| ? allTags.filter((tag) => tag.endsWith('.url') || tag.endsWith('.resumeEndpoint')) | ||
| : allTags |
There was a problem hiding this comment.
style: Consider extracting the tag filtering logic into a helper function since this pattern is now used for both approval and human_in_the_loop blocks
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tag-dropdown/tag-dropdown.tsx
Line: 765:767
Comment:
**style:** Consider extracting the tag filtering logic into a helper function since this pattern is now used for both approval and human_in_the_loop blocks
<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>
How can I resolve this? If you propose a fix, please make it concise.| <Label>Pause Data</Label> | ||
| </div> | ||
| <div style={{ padding: '16px' }}> | ||
| <Code.Viewer code={pauseResponsePreview} language='json' /> |
There was a problem hiding this comment.
style: using Code.Viewer with dot notation instead of importing from barrel
Context Used: Context from dashboard - Import patterns for the Sim application (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/sim/app/resume/[workflowId]/[executionId]/resume-page-client.tsx
Line: 1161:1161
Comment:
**style:** using Code.Viewer with dot notation instead of importing from barrel
**Context Used:** Context from `dashboard` - Import patterns for the Sim application ([source](https://app.greptile.com/review/custom-context?memory=a1041767-1a8e-44e0-9ec7-7efb79eb749b))
<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>
How can I resolve this? If you propose a fix, please make it concise.…lock (#2673) * Add api blcok as tool * Add webhook block * Hitl v1 * Cleanup * Fix * Update names for fields in hitl * Fix hitl tag dropdown * Update hitl dashboard * Lint
Summary
Adds webhook block and webhook resume functionality to hitl block
Type of Change
Testing
Manual
Checklist