Repository navigation
fix(browser): make the browser identity one process-wide choice (#13822) - #20767
Conversation
Electron resolves worker identity from a single process-global default, so two coherent identities cannot coexist in one process. This makes clean/native one app-wide decision read before `ready`, instead of a per-profile one that leaves documents on one identity and every worker request on the other. Both identities are load-bearing, measured across four origins at five reps: the cleaned identity clears an embedded Turnstile widget and WhatsApp's browser check where native is refused; native clears a full-page Cloudflare interstitial that the cleaned identity never clears. Base commit only: removing the per-profile field, its settings surface, and the migration notice follow.
…ennanb2025/ua-b-core
Worker ctx_cb5b1262d7fe stopped ~2h ago mid-implementation (last heartbeat 2026-09-14T22:48:06Z) leaving this uncommitted. Committed unverified to make it recoverable; not reviewed, not necessarily green.
Finishes the interrupted edits in 7db9c54: - browser-user-agent-migration-notice.ts was truncated mid-write; close the then() callback so the file parses. - Register browser.identity.get/set in the generated RPC params catalog so the params type-parity gate is satisfied. - Retire the persistence assertions for the superseded design: a migratedNativeProfileIds event map, a notice-acknowledgement clear, and a global persistence-failure accessor. Legacy userAgentMode bytes are retained now, so these assert retention plus a failed notice write still hydrating. - The in-memory fs fixture threw a codeless ENOENT, which reads as "unreadable" rather than "missing" and made every identity write refuse. Carry the code. - Use the segmented control's per-option disabled rather than adding a control-level prop it does not have.
The rescued work already serialized identity writes, but the writer lived beside the pre-ready reader, so nothing stopped a second caller from writing the record directly -- which is the shape of the bug this change set removes. browser-identity-mode-record.ts is now read-only: record shape, path, parsing and the pre-ready synchronous read. browser-identity-mode-store.ts owns every mutation behind one queue, holds the snapshot and listeners, and derives restartRequired from appliedMode vs configuredMode rather than storing it. Consumers move to the store. The two identity RPC methods also move out of browser-core.ts into browser-identity-rpc.ts: they read and write this host's own process identity rather than driving a page, and browser-core.ts was over its line cap. The generated params catalog is byte-identical.
…ssless A corrupt or newer-version record left the identity unchangeable with no way out. An explicit reset now copies the old bytes verbatim to a fresh unique path before publishing a replacement, and refuses the whole operation if that backup cannot be written -- so the reset can never be the thing that loses the data. Nothing resets automatically. Future-version data says update Orca rather than reporting corruption. Reset is opt-in via browser.identity.set and orca browser identity set --reset. ProfileCreate and BrowserIdentitySet move to browser-identity-params.ts: both carry the per-profile to app-wide identity move, and browser-params.ts was over its line cap. Also registers browser as a top-level CLI name so the Windows launch redirect covers it -- without it orca browser identity get boots the GUI and exits silently there -- and adds the canonical browser identity show alias the CLI vocabulary policy requires.
browser.identity.v1 was static, so every host claimed it including one that never initialized the identity store, where both methods can only throw. It now follows the browser.headless.v1 precedent and is pushed at status time when the store is actually initialized. Also covers the retired profileCreate userAgentMode field at the dispatcher rather than only at the schema, so an older client provably gets the changed-semantics rejection over the wire instead of a success with the field quietly dropped.
…niqueness The queue could not be falsified by any test: writeRecord is synchronous end to end, so two calls cannot interleave and removing serialization entirely left every store test green. Carrying machinery whose guard is unconstructible is what the design review told us to cut, so it is gone. If durable writes ever become async, serialization comes back with the change that makes it testable. The test that claimed to prove serialization now states what it actually pins -- the later of two selections is the one that survives -- and the module doc no longer claims a queue that is not there. Adds the guard that was missing on reset: two resets across separate launches must produce two distinct backups, each holding its own original bytes. Verified discriminating -- a fixed backup filename fails it.
…rtions Pins the mixed-version guarantee that had no test: browser.identity.v1 is advertised when the identity store is initialized and absent when it is not. Verified discriminating -- advertising it unconditionally fails the test. The profileCreate rejection test asserted ok:false against a runtime with no browserProfileCreate, so that assertion passed even when the retired field was accepted. It now stubs a working runtime method, making ok:false load-bearing, and asserts the runtime is never reached. Removes the persistence fixture's dead failIdentityWrite branch on writeFileAtomically: nothing on that path calls it, so it implied a second write mechanism that does not exist. Failure is injected through node:fs, which is what the identity write actually uses.
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review. 📝 WalkthroughWalkthroughThe change replaces per-profile user-agent selection with an app-wide browser identity mode. It adds persisted mode storage, startup initialization, runtime RPC, IPC, preload, CLI, and settings controls. Browser request and viewport handling now use the process identity. Legacy profile settings are inspected and surfaced through migration notices. Profile creation no longer accepts user-agent options. Documentation and integration tests now describe and verify the app-wide behavior. Priority: ➖ Normal Merge Risk: 🔵 Low · up to The change leaves bounded issues affecting localized settings, identity recovery, legacy clients, optional probes, documentation, and some foreign browser identities. These do not indicate a broad outage, but should remain owner-visible. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description provides detailed technical context, rationale, implementation details, and validation results. However, it omits several required template sections and items, including the mandatory Linked Issue with a Fixes reference, Visual Proof or an explicit N/A reason, the Testing section and checkboxes, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist. Resolution Add all required template sections. Include a linked issue using
✨ 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.
ℹ️ No critical issues. Three small suggestions inline; the first is worth a look because it affects the cloudflare live harness's validity.
Reviewed changes
- Process-wide identity store: new
browser-identity-mode-record.ts(read-only, distinguishesmissing/valid/corrupt/future/unreadable) andbrowser-identity-mode-store.ts(single writer, derivedrestartRequired, explicitresetbacks up unhealthy bytes before overwrite). - Pre-ready application:
browser-process-user-agent.tssetsapp.userAgentFallbackbefore Electronready;main-process-preflight.tsinitializes the store then the process UA, and moves the devapp.setNameahead of it. - Session layer:
browser-session-ua.tsreplacessetupGoogleAuthUserAgentOverridewith a disposer-returninginstallBrowserSessionUserAgentPolicy, adding ws/wss filtering, referrer-based auth identity, and CDP-matched client hints;browser-session-partition-policies.tsconfigures every partition from the process identity. - Request resolution:
browser-manager-navigation.tsresolves per-request identity and tracks session-scoped mobile intent for worker requests that omitwebContentsId. - Surface removal + replacement: per-profile
userAgentModeplumbing (types, preload, renderer, CLI--no-ua-spoof,BrowserProfileUserAgentOption) removed; new RPCbrowser.identity.get/set+browser.identity.v1capability,browser:identity:*IPC,browser identity get/setCLI, and a Settings → Browser identity control.ProfileCreatenow rejects the retired field withbrowser_profile_user_agent_mode_is_now_app_wide.
I verified browser-identity-mode-store, browser-identity-mode-record, and runtime/rpc/methods/browser pass locally, and read the new Electron wire-identity suites including their late-session-setter / fallback-disabled negative controls.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
ℹ️ No new PR-authored changes since the previous review — the only new commit is a catch-up merge of
main.
Reviewed changes
- Commit
a08fe664mergesorigin/mainintobrennanb2025/ua-b-finish. It changes only unrelated upstream files (pointer-input / agent-browser-bridge undersrc/main/browser, plus main's other advances) and leaves every file this PR authors untouched. - The branch-vs-
maindiff is therefore unchanged, and the initial review's two inline notes (stale JSDoc insrc/shared/global-settings-types.ts, anddeleteProfilenot retiring the new UA request-policy disposer) still stand.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
The channel split is asserted total, so adding browser:identity:get/set left it short by two. They manage the host's own process-wide user-agent choice rather than acting on a guest the reader is looking at, so they sit with the session and profile channels, not the preview tools.
There was a problem hiding this comment.
Actionable comments posted: 5
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 8c914860-8314-4d94-80db-dd2d5f5f6bd2
⛔ Files ignored due to path filters (1)
src/shared/rpc-contract/rpc-params-catalog.generated.tsis excluded by!**/*.generated.*
📒 Files selected for processing (93)
docs/site/content/docs/browser/overview.mdxdocs/site/content/docs/browser/profiles.mdxsrc/cli/browser-format.tssrc/cli/browser-handler-groups.tssrc/cli/browser.test.tssrc/cli/handlers/browser-identity.tssrc/cli/handlers/browser-profile.tssrc/cli/help.tssrc/cli/root-help-text-secondary.tssrc/cli/specs/browser-basic.tssrc/main/browser/browser-google-auth-ua.tssrc/main/browser/browser-identity-mode-record.test.tssrc/main/browser/browser-identity-mode-record.tssrc/main/browser/browser-identity-mode-store.test.tssrc/main/browser/browser-identity-mode-store.tssrc/main/browser/browser-manager-auth-user-agent.test.tssrc/main/browser/browser-manager-load-failure-replay.test.tssrc/main/browser/browser-manager-navigation.tssrc/main/browser/browser-manager-registration.tssrc/main/browser/browser-manager-state.tssrc/main/browser/browser-manager-types.tssrc/main/browser/browser-manager-viewport-override.test.tssrc/main/browser/browser-manager-viewport.tssrc/main/browser/browser-process-user-agent.tssrc/main/browser/browser-session-partition-policies.test.tssrc/main/browser/browser-session-partition-policies.tssrc/main/browser/browser-session-partition-proxy-install.test.tssrc/main/browser/browser-session-persisted-profile-validation.tssrc/main/browser/browser-session-profile-retirement.tssrc/main/browser/browser-session-registry-import-boundary.test.tssrc/main/browser/browser-session-registry.persistence.test.tssrc/main/browser/browser-session-registry.test.tssrc/main/browser/browser-session-registry.tssrc/main/browser/browser-session-route-policies.tssrc/main/browser/browser-session-ua-cdp-collector.tssrc/main/browser/browser-session-ua-cloudflare-live.electron.test.tssrc/main/browser/browser-session-ua-wire-identity-cross-context.electron.test.tssrc/main/browser/browser-session-ua-wire-identity.electron.test.tssrc/main/browser/browser-session-ua-wire-probe-server.tssrc/main/browser/browser-session-ua.tssrc/main/browser/browser-session-user-agent-migration-inspection.test.tssrc/main/browser/browser-session-user-agent-mode.tssrc/main/browser/browser-viewport-user-agent.tssrc/main/browser/browser-webauthn-profile-delete.test.tssrc/main/browser/doc-preview-protocol.test.tssrc/main/browser/doc-preview-protocol.tssrc/main/browser/offscreen-browser-backend.tssrc/main/ipc/browser-session-profile-ipc.test.tssrc/main/ipc/browser-session-profile-ipc.tssrc/main/ipc/browser.tssrc/main/persistence/loading-store/normalize-loaded-global-settings.test.tssrc/main/runtime/orca-runtime-browser.test.tssrc/main/runtime/orca-runtime-get-status.tssrc/main/runtime/orca-runtime-tests/browser-capabilities.spec.tssrc/main/runtime/rpc/methods/browser-identity-rpc.test.tssrc/main/runtime/rpc/methods/browser-identity-rpc.tssrc/main/runtime/rpc/methods/browser-schemas.tssrc/main/runtime/rpc/methods/browser.test.tssrc/main/runtime/rpc/methods/index.tssrc/main/runtime/runtime-browser-commands-browser-tab-set-profile.tssrc/main/server/serve-stdout-boundary.test.tssrc/main/server/serve-stdout-boundary.tssrc/main/startup/browser-process-user-agent-ordering.test.tssrc/main/startup/cli-command-names.tssrc/main/startup/main-process-preflight.tssrc/main/startup/main-process-ready-identity-write.test.tssrc/main/startup/main-process-runtime-launch.tssrc/preload/api/browser-api.tssrc/preload/api/browser-bridge-page-interaction-and-sessions.tssrc/renderer/src/app-shell/use-app-shell-services.tssrc/renderer/src/app-startup-routing.test.tssrc/renderer/src/components/browser-pane/assemble-chrome/BrowserToolbarMenu.tsxsrc/renderer/src/components/browser-pane/assemble-chrome/browser-toolbar-profile-dialogs.tsxsrc/renderer/src/components/browser-pane/browser-user-agent-migration-notice.tssrc/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/BrowserPane.tsxsrc/renderer/src/components/settings/BrowserProfileRow.tsxsrc/renderer/src/components/settings/BrowserUserAgentSetting.test.tsxsrc/renderer/src/components/settings/BrowserUserAgentSetting.tsxsrc/renderer/src/components/settings/browser-search.test.tssrc/renderer/src/components/settings/browser-search.tssrc/renderer/src/lib/settings-navigation-types.tssrc/renderer/src/store/slices/browser-session-profiles.test.tssrc/renderer/src/store/slices/browser/browser-profile-list-actions.tssrc/renderer/src/store/slices/browser/browser-slice-contract.tssrc/shared/browser-user-agent-mode.tssrc/shared/browser-workspace-types.tssrc/shared/global-settings-types.tssrc/shared/protocol-version.tssrc/shared/rpc-contract/browser-identity-params.tssrc/shared/rpc-contract/browser-params.ts
💤 Files with no reviewable changes (13)
- src/main/browser/offscreen-browser-backend.ts
- src/main/browser/browser-session-route-policies.ts
- src/cli/help.ts
- src/main/ipc/browser.ts
- src/main/browser/browser-session-user-agent-mode.ts
- src/shared/browser-workspace-types.ts
- src/main/browser/browser-session-profile-retirement.ts
- src/cli/root-help-text-secondary.ts
- src/shared/rpc-contract/browser-params.ts
- src/renderer/src/components/browser-profile-user-agent-option.tsx
- src/main/browser/browser-manager-types.ts
- src/renderer/src/components/browser-profile-user-agent-option.test.tsx
- src/renderer/src/components/browser-pane/assemble-chrome/browser-toolbar-profile-dialogs.tsx
Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review.
| return await browserSessionRegistry.createProfile(args.scope, args.label, { | ||
| userAgentMode: args.userAgentMode | ||
| }) | ||
| return await browserSessionRegistry.createProfile(args.scope, args.label) |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
Reject the retired userAgentMode field in browser:session:createProfile.
The trusted-renderer check does not validate the request shape. For a valid scope, createProfile persists and returns a profile using only args.scope and args.label. An older preload can therefore receive success while its requested identity is silently ignored. Reject the field at this IPC boundary, as the RPC contract already does.
Proposed fix
+ if ('userAgentMode' in args) {
+ return null
+ }
return await browserSessionRegistry.createProfile(args.scope, args.label)📝 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.
| return await browserSessionRegistry.createProfile(args.scope, args.label) | |
| if ('userAgentMode' in args) { | |
| return null | |
| } | |
| return await browserSessionRegistry.createProfile(args.scope, args.label) |
| label: string | ||
| }) => Promise<BrowserSessionProfile | null> | ||
| identityGet: () => Promise<BrowserIdentityModeStatus | null> | ||
| identitySet: (mode: BrowserUserAgentMode) => Promise<BrowserIdentityModeSetResult | null> |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Add a reset action to the local browser identity setting.
When identityGet() returns configuredMode === null, BrowserUserAgentSetting renders only the reset-required message. It has no control that calls identitySet. The local IPC path accepts only a mode and calls setBrowserIdentityMode without { reset: true }, so corrupt, unreadable, or future records remain unchanged.
The runtime RPC and CLI already support reset; the CLI is the only shipped user-facing recovery path. Extend the local IPC contract to forward an explicit reset request, then add a reset-and-select action to BrowserUserAgentSetting.
| .identitySet(mode) | ||
| .then((result) => { | ||
| if (!result) { | ||
| setError('Browser identity is unavailable.') |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Localize the unavailable-identity error.
When this fallback runs, setError stores raw English text that the settings UI renders without translate. It can therefore remain English in a localized UI.
Proposed fix
- setError('Browser identity is unavailable.')
+ setError(
+ translate('settings.browser.userAgent.unavailable', 'Browser identity is unavailable.')
+ )📝 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.
| setError('Browser identity is unavailable.') | |
| setError( | |
| translate('settings.browser.userAgent.unavailable', 'Browser identity is unavailable.') | |
| ) |
| floatingTerminalEnabled: boolean | ||
| /** Main-side new-page kill switch for paired Electron client-hosted browser placement. */ | ||
| browserClientHostedRemoteEnabled?: boolean | ||
| /** Process-wide browser identity selected for the next app launch. */ |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Remove the misleading documentation for browserSshWorkspaceRoutingEnabled.
Both consecutive JSDoc blocks document browserSshWorkspaceRoutingEnabled. The first describes browser identity, but the property controls SSH-workspace browser routing. Remove the unrelated block.
- /** Process-wide browser identity selected for the next app launch. */
/** Routes SSH-workspace browser pages through the workspace's SSH host; off = plain local browsing. */
browserSshWorkspaceRoutingEnabled?: boolean📝 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.
| /** Process-wide browser identity selected for the next app launch. */ |
The wire probe server and CDP collector arrived with the cross-context coverage and were never added to the audit list. The collector's two real call sites are safe: the poll cancels its unread body and the version probe consumes it through response.json(). Every hit in the probe server is inside an injected page or worker script source string, not a call this process makes.
app.setName decides the app token in the user agent, and dev sets "Orca Dev". The cleaner matched a single whitespace-delimited token, which cannot span that space, so the replace failed outright and every dev build presented "Orca Dev/1.4.203" on the wire — the exact token class that gets transplanted sessions revoked. Anchoring on the engine comment and consuming lazily up to Chrome/ removes any number of app tokens. A user agent without that comment is returned unchanged rather than mangled, because over-stripping is worse than under-stripping. The function had no unit test at all; it was only exercised through the real-Electron wire tests, which run with a single-token fixture name. That is why this survived.
There was a problem hiding this comment.
ℹ️ No new issues in this delta — the one production change is a correct, well-tested fix. (The three open inline notes from the initial review remain unaddressed, so this is not an approval.)
Reviewed changes
- App-name stripping made robust:
cleanElectronUserAgentnow anchors on the(KHTML, like Gecko)engine comment and lazily consumes any run of tokens up to the firstChrome/, so a multi-wordapp.setName— dev'sOrca Dev— no longer survives onto the wire asOrca Dev/1.4.203. A user agent without that engine comment is returned byte-identical rather than mangled. - New unit coverage:
browser-process-user-agent.test.tspins the one-word, spaced, two-space, and no-app-token shapes, plus the already-clean and foreign-UA no-op cases. All 6 pass locally, and the change holds against theOrcaWireIdentityFixtureelectron harness, which consumes the production cleaner.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 31dc04f2-2b84-4688-afeb-715fcc045140
📒 Files selected for processing (2)
src/main/browser/browser-process-user-agent.test.tssrc/main/browser/browser-process-user-agent.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review.
| // mangled. | ||
| export function cleanElectronUserAgent(userAgent: string): string { | ||
| return userAgent | ||
| .replace(/\s+Electron\/\S+/, '') |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Preserve foreign user agents before removing Electron/.
When (KHTML, like Gecko) is absent, cleanElectronUserAgent should return the original value. The current first replacement removes Electron/<version> before the engine-comment replacement, so SomeOtherAgent/2.0 Electron/43.7.0 Chrome/... is modified. Add this input shape to the regression test.
Proposed fix
export function cleanElectronUserAgent(userAgent: string): string {
+ if (!userAgent.includes('(KHTML, like Gecko)')) return userAgent
+
return userAgent
.replace(/\s+Electron\/\S+/, '')My first attempt anchored on the engine comment, which broke a startup fixture whose platform comment is "(Test)" with no "(KHTML, like Gecko)" at all — the app token survived and the ordering test went red. Anchoring on the nearest ")" before Chrome/ and consuming only non-")" tokens keeps the match inside that gap, so it handles a multi-word app name, a synthetic platform comment, and an already-clean identity alike. A user agent with no such gap is still returned unchanged. The fixture shape is now a test case, since it is what caught the first attempt.
A missing comma between two it.each elements was reformatted into an index expression, collapsing the table so every case ran with undefined input.
There was a problem hiding this comment.
ℹ️ No new issues in this delta. The cleaner anchor rewrite is correct on every shipped UA shape, and the one broken
it.eachtable it briefly produced was already repaired by the very next commit.
Reviewed changes
- Cleaner anchored on the nearest
)beforeChrome/:cleanElectronUserAgentnow uses/(\)\s+)(?:[^)\s]+\s+)*?(Chrome\/)/, so the app token is removed regardless of whitespace inapp.setName(dev'sOrca Dev) and a UA with no)‑to-Chrome/gap is returned byte-identical. I ran all six table shapes plus the foreign-UA no-op against the new regex: all pass. - Case table repaired:
9152a46momentarily emitted a malformedit.eachelement — a missing comma turned into a][ (…) ]index expression, collapsing that row toundefinedinput and failing four cases at that commit.3a90519restores it to],+[, so the table is five well-formed rows and thea platform comment that is not the engine commentcase is actually exercised by the anchor it exists to cover.
The three inline notes from the initial review (orphan JSDoc at global-settings-types.ts:265, deleteProfile not retiring the UA policy disposer, and the cloudflare-live harness calling initializeBrowserProcessUserAgent() with no mode) remain open and are untouched by these commits, so this is not an approval.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
This probe passes locally and fails on CI with an empty receipt set, an empty CDP diagnostic list, and a fixture that still exits 0 — so the assertion message carried nothing usable. Thread the fixture's own result and stderr into the capture assertion so the next run says what the fixture actually did.
…good The retired per-profile userAgentMode bytes are retained on disk by design, so every launch rediscovers them and re-arms the notice — including the launch right after the user answers it, and every launch after that. Documented as one-time, it was permanent. The record already carries explicitSelection, which is exactly the fact that should end the notice. Gate the mark at the single writer rather than deleting the legacy key, so the retained bytes stay untouched and disk never claims a notice is pending beside a choice the user already made. The new test pushed the persistence suite past max-lines, so the in-memory fs and module mocks move to a named fixture module and the retired-identity tests move beside them in their own file.
A profile that fails validation for a reason unrelated to identity — a non-UUID id, a mismatched partition — armed both the notice and its degraded flag. Since hydrateFromPersisted skips such entries silently and nothing ever repairs them, the user got "an old browser identity choice could not be inspected" forever, about a profile that never carried one. Key the notice on the presence of userAgentMode instead, and use validation only to decide whether the choice that was found is inspectable. Refusing to hydrate an entry and finding a retired choice are now separate facts. The old case table asserted the defect for null, 42 and 'broken', so it is replaced by two tables stating the new contract rather than adapted to pass.
A worker request carries no webContentsId, so it always took the session-wide branch and picked up the mobile UA if any tab in the session had a mobile preset. That made a single context disagree with itself: a desktop tab's shared worker reported a desktop navigator.userAgent — the per-target CDP override cannot reach a worker — while its fetches left as CriOS. It also leaked across tabs, and closing the emulated tab silently reverted it. On main the divergence was between contexts, each internally coherent. Making one context internally inconsistent is worse by this PR's own standard, so accept that viewport emulation reaches documents only. Workers keep the session identity on the wire, which is the identity they report in JavaScript. That left hasSessionMobileViewportIntent with no reader, so the map it fed and its three accessors go too, rather than leaving a dead latch behind the guard. The electron fixture models this rule in its own header hook, so its hook and both mobile arms are rewritten around the invariant that each context's wire identity equals the identity its own JavaScript reports — not adapted to keep the old path list passing.
There was a problem hiding this comment.
ℹ️ No new issues in this delta. Both changes are test-rig and localization only — no production behavior moved — and each is covered by the gates below. The five open inline notes from earlier reviews remain unaddressed, so this is not an approval.
Reviewed changes
- Nested CDP targets now pause before their enables —
browser-session-ua-cdp-collector.ts(test-only; imported solely by the three*.electron.test.tsrigs) drops the explicitTarget.attachToTargetonTarget.targetCreatedand instead arms a filtered (iframe/worker)Target.setAutoAttachon every attached session inprepareTarget, ahead ofRuntime.runIfWaitingForDebugger, so an OOPIF or dedicated worker arrives waiting for the debugger rather than racing the capture. Root auto-attach still reaches browser-levelshared_worker/service_worker, so the existingattached:shared_worker:assertion still holds, and the new:wfd=suffix does not disturb thesplit(':')[1]target-type parse. - Browser identity search entry localized — the inline entry moved to
browser-user-agent-search.tsbehindcreateLocalizedCatalog, with its literal English keywords replaced bytranslateSearchKeywordkeys and its description default aligned toen.json. That alignment drops the now-matchedsettings.browser.userAgent.descriptionfromen-runtime-required.json, and the five...search.userAgent.*keyword keys were added toen.json. The entry stays appended at index 10, soBrowserPane's index-based gating is unaffected.
Verified locally: generate-runtime-required-english-catalog.mjs exits 0, verify-localization-extraction.mjs exits 0, and browser-search.test.ts passes 13/13.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
Electron UI validation (read-only, this worktree)Launched Orca from
{"name":"Orca: brennanb2025/ua-b-finish","isDev":true,"devLabel":"ua-b-finish","devBranch":"brennanb2025/ua-b-finish","devWorktreeName":"ua-b-finish","devRepoRoot":"/Users/brennanbenson/orca/workspaces/orca/ua-b-finish","dockBadgeLabel":null}Visible Browser identity surface (Settings → Browser,
Renderer console: 0 errors. Warnings: React Grab outdated, and a Tooltip controlled↔uncontrolled warning on identity radio hover. Screenshots (uncropped app window; not committed)Home / empty workspace: Browser identity default (Cleaned): Native selected + Restart required: Native tooltip: Cleaned tooltip: After toggling back to Cleaned: Settings search New profile dialog (no per-profile UA): Remaining gapsDid not restart, so Native was never applied to live browser requests. Did not open a browser tab, probe wire UA, or cover remote-host / reset-required / migration-toast states. Saving/inert segmented-control state was too fast to see. Screenshots include a collapsed Playwright inspector pill at the bottom edge. |
There was a problem hiding this comment.
ℹ️ No new issues in this delta. The one production change is the fix requested in the previous review — the route-policy caller now propagates and awaits the async identity installer, so its cleanup/rethrow path still runs. Approval is withheld only because four earlier inline notes remain open.
Reviewed changes
- Route-policy installer awaited:
installBrowserRoutePartitionPolicies(browser-session-route-policies.ts:9) now returnsinstallBrowserSessionPartitionPolicies(...)instead ofvoid-discarding it,setupRoutePartitionPolicies(browser-session-registry.ts:202) returns thePromise<void>, andprepareBrowserRouteSessionPolicy(browser-route-session-policy.ts:39)awaitssetupPolicies. An uninitialized process identity now rejects into that function'stry/catch, soclearPoliciesruns and the error rethrows instead of becoming an unhandled rejection that admitted the partition without a UA policy. Both call sites (browser-route-session-runtime.ts:45-46,local-ssh-browser-partitions.ts:158-159) return the promise from their arrows, and the registry test harness was made async to match. - Nested CLI group help:
isCommandGroup(cli/args.ts:148) is now derived fromCOMMAND_SPECS— a visible spec with a strictly longer path matching the prefix — rather than a hardcoded group whitelist, andformatGroupHelp(cli/help.ts:64) takes a group path.orca browser identity --helpnow prints itsget/setsubcommands instead of "Unknown command". Newit.each(cli/index.test.ts:307) coversorca browser --helpandorca browser identity --helpand asserts no runtime client is constructed. - Flag-help consolidation: the eight Linear flag descriptions moved from inline
ifbranches intohelpByFlag, and the retired--no-ua-spoofentry was dropped — a mechanical no-op.
I checked the spec-driven isCommandGroup against every group in the removed whitelist (all 27 resolve to a visible descendant spec) and confirmed the nested agent hooks / storage local|session groups remain recognized, so no group help regressed. Verified at this head: pnpm tc:node clean; browser-route-session-registry (27), browser-session-registry (36), browser-session-partition-proxy-install (9), local-ssh-browser-partitions.probe-cache (3), cli/index (32), and cli/browser (35) all pass.
The four remaining open notes — orphan JSDoc at global-settings-types.ts:265, deleteProfile not retiring the UA disposer, the cloudflare-live harness mode, and the worker-request comment — are untouched by this commit.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
Electron UI validation (browser identity / profile)Isolated Orca Electron from this worktree (
Scenario exercisedSeeded a pending migration notice, then drove the visible Settings flow via Playwright CDP (no OS mouse/keyboard).
Backing state
Disk Screenshots (uncropped 1440×900 app viewport)1. Migration toast on the home surface 2. Settings → Browser identity, Cleaned selected 3. Native selected + Restart required 4. Session & Cookies profile row — no per-profile UA 5. New Browser Profile dialog — name only 6. Settings search 7. Native tooltip Remaining gaps
|
Review statusReviewed at Validation completed:
Remaining validation gap: the Electron pass did not restart the app to re-prove Native on the wire. Current CI status: the latest head's native smoke, typecheck, docs, and cross-version checks passed. Static analysis is failing on |
There was a problem hiding this comment.
ℹ️ No critical issues — one follow-on inline note on the live Cloudflare fixture.
Reviewed changes
- Updated the live Cloudflare fixture to the process-identity API — the
brancharm now callsinitializeBrowserProcessUserAgent('clean')(the fix requested in the initial review's thread) and readsidentity.userAgent, since the retiredidentity.nativeUserAgent/identity.cleanUserAgentmembers no longer exist.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
ℹ️ No new issues in this delta — the one commit fixes the Cloudflare fixture's native-UA capture that the previous review flagged. Earlier inline notes remain open, so this is not an approval.
Reviewed changes
- Preserved the live probe's native UA —
browser-session-ua-cloudflare-live.electron.test.tsnow capturesnativeUserAgentfromapp.userAgentFallbackbefore thebrancharm callsinitializeBrowserProcessUserAgent('clean')and no longer readssess.getUserAgent()afterready. The clean-identity assertion and the native-leak assertion no longer collapse onto the same value.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
Final review statusReviewed and fixed through same-model review passes at Fixes pushed
Validation
CI noteThe latest aggregate Residual P2: legacy clients that still send the retired per-profile |
Additional cookie validationRan after the final review head
The cookie checks cover CHIPS partition keys, SameSite/Secure decoding, Google-family exclusion, replacement rollback, concurrent imports, staged restart fallback, and startup ordering. No cookie regression was observed. Remaining evidence gap: no single two-process fixture currently launches the full app startup path, replays a staged cookie DB through |
# Conflicts: # src/renderer/src/i18n/en-runtime-required.json
- drop a stray JSDoc left over from the removed per-profile setting - leave user agents without a Chromium engine comment byte-identical instead of anchoring the app-token strip on the OS comment and destroying a real engine token - localize the browser identity unavailable error - correct the worker comment: only shared and service worker requests carry no webContentsId, so emulation still reaches dedicated workers - retire the session user agent policy when a profile is deleted
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Stray identity JSDoc removed —
global-settings-types.tsno longer carries the leftoverProcess-wide browser identity…comment dangling abovebrowserSshWorkspaceRoutingEnabled. deleteProfileretires the UA request hook —browser-session-registry.ts:288now callsretireBrowserSessionUserAgentPolicy(sess)after clearing the partition memo, so a deleted profile's session no longer keeps theonBeforeSendHeadershook. A newbrowser-session-registry.test.tscase drives create → delete and asserts the lastonBeforeSendHeaderscall isnull, which goes red without the line.- Cleaner gated on the Chromium engine comment —
cleanElectronUserAgentreturns the input byte-identical unless it contains(KHTML, like Gecko), so the app-token anchor can no longer land on an OS comment and destroy a real engine token. The test table gains the OS-comment-without-engine-comment, no-comment, and Firefox shapes alongside the existing strip cases. - Worker-request comment corrected —
browser-manager-navigation.ts:61-65now attributes id-less requests to shared/service workers and notes the emulated tab's dedicated workers resolve mobile throughbrowserPageId. - Unavailable-identity error localized —
BrowserUserAgentSetting.tsxwraps the fallback intranslate('settings.browser.userAgent.unavailable', …), with the key added toen.json.
All prior Pullfrog threads are addressed, replied to, and resolved. Verified at 71e6e44: pnpm tc:node clean; browser-session-registry (37) and browser-process-user-agent (9) pass; generate-runtime-required-english-catalog.mjs and verify-localization-extraction.mjs exit 0; check:code-quality:changed reports 0 findings across 94 files.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
The ordering fixture carried no "(KHTML, like Gecko)" engine comment, a shape app.userAgentFallback cannot actually produce. That unfaithfulness was what made the old over-stripping look correct, and it broke once the cleaner started leaving non-Chromium identities alone. Add the engine comment, keeping the two-word "Orca Development" app token so the multi-word leak this test exists to catch is still caught. Both assertions are unchanged.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Startup UA fixture now models a real Electron fallback —
browser-process-user-agent-ordering.test.ts'sapp.userAgentFallbackgainsAppleWebKit/537.36 (KHTML, like Gecko)ahead of the two-wordOrca Development/0.0.0app token. The(KHTML, like Gecko)guard added tocleanElectronUserAgentreturns a UA without that comment byte-identical, so the previous fixture made the cleaner a no-op and itsnot.toMatch(/Orca|Development/)/not.toMatch(/Electron/)leak assertions could not hold. With the comment present the cleaner strips bothElectron/43.0.0and the multi-word app token, so the test again exercises the leak path it was written for. Verified against old vs new strings and ran it at this head: 1 passed.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
Review findings — statusFive findings were fixed in Fixed
One follow-on: the fix in (2) was incompatible with an existing test case that pinned the over-stripping as correct, and with the startup ordering fixture, whose user agent had no engine comment. Both were corrected to model a real Open threads that these commits already address — left for the reviewer to close: the Deliberately not changed
Unrelated CI note: |
One conflict: src/cli/help.ts formatFlagHelp. Main extracted the flag table into src/cli/flag-help-text.ts; this branch had folded the eight Linear if-branches into that same table and dropped --no-ua-spoof with the app-wide identity change. Kept both: take main's FLAG_HELP_TEXT lookup, drop the if-chain, and port the eight Linear entries into the extracted table while leaving main's new --shell entry in place and --no-ua-spoof removed. The group-help rewrite (isCommandGroup/formatGroupHelp taking specs and a group path) auto-merged and is unchanged.
Six commits. No agent-launch contract moved: agent-launch-intent, the shared launch params, the executor and the mobile task module are all byte-identical to the merge base. protocol-version.ts did change, but not for this work - #20767 adds BROWSER_IDENTITY_RUNTIME_CAPABILITY ('browser.identity.v1'). Checked rather than assumed, because that file is one of the ones #20999 moves; agent.launch.v2 is still absent from main, so nothing here adapts to it. Twelve goldens conflicted, all on recorderSha256/adapterSha256. Both sides re-record, so neither side's hashes fit the merged source. Re-recorded, seeded from theirs so a recorder that failed to run would fail loudly. Twelve files written by the re-record; the other 705 changed goldens were staged by the merge and are main's. Behaviour-preserving, by multiset comparison of added vs removed content lines with pool keys and hash fields normalised out: net added: 0 net removed: 0 Only the 24 source-hash lines moved - a pure recorder-source shift with no semantic change. Re-validated in normal (non-record) mode: 17 files, 821 passed.
…lyai#13822) (stablyai#20767) * feat(browser): process-wide browser identity, chosen before ready Electron resolves worker identity from a single process-global default, so two coherent identities cannot coexist in one process. This makes clean/native one app-wide decision read before `ready`, instead of a per-profile one that leaves documents on one identity and every worker request on the other. Both identities are load-bearing, measured across four origins at five reps: the cleaned identity clears an embedded Turnstile widget and WhatsApp's browser check where native is refused; native clears a full-page Cloudflare interstitial that the cleaned identity never clears. Base commit only: removing the per-profile field, its settings surface, and the migration notice follow. * test(browser): cover cross-context UA wire identity * refactor(browser): make user agent identity app-wide * test(browser): repair process identity wire fixture * Fix browser identity startup migration failures * WIP: rescue in-flight reduced-design work from a dead worker Worker ctx_cb5b1262d7fe stopped ~2h ago mid-implementation (last heartbeat 2026-09-14T22:48:06Z) leaving this uncommitted. Committed unverified to make it recoverable; not reviewed, not necessarily green. * fix(browser): repair the rescued identity work so it typechecks Finishes the interrupted edits in 7db9c54: - browser-user-agent-migration-notice.ts was truncated mid-write; close the then() callback so the file parses. - Register browser.identity.get/set in the generated RPC params catalog so the params type-parity gate is satisfied. - Retire the persistence assertions for the superseded design: a migratedNativeProfileIds event map, a notice-acknowledgement clear, and a global persistence-failure accessor. Legacy userAgentMode bytes are retained now, so these assert retention plus a failed notice write still hydrating. - The in-memory fs fixture threw a codeless ENOENT, which reads as "unreadable" rather than "missing" and made every identity write refuse. Carry the code. - Use the segmented control's per-option disabled rather than adding a control-level prop it does not have. * refactor(browser): make the identity store the only writer The rescued work already serialized identity writes, but the writer lived beside the pre-ready reader, so nothing stopped a second caller from writing the record directly -- which is the shape of the bug this change set removes. browser-identity-mode-record.ts is now read-only: record shape, path, parsing and the pre-ready synchronous read. browser-identity-mode-store.ts owns every mutation behind one queue, holds the snapshot and listeners, and derives restartRequired from appliedMode vs configuredMode rather than storing it. Consumers move to the store. The two identity RPC methods also move out of browser-core.ts into browser-identity-rpc.ts: they read and write this host's own process identity rather than driving a page, and browser-core.ts was over its line cap. The generated params catalog is byte-identical. * feat(browser): make resetting unhealthy identity data explicit and lossless A corrupt or newer-version record left the identity unchangeable with no way out. An explicit reset now copies the old bytes verbatim to a fresh unique path before publishing a replacement, and refuses the whole operation if that backup cannot be written -- so the reset can never be the thing that loses the data. Nothing resets automatically. Future-version data says update Orca rather than reporting corruption. Reset is opt-in via browser.identity.set and orca browser identity set --reset. ProfileCreate and BrowserIdentitySet move to browser-identity-params.ts: both carry the per-profile to app-wide identity move, and browser-params.ts was over its line cap. Also registers browser as a top-level CLI name so the Windows launch redirect covers it -- without it orca browser identity get boots the GUI and exits silently there -- and adds the canonical browser identity show alias the CLI vocabulary policy requires. * feat(browser): advertise the identity capability only where it exists browser.identity.v1 was static, so every host claimed it including one that never initialized the identity store, where both methods can only throw. It now follows the browser.headless.v1 precedent and is pushed at status time when the store is actually initialized. Also covers the retired profileCreate userAgentMode field at the dispatcher rather than only at the schema, so an older client provably gets the changed-semantics rejection over the wire instead of a success with the field quietly dropped. * refactor(browser): delete the identity write queue and guard backup uniqueness The queue could not be falsified by any test: writeRecord is synchronous end to end, so two calls cannot interleave and removing serialization entirely left every store test green. Carrying machinery whose guard is unconstructible is what the design review told us to cut, so it is gone. If durable writes ever become async, serialization comes back with the change that makes it testable. The test that claimed to prove serialization now states what it actually pins -- the later of two selections is the one that survives -- and the module doc no longer claims a queue that is not there. Adds the guard that was missing on reset: two resets across separate launches must produce two distinct backups, each holding its own original bytes. Verified discriminating -- a fixed backup filename fails it. * test(browser): guard the identity capability and harden two weak assertions Pins the mixed-version guarantee that had no test: browser.identity.v1 is advertised when the identity store is initialized and absent when it is not. Verified discriminating -- advertising it unconditionally fails the test. The profileCreate rejection test asserted ok:false against a runtime with no browserProfileCreate, so that assertion passed even when the retired field was accepted. It now stubs a working runtime method, making ok:false load-bearing, and asserts the runtime is never reached. Removes the persistence fixture's dead failIdentityWrite branch on writeFileAtomically: nothing on that path calls it, so it implied a second write mechanism that does not exist. Failure is injected through node:fs, which is what the identity write actually uses. * test(browser): classify the identity channels on the preview seam The channel split is asserted total, so adding browser:identity:get/set left it short by two. They manage the host's own process-wide user-agent choice rather than acting on a guest the reader is looking at, so they sit with the session and profile channels, not the preview tools. * test(browser): audit the identity rig's global-fetch call sites The wire probe server and CDP collector arrived with the cross-context coverage and were never added to the audit list. The collector's two real call sites are safe: the poll cancels its unread body and the version probe consumes it through response.json(). Every hit in the probe server is inside an injected page or worker script source string, not a call this process makes. * fix(browser): strip an app name that contains a space app.setName decides the app token in the user agent, and dev sets "Orca Dev". The cleaner matched a single whitespace-delimited token, which cannot span that space, so the replace failed outright and every dev build presented "Orca Dev/1.4.203" on the wire — the exact token class that gets transplanted sessions revoked. Anchoring on the engine comment and consuming lazily up to Chrome/ removes any number of app tokens. A user agent without that comment is returned unchanged rather than mangled, because over-stripping is worse than under-stripping. The function had no unit test at all; it was only exercised through the real-Electron wire tests, which run with a single-token fixture name. That is why this survived. * fix(browser): anchor the cleaner on the gap before Chrome/ My first attempt anchored on the engine comment, which broke a startup fixture whose platform comment is "(Test)" with no "(KHTML, like Gecko)" at all — the app token survived and the ordering test went red. Anchoring on the nearest ")" before Chrome/ and consuming only non-")" tokens keeps the match inside that gap, so it handles a multi-word app name, a synthetic platform comment, and an already-clean identity alike. A user agent with no such gap is still returned unchanged. The fixture shape is now a test case, since it is what caught the first attempt. * test(browser): repair the cleaner's case table A missing comma between two it.each elements was reformatted into an index expression, collapsing the table so every case ran with undefined input. * test(browser): make a CI-only capture failure diagnosable This probe passes locally and fails on CI with an empty receipt set, an empty CDP diagnostic list, and a fixture that still exits 0 — so the assertion message carried nothing usable. Thread the fixture's own result and stderr into the capture assertion so the next run says what the fixture actually did. * fix(browser): let an explicit choice retire the migration notice for good The retired per-profile userAgentMode bytes are retained on disk by design, so every launch rediscovers them and re-arms the notice — including the launch right after the user answers it, and every launch after that. Documented as one-time, it was permanent. The record already carries explicitSelection, which is exactly the fact that should end the notice. Gate the mark at the single writer rather than deleting the legacy key, so the retained bytes stay untouched and disk never claims a notice is pending beside a choice the user already made. The new test pushed the persistence suite past max-lines, so the in-memory fs and module mocks move to a named fixture module and the retired-identity tests move beside them in their own file. * fix(browser): stop reporting an unhydratable profile as a retired choice A profile that fails validation for a reason unrelated to identity — a non-UUID id, a mismatched partition — armed both the notice and its degraded flag. Since hydrateFromPersisted skips such entries silently and nothing ever repairs them, the user got "an old browser identity choice could not be inspected" forever, about a profile that never carried one. Key the notice on the presence of userAgentMode instead, and use validation only to decide whether the choice that was found is inspectable. Refusing to hydrate an entry and finding a retired choice are now separate facts. The old case table asserted the defect for null, 42 and 'broken', so it is replaced by two tables stating the new contract rather than adapted to pass. * fix(browser): stop rewriting worker requests for viewport emulation A worker request carries no webContentsId, so it always took the session-wide branch and picked up the mobile UA if any tab in the session had a mobile preset. That made a single context disagree with itself: a desktop tab's shared worker reported a desktop navigator.userAgent — the per-target CDP override cannot reach a worker — while its fetches left as CriOS. It also leaked across tabs, and closing the emulated tab silently reverted it. On main the divergence was between contexts, each internally coherent. Making one context internally inconsistent is worse by this PR's own standard, so accept that viewport emulation reaches documents only. Workers keep the session identity on the wire, which is the identity they report in JavaScript. That left hasSessionMobileViewportIntent with no reader, so the map it fed and its three accessors go too, rather than leaving a dead latch behind the guard. The electron fixture models this rule in its own header hook, so its hook and both mobile arms are rewritten around the invariant that each context's wire identity equals the identity its own JavaScript reports — not adapted to keep the old path list passing. * test(browser): point the identity tests at keys and writers that exist browserUserAgentMode appears in zero production files and zero commits on main; `git log -S` finds nothing. The retired key is profile.userAgentMode inside browser-session-meta.json. Two tests were built on the invented one. The global-settings test is deleted rather than repointed: no browser identity key has ever lived in global settings, and stripRetiredGlobalSettings strips only three unrelated keys, so the test asserted that an arbitrary unknown key survives an object spread — a fact about the normalizer, not about identity. The ready-phase test asserted on writeFileAtomically while the identity store writes through writeFileDurableSync, so it could not go red for the write it existed to forbid. It now watches the real writer, matched on the record path so an unrelated durable write cannot fail it for the wrong reason, and the invented settings key is gone from the Store mock. Proven by ablation: injecting a byte-identical rewrite of the record into ready composition leaves every snapshot and record assertion green and is caught only by the new assertion, while writeFileAtomically is never called. * fix(browser): let an unavailable process identity reject instead of throwing installBrowserSessionPartitionPolicies returned Promise<void> without being async, and configures the user agent policy before any suspension point. getBrowserProcessUserAgentIdentity throws when the process identity was never initialized, so that throw escaped synchronously past every caller's handler: `void install(...).catch(...)` in the registry, and a bare `void install(...)` in the route policies, which has no handler at all. Bookkeeping must never gate a user action. Session startup would have died on a failure its callers were already written to absorb and report. * docs(browser): scope the meta-store claim about dropped legacy keys The comment said persistMeta drops legacy keys on the next write because the loader no longer carries them. That holds for the top-level userAgent keys it describes, but not for the retired per-profile userAgentMode: it sits inside each BrowserSessionProfile in `profiles`, which is carried through untouched, so those bytes survive every write. Retaining them is deliberate — it is what makes rollback and data-loss machinery unnecessary, and the startup notice keys on their presence — so the comment read as broader cover than it provided, in the one place someone would look before deciding it was safe to strip them. * test(browser): pin the unmapped-webContents path beside an emulated tab A popup carries a webContentsId that maps to no registered tab, so it resolves through the same branch as a worker request that carries none at all. The branch already handled both, but only the absent-id case was covered. * test(browser): make the ordering fixture exhibit a multi-word app name This file sets the dev app name to "Orca Development" and then used a single-token user agent fixture, so it set up the multi-word scenario and used a fixture that could not exhibit it — which is how the multi-word app-name leak got through. The fixture now carries a two-word app token, matching what app.setName produces in dev, and the assertion names both words: a single \S+ match would leave "Orca" on the wire and still pass a one-token check. * test(settings): cover the local branch of the browser identity setting The only existing test covered the remote-host branch. The local branch — load, select, refused write, and reset-required — had none, and that is the path the retired-identity notice sends users down to make the choice that retires it. Covers the selected-mode render, the commit that reports restartRequired, a refused write surfacing its message without showing the mode as changed, and the reset-required state offering no control. * test(browser): run the real registry path in the ready identity pin The test stubbed browser-session-startup and browser-session-registry, which are the one ready-phase path that can write the identity record, so the record content assertion could not fail for the write it existed to forbid. Both are now real. Only the pieces hanging off the identity path are stubbed — partition policies, route sessions, cookie staging, webauthn — so the meta load, the retired-choice inspection, the identity store and the durable write all run for real against temp directories. The canonical path mock moves to persistence/loading-store/user-data-path, which is where the registry reads it; mocking persistence alone left the registry pointed elsewhere. The active profile directory is now a real temp dir, so the seeded browser-session-meta.json is actually found — against the old /test-profile literal the meta load found nothing and the whole exercise would have been vacuous. A third case proves the path is live: with no explicit choice, the same retired profile arms the notice through ready and lands migrationNoticePending on disk. The two authority cases assert the opposite, that an explicit choice leaves the record untouched. initializeBrowserSessionsForApp latches on module state, so each case resets modules and imports ready dynamically. Ablated: disabling the explicitSelection gate turns both authority cases red on the record content assertion while the arming case stays green. * fix(browser): reject an unrecognized identity mode at the IPC door normalizeBrowserUserAgentMode turned any unrecognized value into 'clean', so the IPC door reported success for a mode it had quietly replaced, while the RPC door validates against z.enum(['clean', 'native']) and rejects. One concept answered an unknown value two different ways, and a future mode name was silently downgraded rather than refused. The handler now rejects, which is what the RPC door does and what the renderer already handles — its catch puts the message in the error slot. Returning a result instead would have meant inventing a fourth error code for a case no legitimate caller can reach. normalizeBrowserUserAgentMode had no other consumer, so it goes with the change: leaving a coercion helper called "normalize" in shared/ invites the behaviour straight back in. * fix(settings): name the reset command where identity data is unusable When configuredMode is null the setting says identity data must be reset explicitly and then offers no control, because the reset overwrites data that may belong to a newer Orca. The only escape is the CLI, which the message never named — so it told the user to do something and gave them no way to do it. Copy only: one line naming the command, no control and no destructive action in the UI. The command goes in a new key beside the existing sentence rather than expanding its default, which keeps the already-translated string valid. No en.json entry: this component has no catalog entries for any of its keys, so English resolves from the call-site defaults and adding one only for the new key would be inconsistent with its siblings. * fix(i18n): add the browser identity keys to the localization catalog * fix(i18n): regenerate the runtime-required English catalog * fix(browser): attach nested CDP targets paused before enabling Network An OOPIF or dedicated worker was reached only through Target.targetCreated plus an explicit attachToTarget, which never pauses the target. The frame could issue its subresource fetch before Network.enable took effect, so the capture came back empty and the cross-context assertion failed under CI load. Re-arm auto-attach on each attached session, filtered to nested target types, so an OOPIF or worker arrives waiting for the debugger and its enables are ordered ahead of the resume. Drop the explicit attach, which is now both redundant and the racy path. * fix(settings): localize the browser identity search keywords * fix(browser): await route policy setup * fix(browser): satisfy strict static analysis * test(browser): update live identity fixture API * test(browser): preserve native UA in live probe * fix(browser): close the open review findings on the identity revert - drop a stray JSDoc left over from the removed per-profile setting - leave user agents without a Chromium engine comment byte-identical instead of anchoring the app-token strip on the OS comment and destroying a real engine token - localize the browser identity unavailable error - correct the worker comment: only shared and service worker requests carry no webContentsId, so emulation still reaches dedicated workers - retire the session user agent policy when a profile is deleted * test(browser): model a real Electron fallback in the startup UA fixture The ordering fixture carried no "(KHTML, like Gecko)" engine comment, a shape app.userAgentFallback cannot actually produce. That unfaithfulness was what made the old over-stripping look correct, and it broke once the cleaner started leaving non-Chromium identities alone. Add the engine comment, keeping the two-word "Orca Development" app token so the multi-word leak this test exists to catch is still caught. Both assertions are unchanged.
















What changed
Orca's embedded browser identity (the user agent it presents) is now one process-wide choice, applied via
app.userAgentFallbackbefore Electronready, instead of a per-profile setting.What Orca does now, and where it happens
Orca's browser presents one user agent for the whole process: the same string on documents, same-site and cross-site iframes, blob frames, popups, dedicated, shared and service workers, and every request any of them makes.
Where it is decided.
src/main/startup/main-process-preflight.ts:189callsinitializeBrowserProcessUserAgent(...)with the mode read from disk (initializeBrowserIdentityModeStore(getCanonicalUserDataPath()).appliedMode).When. Before Electron is ready — after
initDataPath()and the devapp.setName(), and before the single-instance lock, before anyBrowserWindow, before anysession.fromPartition(). The ordering is the point:app.userAgentFallbackis the default Blink stamps into each renderer and worker at creation, so anything created earlier keeps the old value and disagrees with everything created later.What each mode does.
clean(the default, and what a fresh install gets): the fallback is rewritten to drop theOrca/<version>andElectron/<version>tokens, leaving a Chrome-shaped identity.native: the fallback is left untouched, so the process keeps Electron's own identity.How the rest of the browser picks it up. Every partition sets its session user agent from that same frozen value (
browser-session-partition-policies.ts:35), so the network-layer fill-in cannot drift from the engine default. Navigation and viewport emulation read the same identity (browser-manager-navigation.ts:281), and the Firefox-on-Google-auth exception is gated onmode === 'clean'(:282).How it changes. Settings → Browser → Browser identity writes the choice to
browser-identity-mode.jsonunder userData and marks a restart as required. The running process keeps the identity it started with; the new one applies on next launch, because it cannot be changed under live renderers and workers.The lifecycle, and why the timing is the fix
Everything here follows from one property of Chromium: the user agent is baked into each renderer process and each worker at the moment it is created. It is not looked up per request. A context's identity is decided once, at birth, from whatever
app.userAgentFallbacksays at that instant, and is then fixed for that context's life.That makes this a lifecycle problem, not a configuration problem.
Every step marked bakes in reads the value at that moment. Set the fallback after any of them and that context keeps the old identity while later ones get the new one — which is precisely the split this PR removes.
browser-process-user-agent-ordering.test.tspins the sequence (init-data-path→set-name→read-mode→write-user-agent→ the rest), andinitializeBrowserProcessUserAgentthrows ifapp.isReady(), so it cannot be called late even by accident.app.setNamehas to come first for a related reason: the app name becomes a token inside the UA string, so cleaning before the name is set would strip the wrong thing.Why it cannot be patched later. There is no API to change a live worker's user agent. The CDP override (
Emulation.setUserAgentOverride) is per-target and forward-only: it reaches targets created after it is set and never reaches workers, which are browser-scoped rather than page-scoped. The only moment at which every context can be made to agree is before any of them exists.Why a restart is required to change it. Renderers and workers already running have their identity baked in. A new choice is written to disk and applied on the next launch rather than mutated underneath them.
Why it had to move
Sites bind a logged-in session to the browser identity that created it. Electron's compiled-in UA carries
Orca/<ver>andElectron/<ver>tokens, so transplanted Chrome cookies were being revoked — that is the LinkedIn/X logout report.The subtle part: Electron has two user-agent defaults. One is a network-layer fill-in (
session.setUserAgent) that only applies when a request arrives with no UA header. The other is the engine default that renderers and workers stamp onto requests they generate themselves. Setting only the first left documents clean while service workers, shared workers and renderer-minted requests still said Electron — one client presenting two identities, which is a sharper signal than either alone.Worker identity resolves from a single process-global default, so per-profile identity can never be coherent. Hence one choice per process.
Prior art: this is the upstream mechanism, not a workaround
The divergence is a long-standing, reported Electron behaviour. Three independent upstream reports, three different contexts, all the same shape — a session-level user agent does not cover everything in the process:
session.setUserAgent, the<webview useragent>attribute,loadURL'suserAgentoption andwebRequest.onBeforeSendHeadersall fail to reach a service worker. Closedblocked/need-info; no fix landed.app.userAgentFallbackis the API built for this. It was added in electron#18016, backported and merged as #18110, and the implementation notes are explicit that service workers are the reason it exists:The timing follows Electron's own guidance. The
app.userAgentFallbackdocumentation describes it as "a string which is the user agent string Electron will use as a global fallback", applying "when no user agent is set at the webContents or session level", notes that it helps keep the user agent consistent throughout an application, and recommends assigning it as early as possible during initialization.Another app reached the same conclusion. nativefier#1312 — "Not using userAgentFallback to inject the userAgent causes service workers to get the Electron user agent" reports this exact failure and identifies an app-level user agent as the fix, citing electron#16196. That repository was archived in 2023, so it stands as a corroborating report rather than a shipped fix.
Both modes are load-bearing
Measured across four origins, five repetitions each, with the native arm as a positive control:
Neither identity dominates, so the escape hatch stays — it just becomes app-wide.
The bug this removes
There were two persistence authorities. Preflight read the root record before readiness, but the ready phase then mirrored the active Orca profile's value back into it. With profile A native and B cleaned, switching A→B started B in native while B's settings UI said cleaned. A crash between the immediate root write and the debounced profile save reproduced the same split with no switch at all.
The root record is now the only authority, and the ready phase does not write it in either direction — pinned by a test that asserts the write never happens.
Known limits, deliberate
browser.identity.v1only when its store is initialized, but the dispatcher has no capability gate — an old client is told not to ask rather than refused if it asks anyway.userAgentMode: 'clean'; it now follows the process identity, so in native mode those previews present Electron's identity. Pinning one partition clean is exactly the per-partition identity this change proves cannot be coherent — its workers resolved from the process global regardless, so "clean" was only ever true for its documents.userAgentModebytes are retained on disk, not deleted. Users who had a native profile get a one-time notice on next browser open rather than a silent destination chosen for them.Mixed-version behaviour
An old client sending
userAgentModetoprofileCreatepreviously receivedok: trueand a profile created under the wrong identity. It now receivesinvalid_argumentcarrying the stable tokenbrowser_profile_user_agent_mode_is_now_app_wide.Validation
pnpm tcclean, all changed-code quality gates at 0 findings, ~19,500 unit tests and the real-Electron identity suites passing. New coverage includes a genuine cross-site OOPIF, dedicated-worker script and fetch, and client hints checked againstnavigator.userAgentData— each shown red with the process fallback removed, re-proven at the current head after the merge of main.These suites do run in CI: the
testjob delegates to a vitest invocation with no path filter, whose include matches*.electron.test.ts, and the recorded shard timings contain a real CI runtime for the wire-identity suite. The live-network Cloudflare suite is collected but stays env-gated and does not run.Gaps