Repository navigation
fix(browser): add native-UA session profiles - #12608
Conversation
|
Warning Review limit reached
Next review available in: 4 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughBrowser profiles now support optional 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: b07a93cc-8103-4afe-a1f5-0e0b4f88ad10
📒 Files selected for processing (27)
src/cli/browser-format.tssrc/cli/browser.test.tssrc/cli/handlers/browser-profile.tssrc/cli/help.tssrc/cli/specs/browser-basic.tssrc/main/browser/browser-session-registry.persistence.test.tssrc/main/browser/browser-session-registry.test.tssrc/main/browser/browser-session-registry.tssrc/main/ipc/browser-session-profile-ipc.test.tssrc/main/ipc/browser.tssrc/main/runtime/orca-runtime-browser.test.tssrc/main/runtime/orca-runtime-browser.tssrc/main/runtime/rpc/methods/browser-schemas.tssrc/main/runtime/rpc/methods/browser.test.tssrc/preload/api-types.tssrc/preload/index.tssrc/renderer/src/components/browser-pane/BrowserToolbarMenu.tsxsrc/renderer/src/components/browser-pane/browser-toolbar-profile-dialogs.tsxsrc/renderer/src/components/browser-profile-user-agent-option.test.tsxsrc/renderer/src/components/browser-profile-user-agent-option.tsxsrc/renderer/src/components/settings/BrowserNewProfileDialog.tsxsrc/renderer/src/components/settings/BrowserProfileRow.tsxsrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/store/slices/browser.test.tssrc/renderer/src/store/slices/browser.tssrc/shared/types.tstests/tools/google-signin-ua-probe.cjs
| it('forwards the user-agent mode from a trusted renderer', () => { | ||
| const profile = { | ||
| id: 'profile-google', | ||
| scope: 'isolated', | ||
| partition: 'persist:orca-browser-session-profile-google', | ||
| label: 'Google', | ||
| source: null, | ||
| userAgentMode: 'native' | ||
| } | ||
| createProfileMock.mockReturnValue(profile) | ||
| registerBrowserHandlers() | ||
| const createHandler = handleMock.mock.calls.find( | ||
| ([channel]) => channel === 'browser:session:createProfile' | ||
| )?.[1] as ( | ||
| event: { sender: Electron.WebContents }, | ||
| args: { scope: 'isolated'; label: string; userAgentMode: 'native' } | ||
| ) => unknown | ||
| const sender = { | ||
| id: 91, | ||
| isDestroyed: () => false, | ||
| getType: () => 'window', | ||
| getURL: () => 'file:///renderer/index.html' | ||
| } as Electron.WebContents | ||
|
|
||
| expect( | ||
| createHandler({ sender }, { scope: 'isolated', label: 'Google', userAgentMode: 'native' }) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Register the test sender as trusted.
The test resets the trusted renderer ID to null. It never registers sender ID 91 before calling the handler. Set ID 91 before registerBrowserHandlers() so this test proves the permitted trusted-renderer path.
Proposed fix
}
createProfileMock.mockReturnValue(profile)
+ setTrustedBrowserRendererWebContentsId(91)
registerBrowserHandlers()📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| it('forwards the user-agent mode from a trusted renderer', () => { | |
| const profile = { | |
| id: 'profile-google', | |
| scope: 'isolated', | |
| partition: 'persist:orca-browser-session-profile-google', | |
| label: 'Google', | |
| source: null, | |
| userAgentMode: 'native' | |
| } | |
| createProfileMock.mockReturnValue(profile) | |
| registerBrowserHandlers() | |
| const createHandler = handleMock.mock.calls.find( | |
| ([channel]) => channel === 'browser:session:createProfile' | |
| )?.[1] as ( | |
| event: { sender: Electron.WebContents }, | |
| args: { scope: 'isolated'; label: string; userAgentMode: 'native' } | |
| ) => unknown | |
| const sender = { | |
| id: 91, | |
| isDestroyed: () => false, | |
| getType: () => 'window', | |
| getURL: () => 'file:///renderer/index.html' | |
| } as Electron.WebContents | |
| expect( | |
| createHandler({ sender }, { scope: 'isolated', label: 'Google', userAgentMode: 'native' }) | |
| it('forwards the user-agent mode from a trusted renderer', () => { | |
| const profile = { | |
| id: 'profile-google', | |
| scope: 'isolated', | |
| partition: 'persist:orca-browser-session-profile-google', | |
| label: 'Google', | |
| source: null, | |
| userAgentMode: 'native' | |
| } | |
| createProfileMock.mockReturnValue(profile) | |
| setTrustedBrowserRendererWebContentsId(91) | |
| registerBrowserHandlers() | |
| const createHandler = handleMock.mock.calls.find( | |
| ([channel]) => channel === 'browser:session:createProfile' | |
| )?.[1] as ( | |
| event: { sender: Electron.WebContents }, | |
| args: { scope: 'isolated'; label: string; userAgentMode: 'native' } | |
| ) => unknown | |
| const sender = { | |
| id: 91, | |
| isDestroyed: () => false, | |
| getType: () => 'window', | |
| getURL: () => 'file:///renderer/index.html' | |
| } as Electron.WebContents | |
| expect( | |
| createHandler({ sender }, { scope: 'isolated', label: 'Google', userAgentMode: 'native' }) |
| const window = new BrowserWindow({ | ||
| show: true, | ||
| title: `Google sign-in UA probe: ${mode}`, | ||
| width: 980, | ||
| height: 840, | ||
| webPreferences: { | ||
| contextIsolation: true, | ||
| nodeIntegration: false, | ||
| partition, | ||
| sandbox: true | ||
| } | ||
| }) |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== file outline/stat =="
wc -l tests/tools/google-signin-ua-probe.cjs
echo
echo "== relevant file section =="
sed -n '1,220p' tests/tools/google-signin-ua-probe.cjs | nl -ba | sed -n '1,220p'
echo
echo "== window close / app quit occurrences =="
rg -n "app\.quit|setExitProcess|BrowserWindow|closed|ready|createWindow|quit|allowRendererProcessReuse" tests/tools/google-signin-ua-probe.cjs tests -S || trueRepository: stablyai/orca
Length of output: 287
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== relevant file section =="
sed -n '1,220p' tests/tools/google-signin-ua-probe.cjs | awk '{printf "%5d\t%s\n", NR, $0}'
echo
echo "== window close / app quit occurrences in probe file =="
grep -nE "app\.quit|setExitProcess|BrowserWindow|closed|ready|createWindow|quit|allowRendererProcessReuse|autoLaunch" tests/tools/google-signin-ua-probe.cjs || true
echo
echo "== Electron version hints =="
for f in package.json package-lock.json yarn.lock pnpm-lock.yaml; do
[ -f "$f" ] && { echo "--- $f ---"; grep -nE '"?electron"?|electron@|electron:' "$f" | head -20 || true; }
done
echo
echo "== all app.quit occurrences in tests/tools =="
grep -R -n "app\.quit" tests/tools || trueRepository: stablyai/orca
Length of output: 11637
🌐 Web query:
Electron BrowserWindow alwaysOnTop macOS app.quit when closing last window default behavior
💡 Result:
In Electron, the default behavior for closing the last window is determined by the window-all-closed event [1][2]. If you do not subscribe to this event, the application will quit automatically when all windows are closed [1][2]. However, it is standard practice in Electron applications to subscribe to this event and specifically prevent the application from quitting on macOS [3][4], as macOS design guidelines prefer that applications remain active even when no windows are open [3][4]. The presence of a BrowserWindow with alwaysOnTop: true does not change the default quit behavior or how the app handles the window-all-closed event [5][2]. Whether a window is always-on-top or not, closing that window triggers the same lifecycle events [5]. If the last window is closed—regardless of its always-on-top status—the window-all-closed event will be emitted [1][2]. Commonly, developers implement this logic to align with macOS conventions: app.on('window-all-closed', => { if (process.platform!== 'darwin') { app.quit; } }); In this implementation: 1. On Windows and Linux, the application quits when all windows are closed [3][4]. 2. On macOS (darwin), the application remains active in the background when the last window is closed, allowing the user to continue using the menu bar or open new windows [3][4]. The application will only quit when the user explicitly triggers a quit (e.g., Cmd + Q) or the developer calls app.quit elsewhere in the application lifecycle [1][3]. If you find that an always-on-top window is preventing the application from quitting during an explicit app.quit call, it is typically because the window has been configured in a way that prevents it from closing (e.g., by overriding the close event or setting the window as un-closable) [6]. The always-on-top status itself is a window-level display property and does not create an inherent dependency that blocks the application from terminating [5].
Citations:
- 1: https://github.com/electron/electron/blob/main/docs/api/app.md
- 2: https://electronjs.org/docs/latest/api/app
- 3: https://stackoverflow.com/questions/58822323/for-electron-app-in-macos-when-is-app-quit-invoked
- 4: https://stackoverflow.com/questions/44316306/how-to-quit-electron-app-on-mac
- 5: https://github.com/electron/electron/blob/main/docs/api/browser-window.md
- 6: Inconsistent behavior between app.quit and un-closable BrowserWindow electron/electron#5680
Quit when the probe window closes.
This standalone probe opens a single BrowserWindow, so closing it leaves Electron running on macOS unless the app quits explicitly.
Proposed fix
const window = new BrowserWindow({
// ...
})
+
+ window.once('closed', () => {
+ app.quit()
+ })📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const window = new BrowserWindow({ | |
| show: true, | |
| title: `Google sign-in UA probe: ${mode}`, | |
| width: 980, | |
| height: 840, | |
| webPreferences: { | |
| contextIsolation: true, | |
| nodeIntegration: false, | |
| partition, | |
| sandbox: true | |
| } | |
| }) | |
| const window = new BrowserWindow({ | |
| show: true, | |
| title: `Google sign-in UA probe: ${mode}`, | |
| width: 980, | |
| height: 840, | |
| webPreferences: { | |
| contextIsolation: true, | |
| nodeIntegration: false, | |
| partition, | |
| sandbox: true | |
| } | |
| }) | |
| window.once('closed', () => { | |
| app.quit() | |
| }) |
Source: Coding guidelines
|
Electron QA after commit 358ca6e:
|
|
Exact-head live Google admission test on 358ca6e passed. Environment: Electron 43.1.0 / Chromium 150.0.7871.47, fresh throwaway partition per arm, unique nonexistent Gmail identifier per arm, CDP attached, no account credentials.
Cleaned-UA control: Native-UA profile: This verifies the fresh-sign-in admission fix on the final PR head. It does not repeat the earlier real-account credentials/2FA and 92-minute session-duration test. |
…port (STA-3514) Delete the import-time UA synthesis entirely instead of patching its version detection. The session now always keeps the engine-derived UA the registry sets at startup (clean or native), for imported and non-imported profiles alike. Why deletion is the fix: - The synthesis read CFBundleShortVersionString, which on forks is a marketing version — Arc imports presented Chrome/1.x and sites rejected the browser as ancient (STA-3514). - Its stated purpose (keep Google-bound cookies valid) is handled by isGoogleSourceBoundCookie excluding those cookies since #736, and #12884 measured that Google rejects re-transplants regardless of UA identity. - #12608 measured the synthesized Chrome-shaped UA reaching /v3/signin/rejected while the engine UA reached account lookup. Persisted userAgent/userAgentByPartition meta is no longer read; legacy keys drop off on the next meta write. The #12811 gate existed only to catch bad synthesized values, so it leaves with the synthesis.
…port (STA-3514) (#12849) * fix(browser): stop impersonating the source browser's UA on cookie import (STA-3514) Delete the import-time UA synthesis entirely instead of patching its version detection. The session now always keeps the engine-derived UA the registry sets at startup (clean or native), for imported and non-imported profiles alike. Why deletion is the fix: - The synthesis read CFBundleShortVersionString, which on forks is a marketing version — Arc imports presented Chrome/1.x and sites rejected the browser as ancient (STA-3514). - Its stated purpose (keep Google-bound cookies valid) is handled by isGoogleSourceBoundCookie excluding those cookies since #736, and #12884 measured that Google rejects re-transplants regardless of UA identity. - #12608 measured the synthesized Chrome-shaped UA reaching /v3/signin/rejected while the engine UA reached account lookup. Persisted userAgent/userAgentByPartition meta is no longer read; legacy keys drop off on the next meta write. The #12811 gate existed only to catch bad synthesized values, so it leaves with the synthesis. * test(browser): catch source UA impersonation regression
* fix(browser): add native-UA session profiles * test(browser): add Google sign-in UA probe * fix(browser): preserve native profile UA identity
…port (STA-3514) (stablyai#12849) * fix(browser): stop impersonating the source browser's UA on cookie import (STA-3514) Delete the import-time UA synthesis entirely instead of patching its version detection. The session now always keeps the engine-derived UA the registry sets at startup (clean or native), for imported and non-imported profiles alike. Why deletion is the fix: - The synthesis read CFBundleShortVersionString, which on forks is a marketing version — Arc imports presented Chrome/1.x and sites rejected the browser as ancient (STA-3514). - Its stated purpose (keep Google-bound cookies valid) is handled by isGoogleSourceBoundCookie excluding those cookies since stablyai#736, and stablyai#12884 measured that Google rejects re-transplants regardless of UA identity. - stablyai#12608 measured the synthesized Chrome-shaped UA reaching /v3/signin/rejected while the engine UA reached account lookup. Persisted userAgent/userAgentByPartition meta is no longer read; legacy keys drop off on the next meta write. The stablyai#12811 gate existed only to catch bad synthesized values, so it leaves with the synthesis. * test(browser): catch source UA impersonation regression




Summary
orca tab profile create --no-ua-spoofGoogle sign-in testing consistently reached
/v3/signin/rejectedwith Orca's cleaned Chrome-shaped UA and reached normal account lookup with the untouched Electron UA. A fresh sign-in under the untouched UA also completed and remained usable for 92 minutes. This PR therefore adds a narrow opt-out rather than changing the default or switching identity by destination host.Closes #11518
Screenshots
Profile creation option:
Persisted profile label:
Testing
pnpm lintpnpm typecheckpnpm test— 9 focused files / 166 tests passed insteadpnpm build— no dependency or packaging changesAdditional validation:
node --check tests/tools/google-signin-ua-probe.cjsuserAgentMode: "native", and appears on the profile rowAI Review Report
Reviewed the user-agent precedence and lifecycle end to end: persisted imported-browser UA first, then the profile's native/clean fallback choice before first navigation. Checked metadata hydration and validation, profile creation through trusted local IPC and remote runtime RPC, CLI parsing, deletion cleanup, UI state reset, and client-hint behavior. The review rejected destination-host UA switching because it would create one session under inconsistent request and JavaScript-visible identities.
Cross-platform review: production changes add no OS-specific paths, shell commands, shortcuts, or labels. The profile option flows through local IPC and runtime RPC, so it applies to local, SSH, and folder-workspace use without assuming a git worktree. Behavior is the same on macOS, Linux, and Windows; the live Google measurement and Electron screenshot QA were run on macOS.
Security Audit
The new mode is a closed enum validated at RPC and registry boundaries, and persisted profiles still pass the owned-partition allowlist before hydration. Local profile creation remains restricted to the trusted browser renderer. No cookies, auth tokens, or secrets are logged; no dependency, command-execution, or new filesystem-path input is introduced in production code. The diagnostic probe accepts a test account identifier and records navigation/request metadata, but does not accept or store passwords.
Notes