Skip to content

Claude/fix ide file loading pdy2 l#3

Open
wltt1004 wants to merge 7 commits intoCortexLM:mainfrom
wltt1004:claude/fix-ide-file-loading-pdy2L
Open

Claude/fix ide file loading pdy2 l#3
wltt1004 wants to merge 7 commits intoCortexLM:mainfrom
wltt1004:claude/fix-ide-file-loading-pdy2L

Conversation

@wltt1004
Copy link

No description provided.

claude and others added 7 commits February 25, 2026 18:53
Root cause: Monaco editor had no worker configuration (self.MonacoEnvironment),
causing workers to fail silently in Vite/Tauri and the editor to hang during
initialization.

Changes:
- Add MonacoEnvironment.getWorker() config with proper Vite worker URLs
  using new URL(..., import.meta.url) for all Monaco workers (editor, JSON,
  CSS, HTML, TypeScript)
- Replace static CodeEditor import in MultiBuffer.tsx with lazy() import to
  prevent pulling all editor dependencies into the initial chunk
- Add 15s timeout on Monaco loading to prevent permanent loading spinners
- Add retry limit (max 2 attempts) in createEffect to prevent infinite
  retry loops when Monaco fails to load

https://claude.ai/code/session_015pVrWpDDycPtrZNiJEod36
The infinite loading spinner was caused by Monaco not being in Vite's
optimizeDeps.include. Without pre-bundling, Vite serves 500+ individual
ESM files on first dynamic import, triggering an on-the-fly re-optimization
that blocks the import indefinitely.

Changes:
- Add "monaco-editor" to optimizeDeps.include in vite.config.ts so Vite
  pre-bundles it at dev server start instead of on first request
- Add ErrorBoundary around LazyEditor's Suspense to catch and display
  module load failures with a retry button, instead of an infinite spinner

https://claude.ai/code/session_015pVrWpDDycPtrZNiJEod36
ROOT CAUSE: containerRef was a plain `let` variable, not a SolidJS signal.
The createEffect that creates the Monaco editor checks:
  if (!containerRef || isLoading()) return;

Since containerRef is not reactive, setting it via the ref callback does NOT
trigger the effect to re-run. When Monaco is already cached (isLoading flips
to false before the ref callback fires), the effect runs, sees containerRef
as undefined, returns early, and NEVER re-runs — causing the infinite
"Loading editor..." spinner.

Fix: Convert containerRef to createSignal<HTMLDivElement | undefined>() so
the createEffect properly tracks it as a dependency and re-runs when the
ref callback sets the container element.

https://claude.ai/code/session_015pVrWpDDycPtrZNiJEod36
…llback

The editor container had `height: "auto"` which overrides `flex: 1` on
WebKitGTK (Tauri/Linux), causing Monaco to render into a 0-height div.
Changed to `height: "100%"` so the flex layout properly sizes the container.

Also added try/catch fallback for Monaco web workers: module workers
(`{ type: "module" }`) may not be supported on WebKitGTK, so we now
fall back to classic workers via blob URLs when module workers fail.

https://claude.ai/code/session_015pVrWpDDycPtrZNiJEod36
Three interacting bugs caused "Loading editor..." to show forever:

1. LazyEditor used lazy()+Suspense for CodeEditor, but on WebKitGTK the
   dynamic chunk import can silently hang — Suspense has no timeout, so
   the fallback skeleton shows forever. Fixed by using a direct import.

2. EditorInstance's createEffect retry called monacoManager.ensureLoaded()
   without a timeout. After the initial 15s timeout in onMount, the retry
   got back the SAME dead promise (MonacoManager was still in "loading"
   state), hanging forever. Fixed by adding Promise.race timeout to retry.

3. MonacoManager had no way to reset from a timed-out load — it stayed in
   "loading" state with a dead promise. Added resetLoadState() method,
   called on timeout/error to allow fresh retry attempts.

https://claude.ai/code/session_015pVrWpDDycPtrZNiJEod36
Adds console.warn diagnostics at every stage of the editor loading
chain to identify the exact stuck point on WebKitGTK:
- EditorPanel: logs isOpening, hasOpenFiles, showEditor state changes
- openFile: logs IPC call start/completion and isOpening transitions
- LazyEditor: logs file activation and wasEverActive state
- EditorInstance: logs onMount, Monaco load status, createEffect state
- MonacoManager: logs ensureLoaded state machine, import() resolution

Also preloads Monaco at EditorProvider startup (Tier 1 mount) so the
editor module is already loaded by the time a user opens their first
file. This eliminates the 15+ second wait on first file open.

https://claude.ai/code/session_015pVrWpDDycPtrZNiJEod36
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