Commit Graph
2 Commits
Author SHA1 Message Date
yetone c3e673b061 codex: the account Codex is signed in to goes by the name it is saved under, so two Team seats of one email are weighed apart (#1424, lingqiqi5211)
One email in two Team workspaces is saved as "me@example.com · Team" and
"me@example.com · Team · <workspace>" (codexName). codexAccount still named
the account Codex is on by codexUser alone, "me@example.com · Team". With
Codex signed in to the second seat, its candidate used the second seat's
credentials under the first seat's name. Everything keyed on Account.User
then read the first seat's records: Smart's allowance (98% used, so the
seat with 2% left was ranked last), rests and sticks (restKey/who), the
usage cap, per-account proxy and model list, a gateway key's account list
(LoginID), OwnPaused, and the Routing page's name.

- codexLiveName (logins.go): codexName over the saved logins, shared by
  liveLogin and codexAccount, so the provider's Account.User is the saved
  name.
- SessionIdentities: a saved Codex identity goes by its saved name, and the
  one from auth.json by that of the saved one of its workspace and member,
  so a session of the second seat is told as that seat's.
- providers-accounts.md: the Codex naming rule.

Stored records: nothing keyed under a name that goes away. The first seat
keeps "email · Team"; the second seat's rests, caps, proxy, model list and
usage are already under its saved name, written while it wasn't the one in
use. Records written under the first seat's name while the second was in
use can't be told apart now. Rests run out and readings are read again, so
none is migrated.

Tests: TestCodexTeamSeatsOfOneEmailWeighedApart (gateway): Team A 98%,
Team B (Codex on it) 2% with its week renewing first, another email 20%.
On the old code it fails with "sent to ws-other; want the seat Codex is on"
(and, with its name check, "goes by \"me@example.com · Team\""). With
session_identity.go reverted, TestCodexWorkspaceSessionIdentities (provider)
fails with "the seat Codex is on: [me@example.com · Team]".

Run: gofmt -l (clean); go vet, GOOS=linux and GOOS=windows go vet -tags
nogui on provider, gateway, usage; go build -tags nogui ./... on darwin,
linux, windows; go test -tags nogui ./internal/provider ./internal/gateway
./internal/usage under a temp HOME with pinned caches: all ok. Not tried
with real accounts: no two Team seats of one email are available here.
2026-10-09 23:16:53 +08:00
yetone c13f3bfb7a provider: two Codex accounts of one email in two Team workspaces each go by a name of their own, so removing or refreshing one never touches the other (vincentzhang on Discord)
Removing one Codex account, or running codex logout on one, had the other ask to be signed in again. Two seats of one email in two Team workspaces are both named "email · Team" (codexUser), and while sameLogin tells them apart by workspace, everything after went by the name. ForgetLogin of the one not in use matched the one Codex is signed in to as well: it looked like the last account, so ~/.codex/auth.json was deleted (since 43a65950) and both were dropped from logins.json. A refresh of one (renewSavedLogin) was written over the other's credentials too, and switching picked whichever came last. Codex logout revokes the sign-in it holds; the other record then held those revoked tokens.

codexName gives a Codex account a name no other account has: codexUser's, or when another account already has that, the name with the first 8 characters of its workspace id (" · ws-two"). An account keeps that name once it has one. It is used when an account is saved (upsertLogin, addLogin) and when Codex's own sign-in is read (liveLogin). readLogins renames accounts already saved under one name (nameAlike), the first keeping it, so a user who has them gets them apart without signing in again. magpie never revokes a Codex token: Sign out and remove only delete auth.json and logins.json entries.

TestCodexWorkspacesOfOneEmail (two seats saved, one in use: distinct names, one active, a refresh of the other leaves the active one's credentials, removing the other keeps auth.json) and TestCodexWorkspacesSavedAlike (a logins.json with both already under one name) are new. Both fail without the change, with the two seats under one name. go vet, go build (darwin, GOOS=linux nogui, GOOS=windows) and go test -tags nogui ./... under a temp HOME pass. TestDevinSignedInOnlyInMagpie hit its 3s timeout once under the full run's load; it passes alone and in a rerun of the package.
2026-10-05 22:51:06 +08:00