Skip to content

[Maintainer] Connected duct and pipe editing, ported from #1115 - #1236

Merged
Aymericr merged 18 commits into
mainfrom
cursor/mep-connected-editing-port-14a6
Nov 9, 2026
Merged

Aymericr merged 18 commits into
mainfrom
cursor/mep-connected-editing-port-14a6

Conversation

@Aymericr

@Aymericr Aymericr commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

What does this PR do?

Ports @sudhir9297's community PR #1115 ("Add connected duct and pipe editing with shared build controls") onto main and fixes what kept it from merging. Sudhir's three commits keep their original authorship, and the squash commit 3a972b68 credits him as co-author. The only change to his commits is that the review screenshots under wiki/assets/pr-1115 are left out. They stay linked from #1115, and no document in the repo references them.

Merged from head bbe4b501. Four fixes from the final review were finished after that head and merged in #1237. #1238 and #1240 followed, and #1242 (open) fixes the last Bugbot finding below.

From #1115 (Sudhir)

  • Duct and pipe build settings (profile, material, routing elevations, connect or cross without joining) are remembered across tools. Connection feedback is shared by 2D and 3D.
  • Ducts get connected resize, transitions and offsets. Pipes get grade and downhill flow, endpoint edits that keep grade, connected resize with reducers, offsets, and collar connections to registered equipment, fixtures and traps.
  • The same operations back the inspectors and five agent/MCP tools (duct_edit, pipe_grade, pipe_resize, pipe_offset, pipe_connect), with one undo step per edit.

Maintainer follow-ups

  • MCP SDK split (8f230c60): main moved to @modelcontextprotocol/client and @modelcontextprotocol/server after Add connected duct and pipe editing with shared build controls #1115 branched. On the merged result, five MEP operation tests failed to resolve the old @modelcontextprotocol/sdk paths. They now use the split packages.
  • Open review finding "Plan-route slope blocks connections" (4ffc1f3f): a sloped horizontal route offered snap candidates only at its start height, and the grade check then refused them. It now snaps to collars and runs at the height its fall actually reaches there.
  • Open review finding "Rejected pipe move pauses history" (48d151ef, bbe4b501): a pipe move whose connected runs could only follow by changing grade was refused on click with no feedback, and the click propagated. History did resume on Esc or unmount, so the drag was never stuck.
    • Now the ghost and its footprint box turn red, with a status notice, while the move would regrade a connected run. A refused click is consumed, and the drag stays live until it is placed or cancelled.
    • pipe-segment/move-tool.test.tsx covers a grade-safe move landing in one undo step with its followers, and a regrading move being refused, re-aimed and cancelled.
  • Closed-loop hang (10aebd9a): moving or raising a leg of a closed duct or pipe loop could freeze the tab in resolveConnectivityUpdates.
    • Cause: each fitting re-broadcast its averaged delta through both collars. When two legs split a push differently (a sloped leg, or an oblique move), the queue doubled every round.
    • The hang predates this PR, but the port made it easier to reach, because the grade inspector's "Move elevation", pipe_grade grade and elevation edits, run arrow moves, and loops closed by snapping to collars all walk loops.
    • The resolver now keeps only the newest pending push per joint edge and caps the walk at 64 steps per edge. Loops the old walk could finish resolve as before, a leg moved along its own length carries its loop rigidly, and a sloped loop refuses an elevation edit with the grade notice.
    • Tests: the closed-loop cases in core port-connectivity.test.ts, pipe-segment/move-tool.test.tsx and agent-operations/pipe-grade.test.ts.
  • Review fixes:
    • Plan-view endpoint drags re-aim an elbow again, with the same grade checks as the 3D handles (7e4c9649, Codex P2).
    • A vertical riser previews at its target as soon as its start is placed (b1a6cb77, Bugbot High).
    • A duct offset whose bends cannot be formed is refused (eccac50e, Bugbot Medium).
    • Grade notices don't capture the pointer (1c58d203).
    • A selected pipe's arrow move commits what it previews (a7590edf).
    • MEP operations read the scene with queryNodes (a54408bd).
    • Agent tool contracts state their defaults and refusal codes (89cbd84f).
    • Duct fitting handles follow the snap modes (3c4ca5bb).
  • Localization (34bb7eff, f88c78f0): the new inspector, collar, route-preview and cursor copy uses whole Lingui messages with plurals, and collar sizes and grade labels use the active locale's number format. zh-CN, fr, es and ja get fuzzy Review: required drafts, so they show in English until reviewed.

Known gaps

  • A connected edit that the followers cannot weld could still commit open joints. One example is a diagonal move along a chain of pipe, elbow, three-point L pipe, elbow and pipe. Fixed in [Maintainer] Keep connected MEP edits from splitting joints #1237 (merged).
  • Still open: the pipe-fitting move tool has no grade guard; pipe runs do.
  • Still open: run-tool panel option labels are plain strings in core's ToolOption contract, so they stay English until that contract takes messages.
  • Bugbot's last three findings are answered in their threads, and the threads are resolved. [Maintainer] Leave vertical routing after a riser drawn from a collar #1242 adds tests for all three.
    • High, "Fixture start clears chosen waste grade": by design (reply). A pipe leaves a fixed collar along the collar's axis, so its first section takes the collar's grade. A conflicting grade is refused with a message, and later sections take the chosen grade.
    • Medium, "Snapped grade connect fails with wrong message": overstated (reply). The snap and commit tolerances disagree only between 0.02 mm and 0.1 mm off the fall on a 2 m run. In that window the cursor shows the grade conflict, not fitting clearance.
    • Medium, "Vertical collar draw blocks next segment": confirmed, and fixed in [Maintainer] Leave vertical routing after a riser drawn from a collar #1242 (reply). After a riser from a collar, the tool now switches to the plan route.

This supersedes #1115, with credit to Sudhir. Next owner: Maintainer.

How to test

  1. Draw a DWV pipe in plan with a grade (for example 2%) toward an existing collar or run that sits at the height the fall reaches. It snaps and connects. Before this change, the candidate was offered at the start height and then refused.
  2. Move a pipe that has a sloped branch attached. The branch follows and keeps its grade, and one undo restores everything.
  3. Build a closed rectangle of four pipes joined by elbows, with an adjacent leg sloped. Move a level leg toward the opposite side. The ghost and its footprint box turn red with "This move would change a connected pipe's grade…", and clicking does nothing. Moving back to a safe spot restores the normal ghost, and Esc cancels with no undo entry. Moving a leg along its own length carries the loop without freezing.
  4. Repeat the Add connected duct and pipe editing with shared build controls #1115 steps for build settings, crossings, connected resize, offsets and collars in 2D and 3D.

Checks on the merged head bbe4b501:

Screenshots / screen recording

Recorded on the editor dev server (bun run dev in apps/editor) at 113206bc, which is this PR's merged tree plus the four commits in #1237.

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

Co-authored-by: sudhir sudhir9297@gmail.com

To show artifacts inline, enable in settings.

Open in Web Open in Cursor 

Note

Medium Risk
Touches core port-connectivity propagation and heavily used distribution drawing/move paths; regressions could break welded joints, grades, or undo behavior, though coverage was expanded.

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

sudhir9297 and others added 7 commits November 9, 2026 02:01
[maintainer: ported from #1115 without the wiki/assets/pr-1115 screenshots,
which are review evidence linked from the original pull request and are
not referenced by any document in the repository.]

(cherry picked from commit 9c916aa)
main moved to @modelcontextprotocol/client and @modelcontextprotocol/server
after #1115 branched, so these tests failed to resolve the removed
@modelcontextprotocol/sdk paths.
Horizontal routing kept only ports and run bodies at the leg's start
height, while the free end still takes the pipe fall. A sloped waste run
therefore could not snap to a collar or run at the height it actually
reaches, and the same-height candidates it did offer were then refused by
the grade check on commit.

Candidates are now compared with the height the route reaches above their
plan position, using the adapter's free-end rule, and run bodies are looked
up at that height.
A pipe move whose followers would change another run's grade was refused
on click with no feedback, and the click was left to propagate. The
ghost now turns red with a status notice while the preview would regrade
a connected run, and a refused click is consumed. The drag stays live
(history paused until placed or cancelled), so Esc or a valid spot ends
it as before.

The follower preview now returns the patches it shows, so the grade
check reuses them instead of resolving the graph twice per frame.
The new pipe grade, offset and resize inspectors, the duct edit inspector,
the collar connection buttons, the route preview label and the
distribution cursor hint rendered hardcoded English, which the literal
guard rejects. They now go through Lingui as whole messages: split
fragments are merged, counts use plurals, and numbers use the locale's
formatting. The pipe description and the new grade-blocked move notice
are included.

zh-CN, fr, es and ja get fuzzy drafts awaiting review, so releases keep
showing English for these until a reviewer approves them.
@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-09T03:03:33.429608Z 34bb7ef 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: 34bb7effae

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

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

Stale Bugbot comment from a previous run.

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

[Tooling] Changes needed at 34bb7ef (static review, tests not rerun). Not an LGTM.

Blocker (confirms Codex P2): in 2D, dragging a pipe endpoint that's connected to an elbow no longer re-aims the elbow. pipe-segment/definition.ts (move-path-point, ~L109) now uses pipeGradePointAffordance → editPipeGrade, which refuses any direction change at a connected end (pipe_connection_angle). grade-affordance.ts L63–65 then swallows that refusal, so the endpoint silently doesn't move (only Alt-detach works). On main, createPathPointMoveAffordance swings the elbow, and the 3D handles in selection.tsx still do, so 2D and 3D now disagree. Fix: keep the elbow re-aim path in the new affordance and apply the same grade check as 3D, show a notice on refusal, and add a 2D test that drags a pipe connected to an elbow.

Should-fix (Bugbot): in vertical routing, after the first click the preview and Target elevation label still show the start height, so a second click or Enter without moving commits a riser to a height that was never shown (distribution-run-tool.tsx ~L1054–1074, L670–682). Set the preview to the target elevation right after the first click.

Hardening (Bugbot): in duct-segment/edit-operation.ts ~L121–138, the ! on planElbowAtPort should be a clean refusal like the pipe offset has, even though the current inputs can't hit the null case.

No Security gate needed (it only edits the scene: no auth, payments or secrets). After the fix, I'll do a full pass on the new head before signing off.

Moving or raising a leg of a closed duct or pipe loop could freeze the
editor. Each fitting re-broadcasts its averaged delta through both
collars, and a run held at both ends bounces it straight back, so when
two legs split a push differently (a sloped leg, or an oblique move)
the walk queued every stale push and the queue doubled each round.

The resolver now keeps only the newest pending push per joint edge and
caps the walk at 64 steps per edge. Open chains, trees and loops the
old walk could finish resolve exactly as before; loops it could not
finish now settle with every joint welded (a leg moved along its axis
carries the loop rigidly).

On this branch the grade inspector's "Move elevation" action and the
pipe_grade agent tool reach the resolver too, so a sloped vent loop now
refuses that edit with the grade notice rather than locking up.
The grade-preserving floor-plan affordance replaced main's generic path-point
drag, which swings the elbow at a straight run's far end to follow the drag.
Without it, every turned endpoint was refused and nothing was committed.

Plan-view endpoint drags now try the elbow re-aim first, with the same
grade and connected-collar checks as the 3D handles. A refused frame keeps
the last valid preview and shows a localized floor-plan notice. The 3D
handles use the same localized message.
After the first click of a vertical route, the cursor and last resolved
point still held the start. The ghost and the Target elevation label showed
the start height. The next click then committed a riser the preview never
showed, and Enter committed the zero-length start, which did nothing.
Resolve the vertical target right away so click and Enter both place what
the preview shows.
Match the pipe offset: if an elbow cannot be planned at an offset corner,
refuse with a structured reason. Previously a non-null assertion turned that
case into a TypeError.
drei's Html applies its style to the wrapper around a label. A
pointer-events-none class on the label alone still left the wrapper catching
events. The move tool's notice follows the moved run and could sit under the
cursor, stalling the preview and swallowing clicks. The selection notice
covers the run's center arrows.

Pass pointer-events: none to Html, as the measurement labels do. Also clear
the endpoint drag's notice on release, so it no longer stays over the arrows
after a refused drag.
The center-arrow move checked grades only when publishing a frame. A refused
frame silently froze the preview while the drag offset kept following the
cursor. Release then recomputed from that unseen offset: a plain stretch was
dropped without a message, and a move past the offset threshold committed
offset fittings that were never shown. Vertical frames kept a valid tint even
when the preview was dropped.

Each frame is now planned as release would commit it: a vertical offset, a
translation offset with its new fittings ghosted, or a plain move. That plan
goes through the grade guard. A refused frame keeps the shown frame and
explains why, like the endpoint handles, and release commits the frame on
screen. Live previews also drop overrides left by earlier frames.
… scene

On a detached scene, enumerating the nodes record counts as reading every
node, so a grade, offset, resize, connect or duct edit drafted there was
refused whenever anything was created or deleted meanwhile. Port
connectivity now selects the run and following-fitting kinds, the
operations select their level, and the end-cap and auto-offset helpers
select the kinds they own. The raw-scene-enumeration rule now covers
these modules.
Each description now opens with a sentence that stands alone, states the
defaults of scope, alignment, flow, anchor, detach and the duct sizes, and
lists the refusal codes its operation can return. The nodes README
documents the five tools next to the kitchen ones.
Pipe collars are named (inlet, outlet, branch, or a numbered collar)
instead of showing their port id, duct collar sizes use the locale's
digits, and the grade label shared by the plan view, the grade
inspector and the drawing readout is a catalog message with locale
numbers. Drafts for fr, es, ja and zh-CN await review.
Moving, turning and resizing a selected duct fitting read the grid and
angle snap modes, as the duct segment handles already do, instead of
treating Shift as a snap bypass. The interaction-scope inventory now
lists the handles that still use the legacy bypass.

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

Stale Bugbot comment from a previous run.

A pipe move that would regrade a connected run turned its ghost red but
kept the footprint box in the placeable green. The box now follows the
ghost, as the generic move tool's box does for an invalid placement.

@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 bbe4b50. Configure here.

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

[Tooling] Static peer LGTM at bbe4b50. This is a static review only: I didn't rerun tests, and this doesn't clear the PR to merge or deploy.

Findings from my review at 34bb7ef:

  1. Blocker, fixed (7e4c964): in pipe-segment/grade-affordance.ts, the 2D endpoint drag on a run whose far end sits on an elbow re-aims the elbow again, using the same grade checks as the 3D handles. A refused frame now keeps the last valid preview and shows the blocked-grade notice instead of failing silently. New tests in pipe-grade.test.ts cover the re-aim and the held refusal. This resolves the Codex P2 on definition.ts:107.
  2. Should-fix, fixed for the first-click path (b1a6cb7): distribution-run-tool.tsx:1076 re-resolves the cursor right after the start is set, so the riser at the target elevation shows before the next click or Enter. Bugbot's Medium on :1243 is still open: a draw-from-collar start, or a panel change to target elevation with no pointer move, can still leave a stale preview. Non-blocking follow-up.
  3. Hardening, fixed (eccac50): duct-segment/edit-operation.ts:376 now refuses with duct_offset_angle instead of using the ! assertion. refuse throws, so the early return inside map is safe.

Also since 34bb7ef: the closed-loop hang in resolveConnectivityUpdates is fixed (10aebd9, coalesced edge pushes plus a step budget) and has loop tests, so the PR description's 'avoid moving a loop leg along its own length' warning and its CI note at 34bb7ef are now stale. The arrow move now commits what it previews (run-move.ts, with tests). I found no new P0/P1 in the delta.

Open Bugbot findings I'm treating as non-blocking follow-ups:

  • High, pipe-segment/tool.tsx:504-508: starting from a non-pipe waste/vent collar rewrites the remembered fall and grade from the collar axis. That matches the documented rule that the first section leaves straight along the collar, and a conflicting grade is refused with a message rather than written. Still worth not overwriting the user's grade defaults.
  • Medium, tool.tsx:243-251: the snap tolerance (1e-4 m) and grade-commit tolerance (1e-5) don't line up, so the user can see the wrong refusal message.
  • Medium, shared/pipe-collar-inspector.tsx:58: routingMode: 'vertical' stays set after drawing from a vertical collar, so the next click makes an empty segment.

Holds from the PR description still apply: no local bun dev testing, no screenshots of the grade-blocked notice, no grade guard on the pipe-fitting move tool, and machine-drafted non-English locales.

CI at this head: ci, quality, cli-smoke and Changed paths succeeded; Cursor Bugbot neutral. No auth, payments or secrets changes.

@Aymericr
Aymericr merged commit 3a972b6 into main Nov 9, 2026
5 checks passed
@Aymericr
Aymericr deleted the cursor/mep-connected-editing-port-14a6 branch November 9, 2026 09:05
Aymericr added a commit that referenced this pull request Nov 9, 2026
…#1242)

* Share the collar draw handlers with the pipe and duct tools

The collar inspectors' "Draw from" handlers move next to the existing
continuation starters, so the collar start can be exercised without
rendering the inspector.

* Pin how a pipe run leaves a fixed collar

The first section follows the collar's axis and takes its grade; a
chosen grade that cannot meet the collar is refused with the grade
message, not the fitting-clearance one, and later sections take the
chosen grade.

* Leave vertical routing after a riser drawn from a fixed collar

Drawing from a collar that points up or down sets Route to Vertical.
After the riser reached the target elevation, the next vertical section
aimed at the riser's own top, so every click was refused until the
route or target changed. A committed riser out of a fixed collar now
switches the pipe and duct tools to the plan route; a vertical route
chosen from a pipe or duct end is left alone.

Reported by Cursor Bugbot on #1236 ("Vertical collar draw blocks next
segment").

* Check that a graded section after a collar joins without a bend

The level first section and the 2% section after it meet directly; the
only fitting is the end cap on the open end.

* Keep a chosen vertical route after a riser from a run end

The switch to the plan route applies only to risers out of a fixed
collar; a vertical route chosen while drawing from a pipe or duct end
stays on for the next riser.

---------

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.

3 participants