fix(hitl): fix stream endpoint, pause persistence, and resume page#3995
fix(hitl): fix stream endpoint, pause persistence, and resume page#3995icecrasher321 merged 8 commits intostagingfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview Execution callers are refactored to share a new Reviewed by Cursor Bugbot for commit e0147eb. Configure here. |
Greptile SummaryThis PR fixes three HITL subsystem bugs: (1) refactors duplicated pause-persistence logic into a shared
Confidence Score: 4/5Safe to merge after addressing the P1 re-pause logic gap — the stream endpoint closes early and misleads clients when a resumed workflow hits a second HITL block Score of 4 reflects one P1 finding: when a resumed execution returns status 'paused', the new SSE path writes execution:completed and marks meta as 'complete', causing the stream to close prematurely. This is a real production scenario for any workflow with chained HITL blocks. The two P2 findings (any type, inline styles) are project-convention violations with no runtime impact. All other changes — the pause-persistence extraction, stream auth fix, and background job refactors — are correct and well-structured. Focus on apps/sim/lib/workflows/executor/human-in-the-loop-manager.ts around the finalMetaStatus/else branch (lines 748-810) for the re-pause handling gap Important Files Changed
Sequence DiagramsequenceDiagram
participant C as Client
participant SR as stream/route.ts
participant RR as resume/route.ts
participant HM as human-in-the-loop-manager
participant EW as ExecutionEventWriter
participant EC as executeWorkflowCore
C->>SR: GET /stream?from=N (session auth only)
SR->>SR: getSession() → authorizeWorkflow
SR->>EW: readExecutionEvents(executionId, N)
SR-->>C: SSE events stream (polling loop)
C->>RR: POST /resume/:workflowId/:executionId/:contextId
RR->>RR: getSession() → authorize
RR->>EW: setExecutionMeta(resumeExecId, active)
RR->>HM: startResumeExecution() [fire-and-forget]
RR-->>C: 200 { executionId: resumeExecId }
HM->>EW: setExecutionMeta(active)
HM->>EW: write execution:started
HM->>EC: executeWorkflowCore(resumeSnapshot, callbacks)
EC->>HM: onBlockStart → write block:started
EC->>HM: onStream → write stream:chunk / stream:done
EC->>HM: onBlockComplete → write block:completed
EC-->>HM: result
alt result.status = completed/cancelled
HM->>EW: write execution:completed or execution:cancelled
HM->>EW: setExecutionMeta(complete/cancelled)
SR->>SR: isTerminalStatus → send [DONE]
SR-->>C: data: [DONE]
else result.status = paused (P1 BUG)
HM->>EW: write execution:completed (WRONG)
HM->>EW: setExecutionMeta(complete) (WRONG)
SR->>SR: isTerminalStatus('complete') = true
SR-->>C: data: [DONE] — client misled, workflow still paused
end
|
|
bugbot run |
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit e0147eb. Configure here.
Summary
/streamendpoint to block API key usage (only session auth allowed)HITL fixes
fix(hitl): fix hitl stream— corrected streaming logic for human-in-the-loop blocksfix(hitl): fix hitl pause persistence— paused state now persists correctlyfix(stream): block api key usage on /stream endpoint— stream endpoint now requires session authchore(resume): resume page cleanupType of Change
Testing
Tested manually
Checklist