Skip to content

fix(workflows): honor explicit canonical modes - #6677

Open
BillLeoutsakosvl346 wants to merge 1 commit into
stagingfrom
fix/canonical-selector-mode-resolution
Open

fix(workflows): honor explicit canonical modes#6677
BillLeoutsakosvl346 wants to merge 1 commit into
stagingfrom
fix/canonical-selector-mode-resolution

Conversation

@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor

Summary

  • Treats valid canonicalModes entries as authoritative across selector dependencies, previews, serialization, Agent tools, triggers, search, validation, and workspace-fork flows.
  • Keeps legacy workflows compatible when canonicalModes is absent, including historical value inference, advancedMode, trigger aliases, and direct canonical Agent params.
  • Projects mixed action/trigger block definitions onto the active surface so hidden dormant values cannot affect the active UI or runtime.

Compatibility matrix

Persisted state Behavior
Explicit Basic or Advanced mode Resolve only the selected side; an explicitly cleared active value stays cleared
No canonical mode Preserve historical value-based inference and fallback
Legacy advancedMode: true Backfill Advanced where the active canonical pair supports it
Legacy direct Agent canonical param Preserve it when no selected-side raw member is present
Modern raw Agent member Selected-side member is authoritative, including an empty value
Legacy type-scoped plus current index-scoped Agent modes Use the legacy map as a baseline and let index-scoped entries win per key
Action/trigger-capable blocks Resolve only the active surface while retaining dormant values for switching back

No API, database-schema, persisted-field, generated-metadata, or documentation changes are included.

Validation

  • Focused canonical/workflow suites: 670 tests passed
  • Full repository test suite: 24,717 tests passed, 30 skipped
  • Full type-check: 23/23 tasks passed
  • Full check-only lint: 23/23 tasks passed
  • Client, repository-boundary, migration, tool-registry, and trigger/block-cycle checks passed
  • git diff --check passed
  • Compatibility probes: 3,360 real-block backfill cases had zero serialization drift; 672 explicit-clear cases had zero dormant-mode leaks

@vercel

vercel Bot commented Aug 13, 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 Aug 13, 2026 11:25pm

Request Review

@cursor

cursor Bot commented Aug 13, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Touches shared subblock resolution used by editor, serializer, execution, fork/promote, and validation; regressions could change which credentials/params run without obvious UI breakage. Legacy compatibility paths are extensive but the behavioral surface area is large.

Overview
Makes persisted Basic/Advanced (canonicalModes) authoritative end-to-end so selectors, serialization, and Agent tools no longer leak values from the dormant side of a canonical pair or from the wrong action/trigger surface.

Core resolution: resolveDependencyValue and related helpers now honor an explicit mode (clears stay cleared; only the selected side is used), while workflows without canonicalModes keep legacy value inference and advancedMode backfill behavior.

Surface projection: Mixed action/trigger blocks use getCanonicalSubBlocksForSurface so canonical indexes, selector context, validation, preview, fork/remap, and search only consider the active surface—trigger credentials and dependents are not driven by action-only modes or stale dormant fields.

Nested Agent tools: Dependency context carries per-tool scoped canonicalModeOverrides (via DependencyBlockTypeProvider / getDependencyCanonicalModeOverrides), and tool param surfaces use action-only subblocks so trigger-only aliases do not execute or remap inside tool-input.

Reviewed by Cursor Bugbot for commit 0ab738e. Bugbot is set up for automated code reviews on this repo. Configure here.

@icecrasher321

Copy link
Copy Markdown
Collaborator

@BillLeoutsakosvl346 one question -- is this even possible for the runtime state to end up like this? Like is there a repro case where runtime state and UI can actually go out of sync. I assume we update canonical modes everywhere you'd expect to update it?

@greptile-apps

greptile-apps Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR makes explicit canonical-mode selections authoritative throughout workflow editing, previews, serialization, validation, Agent tools, triggers, search, and workspace-fork operations while preserving legacy inference paths.

  • Scopes canonical pairs and dependent values to the active action or trigger surface.
  • Propagates index-scoped canonical modes through nested Agent tool rendering and resolution.
  • Aligns serialization, migrations, reference remapping, validation, and preview behavior with the selected canonical mode.
  • Adds compatibility coverage for explicit clears, legacy modes, mixed-surface blocks, and nested tools.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
apps/sim/lib/workflows/subblocks/visibility.ts Centralizes active-surface projection and explicit canonical-mode resolution used throughout the workflow stack.
apps/sim/serializer/index.ts Serializes only the selected canonical member on the active action or trigger surface while retaining legacy fallback behavior.
apps/sim/tools/params-resolver.ts Resolves Agent tool parameters using scoped canonical modes and preserves supported legacy parameter representations.
apps/sim/ee/workspace-forking/lib/remap/remap-references.ts Restricts resource remapping and dependent clearing to active action-surface tool parameters.
apps/sim/lib/workflows/comparison/format-description.test.ts The previously untyped workflow fixture now satisfies WorkflowState directly and contains the required structural fields.

Reviews (2): Last reviewed commit: "fix(workflows): honor explicit canonical..." | Re-trigger Greptile

Comment thread apps/sim/lib/workflows/comparison/format-description.test.ts Outdated
@BillLeoutsakosvl346
BillLeoutsakosvl346 force-pushed the fix/canonical-selector-mode-resolution branch from 0da857d to d7f59e0 Compare August 13, 2026 21:30
@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

@icecrasher321 Yes — this can happen with normal saved state. On staging, set an Advanced manual selector/credential, switch back to Basic (the dormant Advanced value is intentionally retained), then clear the Basic value. canonicalModes still explicitly says Basic, but the dependency/preview path used active ?? inactive and reused the hidden Advanced value, while serialization/execution resolved only the selected Basic side. That made selector UI and runtime disagree. This change keeps the old inference when canonicalModes is missing; it only makes a valid persisted mode authoritative.

@icecrasher321

icecrasher321 commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

@BillLeoutsakosvl346 "but the dependency/preview path used active ?? inactive" --> do you mean the dependsOn and workflow preview in the snapshot?

@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

Yes on dependsOn/selector dependency context. By “preview” I mean the editor/read-only workflow preview and preview-context builders that resolve labels/options—not the execution snapshot itself. Those UI consumers could pick the dormant value while serializer/executor used the explicitly selected (cleared) side.

@BillLeoutsakosvl346
BillLeoutsakosvl346 force-pushed the fix/canonical-selector-mode-resolution branch from d7f59e0 to efb0937 Compare August 13, 2026 21:45
@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

@greptileai review

@BillLeoutsakosvl346
BillLeoutsakosvl346 force-pushed the fix/canonical-selector-mode-resolution branch from efb0937 to e584265 Compare August 13, 2026 22:42
Comment thread apps/sim/ee/workspace-forking/lib/remap/remap-references.ts
@BillLeoutsakosvl346
BillLeoutsakosvl346 force-pushed the fix/canonical-selector-mode-resolution branch from e584265 to 73bdab0 Compare August 13, 2026 23:10

@cursor cursor Bot left a comment

Copy link
Copy Markdown

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 using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 73bdab0. Configure here.

Comment thread apps/sim/ee/workspace-forking/lib/remap/remap-references.ts
@BillLeoutsakosvl346
BillLeoutsakosvl346 force-pushed the fix/canonical-selector-mode-resolution branch from 73bdab0 to ee2af27 Compare August 13, 2026 23:25
@BillLeoutsakosvl346
BillLeoutsakosvl346 force-pushed the fix/canonical-selector-mode-resolution branch from ee2af27 to 0ab738e Compare August 13, 2026 23:25
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