Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(preview): Browser pane navigates when the desktop backend has no browser channel #35424

Mergedjuliusmarmingemerged 0 commits intomain fromrefs/pull/35424/headmerged by juliusmarminge View on GitHub

juliusmarmingecommented

Since #22877, ServerBrowser.setUpTab marked a tab headless only when the desktop browser channel was available (!desktop && desktopChannel.available). In WSL-only mode the desktop starts its only backend without the browser fds, so the channel is unavailable and primary-environment server tabs stayed non-headless. rendersServerTabNatively then had Electron draw its own local page, which typed URLs never reached, while the server ran a separate headless page for agents. The fix drops the desktopChannel.available condition, so every tab the desktop does not draw (no channel, attach timeout, or adopted popup) is marked headless and the pane streams the server's page. When the channel is present and the desktop attaches, nothing changes. On servers with no desktop at all (plain t3, remote), tabs now carry headless: true. Nothing reads the flag outside the native-render check, which already needs an Electron primary environment, so there is no visible change there. I chose this over PR #31172, which reads the fd config in PreviewManager.open, because it keeps the decision in the one place that already makes it. The repro test 'a server started without the desktop browser channel marks its tabs headless' fails on the base ('expected undefined to be true') and passes with the fix. No new regex or parser. I did not re-run the desktop app on this branch; the repro step already reproduced the bug end to end there.

Fixes pingdotgg/t3code#17009

Reproduction on main

Commit origin/main f03db4fbef. WSL itself is not available on Linux, so I simulated WSL-only mode exactly at its root cause: I commented out desktopBrowserFd/desktopBrowserControlFd in the Linux primary backend config (apps/desktop/src/backend/DesktopBackendConfiguration.ts L518-519, local only, not committed) and ran the real desktop app (T3CODE_DEV_SEED=0 headless-desktop vp run dev:desktop), driving it over CDP. Steps: created a project, opened a thread, Open a surface -> Browser, typed example.com and pressed Enter. The address field cleared back to 'Search or enter URL', example.com appeared under 'Recently used', and no page loaded; clicking the listed local server localhost:7568 also did nothing. Control: I restored the two lines (Electron and the backend restarted with the fds) and ran the same steps: the tab loaded 'Example Domain' at https://example.com/. Failing test: apps/server/src/preview/ServerBrowser.test.ts, 'a server started without the desktop browser channel marks its tabs headless', runs ServerBrowser with the real DesktopBrowserChannel layer and no fds; on main the opened tab has headless undefined instead of true.

Evidence

Real Linux Electron desktop under Xvfb, with both desktop browser channel fds omitted to simulate the WSL-only backend condition. Fresh synthetic data, light theme, identical 484×780 Browser-pane crops. Steps: open Browser from a new-thread view, type example.com, press Enter; then click the listed localhost:7568 server from a new-tab pane.

BeforeAfter
f03db4fbefb51b3613d2
Before: URL entry leaves the new-tab listAfter: example.com renders
Before URL recordingAfter URL recording
Before: local-server click leaves the new-tab listAfter: local-server page renders
Before local-server recordingAfter local-server recording

Capture driver · Seed script · Synthetic local page · Observations

AI-assisted; verified with the tests and tools listed above.

Not shown:

  • Permanent blocker: native Windows with a WSL-only backend is unavailable on this Linux VM; evidence uses the explicitly supplied no-browser-channel simulation.
  • Direct agent preview-tool operation and synchronization with a saved thread were not exercised; captures demonstrate desktop Browser navigation from the new-thread draft view. A direct MCP request using the desktop client credential was rejected with HTTP 401.

Tests

cd apps/server && vp test run src/preview/ServerBrowser.test.ts src/preview/Manager.test.ts: 79/79 passed. With the fix stashed, the repro test fails with 'expected undefined to be true'. vp run check:changed: format, lint, knip, typecheck (3 packages) and tests (2 files) all passed.

Not in this change

  • Open PR #31172 fixes the same bug a different way, by marking tabs headless in PreviewManager.open from the fd config; it could be closed in favour of this fix.
  • When the desktop browser fds are missing, the WSL-only desktop backend still starts without a browser channel at all, so it streams the server's page instead of rendering natively. Giving WSL backends a real channel is a separate feature.

AI-assisted; verified with the tests and tools listed above.

    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. Approvability

      Verdict: Approved at b51b361

      Macroscope's review found this PR approvable — Server-backed browser tabs are now marked headless even when no desktop browser channel exists, allowing the preview pane to render the page actually being controlled. Desktop-connected tabs remain unchanged, and the change is limited to rendering selection.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    3. Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
      CodexThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      CodexLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)2.0 KiB✅
      CodexLive turn WebSocket decoded21.5 KiB21.5 KiB0 B (0.0%)24.4 KiB✅
      CodexLive turn messages110 (0.0%)8✅
      ClaudeTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
      ClaudeThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      ClaudeLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)2.0 KiB✅
      ClaudeLive turn WebSocket decoded21.9 KiB21.9 KiB0 B (0.0%)24.4 KiB✅
      ClaudeLive turn messages110 (0.0%)8✅

      Other scenarios

      All 64 scenario measurements match main.

      All 64 scenario measurements
      ProviderScenarioMetricMain baselineThis PRImpactPR ceiling
      Codexshort turn resumeWebSocket decoded10.5 KiB10.5 KiB0 B (0.0%)12.7 KiB✅
      Codexshort turn resumeWebSocket messages220 (0.0%)2✅
      Codexlong turn running, cold openHTTP decoded281.7 KiB281.7 KiB0 B (0.0%)302.7 KiB✅
      Codexlong turn running, cold openrows75750 (0.0%)75✅
      Codexlong turn running, history pageHTTP decoded92.4 KiB92.4 KiB0 B (0.0%)107.4 KiB✅
      Codexlong turn running, history pagerows75750 (0.0%)75✅
      Codexlong turn finished, cold openHTTP decoded381.5 KiB381.5 KiB0 B (0.0%)410.2 KiB✅
      Codexlong turn finished, cold openrows1511510 (0.0%)151✅
      Codexlong turn finished, socket cold openWebSocket decoded381.6 KiB381.6 KiB0 B (0.0%)410.2 KiB✅
      Codexlong turn finished, socket cold openWebSocket messages220 (0.0%)2✅
      Codexlong turn finished, socket cold openrows1511510 (0.0%)151✅
      Codexlong turn finished, work pageHTTP decoded186.2 KiB186.2 KiB0 B (0.0%)200.2 KiB✅
      Codexlong turn finished, work pagerows1501500 (0.0%)150✅
      Codexidle thread resumeWebSocket decoded65 B65 B0 B (0.0%)200 B✅
      Codexidle thread resumeWebSocket messages110 (0.0%)1✅
      Codexfleet shell snapshotHTTP decoded41.6 KiB41.6 KiB0 B (0.0%)53.7 KiB✅
      Codexfleet shell snapshotrows27270 (0.0%)27✅
      Codexfleet shell subscribeWebSocket decoded65 B65 B0 B (0.0%)200 B✅
      Codexfleet shell subscribeWebSocket messages110 (0.0%)1✅
      Codexfleet shell resume checkHTTP decoded18 B18 B0 B (0.0%)100 B✅
      Codexfleet shell resume checkrows0000✅
      Codexstale shell reloadHTTP decoded41.6 KiB41.6 KiB0 B (0.0%)53.7 KiB✅
      Codexstale shell reloadrows27270 (0.0%)27✅
      Codexstale shell resumeWebSocket decoded140 B140 B0 B (0.0%)400 B✅
      Codexstale shell resumeWebSocket messages220 (0.0%)2✅
      Codexstale todo list cold openHTTP decoded72.4 KiB72.4 KiB0 B (0.0%)83.0 KiB✅
      Codexstale todo list cold openrows75750 (0.0%)75✅
      Codexstale todo list cold opennodes220 (0.0%)4✅
      Codexstale todo list cold opensubagents220 (0.0%)4✅
      Codexstale todo list cold openplans110 (0.0%)2✅
      Codexstale todo list cold openproviderTurns110 (0.0%)2✅
      Codexstale todo list cold opencheckpoints110 (0.0%)2✅
      Claudeshort turn resumeWebSocket decoded10.6 KiB10.6 KiB0 B (0.0%)12.7 KiB✅
      Claudeshort turn resumeWebSocket messages220 (0.0%)2✅
      Claudelong turn running, cold openHTTP decoded283.3 KiB283.3 KiB0 B (0.0%)302.7 KiB✅
      Claudelong turn running, cold openrows75750 (0.0%)75✅
      Claudelong turn running, history pageHTTP decoded93.4 KiB93.4 KiB0 B (0.0%)107.4 KiB✅
      Claudelong turn running, history pagerows75750 (0.0%)75✅
      Claudelong turn finished, cold openHTTP decoded384.2 KiB384.2 KiB0 B (0.0%)410.2 KiB✅
      Claudelong turn finished, cold openrows1511510 (0.0%)151✅
      Claudelong turn finished, socket cold openWebSocket decoded384.3 KiB384.3 KiB0 B (0.0%)410.2 KiB✅
      Claudelong turn finished, socket cold openWebSocket messages220 (0.0%)2✅
      Claudelong turn finished, socket cold openrows1511510 (0.0%)151✅
      Claudelong turn finished, work pageHTTP decoded188.1 KiB188.1 KiB0 B (0.0%)200.2 KiB✅
      Claudelong turn finished, work pagerows1501500 (0.0%)150✅
      Claudeidle thread resumeWebSocket decoded66 B66 B0 B (0.0%)200 B✅
      Claudeidle thread resumeWebSocket messages110 (0.0%)1✅
      Claudefleet shell snapshotHTTP decoded42.2 KiB42.2 KiB0 B (0.0%)53.7 KiB✅
      Claudefleet shell snapshotrows27270 (0.0%)27✅
      Claudefleet shell subscribeWebSocket decoded66 B66 B0 B (0.0%)200 B✅
      Claudefleet shell subscribeWebSocket messages110 (0.0%)1✅
      Claudefleet shell resume checkHTTP decoded18 B18 B0 B (0.0%)100 B✅
      Claudefleet shell resume checkrows0000✅
      Claudestale shell reloadHTTP decoded42.2 KiB42.2 KiB0 B (0.0%)53.7 KiB✅
      Claudestale shell reloadrows27270 (0.0%)27✅
      Claudestale shell resumeWebSocket decoded140 B140 B0 B (0.0%)400 B✅
      Claudestale shell resumeWebSocket messages220 (0.0%)2✅
      Claudestale todo list cold openHTTP decoded73.4 KiB73.4 KiB0 B (0.0%)83.0 KiB✅
      Claudestale todo list cold openrows75750 (0.0%)75✅
      Claudestale todo list cold opennodes220 (0.0%)4✅
      Claudestale todo list cold opensubagents220 (0.0%)4✅
      Claudestale todo list cold openplans110 (0.0%)2✅
      Claudestale todo list cold openproviderTurns110 (0.0%)2✅
      Claudestale todo list cold opencheckpoints110 (0.0%)2✅

      Baseline: a2685e6 · PR result: b51b361 · Source CI: success

      Scenario and decoded snapshot size

      10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

      • Codex decoded thread snapshot: 108.5 KiB
      • Claude decoded thread snapshot: 108.8 KiB

      Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

    4. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Explain Change →

      No actionable comments were generated in the recent review.

      Walkthrough

      ServerBrowser now marks a tab headless whenever no desktop page is connected, regardless of desktop-channel availability. A regression test covers the unavailable-channel case.

      Changes: Server tab headless fallback

      Layer / File(s)Summary
      Headless fallback and regression test
      apps/server/src/preview/ServerBrowser.ts, apps/server/src/preview/ServerBrowser.test.ts
      The headless fallback now applies whenever no desktop page is connected. A test checks that a tab is marked headless when the desktop channel is unavailable.

      Estimated code review effort: 2 (Simple) | ~5 minutes

      Change: Bug fix · Severity of issue fixed: Medium

      Possibly related issues

      • Issue #32940 reports that the panel remains on the new-tab page in WSL-only mode. This change covers headless marking when no desktop page is connected, but the issue’s exact cause is not verified.

      Possibly related PRs

      • pingdotgg/t3code#27043: Changes the same headless condition in ServerBrowser.ts and tests the no-desktop-channel case.
      • pingdotgg/t3code#31172: Addresses headless marking for server tabs when the desktop browser channel is absent, through PreviewManager.open.
      • pingdotgg/t3code#28488: Applies the same headless condition in ServerBrowser.createTab and tests the no-desktop-channel case.

      Suggested labels: bugfix

      Suggested reviewers: t3dotgg, macroscopeapp, maria-rcks

      Merge Risk: Minimal · up to b51b3

      Tabs that the desktop does not draw now fall back to the server's page, which fixes the reported navigation failure when no desktop browser channel exists. No concrete merge-blocking risk remains.

      Pre-merge checks: Passed 3 · Inconclusive 1

      Failed Failed checks: 1 inconclusive
      Check nameStatusExplanationResolution
      Linked Issues checkInconclusiveIssue #17009 reports two symptoms: (1) the built-in browser pane accepts a URL but does not navigate, and (2) agent desktop browser tools fail with [browser.disconnected]. The diff changes one conditi…Provide evidence that agent desktop browser tools (browser.tabs.list, browser.tabs.open) no longer fail with [browser.disconnected] when the desktop has no browser channel. This can be a test or a run in the desktop app on this head. Altern…
      Passed Passed checks: 3 passed

      Check nameStatusExplanation
      Title checkPassedThe title names the main change: the browser pane navigates when the desktop backend has no browser channel. The PR removes the desktopChannel.available condition so that tabs the desktop does not dra…
      Out of Scope Changes checkPassedThe source change is a one-condition change in ServerBrowser.ts setUpTab. It directly implements the requirement that unrendered tabs stream the server page. The test change in ServerBrowser.test.ts i…
      Description checkPassedThe description follows the repository template closely. It has a clear Problem section, a Change section that explains why dropping the desktopChannel.available condition fixes the bug, and a Scope s…
      Full details: Title check

      Explanation

      The title names the main change: the browser pane navigates when the desktop backend has no browser channel. The PR removes the desktopChannel.available condition so that tabs the desktop does not draw are marked headless and stream the server's page. The title is specific and follows a conventional commit format.

      Full details: Out of Scope Changes check

      Explanation

      The source change is a one-condition change in ServerBrowser.ts setUpTab. It directly implements the requirement that unrendered tabs stream the server page. The test change in ServerBrowser.test.ts is a regression test for the same condition. The PR description says the flag is read only by the native-render check, and this was not contradicted in the reviewed diff. No unrelated changes appear in the whole-PR diff from f03db4fbef to b51b3613d2. The PR does not add WSL browser-channel support, which the PR description excludes as a separate feature.

      Full details: Description check

      Explanation

      The description follows the repository template closely. It has a clear Problem section, a Change section that explains why dropping the desktopChannel.available condition fixes the bug, and a Scope section that links issue #17009 and explains the bug fix. Its Verification section lists a failing-then-passing repro test, a 79/79 test run, check:changed results, and before/after evidence with a reproduction on main. The author also states items not checked, including native Windows with a WSL-only backend and the agent preview tool path. The template's optional agent-model line is not present, but that is minor. The description is mostly complete, so the check passes.

      Full details: Linked Issues check

      Explanation

      Issue #17009 reports two symptoms: (1) the built-in browser pane accepts a URL but does not navigate, and (2) agent desktop browser tools fail with [browser.disconnected]. The diff changes one condition in apps/server/src/preview/ServerBrowser.ts (setUpTab, around L887-891). The condition was !desktop && desktopChannel.available. It is now !desktop. Tabs that the desktop does not draw are marked headless, so the pane streams the server page. This addresses symptom (1) on the code path. The added test 'a server started without the desktop browser channel marks its tabs headless' covers the same path. The diff does not touch the code that emits the [browser.disconnected] error, and no change in this PR is shown to connect agent desktop browser tools to the session. The PR author reports a failing test on the base and a passing test with the fix. The author did not re-run the desktop app on this branch, so end-to-end navigation on this head is reported, not verified here.

      Resolution

      Provide evidence that agent desktop browser tools (browser.tabs.list, browser.tabs.open) no longer fail with [browser.disconnected] when the desktop has no browser channel. This can be a test or a run in the desktop app on this head. Alternatively, state that the tool path is out of scope for this PR and the issue should stay open for it. Also provide the end-to-end run on this head that the PR's Evidence section plans to capture.

      Finishing Touches

      Generate unit tests (beta)

      • Commit to this branch
      • Create a new PR
      • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
      Recent review info

      Run configuration

      Commits

      Reviewing files that changed from the base of the PR and between a2685e64d34945bed0f6317b48b38ef57a7cb558 and b51b3613d2ee1d121b50be12d3d20d4c646b622f.

      Files selected for processing: 2

      • apps/server/src/preview/ServerBrowser.test.ts
      • apps/server/src/preview/ServerBrowser.ts

      Limit details: You’ve used all 10 included reviews currently available.

    5. juliusmarminge merged this4c255bc

    6. juliusmarminge closed this

Sign in to join this conversation.