Skip to content

fix(autolayout): keep branches in stable rows across layers#5877

Open
TheodoreSpeaks wants to merge 1 commit into
stagingfrom
fix/auto-layout-block-ordering
Open

fix(autolayout): keep branches in stable rows across layers#5877
TheodoreSpeaks wants to merge 1 commit into
stagingfrom
fix/auto-layout-block-ordering

Conversation

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator

Summary

  • fixes parallel branches alternating between rows on auto layout: overlap resolution ran once after all layers were positioned, so tied Y values were re-broken per layer by block insertion order, flipping branches between rows and crisscrossing edges
  • resolve vertical overlaps per layer, before the next layer derives its Y from predecessors — each branch now inherits its resolved row and stays in it
  • replaces the whole-graph retry loop (up to 20 re-sort passes) with a single sort + push-down pass per layer
  • adds regression tests for row stability under interleaved block insertion order

Type of Change

  • Bug fix

Testing

Autolayout + diff-engine suites pass (48 tests); new regression test fails on the old code. Lint + strict API validation 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 Jul 23, 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 Jul 23, 2026 3:11am

Request Review

@cursor

cursor Bot commented Jul 23, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Localized autolayout positioning change with targeted tests; no auth, data, or API surface impact.

Overview
Fixes workflow auto-layout where parallel branches swapped rows between layers, causing crisscrossing edges. Overlap handling used to run once over the whole graph after every layer was placed, so tied Y values were re-sorted per layer by block insertion order.

Overlap resolution now runs inside the per-layer loop via resolveLayerOverlaps: each layer gets a single sort-and-push-down pass before the next layer reads predecessor Y positions, so a branch keeps the same row down the graph. The old whole-graph retry loop (up to MAX_OVERLAP_ITERATIONS) and its import from core.ts are removed.

Adds core.test.ts regression coverage for stable row order under interleaved insertion and for no vertical overlaps within a layer.

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

@greptile-apps

greptile-apps Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR keeps parallel autolayout branches in stable rows across layers. The main changes are:

  • Resolves vertical overlaps immediately after positioning each layer.
  • Replaces the whole-graph retry loop with one sorted push-down pass per layer.
  • Adds tests for stable branch ordering and same-layer overlap prevention.

Confidence Score: 5/5

This looks safe to merge.

  • The forward pass uses each node's updated position, so cascading same-layer overlaps are resolved.
  • Each successor is positioned only after its predecessor layer has been resolved.
  • No blocking issues were found in the changed code.

Important Files Changed

Filename Overview
apps/sim/lib/workflows/autolayout/core.ts Moves overlap resolution into the layer loop and uses a deterministic forward push-down pass.
apps/sim/lib/workflows/autolayout/core.test.ts Adds coverage for stable branch rows and the same-layer non-overlap invariant.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Assign graph layers] --> B[Position current layer]
  B --> C[Sort nodes by Y]
  C --> D[Push overlapping nodes down]
  D --> E{More layers?}
  E -- Yes --> F[Derive successor Y from resolved predecessors]
  F --> B
  E -- No --> G[Normalize positions]
Loading

Reviews (1): Last reviewed commit: "fix(autolayout): keep branches in stable..." | Re-trigger Greptile

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