Skip to content

fix(browser): make the browser identity one process-wide choice (#13822) - #20767

Merged
brennanb2025 merged 48 commits into
mainfrom
brennanb2025/ua-b-finish
Sep 16, 2026
Merged

brennanb2025 merged 48 commits into
mainfrom
brennanb2025/ua-b-finish

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 37 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​3239 $\color{#cf222e}{\Huge{\mathbf{−}}}$​822 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​2417
Prod 74 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​2197 $\color{#cf222e}{\Huge{\mathbf{−}}}$​420 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1777

What changed

Orca's embedded browser identity (the user agent it presents) is now one process-wide choice, applied via app.userAgentFallback before Electron ready, 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:189 calls initializeBrowserProcessUserAgent(...) with the mode read from disk (initializeBrowserIdentityModeStore(getCanonicalUserDataPath()).appliedMode).

When. Before Electron is ready — after initDataPath() and the dev app.setName(), and before the single-instance lock, before any BrowserWindow, before any session.fromPartition(). The ordering is the point: app.userAgentFallback is 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 the Orca/<version> and Electron/<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 on mode === 'clean' (:282).

How it changes. Settings → Browser → Browser identity writes the choice to browser-identity-mode.json under 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.userAgentFallback says at that instant, and is then fixed for that context's life.

That makes this a lifecycle problem, not a configuration problem.

process starts
│
└─ src/main/index.ts
   │
   ├─ :77  runMainProcessPreflight()          ← all of this runs BEFORE ready
   │        ├─ initDataPath()                   decide the userData directory
   │        ├─ app.setName('Orca Dev')          decides the app token inside the UA
   │        ├─ read browser-identity-mode.json  what did the user choose?
   │        └─ app.userAgentFallback = …        ★ the change (main-process-preflight.ts:189)
   │
   └─ :109 app.whenReady().then(…)
            │
            ├─ session.fromPartition('persist:orca-browser')
            │     └─ sess.setUserAgent(the same frozen value)
            ├─ BrowserWindow → renderer spawns    ← bakes in the fallback
            └─ page loads
                 ├─ cross-site iframe → own process → bakes in the fallback
                 ├─ new Worker()                   → bakes in the fallback
                 └─ service worker                 → bakes in the fallback

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.ts pins the sequence (init-data-path → set-name → read-mode → write-user-agent → the rest), and initializeBrowserProcessUserAgent throws if app.isReady(), so it cannot be called late even by accident.

app.setName has 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> and Electron/<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:

app.userAgentFallback is 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:

"we have to send the user-agent over the process arguments in order to support the override for service workers … In master it is initialized in the browser process so we don't have this work around."

The timing follows Electron's own guidance. The app.userAgentFallback documentation 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:

origin cleaned native
embedded Turnstile widget clears 5/5 refused 5/5
browser-check page clears 5/5 refused 5/5
full-page challenge interstitial refused 5/5 clears 5/5

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

  • Native mode has no Google sign-in. The Firefox identity used on Google auth hosts is delivered per-target and provably cannot reach workers, so applying it in native mode would recreate the two-identity split. Documented in the profiles page with the way out.
  • Switching modes requires a restart. One process, one identity.
  • Capability advertisement is feature detection, not enforcement. A host advertises browser.identity.v1 only 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.
  • Doc previews no longer pin a clean identity. The workspace document-preview partition previously forced 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.
  • Legacy userAgentMode bytes 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 userAgentMode to profileCreate previously received ok: true and a profile created under the wrong identity. It now receives invalid_argument carrying the stable token browser_profile_user_agent_mode_is_now_app_wide.

Validation

pnpm tc clean, 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 against navigator.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 test job 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

  • The segmented control's saving state is untested; during a save both options are inert-but-focusable.
  • Multi-process browser hosting would restore per-profile identity, and the per-page environment seam means it stays available as a later evolution. Not taken here: a second process can only reach the desktop pane as a pixel stream, which would degrade exactly the sites users pick native to actually use.

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.
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.
@coderabbitai

coderabbitai Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: a2038607-186b-47f6-941b-308cf342770d

📥 Commits

Reviewing files that changed from the base of the PR and between e5ada9d and 3a90519.

📒 Files selected for processing (2)
  • src/main/browser/browser-process-user-agent.test.ts
  • src/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.


📝 Walkthrough

Walkthrough

The 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 3a905

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)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 9.73% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 113 functions across 53 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description provides detailed technical context, rationale, implementation details, and validation results. However, it omits several required template sections and items, including the mandatory … Add all required template sections. Include a linked issue using Fixes #..., attach before/after visual proof or write N/A with a reason, complete the Testing section with platforms and checklist status, provide AI Disclosure as applica…
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely identifies the main change: making browser identity process-wide.
Full details: Description check

Explanation

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 Fixes #..., attach before/after visual proof or write N/A with a reason, complete the Testing section with platforms and checklist status, provide AI Disclosure as applicable, complete Review, Agent skill upstream boundary, Notes, and Checklist items, and organize the existing ELI5 and rationale content under the corresponding headings.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ 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, distinguishes missing/valid/corrupt/future/unreadable) and browser-identity-mode-store.ts (single writer, derived restartRequired, explicit reset backs up unhealthy bytes before overwrite).
  • Pre-ready application: browser-process-user-agent.ts sets app.userAgentFallback before Electron ready; main-process-preflight.ts initializes the store then the process UA, and moves the dev app.setName ahead of it.
  • Session layer: browser-session-ua.ts replaces setupGoogleAuthUserAgentOverride with a disposer-returning installBrowserSessionUserAgentPolicy, adding ws/wss filtering, referrer-based auth identity, and CDP-matched client hints; browser-session-partition-policies.ts configures every partition from the process identity.
  • Request resolution: browser-manager-navigation.ts resolves per-request identity and tracks session-scoped mobile intent for worker requests that omit webContentsId.
  • Surface removal + replacement: per-profile userAgentMode plumbing (types, preload, renderer, CLI --no-ua-spoof, BrowserProfileUserAgentOption) removed; new RPC browser.identity.get/set + browser.identity.v1 capability, browser:identity:* IPC, browser identity get/set CLI, and a Settings → Browser identity control. ProfileCreate now rejects the retired field with browser_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.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

Comment thread src/shared/global-settings-types.ts Resolved

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No new PR-authored changes since the previous review — the only new commit is a catch-up merge of main.

Reviewed changes

  • Commit a08fe664 merges origin/main into brennanb2025/ua-b-finish. It changes only unrelated upstream files (pointer-input / agent-browser-bridge under src/main/browser, plus main's other advances) and leaves every file this PR authors untouched.
  • The branch-vs-main diff is therefore unchanged, and the initial review's two inline notes (stale JSDoc in src/shared/global-settings-types.ts, and deleteProfile not retiring the new UA request-policy disposer) still stand.

Pullfrog  | Fix it ➔ | View workflow run | Using 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 8c914860-8314-4d94-80db-dd2d5f5f6bd2

📥 Commits

Reviewing files that changed from the base of the PR and between 438603f and a08fe66.

⛔ Files ignored due to path filters (1)
  • src/shared/rpc-contract/rpc-params-catalog.generated.ts is excluded by !**/*.generated.*
📒 Files selected for processing (93)
  • docs/site/content/docs/browser/overview.mdx
  • docs/site/content/docs/browser/profiles.mdx
  • src/cli/browser-format.ts
  • src/cli/browser-handler-groups.ts
  • src/cli/browser.test.ts
  • src/cli/handlers/browser-identity.ts
  • src/cli/handlers/browser-profile.ts
  • src/cli/help.ts
  • src/cli/root-help-text-secondary.ts
  • src/cli/specs/browser-basic.ts
  • src/main/browser/browser-google-auth-ua.ts
  • src/main/browser/browser-identity-mode-record.test.ts
  • src/main/browser/browser-identity-mode-record.ts
  • src/main/browser/browser-identity-mode-store.test.ts
  • src/main/browser/browser-identity-mode-store.ts
  • src/main/browser/browser-manager-auth-user-agent.test.ts
  • src/main/browser/browser-manager-load-failure-replay.test.ts
  • src/main/browser/browser-manager-navigation.ts
  • src/main/browser/browser-manager-registration.ts
  • src/main/browser/browser-manager-state.ts
  • src/main/browser/browser-manager-types.ts
  • src/main/browser/browser-manager-viewport-override.test.ts
  • src/main/browser/browser-manager-viewport.ts
  • src/main/browser/browser-process-user-agent.ts
  • src/main/browser/browser-session-partition-policies.test.ts
  • src/main/browser/browser-session-partition-policies.ts
  • src/main/browser/browser-session-partition-proxy-install.test.ts
  • src/main/browser/browser-session-persisted-profile-validation.ts
  • src/main/browser/browser-session-profile-retirement.ts
  • src/main/browser/browser-session-registry-import-boundary.test.ts
  • src/main/browser/browser-session-registry.persistence.test.ts
  • src/main/browser/browser-session-registry.test.ts
  • src/main/browser/browser-session-registry.ts
  • src/main/browser/browser-session-route-policies.ts
  • src/main/browser/browser-session-ua-cdp-collector.ts
  • src/main/browser/browser-session-ua-cloudflare-live.electron.test.ts
  • src/main/browser/browser-session-ua-wire-identity-cross-context.electron.test.ts
  • src/main/browser/browser-session-ua-wire-identity.electron.test.ts
  • src/main/browser/browser-session-ua-wire-probe-server.ts
  • src/main/browser/browser-session-ua.ts
  • src/main/browser/browser-session-user-agent-migration-inspection.test.ts
  • src/main/browser/browser-session-user-agent-mode.ts
  • src/main/browser/browser-viewport-user-agent.ts
  • src/main/browser/browser-webauthn-profile-delete.test.ts
  • src/main/browser/doc-preview-protocol.test.ts
  • src/main/browser/doc-preview-protocol.ts
  • src/main/browser/offscreen-browser-backend.ts
  • src/main/ipc/browser-session-profile-ipc.test.ts
  • src/main/ipc/browser-session-profile-ipc.ts
  • src/main/ipc/browser.ts
  • src/main/persistence/loading-store/normalize-loaded-global-settings.test.ts
  • src/main/runtime/orca-runtime-browser.test.ts
  • src/main/runtime/orca-runtime-get-status.ts
  • src/main/runtime/orca-runtime-tests/browser-capabilities.spec.ts
  • src/main/runtime/rpc/methods/browser-identity-rpc.test.ts
  • src/main/runtime/rpc/methods/browser-identity-rpc.ts
  • src/main/runtime/rpc/methods/browser-schemas.ts
  • src/main/runtime/rpc/methods/browser.test.ts
  • src/main/runtime/rpc/methods/index.ts
  • src/main/runtime/runtime-browser-commands-browser-tab-set-profile.ts
  • src/main/server/serve-stdout-boundary.test.ts
  • src/main/server/serve-stdout-boundary.ts
  • src/main/startup/browser-process-user-agent-ordering.test.ts
  • src/main/startup/cli-command-names.ts
  • src/main/startup/main-process-preflight.ts
  • src/main/startup/main-process-ready-identity-write.test.ts
  • src/main/startup/main-process-runtime-launch.ts
  • src/preload/api/browser-api.ts
  • src/preload/api/browser-bridge-page-interaction-and-sessions.ts
  • src/renderer/src/app-shell/use-app-shell-services.ts
  • src/renderer/src/app-startup-routing.test.ts
  • src/renderer/src/components/browser-pane/assemble-chrome/BrowserToolbarMenu.tsx
  • src/renderer/src/components/browser-pane/assemble-chrome/browser-toolbar-profile-dialogs.tsx
  • src/renderer/src/components/browser-pane/browser-user-agent-migration-notice.ts
  • src/renderer/src/components/browser-profile-user-agent-option.test.tsx
  • src/renderer/src/components/browser-profile-user-agent-option.tsx
  • src/renderer/src/components/settings/BrowserNewProfileDialog.tsx
  • src/renderer/src/components/settings/BrowserPane.tsx
  • src/renderer/src/components/settings/BrowserProfileRow.tsx
  • src/renderer/src/components/settings/BrowserUserAgentSetting.test.tsx
  • src/renderer/src/components/settings/BrowserUserAgentSetting.tsx
  • src/renderer/src/components/settings/browser-search.test.ts
  • src/renderer/src/components/settings/browser-search.ts
  • src/renderer/src/lib/settings-navigation-types.ts
  • src/renderer/src/store/slices/browser-session-profiles.test.ts
  • src/renderer/src/store/slices/browser/browser-profile-list-actions.ts
  • src/renderer/src/store/slices/browser/browser-slice-contract.ts
  • src/shared/browser-user-agent-mode.ts
  • src/shared/browser-workspace-types.ts
  • src/shared/global-settings-types.ts
  • src/shared/protocol-version.ts
  • src/shared/rpc-contract/browser-identity-params.ts
  • src/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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ 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.

Suggested change
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>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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.')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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.

Suggested change
setError('Browser identity is unavailable.')
setError(
translate('settings.browser.userAgent.unavailable', 'Browser identity is unavailable.')
)

Comment thread src/shared/global-settings-types.ts Outdated
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. */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 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.

Suggested change
/** 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.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ 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: cleanElectronUserAgent now anchors on the (KHTML, like Gecko) engine comment and lazily consumes any run of tokens up to the first Chrome/, so a multi-word app.setName — dev's Orca Dev — no longer survives onto the wire as Orca 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.ts pins 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 the OrcaWireIdentityFixture electron harness, which consumes the production cleaner.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 31dc04f2-2b84-4688-afeb-715fcc045140

📥 Commits

Reviewing files that changed from the base of the PR and between 52b3fed and e5ada9d.

📒 Files selected for processing (2)
  • src/main/browser/browser-process-user-agent.test.ts
  • src/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+/, '')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No new issues in this delta. The cleaner anchor rewrite is correct on every shipped UA shape, and the one broken it.each table it briefly produced was already repaired by the very next commit.

Reviewed changes

  • Cleaner anchored on the nearest ) before Chrome/: cleanElectronUserAgent now uses /(\)\s+)(?:[^)\s]+\s+)*?(Chrome\/)/, so the app token is removed regardless of whitespace in app.setName (dev's Orca 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: 9152a46 momentarily emitted a malformed it.each element — a missing comma turned into a ][ (…) ] index expression, collapsing that row to undefined input and failing four cases at that commit. 3a90519 restores it to ], + [, so the table is five well-formed rows and the a platform comment that is not the engine comment case 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.

Pullfrog  | Fix it ➔ | View workflow run | Using 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.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ 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.ts rigs) drops the explicit Target.attachToTarget on Target.targetCreated and instead arms a filtered (iframe/worker) Target.setAutoAttach on every attached session in prepareTarget, ahead of Runtime.runIfWaitingForDebugger, so an OOPIF or dedicated worker arrives waiting for the debugger rather than racing the capture. Root auto-attach still reaches browser-level shared_worker/service_worker, so the existing attached:shared_worker: assertion still holds, and the new :wfd= suffix does not disturb the split(':')[1] target-type parse.
  • Browser identity search entry localized — the inline entry moved to browser-user-agent-search.ts behind createLocalizedCatalog, with its literal English keywords replaced by translateSearchKeyword keys and its description default aligned to en.json. That alignment drops the now-matched settings.browser.userAgent.description from en-runtime-required.json, and the five ...search.userAgent.* keyword keys were added to en.json. The entry stays appended at index 10, so BrowserPane'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.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Electron UI validation (read-only, this worktree)

Launched Orca from brennanb2025/ua-b-finish with ORCA_BACKGROUND_LAUNCH=1 and an isolated ORCA_DEV_USER_DATA_PATH. Attached via Playwright CDP (127.0.0.1:9334 / renderer 127.0.0.1:5174). No computer-use.

window.api.app.getIdentity()

{"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, #browser-user-agent):

  • Label Browser identity; description Choose the user agent for every browser profile and page. Native mode disables Google sign-in. Changes take effect after a restart.
  • Segmented Cleaned / Native. Fresh isolated profile started with Cleaned checked; identityGet() reported appliedMode=clean, configuredMode=clean, restartRequired=false, migrationNotice=null.
  • Clicking Native checked Native, showed Restart required, and identityGet() became configuredMode=native, appliedMode=clean, explicitSelection=true, restartRequired=true.
  • Native tooltip: Keeps Electron's built-in identity for sites that reject the cleaned identity. Google sign-in is unavailable in Native mode.
  • Cleaned tooltip: Removes Orca and Electron tokens to match imported Chrome sessions.
  • Clicking Cleaned again cleared Restart required (configuredMode=clean, restartRequired=false).
  • Settings search browser identity leaves only this row.
  • New Browser Profile dialog is name + Cancel/Create only — no per-profile user-agent control.

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:

01-home-app-context.png

Browser identity default (Cleaned):

04-browser-identity-cleaned.png

Native selected + Restart required:

05-browser-identity-native-restart.png

Native tooltip:

06-native-tooltip.png

Cleaned tooltip:

07-cleaned-tooltip.png

After toggling back to Cleaned:

08-browser-identity-cleaned-after-toggle.png

Settings search browser identity:

09-settings-search-identity.png

New profile dialog (no per-profile UA):

10-new-profile-dialog.png

Remaining gaps

Did 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.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ 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 returns installBrowserSessionPartitionPolicies(...) instead of void-discarding it, setupRoutePartitionPolicies (browser-session-registry.ts:202) returns the Promise<void>, and prepareBrowserRouteSessionPolicy (browser-route-session-policy.ts:39) awaits setupPolicies. An uninitialized process identity now rejects into that function's try/catch, so clearPolicies runs 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 from COMMAND_SPECS — a visible spec with a strictly longer path matching the prefix — rather than a hardcoded group whitelist, and formatGroupHelp (cli/help.ts:64) takes a group path. orca browser identity --help now prints its get/set subcommands instead of "Unknown command". New it.each (cli/index.test.ts:307) covers orca browser --help and orca browser identity --help and asserts no runtime client is constructed.
  • Flag-help consolidation: the eight Linear flag descriptions moved from inline if branches into helpByFlag, and the retired --no-ua-spoof entry 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.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Electron UI validation (browser identity / profile)

Isolated Orca Electron from this worktree (ORCA_BACKGROUND_LAUNCH=1, CDP 127.0.0.1:9334, renderer 127.0.0.1:5174). Confirmed instance identity:

Orca: brennanb2025/ua-b-finish · devRepoRoot=/Users/brennanbenson/orca/workspaces/orca/ua-b-finish · HEAD f8c4f457fc

Scenario exercised

Seeded a pending migration notice, then drove the visible Settings flow via Playwright CDP (no OS mouse/keyboard).

  1. Home toast Browser identity is now app-wide; Open Settings jumps to Settings → Browser identity.
  2. Process-wide Cleaned / Native control; Cleaned selected on first paint.
  3. Choosing Native shows Restart required.
  4. Session profile row and New Browser Profile dialog have no per-profile user-agent control.
  5. Settings search identity filters to the Browser identity row.

Backing state

applied configured explicit notice restartRequired
before Native clean clean false pending false
after Native clean native true null true

Disk browser-identity-mode.json after the click: { "version": 1, "mode": "native", "explicitSelection": true, "migrationNoticePending": false }. Applied mode stayed clean for this process.

Screenshots (uncropped 1440×900 app viewport)

1. Migration toast on the home surface

01-migration-toast-home.png

2. Settings → Browser identity, Cleaned selected

02-settings-browser-identity-cleaned.png

3. Native selected + Restart required

03-settings-browser-identity-native-restart.png

4. Session & Cookies profile row — no per-profile UA

04-settings-session-profiles-no-ua.png

5. New Browser Profile dialog — name only

05-new-profile-dialog-no-ua.png

6. Settings search identity

06-settings-search-identity.png

7. Native tooltip

07-native-tooltip.png

Remaining gaps

  • Did not restart, so Native was not re-proven on the wire for a subsequent launch.
  • No workspace in the isolated profile, so the browser toolbar overflow menu was not opened.
  • Remote-host CLI-only identity copy, unhealthy-record reset UI, and the brief saving-disabled state were not shown.
  • Dev launch produced two toast listitems in the a11y tree (one stacked visually).

@brennanb2025

brennanb2025 commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor Author

Review status

Reviewed at 1b60eb4a2d after the same-model review loop. The review is clean: the process-wide identity flow now waits for route-policy setup, preserves startup and persistence invariants, and the strict static-analysis issues found in this PR are fixed. I also corrected the live Electron fixture to use the current process-identity API while preserving its native control value, and pushed those fixes.

Validation completed:

  • Focused persistence, preview authorization, route/session, and CLI suites passed.
  • pnpm tc:node, changed-code quality, anti-slop, reliability, dead-class, selector-fanout, and diff checks passed locally.
  • Final readiness checklist reported no proven P0/P1/P2 findings.
  • Electron/CDP validation exercised the migration toast, Browser identity Cleaned/Native control, restart-required behavior, settings search, and removal of per-profile UA controls. Seven uncropped screenshots are attached in the validation comment: fix(browser): make the browser identity one process-wide choice (#13822) #20767 (comment)

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 src/shared/agent-status-legacy-adapter.ts, which comes from the current base branch and is outside this PR's diff; this PR's local static gates pass. The remaining package and test shards are still running.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ 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 branch arm now calls initializeBrowserProcessUserAgent('clean') (the fix requested in the initial review's thread) and reads identity.userAgent, since the retired identity.nativeUserAgent / identity.cleanUserAgent members no longer exist.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ 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.ts now captures nativeUserAgent from app.userAgentFallback before the branch arm calls initializeBrowserProcessUserAgent('clean') and no longer reads sess.getUserAgent() after ready. The clean-identity assertion and the native-leak assertion no longer collapse onto the same value.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Final review status

Reviewed and fixed through same-model review passes at 1b60eb4a2d; the reviewer returned clean after each fix loop.

Fixes pushed

  • Awaited route-session policy setup so asynchronous failures reject admission and run cleanup reliably.
  • Derived CLI help groups from registered command specs, including browser and browser identity.
  • Replaced dynamic property reflection in the new browser identity paths with typed parsing.
  • Kept the persistence test fixture under the existing __mocks__ boundary and corrected its moved relative mock paths.
  • Updated the live Cloudflare Electron fixture to use the current process-identity API and preserve the native control UA.

Validation

  • Final readiness checklist completed at the final head: no proven P0/P1 findings; no mobile-facing surface was changed.
  • Focused browser, persistence, route/session, CLI, identity/startup/RPC/renderer tests passed.
  • pnpm tc, changed-code quality, anti-slop, localization, cross-version wire suites, and git diff --check passed locally.
  • Electron/CDP validation used ORCA_BACKGROUND_LAUNCH=1 and attached seven uncropped screenshots in the Electron validation comment.
  • Latest CI: all test shards, package jobs, typecheck, cross-version wire compatibility, native smoke, and docs checks passed.

CI note

The latest aggregate verify is red only because static analysis sees src/shared/agent-status-legacy-adapter.ts:95, a file introduced by the current base branch and outside this PR's diff. No PR-introduced static-analysis errors remain; fixing that base-branch issue here would expand scope.

Residual P2: legacy clients that still send the retired per-profile userAgentMode field receive a deliberate rejection when creating a profile. Ordinary profile creation remains available, and upgrading the client is the practical workaround.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Additional cookie validation

Ran after the final review head 1b60eb4a2d:

  • 15 non-Electron cookie import, clear, staging, persistence, and rollback suites: 138 passed.
  • 7 real Chromium Electron cookie suites: 18 passed.
  • 2 real Electron wire-identity suites: 7 passed, covering documents, frames, workers, HTTP, WebSockets, and tab-specific mobile emulation.

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 BrowserSessionRegistry, and then reads it from a real browser window. The replay logic, startup ordering, and real Chromium import paths are covered separately.

# 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

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Stray identity JSDoc removed — global-settings-types.ts no longer carries the leftover Process-wide browser identity… comment dangling above browserSshWorkspaceRoutingEnabled.
  • deleteProfile retires the UA request hook — browser-session-registry.ts:288 now calls retireBrowserSessionUserAgentPolicy(sess) after clearing the partition memo, so a deleted profile's session no longer keeps the onBeforeSendHeaders hook. A new browser-session-registry.test.ts case drives create → delete and asserts the last onBeforeSendHeaders call is null, which goes red without the line.
  • Cleaner gated on the Chromium engine comment — cleanElectronUserAgent returns 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-65 now attributes id-less requests to shared/service workers and notes the emulated tab's dedicated workers resolve mobile through browserPageId.
  • Unavailable-identity error localized — BrowserUserAgentSetting.tsx wraps the fallback in translate('settings.browser.userAgent.unavailable', …), with the key added to en.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.

Pullfrog  | View workflow run | Using 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.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Startup UA fixture now models a real Electron fallback — browser-process-user-agent-ordering.test.ts's app.userAgentFallback gains AppleWebKit/537.36 (KHTML, like Gecko) ahead of the two-word Orca Development/0.0.0 app token. The (KHTML, like Gecko) guard added to cleanElectronUserAgent returns a UA without that comment byte-identical, so the previous fixture made the cleaner a no-op and its not.toMatch(/Orca|Development/) / not.toMatch(/Electron/) leak assertions could not hold. With the comment present the cleaner strips both Electron/43.0.0 and 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.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review findings — status

Five findings were fixed in 71e6e44ba7 and abc6b71601.

Fixed

  1. global-settings-types.ts — deleted the orphaned /** Process-wide browser identity… */ JSDoc that attached to no member and sat above the SSH-routing field's own doc. Leftover from the per-profile setting this PR removes.
  2. browser-process-user-agent.ts — cleanElectronUserAgent now returns the input unchanged when it carries no (KHTML, like Gecko) engine comment. Without that guard the app-token strip anchored on the OS comment and destroyed a real engine token: Mozilla/5.0 (X11; Linux x86_64) SomeEngine/1.0 MyApp/2.0 Chrome/… Electron/… Safari/537.36 became Mozilla/5.0 (X11; Linux x86_64) Chrome/… Safari/537.36. The function's comment was rewritten to describe the guarantee it actually provides. Regression cases added.
  3. BrowserUserAgentSetting.tsx — the unavailable-identity error was a bare literal in a file where every other string is translated; it now goes through translate(), with both localization catalogs synced.
  4. browser-manager-navigation.ts — comment only, code unchanged. It claimed "a worker request carries no webContentsId", which overgeneralizes: only shared and service workers omit it, while a dedicated worker's requests carry the owning tab's, so they resolve consistently with their own JS.
  5. browser-session-registry.ts — profile deletion now retires the session's user-agent policy. The old clearBrowserSessionUserAgentMode call was removed by this PR and the new disposer was wired only to the clear path, so a deleted profile's session kept its onBeforeSendHeaders hook.

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 app.userAgentFallback, which always carries one — verified against a live Electron 43 run. The multi-word app-name regression those tests exist to catch is still covered, and their assertions are unchanged.

Open threads that these commits already address — left for the reviewer to close: the global-settings-types.ts JSDoc, the BrowserUserAgentSetting.tsx localization, and the browser-process-user-agent.ts foreign-user-agent guard.

Deliberately not changed

  • browser-session-profile-ipc.ts:49 (reject a retired userAgentMode) — the cross-version rejection already exists where it matters, on the RPC path: browser-identity-params.ts:21 raises the stable token browser_profile_user_agent_mode_is_now_app_wide. This IPC is reached only by the same-version trusted renderer, which cannot send the retired field.
  • browser-api.ts:152 (add a reset action) — product scope, deliberately deferred. A destructive reset needs a confirmation flow and localized copy of its own; the CLI path orca browser identity set --mode <mode> --reset covers the recovery case meanwhile.

Unrelated CI note: static analysis is currently failing on src/shared/agent-status-store-snapshot-budget.ts, which this branch does not contain — it is new on main and imports one module three times, tripping import(no-duplicates). Other open PRs are red the same way. All 8 test shards, package, package (windows), typecheck and cross-version-wire are green here.

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.
@brennanb2025
brennanb2025 merged commit aee98cc into main Sep 16, 2026
36 checks passed
brennanb2025 added a commit that referenced this pull request Sep 16, 2026
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.
ivanvykopal pushed a commit to ivanvykopal/orca that referenced this pull request Sep 20, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant