Skip to content

fix(autolayout): rescue new notes from blocks they were created on top of - #6680

Merged
j15z merged 1 commit into
stagingfrom
fix/stop-note-overlapping-start-node
Aug 13, 2026
Merged

fix(autolayout): rescue new notes from blocks they were created on top of#6680
j15z merged 1 commit into
stagingfrom
fix/stop-note-overlapping-start-node

Conversation

@j15z

@j15z j15z commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Targeted layout's note-overlap rescue judged "did this note overlap that block before?" against its own post-edit input — which already contains a newly added note at its (0,0) placeholder. A copilot-added note on a fresh workflow therefore "pre-existed" its overlap with the start block (also at (0,0)) and was preserved as intentional, shipping on top of the start node.
  • applyTargetedLayout now takes an optional previousBlocks (pre-edit snapshot) and uses it as the rescue baseline; a note absent from that snapshot is always eligible for relocation. Defaults to the old behavior when not passed.
  • The copilot edit-workflow tool and the client diff engine pass the pre-edit state they already diff against, so the accepted result and the diff preview agree.

Type of Change

  • Bug fix

Testing

  • New tests: a note created on top of the start block relocates below the flow; a pre-existing note arrangement survives an unrelated edit
  • Autolayout/diff/edit-workflow suites pass (176 tests), type-check clean, lint + audits 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)

🤖 Generated with Claude Code

@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 10:25pm

Request Review

@cursor

cursor Bot commented Aug 13, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Layout-only change with backward-compatible default (previousBlocks falls back to current blocks); limited to note positioning after copilot edits and diff preview.

Overview
Targeted autolayout’s note-overlap rescue used the post-edit block map as the “before” baseline, so a copilot-added note at its (0,0) placeholder looked like it had always overlapped the start block (also at origin) and was left on top of it.

applyTargetedLayout now accepts optional previousBlocks (pre-edit snapshot) for that baseline; notes missing from the snapshot are always relocated. resolveNoteOverlaps is wired to use this baseline instead of the current blocks input.

The copilot edit-workflow tool and the client diff engine pass the pre-edit state they already use for diffs (workflowState.blocks / mergedBaseline.blocks), so saved workflows and diff previews match on note placement.

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

@greptile-apps

greptile-apps Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR corrects targeted autolayout’s note-overlap baseline so newly created notes can be moved away from underlying blocks while intentional existing arrangements remain intact.

  • Adds an optional pre-edit block snapshot to targeted layout.
  • Supplies the snapshot from Copilot workflow editing and the client diff engine.
  • Adds regression tests for newly created and pre-existing notes.

Confidence Score: 5/5

The PR appears safe to merge, with no actionable correctness or security defects identified.

The supplied snapshots remain distinct from the cloned edited state, and both changed integration paths provide complete baselines that support the intended new-note and pre-existing-note behavior.

Important Files Changed

Filename Overview
apps/sim/lib/workflows/autolayout/targeted.ts Introduces the optional pre-edit snapshot and forwards it to note-overlap resolution without changing legacy caller behavior.
apps/sim/lib/copilot/tools/server/workflow/edit-workflow/index.ts Passes the unmodified workflow input as the baseline when laying out Copilot-generated edits.
apps/sim/lib/workflows/diff/diff-engine.ts Uses the diff engine’s comparison baseline for overlap classification so preview and accepted positions remain consistent.
apps/sim/lib/workflows/autolayout/targeted.test.ts Covers relocation of a newly created note and preservation of an existing intentional arrangement.

Sequence Diagram

sequenceDiagram
  participant Edit as Workflow edit
  participant Before as Pre-edit blocks
  participant Layout as Targeted layout
  participant Rescue as Note-overlap rescue
  Edit->>Before: Capture existing workflow state
  Edit->>Layout: Submit edited blocks and previousBlocks
  Layout->>Rescue: Compare resulting overlaps with previousBlocks
  alt Note absent or overlap newly introduced
    Rescue-->>Layout: Relocate note below flow
  else Overlap existed before edit
    Rescue-->>Layout: Preserve note position
  end
Loading

Reviews (1): Last reviewed commit: "fix(autolayout): rescue new notes from b..." | Re-trigger Greptile

@j15z
j15z merged commit 44524d1 into staging Aug 13, 2026
30 checks passed
@j15z
j15z deleted the fix/stop-note-overlapping-start-node branch August 13, 2026 22:56
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