Preview browser has no way to set a mobile User-Agent for testing mobile vs desktop web #32356
What happened#
I'm testing my own app in the desktop preview browser. Like many e-commerce sites (Amazon, for example), it serves a different mobile web or desktop web experience depending on the User-Agent header. The preview browser has no way to change the User-Agent or switch to a mobile device mode. A narrower panel doesn't help, because the site decides on the server. So I can only test the desktop version in T3 Code.
Diagnosis#
In apps/desktop/src/preview/BrowserSession.ts, preview sessions always send Electron's built-in User-Agent. That's deliberate: a comment there says rewriting it breaks Cloudflare Turnstile (error 600010). The only rewrite is a hardcoded one that removes Electron/… for Microsoft Teams. The preview code has no device emulation (Emulation.setUserAgentOverride, setDeviceMetricsOverride, setTouchEmulationEnabled), the panel has no user-agent or device setting, and the agent's preview_* tools have no option for it.
Because of the Turnstile issue, a global override is the wrong fix. An opt-in, per-tab "device mode" (mobile user agent, viewport and touch, like Chrome DevTools device toolbar) would avoid it.
Steps to reproduce#
- In the desktop app, open a preview tab on a site that picks mobile or desktop by User-Agent, such as https://www.amazon.com.
- Look for a way to load the mobile site: a device mode, a User-Agent setting, or an agent tool option.
- There isn't one. Resizing the panel to phone width still serves the desktop site.
Version#
0.1.8-nightly.20261107.4301 (desktop app and local server)
Environment#
macOS 27.0 (arm64), T3 Code Desktop nightly, local server
Evidence#
Source at commit `4cb6945`: `apps/desktop/src/preview/BrowserSession.ts` (Turnstile comment and Teams-only rewrite); no user-agent or device-metrics override in `apps/desktop/src/preview` or the preview panel.
Related issues#
#30014 and #22444. Both are sites rejecting the built-in user agent; a per-tab user-agent override would help with those too.
Fix applied or workaround#
For your own app only: add a development-only override the server checks first, such as a query parameter or cookie. There's no workaround for third-party sites.
Filed by#
Produced by Claude Code (Opus 5.5) via T3 Code triage
akshat-OwO(GitHub profile, opens in a new tab) added labelsvia-triage
Sign in to join this conversation.