Skip to content

Conversation

@waleedlatif1
Copy link
Collaborator

Summary

  • update stream to respect all output select objects

Fixes #2724

Type of Change

  • Bug fix

Testing

Tested manually

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link

vercel bot commented Jan 8, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Review Updated (UTC)
docs Skipped Skipped Jan 8, 2026 7:44pm

Copy link
Contributor

@greptile-apps greptile-apps bot left a 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
Loading

@waleedlatif1
Copy link
Collaborator Author

@greptile

Copy link
Contributor

@greptile-apps greptile-apps bot left a 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 processStreamingResponse to process the final execution result and extract non-content selected outputs from block logs
  • Modified useWorkflowExecution to accumulate BlockLog entries during execution so they're available in the final event
  • Updated dependency array in processStreamingResponse to include selectedOutputs and activeWorkflowId

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
Loading

@waleedlatif1 waleedlatif1 merged commit fdac431 into staging Jan 8, 2026
10 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/output-selector branch January 8, 2026 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants