prgrmrwy runs magpie on a home server and uses it from work through a
remote magpie (and DSH). The remote Codex card said "1 reset", but the
reset could only be used from the GUI of the computer that holds the
sign-in.
What changed:
- Gateway: POST /v1/magpie/quotas/codex-reset?user=<email>[&credit=<id>]
(Server.codexReset) spends one of that account's resets with
provider.SpendCodexReset. That is the Usage page's own code
(UseCodexResetCard, then AwaitAllowance), moved out of
internal/gui/usage.go so both use it. A reset can't be undone, so the
route needs an enabled gateway key with full access, from loopback too.
No key gets 401, and that covers every corsGuard exemption that has no
key: Origin null, app schemes, *.localhost and a missing Origin. A
read-only key gets 403 gateway_key_read_only (readOnlyGuard, which
readOnlyRefused now lists, and again in the handler). A held key gets
403 gateway_key_held, even one told quotas. The account must be named
(400 otherwise). One ask runs per account at a time (409). When the
reset is used, that card is read again.
- Remote client: UseRemoteCodexReset (remote_quotas.go) asks the remote
with the provider's key. remoteJSON's status mapping is shared through
remoteBody. A read-only key there is told as such, and a 404 as a
remote too old. With no answer in time it says the reset may have been
used, and it never asks again by itself. A remote Codex card now keeps
its Resets; a GLM team's (byWindow) and every check-in are still
dropped.
- GUI: "Use a reset" / "Use one..." show on a remote Codex card
(codexResetCard). They open the same in-app confirmation sheet, with a
line saying which computer's magpie uses it, and send the card's
provider to /api/usage/codex-reset. The remote's errors are put in the
user's words. New strings are in all 5 languages.
- DSH: no code here. Its provider plugin reads /v1/magpie/quotas/cards
and can call the new route with a full key.
- resetOutcome (a reset's result in words) moved from app.js into
resetask.js, the only place that says it, so the core's scripts stay
in TestCoreScriptBudget's 1,533,802 with no raise (1,533,003 after;
origin/main b967b1620 is 1,533,756).
- Docs: reference.md (remote quotas, gateway keys), gateway-routing.md
(read-only list, the route's admission), providers-accounts.md.
What was run (rebased on origin/main b967b1620, then on 2e4735f8f):
- mote, at the head before the rebase and the resetOutcome move:
go test -count=1 -timeout 45m ./internal/provider ./internal/gateway
./internal/gui at load ~300-450. provider ok. gateway: only
TestCompactionOverByteCapEveryTime (#4862). gui: TestCoreScriptBudget
(this change, 158 bytes over; fixed by the move), TestMainWindowCorners
(#3949) and TestGatewaySkewOfAnotherIsSaidNotQuit/own_build (#5053,
passes alone here and at b967b1620).
- mote, same run: 155 GUI files (reset|quota|usage-|panel-|i18n|budget|
remote|gui-|old-webkit|core-script|script-size), 1856 of 1904 pass.
- WSL (magpie-desktop), the 9 red files alone, at this change and at
origin/main b967b1620: this change 147 pass / 43 fail, main 146 / 44;
every test red here is red on main too: codex-auto-reset webkit de
(#4790), remote-magpie (#4398), usage-agents-hide (#3414), usage-fold
(#3415, #4790), usage-heatmap (#4718), usage-ledger (#5048).
codex-reset-lead (#5054) and panel-routing-providers (#5055) were red
only under mote's load and pass alone on both.
- mote, at this head: TestCoreScriptBudget and
TestGatewaySkewOfAnotherIsSaidNotQuit ok.
- WSL, at this head: account-every-reset, codex-resets-used, i18n-keys,
providers-reset-use, remote-codex-reset, reset-each-title,
reset-pick-card, reset-providers, quota-used-no-reset: 99 of 102 pass.
The 3 reds are providers-reset-use's 420px Windows cases ("a click
moved the page", #4873); that file alone is red on origin/main
b967b1620 too (3 of 40 there, 2 of 40 here).
- WSL, rebased on 2e4735f8f (main had changed internal/gateway): the new
tests and the read-only, CORS, LAN-guard, held-key, remote-magpie and
UseCodexResetCard tests in ./internal/gateway ./internal/provider ok;
core scripts 1,532,960 under 1,533,802; gofmt clean.
- Earlier on mote: TestCodexResetNeedsAFullKey,
TestRemoteCodexResetThroughTheGateway, TestRemoteCodexResetAnswers, the
read-only, CORS, LAN-guard, held-key and remote-magpie tests ok;
remote-codex-reset and reset-pick-card 20 of 20 (chromium and webkit,
5 languages, 900/390/440px). gofmt clean; go vet darwin, windows ok,
linux for provider and gateway.
Broken by hand:
- With the handler's key check turned off, TestCodexResetNeedsAFullKey
went red: "this computer, no key: 200 {code: reset}" and a reset was
spent.
- With codexResetCard put back to provider === "codex",
remote-codex-reset.test.cjs went red ("one Use, on the remote Codex
card"). On the old code the route doesn't exist, so the full-key case
gets 404.
Not tried:
- A real Codex reset spent between two real magpies: none was spent, to
keep the owner's resets. The ChatGPT backend is the fake from
codex_autoreset_test.
- DSH's plugin calling the route.
- GOOS=linux vet of internal/gui: it needs gtk4/webkitgtk, which neither
mote nor magpie-desktop has. Its change is usage.go only, and that was
vetted on darwin and windows.
Thanks to prgrmrwy for the report and the proposal.