Skip to content

wall chaining, collinear transit, and lazy editor startup - #1289

Open
saadmooh wants to merge 7 commits into
pascalorg:mainfrom
saadmooh:feat/wall-continuous-chain-transit
Open

saadmooh wants to merge 7 commits into
pascalorg:mainfrom
saadmooh:feat/wall-continuous-chain-transit

Conversation

@saadmooh

@saadmooh saadmooh commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

  • Continuous wall chaining in Walls mode (3D and 2D/split): Removes the early !wallDraftIsRun() stop in packages/nodes/src/wall/tool.tsx and packages/editor/src/components/editor/floorplan-panel.tsx so consecutive walls chain directly from the previous wall's exact resolved endpoint (createdWall.end). Chains still terminate cleanly on room close, T-junctions, double-click, or Escape.
  • Collinear wall tracking transit: Exports wallSegmentsCoverSegment from @pascal-app/core (packages/core/src/systems/wall/wall-topology.ts and packages/core/src/index.ts) and handles collinear segments covered by existing walls in 3D and 2D drafting (gating the 2D collinear transit check to 2D-only mode in split view). Moving along an existing wall centerline advances the draft origin without duplicating the wall, so perpendicular partition walls start strictly on the host centerline and T-join cleanly.
  • Editor startup & bundle code-splitting:
    • Moves 3D node-registry bootstrap (apps/editor/lib/bootstrap.ts) out of RootLayout (apps/editor/app/client-bootstrap.tsx) into 3D/scene entrypoints (scene-loader.tsx, embed-viewer.tsx, import-client.tsx) so non-3D routes (/, /login, /settings, /setup) do not load Three.js, @pascal-app/viewer, @pascal-app/editor, @pascal-app/nodes, or external 3D plugins.
    • Converts all external plugins in apps/editor/lib/bootstrap.ts to dynamic import(...) scheduled via requestIdleCallback, and isolates @webxr/plugin behind React.lazy in webxr-feature-gate.tsx, webxr-enabled-runtime.tsx, and scene-loader.tsx.
    • Adds @pascal-app/editor/locales/lazy (packages/editor/src/i18n/lazy-locales.ts) and updates apps/editor (layout.tsx, client-bootstrap.tsx, dev-locales.ts) to register English upfront and load non-English locales (es, fr, ja, zh-CN) and dev en-XA only on demand.
    • Lazy-loads heavy format exporters (GLB, USDZ, IFC, STL, OBJ, 3MF, Manifold) inside packages/editor/src/components/editor/export-manager.tsx, and code-splits FloorplanPanel, FirstPersonControls/FirstPersonOverlay, RiserDiagramPanel, and SnapshotCaptureOverlay inside packages/editor/src/components/editor/index.tsx.
    • Adds a dev:fast script in root package.json and suppresses the node:sqlite ExperimentalWarning in Next.js dev scripts.
  • React 19 + @react-three/drei <Html> unmount patch: Adds patches/@react-three%2Fdrei@10.7.9.patch via patchedDependencies so <Html> reuses its ReactDOM root across effect re-runs (StrictMode / target changes) and defers real unmounts via queueMicrotask, fixing React 19 synchronous unmount errors and NotFoundError: removeChild.
  • Tests: Adds unit coverage for wallSegmentsCoverSegment in packages/core/src/systems/wall/wall-topology.test.ts and integration tests for chained off-grid typed walls and collinear transit T-junctions in packages/nodes/src/wall/tool-chaining.test.tsx.

How to test

  1. Start the editor locally with bun run dev:fast (or bun dev) and open / — confirm it renders cleanly without loading 3D plugin chunks or showing the node:sqlite dev overlay warning.
  2. Open a project (/project/<id>) and verify the 3D scene loads cleanly with no <Html> synchronous-unmount or removeChild console errors, and that 2D floorplan, plugins, and exports still load and work on demand.
  3. Select the Walls tool in default Grid (0.5 m) snapping mode (in 3D, 2D, or split view). Click a start point, type 3.2 and press Enter to place Wall 1 — verify the tool automatically chains from [3.2, 0] without a manual re-click, and closing a 4-wall room leaves zero Not joined gaps.
  4. Click a corner of an existing wall, type 2.3 along its length and press Enter — verify no duplicate wall is created and the draft origin advances 2.3 m along the host wall; turn 90° and place a partition wall to verify a clean T-junction.
  5. Automated checks run locally:
    • bunx biome check on all changed/added files (0 errors)
    • bun --cwd packages/editor check-types (tsgo --noEmit, 0 errors)
    • bun test packages/editor/src/i18n (5 pass, 0 fail)
    • bun --cwd apps/editor test (76 pass; 2 pre-existing Windows path failures in lib/css-build.test.ts)
    • Verified GET http://localhost:3002/ returns HTTP 200 on a fresh .next cache with bun run dev:fast

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

Note

Medium Risk
Broad changes to bootstrap, plugin discovery, i18n hydration, and wall authoring logic; failures in lazy loading or chain sync could affect first paint or drafting in split view.

Overview
This PR shrinks editor cold start by deferring heavy work: the 3D node registry bootstrap moves from the root layout into 3D entry routes (scene-loader, embed-viewer, import), external plugins load via dynamic import() on requestIdleCallback, WebXR/UI chunks use React.lazy, non-English locales and dev en-XA load on demand, and large export pipelines plus floorplan/riser/snapshot panels code-split. Plugin discovery is hardened with per-loader error handling and Promise.allSettled in extendPluginDiscovery. A @react-three/drei <Html> patch and dev:fast / ExperimentalWarning tweaks support React 19 dev ergonomics.

Wall drafting chains consecutive segments from exact resolved endpoints in both 3D and 2D/split view, supports collinear transit along existing walls via exported wallSegmentsCoverSegment, and adds wallOutcome: 'refused' on the segment draft chain so split view stays synced when a commit is rejected.

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

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

@saadmooh saadmooh changed the title wall: chain Walls segments and support collinear wall transit wall chaining, collinear transit, and lazy editor startup Nov 17, 2026

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

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

Comment thread apps/editor/app/client-bootstrap.tsx Resolved
Comment thread apps/editor/app/client-bootstrap.tsx Resolved

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

Comment thread apps/editor/lib/bootstrap.ts Resolved

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

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

// the current 2D draft, run reference, and typed fields intact.
return
} else {
nextStart = createdWall ? (createdWall.end as WallPlanPoint) : publishedNextStart

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

2D-only chaining ignores double-click

Medium Severity

Removing the !wallDraftIsRun() stop makes 2D-only Walls mode keep chaining, but handleWallPlacementPoint never checks detail. The 3D tool stops a run on a double-click; in 2D-only that second click is just a too-short segment and is ignored, so the draft stays live until Escape, a T-junction, or a room close.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 8f78bdf. Configure here.

@Aymericr Aymericr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @saadmooh. Continuous chaining and collinear transit are both things people ask for. Some context first: #1249 landed typed wall length and angle (including the angle work from your #1207), so this branch now conflicts with main in the wall tool and floor-plan panel.

To get this reviewable:

  1. Split it into three PRs. This bundles wall chaining, collinear transit, and a startup/bundle refactor (lazy bootstrap, dynamic plugin imports, lazy locale loading, Suspense around FloorplanPanel and first-person). They touch different owners and carry different risks, and most of Bugbot's open findings are in the lazy-loading half. I'd start with chaining on its own, then transit, then the startup work.
  2. Rebase onto current main and reuse the usePlacementTyping / useSegmentDraftChain state that's there now rather than adding a parallel path.
  3. Open Bugbot findings worth fixing in the chaining PR: split-view draft surviving a 3D chain stop (high), split view desyncing on a failed create, 2D-only chaining ignoring double-click, and the 2D transit using a stale origin. For the startup PR: one failed plugin chunk blocking all plugins (Promise.all plus externalsKickedOff set before await), the first-person HUD disappearing during lazy load, stale/failed locale loads winning, and zh-Hans-CN aliases no longer resolving.
  4. Screen recording of chaining in 3D, 2D and split view, plus a transit along an existing wall.

Happy to review each piece quickly once it's split.

@Aymericr Aymericr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

[Maintainer] Thanks @saadmooh. Continuous wall chaining and the collinear transit are features users asked for (#1206), and CI is green at 8f78bdf. Before this can be merged:

1. Merge conflicts. The branch is dirty against main; please rebase.

2. Please split. This bundles three independent changes (3D/2D wall chaining and collinear transit, the lazy editor startup and plugin loading, and lazy locale loading). 983 lines across 28 files in different areas are hard to review and revert. Suggested: (a) wall chaining and transit, (b) lazy startup and plugin discovery, (c) lazy locales. Note #1310 also changes client-bootstrap.tsx and lazy-locales.ts.

3. Bugbot findings that look valid and that I would like confirmed fixed at the head (several were reported on earlier commits, so some may already be resolved; please reply to each): the draft surviving a chain stop in split view (High); split view desyncing on a failed create; the floorplan missing the in-progress chain; 2D collinear transit using a stale origin; 2D-only chaining ignoring double-click (the 3D tool stops a run on a double-click); first-person UI vanishing during the lazy load; locale switching applying stale or failed loads, and Chinese aliases such as zh-Hans-CN not resolving to the zh-CN catalog; and one failing plugin import blocking all first-party plugins, because they are loaded together with Promise.all (use allSettled so one failed chunk degrades gracefully).

4. Screenshots or a screen recording are needed for the new chaining and transit behavior (none in the description).

Happy to re-review the pieces.

Aymericr commented Dec 3, 2026

Copy link
Copy Markdown
Member

Review at 8f78bdfe, run with Codex (gpt-6.2-astra) over two rounds: a full review, then each finding re-checked against the diff. Only findings that survived are listed.

  • P1 — packages/editor/src/components/editor/floorplan-panel.tsx:5150: The first 3D click now publishes a wall origin. The floorplan copies it into draftStart and wallChainFirstVertex, but if (!next) return ignores the matching clear. Finishing the chain in 3D leaves the old origin in 2D. Clear the local draft on a non-null → null transition, and test that the next 2D click starts a fresh wall with both panes mounted.
  • P2 — apps/editor/lib/bootstrap.ts:149: Idle discovery calls import('@webxr/plugin') without checking the scene. The feature gate defers the hook and button, not this package import. Discover lightweight panel metadata separately and import the plugin runtime only for an enabled scene. Verify that a disabled scene makes no runtime request after idle.
  • P2 — apps/editor/lib/bootstrap.ts:89: A failed chunk returns [], so discovery resolves and externalsKickedOff stays true. A later loadExternalPlugins() call returns immediately. Activation failures are also caught after panel registration. Track failures per plugin, allow retry without reloading successful plugins, and publish the active panel only after loadPlugin succeeds.
  • P2 — packages/core/src/registry/registry.ts:497: Promise.allSettled([previous(), fn()]) calls previous() before fn(). A synchronous throw skips fn() entirely; the added test throws inside an async callback and exercises only rejection. Schedule each callback with Promise.resolve().then(callback) and test that the second source still contributes plugins after a synchronous throw.
  • P2 — apps/editor/app/client-bootstrap.tsx:59: The subscription receives the new defaultI18n locale, but the provider calls i18n.setLocale(nextLocale) only after both catalog loads succeed. The empty catch leaves the two locales different on rejection. Load before publishing the change, or roll back only the still-current request; test rejection followed by another selection.
  • P3 — patches/@react-three%2Fdrei@10.7.9.patch:39: The patch reuses the DOM root and defers unmount to a microtask, but packages/nodes/src/wall/tool-chaining.test.tsx:83 mocks Html.render to return null. Add a DOM test that performs setup → cleanup → setup before the microtask, verifies the reused root still renders, and checks that final cleanup unmounts it exactly once.

This changes visible UI, so please attach before/after screenshots or a short clip.

P0/P1: 1. Those need fixing before this can land. CI hasn't run on this fork PR yet because it needs a maintainer to approve the workflow run; it merges once that's green.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants