Files
magpie/docs
yetone 3d0d790606 codex: the Codex app left on an account that runs out is restarted onto the one Codex is signed in to (nb5p on Discord)
nb5p has two ChatGPT accounts in magpie, B first. The Codex app showed A,
and once A ran out Send was grey for every model, magpie's and another
provider's too.

Cause: magpie's switch back to the first account (or to the account
Codex is kept signed in to) leaves the Codex app's app-server running
unless "Restart the Codex app to follow" is on. The app-server keeps the
account it started on (CodexAppStale), so the app stayed on A while
auth.json said B. magpie read only B, which had room, so nothing moved,
magpie never took over, and the app-server was never restarted: the app
greyed Send on A's allowed false for good.

Fix: on each full look of KeepOnAnAccountWithRoom,
restartCodexAppLeftOnSpent reads the account the app is left on, and
once that is held (codexHeld) marks a spent switch (codexAppSwitched
true), which codexAppStep restarts past the RestartApp tick, as a switch
off a used-up account already does. Once per app-server left.

Run (mote, at this tree):
- go test ./internal/provider -count=1: ok
- TestCodexAppLeftOnASpentAccountIsRestarted: user switches to A, magpie
  switches back to B and leaves the app running, A still has room
  (nothing ended), A runs out with B's room (app-server 7 ended), next
  look (not ended again).
Broken by hand:
- codexAppSwitched(true, false) commented out: red, "ended [], want the
  app-server left on the used-up account".
- the once-per-app-server check off: red, "restarted again: [7]".
Not tried: the real Codex app on a real account running out; the call
in KeepOnAnAccountWithRoom's loop is covered by reading, not by a test.
2026-11-05 07:51:09 +08:00
..