Skip to content

Remove Electron token from built-in browser user agent #55730

Closed

Description

@sathwick-p

Description

The built-in desktop browser sends Electron's default user agent, which includes an Electron/ token:

Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) OpenCode/2.0.29 Chrome/152.0.7977.130 Electron/44.4.5 Safari/537.36

Some sites check the user agent and treat Electron/ as a separate, unsupported browser. Medium is one example. When I'm logged in, clicking Write redirects to /m-write ("Start writing in the Medium app"), and /p/<id>/edit redirects to the public story. The editor page reports "browser": "electron" and "supportsDesktopEdit": false. The same account works in regular Chrome, so the user agent is the cause, not the account, login, or window width.

Cause: packages/gui-extensions/src/browser/pane.ts creates the opencode-browser-<id> session but never calls setUserAgent, so Electron's default is used.

Suggested fix: when the browser session is created, call setUserAgent on it with only the Electron/… token removed. The OpenCode/… token and the real Chrome version stay. With that change, common parsers such as ua-parser-js and Bowser detect Chrome instead of Electron. This only touches the browser partition, not the app window.

I'm happy to open a PR for this.

Plugins

none

OpenCode version

Desktop 2.0.29

Steps to reproduce

  1. Open the built-in browser in OpenCode Desktop.
  2. Run navigator.userAgent in the page and note that it contains Electron/.
  3. Sign in to Medium and click Write. You land on https://medium.com/m-write ("Start writing in the Medium app").
  4. Open https://medium.com/p/<story-id>/edit. You get the public story instead of the editor.
  5. Do the same in regular Chrome with the same account. The editor opens.

Screenshot and/or share link

Image

Operating System

macOS 26.6.2

Terminal

N/A

Activity

  1. opencode-agent commented on Oct 15, 2026

    @opencode-agent
    Contributor

    Thanks for the detailed report. I couldn't run OpenCode Desktop's built-in browser in this sandbox, so I haven't watched it happen. The code does match what you describe, though. In packages/gui-extensions/src/browser/pane.ts, the opencode-browser-<id> partition is created without a setUserAgent call, so pages get Electron's default user agent, Electron/… token included. That's still the case on the latest dev (81200db). A maintainer with the desktop app will need to confirm it. Since you offered, a PR along the lines you suggested could help: strip only the Electron/ token on the browser partition and leave the app window alone.

  2. quanliew28 commented on Nov 7, 2026

    @quanliew28

    yes, please remove 'electron' UA token from the browser, i was unable to access website via opencode browser.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions