Skip to content

fix(web): browser tests no longer proxy to the T3 server running the agent - #91

Merged
nullStack65 merged 1 commit into
release/native-0.1.10from
fix/native-0.1.10-browser-tests-ignore-dev-proxy
Nov 18, 2026
Merged

nullStack65 merged 1 commit into
release/native-0.1.10from
fix/native-0.1.10-browser-tests-ignore-dev-proxy

Conversation

@nullStack65

Copy link
Copy Markdown
Owner

The "Thread hygiene" lane reported that Sidebar.shortcuts.browser.test.tsx → "leaves thread shortcuts and their hints to the preview when their rules exclude it" fails every time on release/native-0.1.10, with expected '/environment-render/thread-a' to be '/environment-render/thread-b'.

Cause

It isn't from a product change. It fails the same way at every commit back to 7d32075e37, the upstream base before any Closura patch, and it passes as soon as T3CODE_PORT is unset.

  • apps/web/vite.config.ts proxies /api, /ws and /.well-known to localhost:$T3CODE_PORT, and the browser test projects inherit that server config.
  • An agent running inside T3 inherits T3CODE_PORT from the live server (3773 on ASUS). The test's app then discovered the real primary environment through the proxy.
  • The sidebar keyed the fake threads under the live environment's ID (26cc7088-…), while the route used the fixture's environment-render. So Ctrl+Shift+] found no current thread to move from.

The release CI doesn't run this browser test and has no live server, which is why nobody saw it.

Fix

The proxy is off under Vitest. Dev (vp run dev) doesn't set VITEST, so the dev proxy is unchanged.

Verification

With T3CODE_PORT=3773 set, as in an agent shell: Sidebar.shortcuts.browser.test.tsx and Sidebar.browser.test.tsx pass (2 files, 10 tests). Before the fix the shortcuts test failed in that shell and passed with the variable unset. Format, lint and the web typecheck are clean.

No screenshot: this changes test setup only, with nothing user-visible.

Opus 5.5 via Claude Code in T3 Code.

🤖 Generated with Claude Code

…agent

The web Vite config proxies /api, /ws and /.well-known to localhost:$T3CODE_PORT,
and the browser test projects inherit that server config. Agents running inside
T3 inherit T3CODE_PORT from the live server, so browser tests discovered the
real primary environment instead of the fake one. Sidebar.shortcuts' "leaves
thread shortcuts ... to the preview" failed every time that way: the sidebar
keyed threads under the live environment's ID, the route used the fixture's,
and Ctrl+Shift+] had no current thread to move from.

Under Vitest the proxy is now off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nullStack65

Copy link
Copy Markdown
Owner Author

Independent bot review (Claude Sonnet 5.5 via T3 delegation), head 45774f7

No blocking findings.

Checks:

  1. VITEST is set before config load. Vitest's startVitest (cli-api, vitest 5.0.5) sets process.env.VITEST = "true" before it resolves config. Vite+ vp test delegates to it. vite.config.ts:216 is evaluated once per process, so the node unit project and the browser and renders projects see it. I ran Sidebar.shortcuts.browser.test.tsx with inherited T3CODE_PORT=3773: 1 passed.
  2. Dev and build paths don't set VITEST. Nothing under apps/web, scripts or apps/desktop assigns it (grep). vp run dev, dev:desktop, the bundled dev plugin and dev:web don't go through Vitest, so the proxy at vite.config.ts:397 is unchanged. Scenarios start dev:web through scripts/dev-runner.ts, which sets T3CODE_PORT itself (dev-runner.ts:348). The e2e runner isn't Vitest and sets no VITEST, so its proxy stays.
  3. No test relies on the proxy. Browser and unit tests don't hit /api through Vite.
  4. Placement is right. The gate sits at the single place the proxy target is computed, so a one-line change covers every Vitest project. The alternatives are worse: unsetting T3CODE_PORT in per-project config, or in the test setup, is later than config evaluation and would need repeating per project.

Nit (not blocking): the comment is accurate. Consider ending it with "Dev doesn't set VITEST." Optional.

Risk to note: if someone later runs the dev server from inside a Vitest process (for example a test that spawns vite and inherits env), it would lose the proxy. Nothing does that today.

@nullStack65
nullStack65 merged commit 9e95d1c into release/native-0.1.10 Nov 18, 2026
2 checks passed
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.

1 participant