Skip to content

[codex] Fix account removal and token recovery#1

Merged
ademisler merged 1 commit into
mainfrom
codex/fix-account-removal-refresh
May 31, 2026
Merged

[codex] Fix account removal and token recovery#1
ademisler merged 1 commit into
mainfrom
codex/fix-account-removal-refresh

Conversation

@ademisler
Copy link
Copy Markdown
Owner

Summary

Fixes account lifecycle and quota refresh issues across the macOS and Windows apps.

  • Keep accounts keyed by provider account ID before falling back to subject/email matching, so distinct Codex accounts no longer collapse into one row.
  • Persist removed-account identities and filter future managed-home discovery against them, preventing deleted accounts from reappearing.
  • Remove all duplicate managed homes for the same provider account when deleting a managed account.
  • Recover stale refresh-token failures from newer matching auth homes before surfacing a reauthentication error.
  • Decode Plus account credits.balance values when the usage API returns the balance as a string.
  • Skip automatic refresh retries for accounts already known to need reauthentication, while keeping manual refresh/reauth available.

Root Cause

The app rediscovered every managed-homes/*/auth.json on startup, so old duplicate auth homes could recreate accounts after deletion. Some accounts also had stale rotated refresh tokens in older auth homes, and Plus usage responses may return credits.balance as a string, which the Swift decoder previously rejected.

Validation

  • /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -target arm64-apple-macosx14.0 -typecheck $(rg --files Sources/CodexControl -g '*.swift')
  • PYTHONPATH=windows python3 -m compileall -q windows/codexcontrol_windows windows/tests
  • PYTHONPATH=windows python3 unittest harness covering test_codex_api, test_account_manager, test_presentation_logic, and test_models: 16 tests passed
  • Local live check for idemasler1@gmail.com: Plus plan snapshot now writes successfully with primary/secondary quota windows and credits

@ademisler ademisler marked this pull request as ready for review May 31, 2026 19:09
@ademisler ademisler merged commit 54bdae4 into main May 31, 2026
3 checks passed
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