Skip to content

fix(app): load component-test modules at the URLs Vite imports them by - #53091

Merged
Hona merged 1 commit into
v2from
fix-browser-pane-tests
Oct 4, 2026
Merged

Hona merged 1 commit into
v2from
fix-browser-pane-tests

Conversation

@kitlangton

Copy link
Copy Markdown
Contributor

Why

e2e (linux) fails on every PR against v2 (for example run 37175224254 on #53012) because two app component tests fail on every attempt:

  • component-tests/browser-pane-restore.spec.ts:43 keeps a restored browser tab selected and undrawn until the desktop's first inventory
  • component-tests/browser-pane-restore.spec.ts:65 keeps the browser tabs while the pane's Ipc is away and registers them again when it returns
Error: page.evaluate: Error: Language context must be used within a context provider
    at createHost (.../packages/app/src/runtime/extension/host.tsx)

Root cause

The component specs build Vite module URLs as `/@fs/${fileURLToPath(...)}`. On POSIX, fileURLToPath returns a path that starts with /, so the specs import /@fs//home/.../language.tsx (double slash). Vite rewrites host.tsx's own @/runtime/i18n/language import to /@fs/home/.../language.tsx (single slash). The browser treats these as two different modules, so the LanguageProvider the spec passes to the fixture provides one LanguageContext, while ExtensionHostProvider reads a different one.

The bug was already in the specs. #52868 (0048c97c27) exposed it by adding the Run app component tests step to CI. Windows passes because its paths become /@fs/C:/..., which is the same URL Vite uses.

What changes

  • Add sourceURL(url) to packages/storybook/playwright/story.ts. It returns /@fs${url.pathname}, which matches the URLs Vite rewrites imports to on POSIX and Windows.
  • Use it in every app and session-ui component spec that imported modules by /@fs URL. The other specs only load a single fixture each, so they weren't failing, but they had the same double-slash URLs.
  • Regenerate the tracked story.d.ts.

No assertions change.

Verification

  • Before the fix, on origin/v2 (macOS, which also produces /@fs//Users/...): bun run test:components -- browser-pane-restore.spec.ts --retries=0 fails both tests with the same Language context error.
  • After the fix, from packages/app:
    • bun run test:components -- browser-pane-restore.spec.ts --retries=0: 2 passed
    • CI=1 bun run test:components: 92 passed, 0 flaky
  • From packages/session-ui: CI=1 bun run test:components: 130 passed
  • bun typecheck passes in packages/app and packages/session-ui.
  • bun run check from the repo root: 36/36 tasks passed.

@Hona
Hona merged commit 9155b7b into v2 Oct 4, 2026
10 of 11 checks passed
@Hona
Hona deleted the fix-browser-pane-tests branch October 4, 2026 06:06
Hona added a commit to Hona/opencode that referenced this pull request Oct 4, 2026
v2 fixes the same module identity problem with sourceURL (anomalyco#53091).
Ichinose-Kazuki pushed a commit to Ichinose-Kazuki/opencode that referenced this pull request Oct 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants