Repository navigation
fix(codex): persist outgoing managed tokens before real-home lane takeover (PR-C) - #9175
Closed
brennanb2025 wants to merge 2 commits into
Closed
brennanb2025 wants to merge 2 commits into
brennanb2025 wants to merge 2 commits into
Conversation
…eover (PR-C) prepareForCodexLaunch returns null early for the real-home / system-default lane before syncForCurrentSelection runs. If a managed account is still recorded as synced when the selection has dropped to the system default (nulled without a sync pass, or auto-deselect on missing managed auth), a Codex-refreshed token stranded in the shared runtime home is never persisted to its canonical per-account home -> token loss. Read the outgoing managed account's refreshed token back before the real home takes over. The real-home lane implies host === null, so running the managed->system-default transition restores only Orca's runtime mirror from ~/.codex and never writes the real ~/.codex. It is a no-op once the selection has already been reconciled, so the normal select path does not double-write.
Contributor
Author
|
Closing as superseded: #9501 (real-home routing + self-contained multi-account homes) explicitly lists this draft as superseded in its description, and that consolidation merged and shipped in v1.4.149 stable. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Guarantees the outgoing managed Codex account's refreshed OAuth token is read back (persisted to its canonical per-account home) before the real-home / system-default lane takes over the shared runtime home — on the launch path, not only on the explicit select path. Closes GAP-6 in the real-home consolidation work.
Why
prepareForCodexLaunch(runtime-home-service.ts) returnsnullearly for the real-home lane, beforesyncForCurrentSelectionruns. The outgoing managed account's refreshed-token read-back normally happens insidedoSelectAccount → syncForCurrentSelection. Any path that drops the selection to the system default without going throughsyncForCurrentSelection— e.g. the selection nulled out-of-band, or the auto-deselect when an active managed account'sauth.jsongoes missing — hands off to the real-home lane while a freshly Codex-refreshed token sits unpersisted in the shared runtime home. On the next real-home launch that token is silently dropped → token loss.Change
readBackOutgoingManagedHostAccountBeforeSystemDefault()runs the managed→system-default transition (viasyncForCurrentSelection) when a managed account is still recorded as synced (lastSyncedAccountId !== null), and is invoked right before the real-home lane's earlyreturn null.host === null, so this restores only Orca's runtime mirror from~/.codex— it never writes the real~/.codex(lastSyncedAccountId !== nullroutes to the snapshot-restore branch, never thewriteSystemDefaultAuthpath).Test evidence
npx vitest run --config config/vitest.config.ts src/main/codex-accounts/runtime-home-service.test.ts→ 89 passed (86 existing + 3 new).pnpm run typecheck:node→ clean.New tests (all sandboxed — never touch the real
~/.codex):syncForCurrentSelectionis not called again) → no double-write / no regression.Guardrails
~/.codex(asserted; restore path only reads it and writes Orca's runtime mirror).max-linesdisables; follows AGENTS.md / CLAUDE.md.Matrix rows covered
auth.jsonmissing) → system-default handoff, outgoing refresh preserved.