Skip to content

fix(desktop): report a stock Chrome user agent in the browser tab - #6695

Merged
waleedlatif1 merged 1 commit into
stagingfrom
fix/browser-user-agent
Aug 14, 2026
Merged

fix(desktop): report a stock Chrome user agent in the browser tab#6695
waleedlatif1 merged 1 commit into
stagingfrom
fix/browser-user-agent

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • The Browser tab sent Electron's default user agent, which carries Sim/<version> and Electron/<version> tokens. Detection libraries sites gate on test for Electron before Chrome (bowser matches /electron/i several descriptors ahead of its Chrome one; ua-parser-js reports Electron as the browser name), so we read as "Electron" — on no site's supported list. Ashby warns "Ashby does not support this browser"; stricter sites refuse to render.
  • Rebuild the user agent as the desktop form Chrome's user-agent reduction specifies — same platform token, Chromium major version, rest zeroed, no application or Electron token.
  • Apply it on both the browser partition session and each tab's WebContents. Both are load-bearing: session.setUserAgent does not reach an already-created WebContents (and the first tab is what creates the session), and service workers do not inherit a tab's user agent — with only the tab's set, a worker's script request still announced Electron.
  • Scoped to the browser partition. app.userAgentFallback is deliberately untouched, so the Sim shell's own user agent is unchanged.

Type of Change

  • Bug fix

Testing

Verified against a real Electron 43.1.1 runtime with a local echo server, with the app named Sim so both tokens are present in the input:

  • Input ... Sim/43.1.1 Chrome/150.0.7871.114 Electron/43.1.1 Safari/537.36 → output Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/150.0.0.0 Safari/537.36.
  • Document request, service-worker script request, and navigator.userAgent all report that string.
  • Removing the session-level call reproduced the leak: the document request stayed clean while /sw.js went out as Chrome/150.0.7871.114 Electron/43.1.1.
  • navigator.userAgentData.brands is Not;A=Brand + Chromium — Electron was never listed there, so the header and the client hints agree rather than conflict.

Unit tests cover the derivation and a regression test asserts every tab gets a user agent with no Electron token; both were confirmed to fail without the fix. Full desktop suite (1135 tests), type-check, and lint pass.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

Electron's default user agent carries Sim/<version> and Electron/<version> tokens, and the detection libraries sites gate on test for Electron before Chrome — so the browser read as "Electron", which is on no site's supported list. Ashby warned "Ashby does not support this browser"; stricter sites refuse to render.

Rebuild the string as the desktop form Chrome's user-agent reduction specifies — same platform token and Chromium major version, the rest zeroed, no application or Electron token — and apply it to both the browser partition session and each tab's WebContents. Service workers do not inherit a tab's user agent, so without the session-level call a worker's script request still announced Electron.

Scoped to the browser partition: app.userAgentFallback is left alone so the Sim shell's own user agent is unchanged.
@vercel

vercel Bot commented Aug 14, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Aug 14, 2026 6:43am

Request Review

@cursor

cursor Bot commented Aug 14, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Scoped to the browser agent partition and tab WebContents; no auth or shell UA changes. Main caveat is sites that intentionally block non-standard clients may now treat the tab as stock Chrome.

Overview
Browser tabs no longer advertise Electron to sites. Electron’s default string includes Sim/ and Electron/ tokens that UA parsers treat as unsupported browsers; the change rebuilds the agent from app.userAgentFallback into Chrome’s user-agent–reduction desktop form (platform + Chromium major, no app/Electron tokens).

Application is layered on the browser partition and each tab: session.setUserAgent on the agent partition covers service workers that don’t inherit a tab’s UA, and contents.setUserAgent on every tab covers the first WebContents created when the session already exists. The Sim shell’s global userAgentFallback is unchanged.

New user-agent helpers plus session and electron-mock tests assert the derived string and that every tab gets a Chrome-like UA with no Electron or Sim/ tokens.

Reviewed by Cursor Bugbot for commit 3106c54. Configure here.

@greptile-apps

greptile-apps Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR normalizes the embedded browser’s Electron user agent into Chrome’s reduced desktop form so compatibility checks recognize it as Chrome.

  • Derives the stock Chrome string from Electron’s platform token and Chromium major version.
  • Applies the override to both the browser partition session and every tab WebContents.
  • Adds parser, tab-level regression, and Electron-mock coverage.

Confidence Score: 5/5

The PR appears safe to merge, with both tab and service-worker request paths receiving the normalized user agent before navigation.

The transformation matches the current Electron user-agent format, and all browser-agent WebContents creation paths synchronously apply both session-level and tab-level overrides before loading content.

Important Files Changed

Filename Overview
apps/desktop/src/main/browser-agent/user-agent.ts Adds a focused transformation from Electron’s default user agent to Chrome’s reduced desktop format.
apps/desktop/src/main/browser-agent/session.ts Applies the normalized user agent to the agent partition and each tab before navigation begins.
apps/desktop/src/main/browser-agent/user-agent.test.ts Covers token removal, exact reduced output, platform preservation, fallback behavior, and Electron integration.
apps/desktop/src/main/browser-agent/session.test.ts Verifies that every created browser-agent tab receives a Chrome-form user agent without Electron or Sim tokens.
apps/desktop/src/test/electron-mock.ts Extends Electron test doubles with the fallback user agent and session/WebContents setters required by the change.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Electron default user agent] --> B[Extract platform and Chromium major]
  B --> C[Build reduced Chrome user agent]
  C --> D[Browser partition session]
  C --> E[Each tab WebContents]
  D --> F[Service-worker and session requests]
  E --> G[Document requests and navigator.userAgent]
Loading

Reviews (1): Last reviewed commit: "fix(desktop): report a stock Chrome user..." | Re-trigger Greptile

@waleedlatif1
waleedlatif1 merged commit 0239db8 into staging Aug 14, 2026
22 of 24 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/browser-user-agent branch August 14, 2026 06:50
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