fix(mothership): run workflow tools (run from block, run until block)#3595
fix(mothership): run workflow tools (run from block, run until block)#3595
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Greptile SummaryThis PR fixes two related issues in the Mothership/Copilot feature: broken workflow execution tools ( Key changes:
Confidence Score: 3/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Browser
participant NextAPI as Next.js API
participant Orchestrator as Orchestrator (handlers.ts)
participant Go as Go Backend
Note over Browser,Go: Normal send-message flow
Browser->>NextAPI: POST /api/copilot/chat
NextAPI->>Go: Forward message + open SSE stream
Go-->>Orchestrator: SSE: tool_call (run_workflow, clientExecutable=true)
alt interactive === false (NEW behavior)
Orchestrator->>Orchestrator: fireToolExecution() → SIM_WORKFLOW_TOOL_HANDLERS
Orchestrator->>NextAPI: Execute workflow server-side
Orchestrator-->>Go: markToolComplete (result)
end
Go-->>NextAPI: SSE forwarded to browser stream
NextAPI-->>Browser: SSE: tool_call (ui.clientExecutable=true)
Browser->>Browser: executeRunToolOnClient() ← still triggered!
Browser->>NextAPI: POST /api/workflows/{id}/execute (client-side)
Browser->>NextAPI: POST /api/copilot/confirm (reportCompletion → Redis)
Note over NextAPI: Nobody reads Redis result in new code
Note over Browser,Go: Stream reconnect flow (NEW)
Browser->>NextAPI: GET /api/copilot/chat?chatId=X
NextAPI->>NextAPI: getStreamMeta + readStreamEvents (parallel)
NextAPI-->>Browser: chat + streamSnapshot{events[], status}
alt snapshot exists & not expired
Browser->>Browser: Pipe batch events into ReadableStream
Browser->>NextAPI: GET /api/copilot/chat/stream?from=lastEventId
NextAPI-->>Browser: Live SSE tail
Browser->>Browser: processSSEStream(combinedStream)
else snapshot expired (status=unknown, 0 events)
Browser->>NextAPI: POST /api/mothership/chat/stop (cleanup)
end
|
Summary
Fixes run workflow tools
Fixes stream reconnect bug
Type of Change
Testing
Manual
Checklist