Skip to content

Reload auth storage after Codex account switch - #1

Open
S2P2 wants to merge 1 commit into
fadilsflow:mainfrom
S2P2:reload-auth-storage-on-switch
Open

Reload auth storage after Codex account switch#1
S2P2 wants to merge 1 commit into
fadilsflow:mainfrom
S2P2:reload-auth-storage-on-switch

Conversation

@S2P2

@S2P2 S2P2 commented Jul 8, 2026

Copy link
Copy Markdown

Summary

  • reload pi's in-memory auth storage after swapping auth.json during /codex switch
  • refresh the model registry before ctx.reload() so the current process picks up the switched Codex account

Why

ctx.reload() reloads extensions/resources, but pi keeps auth.json cached in AuthStorage. Without reloading that cache, the process can keep using the previous Codex credential until pi fully exits and starts again.

Testing

  • bun run typecheck
  • bun test

Summary by CodeRabbit

  • Bug Fixes
    • Improved the credential-switching experience so the app refreshes immediately after changing the active Codex credential.
    • Fixed an issue where the app could keep using stale authentication state after a switch, causing reloads to feel incomplete.

@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 30865d2b-35c0-4ea1-9974-7ff23fb11ef2

📥 Commits

Reviewing files that changed from the base of the PR and between 35b77b8 and 623cf86.

📒 Files selected for processing (1)
  • src/index.ts

📝 Walkthrough

Walkthrough

The doSwitch function in src/index.ts was modified to reload credentials via ctx.modelRegistry.authStorage.reload() and ctx.modelRegistry.refresh() instead of calling ctx.reload(), ensuring the swapped Codex credential is picked up in-memory.

Changes

Credential Reload Fix

Layer / File(s) Summary
Targeted registry reload in switch flow
src/index.ts
doSwitch now reloads auth storage and refreshes the model registry directly instead of relying on ctx.reload(), while retaining the notification to the user.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Poem

A rabbit hopped through switched-out keys,
No full reload, just what it sees—
Auth storage refreshed, registry too,
Credentials swapped, clean and true.
Hop, hop, done. 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely matches the main change: reloading auth storage after a Codex account switch.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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