fix(desktop): report a stock Chrome user agent in the browser tab - #6695
Conversation
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.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryLow Risk Overview Application is layered on the browser partition and each tab: New Reviewed by Cursor Bugbot for commit 3106c54. Configure here. |
Greptile SummaryThe PR normalizes the embedded browser’s Electron user agent into Chrome’s reduced desktop form so compatibility checks recognize it as Chrome.
Confidence Score: 5/5The 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.
|
| 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]
Reviews (1): Last reviewed commit: "fix(desktop): report a stock Chrome user..." | Re-trigger Greptile
Summary
Sim/<version>andElectron/<version>tokens. Detection libraries sites gate on test for Electron before Chrome (bowser matches/electron/iseveral descriptors ahead of its Chrome one; ua-parser-js reportsElectronas 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.WebContents. Both are load-bearing:session.setUserAgentdoes not reach an already-createdWebContents(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.app.userAgentFallbackis deliberately untouched, so the Sim shell's own user agent is unchanged.Type of Change
Testing
Verified against a real Electron 43.1.1 runtime with a local echo server, with the app named
Simso both tokens are present in the input:... Sim/43.1.1 Chrome/150.0.7871.114 Electron/43.1.1 Safari/537.36→ outputMozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/150.0.0.0 Safari/537.36.navigator.userAgentall report that string./sw.jswent out asChrome/150.0.7871.114 Electron/43.1.1.navigator.userAgentData.brandsisNot;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