Skip to content

fix(accounts): preserve saved snapshots on codex login from a fresh terminal#24

Merged
NagyVikt merged 1 commit into
mainfrom
fix/preserve-snapshots-on-fresh-login
May 13, 2026
Merged

fix(accounts): preserve saved snapshots on codex login from a fresh terminal#24
NagyVikt merged 1 commit into
mainfrom
fix/preserve-snapshots-on-fresh-login

Conversation

@NagyVikt
Copy link
Copy Markdown
Collaborator

Summary

  • Move materializeAuthSymlink above the early returns in restoreSessionSnapshotIfNeeded so a stale ~/.codex/auth.json symlink (from older installs) is flattened before codex login runs. Previously, in a fresh terminal with no pinned session, the function returned early and codex login wrote through the symlink, overwriting the previously-active saved snapshot — the next codex-auth list showed only the freshly-logged-in account.
  • Exclude update-check.json (npm version cache) from listAccountNames so it no longer appears as a phantom "account".
  • Realign the email-shaped-duplicate test with the refresh-by-email behavior introduced in fix(accounts): refresh snapshot by email even when not active #23.

Test plan

  • npm run build
  • npm test — 76/76 pass (was 75/76 on main; the --dup-2 test was outdated since fix(accounts): refresh snapshot by email even when not active #23)
  • New regression test: symlinked auth.json + no session pin → restore-session converts to regular file; subsequent overwrite of auth.json leaves the previous snapshot intact
  • New test: update-check.json in accounts dir is excluded from listAccountNames

🤖 Generated with Claude Code

…erminal

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: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@NagyVikt NagyVikt merged commit d82a006 into main May 13, 2026
1 check passed
@NagyVikt NagyVikt deleted the fix/preserve-snapshots-on-fresh-login branch May 13, 2026 18:31
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