Commit Graph
2 Commits
Author SHA1 Message Date
yetone bc7362904f quotas: another computer's magpie that won't tell its quotas says why on its card — not shared there, this key not taken, or not reached — instead of "Allowance unavailable" (Fim980 on X)
Fim980's tray showed one "Remote magpie · 暂时无法获取额度" card and
nothing else. A remote magpie's 403 (a gateway MAGPIE_ADDR opens, as
Docker's does, serves models to anyone but tells its quotas only when
shared on its local network — TestQuotasOverLAN keeps that), its 401 and
a failed connection all fell to the generic label. remoteJSON now gives
each its own error (errRemoteNotShared, errRemoteKey,
errRemoteUnreachable), and quotaError says what to do there, in en, zh,
zh-TW, ja and de; magpie quota and the TUI show the English sentence.

Run: go test ./internal/provider ./internal/gateway (pass);
TestRemoteMagpieUnreachable's new 403/401 cases and
usage-remote-cards.test.cjs's three new cards fail on the old code;
the GUI test passes in Chromium and WebKit, en/zh/ja/de; gofmt, go vet
darwin/linux/windows clean.
2026-10-09 19:34:11 +08:00
yetone 8c71cd27f9 quotas: a computer using another's magpie (remote-magpie) shows that magpie's quota cards (莫 on Discord: the second computer had the models and groups but /v1/magpie/quotas was empty, so Usage, the menu bar and magpie quota showed nothing) — each named with the remote ("Codex · Office", id office/codex, from: Office) and kept in its kind (subscription, plan, balance), on the Usage page, the tray, the TUI and magpie quota (which matches by the remote's id or name); their history comes with the local one. Only the computer holding the sign-ins asks vendors: it answers the new GET /v1/magpie/quotas/cards from what it has kept (CachedCards, never a read, whatever the age), asked here at most once in 30s; a card's refresh here POSTs /v1/magpie/quotas/refresh (that card, or every card from the remote's own card), which the remote does at most once in 30s per card. A remote keeps showing its last cards when it can't be reached; with none its one card says why (nothing read there yet, or a magpie too old to share — "update magpie there", zh/ja/de added). Cards from a third magpie aren't passed on, and the refresh path refuses them (400); a Codex reset or check-in isn't offered on a remote card. Same auth as /v1/magpie/quotas (loopback, or LAN with the key).
Verified: provider tests (fake remote: names/kinds, buttons stripped, third-magpie cards dropped, one ask per 30s, refresh paths, unreachable keeps last cards, 404 → update card, cache-only CachedCards, histories) and the gateway test (an in-process gateway with a fake balance vendor counting hits, asked through a remote-magpie provider: nothing read until a refresh, 5 card asks read nothing, two refreshes of a card read once, a remote card's refresh 400, another machine without the key refused) pass with -race -count=20; go test provider/gateway/gui/tui/root, vet, linux and windows builds pass. Two sandbox gateways (3481 with a fake balance vendor, 3482 with it as remote-magpie): magpie quota on the second showed the "nothing read" card with 0 vendor hits, then office/bal "Bal · Office" $12.00 after one refresh (1 hit), 10 more asks 0 hits, two card refreshes 1 hit. usage-remote-cards (names, translated remote errors, refresh ids) passes in Chromium and WebKit, en/zh/ja/de and fails without the app.js change; i18n-keys, gui-ja, gui-de, usage-card-refresh, usage-refresh, quota-reading-again pass. Not tried with a real second computer.
2026-10-06 12:38:52 +08:00