Skip to content

Fix stale mesh references and execution state on project reload#534

Open
tracygardner wants to merge 1 commit intomainfrom
claude/fix-workspace-mesh-updates-lweto
Open

Fix stale mesh references and execution state on project reload#534
tracygardner wants to merge 1 commit intomainfrom
claude/fix-workspace-mesh-updates-lweto

Conversation

@tracygardner
Copy link
Copy Markdown
Contributor

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 in loadWorkspaceAndExecute() 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 allow loadWorkspaceAndExecute() to reset the isExecuting guard 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 to window.currentBlock?.id when getBlockKeyFromBlock() 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 meshMap entries 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

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
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 14, 2026

Warning

Rate limit exceeded

@tracygardner has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 12 minutes and 27 seconds before requesting another review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1cb486d2-3b06-4d78-9b05-a9517c5e2600

📥 Commits

Reviewing files that changed from the base of the PR and between 6928646 and 76927b6.

📒 Files selected for processing (4)
  • main/execution.js
  • main/files.js
  • ui/blockmesh.js
  • ui/gizmos.js
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/fix-workspace-mesh-updates-lweto

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying flockxr with  Cloudflare Pages  Cloudflare Pages

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

View logs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants