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%[email protected] 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.

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