Commit Graph
6 Commits
Author SHA1 Message Date
yetone 7dd2434d31 remote quotas: a key with Quotas on but told no card shows why too (yi_time)
ef6bd155f made a held remote read show the remote's own card saying why.
A key with Quotas on that may use no provider's cards is answered 403
held too (writeCards), so it now shows that card as well, and the full
suite went red on TestRemoteMagpieShowsHeldKeyItsQuotas, which expected
the key's own card alone. The test now expects the held card, and the
words tell such a key what is missing: let it use every model of a
provider whose usage it is to see, not only turn Quotas on. The GUI
string ends "hover for what to change there" in every language; the core
weighs 21 bytes less than before (1,533,980; main is over its budget
under #5139, not by this).

Run (mote, at 053fc9f9c, on ce21ea856):
- go test -count=1 -run 'Remote|Quota|HeldKey' ./internal/provider
  ./internal/gateway: ok, ok
- node --test usage-remote-cards, routing-remote-windows, i18n-keys
  (Chromium + WebKit; en, zh, zh-TW, ja, de): 36 pass, 0 fail
- TestCoreScriptBudget: red as on main (#5139)
- gofmt -l: clean
Broken by hand: errRemoteHeld's wording changed, the gateway test went
red with the new card's text; restored.
Not tried: a real Windows magpie against a real Mac one.
2026-11-04 18:49:38 +08:00
yetone ef6bd155ff provider: a remote magpie that holds this key says so, where its Claude card went missing with no word (yi_time on Discord)
yi_time on Discord: "没变化 还是不显示通过局域网添加的Claude额度". c7bbd3faf
(v0.1.2908) drew a Remote magpie's cards on Routing. It did not cover a
remote that answers 403 gateway_key_held. That is a key held to a budget,
models or accounts there, without the key's Quotas on (#1981, #2216). For
such a key, keepRemoteCards dropped the cards and remoteCards returned
nothing. The remote's Claude then vanished from Usage, the tray panel and
Routing, with no reason shown anywhere; only the key's own Limit card
stayed.

The remote's own card now carries errRemoteHeld. quotaError words it as
"That computer's magpie tells this key no quotas: it holds the key to a
budget, models or accounts — turn on Quotas for the key under Gateway keys
there", in en, zh, zh-TW, ja and de. Routing's existing "Allowance
unavailable — hover for why" shows it too. A failed read since the hold
(unreachable, refused) still leads with that read's own error.

Only the computer that shows the quota needs this release. The computer
that holds the account needs nothing new, but its owner turns on Quotas
for the key, or lifts the key's hold.

app.js pays for its one line with four quotaError comments cut. The core
weighs 1,534,001 against 1,534,022 on origin/main, so it grows nothing and
raises no budget. TestCoreScriptBudget stays red as on main (#5139, owned
there).

Run (mote, worktree on origin/main 69eb93e0a):
- Real two-magpie repro, sandbox HOMEs. A (old binary) on 3561/3562 had a
  Claude account and LAN on. B (this change) on 3571/3572 added A with
  `provider add remote-magpie <key> url=http://<lan ip>:3561`. A's key was
  held to claude/* models.
  - Before: B's Usage, panel and Routing had no Claude card and no reason.
  - After: Usage and the panel's Allowances show the new line; Routing
    shows "Allowance unavailable — hover for why".
  - With `gateway-key quotas <id> on` on A: B shows remote-magpie/claude,
    5 hours 40%, 7 days 12%.
- go test -run 'Remote|Quota' ./internal/provider: ok. gofmt -l clean.
  GOOS=windows and GOOS=linux go vet ./internal/provider: ok.
- usage-remote-cards.test.cjs (now en, zh, zh-TW, ja, de; chromium and
  webkit) and i18n-keys.test.cjs: 14 of 14 pass.

Broken by hand:
- remoteCards' held branch put back: TestRemoteMagpieHeldKeyShowsOnlyItsOwnCard
  red with 3 errors.
- quotaError's new line removed: usage-remote-cards went 0 pass, 5 fail.

Not tried: yi_time's own two computers, a real Claude account on the
remote (the repro's account is a fake token with a kept reading), the
Windows and Linux app engines (WebView2, WebKitGTK). Whether yi_time's key
is held is not known.

Sibling, filed rather than changed here: with Quotas on and a key held to
only some of a provider's models, the remote answers [] and this side says
"Nothing read on that computer yet" (#5217).
2026-11-04 18:14:10 +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 44d8c742bf remote magpie: the guide names Settings → Network and sharing → Share on local network
The Remote magpie provider's guide, its "isn't shared" message and the
gateway's LAN errors said "Settings → Share on local network", but that
switch sits under Settings → Network and sharing. Every place now names
the real path: the en key and its zh, zh-TW, ja and de words in i18n.js,
app.js's message key, the preset's EndpointHint, the gateway's and
agent's English errors, docs/reference.md, docs/integrating.md,
README.zh-CN.md and the remote and docker pages of the site (en, zh, ja).
errRemoteNotShared names no Settings path and app.js matches its prefix,
so it is left as it is.

Run at base 673651e8d with this change:
- gofmt -l: clean. go vet ./... (darwin), GOOS=linux go vet -tags nogui
  ./..., GOOS=windows go vet ./...: clean.
- GUI (playwright 1.62.0, chromium and webkit, every language): 12 files
  that reach the strings, 121 of 122. The red, quota-name-translated
  (webkit en, 2px past its quota at 440px), fails the same at
  673651e8d without this change; it is #2228.
- go test -timeout 45m ./...: every package ok but internal/gui,
  where TestCoreScriptBudget failed: app.js was 1,338,819 bytes at
  673651e8d itself, over its 1,337,735 budget; origin/main 34ad18ed8
  (#3367) moved code out. This change adds 24 bytes to app.js.

Run again after the rebase onto origin/main 34ad18ed8: gofmt -l clean,
go vet of internal/gui, gateway, provider, agent and tui clean,
go test ./internal/gui/ ok (TestCoreScriptBudget passes), and the same
12 GUI files 121 of 122 with the same #2228 red.
2026-10-23 18:01:03 +08:00
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