Skip to content

Fix Monaco workspace initialization and selected-file preview regressions in WorkspaceCodeEditor#9

Merged
rushabhcodes merged 2 commits into
tscircuit:mainfrom
rushabhcodes:fix/monaco-workspace-init-and-preview-regressions
Jun 29, 2026
Merged

Fix Monaco workspace initialization and selected-file preview regressions in WorkspaceCodeEditor#9
rushabhcodes merged 2 commits into
tscircuit:mainfrom
rushabhcodes:fix/monaco-workspace-init-and-preview-regressions

Conversation

@rushabhcodes

Copy link
Copy Markdown
Contributor

Summary

This PR fixes two regressions in the workspace editing and preview flow:

  1. WorkspaceCodeEditor could remain stuck on Loading editor... even after the priority file was fetched.
  2. The runframe preview could switch to non-runnable helper files when the selected file was not a real entrypoint.

It also strengthens Monaco workspace model initialization so cross-file TypeScript state is synchronized before the editor is shown.

What Changed

  • Added explicit workspace model readiness tracking in WorkspaceCodeEditor.
  • Switched initial workspace model sync to useLayoutEffect so Monaco models are populated before the editor renders.
  • Added a post-mount re-sync to trigger a clean TypeScript pass once the editor is mounted.
  • Fixed the isPriorityFileFetched compatibility gate so true means the priority file is ready instead of blocking editor mount.
  • Tightened tscircuit entrypoint resolution so selected files only override the preview when they look like a real default-exported entry component.
  • Prevented named-export helper files from hijacking the live preview.
  • Updated Monaco workspace URIs to use monaco.Uri.file(...) for file-backed workspace models.
  • Expanded the runframe fixture to exercise a multi-file board setup with imported components and manual edits.

User Impact

Before this change:

  • Some hosts could leave the editor permanently stuck in a loading state.
  • Monaco could initialize before the full workspace model graph was ready.
  • Selecting a helper TSX file could redirect the preview away from the actual runnable board entrypoint.

After this change:

  • The editor mounts once the workspace and priority file are actually ready.
  • Cross-file Monaco state is synchronized earlier and refreshed after mount.
  • The preview stays on a runnable board entrypoint unless the selected file is a valid default-exported entry file.

Why This Matters

This is a user-facing workspace UX fix. It improves editor readiness, stabilizes cross-file Monaco behavior, and prevents incorrect preview switching during normal file navigation in multi-file tscircuit projects.

Validation

  • bun run typecheck

@vercel

vercel Bot commented Jun 29, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
monaco-code-editor Ready Ready Preview, Comment Jun 29, 2026 3:12am

Request Review

@rushabhcodes rushabhcodes marked this pull request as ready for review June 29, 2026 03:14
@rushabhcodes rushabhcodes merged commit 63e40da into tscircuit:main Jun 29, 2026
4 checks passed
@rushabhcodes rushabhcodes deleted the fix/monaco-workspace-init-and-preview-regressions branch June 29, 2026 03:15
@tscircuitbot

Copy link
Copy Markdown
Collaborator

Thank you for your contribution! 🎉

PR Rating: ⭐⭐⭐
Impact: Major

Track your contributions and see the leaderboard at: tscircuit Contribution Tracker


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