[codex] distinguish ChatGPT accounts by email and plan#66
Conversation
emreertunc
left a comment
There was a problem hiding this comment.
I found one real issue and two minor cleanup points.
Real issue
The duplicate ChatGPT identity rule is only enforced when adding a new account. add_account rejects an existing same email + same plan pair, but later refresh paths can still update an account’s email/plan without checking whether that makes it collide with another stored ChatGPT account. This can happen through token refresh / metadata refresh. If the goal is “same email + same plan must not exist twice”, the invariant needs to be enforced on metadata/token updates too, not only on initial add.
Minor / cleanup
ensure_unique_account_name now applies to all account types, so duplicate API-key account names may be silently renamed to something like Name (account) instead of failing as before. If intentional, fine; if this PR is only about ChatGPT email+plan identity, this is a small scope creep.
Minor / cleanup
The README attribution says this project is based on Lampese/codex-switcher, but this PR targets Lampese/codex-switcher itself. That attribution makes sense in a fork, but looks odd in the upstream repo.
Summary
Root Cause
The storage layer only enforced uniqueness by display name. Same-email accounts with different ChatGPT plans were hard to manage because the UI could present them as the same account, and duplicate display names blocked adding a second account cleanly.
Validation
cargo test --manifest-path src-tauri/Cargo.toml --quietnpm run build