Skip to content

fix(accounts): refresh snapshot by email even when not active#23

Merged
NagyVikt merged 1 commit into
mainfrom
fix/relogin-snapshot-by-email
May 12, 2026
Merged

fix(accounts): refresh snapshot by email even when not active#23
NagyVikt merged 1 commit into
mainfrom
fix/relogin-snapshot-by-email

Conversation

@NagyVikt
Copy link
Copy Markdown
Collaborator

Drops the activeName gate from email-match branches in resolveExistingAccountNameForIncomingSnapshot and resolveRegistryAccountNameForIncomingSnapshot. Re-logging into a non-active account whose canonical email-shaped snapshot exists with mismatched recorded email no longer throws SnapshotEmailMismatchError; the snapshot whose recorded email matches the incoming auth is refreshed in-place.

Previously the relogin path only refreshed a matching-email snapshot when
it was the active one. Re-logging into a non-active account whose
canonical email-shaped snapshot already existed threw
SnapshotEmailMismatchError. Drop the activeName gate so any snapshot
whose recorded email matches the incoming auth email is refreshed
in-place.
@NagyVikt NagyVikt merged commit 3c8add5 into main May 12, 2026
1 check passed
NagyVikt added a commit that referenced this pull request May 13, 2026
…erminal (#24)

restoreSessionSnapshotIfNeeded materialized the auth symlink only after
the session-pin lookups. In a fresh terminal with no pinned session, it
early-returned without materializing, leaving ~/.codex/auth.json as a
symlink into accounts/<name>.json from older installs. The shell hook
then ran `codex login`, which wrote through the symlink and overwrote
the previously-active snapshot in place; syncExternalAuthSnapshotIfNeeded
afterward saw the corrupted file matched the incoming identity and
renamed it, wiping the previous account.

Move the materialize step above all early returns so the symlink is
flattened before `codex login` ever sees auth.json.

Also exclude update-check.json (the npm version cache) from
listAccountNames so it stops appearing as a phantom account in
`codex-auth list`.

Realign the email-shaped-duplicate test with the refresh-by-email
behavior introduced in #23: same-email re-login now refreshes the
canonical snapshot in place with forceOverwrite=true, instead of
spawning a --dup-2 entry.

Co-authored-by: NagyVikt <nagy.viktordp@gmail.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

1 participant