Three concrete bugs surfaced when first-running the spike in community:
1) NEXT_PUBLIC_USE_REGISTRY_FOR_SPAWN flag never detected:
The previous readEnvFlag used dynamic bracket access
(`env?.[name]`), which Next.js / Turbopack does NOT substitute at
build time. Only literal `process.env.NEXT_PUBLIC_FOO` references
get inlined into the client bundle. Switched to literal access
plus a `typeof process` guard. Spawn now toggles via the flag as
designed.
2) Shelf cursor appeared offset from the mouse:
The cursor mesh lives inside the ToolManager's building-local
group, but the tool was setting `cursorRef.current.position` to
level-local coordinates (computed via `worldToLocal(level)`).
Result: cursor shifted by (building-pos − level-pos) in worst
case. Switched cursor display to use `event.localPosition`
(already building-local) with grid snap — matches the legacy
spawn-tool pattern. The commit path keeps the worldToLocal(level)
conversion since the shelf node's `position` field is stored
relative to its level parent.
3) Shelf rendered invisibly after click (suspected):
The renderer used a useEffect-swap pattern where it mounted an
empty <group> and imperatively added Three.js children from a
buildShelfGeometry() Group. Plausibly fragile under StrictMode
double-invoke or fast HMR. Switched to inline R3F JSX — top
board + brackets as plain <mesh> primitives. The pure geometry
function still exists in geometry.ts for tests and AI-authored
consumers; renderer just doesn't go through it.
Diagnostics added (dev-only; removed once spawn parity ships):
- `[shelf] placed <id> level-local <pos> parent <levelId>` on click
- `[shelf] rendered <id> at <pos>` on mount
Also: types: ["node"] in nodes/tsconfig.json so the typeof process
guard typechecks cleanly.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The first time registry-driven nodes actually run in the editor.
Spawn migration (under NEXT_PUBLIC_USE_REGISTRY_FOR_SPAWN flag):
- New packages/nodes/src/spawn/ folder with renderer, tool, schema
(re-exported from core), parametrics, definition, index.
- Spawn definition appended to builtinPlugin.nodes only when the flag
is set. With the flag off, the Phase 0 shims fall through and the
legacy SpawnRenderer / SpawnTool keep ownership.
- New no-props SpawnTool reads activeLevelId from useViewer directly,
matches legacy placement behavior (half-meter snap, singleton-per-
level, replace-on-reclick).
- Structural parity test (9 cases) validates definition shape +
schema identity. Pixel-diff defers to Phase 4 alongside more nodes.
New shelf node (no legacy — registered unconditionally):
- ShelfNode schema in core/schema/nodes/shelf.ts (hand-maintained
AnyNode union for now; Phase 6 derives the union from the registry
and moves the schema fully into nodes/shelf/).
- packages/nodes/src/shelf/ folder: pure geometry builder
(buildShelfGeometry returns a Three.js Group of top board +
brackets), R3F renderer that mounts the built group, no-props
placement tool, parametrics descriptor (width/depth/thickness/
height/bracketStyle/color), definition with surfaces.top stackable
surface for future stacking, and presentation metadata for the
palette.
- 13 unit tests across schema bounds and geometry behavior.
- Palette wiring: 'shelf' added to StructureTool union + an entry in
the structure-tools array (placeholder icon, replaced in Phase 4
when palette is registry-driven).
Framework changes:
- @pascal-app/viewer now exports useNodeEvents from its public barrel
so node bundles in @pascal-app/nodes can subscribe to node-specific
pointer events. (Used by spawn renderer; shelf renderer skips it
for now since useNodeEvents has a hardcoded kind list — Phase 4
generalizes it via the registry.)
- @pascal-app/nodes gains @pascal-app/viewer as a peer + dev dep so
node bundles can import from it.
630 tests pass across 76 files (22 new this phase). Editor app
continues to ship green with both legacy spawn and the new shelf
node co-existing through the Phase 0 dispatch shims.
To validate end-to-end in dev:
- bun dev:community → open editor → click 'Shelf' in structure
toolbar → click to place. Confirms full registry path
(NodeRenderer dispatch + ToolManager dispatch + sceneRegistry
byType Proxy).
- Set NEXT_PUBLIC_USE_REGISTRY_FOR_SPAWN=1, restart dev, place spawn
→ visually identical to legacy. Confirms parity.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
New workspace package that owns built-in node bundles, one folder per
kind. Today the plugin is empty — no behavior change. Future commits
will add column/, shelf/, wall/, etc. and append each definition to
builtinPlugin.nodes.
The package depends on core (registry types) at v1; viewer, editor,
react, three are declared as peer deps so future node bundles can use
them without bumping their own version on every monorepo bump.
External plugins land as separate packages with the exact same shape
— this package is the dogfooded reference.
Tests: builtinPlugin shape + loadPlugin succeeds with zero kinds.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>