jojonas_xyz on X: "我账号额度用完了自动给我切了别的号…找不到怎么关掉设置…你怎么知道
我不是想用 credits 呢". (Roughly: "my account ran out of quota and magpie
switched me to another account by itself; I can't find a setting to turn
that off; how do you know I didn't want to use the credits?")
Cause. At 90% or 98% of a window, smart routing's tier put the account
behind every account that still had room, whether or not it had ChatGPT
credits. Codex's own sign-in (NextLogin / SwitchWhenSpent) moved at the
spent share in the same way. The account's credits were spent only once
every other account was used up, and the switch was a log line. The Use
credits switches that existed (on, and "Only after other accounts" from
699ddf152) were only on the Usage page and the panel. None of them meant
"stay on this account and spend its credits".
Change.
- A fourth credits mode, first: settings.CodexCreditsFirst. on, first,
last and off are exclusive; one mode replaces another.
- routes.Seat.First: a first seat's tier is 0, so routing keeps it in
front past its windows while it has credits. The trace records
Weighed.CreditsFirst.
- NextLogin keeps Codex's own sign-in on such an account (spendsFirst).
- The POST /api/codex-credits handler takes "first". The general
settings save keeps the stored value.
- The CLI: `magpie quota credits <account> first`.
- GUI. No new page and no new component, only the Use credits row that
already exists:
- 供应商 → Codex → 账号 ⋯ → 使用积分 → 「先用完积分再换账号」. The
Providers ⋯ tools now carry the credits row too, which is where the
reporter looked.
- 用量 → Codex 账号卡 → 使用积分 → 「先用完积分再换账号」.
- The menu-bar panel's folded line reads 「开,先于其他账号」.
- The "First again once it has room" tag on a moved-off account now
points to the switch in its title.
- Strings are in en, zh, zh-TW, ja and de.
- "Only after other accounts" (gokoshiki, 699ddf152) is unchanged.
Its off title now says what off means.
- Docs: docs/reference.md and docs/subsystems/gateway-routing.md.
Budgets: at this head app.js is 1,312,105 of 1,316,874 bytes, and
TestCoreScriptBudget passes (231 bytes under before the rebase). Comments
were condensed; no budget was raised.
Run on mote, at this tree (rebased on origin/main 9d08993c8; the rebase
moved the settings save into internal/settingsapi, which now carries
CodexCreditsFirst beside CodexCreditsLast):
- go test -count=1 -timeout 45m ./internal/gateway ./internal/provider
./internal/routes ./internal/settings ./internal/settingsapi
./internal/gui ./internal/cli at 9d08993c8+1: gateway, provider,
routes, settings and settingsapi ok. Two reds, both filed:
- internal/gui TestMainWindowCorners/macOS_26_SDK: #3949.
- internal/cli TestLibraryMCPHub, TempDir cleanup not empty: #4140.
At the pre-rebase tree (da0005df8+1) internal/gui also had
TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and TestColdTurnsTaken
(#4510), red the same at da0005df8; both pass at this head.
- New tests:
- internal/provider/codex_credits_first_test.go
- internal/gateway/codex_credits_first_test.go (routing and the trace)
- internal/gui/codex_credits_first_test.go (POST sequence, sandbox HOME)
- internal/gui/tests/codex-credits-first.test.cjs: the Usage page and
Providers ⋯ at 900 and 440px, and the panel at 360px; chromium and
webkit, en zh zh-TW ja de. It also checks for no select, no stripe,
the i18n keys, and that a click does not move the page.
- The whole GUI suite (make test-ui), at da0005df8+1 on mote at load
66 to 213, in two parts (a wiped scratchpad cut the first log; its red
titles were kept): 59 files with a red. 45 of them are red at
origin/main da0005df8 too, each under an open issue: #4304 (mote
umbrella), #4600, #4471, #4120, #4119, #4621, and per file balance-fix
#4682/#4683, gui-ja #4580, page-width-steady #4541, phone-connect-menu
#4706/#4707, quota-curve #4768, segs-press-redraw #4566, signin-proxy
#4643/#1814, zhipu-team #4728, model-copy-id #4621 (red 4 of 4 on main).
- The 14 green at da0005df8 were run again at this tree. One was this
change's: usage-curve-zoom-back. The Codex card's fourth credits line
(366px, was 344) held the DeepSeek card beside it to 261px, so the
"card grows" check at 1100px had no room. Its fixture now turns the
Codex account's credits off, since the count of credits lines isn't
what it tests; 20 of 20 pass.
- At this head (9d08993c8+1), on mote at load 75 to 84: codex-credits-first,
codex-credits-last, codex-credits, routing-codex-credits-again,
panel-options-fold, usage-curve-zoom-back, i18n-keys and the 13 files
above: 232 tests, 227 pass. Each red has an open issue:
- models-fold webkit en/zh, "ebody holds" after the click: #4071; red
the same at 9d08993c8 (run there).
- account-weight webkit, same "ebody holds": #4644 (red at
da0005df8+1, green in this run).
- routing-many-keys chromium de "2 keys in sight at the foot": #4082
(under load; red again alone here, green at 9d08993c8 in one run).
- signin-closes-sheet chromium en/zh: #2628 (green alone at this head
in a second run).
- signin-again and signin-port-blocked, red once at da0005df8+1 under
load, pass at this head and at 9d08993c8.
- Rebased last onto 94f6f6092 (three commits; c0477aa72 changes the
Codex Providers row): go test -run 'Budget|CodexCredits|SettingsSave'
./internal/gui ok, and codex-credits-first, codex-credits,
codex-credits-last, providers-reset-use, i18n-keys and
usage-curve-zoom-back: 92 of 92 pass.
Broken by hand, each red, then restored:
- spendsFirst forced false: the provider test is red.
- The gateway's l.first forced false: both gateway tests are red.
- codex-credits-first.test.cjs against origin/main's assets: red
(TimeoutError on the switch).
Not tried:
- No real ChatGPT account with credits went past its window. The routing
order and NextLogin are tested on fakes only.
- The Linux and Windows apps were not run.
go vet -tags nogui ./... with GOOS darwin, linux and windows on mote:
clean (cgo enum warnings only). gofmt -l on the changed Go files: clean.
Claude has no equivalent: magpie reads no extra_usage and has no Use
credits modes for Claude. Filed as #4662 (see #4241).
The owner (11-01): the interactive mode falling back to -p is dangerous,
for the account (a -p request counts as another client's) and for the
cache (a -p run starts without the interactive mode's), so it goes
entirely. With Settings › Models › Replies' interactive mode on:
- a request it can't take (safeguards, client cache marks, a JSON
schema, an image by URL, words over 400KB, a branch of a -p session,
a WSL Claude Code whose home or transcripts magpie can't reach) is
refused before any Claude Code starts, saying why and naming the
setting (claudeTUIErr), never run as -p;
- a helper that can't start the interactive mode (sign-in asked,
first-run notes, an untrusted folder, no prompt within ReadyWait)
ends saying why (claudetui fail); printMode, OnlyEnv and the
claude-tui-broken mark that sent every run to -p for a day are gone;
- a helper that never answers initialize fails the turn
(tuiNoStart), and the next turn tries again.
Off still runs every request as -p. The "Interactive only" choice of
v0.1.2448 (claudeTUIOnly) is what On is now; the setting is no longer
read or sent.
The Claude Code provider editor's "Claude Code runs as" row is a
switch between Interactive mode (TUI) and claude -p (owner, 11-01),
saving claudePrintMode and reading /api/claude/mode again; disabled in
magpie web. It reads the settings first when the Settings page was
never opened (prefs null crashed the switch; found by the GUI test).
Chromium has no onfocusin property, so the card on keyboard focus
listens for focusin/focusout. Words in en, zh, zh-TW, ja and de.
Docs: claude-subscription-bridge.md describes refusal, not fallback.
Not covered yet, now refused under On rather than run as -p (follow-
ups, each to be done inside the interactive mode): an image by URL, a
JSON schema, safeguards, client cache marks, over 400KB, a -p
session's branch, WSL transcripts Windows can't read. /usage reads
the allowance with claude -p /usage (no model request) either way.
Run (worktree at df0320156 + this):
- mote: gofmt -l clean; go vet darwin/windows/linux of claudetui,
gateway (gui for windows); go test claudetui, settings, settingsapi
ok; gateway -run "TUI|Warm|Claude|AskClaude|Cache|Mode" ok (110s);
gui -run "Budget|I18n|Settings|Claude" ok.
- mote GUI: claude-mode, claude-tui-setting, i18n-keys: 64/64 pass in
Chromium and WebKit, 900 and 420 wide, en zh zh-TW ja de.
- wsl-run go vet -tags nogui ./internal/gui ./internal/claudetui ok;
win-run go test ./internal/claudetui ok.
- Real Claude Code 2.1.316 on macOS through this build's
claude-tui-helper, sandbox HOME, CLAUDE_CODE_OAUTH_TOKEN: trusted
folder -> interactive run, streamed (message_start, 4 deltas,
message_stop), result success in 5.2s; untrusted folder -> exit 1
"Claude Code's interactive mode didn't run: Claude Code asks whether
to trust the folder", no -p run; config without onboarding -> exit
1 naming the first-run notes, no -p run.
Seen red: claude-mode's save test with prefs null before the fix, and
its focus test in Chromium before the listeners; TestClaudeModeLast
while it still read a helper's "this run is -p" line.
Not tried: a real gateway request refused in the GUI (covered by the
Go tests with the fake Claude Code); the new gateway tests run
against the old fallback code; Windows and WSL real runs of this
build; no full suite.
Stage 1 of #4745 (StringKe): every setting POST /api/settings saves can
be read and set from the terminal.
- internal/settingsapi holds the save the handler made: Merge (the
carry of keys a page leaves out, moved verbatim from api.go, plus
upstream's RouterNote line), the vision/imageGen/searcher checks,
settings.Save's own checks, catalog.Touched. POST /api/settings and
`magpie settings` both call settingsapi.Apply, so a value is checked
and saved one way. It sits outside internal/gui so the nogui build
has it.
- `magpie settings` (list, the default, with value, default and
choices; get; set; reset to settings.Defaults()), --json on list and
get. Body sends the whole file with one key changed, so a key the
save keeps when absent (noBird, refusalRetries, ...) is set even to
off. A flag where a key or value goes, an unknown key (with near
matches named) or a refused value writes nothing and exits 1;
--help prints usage.
- Parity guards: TestKeysAreWhatTheSaveWrites (each Settings field sent
changed on its own; what the save takes must equal Keys),
TestSettingsCLISetsWhatTheWindowSaves (every key the page's prefsKeep
and savePrefs send is a key), TestEveryRouteHasACommandOrIsNamed
(each /api route has a command or a reason in notYet, which later
stages shrink; 36 have one now).
- Item 3 of the stage (per-provider CLI-only fields in the window) is
left for stage 2.
- The open app's in-process follow-ups (fonts, Dock, tray menu, alerts,
language, update re-check) run only from the window's save: #4752.
Run (mote, at the pushed head 1c3591b5d + this):
- gofmt -l; go vet ./...; GOOS=linux go vet -tags nogui ./...;
GOOS=windows go vet ./...; GOOS=linux go build -tags nogui;
GOOS=windows go build: clean (before rebase, the vets again after).
- go test internal/settingsapi, internal/settings, internal/cli: ok.
internal/gui -run Settings|Prefs|Keep after the rebase: ok. The full
internal/gui run before the rebase had three reds:
TestSettingsSaveKeepsWhatItDoesNotSend (BusyLoad, fixed on main in
b646a9127), TestColdTurnsTaken (fixed on main in 647323409) and
TestMainWindowCorners/macOS_26_SDK (#3949, mote is macOS 27).
- Real run in a sandbox HOME on mote with a magpie built from this:
settings --help / help, list, get, set theme dark, noBird on,
redactWords "acme, globex", usageAlert 85; refused theme neon, `them`
(names theme), usageAlert lots, trayUsageEvery 4, vision
nobody/nothing, each exit 1 with settings.json unchanged; set
usageAlert --help printed usage and wrote nothing. Then `magpie web`
with MAGPIE_WEB_KEY: GET /api/settings read back each value the CLI
set; POST /api/settings lang ja, then `settings get lang` said ja;
reset theme gave system.
Broken by hand, each red, then put back: noBird dropped from Keys
(TestKeys, TestBodySetsOneKeyOnly, the CLI set test and the GUI parity
test red); Body dropping false values (TestBodySetsOneKeyOnly and the
CLI "noBird off" check red); a route taken out of notYet and another
renamed (TestEveryRouteHasACommandOrIsNamed red, 3 errors). On the old
code the new tests don't compile (no settingsapi, no command).
Not tried: a real run on Windows or Linux; the live app reacting to a
CLI write while open (#4752); the GUI node suite (no page file changed).