Skip to content

fix(workflow-block): exclude trigger-advanced subblocks from canvas preview outside trigger mode#4969

Merged
waleedlatif1 merged 1 commit into
stagingfrom
fix/table-block-duplicate-tableid-preview
Jun 11, 2026
Merged

fix(workflow-block): exclude trigger-advanced subblocks from canvas preview outside trigger mode#4969
waleedlatif1 merged 1 commit into
stagingfrom
fix/table-block-duplicate-tableid-preview

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Table block showed a duplicate "Table ID" row in the canvas block preview when the table field was switched to advanced (manual) mode
  • The block spreads the table_new_row trigger's subBlocks, which include a second manualTableId with mode: 'trigger-advanced'; the canvas preview filter only excluded mode === 'trigger', so the trigger copy leaked through and rendered a second row
  • Replaced the hand-rolled mode checks in the canvas preview and the autolayout row estimator with the canonical isTriggerModeSubBlock helper (covers both trigger and trigger-advanced), matching the editor sidebar's isSubBlockVisibleForTriggerMode behavior
  • Added a regression test asserting basic and advanced canonical modes produce the same estimated row count for a block with trigger-spread duplicates

Type of Change

  • Bug fix

Testing

  • Regression test fails without the fix and passes with it
  • bunx tsc --noEmit and existing autolayout/visibility tests pass

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

vercel Bot commented Jun 11, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Jun 11, 2026 5:56pm

Request Review

@cursor

cursor Bot commented Jun 11, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Narrow visibility-filter change with a focused regression test; no auth, data, or API surface changes.

Overview
Fixes a duplicate "Table ID" row on the workflow canvas when a Table block uses advanced (manual) table selection. Blocks that merge trigger subBlocks (e.g. table_new_row) can include a second manualTableId with mode: 'trigger-advanced'; preview and layout logic only hid mode === 'trigger', so that copy still appeared outside trigger mode.

Canvas preview (workflow-block.tsx) and autolayout height estimation (autolayout/utils.ts) now use isTriggerModeSubBlock, which treats both trigger and trigger-advanced as trigger-only—aligned with the editor sidebar’s trigger visibility rules.

Adds a regression test in utils.test.ts: for a table-like config with trigger-spread duplicates, getBlockMetrics yields the same height for basic vs advanced canonical mode.

Reviewed by Cursor Bugbot for commit 626cd78. Configure here.

@greptile-apps

greptile-apps Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a UI bug where switching the Table block's table field to "advanced" (manual) mode caused a duplicate "Table ID" row to appear in the canvas block preview. The root cause was that the canvas filter and autolayout row estimator only excluded mode === 'trigger' subblocks, missing mode === 'trigger-advanced' subblocks that are spread from the trigger definition.

  • Replaces hand-rolled block.mode === 'trigger' checks in workflow-block.tsx and autolayout/utils.ts with the canonical isTriggerModeSubBlock helper (which covers both 'trigger' and 'trigger-advanced'), matching what isSubBlockVisibleForTriggerMode already did in the editor sidebar.
  • Adds a regression test in utils.test.ts that constructs a table-like config with trigger-spread duplicate subblocks and asserts that basic and advanced canonical modes produce identical row heights.

Confidence Score: 5/5

Safe to merge — the change is a targeted two-site substitution replacing an incomplete mode check with the canonical helper, backed by a new regression test that fails without the fix.

Both changed call sites in workflow-block.tsx and autolayout/utils.ts are straightforward replacements of block.mode === 'trigger' with the already-existing isTriggerModeSubBlock helper, which has been in use in the editor sidebar. The fix is consistent across canvas preview and autolayout estimation. The new test exercises the exact failure scenario described in the PR and correctly asserts height parity between basic and advanced modes. No new state management, API calls, or side effects are introduced.

No files require special attention.

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/workflow-block.tsx Replaces two hand-rolled block.mode === 'trigger' checks with isTriggerModeSubBlock(block), correctly excluding both trigger and trigger-advanced subblocks from the canvas preview when not in trigger mode.
apps/sim/lib/workflows/autolayout/utils.ts Mirrors the same fix in getVisiblePreviewSubBlockCount, ensuring the autolayout row estimator applies the same filtering logic as the canvas renderer.
apps/sim/lib/workflows/autolayout/utils.test.ts Adds a well-structured regression test with a table-like config that includes trigger-spread duplicate subblocks; correctly asserts that basic and advanced modes produce the same block height after the fix. Mock reset via beforeEach is properly scoped.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Block subBlocks config spread\nfrom trigger definition] --> B{effectiveTrigger?}
    B -- Yes --> C{isPureTriggerBlock?}
    C -- Yes --> D["isTriggerModeSubBlock(block)\nOR !block.mode"]
    C -- No --> E["isTriggerModeSubBlock(block)"]
    D -- false --> F[Exclude from canvas preview]
    E -- false --> F
    D -- true --> G[Keep - proceed to mode/condition checks]
    E -- true --> G
    B -- No --> H["isTriggerModeSubBlock(block)\n= mode==='trigger' OR mode==='trigger-advanced'"]
    H -- true --> F
    H -- false --> G
    G --> I["isSubBlockVisibleForMode()"]
    I -- visible --> J["evaluateSubBlockCondition()"]
    J -- pass --> K[Render row in canvas preview]
    I -- not visible --> F
    J -- fail --> F

    style F fill:#f96,stroke:#c00
    style K fill:#6c6,stroke:#060
Loading

Reviews (1): Last reviewed commit: "fix(workflow-block): exclude trigger-adv..." | Re-trigger Greptile

@waleedlatif1 waleedlatif1 merged commit ac2817d into staging Jun 11, 2026
15 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/table-block-duplicate-tableid-preview branch June 11, 2026 18:05
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