Commit Graph
1 Commits
Author SHA1 Message Date
yetone e90a635a9a provider: a Codex account held in another Codex folder offers Sign in again when its refresh is refused (charliepu)
charliepu on Discord (#general 1566029465107173518, Windows): a ChatGPT
account whose sign-in had lapsed had no button to sign in again in the
Providers editor. The account was one Codex keeps in another of its
folders (CODEX_HOME=C:\Users\...\.codex-db-backup-...). OpenAI refused
its refresh, but renewSaved only wrapped the refusal in "run CODEX_HOME=...
codex login", and codexSignInRead skipped marking it: a saved account's
refused refresh is marked by savedRefreshFailed, which never runs for a
folder-held one. So the row never got a lapse, and the GUI's Sign in
again (renderAccounts' signedOut, SIGN_IN_GONE) never showed.

- logins_on.go: renewSaved wraps such a refusal as codexHeldRefusal and
  names no command to run.
- login_usage.go: codexSignInRead marks a codexHeldRefusal signed out
  (markRevoked), as it does Codex's own, so the row reads "Sign-in
  required" with Sign in again, which runs magpie's Codex sign-in for
  that user (startSignIn), the flow every other revoked Codex account uses.
- signin.go: addLogin writes the new tokens back to the Codex folder that
  holds the account (codexHeldFolder, saveCodexLogin) and clears its gone
  mark, or the next look would read the dead tokens back over them.
  ~/.codex/auth.json is not touched.
- account.go: codexRefresh's failure says "sign in to this account again",
  not "run codex login".
- chatgpt_api.go (sibling): a ChatGPT API account's kept lapse is listed
  on its row too, so it gets the same Sign in again.

No GUI change: the row already shows Sign in again for a Codex lapse
(revoked-signin-account.test.cjs covers it); the backend never set one.

Run at origin/main 4f00a32ff plus this change; rebased after onto
8680ffa41, which touches internal/gateway only (not run again):
- mote: go test -timeout 45m -count=1 ./internal/provider: ok (114s)
- mote: GOOS=windows and GOOS=linux go vet ./internal/provider: ok
- gofmt -l internal/provider: empty
At the earlier base 0379f2610 (mote rebooted mid-run, so the rest went
to the WSL box magpie-desktop):
- WSL: go vet ./internal/provider (linux, windows, darwin): ok
- WSL: go test ./internal/provider ./internal/gateway: ok (gateway 488s);
  ./internal/gui doesn't build there (no webkitgtk-6.0 dev package)
- mote: go test ./internal/gui: two reds, both filed and untouched
  here: TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and
  TestMainWindowCorners/macOS_26_SDK on macOS 27 (#3949)
- WSL, Playwright 1.62.0, Chromium and WebKit, every language, 420 and
  1100 wide: revoked-signin-account and codex-signout pass; i18n-keys
  passes except "a plugin's words are its own", the known red #4524
  (plugins/routing "Unmarked")

Broken by hand, each red with the new tests:
- codexSignInRead without the codexHeldRefusal exception:
  TestCodexHeldInOtherFolderSignedOutThenSignedInAgain fails "the row
  isn't signed out, so it has no Sign in again".
- addLogin with held = "": the same test fails "the new sign-in didn't
  reach the account's Codex folder".
- siwcLoginList without the saved lapse: TestSIWCLapsedListedOnItsRow fails.

Not tried: a real lapsed account, on Windows or anywhere (the refusal is
a fake token endpoint answering 400 invalid_grant); a real OpenAI
sign-in written back into a CODEX_HOME folder; the full ./... suite.
Not changed: codexTokenAsKept and codexTokenRenewing still say "run codex
login" when a folder has no access token at all (Codex itself signed out,
not a refused refresh).
2026-10-31 19:26:55 +08:00