Repository navigation
[Maintainer] Keep connected MEP edits from splitting joints - #1237
Conversation
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.
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: 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 |
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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 andshared/refrigerant-line-selection.tsx:267). These selection-handle drags don't establish an interaction scope; Select/idle gives no snap context andgetActiveSnappingMode()returnsoff. Thus switching from Shift-based snapping toisGridSnapActive()/isAngleSnapActive()disables snapping in ordinary Select mode. Please follow up by bracketing these gestures with an ownedhandle-dragscope, 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 amovingscope, 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.
…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>
What does this PR do?
Follow-up to #1236, which ported @sudhir9297's community PR #1115 and was merged as
3a972b68from headbbe4b501. These four commits fix the findings still open from the final independent review of #1236 (on3c4ca5bb), plus one Bugbot finding that review confirmed. They were finished after the merged head, so they are not onmainyet. This branch ismainplus these four commits.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.resolveConnectivityUpdatesnow checks every snapshotted joint after solving. It returnsnullif 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, andpipe_graderefuses withpipe_connection_split.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 inwiki/architecture/interaction-scope.mdnow lists only the polygon-centroid drag.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.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)
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.How to test
main, the joints open and the far leg stretches.pipe_gradewithaction: 'endpoint'refuses withpipe_connection_split.Automated checks on
113206bc:bun run cipassed 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.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".shared/port-connectivity-pipe.test.ts: the L chain above, with real pipe kinds, diagonal and lifted moves.shared/run-move-connectivity.test.ts: "a transform the followers cannot follow keeps the last preview and commits nothing".agent-operations/pipe-grade.test.ts: the U-loop refusal, plus the notice clearing on placement.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 devinapps/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
bun devbun checkto verify)mainbranchTo show artifacts inline, enable in settings.
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.