codex-auto-reset was red about once a run in Chromium, one 420px case in
a different language each time: "locator.scrollIntoViewIfNeeded: Element
is not attached to the DOM" in flip(), at the panel's first switch.
Opening the panel's Allowances tab calls quotasOpened(), an asked read
(usage/quotas?asked=1); when it answers, loadQuotas' finally calls
renderQuotas() -> renderPanelQuota(), which builds every card anew. The
cards drawn at boot are already there, so waitFor(psel) passed on them,
and when the asked answer came a few ms later than usual it landed
between flip's locate and its scroll. Instrumented on main (Chromium, en,
420): boot draw at 3ms, the tab's asked read at 76ms, its redraw at
105ms, the first flip after it. codex-credits met the same thing in
#1622 (0b3444999) and waits for !quotasLoading after opening the tab;
this test now does too, and codex-resets-used, which measures the
panel's card on the same draw, gets the same wait. No app change: a
fresh read redrawing the cards can only swallow a press held across
the moment it lands, and a real read's cards differ (their read time),
so skipping an unchanged redraw would not help a user.
Run: the asked answer held back on purpose (a scratch copy serving
usage/quotas?asked=1 60ms late, en 420 Chromium): the old test failed 2
of 3 with the reported "Element is not attached to the DOM" at flip; the
new one passed 3 of 3 (also passed held 30, 120 and 250ms). Unchanged
copies: codex-auto-reset + codex-resets-used pass 15/15 in Chromium 3
runs out of 3, and 15/15 in WebKit, every language. Test-only change, no
Go code touched.
Full suite: SUITE_LINE
alanwalk asked for "自动使用重置卡" to be split: they want a reset that is
about to expire used rather than lost, but a used-up week waited out rather
than spending a reset on it (and the other way round for others).
What changed:
- settings: codexAutoResetOnly narrows an account in codexAutoReset to
"week" or "expiring". An account with no entry keeps both, so every
existing config means what it meant: nothing to migrate, and no user
value is rewritten. Load drops entries for accounts not in the list or
with an unknown value.
- provider: CodexAutoResetWhen(user) reads both times. AutoUseCodexReset
(the week used up, called from the gateway's autoReset and
autoResetSignedIn through AutoResetsWeek) only acts when the week is on;
SpendExpiringCodexResets and routing's resetRunsOut only count on the
expiring reset when that is on. SetCodexAutoResetCase(user, when, on)
sets one time and keeps the other; SetCodexAutoReset still sets both.
Both off removes the account.
- gateway: POST /api/settings/codex-auto-reset takes an optional "when";
POST /api/settings keeps codexAutoResetOnly, which the page doesn't send.
- GUI: the account's card (Usage page and the menu bar panel) says
"Auto-use resets:" with each time on its own line and its own switch;
the brief account's one switch still sets both, its title naming each
time; Settings › Usage gives each account an Off/On per time. The status
line says which times are on now. "· auto-used before it expires" on
the resets held follows the expiring switch alone. Strings in zh, zh-TW,
ja and de.
- CLI/TUI: `magpie quota auto-reset <account> week|expiring on|off`; the
quota and accounts tables and the TUI say "auto", "auto when the week
runs out" or "auto before one expires".
What was run (worktree on origin/main 2fbbd1694):
- gofmt -l on the changed Go files: clean. go vet ./... (darwin),
GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./...: clean.
- go test -tags nogui ./internal/provider ./internal/gateway ./internal/cli
./internal/tui ./internal/gui ./internal/settings: ok. The gateway
package hit go test's 10m default once while ~15 sibling sessions were
building on this machine (no test failed; TestRemoteMagpieModels was
merely running); with -timeout 30m it passed in 967s.
- New Go tests: TestCodexAutoResetCases (provider), a week-only step in
TestSpendExpiringCodexResets, an "only before one expires" case in
TestCodexAutoResetNot (gateway), CodexAutoResetOnly in
TestSettingsSaveKeepsWhatItDoesNotSend. Broken by hand: making
CodexAutoResetWhen ignore the narrowing turned all three reset tests
red (the gateway case answered 200, a week-only account read 2 and
spent 1); dropping the keep line in api.go turned the settings test red.
- GUI (Playwright, chromium and webkit): codex-auto-reset.test.cjs, now in
en, zh, zh-TW, ja and de at 1100 and 420 wide, flips each time's switch
on the card and the panel and checks posts carry "when", the other time
is kept, the status, the resets-held line, the brief switch, fit at 420,
no left border, no select; codex-auto-reset-settings.test.cjs does the
same for Settings › Usage. Both, with codex-resets-used, routing-auto-reset,
quota-curve (its class list now holds ar-split) and i18n-keys: 56 + 18
pass. Broken by hand: posting without "when" turned 20 of 21 red.
quota-curve failed 2 of 18 once while a go test build ran beside it; it
passed 15/15 serially and 18/18 again at concurrency 4 just after.
Not tried: a real ChatGPT account using or keeping a reset; the times are
driven with the faked usage reads the existing tests use.