Repository navigation
fix(serve): keep the isolated profile off the login keychain - #27463
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to 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 |
|
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.
Co-authored-by: Paolo <[email protected]>
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]>
7b479d2 to
5ba1862
Compare
This is a copy of #25517 by @paoValle, rebased on current
mainso CI can run here. The contributor's commit is kept unchanged, with their authorship. One follow-up commit removes the two newas string[]casts inlaunch.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_DIRoverride 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 requireORCA_E2E_USER_DATA_DIR, and a launch test covers the HOME-only case.Co-authored-by: Paolo [email protected]
Author: @paolovalletta_
ELI5
pnpm start:emulatorruns Orca with a throwawayHOMEso 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:
…with the main thread parked in
SecItemAdd→AuthorizationCopyRights, andmain-thread-hang.jsonwritten 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 callsreportSecretProtectionGap()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 issafeStorage.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.tslaunches its sidecar with['--password-store=basic', '--use-mock-keychain']wheneverORCA_E2E_USER_DATA_DIR || ORCA_E2E_HOME_DIRis set, andelectron-serve-browser-process.test.tspins 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.tsand uses it at both launch sites.Why
--use-mock-keychainremoves the keychain from the process, which is why the sidecar uses it.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.Linked Issue
Fixes #25453
Visual Proof
N/A— no user-interface change. The observable difference is that the foreground serve process starts advertising.Testing
electron-isolated-profile-switches.test.ts(new) — either env half, neither, and a bareHOMEoverridecli/runtime/launch.test.ts— an isolated profile's serve args carry both switches; a normal profile's carry neitherchildArgs.push(...)removed- "--use-mock-keychain", so it cannot pass by constructionmain/orcad/electron-serve-browser-process.test.ts(the sidecar's pinned args, after the refactor)pnpm test src/cli/pnpm test src/main/orcad/pnpm tc(node + cli + web)oxlint+oxfmton the five files (pre-commit)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(provideropencode-go). All commands and results above were produced on this machine.Review
--use-mock-keychainis a macOS switch and--password-storea Linux one; the sidecar already passed both unconditionally for this profile, which is the behaviour this mirrors.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
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
pnpm start:emulatorwork; 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.AGENTS.mdforbids 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-runnode scripts/start-emulator.mjsagainst 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
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred) —tc, both affected suites,oxlintandoxfmtpass locally;pnpm lintandbuildare left to CI