Skip to content

improvement(preview): render nested values like input format correctly in workflow execution preview #3154

Open
icecrasher321 wants to merge 6 commits intostagingfrom
fix/preview-minor-issues
Open

improvement(preview): render nested values like input format correctly in workflow execution preview #3154
icecrasher321 wants to merge 6 commits intostagingfrom
fix/preview-minor-issues

Conversation

@icecrasher321
Copy link
Collaborator

@icecrasher321 icecrasher321 commented Feb 6, 2026

Summary

Fix preview/snapshot rendering for nested workflow blocks and all sub-block components that read sibling values. Snapshot service now refreshes stale stateData on dedup hits, non-executed blocks show "Not Executed" instead of "Deleted Workflow", and a shared resolvePreviewContextValue utility ensures all 12 sub-block components correctly resolve sibling values from snapshot context rather than falling back to the live editor store.

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 Feb 6, 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 6, 2026 7:47pm

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 6, 2026

Greptile Overview

Greptile Summary

  • Adds previewContextValues plumbing through many sub-block inputs so execution preview can resolve sibling/nested values the same way as live inputs.
  • Introduces resolvePreviewContextValue() to normalize preview context entries that may be wrapped as { value: T } vs already-raw values.
  • Updates PreviewEditor to treat “block not executed” as a distinct state and avoid showing deleted/missing-child-workflow messaging in that case.
  • Snapshot deduplication now attempts to refresh stored stateData on reuse so presentation-only fields remain current.

Confidence Score: 3/5

  • This PR is moderately safe to merge, but has two correctness issues that should be addressed first.
  • Most changes are straightforward preview-context plumbing and UI messaging improvements. However, snapshot refresh can return stateData inconsistent with the DB on update failure, and the new preview unwrapping helper collapses null/undefined which can prevent preview from explicitly clearing values.
  • apps/sim/lib/logs/execution/snapshot/service.ts; apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/utils.ts

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/credential-selector/credential-selector.tsx Threads previewContextValues through useDependsOnGate so preview can resolve dependsOn values correctly.
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/document-selector/document-selector.tsx Uses resolvePreviewContextValue when reading knowledgeBaseId from previewContextValues to handle wrapped {value} preview entries.
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/document-tag-entry/document-tag-entry.tsx Normalizes previewContextValues.knowledgeBaseId via resolvePreviewContextValue before deriving tag context.
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/file-selector/file-selector-input.tsx Resolves several selector context fields via resolvePreviewContextValue; behavior depends on whether null in preview should override store (see utils helper comment).
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/folder-selector/components/folder-selector-input.tsx Adds previewContextValues support for credential + dependsOn gate; no further behavioral changes observed.
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/input-mapping/input-mapping.tsx Uses resolvePreviewContextValue to pick workflowId from preview context, enabling accurate preview of nested input mapping.
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/knowledge-tag-filters/knowledge-tag-filters.tsx Uses resolvePreviewContextValue for knowledgeBaseId in preview context; otherwise unchanged.
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/mcp-dynamic-args/mcp-dynamic-args.tsx Adds previewContextValues to resolve tool/schema values in preview; change aligns with new helper.
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/mcp-server-modal/mcp-tool-selector.tsx Resolves server sub-block value from preview context for tool selection; no other changes.
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/project-selector/project-selector-input.tsx Resolves credential/domain/teamId from preview context; same null-vs-missing semantics concern as other selectors.
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/sheet-selector/sheet-selector-input.tsx Resolves credential/spreadsheetId/manualSpreadsheetId from preview context; depends on helper semantics for null overrides.
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/slack-selector/slack-selector-input.tsx Resolves authMethod/botToken/credential from preview context; straightforward refactor.
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tool-input/tool-input.tsx Plumbs previewContextValues into FolderSelectorSyncWrapper so nested selector can resolve sibling values in preview.
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/sub-block.tsx Passes subBlockValues as previewContextValues to multiple sub-block UIs during preview rendering; enables sibling resolution.
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/utils.ts Introduces resolvePreviewContextValue helper; current design collapses null/undefined to null which can prevent preview context from explicitly clearing fields (see review comment).
apps/sim/app/workspace/[workspaceId]/w/components/preview/components/preview-editor/preview-editor.tsx Adjusts preview UI to treat not-executed blocks distinctly and avoid showing deleted-workflow state when executionData is missing.
apps/sim/lib/logs/execution/snapshot/service.ts On snapshot dedupe, attempts to refresh stored stateData; current implementation can return updated stateData even if DB update failed, causing inconsistency (see review comment).

Sequence Diagram

sequenceDiagram
  participant UI as PreviewEditor UI
  participant Sub as SubBlockComponent
  participant Comp as Sub-block Inputs
  participant Gate as useDependsOnGate
  participant Util as resolvePreviewContextValue
  participant Snap as SnapshotService
  participant DB as workflowExecutionSnapshots (DB)

  UI->>Snap: createSnapshotWithDeduplication(workflowId, state)
  Snap->>DB: SELECT snapshot by (workflowId, stateHash)
  alt snapshot exists
    Snap->>DB: UPDATE stateData (best-effort)
    Snap-->>UI: return existingSnapshot + stateData=state
  else new snapshot
    Snap->>DB: INSERT snapshot(stateData=state)
    Snap-->>UI: return new snapshot
  end

  UI->>Sub: render block preview (execution/preview mode)
  Sub->>Comp: pass previewValue + previewContextValues=subBlockValues
  Comp->>Gate: compute depsSatisfied / finalDisabled
  Gate->>Util: unwrap previewContextValues entries (optional)
  Util-->>Gate: normalized raw values
  Gate-->>Comp: finalDisabled + depsSatisfied
  Comp-->>UI: render resolved nested inputs
Loading

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.

17 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

@icecrasher321
Copy link
Collaborator Author

@cursor review

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

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