Commit Graph
4 Commits
Author SHA1 Message Date
yetone ec7a18d124 gui: the account options' tooltips say what they do in a sentence or two
B3TT3R on Discord (#feedback) found the tooltip on Codex's "Only switch
Codex's sign-in" hard to read: one run-on sentence of three clauses, then
two more caveats. Its siblings in the same account list were the same
kind. Each now says what the option does in one short sentence, and at
most one caveat, in every language (zh, zh-TW, ja, de rewritten, not
machine-shortened from the old text).

- Codex, Only switch sign-in: "When an account is used up, magpie signs
  {agent} in to the next one, and requests go straight to OpenAI. Open
  {agent} sessions keep their account until reopened." (zh: 账号额度用完时,
  magpie 把 {agent} 切到下一个账号,请求直连 OpenAI。已打开的 {agent} 会话重新
  打开后才换账号。) The third caveat, that a Codex connected to magpie
  still sends its requests through it, is dropped: the option is for a
  Codex not connected (Agents row "Not connected · switching accounts
  only"), and a connected one is unchanged by it.
- Claude Code, Only switch sign-in: "When an account is used up, magpie
  signs {agent} in to the next one. Requests on these accounts don't go
  through magpie."
- Keep signed in to: "{agent} stays on this account even when it runs
  low. Requests through magpie still follow Routing."
- The account it stays on (picker): "The account {agent} stays signed
  in to".
- Check usage again near a cap: "On: an account near its cap has its
  usage read again before a request. One whose usage can't be read is
  held." (the 5 points, 15s/5m and 10s wait stay in
  docs/subsystems/providers-accounts.md).

Restart-the-app and Stop-at-cap were already one or two short sentences
and are unchanged.

Run (on mote, through mote-run, at 9730e0199 + this change):
- node --test switch-only, claude-switch-only, keep-login, pool-ends,
  restart-app, i18n-keys, i18n-en-no-cjk (chromium and webkit, 1100 and
  420 wide, en/zh/ja/de): 159 of 160. The one red is i18n-keys "a
  plugin's words are its own", red the same on a clean 9730e0199 copy,
  filed as #5332, #5327, #5482, #5426.

Not run at push: the whole GUI suite, queued under mote's suite.lock
behind other sessions' suites (log ~/csd-logs/gui.log on mote).

Reported-by: B3TT3R
2026-11-08 22:12:36 +08:00
yetone 41b5c0f19a accounts: Claude Code stays on the account it moved to till that is spent too (hxy920830 on X)
hxy920830 on X wants Claude Code to use one account to 98%, move to the
next and use that one to 98%, not jump back the moment the first resets.
No setting gave that. NextLogin (#408) signed the agent back in to the
first account as soon as it was under 90% again, under every routing.
KeepLogin pins one account, In order goes back too, and switch only
went back as well.

Where the sign-in is what spends the accounts (Claude Code, whose own
requests never pass the gateway, and Codex under switch only), the
sign-in now stays on the account it moved to until that one is spent
or fails, then moves on to the next ticked account with room. It goes
back to the first only where the user said the first comes first:
routing In order, or KeepLogin. Codex through the gateway keeps going
back, because Smart routing sends its requests to the first account
(#209) and the sign-in follows it. This is returnsToFirst in
codex_switch.go. The return record is still written, so turning In
order on later goes back as before. An old record is ignored otherwise,
and its "First again" label (logins.go) is hidden. No user setting is
overridden: In order and KeepLogin keep their meaning.

GUI: the Routing note for Claude Code (and Codex under switch only) now
says it stays on the account till that one is 98% used too. The two
switch-only tooltips no longer promise going back. New and changed
strings are in zh, zh-TW, ja and de. app.js lost a 3-line comment so
the core script budget holds without a raise (core 1,531,108 of
1,533,105).

Run on mote at 94cd5edde (base d307aa648):
- go test -tags nogui -count=1 ./internal/provider/: ok. New test
  TestSignInStaysOnTheAccountMovedTo (claude, claude switch only, codex
  switch only stay; claude in order goes back).
- TestCoreScriptBudget and the gui package's budget tests: ok.
- go vet -tags nogui ./internal/provider/ ./internal/gui/ with GOOS
  darwin, linux and windows: clean. gofmt -l: clean.
- GUI, Chromium and WebKit: account-return, switch-only,
  claude-switch-only, i18n-keys, keep-login, routing-signin, gui-zh-tw,
  gui-de, gui-ja. 116/117 and 64/65 passed. The one red is gui-ja's
  "{agent} three times" string, red on origin/main dd7442f28 too (#4580).
- Full suite at the earlier base 76c130b29, -timeout 45m: provider ok.
  Reds, all already filed: TestSettingsSaveKeepsWhatItDoesNotSend
  (#4514), TestCodexListTagNotKeptOverAFreshFile (#4216),
  TestUnroutedRequestShownThenAnswered (#4200). TestCoreScriptBudget
  failed by 41 bytes, fixed above. internal/gui hit its 45m timeout in
  TestUpdateInATerminalRestartsTheAppWithoutCuttingIt.

Broken by hand: with returnsToFirst forced to true,
TestSignInStaysOnTheAccountMovedTo (all three staying cases) and
TestCodexSwitchOnlyStillSwitchesTheSignIn went red. With the note forced
back to the "back to the first" text, the new account-return GUI test
went red in Chromium en and zh.

Not tried: a real Claude account moving and its first renewing (needs
two real windows to run out), runs on the Windows and Linux boxes, and
the full GUI suite at this head.
2026-11-01 05:23:58 +08:00
yetone ce8b67de37 gui tests: a page's first load gets a minute, not a click's 5s (#4470)
claude-switch-only set page.setDefaultTimeout(5000) and then called
page.goto with no timeout of its own, so Playwright held the first load
of app.js, i18n.js and the plugins to the 5s bar meant for clicks. On a
busy box (a whole-suite run at load 130-160) that load took longer and
goto timed out. The same pattern is in 988 GUI test files (1174 pages):
every one of them now also sets setDefaultNavigationTimeout(60000) on
the same page, right after its default, so goto, reload and waitForURL
wait on the load itself with room, while clicks and waits keep their
short bar. group-from-model-add's own 20s navigation bar is raised to the
same minute. claude-switch-only also gives its first provider row (drawn
from the page's first reads) a minute before clicking it.

nav-timeout.test.cjs (no browser) reads every GUI test file and names
each page given a default under a minute without a navigation timeout of
at least a minute, so a new file can't bring the pattern back.

What was run (WSL magpie-desktop, Playwright 1.62.0, load 70-260 from
other sessions):
- node --check on every file in internal/gui/tests: all parse.
- nav-timeout.test.cjs against origin/main's test files: red (names the
  1174 pages); against this tree: its only reds were my own probe copies
  of the old files, since removed.
- By hand: claude-switch-only with app.js served 7s late (a busy box's
  first load), --test-name-pattern "1100 en": origin/main's file 4 of 4
  red with "page.goto: Timeout 5000ms exceeded"; this file 4 of 4 green.
- claude-switch-only.test.cjs, both engines, en/zh/ja/de, 1100 and 420:
  32 of 32. group-from-model-add, usage-access-key-card and i18n-keys:
  green. agent-plugin-agents: Chromium green; WebKit's de 420 subtest red
  on a 5s waitForFunction at line 115 (a wait after load, not the
  navigation), at load ~230.

Not tried: the whole GUI suite (about 1000 files; the change is one
mechanical line per page), Windows or mote (mote's browsers, #4125).
2026-10-31 02:09:18 +08:00
yetone d6fd9b3a36 provider, agent, gui, cli: Codex can switch only its own sign-in between accounts, never through the gateway (#1907, foobra)
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.
2026-10-13 14:35:08 +08:00