Skip to content

fix(serve): keep the isolated profile off the login keychain - #27463

Merged
OrcaWin merged 3 commits into
mainfrom
OrcaWin/copy-25517-isolated-profile-switches
Oct 11, 2026
Merged

OrcaWin merged 3 commits into
mainfrom
OrcaWin/copy-25517-isolated-profile-switches

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 11, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​117 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​117
Prod 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​38 $\color{#cf222e}{\Huge{\mathbf{−}}}$​4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​34

This is a copy of #25517 by @paoValle, rebased on current main so CI can run here. The contributor's commit is kept unchanged, with their authorship. One follow-up commit removes the two new as string[] casts in launch.test.ts, which the changed-code gate rejects. They are replaced with a small helper that reads the spawn args and fails clearly if serve did not spawn.

A second follow-up comes from review. The sidecar always runs on a fresh profile, so either E2E variable is enough there. The foreground serve process, though, opens the selected profile's sealed secrets, and an ORCA_E2E_HOME_DIR override alone still selects the user's real profile. With only that variable set, the keychain would be switched off for real credentials. The foreground switches now require ORCA_E2E_USER_DATA_DIR, and a launch test covers the HOME-only case.

Co-authored-by: Paolo [email protected]


Author: @paolovalletta_

ELI5

pnpm start:emulator runs Orca with a throwaway HOME so it cannot touch your real profile. On macOS that also means there is no login keychain — and Orca's first startup step on the serve path asks macOS for its encryption key. macOS tries to create the keychain item, finds nothing to authorize it with, and waits for a reply that never comes, so the process stops there and never advertises itself.

Orca already knows how to run an isolated profile without the keychain: its browser sidecar is launched with --use-mock-keychain. The foreground serve process — the one this repro hangs in — was simply never given the same two switches. This shares that decision and applies it there too.

What Changed

Before, on macOS with the pairing runtime's disposable profile:

$ cd mobile && node scripts/start-emulator.mjs
[0] Starting temporary desktop runtime for mobile pairing...
[error] Timeout waiting for temporary desktop pairing URL   # after 120 s

…with the main thread parked in SecItemAdd → AuthorizationCopyRights, and main-thread-hang.json written after 45 s.

After: the foreground serve process is launched with the switches the sidecar already carries, so nothing in an isolated profile reaches the login keychain.

Mechanism. The main-thread caller the report could not name is Orca's own secret-protection probe, and the serve path runs it inline:

  • startup/main-process-ready-foundation.ts:181 — deferUntilFirstWindow: !state.isServeMode, so serve reports inline rather than after a window.
  • host/deferred-secret-protection-report.ts:51 — the non-deferred branch calls reportSecretProtectionGap() directly, on the main thread, before anything is advertised.
  • host/secret-protection-report.ts:49 → getSecretStore().describeProtectionGap() → host/electron-secret-store.ts:10 — first statement is safeStorage.isEncryptionAvailable(). The module's own comment above it records the same class of block on Linux (76 s to first window, STA-5765).

With no login keychain, Chromium's keychain lookup creates the item instead of reading it, and the creation is what waits on the authorization reply.

The switches already existed for this exact profile. orcad/electron-serve-browser-process.ts launches its sidecar with ['--password-store=basic', '--use-mock-keychain'] whenever ORCA_E2E_USER_DATA_DIR || ORCA_E2E_HOME_DIR is set, and electron-serve-browser-process.test.ts pins that. The foreground serve process is spawned by the CLI (cli/runtime/launch.ts, serveOrcaApp) and never received them, so the profile was isolated for one of its two Electron processes only.

This change moves the condition into shared/electron-isolated-profile-switches.ts and uses it at both launch sites.

Why

  • Why not just skip the probe for these profiles. The probe is not the only thing that can reach that keychain item — anything in the process that encrypts, Chromium's own cookie key included, hits the same one. Skipping one caller would leave the next one blocked. --use-mock-keychain removes the keychain from the process, which is why the sidecar uses it.
  • Why not defer the report for serve instead. That timing is deliberate and documented in deferred-secret-protection-report.ts: blocking after the runtime is advertised reads to a paired client as a dead host (stalled pings and PTY pumps), and the maintainers chose blocking before it. Reversing that is their call, not a drive-by change.
  • Why share the condition. Two Electron processes, one profile. The decision existed once in code and once in intent; now it exists once in code.

Linked Issue

Fixes #25453

Visual Proof

N/A — no user-interface change. The observable difference is that the foreground serve process starts advertising.

Testing

Check Result
electron-isolated-profile-switches.test.ts (new) — either env half, neither, and a bare HOME override 4 passed
cli/runtime/launch.test.ts — an isolated profile's serve args carry both switches; a normal profile's carry neither passed, 2 new cases
Mutation check: the same test with only the childArgs.push(...) removed fails with - "--use-mock-keychain", so it cannot pass by construction
main/orcad/electron-serve-browser-process.test.ts (the sidecar's pinned args, after the refactor) passed
pnpm test src/cli/ 1626 passed, 4 skipped (141 files)
pnpm test src/main/orcad/ 241 passed, 12 skipped (34 files)
pnpm tc (node + cli + web) exit 0
oxlint + oxfmt on the five files (pre-commit) clean

Platforms tested: macOS, where the switches are inert for a normal profile. I did not run the packaged reproduction — see Notes for why, and the confirmation I would like from the reporter.

AI Disclosure

Written with an AI coding agent, session model deepseek-v4.1-flash (provider opencode-go). All commands and results above were produced on this machine.

Review

  • Cross-platform: the condition is environment-driven, not platform-driven. A normal profile gets no extra switch on any platform, so macOS, Linux and Windows launches are byte-identical to before. --use-mock-keychain is a macOS switch and --password-store a Linux one; the sidecar already passed both unconditionally for this profile, which is the behaviour this mirrors.
  • SSH / remote / local: the switches are appended to a local process launch and change no wire, host, or provider path.
  • Agent and integration compatibility: no agent surface, hook, or provider frame is touched.
  • Performance risk: none. Two argv entries at launch, and the isolated profile skips a keychain round trip that would otherwise block the main thread.
  • UI quality: not applicable.
  • Security: this makes an isolated profile use Chromium's mock keychain, so anything that profile "encrypts" is not OS-protected. That is the intended trade for a disposable profile handed a temporary HOME, and it is exactly what the sidecar already does for the same profile; a normal profile keeps its real keychain. Stated plainly because it is the one behavioural consequence beyond "it starts".

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Not changed: the inline report on the serve path. It is documented as deliberate and I did not want to reverse a maintainer decision inside a launch-args fix.
  • Not fixed: the general case. A real profile whose login keychain is missing or locked still reaches the same main-thread probe and can still block. This PR removes the keychain for the disposable profile in the report, which is what makes pnpm start:emulator work; making the probe itself non-blocking (or moving it off the main thread) is a separate change and I would want a steer before making it, because it is the timing decision above.
  • I did not run the reproduction myself. The blocking call raises a Keychain authorization UI, and AGENTS.md forbids an agent-launched app from stealing desktop focus, so I could not honestly run it here. What I verified is the missing launch arguments and where they go. @prateek — if you can re-run node scripts/start-emulator.mjs against a build of this branch, that confirms it end to end, and if it still hangs then Chromium is creating the item through a path the mock switch does not cover, which is worth knowing before this goes further.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred) — tc, both affected suites, oxlint and oxfmt pass locally; pnpm lint and build are left to CI

@coderabbitai

coderabbitai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

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: 20ef1fe4-d4c9-4319-b854-6f28d51aead8


📥 Commits

Reviewing files that changed from the base of the PR and between 7b479d2 and 5ba1862.



📒 Files selected for processing (4)
  • src/cli/runtime/launch.test.ts
  • src/cli/runtime/launch.ts
  • src/shared/electron-isolated-profile-switches.test.ts
  • src/shared/electron-isolated-profile-switches.ts


Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.




📝 Walkthrough
📝 Walkthrough

Walkthrough

The changes add shared helpers that detect isolated E2E profiles and select Electron keychain switches. The CLI serve launch appends foreground switches to its Electron arguments. Electron sidecar startup uses switches selected from the process environment. Tests cover helper results and launch arguments for isolated user-data, home-only, and normal profiles.



Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 5ba18

No actionable merge-blocking issue is established. The disposable-profile behavior can proceed through normal checks, with packaged macOS confirmation still pending.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 5 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check Passed Issue #25453 is closed and marked completed. It supplies historical context only. No active directly linked issue supplies coding requirements. The reported changes remain consistent with the historic…
Out of Scope Changes check Passed The changes remain within the stated scope. They add shared switch-selection helpers, use them at the two Electron launch sites, and add focused tests. The HOME-only foreground behavior addresses the …
Title check Passed The title clearly and concisely describes the main change: preventing isolated serve profiles from using the login keychain.
Description check Passed The description includes all required template sections, links issue #25453, explains the user impact and implementation, documents testing and platform considerations, and identifies remaining limita…

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR



  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

paoValle and others added 3 commits October 11, 2026 05:41
The E2E/pairing runtime hands the app a fresh HOME, so there is no login
keychain for OSCrypt to read. On the serve path the secret-protection report
runs inline before readiness and probes safeStorage on the main thread, where
Chromium's keychain lookup creates the item and waits on an authorization
reply that never arrives, so `orca serve` never advertises (#25453).

The sidecar already launches with --use-mock-keychain for exactly this
profile; share that decision and give the foreground serve process the same
switches.
The sidecar always runs on a fresh profile, so either E2E variable is
enough there. The foreground serve process opens the selected profile's
sealed secrets, and a HOME override alone still selects the user's real
profile, so it now needs ORCA_E2E_USER_DATA_DIR.

Co-authored-by: Paolo <[email protected]>
@OrcaWin
OrcaWin force-pushed the OrcaWin/copy-25517-isolated-profile-switches branch from 7b479d2 to 5ba1862 Compare October 11, 2026 12:41
@OrcaWin
OrcaWin merged commit 5d7f48e into main Oct 11, 2026
52 checks passed
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.

[Bug]: orca serve hangs at startup on macOS when HOME is a fresh directory, so mobile start:emulator cannot pair

2 participants