Fix stale mesh references and execution state on project reload#534
Fix stale mesh references and execution state on project reload#534tracygardner wants to merge 1 commit intomainfrom
Conversation
When the same .flock project is reloaded, block IDs are identical before and after the reload. If a gizmo/block colour interaction had previously populated meshMap["abc123"] = block1, workspace.clear() disposes block1 but the stale entry remains in meshMap. The guard in updateBlockColorAndHighlight treated it as truthy, bypassing the ws.getBlockById() fallback, causing silent failures. - main/files.js: call clearMeshMaps() before workspace load to drop stale disposed-block references; call window.cancelExecution?() to unblock any lingering isExecuting guard before the fresh run - main/execution.js: expose window.cancelExecution to allow files.js to reset the guard without a circular import - ui/blockmesh.js: extend the meshMap guard to also catch disposed blocks and blocks detached from the workspace, so the fallback fires even if stale entries slip through - ui/gizmos.js: add ?? window.currentBlock?.id fallback in focusCameraOnMesh so blockKey lookup succeeds after clearMeshMaps() empties blockKeyByBlock https://claude.ai/code/session_01TYhT3DLqdA1jpETGJpxpBy
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 12 minutes and 27 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Deploying flockxr with
|
| Latest commit: |
76927b6
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://a919f351.flockxr.pages.dev |
| Branch Preview URL: | https://claude-fix-workspace-mesh-up.flockxr.pages.dev |
Summary
This PR fixes issues that occur when reloading a project by clearing stale mesh-map entries and resetting execution state before loading a new workspace. It also adds defensive checks to handle disposed blocks and improves block key resolution in the gizmo system.
Key Changes
Clear stale mesh maps on reload: Added
clearMeshMaps()call inloadWorkspaceAndExecute()to remove disposed block references from previous runs. This prevents stale entries from shadowing workspace lookups when reloading projects with identical block IDs.Reset execution guard on reload: Exposed
cancelExecution()function to allowloadWorkspaceAndExecute()to reset theisExecutingguard before triggering a fresh run. The new execution will abort any previous run via its own abort-controller mechanism.Add defensive checks for disposed blocks: Enhanced
updateBlockColorAndHighlight()to check if a block is disposed or lacks a workspace before using it from the mesh map, falling back to workspace lookup if needed.Improve block key resolution: Updated
focusCameraOnMesh()to fall back towindow.currentBlock?.idwhengetBlockKeyFromBlock()returns undefined, providing more robust block identification.Implementation Details
The core issue addressed is that when a project is reloaded, block IDs remain identical, so stale
meshMapentries from the previous run would shadow the workspace-lookup fallback and cause gizmo/block color updates to silently fail. The fix ensures a clean state by clearing the mesh maps before loading the new workspace and resetting the execution guard to allow the new run to proceed cleanly.https://claude.ai/code/session_01TYhT3DLqdA1jpETGJpxpBy