editor: gate Load Build behind a verification dialog#320
Merged
Conversation
Loading JSON previously called setScene blindly and crashed when the file held schema-invalid nodes (e.g. items missing `asset`). The new dialog parses the file, runs validateBuildJson in core, and surfaces structure counts (site/building/levels/walls/doors/ windows/items/slabs/ceilings/zones/scans), floor area, and a per-node Schema Details list grouped by type. Import is blocked when any hard error exists. Two schema bugs the validator surfaced are fixed here too: - SiteNode.children is now an id array like every other node (was a discriminatedUnion of full objects; three readers carried a string-or-object ternary that's now dropped). migrateNodes flattens legacy nested-object children on load. Default-scene seed and photo-to-scene MCP builder updated to pass `building.id`. - LevelNode.children now includes shelf — the editor allowed it but the schema didn't. The schema-vs-registry-as-source-of-truth discussion is captured in plans/editor-node-registry.md. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
4 tasks
wass08
pushed a commit
that referenced
this pull request
May 21, 2026
Fixes breakage introduced by #320 which changed `SiteNode.children` from embedded `BuildingNode | ItemNode` objects to flat `string[]` IDs. - `packages/mcp/src/lib/rehydrate-site-children.ts`: replace now-obsolete re-embedding logic with a no-op passthrough (call-site compatible) - `packages/mcp/src/tools/variants/generate-variants.ts`: drop the inline copy of the same function and its call - `packages/nodes/src/site/renderer.tsx`: cast `childId as AnyNodeId` since `SiteNode.children` is now `string[]`, not `AnyNodeId[]` Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
4 tasks
wass08
pushed a commit
that referenced
this pull request
May 21, 2026
PR #320 changed SiteNode.children from embedded BuildingNode/ItemNode objects to flat string[] IDs. PR #325 updated the runtime call sites but missed the three scene templates, which still mutated the site node's children array to embed full building objects after building the flat dict. This caused AnyNode.safeParse to fail for site_empty, site_2br, and site_garden in bun test --cwd packages/mcp. Remove the obsolete mutation blocks; each template already initialises site.children with the correct string id (e.g. ['building_empty']). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Loading a JSON build previously called
setSceneblind and could crash the editor on schema-invalid input (e.g. items missingassetfrom a buggy IFC export). This PR gates Load Build behind a verification dialog that parses + validates the file first.validateBuildJsonin@pascal-app/core— pure pre-flight: structural errors (missingnodes/rootNodeIds, no valid roots, duplicate keys), per-node Zod parse with fullSchemaIssue[]detail, orphan-parent / unknown-type / no-building / no-levels warnings, plus floor-area sum across slab polygons (minus holes).LoadBuildDialog— title + ✓/✗, filename + size + node count, errors block (red), structure summary per node type (sites, buildings, levels, walls, doors, windows, items, slabs, ceilings, zones, scans) with floor area row, warnings block, collapsible Schema Details list grouped by node type (every failure shown — no truncation). Import is blocked on any hard error.handleFileLoadnow parses → validates → opens the dialog.setSceneis deferred to confirm.Two schema bugs surfaced by the validator on real saves are fixed in the same PR:
SiteNode.childrenis nowz.array(z.string())— every other node has used id arrays for years, andSiteRenderer/use-editor/site-panelall carried atypeof child === 'string' ? child : child.idternary. The default-scene seed inuse-scene.tsand the photo-to-scene MCP builder now passbuilding.idinstead of the full object.migrateNodesflattens legacy nested-object children on load so older saved scenes still import.LevelNode.childrennow includesshelf— the editor allowed shelves parented to a level but the schema's union didn't list them, so a clean save → load roundtrip failed validation. The schema-vs-registry-as-source-of-truth discussion (drop the unions entirely and lean onrelations.hosts) is captured inplans/editor-node-registry.mdunder Open questions in the private-editor repo.How to test
bun dev:community(or the standalone editor) and open the build editor.editor/packages/core/...or any IFC-converter output with bad nodes (items missingasset, doors with scalarposition, etc.). Dialog title becomes "Cannot import this file", the error block lists the failure count, and the Schema Details section enumerates every failing node withnodeId · path — message. Import button is disabled..txt). Dialog opens with "File could not be parsed as JSON".{}. Errors list both missing-nodes and missing-rootNodeIds.Screenshots / screen recording
N/A here — happy to add a short clip if useful.
Checklist
bun devbun checkto verify)mainbranch🤖 Generated with Claude Code