-
Notifications
You must be signed in to change notification settings - Fork 3.2k
fix(chat): update stream to respect all output select objects #2729
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Greptile Overview
Greptile Summary
Fixes streaming chat to display all selected workflow outputs, not just content. The hook now accumulates block logs during execution and passes them in the final event, allowing the chat component to extract and display non-content outputs like model, tokens, and toolCalls. This ensures all user-selected outputs appear in the chat response.
Confidence Score: 3/5
- Generally safe to merge with minor optimization concerns
- The fix correctly addresses the issue by accumulating block logs and extracting selected outputs from the final event. The logic is sound and properly handles edge cases (skipping content path, checking for undefined values). However, the accumulation of block logs without size limits in long-running workflows could lead to memory issues. The dependency array update is correct, preventing stale closure issues.
- apps/sim/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-workflow-execution.ts for potential memory optimization
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/chat/chat.tsx | 4/5 | Added logic to extract and display non-content selected outputs from streaming execution final event; properly updates dependency array |
| apps/sim/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-workflow-execution.ts | 3/5 | Accumulates block logs during execution for final result; minor concern about potential memory usage with many blocks |
Sequence Diagram
sequenceDiagram
participant User
participant Chat
participant WorkflowExec as useWorkflowExecution
participant Server
participant StreamProcessor
User->>Chat: Send message with selected outputs
Chat->>WorkflowExec: handleRunWorkflow(input)
WorkflowExec->>Server: Execute workflow (with selectedOutputs)
Server-->>WorkflowExec: Stream starts
WorkflowExec->>StreamProcessor: onBlockCompleted callbacks
Note over WorkflowExec: Accumulate block logs
StreamProcessor->>Chat: Stream chunks (content)
Chat->>Chat: Display streaming content
Server-->>WorkflowExec: Final event with logs
WorkflowExec->>Chat: processStreamingResponse (final event)
Chat->>Chat: Extract non-content outputs from logs
Note over Chat: Filter path !== 'content'
Chat->>Chat: Append additional outputs (model, tokens, etc.)
Chat->>User: Display complete response
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-workflow-execution.ts
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Greptile Overview
Greptile Summary
Enhanced chat streaming to extract and display all selected output fields (like model, tokens, toolCalls) from execution logs, not just the content field.
Key Changes:
- Added logic in
processStreamingResponseto process the final execution result and extract non-contentselected outputs from block logs - Modified
useWorkflowExecutionto accumulateBlockLogentries during execution so they're available in the final event - Updated dependency array in
processStreamingResponseto includeselectedOutputsandactiveWorkflowId
Confidence Score: 4/5
- This PR is safe to merge with minimal risk - focused bug fix with proper error handling
- The changes are well-contained and address a specific bug where non-content output selections weren't being displayed in chat. The implementation follows existing patterns, includes proper guards, and correctly filters out the content path to avoid duplication. Dependencies are properly declared in useCallback.
- No files require special attention
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/chat/chat.tsx | 4/5 | Enhanced streaming response handler to extract non-content selected outputs from execution logs and append them to chat messages |
| apps/sim/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-workflow-execution.ts | 4/5 | Added block log accumulation in server-side execution callbacks to populate execution result logs for both success and error cases |
Sequence Diagram
sequenceDiagram
participant User
participant Chat
participant useWorkflowExecution
participant ExecutionStream
participant processStreamingResponse
User->>Chat: Send message with output selections
Chat->>useWorkflowExecution: handleRunWorkflow(input)
useWorkflowExecution->>ExecutionStream: execute workflow
alt Streaming Block (Agent/Router)
ExecutionStream-->>processStreamingResponse: Stream chunks
processStreamingResponse->>Chat: Append content chunks
end
alt Non-Streaming Block (Function)
ExecutionStream->>useWorkflowExecution: onBlockComplete(blockId, output)
useWorkflowExecution->>processStreamingResponse: Send via SSE
processStreamingResponse->>Chat: Append formatted output
end
ExecutionStream->>useWorkflowExecution: onExecutionCompleted(logs)
useWorkflowExecution->>processStreamingResponse: Send final event with logs
processStreamingResponse->>processStreamingResponse: Extract selected outputs from logs
processStreamingResponse->>processStreamingResponse: Filter out 'content' path
processStreamingResponse->>processStreamingResponse: Format additional outputs (model, tokens, etc)
processStreamingResponse->>Chat: Append additional outputs to message
processStreamingResponse->>Chat: Finalize stream
Summary
Fixes #2724
Type of Change
Testing
Tested manually
Checklist