fix(autolayout): targetted autolayout heuristic restored#3536
fix(autolayout): targetted autolayout heuristic restored#3536icecrasher321 merged 9 commits intofeat/mothership-copilotfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview Improves subflow move/extract behavior by resetting positions when inserting into a container, converting relative→absolute positions on extraction, and adding a post-processing pass to drop scope-crossing/dangling edges once final Refines targeted layout heuristics (better anchor selection; treat only non-finite coordinates as invalid) and adds height estimation for unmeasured blocks to reduce overlaps. Updates diff-generation to preserve server-assigned UUIDs, preserve positions when scope is unchanged, and standardize on targeted layout. Hardens socket DB writes by switching block/edge/subflow inserts to upserts ( Written by Cursor Bugbot for commit f483723. Configure here. |
Greptile SummaryThis PR restores and improves the targeted autolayout heuristic for copilot-driven workflow edits. Instead of running a full Key changes across the files:
The one dead-code issue ( Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Client
participant EditWorkflowTool as edit-workflow/index.ts
participant Engine as engine.ts (applyOperationsToWorkflowState)
participant Operations as operations.ts
participant DiffEngine as diff-engine.ts (WorkflowDiffEngine)
participant TargetedLayout as autolayout/targeted.ts
Client->>EditWorkflowTool: copilot edit request
EditWorkflowTool->>Engine: applyOperationsToWorkflowState(ops)
loop Each operation
Engine->>Operations: handleInsertIntoSubflow / handleExtractFromSubflow / etc.
Operations-->>Engine: modifiedState (position reset to 0,0 for subflow inserts)
end
Engine->>Engine: removeInvalidScopeEdges(modifiedState)
Engine->>Engine: generateLoopBlocks / generateParallelBlocks
Engine-->>EditWorkflowTool: { state, validationErrors }
EditWorkflowTool->>EditWorkflowTool: compute blocksNeedingLayout\n(new blocks + parent-changed blocks with pos 0,0)
alt blocksNeedingLayout.length > 0
EditWorkflowTool->>TargetedLayout: applyTargetedLayout(blocks, edges, {changedBlockIds})
TargetedLayout->>TargetedLayout: selectBestAnchor (edge-neighbor preference)
TargetedLayout->>TargetedLayout: layoutGroup per scope
TargetedLayout-->>EditWorkflowTool: repositioned blocks
end
EditWorkflowTool->>Client: persist final workflow state
Note over DiffEngine: Client-side path (applyProposedState)
Client->>DiffEngine: applyProposedState(proposedState)
DiffEngine->>DiffEngine: id-map: preserve UUIDs, mint for non-UUID IDs
DiffEngine->>DiffEngine: merge: keep existingBlock.position for unchanged blocks
DiffEngine->>DiffEngine: compute blocksNeedingLayout (new + parent-changed)
DiffEngine->>TargetedLayout: applyTargetedLayout(finalBlocks, edges, {changedBlockIds})
TargetedLayout-->>DiffEngine: repositioned blocks
DiffEngine-->>Client: merged + laid-out workflow state
Last reviewed commit: fc9c9c1 |
apps/sim/lib/copilot/tools/server/workflow/edit-workflow/index.ts
Outdated
Show resolved
Hide resolved
|
bugbot run |
|
@greptile |
apps/sim/lib/copilot/tools/server/workflow/edit-workflow/operations.ts
Outdated
Show resolved
Hide resolved
|
bugbot run |
|
@greptile |
|
bugbot run |
|
bugbot run |
|
bugbot run |
|
bugbot run |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Summary
Restore targeted autolayout for copilot edits to workflows.
Type of Change
Testing
Tested manually
Checklist