Carry scene materials through Load Build - #729
Conversation
validateBuildJson dropped the top-level materials table, so every scene:<id> slot ref in an imported file pointed at a material that no longer existed — custom finishes silently reverted to defaults on Load Build. ParsedBuildJson now carries materials, each entry validated individually (a bad material never takes the import down, it is skipped with a warning), and handleConfirmImport hands them to setScene, whose extra.materials support already existed. Normalization here is DELIBERATE and documented in-line: safeParse().data injects defaults and drops unknown keys — the opposite of apiGraphSchema's preserve-unknowns stance — because import feeds the live scene store, which only understands schema-shaped materials. Split out of pascalorg#720 at the maintainer's request.
Aymericr
left a comment
There was a problem hiding this comment.
Thanks for splitting this out — the core change is right, and I checked the resolution path: keying the kept table by record key matches how every scene: ref is resolved at runtime (slot-paint.ts, wall/paint.ts, etc.), and the normalization stance matches how the hosted loader already parses materials, so import parity is correct. The handleConfirmImport retype to ParsedBuildJson also finally matches LoadBuildDialog's onConfirm signature instead of a drifting inline copy. Good.
One thing must change before merge: handleSaveBuild in the same file (settings-panel/index.tsx:234) still exports { nodes, rootNodeIds, installedPlugins }. Paint a finish, Save Build, Load Build that file — the finish reverts to default, which is exactly the bug in your description, still alive in the round-trip through this panel. As it stands the fix only helps files that already carry materials (API exports, hand-edited). Subscribe materials from the store and add it to sceneData; that completes the loop, and a Save→Load round-trip is the natural test for it.
Two smaller notes:
- The
invalid_materialswarning is count-only. Since the audience is hand-edited files, append the skipped ids to the message so the file is repairable — the node-level warnings in this validator all name their node. collectionshave the identical gap on both sides (Save omits them,validateBuildJsondrops them, confirm doesn't pass them — whilesetSceneacceptsextra.collectionsand the hosted loader round-trips them). Don't fix it here; I'll file it as a follow-up unless you want to take it in a separate PR.
With the Save Build line added this is ready. (CI run is approved.)
Review follow-up (pascalorg#729): paint a finish, Save Build, Load Build that file — the finish reverted to default because handleSaveBuild still exported only { nodes, rootNodeIds, installedPlugins }. Materials ride along now, closing the round-trip this PR opened on the import side. Also names the skipped ids in the invalid_materials warning: the audience is hand-edited files, and a bare count leaves nothing to repair by. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Done in 2996a11 — Save Build now subscribes |
Aymericr
left a comment
There was a problem hiding this comment.
Verified the follow-up commit: Save Build now exports the materials table (with the why captured in the comment), and the invalid_materials warning names the skipped ids with a test pinning it. The round-trip is closed. Merging.
* fix(editor): store scans locally without host uploads
* Host hooks for a guided tour: targets, a success cue, snapping and camera hints (#728)
* editor: share the shortcut glyph resolver and note Escape's mid-draw behavior
The Keyboard Shortcuts dialog owned the only key→glyph map (⎋, ⌫, ⌘/Ctrl, …)
while `ShortcutToken` — the thing that actually prints a key — knew only about
the command modifier. Move the map next to the token as `shortcutDisplayValue`
and export both from the package, so a second surface (the community
getting-started guide, which teaches Escape / undo / delete) prints the same
glyph for the same key instead of re-deriving the platform rules.
The dialog's output is unchanged; it drops its own copy of the map and its
`isMac` state in favour of the token file's module-level detection, which it was
already relying on for ⌘ anyway.
Also record what Escape really does in `use-keyboard.ts`: a tool that has an
active mid-action consumes the cancel (`markToolCancelConsumed`), so mid-draw it
drops only the chain and keeps the tool armed — the dialog claimed it always
returns to Select mode.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EfcEhXQKCFz216c2Y11Wah
* editor: print Esc, Space and Delete as words, and document the modifier taps
`shortcutDisplayValue` printed ⎋ for Escape, ␣ for Space and ⌫ for
Delete. None of those appear on a keyboard, so they read as "some
symbol" rather than as the key they mean — the getting-started guide
tells users to press Esc and rendered a glyph almost nobody decodes.
They now spell their names, and Delete uses the name the current
platform actually puts on the keycap. ⌘ and the arrows stay: those are
printed on the keys they stand for.
Shift keeps its icon in the token (the rail already draws ph:arrow-fat-up
because the ⇧ glyph sits too high in this font), but drops out of the
display map so any surface printing it as text now gets the word.
Also lists the two tap bindings in the Keyboard Shortcuts dialog. Shift
and Ctrl each mean one thing held and another tapped, and only the hold
was documented, which read as the taps not existing.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EfcEhXQKCFz216c2Y11Wah
* editor: keep in-scene HTML under the viewer overlays, and mark the level +
drei's `<Html>` derives its z-index from camera distance and defaults to a
range topping out at 16,777,271. Nothing between it and the viewer column
created a stacking context, so those values competed directly with the
toolbar (z-20), the stage overlay (z-10) and the overlay band (z-30) — and
the wall tool's cursor badge painted over anything an app put in that band,
including the community getting-started card. `isolate` on the canvas area
confines every in-scene HTML layer inside the canvas and leaves their order
relative to each other untouched.
The `data-guide-target` on the level stack's "add above" button is a static
hook for host-app onboarding to point at, read only from outside. Nothing
here depends on it.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EfcEhXQKCFz216c2Y11Wah
* editor: add a success cue to the SFX registry
A three-second jingle for finishing something, next to the click and thud
cues the registry already holds. No pitch or volume jitter — a fanfare
that lands a semitone off reads as broken rather than as varied — and a
minimum gap longer than the sound itself, so two milestones that land
together play once instead of phasing over each other.
The asset ships with the standalone editor because `preloadSFX` loads
every definition in the registry, wherever the player is mounted.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EfcEhXQKCFz216c2Y11Wah
* editor: let a host tour point at the Select control
One static `data-guide-target` attribute on the action menu's Select
button, matching the level selector's `level-add`. Nothing in the package
reads it: it exists so a host app's first-run guide can find the control
without the editor knowing a guide exists.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EfcEhXQKCFz216c2Y11Wah
* Two guide targets: the material picker and the ground-floor level row
Both are one static `data-guide-target` attribute and nothing else — no
import, no hook, no conditional class, no knowledge that a guide exists.
The host app's getting-started guide resolves and rings them from outside.
- `paint-material` on the material picker band in `MaterialPaintPanel`, so a
guide can ask for a brush to be loaded before asking for a surface to be
clicked. The grid rather than a swatch: the ask is that something is
chosen, not which.
- `level-ground` on the floating level selector's ordinal-0 row — the one
level a guide can name without knowing anything about the building. Same
conditional-attribute shape the Build grid already uses for its tiles.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EfcEhXQKCFz216c2Y11Wah
* editor: export the active snapping mode
A host that has to say something about snapping needs the same answer the
HUD chip on the right of the screen shows, and the editor already has one
source for it — `getActiveSnappingMode`, resolved through the active snap
context. Exported alongside `resolveSnapFlags` so a host can ask whether
the grid is what is in play rather than re-deriving the mapping and owning
a second version of it.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EfcEhXQKCFz216c2Y11Wah
* editor: let a host narrow the camera controls hint
The panel over the canvas explains Pan, Rotate and Zoom at once, which is
the right answer for somebody left to find their own way and the wrong one
for somebody being asked for a single gesture: three controls on screen
turns "drag to orbit" into a search. And once the lesson is over it is a
permanent widget explaining what the user has just been walked through.
`useCameraHintFocus` narrows it to the actions a host names, and hides it
outright for an empty list. Null — the default, and what every host gets
without touching it — is all of them, unchanged.
A store rather than a prop because the thing that knows which gesture is
being taught is several levels away from the canvas, and threading it
through would put a teaching concern in every component between. The
editor knows only "show these actions"; it never learns why.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EfcEhXQKCFz216c2Y11Wah
---------
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
* editor: let a host tour point at the snapping chips (#730)
One static `data-guide-target` on each of the helper panel's two snapping
chips — `snap-mode` on the Shift/mode chip and `snap-grid-step` on the
Ctrl/grid-step chip — through an optional `guideTarget` prop on `ChipRow`.
Same shape as the Select button, the level "+" and the material picker:
nothing in the package reads it.
The community getting-started guide's window step used to name the keys in
its small print and say the chips were "on the right of the screen", which
first-time users read as decoration. With a hook on the chip the guide can
ring the actual control and ask for the grid step to be shrunk as a beat.
Claude-Session: https://claude.ai/code/session_01EfcEhXQKCFz216c2Y11Wah
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
* editor: fix roof and placement previews (#718)
* Add roof surface placement support for items
Items (e.g. solar panels) can now be placed on sloped roof surfaces.
The placement system computes euler rotation from the roof surface
normal so items sit flush on the slope instead of going inside.
- Add roofStrategy to placement-strategies with enter/move/click/leave
- Wire roof:enter/move/click/leave events in the placement coordinator
- Add calculateRoofRotation in placement-math using surface normals
- Support full 3D cursor rotation for sloped surfaces
- Items on roofs are parented to the level with world-space rotation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fixed conflict
* feat: improve roof placement and hosted extensions
* fix: preserve curved lean-to roof connections
* fix roof and dormer editing behavior
* feat: improve roof openings and lean-to canopies
* Fix centered lean-to placement
* Align placement previews with architecture
* Fix dormer window placement grid orientation
* fix roof canopy geometry and continuous placement
* stabilize canopy miter quality assertions
* stabilize canopy gutter quality assertions
* fix conical roof hover elevation across levels
* fix conical roof placement on higher floors
* limit conical wall roofs to adjacent levels
* limit continuous mono canopy mitering to single-corner L runs
Straight freestanding mono runs now only miter across a corner when the
joined chain is exactly two runs (an L). J-shapes, longer chains, and
closed loops render as plain overlapping runs — no shaped footprint,
no joint step closures, no corner extension — which avoids the dark
wedges and fascia slivers those multi-corner miters produced. Curved
and wall-attached canopies keep their multi-corner mitering.
The joint step closure that L runs still use is rebuilt on geometric
ownership (the lower run raises the closure wall to the sibling top),
so it no longer depends on node-id order or draw direction.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* restrict conical roofs to curved wall footprints
* fix conical roof placement architecture
* fix remaining Bugbot findings
* restrict standard roofs to rectangular rooms
* ignore curved walls for standard roof drawing
* fix lower-floor roof room preview elevation
* test L-shaped roof footprint eligibility
* ignore diagonal walls for standard roof guides
* fix roof placement architecture and window previews
* fix roof footprint previews and wall guides
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
* feat(editor): expose exportFloorplanPdf from the package entry (#636)
* feat(editor): add structure+utility 'routing' floorplan export scope
Add a third FloorplanExportScope value that includes structure and
utility nodes (ducts, pipes, HVAC) without furniture, shared through a
pure isFloorplanNodeInExportScope predicate used at both collection
filter sites. Existing 'full' and 'structure' behavior is unchanged.
Co-authored-by: CommandCodeBot <noreply@commandcode.ai>
* feat(editor): export exportFloorplanPdf from the package entry
Re-export exportFloorplanPdf and the FloorplanExportScope type from
@pascal-app/editor so hosts with their own export UI can trigger a
floorplan PDF export without reaching into the settings panel.
Co-authored-by: CommandCodeBot <noreply@commandcode.ai>
* fix(review): add package-entry re-export smoke test and drop redundant comment
Per code review, add a consumer-side compile-time assertion in apps/editor
that imports exportFloorplanPdf and FloorplanExportScope from the
@pascal-app/editor package entry, so a broken re-export fails check-types
instead of passing silently. Also drop the WHAT-narration doc comment on
collectFloorplanGeometry (behavior-preserving).
Co-authored-by: CommandCodeBot <noreply@commandcode.ai>
* docs(review): record residual review findings
Co-authored-by: CommandCodeBot <noreply@commandcode.ai>
* refactor(editor): drop routing floorplan export scope
Per review on #636: the 'routing' scope has no UI trigger anywhere
(#632) and its name would collide with PrintContentScope's vocabulary
from #701. Narrows FloorplanExportScope back to 'full' | 'structure'
and simplifies the predicate accordingly. 'full' and 'structure'
behavior is unchanged.
Also renames the predicate's first parameter from `node` to
`definition` (it receives a NodeDefinition, not a node instance) and
corrects the apps/editor smoke test's comment, which mis-described a
runtime barrel import as a compile-time check.
* docs(review): drop residual-findings file, not a supported doc location
This repo keeps durable docs in wiki/, not a top-level docs/ tree, and
the file cited paths that don't exist here (a /tmp/... run path and a
docs/plans/... plan file). The two facts worth keeping — the tracker
issues filed from the original review round, and that #631 is the one
confirmed-real finding — move into the PR description instead.
---------
Co-authored-by: CommandCodeBot <noreply@commandcode.ai>
* fix(packaging): declare license on @pascal-app/editor, ship LICENSE in tarballs, re-export calculateLevelMiters from core/wall (#732)
- @pascal-app/editor published with no license field; automated license
inventories reported it as unlicensed. Declare MIT like its siblings.
- npm auto-includes a package-root LICENSE in the tarball, so committing
the root MIT text into each published package satisfies the MIT
attribution requirement without touching the files allowlists.
- @pascal-app/core/wall exported getWallPlanFootprint(wall, miterData)
without any way to produce or even name miterData; re-export
calculateLevelMiters plus the Point2D/WallMiterData types from the
same entry. wall-mitering was already a static dependency of the
entry, so the module graph is unchanged.
Reported in #731.
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
* Carry scene materials through Load Build (#729)
* Carry scene materials through Load Build
validateBuildJson dropped the top-level materials table, so every
scene:<id> slot ref in an imported file pointed at a material that no
longer existed — custom finishes silently reverted to defaults on Load
Build. ParsedBuildJson now carries materials, each entry validated
individually (a bad material never takes the import down, it is
skipped with a warning), and handleConfirmImport hands them to
setScene, whose extra.materials support already existed.
Normalization here is DELIBERATE and documented in-line:
safeParse().data injects defaults and drops unknown keys — the
opposite of apiGraphSchema's preserve-unknowns stance — because import
feeds the live scene store, which only understands schema-shaped
materials.
Split out of #720 at the maintainer's request.
* Save Build exports the materials table it now imports
Review follow-up (#729): paint a finish, Save Build, Load Build that
file — the finish reverted to default because handleSaveBuild still
exported only { nodes, rootNodeIds, installedPlugins }. Materials ride
along now, closing the round-trip this PR opened on the import side.
Also names the skipped ids in the invalid_materials warning: the
audience is hand-edited files, and a bare count leaves nothing to
repair by.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
* fix(mcp): report skipped persistence instead of silently dropping live sync (#736)
publishLiveSceneSnapshot returned void and silently skipped both the
draft save and the live event whenever no active scene was bound or the
store could not append scene events — mutations 'vanished' with no
error, no log, and no signal to the caller, sending people hunting in
the wrong layer (#725).
Neither of the two fixes #561 debated survives the constraints: a typed
throw breaks the plain --stdio quick start on the first create_wall, and
lazily binding a draft scene creates persistent artifacts the user never
asked for on stores that may require project context. Instead the skip
becomes visible at the layer the caller sees: publishLiveSceneSnapshot
returns 'published' | 'unbound' | 'events_unsupported', and every
mutating tool spreads a persistence warning into its result (declared in
the tool outputSchema via a shared fragment so the SDK's structured-
content validation keeps it). An AI caller can react by binding a scene
with save_scene/load_scene; a human reading the transcript sees why
nothing persisted.
InMemorySceneStore now implements appendSceneEvent/listSceneEvents so
the three paths are testable; live-sync.test.ts covers them through a
real client/server pair and at the unit level.
Fixes #725
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
* nodes: improve modular cabinet constraints and finishes (#719)
* Add roof surface placement support for items
Items (e.g. solar panels) can now be placed on sloped roof surfaces.
The placement system computes euler rotation from the roof surface
normal so items sit flush on the slope instead of going inside.
- Add roofStrategy to placement-strategies with enter/move/click/leave
- Wire roof:enter/move/click/leave events in the placement coordinator
- Add calculateRoofRotation in placement-math using surface normals
- Support full 3D cursor rotation for sloped surfaces
- Items on roofs are parented to the level with world-space rotation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fixed conflict
* feat(cabinets): improve modular sizing and ceiling finishes
* fix(cabinet): improve constrained run reflow
* fix(nodes): constrain modular cabinet reflow
* chore(cabinet): format top finish changes
* fix modular cabinet appliance and corner behavior
* fix cabinet schema version
* fix(cabinet): improve placement snapping behavior
* fix cabinet wall snapping and direct drag
* fix cabinet resize handle pointer ownership
* fix cabinet resize constraints and reflow
* fix cabinet snap architecture findings
* fix cabinet corner resize edge cases
* fix cabinet reflow and handle hit priority
* fix occluded drag and snapped rotation
* fix nested wall cabinet panel edits
* fix L reflow context and run height bounds
* fix L-leg panel edit ownership
* chore: remove cabinet planning artifacts
* refactor: move roof placement into node registry
* fix cabinet resize handle pointer ownership
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
* fix(editor): correct wall editing and roof controls (#738)
* fix wall curve topology and height drag dimensions
* fix roof accessory paint slots and draw default
* fix duplicate roof segment drainage control
* fix wall editing and add thickness handles
* add plain-language OpenPR2 skill
* viewer: fix lean-to roof mitering across connected runs (#739)
* Add roof surface placement support for items
Items (e.g. solar panels) can now be placed on sloped roof surfaces.
The placement system computes euler rotation from the roof surface
normal so items sit flush on the slope instead of going inside.
- Add roofStrategy to placement-strategies with enter/move/click/leave
- Wire roof:enter/move/click/leave events in the placement coordinator
- Add calculateRoofRotation in placement-math using surface normals
- Support full 3D cursor rotation for sloped surfaces
- Items on roofs are parented to the level with world-space rotation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fixed conflict
* fix lean-to roof miters across connected runs
* fix canopy miter edge cases
* keep continuous canopy endpoints connected
* avoid invalid curved gutter miters
* fix(viewer): keep curved shed miters flush
* fix lean-to roof mitering and gutter spans
* test(nodes): allow canopy angle sweep under CI load
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
* editor: don't put an empty plugin manager in an empty rail (#741)
The open lobby (`/play/<id>`) mounts the editor under a read-only lease and
registers no host panels, so the plugin *manager* was the only tab in the
rail — and the rail opens on its first tab. A visitor who left the game found a
bare "Plugins" heading covering ~40% of the window over the world they had come
to play in.
Gate the manager on having something to manage, or on a writable scene:
- `managedPluginIds(panels)` — the distinct plugins behind the registered
panels, since one plugin may contribute several and the manager lists plugins.
- `showsPluginManager({managedPluginCount, readOnly, workspaceMode})` — the tab
earns its slot when a plugin is registered, or when the scene is writable and
"Create a Pascal plugin" is still worth offering.
The only case this drops is read-only *and* nothing registered, which is exactly
the lobby; with no tabs at all both the v2 and mobile layouts already skip the
sidebar entirely, leaving the canvas alone. A read-only editor keeps the tab as
soon as a plugin is registered — browsing what a project uses is a read, and the
install button was already disabled on its own. Writable edit-workspace
behaviour is unchanged, and fenced by a test that says so.
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
* editor: capture-mode camera suite — FOV lens, walk/drone framing, keycap hints (#742)
* feat(editor): capture-mode fov control and orbit/walk/fly framing cameras
- Lens pill in the snapshot overlay drives the main camera's fov (15-110°)
while capture is open; entry fov restored on every exit path
- Orbit / Walk / Fly segmented control: walk reuses first-person, fly is a
new no-gravity/no-collision variant on the same controls
- Enter fires the shutter (pointer lock makes the button unclickable);
walk/fly snapshots synthesize a stored target down the view axis
- Walkthrough HUD hidden and fov effect no-oped while capture owns the frame
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018gQSsJ7nfdARkNH5PcKUjt
* feat(editor): drone mode polish — rename, E/Q vertical keys, keycap hints
Fly becomes Drone (lucide Drone icon, internal ids renamed; nothing
persists the value). Drone vertical: Space or E up, Q or Ctrl down; walk
keeps E/R door interaction. Camera hints are keycap chips instead of
sentence lines.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018gQSsJ7nfdARkNH5PcKUjt
* fix(editor): drop backdrop-blur from snapshot capture overlay pills
backdrop-filter over the WebGPU canvas flickers black on ProMotion/XDR
displays; the pills are near-opaque so the blur read as solid anyway.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018gQSsJ7nfdARkNH5PcKUjt
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
* editor: keep walk/drone snapshot framing as clean as orbit's (#743)
Snapshot capture in walk/drone still ran the viewer's default selection
manager (cursor hover highlights) and ViewerZoneSystem showed zone
geometry and tags — none of which orbit capture allows into the shot.
Gate both on capture mode.
Claude-Session: https://claude.ai/code/session_018gQSsJ7nfdARkNH5PcKUjt
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
* deps: cap zod below 4.5.0 (#744)
Zod 4.5.0-4.5.4 (upstream PR #6432) makes a wrapped discriminator claim
undefined in addition to its literal. All 48 AnyNode members use
z.literal(t).default(t) as the discriminator, so the union's lazily
built map throws 'Duplicate discriminator value "undefined"' at first
parse — a plain Error that escapes safeParse. Cap every zod range below
4.5.0 until the projection fix lands, and drop the unused zod dependency
from apps/ifc-converter.
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
* core: project AnyNode discriminators to bare literals (#745)
`nodeType()` defaults the node `type` literal so a per-kind schema can fill
it in (`WallNode.parse({ start, end })`). From zod 4.5.0 (upstream #6432) a
`.default()`-wrapped discriminator additionally claims `undefined`, so all 48
`AnyNode` members collide on that key: the union's lazily-built discriminator
map throws `Duplicate discriminator value "undefined"` at the first parse, as
a plain Error that escapes `safeParse` — a crash in every path that validates
a node (scene load, API boundary, MCP bridge).
`nodeUnion()` projects each member to a clone whose `type` is the bare literal
before assembling the union, carrying the member's registry metadata across
`.extend()` so `.describe()` text survives. The 48 node files and `nodeType()`
are untouched, so per-kind parsing keeps its default.
The two call sites that read the kind by parsing the defaulted literal
(`AnyNode.options.map(o => o.shape.type.parse(undefined))`) now use an
exported `nodeKindOf(option)`, which also replaces the `_zod.def` walk in the
nodes coverage test.
Verified on the pinned zod 4.4.3 (core 1164, nodes 1830, mcp 341 tests green,
workspace typecheck clean) and smoke-tested on zod 4.5.4, where the schema
tests pass with the projection and an unprojected two-member union still
throws `Duplicate discriminator value "undefined"` out of `safeParse`.
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
* core: type node metadata as a record instead of z.json() (#746)
`BaseNode.metadata` (and `ZoneNode`'s redeclaration of it) was `z.json()`,
zod's recursive JSON value. That schema is self-referential, and a
self-referential member is exactly what zod 4.5's `z.compile()` refuses to
compile — so it wasn't just the slowest field in every node, it denied the
whole node tree the compiled parser.
Measured on the real `WallNode` (200k parses, steady state):
| schema | zod 4.4.3 | 4.5.4 interpreted | 4.5.4 `z.compile()` |
|--------------------|-----------|-------------------|---------------------|
| `z.json()` | 125ms | 127ms | 133ms (1.0x) |
| `z.record(string, unknown)` | 81ms | 68ms | 31ms (2.2x) |
So ~1.5x per-node parse today on the shipped zod, and a 4x gap once the
compiled parser lands.
Metadata is a flat bag of per-node extras — every reader in the repo already
guards it with `typeof === 'object' && !Array.isArray()` — so an open object
with unchecked values is the whole contract. This does narrow the published
`@pascal-app/core` input contract: `metadata` was any JSON value and is now
object-only (founder-approved 2026-09-01).
Call sites that leaned on the old looser type:
- `nodes/cabinet/run-ops`: four `?.metadata ?? null` fallbacks become `?? {}`
(both consumers normalized `null` to `{}` already, so no behavior change).
- `nodes/dormer/csg-geometry`: the virtual roof segment's `metadata: null`
becomes `{}`.
- comments in `ifc-converter` and the converter app that described the field
as `z.json()`.
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
* deps: lift the zod cap to >=4.5.4 <4.6 (#747)
#744 capped zod below 4.5.0 because `AnyNode` threw on first parse; #745
fixed that with bare-literal discriminators. The remaining blocker was 27
failures plus a broken `tsc --build` in packages/mcp, which looked like an
MCP-SDK incompatibility with zod 4.5. It wasn't: it was two zod copies in
the tree.
Bun preserves a transitive resolution that still satisfies its range, so
moving our five workspace ranges to 4.5.4 left
`@modelcontextprotocol/sdk/zod` pinned at 4.4.3 while our schemas ran on
4.5.4. The SDK's compat layer is typed as
`z3.ZodTypeAny | z4.$ZodType` with `z4` imported from its *own* zod
(dist/esm/server/zod-compat.d.ts:1-3), so every `inputSchema` we hand it
was a foreign `$ZodType` — hence the TS2322s — and its `safeParse` ran
4.4.3 internals over 4.5.4 schema objects, which is where
`expected "nonoptional"` came from. Deleting the nested copy alone (SDK
still 1.29.0) took packages/mcp from 27 failures to 1 and made
`tsc --build` clean.
Bumping the SDK 1.29.0 -> 1.30.0 is the durable form of that fix: it makes
bun re-resolve the SDK subtree, which dedupes zod onto the single root
4.5.4 and drops the nested entry from the lockfile. A from-scratch install
of either SDK version already dedupes; only our incremental range change
skewed. No SDK API changed.
The one genuine zod 4.5 behavior change is in JSON Schema emission: a
union of primitive types now folds to `type: ['number','string']` instead
of `anyOf: [{type:'number'},{type:'string'}]`. Both forms validate
identically under the ajv draft-2020-12 validator the SDK ships (checked
against 0.9, "6 ft", true, null, {}), so `measurement.test.ts` now asserts
the accepted type set rather than the spelling.
Left alone: `ultracite/zod` and `react-doctor/eslint-plugin-react-hooks/zod`
keep their own 4.4.3 — dev-only CLIs that never see our schemas.
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
* core: lazy per-kind compiled node parsers behind a flag (#748)
`z.compile()` (zod 4.5) AOT-codegens a parser. Applied per node kind, on
first parse of that kind, it is p50 2.8x faster than the interpreted
per-kind schema and 3.4x faster than parsing through `AnyNode`.
Applied to the *union* it is the wrong trade: 41ms of codegen in one hit
and no faster than the per-kind map on mixed input (0.98x). Applied to
all 48 kinds eagerly it costs +44MB RSS. So: one lazy `Map`, one clone
per kind, only for kinds a call site actually sees, and off by default.
Wired at three long-lived call sites — the MCP bridge create path,
scene-load migrations, and the store create/update parses — each of
which re-parses the same handful of kinds for the lifetime of the tab.
Parity is asserted for all 48 kinds: identical output (key set *and*
key order, since `wall.height` absence is a mode), identical issues,
identical `error.message`, both against the interpreted per-kind schema
and against the union. Under `jitless` / a blocked `Function`
constructor, `z.core.util.allowsEval` short-circuits and every schema
stays interpreted — proven in a child process.
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
* viewer: re-resolve dangling library material refs; paint picker defaults to Pascal (#749)
* viewer: re-resolve dangling library material refs when the dynamic library registers
AI-generated `library:mtl_*` presets register asynchronously (a host fetch),
so a wall that renders before they land resolves its painted slots to the
slot default — and the wall material cache, whose signature assumed library
refs are static catalog content, pinned that default for the whole session.
Library-ref signatures now carry an `#unresolved` tag while the ref dangles,
and the wall renderer + cutout loop watch the dynamic library version, so a
late registration flips the signature and recomputes the materials.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018gQSsJ7nfdARkNH5PcKUjt
* editor: drop the paint picker's All source tab, default to Pascal
Parity with the Items / Rooms / Build browse surfaces, which dropped the
combined list because it buried the curated set.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018gQSsJ7nfdARkNH5PcKUjt
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
* registry: declarative def.toolOptions + shared ToolOptionsPanel; roof draws from it (#750)
The roof's 'Create from' (draw two corners vs pick a detected room) only
existed as a hand-rolled row in the standalone Build tab, backed by
toolDefaults.roof.footprintSource — which preset seeding nulls on every
activation and the roof tool clears on unmount, so the choice never
reliably survived, and the community Build sidebar (preset-driven,
hardcoded) never surfaced it at all.
Kinds now declare pick-one option rows via def.toolOptions (the sidebar
sibling of toolHints[].chip), rendered by the shared <ToolOptionsPanel>
that any host mounts once — no per-kind host wiring. The roof declares
footprintSource over a small ephemeral store (like roof-placement-mode),
the tool and the 2D floorplan hook read that store (the hook through the
registry — its editor sources land in the nodes program, where a nodes
import would cycle onto nodes' own dist), and the standalone Build tab
replaces its hand-rolled row with the panel.
Claude-Session: https://claude.ai/code/session_018gQSsJ7nfdARkNH5PcKUjt
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
* editor: single-writer ToolMode FSM for mode/tool (#751)
mode and tool were two independently-writable, independently-persisted
fields with six ad-hoc writers (setMode, raw setTool, setPhase's rewrite,
setStructureLayer's rewrite, keyboard, panels), so impossible states —
build with no tool, a lit tool in select mode, a paint swatch click that
never re-armed paint mode — were representable and survived reload.
The store now holds a ToolMode discriminated union as the source of truth
(build carries its tool by construction), with armToolMode as the sole
transition: it owns phase/viewMode promotions, default-tool election,
paint priming, and syncBrushModeScope, and materializes mode/tool mirrors
so the ~150 existing readers are untouched. armMaterialPaint arms paint
and sets the brush in one step — the material picker now routes through
it, so picking a swatch always returns to paint mode. setMode/setTool
remain as thin wrappers over the transition; rehydration normalizes the
persisted toolMode against legacy mode/tool pairs.
Claude-Session: https://claude.ai/code/session_018gQSsJ7nfdARkNH5PcKUjt
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
* editor: level-follow camera, snapshot walk/drone suite, opening placement regressions (#752)
* editor: camera follows the level across mode switches and new levels
Switching level presentation (stacked/exploded/solo) never moved the
camera — the level-frame effect only fired on selection change — and a
freshly created level framed at y=0 because the effect read the level
Object3D's position before LevelSystem had lerped it anywhere.
The effect now derives the destination analytically (stacked elevation +
exploded gap, shared with LevelSystem via getLevelPresentationY), watches
levelMode, and skips when already on target — which also swallows the
thumbnail generator's synchronous stacked/restore round-trip.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018gQSsJ7nfdARkNH5PcKUjt
* editor: studio snapshot camera polish — capture pill, instant pointer lock, wheel lens + click shutter
- The Studio capbar's preselected crop no longer hides the
standard/viewport/area pill: preselecting seeds the overlay, and only an
explicit host lockCrop (the publish cover's exact-shape capture) hides
the switcher.
- Switching the snapshot camera to walk/drone locks the pointer in the same
click (flushSync mounts the controls first) instead of demanding a second
canvas click.
- While walk/drone hold the lock: wheel drives the lens (accumulated
sub-degree deltas, wheel-up zooms in) and left click fires the shutter
alongside Enter. Walk's door-toggle click is silenced during capture, and
the acquiring click can't shoot (shutter gates on the lock being held).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018gQSsJ7nfdARkNH5PcKUjt
* editor: fix window on-wall placement preview and opening cursor facing
Two regressions in opening placement:
- #718 rewrote MoveWindowTool to publish drag state through
useLiveNodeOverrides, including `parentId` — but reparenting is
structural: the wall's CSG merge and the renderer's nesting walk the
wall's `children` array, which an override never joins. Placing a window
preset showed no on-wall preview at all (no cut, no mesh — only the
override-independent guides), while doors, still on scene writes, worked.
The wall branch and free-follow now write the scene exactly like
MoveDoorTool (reparent on host change, direct mesh transform + live
transforms on same-host slides), and stale overrides are dropped when
entering the wall mode.
- The door/window PLACEMENT tools still fed `calculateCursorRotation` into
the cursor and facing triangle — the helper #643 identified as π off and
migrated every other caller away from. The triangle pointed at the far
side of the wall on half the walls. Both tools now use the wall-child
world yaw (`itemRotation - wallAngle`, the move tools' convention), and
the helper is deleted so nothing can regress onto it.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018gQSsJ7nfdARkNH5PcKUjt
* editor: capture walk/drone — E opens, Esc pauses, click shoots, drone re-locks
Four snapshot-camera fixes:
- E/R open doors and windows again during capture walk (only the CLICK
path is capture-gated now — a locked click is the shutter), and the
walkthrough crosshair (dot → green ring over an interactable) renders in
the capture overlay, which replaces the walkthrough HUD.
- Esc acts like P in walk/drone: the browser's pointer-lock exit pauses
(cursor freed, camera and capture kept) instead of bailing to orbit and
throwing away the framed pose; the overlay only dismisses on Esc from
orbit. Covers both the keydown path and the no-keydown native unlock.
- The click shutter actually fires: FirstPersonControls' document-capture
mousedown handler stops propagation while locked, so the overlay's
listener moves to window-capture (and the door-toggle mousedown yields
during capture).
- Switching cameras right after freeing the cursor hit the browser's
~1.25s re-lock cooldown — the reason drone (only reachable with a free
cursor) never locked while walk-from-orbit did. The lock helper retries
once after the cooldown while still framing.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018gQSsJ7nfdARkNH5PcKUjt
* editor: freeze walk/drone while the shutter renders
From the click/Enter until the saved toast clears, look, walk physics and
drone motion hold still — a late WASD tap or mouse twitch no longer shifts
the frame out from under the shot the user just took.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018gQSsJ7nfdARkNH5PcKUjt
* editor: second Esc in capture walk/drone cancels the snapshot
First Esc frees the cursor (pause); with the cursor already free, Esc now
cancels capture — setCaptureMode(false) lands the camera back on orbit —
instead of doing nothing.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018gQSsJ7nfdARkNH5PcKUjt
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
* feat(cabinet): support exact sizing and run-aware editing (#753)
* Add roof surface placement support for items
Items (e.g. solar panels) can now be placed on sloped roof surfaces.
The placement system computes euler rotation from the roof surface
normal so items sit flush on the slope instead of going inside.
- Add roofStrategy to placement-strategies with enter/move/click/leave
- Wire roof:enter/move/click/leave events in the placement coordinator
- Add calculateRoofRotation in placement-math using surface normals
- Support full 3D cursor rotation for sloped surfaces
- Items on roofs are parented to the level with world-space rotation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fixed conflict
* Enhance modular cabinet editing and validation
* Complete cabinet interaction enhancements
* Fix architecture review findings
* fix cabinet wall opening awareness during moves
* feat cabinet exact dimension placement
* feat cabinet run width equalization
* feat cabinet run array duplication
* feat add wall cabinet height presets
* chore remove swing check and hinge quick action
* fix cabinet preview architecture findings
* fix(cabinet): preview linked L runs during width resize
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
* ?perf instrumentation suite: real GPU timestamps, system tracks, action receipts, DOM panel (#755)
* viewer: perf-tracks shared sink for ?perf instrumentation
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Nq2rLE18tFVES2LU6HGokK
* viewer/editor: ?perf instrumentation pass — real GPU timestamps, per-system User Timing tracks
- DRAW read info.render.calls (lifetime render() count, never reset) — now drawCalls
- GPU time now from WebGPU timestamp queries (trackTimestamp + resolveTimestampsAsync);
the old queue-fence delta stays as QUEUE (backpressure), encode CPU as ENCODE
- perf-tracks: shared sink emitting DevTools custom tracks (trackGroup Pascal) +
per-window counter buckets; perf-observers: longtask observer
- spans: frame-cpu (FrameLimiter advance), geometry builders, wall miter/rebuild/CSG,
door/window rebuilds, pointer raycast, react-render Profiler boundary
- panel: FRAME cpu avg/max, MEM (info.memory + JS heap), visible-only census at 2s,
TRACKS readout, clearPerfMeasures per drain; FPS threshold matches the 50fps cap
- deleted dormant DebugRenderer (unreferenced; would double-render if mounted)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Nq2rLE18tFVES2LU6HGokK
* viewer: perf panel as draggable DOM tool, out of the canvas
drei <Html> wrappers carry a camera-driven transform, which turns the old
overlay's position:fixed into 'fixed relative to the wrapper' — the panel
drifted with the camera. PerfMonitor is now a headless in-canvas collector
publishing to perf-panel-store; PerfPanel portals to <body>: draggable by
header, dockable to the nearest edge as a live fps tab, placement persisted
in localStorage.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Nq2rLE18tFVES2LU6HGokK
* viewer: perf-actions ledger contract + sample tap in perf-tracks
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Nq2rLE18tFVES2LU6HGokK
* viewer/editor: action-cost ledger for ?perf
Edit gestures now produce receipts: begin/commit/cancel bracket a gesture,
every perf-tracks sample in between is attributed to it, and the action
settles only when dirty nodes + deferred wall rebuilds hit zero and one more
GPU sample lands. Receipts surface in the panel (last action + breakdown),
the console, and a DevTools 'Actions' lane.
Call sites: the interaction scope store as the generic bracket (yields to
more specific ones), use-drag-action, 2D floorplan gestures, place/undo/
redo/delete/level-switch; markToolCancelConsumed finalizes cancels.
Settle system feeds the ledger per frame at priority 100.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Nq2rLE18tFVES2LU6HGokK
* viewer: window.__pascalPerf probe hooks for scripted perf runs
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Nq2rLE18tFVES2LU6HGokK
* viewer: settle counts only live dirty nodes
A node deleted while dirty (undo of a wall split) leaves its mark in
dirtyNodes forever — no system clears marks for missing nodes — and that
phantom dirt kept every action receipt from settling in furnished scenes.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Nq2rLE18tFVES2LU6HGokK
* perf ledger: review fixes — scope ownership, settle without timestamps, no-op undo
- the interaction scope now commits only the action IT began (id token), and
yields only to an UNCOMMITTED action, so a settling receipt can't swallow
the next gesture and a specific call site's cancel is never committed by
the generic bracket
- devices without timestamp-query settle on the queue fence instead of
timing every receipt out
- a no-op undo/redo no longer opens a receipt
- import order (CI quality)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Nq2rLE18tFVES2LU6HGokK
* viewer: declare react-dom (portal in perf-panel)
CI typecheck resolves per-package: the perf panel's createPortal import needs
react-dom declared, not inherited from hoisting. Same peer + types pattern as
packages/editor.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Nq2rLE18tFVES2LU6HGokK
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
* Add presentation.findInCatalog opt-out for the action menu's find button (#756)
Panel-placed plugin kinds (e.g. pets) have no catalog entry to find; let a
definition drop the Search action while keeping move/duplicate/delete.
Claude-Session: https://claude.ai/code/session_01FB5xnSoozJZ1jXCFgbLSDG
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
* capture-viewer: render extracted JSON preview artifacts (#757)
The manifest-first archive moved surface-mesh, point-cloud, and
device-motion payloads out of inline stream data into JSON preview
artifacts, but renderability and hydration still assumed inline —
surface mesh reported "no data", point cloud and the motion trajectory
silently vanished. Accept application/json payload artifacts as
renderable and fetch them into the inline payload shape the layers
already consume.
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
* Dirty-lifecycle correctness: guarded dirty set, undo phantom sweep, animation split (#758)
* perf probe: expose raw dirty-set census as __pascalPerf.dirtyResidue()
The panel's DIRTY readout filters to live nodes, so scripted matrix runs
could not see phantom marks (deleted-node ids) or distinguish stuck kinds.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Nq2rLE18tFVES2LU6HGokK
* Dirty-lifecycle correctness: guarded dirty set, undo phantom sweep, animation split
Three stuck-mark classes kept scenes from ever settling to DIRTY 0
(charter findings 7/8):
- ~120 call sites add to dirtyNodes directly, bypassing markDirty's
consumer-kind guard — a wall's parentId is a level, so unconsumable
level/building marks wedged forever. dirtyNodes is now a GuardedDirtySet
whose add() applies the guard itself.
- Undo/redo rewrites nodes without the delete actions, leaving marks for
nodes that no longer exist (rich-2x: 47 phantoms after one scripted
run). The temporal subscriber now sweeps marks whose node is gone.
- Door/window animation systems marked dirty every tween tick, so DIRTY 0
was unreachable while anything animated. A dirty mark is one-shot work:
DoorSystem rebuilds doors straight off doorAnimations entries, window
types without a direct pose path use a transient rebuild set, and only
the settled pose gets a final one-shot mark.
The ?perf settle detector counts the raw set again (its live-only filter
papered over the phantoms it now must catch).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Nq2rLE18tFVES2LU6HGokK
* wiki: dirty marks are one-shot work — animations signal via their records, not markDirty per tick
The 'system advances animation then calls markDirty' recipe was the
exact pattern behind charter finding 8; the dirtyTracking section now
describes the GuardedDirtySet enforcement.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Nq2rLE18tFVES2LU6HGokK
* review skill: scope 'markDirty per tick is fine' to bounded gestures
Unqualified, the aside could wave through an animation loop that marks
dirty every frame — the finding-8 class the GuardedDirtySet cannot
block, since animating kinds are legitimately consumable.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Nq2rLE18tFVES2LU6HGokK
* wiki: same bounded-gesture scoping for tools.md's markDirty aside
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Nq2rLE18tFVES2LU6HGokK
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
* editor: a failed scene load shows an error with retry instead of an empty scene (#759)
A host `onLoad` that rejects (failed fetch, timeout) used to fall through to
`applySceneGraphToEditor(null)`, i.e. the default site/building/level
scaffold. The autosave loop re-baselined on that cleared store, the next
store touch armed a save, and the scaffold was written over the real
project. Prod audit 2026-09-02: 10–100 such wipes per day; 11–13 % of forks
and template starts opened over two weeks lost their copied scene on the
first save.
Now a failed load keeps the store unloaded and the autosave loop in its
loading state (nothing can be written), and renders `SceneLoadFailed` with
a retry that re-runs the load effect.
Claude-Session: https://claude.ai/code/session_01DLB54VYmGTzvyHNFb3wWxE
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
* Node batching: items, columns, doors and windows draw through BatchedMesh containers (#760)
* perf probe: drawComposition() — per-item/per-asset/per-kind draw census
Feeds charter backlog #3: projected draws for per-item merge vs
per-asset instancing, plus a meshes-by-kind bucket for the non-item
side of the budget.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Nq2rLE18tFVES2LU6HGokK
* spike: BatchedMesh through the WebGPU pipeline (?spike=batch)
400-4,900 instances, two geometries, one material, shadows on. Verdict:
renders/shadows/post-FX clean; ~0.3us encode per instance (~10x cheaper
than a real mesh); per-instance frustum culling active (draw/tri track
the camera). WebGPU counts each multi-draw segment in info.render, so
the 3a metric is encode/frame-cpu ms, not draw calls.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Nq2rLE18tFVES2LU6HGokK
* Item draw batching v1: per-material BatchedMesh with wall-batch semantics (charter 3a)
Level-parented items render through one BatchedMesh per (level, material,
attribute-signature) — membership follows the dirty signal, lit items
release and draw themselves (outline/selection paint untouched), joins
wait for a quiet window, isolation stands the whole thing down, and
'thumbnail:before-capture' hands every item its meshes back so exports
never see a batch (belt: batches carry pascalExport='strip').
The container is incremental — instance add/delete per membership
change, geometry deduped per batch, capacity grown 2x on overflow. An
existing batch always accepts a rejoining item; only new batches need
MIN_BATCH_ENTRIES. v1 scope: items whose parent is a level; hosted
items (wall/ceiling/roof) move on host edits that never dirty the item,
so they keep drawing themselves. Interactive/animated/transparent items
excluded by the same rule as walls.
Rich 2x: 114 of 270 items batched (304 instances, 37 batches), idle
frame cpu 10.65 -> ~8.3ms. Full matrix + gates follow.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Nq2rLE18tFVES2LU6HGokK
* item batch: prune batches orphaned by level-subtree remounts + probe surface
A React remount of a level subtree (thumbnail capture level shuffling,
tool-state swings) replaces the registry groups: imperatively-parented
batch meshes die with the old group while fresh source clones mount with
no layer hold. pruneDetached() spots the orphaned batches by parent
identity each frame and re-stales their items. ?perf probe gains
stats/wave/census/batchRender hooks for scripted verification.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Nq2rLE18tFVES2LU6HGokK
* ?perf: draw row shows batched instance share
On WebGPU each batched instance still counts once in drawCalls (the
backend loops drawIndexed per visible instance), so a batched scene
looked no cheaper by the panel's DRAW number. The row now reads e.g.
'581 (272 batched · 2 mesh)' — live per sample, so per-instance frustum
culling is visible as the camera moves.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Nq2rLE18tFVES2LU6HGokK
* ?perf: batch row shows membership truth, not per-pass culling
The first cut read _multiDrawCount, which snapshots whichever camera
culled the batch last — shadow vs main vs outline passes made the
number flip (206 -> 11 on hover) and read as items dropping out of the
batch. The batch system now publishes its membership (items/instances/
containers) to the panel store; the row is stable and only moves when
membership actually changes.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Nq2rLE18tFVES2LU6HGokK
* Node batching 3b: doors, windows and columns join the batch (charter 3a+3b)
item-batch generalizes to shared/node-batch: same wall-batch semantics,
BatchedMesh containers per (level, material, attribute-signature), now
covering items, columns and wall-hosted openings (resolved to the host
wall's level). New release triggers: a dirty WALL cascades to its
openings (the wall edit moves them without marking them), a host wall
that is lit or mid-gesture releases its openings, and a door/window
whose animation record appears draws itself for the tween. Hitboxes
(material.visible=false) and glass (transparent) never batch. Bake
pages (?disable=draw) stand batching down entirely, and the release-
everything paths sweep every level subtree for stale 'batched' holds —
a system can rebuild a batched node's meshes and orphan the tracked
refs, and a stale hold is exactly what the GLB exporter would prune.
Rich 2x: 188 nodes / 1,108 instances batched, in-page A/B frame
9.1 -> 7.4ms (-19%); rich 4x: 2,280 instances, 19.3 -> 14.1ms (-27%).
Gates: e2e 8/8; bake tri+byte parity batching-on vs off; in-session
pixel diff 0.4% confined to seam AA and transparent blend order.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Nq2rLE18tFVES2LU6HGokK
* lint: sort node-batch imports/exports, format store
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Nq2rLE18tFVES2LU6HGokK
* node batch: id-diff membership + per-batch geometry refcounts (Bugbot findings)
A same-size add-and-remove slipped past the count tell and left the
removed node's instances drawing as ghosts — membership now diffs ids
against last frame's registry. Released geometries drop their packed
mapping at refcount zero, so a rejoin re-packs current vertex content
(a rebuilt geometry can reuse its uuid) instead of the copy captured at
first join; the orphaned range stays until the existing overflow
rebuild reclaims it.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Nq2rLE18tFVES2LU6HGokK
* node batch: content-stamped geometry reuse + container culling off (Bugbot round 2)
The refcount fix traded one problem for another: dropping the packed
mapping at zero made every hover release/rejoin cycle re-pack the same
geometry, inflating used until premature overflow rebuilds. The mapping
now survives cycles and carries a content stamp (position version +
counts) — reuse is free, and a geometry rebuilt in place under the same
uuid re-packs instead of instancing stale vertices. Whole-container
frustumCulled goes off: its bounding sphere is computed at first cull,
so instances joining farther out later could vanish with the whole
batch — per-instance culling already owns visibility.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Nq2rLE18tFVES2LU6HGokK
* node batch: hosted child nodes' subtrees stay out of the host's candidate walk (Bugbot round 3)
An item can host other items (a shelf's books) whose registered groups
mount inside the host's group — the walk packed those meshes as the
HOST's instances, freezing the child at join pose with no release of
its own. The walk now cuts at every hosted child's registered group;
hosted nodes keep drawing themselves (they are outside v1 batch scope
by the level-parent rule anyway).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Nq2rLE18tFVES2LU6HGokK
* node batch: hidden-wall openings, autoplaying clips, late-copy gathering (Bugbot round 4)
- A hidden wall hides its openings through group visibility; batch
instances hang off the level root and kept drawing them. Openings of
an invisible wall are no longer candidates (the wall's visibility
dirty-mark cascades the release).
- ItemAnimation autoplays a GLB's first clip even without an
interactive effect; such items batched and froze mid-motion. The
renderer stamps clip presence on the registry group and candidates
exclude it.
- Below-threshold candidates were dropped after their wave, so copies
placed more than a settle window apart never gathered into a batch.
A new id now re-stales every unbatched node, letting the copy that
crosses MIN_BATCH_ENTRIES pull earlier ones in.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Nq2rLE18tFVES2LU6HGokK
* node batch: partial members re-offer leftovers on new placements (Bugbot round 5) + import sort
store.has locked a partially-joined node (some meshes under the
new-batch threshold) out of every later wave. Partial members are now
tracked; a new placement releases them for a full re-collect, so the
copy that makes a leftover bucket viable pulls them in.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Nq2rLE18tFVES2LU6HGokK
* lint: format node-batch system
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Nq2rLE18tFVES2LU6HGokK
* node batch: overrides release + deferred-peer gathering (Bugbot round 6)
Live overrides now release an already-batched node (a collaborator's
remote drag or a programmatic move carries no local selection to tint
it) and defer, rather than drop, a stale one — the commit mark
re-offers it. Threshold-short candidates land in a leftover set that
re-offers as a group when a NEW leftover arrives, so a copy that was
deferred (selected, dirty, loading) while its peers' wave ran can still
gather them into a batch; a stable leftover set re-offers nothing and
small scenes stay quiet.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Nq2rLE18tFVES2LU6HGokK
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
* Wall batching stays live in cutaway (#761)
* Wall batching stays live in cutaway
Cutaway never changes wall geometry: WallCutout swaps each wall's material
array by camera facing and stamps userData.wallHidden. The merged batch
already released tinted walls per frame, so hidden walls take the same
path — released the frame the stamp appears (WallCutout runs at priority
0, this system at 5), excluded from candidates and from the re-merge drift
count, re-sewn at settle when they come back. Mode flips between up and
cutaway no longer dispose every level; down, translucent and isolation
still stand the batch down.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Jmmz2AMwTzcnKsSHHPEMhN
* Wall batch: expose membership to ?perf probes
The panel's batch row covers node batching only; scripted runs had no way
to tell whether the merged wall batch was live in a given wall mode.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Jmmz2AMwTzcnKsSHHPEMhN
* Wall batch: re-sew a level when its cutaway-hidden walls come back
Releasing on the hidden stamp covered only half the flip: when the stamp
lifted nothing marked the level stale, so a wall that became visible again
drew itself until an unrelated edit re-sewed the floor. Bugbot caught it;
the parity probe confirmed it (rich-4× stayed at 172 batched walls after
returning to full height, now 352).
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Jmmz2AMwTzcnKsSHHPEMhN
* Wall batch: keep the remembered hidden set apart from the exclusion set
They aliased the same Set, so tinted walls leaked into last frame's hidden
set and read as stamp lifts every frame — the settle window never closed
while anything was selected or hovered. Bugbot caught it. The regression
test hovers one wall after a flip and expects the other eight to re-sew.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Jmmz2AMwTzcnKsSHHPEMhN
---------
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
* Wall load fixes: treatment fan-out, one CSG cut per wall, capture draw leak, converter duplicates (#762)
* Wall treatments: recompute level miters only when their inputs change, subscribe per wall
While any wall on a level was dirty, the treatment system recomputed the
level's miters every frame (uncached, once per proud offset) and wrote a
fresh object to its store; every wall renderer on the level subscribed to
that object, so all of them re-rendered each frame — 65k WallTreatments
renders in 12 s on the IFC castle, and the same fan-out on every wall drag.
Now the system skips a level whose effective walls (identity, with live
overrides cached per override) and proud offsets are unchanged, caches the
per-proud miter data on those inputs, and each wall subscribes to a slice
holding only its own endpoint intersections, compared structurally. Walls
with no trim enabled mount no treatment work at all.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Jmmz2AMwTzcnKsSHHPEMhN
* Wall openings: union the cutouts and subtract once; give heavy walls their own frame
Each opening was subtracted in turn from a result that grew with every
cut, so a wall with 20 openings paid 20 passes over an ever-larger mesh
(70 ms in one call on the IFC castle). The cutouts are now grouped by
bounding-box overlap: disjoint ones are merged as-is, overlapping groups go
through a real union, and the wall is cut once. The progressive rebuild
loop also defers a wall with six or more cutouts when the frame has already
rebuilt something, instead of checking the time budget only between walls.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Jmmz2AMwTzcnKsSHHPEMhN
* Wall batch: keep its holds out of the node batch's capture sweep
The project thumbnail autosave fires 30–40 s after load and emits
thumbnail:before-capture. The node batch answers by revealing every mesh
held under the shared 'batched' reason — including the wall sources the
merged wall batch was already drawing — and nothing re-hid them: every
batched wall drew twice (and cast shadows twice) for the rest of the
session. Measured on rich-4×: 4 494 → 5 662 draws, 11.8 → 17.1 ms, forever.
Wall holds now carry their own reason, and the wall batch handles capture
itself: sources come back for the capture (exports still prune off-layer
meshes) and go under again on thumbnail:after-capture.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Jmmz2AMwTzcnKsSHHPEMhN
* Wall openings: drop coincident box cutouts, cap the union at four
A real IFC import carries the same door eight times on one wall; coincident
boxes are the worst input a boolean can get, and a union chain over them
took 148 ms and then froze the page. Box cutouts fully inside another box
are dropped before grouping, overlapping groups of up to four are unioned,
and larger groups fall back to the bounded chained subtraction.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Jmmz2AMwTzcnKsSHHPEMhN
* IFC converter: emit each door and window once
Every void relationship for a wall appended to its opening list, and the
emission loop created a fresh node per visit, so a fill referenced by
repeated relationships became eight identical doors on one wall (the
sample castle). A fill belongs to one opening, which voids one host, so
emitted fill ids are now tracked globally; spatial children use sets.
Existing converted scenes keep their duplicates until reconverted.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Jmmz2AMwTzcnKsSHHPEMhN
* Wall placeholder sweep: stamp rebuilt geometry so degenerate walls stay built
A zero-length or fully cut wall rebuilds to as few vertices as the mount
placeholder, and the sweep re-marked it every 30 frames — 21 castle walls
rebuilt forever and their level's batch re-sewed with them.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Jmmz2AMwTzcnKsSHHPEMhN
* Sort imports in the wall batch test
Co-Authored-By: Claude F…
Split out of #720 as requested in the review — the materials fix on its own, so it doesn't wait on the import-page discussion.
The bug
validateBuildJsondrops the top-levelmaterialstable: everyscene:<id>slot ref in an imported file points at a material that no longer exists, so custom finishes silently revert to defaults on Load Build. Confirmed against main:handleConfirmImportpasses onlyinstalledPluginstosetScene, whoseextra.materialssupport already exists.The fix
ParsedBuildJsongainsmaterials?: Record<string, SceneMaterial>; entries are validated one by one (SceneMaterial.safeParse), invalid ones skipped with a warning so a bad material never takes the import down.safeParse().datainjects defaults and drops unknown keys — the opposite ofapiGraphSchema's preserve-unknowns stance — because import feeds the live scene store, which only understands schema-shaped materials. The in-line comment states this and why.handleConfirmImportnow takesParsedBuildJsondirectly (no widened record + cast) and handsparsed.materialstosetScene.bun:test(bun test src/validation: 8 pass);tsc --noEmitandbiome checkclean; no lockfile changes.The review's other points (vitest→bun:test in the page test, byte-accurate size cap, capture-protocol seam) are being addressed on #720.
🤖 Generated with Claude Code
Note
Low Risk
Scoped to build JSON validation and editor save/import; invalid materials are warned and skipped without blocking import.
Overview
Load Build no longer drops the top-level
materialstable, which fixes custom finishes silently reverting when nodes referencescene:<id>slot refs.validateBuildJsonnow accepts optionalmaterials, validates each entry withSceneMaterial.safeParse(normalized output for the scene store), skips bad entries withinvalid_materialswarnings that name the ids, and includes valid materials onParsedBuildJson. The editor Save Build export includes scenematerials, and Load Build passesparsed.materialsintosetSceneon confirm. Tests cover valid carry-through, partial invalid entries, and non-objectmaterials.Reviewed by Cursor Bugbot for commit 2996a11. Bugbot is set up for automated code reviews on this repo. Configure here.