Repository navigation
feat(codex): opt-in to use default ~/.codex config dir (fixes auth revocation war, supersedes #5594) - #6577
feat(codex): opt-in to use default ~/.codex config dir (fixes auth revocation war, supersedes #5594)#6577nwparker wants to merge 2 commits into
Conversation
… revocation war Fixes #5370. Orca injects a private managed CODEX_HOME into Codex processes. For a single OpenAI/ChatGPT account, OAuth enforces one active session, so two independently refreshing homes (Orca's managed home and the user's ~/.codex) revoke each other's single-use refresh tokens — silently breaking non-Orca Codex usage. The refresh is driven both by interactive Codex and by Orca's BACKGROUND quota poller, which spawns the real codex binary against the managed home. Adds an opt-in "Use default Codex config directory" setting (Settings > Accounts > Codex). When enabled: - PTY launches inject no CODEX_HOME (all three buildPtyHostEnv sites OR in isCodexDefaultHomeEnabled), so terminals resolve ~/.codex. - The background quota poller and host Codex launches resolve the system ~/.codex home instead of spawning codex against the managed home — closing the revocation gap that persisted even after the ~/.zshenv workaround. Supersedes community PR #5594: re-derives the locale changes (drops the out-of-scope "Create PR" status-message block, keeps only the new Codex keys), closes the background-revocation gap left unaddressed by the original PR, and sharpens the setting description to state it also disables the managed-home quota refresh. Co-authored-by: Eilon Goldberg <[email protected]>
|
Warning Review limit reached
Next review available in: 12 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (21)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
EvidenceUnit / regression testsNew tests (verbose, all passing):
Also green: Live Electron validation (CDP, dev build of this branch)Attached to the running dev instance of
Before (off — default): the switch renders unfilled in the Codex section; Orca keeps its managed After (on): the switch renders filled/enabled;
Before/after reasoning
|
Update: default-home tradeoff narrowedPushed
Tradeoff status: not fully zero for host. Preserving host hot-swap while using the real Validation:
|
Follow-up audit: host default-home contractDid one more pass on whether host managed switching/previews can safely stay available while default-home mode is enabled. Conclusion: host default-home and host managed hot-swap are logically mutually exclusive unless Orca takes ownership of the user's real Why:
No code change from this pass. I updated the PR body to frame the behavior as an explicit opt-in mode contract: when enabled, host Codex uses the system |
|
Closing as superseded after checking current Superseded by merged #9501 and the WSL direct-home cutover in #16854. System-default Codex launches now use the real system home without injecting a managed CODEX_HOME, while managed accounts retain their separate homes. This older opt-in toggle achieves the earlier goal by disabling account controls that the shipped routing now preserves. Closing this PR only; its branch is being retained. |
🧑🤝🧑 Impact & ELI5
1) What's broken today (ELI5). If you use the OpenAI Codex CLI both inside Orca and outside Orca (in a plain terminal, a scheduled job, or another tool) with the same single ChatGPT/OpenAI account, your Codex login silently breaks. OpenAI only allows one active login per account, but Orca quietly keeps its own private Codex login in a separate hidden folder. So Orca and your normal
~/.codexlogin keep kicking each other out — like two phones signed into the same account where each one logs the other off the moment it checks in. The nasty part: Codex still says "Logged in," so you can't tell anything is wrong until a command suddenly fails with "token revoked." This hits the (relatively niche) group of power users who run Codex in multiple places on one account, but for them it's a real blocker — background/scheduled Codex jobs fail intermittently and it's extremely hard to diagnose. A previous~/.zshenvworkaround helped terminals but Orca's always-running background checker kept re-triggering the fight.2) What this PR does (ELI5). It adds a new opt-in toggle — Settings → Accounts → Codex → "Use default Codex config directory". Flip it on and Orca stops keeping its own separate Codex login; instead it uses your normal
~/.codexlogin, the same one your terminal and other tools use. Crucially, it also tells Orca's background "how much quota do I have left?" checker to stop poking the private login folder, since that background checker was the thing secretly re-igniting the fight even after the manual workaround. Oh, so Orca now shares your one real Codex login instead of secretly maintaining a rival second one that logs you out.3) Opt-in mode contract — honest answer. The toggle is OFF by default, so nobody's current behavior changes unless they choose to enable it. When it is on, host Codex has exactly one source of truth: the user's system
~/.codex. In that mode Orca intentionally does not own, switch, re-authenticate, or preview separate host managed Codex homes; stale host add/select/re-auth calls are rejected so no hidden path can spawn Codex against a rival host home. This is the contract of default-home mode, not an unfinished host hot-swap implementation. Turn the toggle off to use Orca's host managed multi-account switching again. WSL managed Codex accounts still work and keep their own managed homes. SSH/remote paths are untouched, and for everyone who leaves the toggle off this PR is a no-op.Summary
Fixes #5370Orca injects a private managed
CODEX_HOME(~/Library/Application Support/orca/codex-runtime-home/home) into Codex processes. For a single OpenAI/ChatGPT account, OAuth enforces one active session, so two independently-refreshing homes (Orca's managed home and the user's real~/.codex) revoke each other's single-use refresh tokens — silently breaking non-Orca Codex usage. The refresh is driven not only by interactive Codex but by Orca's background quota poller, which spawns the realcodexbinary against the managed home; that daemon-side session is why the issue persists even after the~/.zshenvworkaround.This adds an opt-in "Use default Codex config directory" setting under Settings > Accounts > Codex. When enabled, Codex launched inside Orca resolves the user's system
~/.codexinstead of Orca's managed home:buildPtyHostEnvcall sites OR inisCodexDefaultHomeEnabled, soskipCodexHomeEnvstripsCODEX_HOME/ORCA_CODEX_HOME.prepareForRateLimitFetchand the host branch ofprepareForCodexLaunchreturnnullwhen the setting is on.nullmakes the rate-limit fetcher resolve~/.codexand tells the commit-message agent to inject noCODEX_HOME, and it skips the managed-home sync so Orca never spawns Codex against the managed home to drive a token refresh.Default is off, preserving today's managed-home behavior and Codex account switching. When enabled, host default-home mode is an explicit auth-source contract: host Codex uses
~/.codexonly, and Orca does not switch or refresh separate host managed homes. WSL managed accounts stay managed.Supersedes community PR #5594
This takes over #5594 (does not close it; original author credited via
Co-authored-by). Changes made on top of the original PR:main— dropped the entire out-of-scope "Create PR" status-message block (and the malformedh3i4j5k607key) that feat(codex): opt-in setting to use your default ~/.codex config directory #5594 introduced into en/es/ja/ko/zh. Kept only the new Codex keys + accounts-search keys, then ranpnpm run sync:localization-catalogso all five locales stay at parity. No merge conflict and no reintroduction of already-present keys.prepareForRateLimitFetch/ hostprepareForCodexLaunch), and added a test for it.Screenshots
~/.codex, background poller stops touching the managed homeBefore/after screenshots and unit-test output are attached as a PR comment (validated live over CDP in the running dev app — see comment).
Testing
pnpm lint(oxlint, scoped to changed files — clean)pnpm typecheck(tsconfig.node.json+tsconfig.tc.web.json+tsconfig.tc.cli.json— clean)pnpm test(ransrc/main/ipc/pty.test.tsandsrc/main/codex-accounts/runtime-home-service.test.ts— 265 passing incl. 3 new; plus rate-limits/codex-accounts service + text-generation suites — 112 passing)pnpm build(not run; no build-affecting changes — type/lint clean)verify-localization-catalog.mjspasses with no diff).aria-checkedflips andcodexUseDefaultConfigDirpersists to the store and to disk (verified viafetchSettingsIPC round-trip). No render crash.AI Review Report
Reviewed the diff adversarially (treating the adopted PR author as untrusted) for correctness, edge cases, cross-platform behavior, security, and scope.
e.metaKey/ path-separator assumptions added. The PTY change ORs a boolean ahead of the existing WSL/Windows-shell conditions, preserving prior behavior when off. WSL rate-limit/launch paths return before the new host gate, so WSL homes are untouched.nullreturns flow correctly throughgetCompatibleSelectedCodexHomePath(null→null), the rate-limit fetcher (getCodexHomePath→~/.codex), and the commit-message agent (noCODEX_HOMEinjected).CODEX_HOMEinjection only happens for local + daemon-host terminals (buildPtyHostEnvis not on the SSH spawn path); remote shells use the remote machine's own~/.codex. So the revocation war is inherently a local-machine problem and the fix is correctly scoped there — the description does not over-claim SSH coverage.Security Audit
null/strips env. Noeval, no newspawn/exec, no network calls, no new dependencies, no path traversal, no secret reads added.~/.codexOAuth session.0o600by existing code paths (unchanged).Default-home mode contract
Follow-up audit for zero-tradeoff alternatives:
~/.codexas a managed account can only represent the account currently logged in there. Switching to any other host account still requires either settingCODEX_HOMEaway from~/.codexor overwriting~/.codex/auth.jsonwith another account's tokens.~/.codexidentity, but it cannot make Codex run as a different host account while Codex is still reading~/.codex.So the safe contract is: default-home mode means host Codex uses the system
~/.codexidentity only. Host managed switching/previews resume when the toggle is off. WSL managed account switching remains available because WSL uses separate WSL runtime homes rather than the host~/.codex.Made with Orca 🐋