v0.1.2826 (1dead5dc7) added Restart the Codex app when magpie switches
its account, off by default, so that atom0964's ChatGPT app stopped
relaunching at every switch magpie made between two Plus accounts. Its
guard in codexAppStep left the app-server running for every change
magpie made by itself, and that covered too much:
- the takeover in, where magpie becomes Codex's provider for its used-up
account;
- the first look on a used-up account;
- magpie's switch off an account at 98% (SwitchWhenSpent).
The Codex app greys Send for every model while its signed-in account's
rate limit says not allowed, and reads the account only as its
app-server starts (ChatGPT.app 26.1013, 8b0132b3d). Left running, the
app stayed on the used-up account with Send grey, so neither magpie's
fallback nor the next account could serve it until the user restarted
it by hand. With the default off, that broke the takeover for every
user with a fallback.
Now those three restart the app-server tick or not (`needed` in
codexAppStep: `into || c.switched && c.spent`). The tick covers only
what the app works without: the switch back once the first account has
room, and Codex given its account back at the reset. The label, tooltip
and toasts say "switches its account back" in en, zh, zh-TW, ja and de.
The tooltip adds that a used-up account restarts the app anyway.
SwitchWhenSpent's stale-app log, RestartApp's comment and
agent-wiring.md say the same.
atom0964 will still see one restart when an account runs out. Send
needs it. The restarts at the switch back and at the reset are gone.
Run at the pushed head (on mote, rebased on c0d4f17a3):
- gofmt -l clean; GOOS=linux (-tags nogui) and GOOS=windows go vet of
provider and gui clean.
- go test -count=1 -timeout 45m ./internal/provider ./internal/davsync
./internal/backup: ok. ./internal/gui -run "Budget|I18n|Restart": ok
(the core script budget holds with the longer strings, no raise).
- GUI (chromium + webkit, narrow and wide, en/zh/ja/de): restart-app,
switch-only, i18n-keys, codex-accounts-via: 76/76.
Broken by hand: codexAppStep's guard without `!needed`:
TestCodexAppLeftRunningForMagpiesOwnChanges ("magpie switched off the
used-up account: ended [], want [60]") and
TestCodexAppFirstLookOnAUsedUpAccountRestarts go red.
Not tried: a real ChatGPT desktop app on a real used-up account (the
app-server end is stubbed); Windows, where an end is followed by
CodexAppReopen.
atom0964 on Discord (#help) has two ChatGPT Plus accounts in magpie, with
Codex always signed in to the first and Only switch Codex's sign-in both
off, on Smart routing. The Codex desktop app kept restarting by itself.
They tried several combinations of the ticks and it still did.
Why: with both off, SwitchWhenSpent signs Codex in to the next account at
98% and back to the first below 90%. Each switch was noted for the Codex
app (codexAppSpentSwitch), and KeepCodexAppOnItsProvider ended its
app-server once no turn ran; the ChatGPT app shows that as an error and
relaunches (#4550). With Codex kept on the first account there is no
switch, but the used-up takeover (magpie made Codex's provider for a
used-up account and given back once it has room; f37742e14 only limits
it to when another account can serve, which two accounts always can)
changed Codex's route, and that ended it too. So every combination
restarted the app.
What changed:
- Provider.RestartApp (restartApp), off by default, set by
provider/restartapp (SetRestartApp, Codex only). This computer's own,
like KeepLogin: Mirror keeps it and davsync's hash leaves it out.
- switchLoginBy(agent, user, byMagpie): SwitchWhenSpent marks its
switch magpie's own (codexApp.auto). In codexAppStep, a change that is
magpie's own (its switch, the takeover in or out, the first look at an
app on a used-up account) ends nothing unless RestartApp is on; it
logs why and the app follows once restarted. The switch notice's
Restart, the Agents row's Restart, and uninstall are unchanged.
- Still restarted: a switch the user makes (Switch, the Agents row, the
CLI), a Connect or Disconnect, failover written or taken out (any
route change while the takeover state is unchanged), and a user's
switch pending when magpie's comes.
- GUI: under Codex's accounts, with more than one on (or the tick set),
"Restart the Codex app when magpie switches its account", with a tip
and toasts in en, zh, zh-TW, ja and de. app.js paid for it with five
account-row comments cut; TestCoreScriptBudget is not raised.
- docs/subsystems/agent-wiring.md says which changes restart the app.
Known edge: a takeover flip in the same 3s tick as a Connect is taken
as the Connect's (restarted), since the route changed by the user.
Run at the pushed head (on mote, rebased on b967b1620; then rebased on 2a19043af, a Library change touching none of these files, with the core budget checked again: 160 bytes under):
- gofmt -l clean; GOOS=linux (-tags nogui) and GOOS=windows go vet of
provider, gui, davsync clean.
- go test -count=1 -timeout 45m ./internal/provider ./internal/davsync
./internal/backup: ok. ./internal/gui: ok except
TestMainWindowCorners/macOS_26_SDK, red alone on origin/main 694f4a6d6
too (#3949). ./internal/cli: ok except TestEveryRouteHasACommandOrIsNamed
on GET /api/context/reply (#5026).
- GUI (chromium + webkit, 1100 and 420 wide, en/zh/ja/de):
restart-app (new), switch-only, claude-switch-only, keep-login,
codex-accounts-via, account-arrange, i18n-keys: 110/110 and 94/94.
account-arrange's webkit case went red once in a 5-file run on an
aborted /api/lanes request; it passes alone on origin/main and at
this head.
Broken by hand:
- codexAppStep's guard turned off: TestCodexAppLeftRunningForMagpiesOwnChanges
and TestCodexAppFirstLookLeftRunning go red (ended [60]).
- SwitchWhenSpent marking its switch as the user's: TestCodexSwitchedWhenUsedUp
goes red ("magpie's own switch is counted the user's").
Not tried: a real ChatGPT desktop app on a real used-up account (the
app-server end is stubbed as before); Windows, where the app is quit and
reopened (CodexAppReopen runs only after an end, so leaving it running
skips it too); no CLI command for the tick (switch-only has none either).