fix: preserve scene material document state - #560
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 9970b0c. Configure here.
| nodes: state.nodes, | ||
| rootNodeIds: state.rootNodeIds, | ||
| collections: state.collections ?? {}, | ||
| materials: state.materials, |
There was a problem hiding this comment.
MCP save drops materials
High Severity
SceneBridge.exportJSON now includes materials, but SceneOperations.exportSceneGraph still returns only nodes, roots, collections, and plugins. MCP save_scene and live sync publish through exportSceneGraph, so custom scene materials are dropped on persist even though import/export round-trips them in tests.
Reviewed by Cursor Bugbot for commit 9970b0c. Configure here.
|
|
||
| versionRef.current = payload.version | ||
| lastRemoteGraphJsonRef.current = sceneGraphSignature(payload.graph) | ||
| suppressRemoteSaveUntilRef.current = Date.now() + 2500 |
There was a problem hiding this comment.
Remote echo uses pre-apply graph
Medium Severity
Live sync stores the echo signature from the SSE payload.graph before applySceneGraphToEditor, while autosave signs the store graph after setScene migration and cleanup. Those graphs often differ, so exact echo fails and the removed 2.5s save suppress no longer blocks redundant PUTs after remote updates.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 9970b0c. Configure here.


Summary
Checks
bun test packages/core/src/utils/clone-scene-graph.test.ts packages/mcp/src/storage/sqlite-scene-store.test.ts packages/mcp/src/bridge/scene-bridge.test.ts apps/editor/lib/graph-schema.test.ts apps/editor/lib/scene-sync.test.ts— 83 passed.bun run --cwd packages/core buildbun run --cwd packages/mcp buildscene-sync.tsandscene-loader.tsx.Note
Medium Risk
Touches untrusted graph validation and multi-session save/sync behavior; changes are bounded by schema checks and targeted tests but affect how scene payloads are accepted and written.
Overview
Fixes loss of custom scene document state (materials, collections, installed plugins) when scenes are saved, cloned, imported/exported, or synced live.
Persistence & validation:
materialsare now part of the coreSceneGraphclone/fork path (deep-cloned on duplicate), validated on API (apiGraphSchemawithSceneMaterial, including unsafe texture URL rejection) and SQLite graph parsing. MCP SceneBridgeexportJSON/loadJSONandsetSceneextras round-trip collections, materials, and explicit plugin installs in one load.Live sync: Shared
scene-synchelpers build a signature that includesmaterials(and other persisted fields). The editor skips autosave only when the outgoing graph exactly matches the last applied remote event—replacing a broad time-based suppress—so a local edit right after a live update still saves.Reviewed by Cursor Bugbot for commit 9970b0c. Bugbot is set up for automated code reviews on this repo. Configure here.