Fix realtime terrain and scene collaboration primitives - #573
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.
Reviewed by Cursor Bugbot for commit f65686e. Configure here.
| set((state) => { | ||
| const next = new Map(state.remoteStrokes) | ||
| next.set(siteId, { sourceId, field, lastPatch: patch }) | ||
| return { remoteStrokes: next } |
There was a problem hiding this comment.
Remote previews skip terrain mesh
High Severity
The new remoteStrokes are exposed via fieldOf, but downstream rendering and persistence logic isn't fully updated. This causes remote sculpts to appear flat on the grid, prevents mesh updates from remote lastPatches, and allows remote previews to incorrectly override persisted terrain after updates.
Reviewed by Cursor Bugbot for commit f65686e. Configure here.
| ...node, | ||
| children: children.filter( | ||
| (childId) => !(typeof childId === 'string' && removedNodeIds.has(childId)), | ||
| ), |
There was a problem hiding this comment.
Migration keeps non-string children
Low Severity
When stripping retired drawing-sheet ids from parent children, the new helper removes only string entries in the retired set, while the inlined migrateNodes logic normalized via getStringArray, dropping non-string entries whenever a parent was rewritten.
Reviewed by Cursor Bugbot for commit f65686e. Configure here.


Summary
Automated verification
bun test packages/core/src packages/editor/src/lib/terrain-sculpt.test.ts— 949 passedbun run check-types— 9 tasks passedgit diff --checkpassedManual verification
Note
Medium Risk
Changes live terrain resolution and sculpt commit baselines (easy to get wrong vs. persisted state), plus new decode paths for patch payloads; scene migration is isolated but runs on every load.
Overview
Adds collaboration primitives so remote terrain sculpting can render in-session without polluting local undo/history.
Live terrain gains a separate remote preview layer (
previewRemote,endRemote,endRemoteSource): observers see in-progress strokes, local strokes override remote previews, and sculpt starts/commits from persisted ground via newpersistedTerrainFieldOf(whileterrainFieldOfstill merges local + remote for rendering/raycasts).Wire format: bounded height patches are encoded/decoded as base64 int16 samples (
encodeHeightPatch/decodeHeightPatch), sharing helpers with full-field terrain codec.Scene load: retired
drawing-sheetremoval moves to immutableremoveRetiredDrawingSheetNodesand is exposed as@pascal-app/core/scene-migrationsfor server-side authority.Editor re-exports
subscribeCameraPosefor hosted camera awareness; terrain sculpt baseline reads persisted terrain only.Reviewed by Cursor Bugbot for commit f65686e. Bugbot is set up for automated code reviews on this repo. Configure here.