Repository navigation
[Maintainer] Restore joined MEP runs on Alt detach and drag cancel - #1240
Conversation
Drags that preview by writing the scene (the refrigerant line handles, the fitting moves and the plan-view run point drag) left a follower where an earlier frame put it when a later frame left it out: held Alt detached the joint, or the drag came back to a zero delta, which connectivity leaves unwritten. The refrigerant drag then also skipped the revert on a detached release or Escape, so the joined line stayed displaced, and the plan-view dispatcher committed the stale follower. createFollowerFrames restores each such follower to its drag-start fields, and the refrigerant finish always reverts every connection. The pipe and duct point drags, which preview through live overrides, now drop the overrides of nodes the current frame no longer moves.
The selection handles claimed the handle-drag scope themselves and only listened for Escape, so an undo or redo from the toolbar, a mode, level or selection change, the node's deletion or the handles unmounting left the drag live with history paused, and a pointercancel committed it. useHandleDragScope starts each drag with beginGesture, which cancels it on all of those, and every handle drag maps pointercancel to a cancel. The editor exports beginGesture for kind packages.
The fitting arrow moves and the pipe and duct run slides stepped on the grid even with Alt held, while their rotations and resizes already took the raw cursor. Held Alt now slides the moves freely too, as E-004 has it; the run point drags keep Alt for detaching the joint.
The item snap mode defaults to Lines, where a fitting arrow move slid freely while the size handles stepped. Switching the persisted item mode to Grid to get steps also changes how every item places. The arrow move does not align to lines, so either snapping mode now steps it on the grid, as the resize does and as the pipe fitting arrow did before #1237; Off or held Alt slides freely.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f3b381d11d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| !event.altKey && (isGridSnapActive() || isMagneticSnapActive()) | ||
| ? useEditor.getState().gridSnapStep | ||
| : 0 |
There was a problem hiding this comment.
Gate grid quantization on Grid mode
When the item snap context is lines—the default—this condition still passes gridSnapStep to snap, so fitting arrows quantize to the grid while the HUD says Lines and perform no magnetic alignment. The interaction contract requires grid steps to be gated by isGridSnapActive(); either implement actual line alignment for magnetic mode or leave the movement unquantized. The same regression is duplicated in packages/nodes/src/pipe-fitting/selection.tsx:515-517.
AGENTS.md reference: AGENTS.md:L23-L24
Useful? React with 👍 / 👎.
E-004 gates grid steps on isGridSnapActive(). Stepping a fitting's position by the grid while the HUD reads Lines breaks that contract, so the arrow move goes back to stepping in Grid mode only and slides freely in Lines and Off, as on main. Aligning it along its axis in Lines mode, as the ghost move tool aligns, is left open. This reverts commit f3b381d.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 44adc1f. Configure here.
| const s = sampleAxis(axis, event.clientX, event.clientY, anchorWorld) | ||
| if (s === null) return null | ||
| const step = isGridSnapActive() ? useEditor.getState().gridSnapStep : 0 | ||
| const step = !event.altKey && isGridSnapActive() ? useEditor.getState().gridSnapStep : 0 |
There was a problem hiding this comment.
Fitting move doesn't step in Lines mode unlike resize
Medium Severity
The fitting arrow move computes the grid step using only isGridSnapActive(), which returns false in Lines mode (resolveSnapFlags('lines').grid is false). The resize handle in the same file uses isGridSnapActive() || isMagneticSnapActive() to step in both Grid and Lines modes. The PR description explicitly states this commit makes "Fitting arrow moves step in Lines mode" with "either snapping mode steps the arrow move on the grid, as the resize does," but the move step calculation doesn't include isMagneticSnapActive(), so it slides freely in Lines mode instead of stepping.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 44adc1f. Configure here.
… history Undo and redo cancel live gestures before they jump, so whatever onCancel does must stay out of history. The MEP handle drags revert their paused scene writes there before resuming history; the doc said onCancel never writes the scene, which beginGesture's public callers could not follow.
…red tests The duct fitting drag has its own implementation, and the pipe and duct run slides read Alt separately from the point drags, so reverting those lines left every test green. The new tests pin the fitting arrow's grid step and handle-drag scope, Alt and pointercancel on its move, a joined duct going back when the slide returns to the start, the free slide in Lines and Off, a cancelled resize, and Alt and pointercancel on the pipe and duct run slides.
A pointercancel on the duct run's center arrow drops the live preview, frees the scope and commits nothing. The run slide's cancel is the third site in duct-segment/selection.tsx; wiring it back to the release fails this test.


What does this PR do?
Follow-up to #1238, merged by @Aymericr as
23f64785from headfea76bc6. That was the last of the maintainer PRs (#1236, #1237, #1238) porting @sudhir9297's connected duct and pipe editing from #1115. The independent review offea76bc6requested changes with 11 numbered findings: one P2, four P3s and six nits. This PR fixes the P2, P3 #2 and #3, and nits #6, #7, #9 and #10, and corrects #11 below. P3 #4 was tried here and reverted. It stays open with the two carried-over items.bcb861e4; review P2 Feat/builder modes #1, P3 Feat/cc and levels #3 and nit Feat/doors #9).shared/follower-frames.tswrites each such follower back to its drag-start fields, and the refrigerant drag's finish always reverts every connection.43f4b7d3; P3 Feat/import and manipulate image scans #2 and nit Feat/interactions improvements #6).useHandleDragScopestarts each drag withbeginGesture, which@pascal-app/editornow exports. Any history command, a mode, level or selection change, the node's deletion, or the handles unmounting now cancels the drag.pointercancelnow cancels the drag at all ten sites instead of committing it, asuseHandleDragdoes.42ce9ca6; nit Feat/controls ux enhancement #7). The fitting arrow moves and the pipe and duct run slides ignored Alt in Grid mode, while their turns and resizes honoured it (E-004). Run point drags keep Alt for "Detach the joint".f3b381d1).49c84c19,0f529c01). Between them they cover connected followers, undo, Alt,pointercanceland unmounting. The plan-view point drag tests call the lineset's and duct's registeredmove-path-pointaffordance directly, so they don't exercise the plan view's dispatcher.pointercancelsites have no test: the pipe fitting resize, the duct point drag and roll, and the pipe point drag. With all four changed to commit on cancel, the nodes suite still passes.wiki/architecture/interaction-scope.mdrecords the gesture-owner claim.onCanceldoc ingesture-lifecycle.tssaid it "Never writes the scene", but every MEP drag reverts its paused preview writes there. It now saysonCancelrecords no history, because undo and redo cancel the gesture before they jump (e65a11d9).Two corrections to #1238's description, from the review (#11):
Still open, not changed here
P3 Feat/wall merging #4, tried and reverted. In the default Lines mode, a fitting's move arrow slides freely while its size handles step by a fixed size increment.
f3b381d1made the arrow step on the grid in Lines mode too. Codex flagged that as a P1: E-004 gates grid steps onisGridSnapActive(), and the HUD would read "Snapping: Lines" while the arrow quantized to the grid.44adc1f8reverts it, so the arrow behaves as onmain.P3 Feat/sidebar layers #5, carried over. The duct run arrow slide (
duct-segment/selection.tsx) holds at the last welded frame, but its release first tries the elbow-and-connector reroute (planRunTranslationOffsets). This has two effects:This dates from nodes: add MEP movement controls and DWV parity #438. The duct ghost move tool already previews the reroute first.
Nit Feat/roof element #8, carried over. Rotating a surface-hosted node with the registry move tool (
move-registry-node-tool.tsx) keeps previewing when the follow fails, while the drop refuses.The whole-run move tools ignore Alt (re-review nit; older than this series). The pipe and duct run move tools step whenever Grid mode is on (
pipe-segment/move-tool.tsx:180,duct-segment/move-tool.tsx:209), andisGridSnapActive()does not read Alt. So held Alt now frees a run's center arrow but not a move-tool move of the same run, which E-004 also covers.Per-frame scene writes (re-review, informational; from nodes: add MEP movement controls and DWV parity #438). The fitting, lineset and plan-view drags write
useSceneon every frame, which E-007 andwiki/architecture/tools.mdrule out; the duct and pipe point drags already preview through live overrides. The follower frames here build on that existing pattern, and moving these drags to live overrides is a follow-up.Selection lost on a late release, seen while recording. Releasing the button after Escape can clear the selection, because the click that follows reaches the canvas:
useHandleDraguses.floorplan-registry-layer.tsx) swallows none.This happens on
maintoo.From earlier rounds. Bugbot's "Vertical collar draw blocks next segment" (rated P3) is fixed in [Maintainer] Leave vertical routing after a riser drawn from a collar #1242 (open). The pipe fitting move tool has no grade guard.
The connected editing these drags belong to is @sudhir9297's work from #1115. Next owner: Maintainer.
How to test
main.Automated checks:
bun run cipassed locally on this head,0f529c01(exit 0).23f64785's source and pass here (the re-review re-ran these on the base):lineset/selection.test.tsxmounts the real handles on two joined linesets:runUndo()mid-drag cancels the drag and undoes the earlier edit, and the later release commits nothing;pointercancelor an unmount mid-drag, the scope is idle,inputDraggingis false, history is tracking again and there is no history entry.shared/path-point-affordance.test.ts:duct-segment/selection.test.tsx: holding Alt on a duct end drag drops the joined duct's live preview, and the release commits one step without moving it.pipe-fitting/selection.test.tsx:pointercanceldrops the drag;49c84c19and0f529c01. Each was checked by reverting its fixed line at this head, one line at a time, and each revert fails exactly that test:duct-fitting/selection.test.tsx(new file):pointercanceldrops the drag. It fails when the arrow ignores Alt, and whenpointercancelcommits the move;pointercanceldrops a resize. It fails whenpointercancelcommits the resize.duct-segment/selection.test.tsxand the newpipe-segment/selection.test.tsx, on the run center arrow:pointercanceldrops the slide. It fails whenpointercancelcommits the slide.main: in Grid mode the arrow claims a handle-drag scope and steps on the grid, and in Lines and Off it slides freely.Screenshots / screen recording
Both clips play the same scripted input in the plan view of the local dev server. The "after" clip runs this branch. The "before" clip runs this branch with
shared/path-point-affordance.ts, the file that drives this drag, swapped back to23f64785's version; that file is unchanged onmain.Before and after, plan view, lineset joint. Top row:
main. Bottom row: this PR. Left: dragging A's corner with Alt held. Right: just after releasing with Alt held.Top: main. Bottom: this PR. Left: dragging with Alt held. Right: released with Alt held
Before, on
main's plan-view drag (46 s).lineset-alt-detach-before-plan.mp4
After, on this branch (45 s).
main, so A is selected again.lineset-alt-detach-escape-undo-plan.mp4
Left: B follows the drag. Middle: with Alt held, B is back at its start. Right: released with Alt, only A's end moved
Checklist
bun devbun checkto verify)mainbranchTo show artifacts inline, enable in settings.
Note
Medium Risk
Touches core 3D/plan editing, scene history pausing, and live preview state across many MEP affordances; behavior is heavily tested but regressions in connected-run editing are possible.
Reviewed by Cursor Bugbot for commit 0f529c0. Bugbot is set up for automated code reviews on this repo. Configure here.