Skip to content

[Maintainer] Restore joined MEP runs on Alt detach and drag cancel - #1240

Merged
Aymericr merged 8 commits into
mainfrom
cursor/mep-drag-cancel-followups-14a6
Nov 9, 2026
Merged

Aymericr merged 8 commits into
mainfrom
cursor/mep-drag-cancel-followups-14a6

Conversation

@Aymericr

@Aymericr Aymericr commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

What does this PR do?

Follow-up to #1238, merged by @Aymericr as 23f64785 from head fea76bc6. That was the last of the maintainer PRs (#1236, #1237, #1238) porting @sudhir9297's connected duct and pipe editing from #1115. The independent review of fea76bc6 requested 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.

  • Joined runs go back when a drag detaches or comes back to its start (bcb861e4; review P2 Feat/builder modes #1, P3 Feat/cc and levels #3 and nit Feat/doors #9).
    • Some drags preview by writing the scene: the lineset and liquid-line handles, the pipe and duct fitting moves, and the plan view's run point drag. In them, a follower stayed where an earlier frame put it once a later frame left it out. That happened when Alt was held to detach the joint, or when the drag came back to a zero delta, which connectivity leaves unwritten.
    • In 3D, a lineset end dragged with Alt and then cancelled with Escape left the joined lineset displaced. Released instead, it took one undo step, and undo restored only the dragged lineset. The lineset tool draws every segment as its own node, so every interior joint of a drawn run has a follower.
    • shared/follower-frames.ts writes each such follower back to its drag-start fields, and the refrigerant drag's finish always reverts every connection.
    • The pipe and duct point drags preview through live overrides. They now drop the overrides of nodes the current frame no longer moves, instead of showing the follower at its old position until release.
  • MEP handle drags run under the editor's gesture owner (43f4b7d3; P3 Feat/import and manipulate image scans #2 and nit Feat/interactions improvements #6).
    • useHandleDragScope starts each drag with beginGesture, which @pascal-app/editor now exports. Any history command, a mode, level or selection change, the node's deletion, or the handles unmounting now cancels the drag.
    • Before, an undo issued outside the keyboard landed under the live drag, and the release then committed over it. Unmounting left the scope claimed, history paused and window listeners writing the scene. Keyboard ⌘Z mid-drag still only aborts the drag, as in [Maintainer] Snap and cancel MEP handle drags in Select mode #1238.
    • A browser pointercancel now cancels the drag at all ten sites instead of committing it, as useHandleDrag does.
  • Held Alt frees the move drags (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".
  • Tests and docs (nit Feat/ux improvements #10, plus two nits from the re-review of f3b381d1).
    • The new rendered tests mount the real handles: lineset ends, the duct point drag, the pipe and duct fitting arrows, the duct fitting resize, and the pipe and duct run slides (49c84c19, 0f529c01). Between them they cover connected followers, undo, Alt, pointercancel and unmounting. The plan-view point drag tests call the lineset's and duct's registered move-path-point affordance directly, so they don't exercise the plan view's dispatcher.
    • Four of the ten pointercancel sites 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.md records the gesture-owner claim.
    • The onCancel doc in gesture-lifecycle.ts said it "Never writes the scene", but every MEP drag reverts its paused preview writes there. It now says onCancel records no history, because undo and redo cancel the gesture before they jump (e65a11d9).

Two corrections to #1238's description, from the review (#11):

  • Escape did not leave the scene unchanged for a lineset or liquid line dragged with Alt; that case is fixed here.
  • "There is nothing on its axis to align to" was inaccurate: the ghost move tool aligns in Lines mode. The arrow move neither aligns nor steps there; see P3 Feat/wall merging #4 below.

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.

    • f3b381d1 made the arrow step on the grid in Lines mode too. Codex flagged that as a P1: E-004 gates grid steps on isGridSnapActive(), and the HUD would read "Snapping: Lines" while the arrow quantized to the grid. 44adc1f8 reverts it, so the arrow behaves as on main.
    • The fix that fits E-004 is for the arrow to align in Lines mode, as the ghost move tool does. That is a larger change than this PR.
  • 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:

    • A slide that only the reroute can make is unreachable.
    • When an end moves at least two fitting legs plus 5 cm, the preview shows the joined runs following, while the release builds elbows and connectors instead.

    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), and isGridSnapActive() 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 useScene on every frame, which E-007 and wiki/architecture/tools.md rule 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:

    • In 3D, a cancelled handle drag swallows only a click within 300 ms, the same window the editor's useHandleDrag uses.
    • In the plan view, the dispatcher's Escape cancel (floorplan-registry-layer.tsx) swallows none.

    This happens on main too.

  • 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

  1. Draw a two-segment lineset run, select one segment and drag the shared end's arrow: the other segment follows. Hold Alt: the end moves alone and the other segment returns to where it was. Press Escape and release: both segments are back where they started. Repeat, but release with Alt held: there is one undo step, the other segment never moved, and undo puts the end back. Dragging the shared end's point in the plan view behaves the same way.
  2. Drag the end of a lineset, fitting or run, then drag it back onto its start without releasing. Every joined node is back where it was.
  3. In the plan view, drag the free end of a straight duct whose other end sits on an elbow: the elbow turns to follow. Hold Alt: the elbow turns back and the end moves alone. Release: the elbow keeps its original turn.
  4. Press Shift until the HUD reads "Snapping: Grid". Drag a pipe fitting's move arrow: it steps by the grid. Hold Alt: it slides freely. Do the same on a duct fitting, and on a pipe or duct run's center arrow. In the default Lines mode, the fitting arrow slides freely, as on main.

Automated checks:

  • bun run ci passed locally on this head, 0f529c01 (exit 0).
    • Biome, the i18n and skills checks, the root i18n and proxy tests and the production-server smoke test always run outside Turbo, so they ran fresh.
    • Turbo also ran the nodes build, both apps' type-checks and builds, and the editor, nodes and app test suites fresh. It replayed the other type-checks, package tests and builds from its cache. Turbo caches only tasks that succeed, and those inputs are unchanged since the earlier passing runs.
  • Test counts were core 7,073, nodes 5,337, editor 2,867, viewer 1,350, MCP 1,523, CLI 139, IFC converter 106, geometry-script 64 and app 78, with 0 failures.
  • New tests that fail on 23f64785's source and pass here (the re-review re-ran these on the base):
    • nodes lineset/selection.test.tsx mounts the real handles on two joined linesets:
      • Alt then Escape;
      • Alt then release, followed by undo;
      • runUndo() mid-drag cancels the drag and undoes the earlier edit, and the later release commits nothing;
      • after a pointercancel or an unmount mid-drag, the scope is idle, inputDragging is false, history is tracking again and there is no history entry.
    • nodes shared/path-point-affordance.test.ts:
      • a plan-view lineset end drag puts the joined lineset back on an Alt frame and on a zero-delta frame;
      • on a plan-view duct end drag, an Alt frame turns a re-aimed elbow back.
    • nodes 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.
    • nodes pipe-fitting/selection.test.tsx:
      • Alt slides the arrow freely in Grid mode, and a pointercancel drops the drag;
      • a joined pipe run goes back when the slide returns to the start.
  • New tests from 49c84c19 and 0f529c01. Each was checked by reverting its fixed line at this head, one line at a time, and each revert fails exactly that test:
    • nodes duct-fitting/selection.test.tsx (new file):
      • Alt slides the arrow freely in Grid mode, and a pointercancel drops the drag. It fails when the arrow ignores Alt, and when pointercancel commits the move;
      • a joined duct goes back when the slide returns to the start. It fails when the move writes without its follower frame;
      • a pointercancel drops a resize. It fails when pointercancel commits the resize.
    • nodes duct-segment/selection.test.tsx and the new pipe-segment/selection.test.tsx, on the run center arrow:
      • Alt slides it freely in Grid mode. It fails when the slide ignores Alt;
      • a pointercancel drops the slide. It fails when pointercancel commits the slide.
    • Two more duct fitting tests pin behavior unchanged from 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 to 23f64785's version; that file is unchanged on main.

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

  • Holding Alt lights up the HUD's "Alt: Detach the joint" row, but B stays on A's dragged corner.
  • Escape restores both lines.
  • A second drag is released with Alt held: B is committed moved. Ctrl+Z puts both back.

lineset-alt-detach-before-plan.mp4

After, on this branch (45 s).

  • Lineset A's corner end is dragged and Lineset B follows.
  • Holding Alt puts B back at its start, and the HUD's "Alt: Detach the joint" row lights up. Releasing Alt rejoins B; holding Alt again puts it back.
  • Escape restores both lines. The plan view drops the selection on that release, as on main, so A is selected again.
  • A second drag is released with Alt held: only A's end moves. Ctrl+Z puts it back.

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

  • I've tested this locally with bun dev
  • My code follows the existing code style (run bun check to verify)
  • I've updated relevant documentation (if applicable)
  • This PR targets the main branch

To show artifacts inline, enable in settings.

Open in Web Open in Cursor 

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.

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.
@Aymericr Aymericr added the bot:maintainer label Nov 9, 2026 — with Cursor
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-09T15:39:46.372061Z f3b381d PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 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".

Comment on lines +588 to +590
!event.altKey && (isGridSnapActive() || isMagneticSnapActive())
? useEditor.getState().gridSnapStep
: 0

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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.

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

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ 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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Fix in Cursor Fix in Web

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.
@Aymericr
Aymericr merged commit 7999593 into main Nov 9, 2026
4 checks passed
@Aymericr
Aymericr deleted the cursor/mep-drag-cancel-followups-14a6 branch November 9, 2026 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants