Skip to content

[Maintainer] Keep connected MEP edits from splitting joints - #1237

Merged
Aymericr merged 4 commits into
mainfrom
cursor/mep-editing-followups-14a6
Nov 9, 2026
Merged

Aymericr merged 4 commits into
mainfrom
cursor/mep-editing-followups-14a6

Conversation

@Aymericr

@Aymericr Aymericr commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

What does this PR do?

Follow-up to #1236, which ported @sudhir9297's community PR #1115 and was merged as 3a972b68 from head bbe4b501. These four commits fix the findings still open from the final independent review of #1236 (on 3c4ca5bb), plus one Bugbot finding that review confirmed. They were finished after the merged head, so they are not on main yet. This branch is main plus these four commits.

  • Connected edits stay welded or hold their last welded frame (d65823df, review P2). [Maintainer] Connected duct and pipe editing, ported from #1115 #1236 bounded the resolver's walk so that closed loops no longer hang. But when the walk ran out, or the followers could not all satisfy their pushes, the resolver returned the partial state and the move tools committed it. Take a chain of pipe, elbow, three-point L-shaped pipe, elbow and pipe: a diagonal move of the first pipe opened all four joints by 5–10 cm and stretched the L's far leg from 2.93 m to 14 m.
    • A run driven at both ends by a fitting that only echoes its far end now follows the driven end alone. That chain now stays welded, and the far leg keeps its 2.93 m.
    • resolveConnectivityUpdates now checks every snapshotted joint after solving. It returns null if any joint would open by more than 1 mm, for example when stretching a run whose U loops back to its own start corner. The move tools, selection handles and plan affordances then keep the last welded frame and place nothing on release, and pipe_grade refuses with pipe_connection_split.
  • Pipe fitting and refrigerant line drags follow the snap modes (68e6d9c0, review P3, E-004). These drags now read the grid, angle and magnetic snap modes instead of treating Shift as a snap bypass, as the duct fitting handles already do: moving, turning and resizing a selected pipe fitting, moving it with its ghost, dragging a refrigerant line end, and sliding a plan-view run segment. The Shift-bypass inventory in wiki/architecture/interaction-scope.md now lists only the polygon-centroid drag.
  • A vertical route rises to the panel's target without a pointer event (c27a1b27, Bugbot Medium "Vertical route ignores panel without pointer"). Before this, a riser drawn from a collar showed no target until the pointer moved, so Enter placed nothing. A target entered in the panel after the start click also left the old target in the preview.
  • The plan-view grade notice clears when the shown frame is placed (113206bc, review nit). It used to stay up until it timed out.

The connected editing these commits fix is @sudhir9297's work from #1115. Next owner: Maintainer.

Replies to the Bugbot threads still open on #1236 (not changed here)

  • High, "Fixture start clears chosen waste grade": the mechanism is confirmed. Starting a waste run at a trap or fixture collar copies the collar's grade into the remembered defaults, and a horizontal outlet is level. This follows Add connected duct and pipe editing with shared build controls #1115's rule, documented by pipe_connect, that a pipe leaves a fixed collar along the collar's axis. A conflicting grade is refused with a message and never written. Changing this is a design call, with two options: let a fixed horizontal collar take a first leg at the chosen grade, or level only the first leg and keep the user's grade in the defaults.
  • Medium, "Snapped grade connect fails with wrong message": overstated. Snapping accepts a collar up to 0.1 mm off the fall height, while the commit check allows a grade error of 1e-5 times the run length. On a 2 m run, they disagree only between 0.02 mm and 0.1 mm. In that window the pipe tool shows the preview's grade-conflict message, so the user still sees the right reason.
  • Medium, "Vertical collar draw blocks next segment": confirmed, though the message differs from Bugbot's description. Drawing from a vertical collar sets Route to Vertical in the remembered defaults, just as it sets size, material and grade. After the riser, the next vertical target is the riser's own end. The tool shows "Run must be at least 0.05 m", and clicks place nothing until Route or the target elevation changes. No geometry is written. Two options: switch to the horizontal route after a riser that started at a collar, or apply the collar's vertical route to its first segment only.
  • Still open from [Maintainer] Connected duct and pipe editing, ported from #1115 #1236: the pipe-fitting move tool has no grade guard.

How to test

  1. Build a chain of pipe, elbow, three-point L pipe, elbow and pipe. Agents and older scenes create multi-point runs; the drawing tools only draw two-point runs. Select the first pipe, press M, move it diagonally and place it. Every joint stays closed and the L's far leg keeps its length. On main, the joints open and the far leg stretches.
  2. Join a straight pipe and a U-shaped pipe at two elbows to make a closed loop, then drag the straight pipe's end point along its length. The handle stops at the last welded frame and releasing places nothing. pipe_grade with action: 'endpoint' refuses with pipe_connection_split.
  3. Select a pipe fitting and move, turn and resize it with grid snap on, then off. Holding Shift no longer bypasses snapping. Do the same for a refrigerant line end and a plan-view run segment.
  4. Use "Draw from collar" on a fixture or equipment collar that points up or down. The riser at the target elevation shows without moving the pointer, and Enter places it. After a start click in vertical routing, change "Target elevation above level" in the panel: the preview follows.
  5. In the plan view, drag a pipe point through a frame that would change a connected grade, then release on an allowed frame. The notice clears when the frame is placed.

Automated checks on 113206bc:

  • bun run ci passed locally. 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,313, editor 2,863, viewer 1,350, MCP 1,523, CLI 139, IFC converter 106, geometry-script 64 and app 78, with 0 failures.
  • New regression tests:
    • core services/port-connectivity.test.ts: "a fitting its own collars pull apart cannot follow" and "a loop back to the moved run refuses a drag that would pull its start corner off".
    • nodes shared/port-connectivity-pipe.test.ts: the L chain above, with real pipe kinds, diagonal and lifted moves.
    • nodes shared/run-move-connectivity.test.ts: "a transform the followers cannot follow keeps the last preview and commits nothing".
    • nodes agent-operations/pipe-grade.test.ts: the U-loop refusal, plus the notice clearing on placement.
    • editor distribution-run-tool.test.tsx: duct and pipe risers from a collar reach each panel target without a pointer event.

Screenshots / screen recording

Connected duct and pipe editing, recorded on this head's tree with the editor dev server (bun run dev in apps/editor). No clip shows the joint-split hold or the riser preview on their own; those changes are covered by the tests above.

Refused move on a closed loop. In a square pipe loop with one sloped leg, the south leg is moved inward. That would regrade the sloped leg, so the ghost and its footprint box turn red and the notice appears (about 0:11–0:22). Clicks place nothing, and after Esc the loop is unchanged.

Refused loop move: red ghost, red footprint box and the grade notice

pipe-loop-refused-move.mp4

Accepted connected move. An open L of a leg, an elbow and a sloped branch. The leg is dragged sideways with a blue ghost and green joint markers, and the elbow and branch follow and stay joined. A click places the move at 0:35, and one undo at 0:40 restores all three parts.

pipe-open-leg-accepted-move.mp4

Duct offset. A 14 × 8 in duct in an L. "Offset around obstacle" shows the side-elevation sketch, and "Apply offset" (0:29) raises the section with four elbows while both ends stay joined.

duct-offset.mp4

Connected branch resize. With the scope "Connected same-size branch" and a width of 16 in, the form reads "11 existing parts affected · 0 new parts". "Apply resize" (0:27) widens every segment and elbow of the branch in one step. The clip skips scrolling the inspector at 0:23.

duct-branch-resize.mp4

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 connectivity resolution and many editor commit paths; behavior changes are user-visible but guarded by tests and fail closed on invalid joints.

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

Port connectivity now checks every joint it snapshotted once the
followers are solved. If any joint between the moved node, the runs it
walked and the fittings that follow would open by more than a
millimetre, the resolver returns null instead of the split. Stretching
the end of a run whose loop returns to its own start is one such edit.

The move tools, selection handles and plan affordances keep the last
welded frame and commit nothing on release, and pipe_grade refuses with
pipe_connection_split. A run driven at both ends by a fitting that only
echoes its far end now follows the driven end alone, so a chain carried
through elbows stays welded instead of drifting on every echo.
Moving, turning and resizing a selected pipe fitting, moving it with
its ghost, dragging a refrigerant line end and sliding a run segment in
the plan view read the grid, angle and magnetic snap modes instead of
treating Shift as a snap bypass, as the duct fitting handles do. The
interaction-scope inventory keeps only the polygon-centroid drag.
A vertical route ends at the target elevation above its start, wherever
the pointer is. Refreshing the cursor still waited for a canvas pointer
event, so a riser drawn from a collar showed no target until the pointer
moved and Enter placed nothing, and after a start click a new target from
the panel left the previous one in the preview. The vertical target now
resolves from the start alone.
A plan-view pipe point drag that passed through a refused frame placed
the last frame it showed but left "would change a connected pipe's
grade" up until it timed out. Placing now clears it, as releasing the 3D
handle does.
@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-09T12:17:02.111918Z 113206b 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: 113206bc37

ℹ️ 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".

const s = sampleAxis(axis, event.clientX, event.clientY, anchorWorld)
if (s === null) return null
const step = event.shiftKey ? 0 : useEditor.getState().gridSnapStep
const step = 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.

P2 Badge Establish a snap context before reading snap modes

When a selected fitting is edited through these handles rather than the Move tool, beginDrag never starts an interaction scope, so the scope remains idle; getActiveSnappingMode() therefore resolves to off, making this new isGridSnapActive() check—and the new angle/resize checks below—always false in normal Select mode. As a result, fitting movement and resizing no longer grid-snap, rotation no longer angle-snaps, and Shift has no active context to cycle. Start and end a handle-drag scope around this interaction (and the similarly migrated refrigerant-line selection drag) before reading the mode helpers.

AGENTS.md reference: AGENTS.md:L21-L24

Useful? React with 👍 / 👎.

@Aymericr Aymericr left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

LGTM at 113206b (static peer review; no tests rerun).

Maintainer: I read the full 26-file diff, including all changed/new tests, and all available review and conversation comments. No P0/P1 found. The connectivity solver now fails closed on incompatible follower displacements, its nullable result is handled by the affected preview/commit paths, and the L-chain/U-loop tests cover the central regression. The pointer-free vertical-target refresh and notice cleanup also look correct.

Codex disposition — one finding at this head:

  • Real, P2, non-blocking: packages/nodes/src/pipe-fitting/selection.tsx:490 (also angle/resize handling and shared/refrigerant-line-selection.tsx:267). These selection-handle drags don't establish an interaction scope; Select/idle gives no snap context and getActiveSnappingMode() returns off. Thus switching from Shift-based snapping to isGridSnapActive()/isAngleSnapActive() disables snapping in ordinary Select mode. Please follow up by bracketing these gestures with an owned handle-drag scope, using the rotation handle label for angle snapping, and cleaning it up on release/cancel/unmount; add Select/idle tests for grid/angle modes and Shift cycling. Don't use a moving scope, which would mount a second mover. This is a constrained precision/UI regression, not a P1 or a geometry-integrity failure.

No Bugbot inline findings or other review findings were returned for this PR; its check succeeded. The PR description's acknowledged #1236 follow-ups remain outside this change: collar-start grade defaults, the narrow snap/grade tolerance mismatch, vertical route defaults after a riser, and the pipe-fitting mover's missing grade guard.

Exact-head CI: cli-smoke, quality, ci, Changed paths and Cursor Bugbot all completed successfully. main's returned protection summary lists no required status-check contexts; mergeable=true, mergeable_state=clean. Head rechecked unchanged immediately before this review. No auth, payments or secrets touched. No merge or thread resolutions.

@Aymericr
Aymericr merged commit cad92aa into main Nov 9, 2026
5 checks passed
@Aymericr
Aymericr deleted the cursor/mep-editing-followups-14a6 branch November 9, 2026 13:11
Aymericr added a commit that referenced this pull request Nov 9, 2026
…1240)

* Put MEP drag followers back when a frame stops moving them

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.

* Run MEP handle drags under the editor's gesture owner

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.

* Let held Alt slide MEP fitting and run moves past the grid

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.

* Step MEP fitting arrow moves on the grid in Lines mode

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.

* Revert "Step MEP fitting arrow moves on the grid in Lines mode"

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.

* Say that a gesture's onCancel may revert paused writes but records no 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.

* Cover the duct fitting handles and the run slides' Alt check in rendered 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.

* Cover a cancelled duct run slide

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.

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
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