Skip to content

Comments

feat(terminal): expandable child workflow blocks in console#3306

Merged
waleedlatif1 merged 9 commits intostagingfrom
feat/child-workflow-logs
Feb 23, 2026
Merged

feat(terminal): expandable child workflow blocks in console#3306
waleedlatif1 merged 9 commits intostagingfrom
feat/child-workflow-logs

Conversation

@waleedlatif1
Copy link
Collaborator

@waleedlatif1 waleedlatif1 commented Feb 23, 2026

Summary

  • Workflow blocks in the terminal console are now expandable accordions showing nested child blocks in real-time, identical UX to loop/parallel subflows
  • Child block events are propagated from the child executor to the parent SSE stream via onBlockStart/onBlockComplete callbacks with a ChildWorkflowContext (depth-capped at 3 levels)
  • Supports full nesting: loops, parallels, and nested workflows inside child workflows all render correctly
  • Fixed depth >1 nesting bug where grandchild workflow blocks were orphaned in the tree builder
  • Auto-expand, keyboard navigation, error/running/canceled status indicators all work recursively through the tree

Type of Change

  • New feature

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)
Screenshot 2026-02-22 at 3 50 05 PM

@vercel
Copy link

vercel bot commented Feb 23, 2026

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Feb 23, 2026 8:17am

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 23, 2026

Greptile Summary

This PR adds expandable child workflow blocks to the terminal console, bringing workflow blocks to feature parity with existing loop/parallel subflow rendering. The implementation spans 18 files across four layers:

  • Executor layer: WorkflowBlockHandler generates a per-invocation instanceId (crypto.randomUUID()) to correlate parent workflow blocks with their child block events. Callback propagation is depth-gated at 3 levels via MAX_SSE_CHILD_DEPTH. A new executeWithNode method provides node metadata (loop/parallel context) to enable proper iteration-aware event emission.
  • SSE transport layer: A new block:childWorkflowStarted event type allows clients to pre-associate the instanceId with a running console entry before child blocks start emitting. Existing block:started, block:completed, and block:error events now carry childWorkflowBlockId and childWorkflowName fields.
  • Store/state layer: ConsoleEntry and ConsoleUpdate types gain three new optional fields (childWorkflowBlockId, childWorkflowName, childWorkflowInstanceId) for tree construction.
  • UI layer: buildEntryTree now classifies entries into three buckets (iteration, workflow child, regular) and recursively builds workflow subtrees with cycle-guarded descendant collection. A new WorkflowNodeRow component renders expandable accordions consistent with the existing SubflowNodeRow pattern.

The _childWorkflowInstanceId output property uses the underscore-prefix convention to be automatically filtered by filterOutputForLog, preventing internal correlation data from leaking to user-facing output.

Confidence Score: 4/5

  • This PR is safe to merge — the feature is well-structured with proper depth caps, cycle guards, and consistent patterns across all execution paths.
  • The implementation is thorough and well-reasoned: per-invocation instanceId prevents cross-iteration child mixing, depth cap at 3 prevents unbounded SSE propagation, visited-set cycle guard prevents infinite recursion, and the underscore-prefix convention correctly filters internal data. The only gap is the execute() fallback path not firing onChildWorkflowInstanceReady, which is a minor degradation rather than a bug. No tests were added, but the feature is manually tested and the changes are largely plumbing new fields through existing well-tested paths.
  • apps/sim/executor/handlers/workflow/workflow-handler.ts (core logic for child workflow event propagation) and apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/terminal/utils.ts (tree building logic) deserve the most attention during review.

Important Files Changed

Filename Overview
apps/sim/executor/handlers/workflow/workflow-handler.ts Core changes: added executeWithNode method, _executeCore refactor, per-invocation instanceId via crypto.randomUUID(), depth-gated callback propagation, and getIterationContext helper. Well-structured with proper cycle guarding.
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/terminal/utils.ts Added workflow block type detection, tree building for nested child workflows with cycle-guarded collectWorkflowDescendants, recursive collectExpandableNodeIds, and updated flattenBlockEntriesOnly to include workflow nodes.
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/terminal/terminal.tsx New WorkflowNodeRow component following existing SubflowNodeRow patterns, recursive tree status helpers, auto-expand logic now uses shared collectExpandableNodeIds. Consistent with existing component patterns.
apps/sim/executor/execution/block-executor.ts Extracts _childWorkflowInstanceId from output and passes childWorkflowContext to callbacks. Added originalBlockId and isLoopNode to buildNodeMetadata. Changes are minimal and targeted.
apps/sim/executor/execution/types.ts New ChildWorkflowContext interface and updated callback signatures to include child workflow context. Added onChildWorkflowInstanceReady callback. Clean type additions.
apps/sim/lib/workflows/executor/execution-events.ts New BlockChildWorkflowStartedEvent type, updated existing events with child workflow fields, refactored createSSECallbacks to use imported types instead of inline type literals.
apps/sim/app/api/workflows/[id]/execute/route.ts Updated onBlockStart/onBlockComplete callbacks to pass child workflow context through SSE events, added new onChildWorkflowInstanceReady callback.
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-workflow-execution.ts New onBlockChildWorkflowStarted handler plumbed through all execution paths (streaming, non-streaming, run-from-block). Consistent with existing handler patterns.
apps/sim/stores/terminal/console/types.ts Added child workflow fields to ConsoleEntry and ConsoleUpdate interfaces with proper TSDoc comments.

Sequence Diagram

sequenceDiagram
    participant UI as Terminal UI
    participant Store as ConsoleStore
    participant SSE as SSE Stream
    participant Exec as DAGExecutor
    participant BE as BlockExecutor
    participant WH as WorkflowBlockHandler
    participant Child as Child Executor

    Exec->>BE: execute(workflowBlockNode)
    BE->>WH: executeWithNode(ctx, block, inputs, nodeMetadata)
    WH->>WH: instanceId = crypto.randomUUID()
    WH->>SSE: onChildWorkflowInstanceReady(blockId, instanceId)
    SSE->>UI: block:childWorkflowStarted event
    UI->>Store: updateConsole(blockId, {childWorkflowInstanceId})

    WH->>Child: new Executor({childWorkflowContext: {parentBlockId: instanceId, depth}})
    Child->>BE: execute(childBlock)
    BE->>SSE: onBlockStart(childBlockId, ..., childWorkflowContext)
    SSE->>UI: block:started {childWorkflowBlockId: instanceId}
    UI->>Store: addConsole({childWorkflowBlockId: instanceId})

    BE->>SSE: onBlockComplete(childBlockId, ..., childWorkflowContext)
    SSE->>UI: block:completed {childWorkflowBlockId: instanceId}
    UI->>Store: updateConsole(childBlockId, ...)

    Note over UI,Store: buildEntryTree groups children by childWorkflowBlockId → instanceId
    Store->>UI: Re-render with WorkflowNodeRow accordion
Loading

Last reviewed commit: f4f293a

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.

15 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@waleedlatif1
Copy link
Collaborator Author

@cursor review

@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.

15 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@waleedlatif1
Copy link
Collaborator Author

@greptile

@waleedlatif1
Copy link
Collaborator Author

@cursor review

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.

18 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@waleedlatif1
Copy link
Collaborator Author

@cursor review

@waleedlatif1
Copy link
Collaborator Author

@cursor review

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

@waleedlatif1 waleedlatif1 merged commit 69ec70a into staging Feb 23, 2026
5 checks passed
@waleedlatif1 waleedlatif1 deleted the feat/child-workflow-logs branch February 23, 2026 08:17
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.

1 participant