Skip to content

Preview browser has no way to set a mobile User-Agent for testing mobile vs desktop web #32356

Closed

Description

@akshat-OwO

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

  1. 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.
  2. Look for a way to load the mobile site: a device mode, a User-Agent setting, or an agent tool option.
  3. 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

Activity

  1. added
    via-triage
    on Nov 7, 2026
  2. locked and limited conversation to collaborators on Nov 7, 2026
  3. converted this issue into a discussion #32358 on Nov 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    via-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions