Skip to content

fix(workflow): draw a highlighted edge over the ordinary ones - #6642

Merged
waleedlatif1 merged 3 commits into
stagingfrom
fix/selected-edge-z-order
Aug 12, 2026
Merged

fix(workflow): draw a highlighted edge over the ordinary ones#6642
waleedlatif1 merged 3 commits into
stagingfrom
fix/selected-edge-z-order

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • A highlighted edge gets cut in half where an unselected edge crosses it, as reported by Theo.
  • An edge's z came from the nesting depth of the container it belongs to, and a highlighted edge kept that depth like any other. A top-level edge sits at EDGE_Z_BASE; an edge one container deeper sits above it — so the deeper, unselected line paints straight through the highlight.
  • A highlighted edge (selected, or connected to the selected card) now takes the top tier of the edge band. Depth only ever ordered edges against each other, and once one is picked out, being drawn whole matters more than which container it came from.

The tier deliberately stays inside the band, below the cards. There's a comment at the call site recording that highlighted edges were elevated over cards once before and drew across the chrome of their own endpoints. So ordinary edges give up the top of the band (EDGE_Z_DEPTH_MAX, 18) rather than the band being widened into the cards. EDGE_Z_MAX (20) is untouched, so the in-flight connection line still sits above everything.

Resulting order, unchanged either side of the new tier: container bodies 0… → ordinary edges 10…18highlighted edges 19 → in-flight line 20 → cards 21+ → container children 1000 → connection picker 2000.

Type of Change

  • Bug fix

Testing

New unit tests on canvas-layers, pinning both directions of the invariant — that a highlighted edge beats every ordinary one at any depth, and that it stays under the cards, getBlockZIndex, and container children. Two of them fail on the old code (expected 10 to be less than 10 — the highlighted edge tied with an ordinary top-level one).

Also pinned: ordinary edges still order by depth, every edge still clears the container body it crosses, and the in-flight line still tops the band.

One honest note on a pre-existing limit the tests now document. The band is fixed, so past its ceiling every edge saturates at the deepest tier and no longer clears a container nested that far. That was already true — the old cap was EDGE_Z_MAX, so it broke past depth 10 — and this change moves the ceiling from depth 10 to depth 8. Nothing in the editor nests remotely near either.

Full workflow-renderer suite green (70), type-check and lint clean across all 23 packages.

Not verified on a running canvas — this is layering, so it's worth a look at a selected edge crossing a nested one before merging.

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)

An edge's z came from the nesting depth of the container it belongs to, and a
highlighted edge kept that depth like any other. A line one level deeper
therefore sat above it and painted straight through the highlight, cutting it
in half wherever the two crossed.

Give a highlighted edge — selected, or connected to the selected card — the top
tier of the edge band instead. Depth only ever ordered edges against each
other, and once the user has picked one out, being drawn whole matters more
than which container it came from.

The tier stays inside the band, below the cards, deliberately: highlighted
edges were elevated over the cards once before and drew across the chrome of
their own endpoints. A line belongs behind cards, knobs and the action-bar
swell whether or not it is highlighted, so ordinary edges give up the top of
the band rather than the band being widened into the cards.
@vercel

vercel Bot commented Aug 12, 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 12, 2026 10:20pm

Request Review

@cursor

cursor Bot commented Aug 12, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Canvas rendering and z-index only; no auth, data, or execution paths. Behavior is covered by new unit tests.

Overview
Fixes workflow canvas layering where highlighted edges (selected, tied to a selected block, or open in the editor) could be drawn under a deeper nested ordinary edge, splitting the highlight visually.

getEdgeZIndex now accepts { isHighlighted } and assigns highlighted edges a fixed tier (EDGE_Z_HIGHLIGHTED, 19) above depth-ordered ordinary edges (capped at EDGE_Z_DEPTH_MAX, 18) while still below cards and the in-flight connection line (EDGE_Z_MAX, 20). Edge z-index in workflow.tsx uses the same highlight rules, including when the editor panel tab/block changes; the pending-connect preview line is elevated as highlighted.

New edge-highlight helpers (isEdgeHighlighted, isEdgeConnectedToEditor) replace duplicated predicates in workflow-edge, workflow-block (handle knobs), and the canvas so stroke, knobs, and z-order stay in sync.

Adds canvas-layers.test.ts to lock the z-index invariants.

Reviewed by Cursor Bugbot for commit 7496c23. Configure here.

It renders highlighted — its data carries `isConnectedToSelection` — but it was
the one call site left taking a depth tier, so the line being drawn could be
crossed by an ordinary edge in a deeper container. Highlighted now means
elevated with no exception.

Also drop the export on the highlighted tier: nothing outside the module reads
it, and the band's tiers are an implementation detail of `getEdgeZIndex`.
@greptile-apps

greptile-apps Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR centralizes edge-highlight detection and reserves a z-index tier so highlighted workflow edges render above ordinary edges while remaining below cards.

  • Adds shared helpers for selected-node, selected-edge, and editor-connected highlighting.
  • Assigns highlighted edges z-index 19 and caps ordinary depth-based edges at 18.
  • Adds unit coverage for ordering across edge, card, container-child, and in-flight connection tiers.

Confidence Score: 5/5

The PR appears safe to merge because no blocking failure remains in the eligible follow-up scope.

No blocking failure remains.

Important Files Changed

Filename Overview
packages/workflow-renderer/src/canvas-layers.ts Reserves z-index 19 for highlighted edges and confines ordinary depth-based edges to tiers 10–18.
packages/workflow-renderer/src/canvas-layers.test.ts Covers highlighted-edge precedence and the surrounding canvas-layer invariants.
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx Computes edge highlighting from node, edge, and editor state before assigning render z-index.
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/utils/edge-highlight.ts Centralizes the highlight and editor-connectivity predicates used by canvas consumers.
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-edge/workflow-edge.tsx Adopts the shared predicate for edge highlight rendering.
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/workflow-block.tsx Uses the shared predicate to keep endpoint-knob highlighting aligned with connected edges.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart BT
  Containers[Container bodies: 0–9]
  Ordinary[Ordinary edges: 10–18]
  Highlighted[Highlighted edges: 19]
  InFlight[In-flight connection: 20]
  Cards[Cards: 21+]
  Children[Container children: 1000]
  Picker[Connection picker: 2000]
  Containers --> Ordinary --> Highlighted --> InFlight --> Cards --> Children --> Picker
Loading

Reviews (3): Last reviewed commit: "fix(workflow): give the edge highlight o..." | Re-trigger Greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

Comment thread apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx
The z-index elevation I added checked canvas selection only, while the edge
darkens for panel focus too — a block open in the editor lights its edges, and
those stayed depth-tiered, so an ordinary edge could still cut through the
highlight. The bug I set out to fix, on the path I had not covered.

The condition already existed in two places and the second one carries a comment
saying it must mirror the first exactly, because a knob checking fewer
conditions than the line leaves a dark line running into a light knob. Adding
the z would have made a third copy, and the finding here is what the third copy
gets you.

One predicate now, in `edge-highlight`, used by the line, the knobs, and the z.
The canvas subscribes to the panel store rather than reading `getState()`, since
the z has to be recomputed when the open block changes.
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

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

✅ Bugbot reviewed your changes and found no new issues!

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

Reviewed by Cursor Bugbot for commit 7496c23. Configure here.

@waleedlatif1
waleedlatif1 merged commit e56b288 into staging Aug 12, 2026
30 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/selected-edge-z-order branch August 12, 2026 22:28
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