foobra wants Codex Desktop and the CLI kept on their own ChatGPT
subscription, moved to the next saved account when the signed-in one is
used up and back when it resets, without magpie's gateway in the way.
magpie already did the switch (codex_switch.go: 98%, 100% In order, back
under 90%, unknown usage never switches), but with more than one Codex
account on it also wrote openai_base_url into config.toml so a refused
request fails over through the gateway (codexFailover). There was no way
to have the first without the second.
Now Codex's subscription has SwitchOnly (providers.json "switchOnly",
opt-in, off by default so nothing changes for anyone who doesn't tick it):
- provider.SetSwitchOnly / provider.SwitchOnly; only Codex's own
subscription takes it. An unreadable providers.json reads as on, so
magpie's own failover is never written on a guess.
- agent.codexFailover is false when it is on: no openai_base_url, no
failover note, no magpie models in Codex's list. A base URL the user
wrote stays.
- The account Save copy keeps it.
- GUI: "Only switch Codex's sign-in" tick under Providers > Codex's
accounts (with more than one on), posting provider/switchonly; the
Agents row's failover title points at it. zh, zh-TW, ja, de.
- CLI: magpie accounts switch-only codex [on|off].
- docs/reference.md and providers-accounts.md say what it does and that
an open Codex app or app-server stays on its account until reopened.
Run (darwin, sandbox HOME, -tags nogui):
- go test ./internal/provider -run 'TestCodexSwitchOnly|TestCodexSwitchedWhenUsedUp|KeepLogin'
- go test ./internal/agent -run 'TestCodexSwitchOnly|TestCodexFailover|TestCodexOwnModelThroughMagpie|TestCodexHandWritten'
- Broken by hand, each red: codexFailover guard removed (agent test),
SwitchOnly dropped from the Save copy, SwitchOnly reading false on an
unreadable file (provider test), the tick drawn unticked (GUI, 16/16).
- GUI: switch-only (new), keep-login, agent-failover, gui-ja, gui-de,
gui-zh-tw in Chromium and WebKit, en/zh/ja/de at 1100 and 420: 77 pass.
- The built binary's `accounts switch-only` in an empty sandbox HOME:
reads off, refuses on with no Codex provider, refuses claude.
- gofmt -l clean; darwin go vet.
Reviewed and rerun after rebasing onto eba718736 (darwin, sandbox HOME).
The rebase met #1899's withPicks; SwitchOnly is copied there now.
- gofmt -l clean; go vet -tags nogui on darwin, GOOS=linux and
GOOS=windows for internal/provider, agent, cli, gui.
- go test -tags nogui -timeout 40m ./internal/provider ./internal/agent
./internal/cli ./internal/gui: all ok. (On the base before, provider's
TestCopilotSecretToolUsername timed out once under load: #1627,
untouched code, 3 of 3 alone.)
- Broken by hand, each red: the codexFailover guard removed
(TestCodexSwitchOnlyKeepsCodexOffTheGateway), SwitchOnly dropped from
the Save copy, from withPicks, and an unreadable providers.json
reading off (TestCodexSwitchOnlyStillSwitchesTheSignIn).
- GUI: switch-only, keep-login, agent-failover, gui-ja, gui-de, gui-zh-tw
in Chromium and WebKit at 1100 and 420: 77 of 77 pass.
Rebased again onto 81f587d7b (clean; it touches provider, cli, gui but
not agent): vet on all three OSes again, go test -timeout 40m
./internal/provider ./internal/cli ./internal/gui all ok, -run TestCodex
./internal/agent ok, and the 77 GUI cases above pass again.
Rebased once more onto d45b20757 (clean; no lines of this change touched):
vet on all three OSes, -run 'TestCodex|KeepLogin|SwitchOnly'
./internal/provider ./internal/agent ok, switch-only and agent-failover
in Chromium and WebKit pass.
Not run: not tried with real ChatGPT accounts or the Codex app.