Skip to content

fix: hide tab progress bar when opening pre-loaded ESM dependency#1748

Merged
willeastcott merged 2 commits intomainfrom
fix-esm-tab-progress
Feb 12, 2026
Merged

fix: hide tab progress bar when opening pre-loaded ESM dependency#1748
willeastcott merged 2 commits intomainfrom
fix-esm-tab-progress

Conversation

@willeastcott
Copy link
Contributor

@willeastcott willeastcott commented Feb 12, 2026

Summary

  • Fixes the tab progress bar staying visible forever when opening an ESM script that was previously pre-loaded as a dependency of another ESM script
  • Repro: open b.mjs (which imports a.mjs), close it, then open a.mjs -- the progress bar under the tab never hides

Root Cause

When an ESM script (e.g. b.mjs) loads, documents-load.ts pre-loads its dependencies (e.g. a.mjs) into documentsIndex via loadDocument(a.mjs, false). Later, when the user opens a.mjs directly, the select:asset handler in documents-load.ts sees documentsIndex[a.id] already exists and takes a fast path -- emitting documents:focus instead of calling loadDocument. Since documents:load never fires again for a.mjs, the tab-panel.ts listener that hides the progress bar via toggleProgress(id, false) never runs.

Fix

After creating a new tab in tab-panel.ts, check whether the document was already loaded (exists in documentsIndex and is not currently loading). If so, hide the progress bar immediately since documents:load won't fire again.

Test plan

  • Create two ESM scripts where b.mjs imports from a.mjs (e.g. class inheritance)
  • Open a.mjs in the Code Editor (progress completes and hides)
  • Click b.mjs to replace a.mjs in the preview tab (progress completes and hides)
  • Click a.mjs again -- verify the progress bar completes and hides (previously stayed visible)
  • Verify non-ESM scripts still work normally

When an ESM script (e.g. b.mjs) imports from another script (e.g. a.mjs), the dependency is pre-loaded into documentsIndex. If the user later opens a.mjs directly, documents-load.ts sees it is already loaded and emits documents:focus instead of re-running loadDocument. Since documents:load never fires again, the newly created tab's progress bar was never hidden.

Check whether the document was already loaded when creating a new tab and hide the progress bar immediately if so.

Co-authored-by: Cursor <cursoragent@cursor.com>
@willeastcott willeastcott self-assigned this Feb 12, 2026
@willeastcott willeastcott added bug Something isn't working area: code editor labels Feb 12, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a UI bug where the tab progress bar can remain visible indefinitely when opening an ESM asset that was previously pre-loaded as a dependency, by hiding progress immediately for already-loaded documents.

Changes:

  • Adds an early progress-hide check when creating a new tab for an already-loaded document.
  • Uses documents:get + documents:isLoading to determine whether documents:load will fire.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@willeastcott willeastcott merged commit 6361c9d into main Feb 12, 2026
3 checks passed
@willeastcott willeastcott deleted the fix-esm-tab-progress branch February 12, 2026 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: code editor bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants