Repository navigation
feat(codex): show system-default/real-home account identity in switcher (PR-B) - #9176
Closed
brennanb2025 wants to merge 2 commits into
Closed
brennanb2025 wants to merge 2 commits into
brennanb2025 wants to merge 2 commits into
Conversation
…er (PR-B)
The account switcher modeled the system-default Codex account as
activeAccountId:null with no identity fields, so the null row rendered
blank ("System default" / generic subtitle) even though its effective
login is whatever ~/.codex/auth.json currently is.
Add a CodexSystemDefaultIdentity descriptor {hasAuth, authKind, email,
providerAccountId, workspaceLabel} to CodexRateLimitAccountsState,
resolved live and READ-ONLY from ~/.codex by the accounts service and
returned from listAccounts()/getSnapshot(). The settings switcher now
renders the null (system-default) row as that real identity: the OAuth
email when signed in, "Custom provider — no usage tracked." for
env-key/custom-provider logins (auth.json with OPENAI_API_KEY, or an
OPENAI_API_KEY env with no auth.json), and the generic fallback when
signed out. Identity is host-scoped (per-distro WSL keeps the generic
label). Orca never writes ~/.codex; managed-account switches only touch
Orca-owned homes, so the system-default identity stays a stable,
displayed source of truth. Usage already routes to the real home via
getSystemCodexHomePath, so the switcher now attributes it to a real face.
Tests (sandboxed temp homes only): OAuth email/provider resolution,
api-key auth.json and env-key (no auth.json) as custom-provider,
signed-out, and select/deselect of a managed account never mutating
~/.codex/auth.json.
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 & why
The account switcher modeled the system-default Codex account as
activeAccountId:nullwith no identity fields (src/shared/types.ts). Under real-home routing the null account's effective identity is "whatever~/.codex/auth.jsoncurrently is," but it rendered blank ("System default" + a generic subtitle), and managed-account switches never touch~/.codexso it couldn't track or display a stable identity. Env-key/custom-provider logins (no ChatGPT usage) also had nothing to render.This PR surfaces a real, live, read-only identity for the system-default / real-home account and renders
activeAccountId:nullas that identity.Changes
src/shared/types.ts— newCodexSystemDefaultIdentitydescriptor{ hasAuth, authKind: 'oauth' | 'api-key' | 'none', email, providerAccountId, workspaceLabel }, added as optionalsystemDefaultonCodexRateLimitAccountsState(optional so WSL/remote/empty states are unaffected).src/main/codex-accounts/service.ts—getSnapshot()(returned bylistAccounts()) now resolves the descriptor live and READ-ONLY from~/.codex/auth.json. OAuth → email/provider; auth.json withOPENAI_API_KEY(or anOPENAI_API_KEYenv with no auth.json) →api-key; no auth.json →none. Reuses the existing JWT/identity parsing via extractedextractOAuthCredentials/resolveIdentityFromCredentials(no behavior change to managed add/re-auth). It flows unchanged through IPC and the remotegetAccountsSnapshot()RPC, so each runtime reports its own host's~/.codex.AccountsPane.tsx) — the system-default row subtitle now shows the OAuth email when signed in, "Custom provider — no usage tracked." for env-key/custom-provider, or the generic fallback when signed out. Host-scoped (per-distro WSL keeps the generic label).Attribution & the fetcher (deliberately not changed)
Usage for the null account already routes to the real home via
prepareForRateLimitFetch → getSystemCodexHomePath()(unchanged), so the switcher now attributes it to a real, displayed identity. The env-key (no auth.json) case is already reported cleanly asstatus: 'unavailable'(no usage) by the existing presence gate (codex-auth-presence.ts). I prototyped anapi-keyshort-circuit incodex-fetcher.tsbut reverted it: it added anauth.jsonread + parse to every poll on the hot path for all users (OAuth included) to catch a rare case, and perturbed fake-timer RPC/PTY tests that read the real~/.codex. The clean "custom provider / no usage" rendering is fully delivered by the descriptor-driven switcher instead. Happy to add a fetcher-side relabel as a follow-up if the status-bar (separate surface) api-key-auth.json edge is in scope.Guardrails
~/.codex— the identity read is read-only; a dedicated test asserts select/deselect of a managed account leaves~/.codex/auth.jsonbyte-identical.~/.codex, so the displayed identity matches. Noruntime-home-service/flag code touched.max-linesdisables added (ratchet check passes). Localization catalog synced (sync:localization-catalog) across all 5 locales. Follows AGENTS.md / STYLEGUIDE.md.Test evidence
Sandboxed temp homes only (
homedir()mocked):src/main/codex-accounts/service.test.ts(+5): OAuth email/provider resolution; api-key auth.json → custom provider; envOPENAI_API_KEY(no auth.json) → custom provider; signed-out →none; select/deselect never mutates~/.codex.service.test.ts,codex-fetcher*.test.ts,rate-limits/service.test.ts,provider-account-visibility.test.ts,codex-account-auth-warning.test.ts,status-bar-runtime-groups.test.ts,runtime-provider-accounts-client.test.ts(114 passed).pnpm run typecheck:node✅ andpnpm run typecheck:web✅.oxlintclean; max-lines ratchet OK; localization verify OK.Addresses matrix rows 2, 3, 4, 5.