Skip to content

[Maintainer] Snap and cancel MEP handle drags in Select mode - #1238

Merged
Aymericr merged 3 commits into
mainfrom
cursor/mep-handle-snapping-14a6
Nov 9, 2026
Merged

Aymericr merged 3 commits into
mainfrom
cursor/mep-handle-snapping-14a6

Conversation

@Aymericr

@Aymericr Aymericr commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

What does this PR do?

Follow-up to #1237 (merged as cad92aac from head 113206bc), which finished #1236's port of @sudhir9297's community PR #1115. The final independent review of 113206bc asked for changes: one P2 (also the Codex bot's P2 on #1237), two P3s and two nits. These three commits fix the P2, one P3 and the docs nit. They also add the regression test that #1236's duct offset hardening was missing.

  • MEP handle drags snap in Select mode, and Escape cancels them (366bbea0, review P2, E-004 and E-005). The snap helpers resolve through the interaction scope. In Select mode no MEP handle claimed a scope, so every snapping mode read as off. The pipe fitting and refrigerant line drags stopped snapping when [Maintainer] Keep connected MEP edits from splitting joints #1237 moved them from the Shift bypass to the snap modes. The duct fitting, duct run and pipe run handles on main did not snap in Select mode either.
    • Each drag now claims a handle-drag scope for its node (shared/handle-drag-scope.ts), and the mode follows the kind's snap profile, as in the build tools. Fitting moves and resizes use the item modes, which default to Lines. Run and lineset point and arrow drags use the polygon modes, which default to Grid. Turn and roll arcs use the rotation modes, which default to 45° steps. Shift cycles the mode during the drag.
    • A fitting arrow move in Lines mode slides freely, since there is nothing on its axis to align to. Shift to Grid gives grid steps. Before [Maintainer] Keep connected MEP edits from splitting joints #1237, the pipe fitting arrow stepped on the grid by default.
    • Fitting sizes step by 0.25 in for pipe and 1 in for duct in Grid or Lines mode, since a size has no alignment lines. Off, or holding Alt, sizes freely. Holding Alt also turns and rolls freely, and no longer cycles a fitting's rotation axis mid-drag.
    • Escape, or ⌘Z/Ctrl+Z mid-drag, cancels the drag. Both go through tool:cancel. The scene is left unchanged, the selection stays, and the trailing pointer-up does nothing. Before, nothing consumed the cancel, so either key cleared the selection mid-drag instead.
    • The plan view's run point and segment drags claim the same scopes (floorplanAffordanceReshapeScope).
    • The HUD titles a run point drag "Edit" and an arrow move "Move", followed by the kind's name, and shows the snap mode. Turn and size drags keep their existing HUDs. During a run point drag the HUD keeps "Alt: Detach the joint" on screen. The string is new, and its es, fr, ja and zh-CN drafts are machine-written and marked fuzzy for review.
    • wiki/architecture/interaction-scope.md documents the handle-drag claim. It also lists the Shift bypasses that remain outside MEP: the polygon-centroid drag, the building and elevator move tools, and nine roof-accessory move tools.
  • Agent contracts at 1.1.2 (85e96a6b, review P3). pipe_grade gained the pipe_connection_split refusal in [Maintainer] Keep connected MEP edits from splitting joints #1237.
  • Duct offset refusal test (fea76bc6). After the Tooling review on [Maintainer] Connected duct and pipe editing, ported from #1115 #1236, eccac50e replaced the non-null assertion on planElbowAtPort in duct-segment/edit-operation.ts with a duct_offset_angle refusal, but added no test. The new test stubs a missing bend plan: editDuct refuses and leaves the scene unchanged.

A correction to #1237's description, which the review caught: when a connected edit cannot stay welded, the move tools and handles hold the last welded frame, and releasing places that frame. Nothing is placed only when no welded frame was ever shown, as in #1237's How-to-test step 2.

Still open, not changed here

  • Review P3: the duct arrow slide (duct-segment/selection.tsx) holds at the last welded frame even where release could reroute through planRunTranslationOffsets. The pipe arrow move and the duct ghost move try the reroute first. This affects few cases.
  • Review nit: rotating a hosted node with the registry move tool keeps previewing when the follow fails, while the drop refuses.
  • Bugbot "Vertical collar draw blocks next segment", rated P3 by the reviewer, who prefers applying the collar's vertical route to the first segment only. Bugbot "Fixture start clears chosen waste grade" and "Snapped grade connect fails with wrong message" are answered in [Maintainer] Keep connected MEP edits from splitting joints #1237.
  • The pipe fitting move tool has no grade guard.
  • The MEP handles cancel through tool:cancel. They are not registered with the editor's gesture owner (lib/gesture-lifecycle.ts), which useHandleDrag uses but which @pascal-app/editor does not export.

The connected editing these drags belong to is @sudhir9297's work from #1115. Next owner: Maintainer.

How to test

  1. In Select mode, select a pipe fitting and drag a move arrow. The HUD names the move and reads "Snapping: Lines", and the fitting slides freely. Press Shift until it reads Grid: the fitting steps by the grid size.
  2. Drag the fitting's turn arc. It turns in 45° steps, and holding Alt turns it freely. Drag the size handle: the diameter steps by 0.25 in, and holding Alt sizes it freely. Do the same on a duct fitting, where sizes step by 1 in.
  3. Drag a point of a pipe or duct run. The HUD names the edit and reads "Snapping: Grid", "Alt: Detach the joint" and "Esc: Cancel", and the point steps by the grid. Press Escape mid-drag: the run snaps back, the selection stays, and releasing the mouse places nothing. ⌘Z mid-drag does the same and does not undo the previous edit.
  4. In the plan view, drag a pipe point or a duct segment. It steps by the grid, and Shift cycles the mode.

Automated checks on fea76bc6:

  • bun run ci passed locally on the same tree (00358792), before the commits were moved onto current main, whose tree equals [Maintainer] Keep connected MEP edits from splitting joints #1237's head. That covers lint, i18n, skills, type-check, all package tests, the production build and the production-server smoke test. Test counts were core 7,073, nodes 5,319, 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:
    • nodes pipe-fitting/selection.test.tsx mounts the real selection handles and drives them with pointer events:
      • the arrow move steps by the grid in Grid mode and slides freely in Lines and Off;
      • Escape cancels mid-drag;
      • the turn arc steps by 45°, and holding Alt frees it;
      • the size handle steps by 0.25 in under Grid and Lines, and sizes freely under Off.
    • nodes duct-segment/edit-operation.test.ts: the duct_offset_angle refusal when a bend cannot be planned.
    • editor helper-manager.test.tsx: which handle drags get the MEP HUD, its hints with "Alt: Detach the joint" lit while Alt is held, and the snap context per handle.
    • editor floorplan-registry-layer.test.ts: the plan view's move-path-point and move-segment scopes.

Screenshots / screen recording

Not added yet.

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
Open in Web Open in Cursor 

Note

Medium Risk
Touches core editor interaction scope, snapping, and MEP drag commit/cancel paths across many selection affordances; behavior changes are user-visible but covered by new tests.

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

The duct and pipe fitting, run and refrigerant line handles read the snap
modes, but in Select mode nothing claimed a scope, so every mode read as
off. Each drag now claims a handle-drag scope (shared/handle-drag-scope.ts):
fitting moves and resizes resolve the item context, run point and segment
drags the polygon context, and rotate and roll arcs the rotation context.
Escape and a mid-drag undo cancel the drag through tool:cancel instead of
leaving it live. The plan view's run point and segment drags claim the
same scopes.

Fitting sizes step in either snapping mode, since a size has no alignment
lines to pull to; held Alt turns and sizes freely, and no longer cycles
the fitting's rotation axis mid-drag. The HUD names the MEP gesture and
keeps "Alt: Detach the joint" on screen during a run point drag.
pipe_grade gained the pipe_connection_split refusal, so hosts that pin a
contract revision for long turns see a new one.
editDuct refuses with duct_offset_angle and writes nothing when
planElbowAtPort has no plan for one of the four corners, where it used to
dereference the missing plan.
@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-09T13:20:59.778236Z fea76bc 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.

@Aymericr
Aymericr merged commit 23f6478 into main Nov 9, 2026
4 checks passed
@Aymericr
Aymericr deleted the cursor/mep-handle-snapping-14a6 branch November 9, 2026 15:08
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