Commit Graph
125 Commits
Author SHA1 Message Date
yetone 2926b7beff usage, routing: the model id a request went out under is kept and shown
daoche_wuzui on X asked how magpie serves Antigravity and whether a
request goes out under a suffixed model: nothing showed the id actually
sent. Antigravity's plugin turns gemini-3.7-flash at high effort into
gemini-3.7-flash-high, and a relay's upstream name (ModelWires) renames
a model too; the ledger and Routing showed only the routed model.

- A plugin's reply may carry X-Magpie-Sent-Model
  (provider.SentModelHeader). forward() reads it from plugin providers
  only (a non-plugin's header is ignored) and deletes it, so it never
  reaches the agent. Without it, provider.SentNameOnIn (the upstream
  name, or Antigravity's variant) is used.
- wireName keeps the id only when it differs from the model. It goes in
  usage.Record.Wire (`wire`, omitempty), the trace's Try.Wire, the
  ledger cache and a last CSV column, sent_model (docs/reference.md).
- Usage › Requests: the Sent cell and the detail show the sent id when
  there is one, with "model → sent id" on hover. Routing: a try sent
  under another id gets one aside line, "Sent to the vendor as {model}"
  (zh, zh-TW, ja, de).
- Antigravity's mover min is 0.2.4: plugins 67fb1258 sets the header on
  every reply (stream, whole and errors); its tgz is on the plugins
  repo's dist branch.

Run at this head (ef997d186 + this), on mote:
- gofmt -l: nothing. go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./...: ok.
- go test -tags nogui -count=1 -timeout 45m ./...: every package ok but
  internal/gateway, red only in TestOpenCodeGoOwnFreeModelGetsNothingOfOpenCodes,
  red 5 of 5 alone at origin/main ef997d186 too (#7117, taken).
- GUI: the 46 files that reach the Usage ledger, Routing's tries and
  i18n (i18n-*, ledger-*, usage-ledger-*, routing-try-fixed, sent-model
  and the files that read the Sent cell or an aside): 230 ok; red only
  aside-native (#6212) and usage-ledger-chart's remembered metric
  (#6790), both red the same way at origin/main ef997d186. The whole
  GUI suite (1609 files) was still running at push; its reds so far are
  in account-arrange and the Codex lone-capped-account files.
- sent-model.test.cjs: 10/10, Chromium and WebKit, en zh zh-TW ja de.
- Plugin: bun test packages/antigravity 136 pass, check.mjs ok.

Rebased onto 593ea437d (three gateway/routing commits) before the push,
then again: gofmt; vet of gateway, usage and provider for darwin, linux
and windows; the new tests with the gateway's Wire, Ultrafast and Prefix
tests; sent-model and i18n-keys (14 pass): ok.

Broken by hand, each red:
- no noteWireModel call: TestPluginSentModelIsKept;
- the IsPlugin check removed: the spoofed-header case;
- no SentNameOnIn fallback: TestUpstreamNameSentIsKept;
- an id equal to the model kept: both tests;
- the old GUI assets: every sent-model case; the old usage page.js
  alone: the Sent cell assertion;
- the plugin's old index.mjs: its new test (31 pass, 1 fail).

Not tried: a real Antigravity account (the plugin's header was tested
with its fake vendor only).
2026-11-19 14:45:14 +08:00
yetone 1c9c359f9d gui: Usage cards keep their place as they come in (liuzhengdong99 on X)
liuzhengdong99 on X: 用量界面每张卡片取数的时间不一致,导致卡片渲染时高度一直
跳动——滑到上面看某张卡片,视图会被拽回下面. The allowance cards come in
at different times: each vendor's read (the page asks again every 1.5s
while X-Magpie-Reading says a read is under way), then the curves'
history. Every answer redraws the cards (renderQuotas), and packUsage
grows the ones above the card being read. Nothing kept that card in
place: the view's scroll guard (keepInView) only knew elements by node,
and the cards are new nodes on each draw, so the browser's anchoring was
the only thing holding them. It anchored on nodes that were being
replaced, and the reader ended up dragged down.

Fix:
- The Overview keeps the card being read in place: the highest card (or
  part of the page under the cards) that starts in sight, found again by
  its data-key after a redraw (keepInView's new `only` mode with pinnedAt),
  and followed after every packUsage (followPin). The browser's own
  anchoring stays on while nothing is kept: at the page's top, on
  another tab, and while the cards are dragged or moved by keys (unpin,
  so a dropped card lands where its slot showed).
- Placeholders from the last known height: each card's height drawn in
  full is kept by its key (localStorage magpie.usageCardTall, 1s
  debounce, 200 keys at most). A card still waiting on its read or its
  curve (usageWaiting: quotasReading, the new flag loadQuotas sets, or
  no history answer yet) is packed and held at least that tall, in the
  column count the cards were last whole in at that width. On the next
  start, no card in sight moves.
- loadQuotaHist counts its first answer even when it is empty, so a
  user with no history isn't left waiting (found by usage-pack: the
  cards held their first packing at 560px).

No new animation, nothing scrolls the page on its own (click-scroll
passes), and the layout is unchanged once the cards are in.

Run (mica, Playwright 1.62.0, Chromium + WebKit):
- usage-cards-steady.test.cjs (new): 20 tests, all 5 languages, 1100px
  and 420px. On the old assets (MAGPIE_ASSETS) it was red 8 of 8 in en
  and ja. With the hold disabled, the second visit goes red.
- At ee079814b + this change (then rebased onto 1c29e2c7d, which changes
  only app.css, redact.css and a new contrast test; script budgets
  measured again, unchanged): go test ./internal/gui/ (budgets included),
  gofmt, and usage-pack, usage-cards-steady, usage-drag, usage-arrange,
  click-scroll and i18n-keys: go ok (300s), 64 of 64 GUI tests pass.
- Every usage-*, quota-*, view-*, account-arrange, click-scroll,
  i18n-keys and gui-de/ja/zh-TW file (151 files), run before the empty-history fix and the last
  rebase, head vs origin/main.
  No red at head is new. The reds that are also on base: account-arrange
  (#6010), quota-count-wrap (#3404), quota-curve (#6789),
  quota-refresh-order (#6180), quota-credits (#6807), usage-ledger
  (#5048, #6003), routing-* (#7016), gui-ja (#7144),
  view-trackpad-coast (#4724), view-wheel-unheard (#5158), plus the
  whole-suite reds in #6975 and #6934. usage-pack and usage-drag went
  red at head along the way and are fixed here.

Not tried: the real app (WebKitGTK on Linux, WebView2 on Windows,
WKWebView on macOS) and the full GUI suite.
2026-11-19 13:01:23 +08:00
yetone 4d79bebfa7 usage: speed counts all output, reasoning and tool calls too, from the first output (Archivemylife on X)
Archivemylife on X: speed should be the upstream's usage over the local
time, with no split into reasoning, tools and answer, since reasoning and
tool calls are tokens too.

Speed is now every output token the vendor's usage counts (reasoning and
tool-call arguments included) over the time from the first output of any
kind to the end of the reply. The first output is the earlier of the first
content (TTFT) and the first sign of reasoning, firstToken.reasoningMs in
ttft.go, which works the same in every protocol:
- a Responses reasoning item's start;
- an Anthropic thinking or redacted_thinking block's start;
- sealed (hidden) thinking;
- reasoning deltas spread over 100 ms or more. Deltas that came at once
  are a buffered burst and tell none.

A summary is no sign (summaryPart: a Responses reasoning summary, a Gemini
thought, or a summary translated from another protocol via
firstToken.summarized), because it is written after some of the reasoning
it sums up (#1463). A reply that reasoned with no sign of when it began
counts only its answer, its output less the reasoning, from its first text,
and none with no text. Before this, a reply that reasoned always counted
only its answer, and a reply that wrote tool calls after reasoning told no
speed. Burst and held-content checks judge the answer's part.

The same definition holds everywhere:
- gateway: speed.go, trace.go, codex_backend.go;
- usage.DecodeOf, for the Usage cards, rows and `magpie usage`;
- the Usage page's ledDecode;
- the Routing page's decodeOf and its ranking (fast routing reads
  noteTrySpeed, which uses DecodeOf).

settledCountVersion goes to 8, so settled heat totals are counted again.
The rule text is in en, zh, zh-TW, ja and de. Docs: reference.md, and
gui-shell.md under "Streamed output speed".

Red on the old code (scratch worktree at 589e4ba6d):
- TestCodexPreambleThenReasoningTellsSpeed: "reasoning seen from 0 ms;
  want 3166".
- TestVisibleReasoningSpeed: 100/1000 and 0/0 where 1500/14000 was
  wanted.

Run at this head (rebased on dc507aefd), on mote:
- go test -tags nogui -count=1 -timeout 45m ./...
  - gateway ok (1132s), usage ok, routes ok.
  - Red, filed, and caused by mote's own gateway on 127.0.0.1:3425:
    internal/cli TestHealthcheckFindsTheRunningGatewayWithoutMagpieAddr,
    TestUpdateRestartsTheGatewayItFindsWithoutMagpieAddr and
    TestUpdateFindsAMagpieThatWroteNoRecord (#6223, #6471); internal/gui
    TestLaneLimitRoutes (#5150).
- go vet for gateway and usage on darwin, GOOS=linux -tags nogui and
  GOOS=windows: ok. gofmt -l: clean.
- GUI, 18 files in Chromium and WebKit (reasoning-speed, usage-speed-*,
  usage-ledger, routing and the i18n files): 242 of 270 pass. The rest are
  usage-ledger "newest live route needs no return-to-live button" (#6003)
  and usage-speed-all-models "asked for 7d" (#5834). Both are red the same
  way on origin/main dc507aefd, in a run of its own.

Rebased again on 70ad7cf30, which touches gateway.go and usage/page.js.
At that head, on mote: go vet for gateway and usage; go test -run
"Reasoning|Speed|Decode|Ultra|Uncounted" for gateway and usage, ok;
reasoning-speed, usage-reads-note, usage-speed-every-row and i18n-keys in
both engines, 66 of 66.

Not tried: a real account per vendor. The timing is taken from recorded
stream shapes in the tests: Responses, Anthropic, Chat and Gemini, native
and translated.
2026-11-18 21:30:25 +08:00
yetone 5cf1d3846a sessions: an agent left off in the first "allow selected" is asked about once more, on Sessions and Usage › Requests
baysonfox on X: with magpie installed after Antigravity 2.0, the app's
sessions and calls made without magpie never showed in Usage, while agy
CLI's did. The first consent named the app off beside agy, and a named
agent was never "new" again, so nothing asked about it and nothing on
Usage said why. The reader is fine: the app's calls come from its own
SQLite steps (antigravityRead), read once allowed.

Nothing is turned on by magpie: the gate is the user's privacy choice.
Instead:
- settings.SessionReads gets Kept: agents turned off on their own (a
  sessions/reads post without `all`: Keep off, a Settings › Privacy row,
  `magpie sessions read off <agent>`). A post setting it on takes it out.
- readsNow's New: off, found here and not Kept (was: never named). So an
  agent left off in the first choice's list is asked about once more,
  as one found later already was.
- Usage › Requests shows a line above its rows for those agents
  (readsLater in the usage plugin): Count {names} / Don't count, the
  same {agents} posts as the Sessions page's laterCard. Gone after
  either answer; sessions/reads read at most once a minute.
- Old data: an agent turned off in Settings before Kept existed has no
  entry and is asked once more, for every user with such an agent.

Tests:
- TestSessionReadsUncheckedAgentAskedAgain (count, keep off): sandbox
  HOME with testdata/agy-sessions and the real Antigravity 2.30
  conversation (antigravity-2.30-tools); after the first choice the app
  is off and New, has no rows in /api/usage/requests; Count brings its
  rows in, Keep off keeps none, and neither is asked again. Red on the
  old code (New false after the first choice).
- TestSessionReadsTurnedOffNotAskedAgain: off on its own, under all true
  and all false, is neither on nor New.
- usage-reads-note.test.cjs: the Requests line in Chromium and WebKit,
  en/zh/zh-TW/ja/de at 900/420/390px, both answers, buttons inside the
  line, no sideways scroll; red on the old code (no #ledReads).

Run on mica (mote was full: load 40+, another GUI suite on it), rebased
on 389169f76:
- gofmt -l clean
- go vet on gui, sessions, settings, cli and tui; GOOS=linux -tags nogui
  and GOOS=windows vet on gui, sessions, settings and cli; go build ./...
- go test -count=1 -timeout 45m on internal/gui, sessions, settings, cli
  and tui: all ok except gui's TestGatewayModeListsNoOwnSessions, red
  the same on an untouched 389169f76 copy (#7064)
- GUI, both engines: usage-reads-note, sessions-reads, i18n-keys,
  i18n-en-no-cjk, usage-ledger, usage-request-page, usage-no-reading,
  usage-ledger-fit, ledger-hscroll, usage-phone-head, sessions-usage-off.
  Only usage-ledger's "newest live route needs no return-to-live button"
  was red (en, zh, both engines), red the same on the untouched
  389169f76 copy (#3104). i18n-keys first caught "Leave off" as otel's
  word; renamed to "Don't count".
- After rebasing on dc507aefd: gofmt, vet, the TestSessionReads tests
  and usage-reads-note, i18n-keys, i18n-en-no-cjk and sessions-reads
  again: all ok, 98 of 98 GUI tests.

Broken by hand: recording Kept on every off post (all sent too) turns
TestSessionReadsNewAgent, ...UncheckedAgentAskedAgain and
...TurnedOffNotAskedAgain red.

Not tried: the whole GUI suite (both machines had another GUI suite
running), the full go test ./..., and a real Antigravity 2.0 install
in the GUI; the live Antigravity data was not touched.
2026-11-18 20:59:55 +08:00
yetone 67f24d7422 usage: every cache hit rate to two decimals, its exact share on hover; a speed's dash says why
shangyuan0818 on X: in Usage › Requests the ranking's model hit rates
had no decimals or one ("98%" beside "99.6%"), the request table mixed
them too, and hovering showed no exact value.

- hitPct gives every hit rate two decimals (98.00%, 99.60%), the same
  in the ranking, the request table and its details, the Cache hit
  rate card, the cache-read tiles, the model and agent rows, Sessions,
  the tray panel, Routing's rows, figures and group averages, and the
  context window's Prompt cache. It still never says 100.00% or 0.00%
  of a prompt not all or none cached (99.99%, 0.01%).
- Each of them has the exact share on hover, in its title (hitTip):
  "9,800 of 10,000 prompt tokens read from the cache: 98%", the share
  to six places with no trailing zeros. One new string, translated in
  zh, zh-TW, ja and de.

ohblue on X: 速度 shows "—" for many 200 requests (491 in, 93 out,
first token 6.3s, total 6.4s), "≥133 token/秒" for others.

- That speed can't honestly be counted: 93 tokens in the 120ms after a
  6.3s wait would read ~775 tok/s, which is a reply written during the
  wait and let go at once (ledHeldShort_). The dash already had its
  reason as a title, but nothing showed it was there. It now has the
  help cursor (the cache column's dash too), the Speed column's head
  says what a speed is on hover, and a request's details say "— " and
  the reason in words, for a reader who can't hover.

Budget: app.js and the core grew by my hitTip, cacheHitTip and the
titles. To stay inside both budgets with no raise, setQuotaRange moved
to plugins/usage/page.js and PLACEHOLDER to plugins/redact/page.js (each
read by that page alone), cacheHitOf and cacheHitTip share cachePrompt,
and hitPct is one expression. Core 1,272,578 of 1,272,581; app.js
1,087,887 of 1,088,248.

Run on mote/mica, this change on origin/main, both engines, every
language, at the widths each file covers:
- usage-hit-exact.test.cjs (new): green. Red with the old hitPct
  ('hit rate 98%') and red with the help cursor and the details' line
  taken out ('pointer' !== 'help').
- 85 GUI files (every test that reads a hit rate, quota range or
  masking, Usage, Routing, i18n-keys, gui-ja/de/zh-tw): 1318 pass, 30
  fail. All 30 are red alike without this change, and all are filed:
  agent-menu-label webkit panel (#6371), zcode-models webkit de
  (#6566), quota-credits (#6807), quota-curve (#6789), usage-fold's
  17 subscriptions (#3415, #6003), usage-ledger (#4078, #3104, #4626),
  usage-ledger-chart (#6790). usage-fold's 'several accounts' went red
  only under the 85-file run and passes alone on this tree (#3415,
  commented).
- go test ./internal/gui on mica: ok (TestCoreScriptBudget included).
- Red alike on a HEAD checkout without this change, already filed:
  usage-ledger "newest live route needs no return-to-live button"
  (#4078, #3104, #4626), usage-ledger-chart "the metric is remembered"
  (#6790).

Not run before the push: the whole GUI suite and go test ./... (both
machines had other sessions' full suites running); they run after it
and their result goes on record. Not tried: Windows WebView2, the
reporters' own ledgers, the real app.
2026-11-18 16:14:52 +08:00
yetone 5bfa57e3d3 usage: check one model on one provider with a few fixed-answer calls, kept beside the other providers
skingstyle48487 on X runs more than ten relays and asked for something
like the "pelican test" to spot one that waters a model down. In a
follow-up (2122694296054972815) they said speed, failures and the model's
name show whether a relay is fast and stable, not whether the model got
weaker. They asked for small tests with known answers, the share of right
answers and of right tool calls, and relays compared side by side.

On Usage › Requests › Model speed › Providers, each row has a Check… that
opens a dialog. Opening it sends nothing; only its Check makes the calls.
POST /api/relay-check (gateway.CheckRelay) makes 6 small streamed Chat
Completions calls through the gateway, pinned to provider/model as an
agent would, three at a time:
- write 1 to 40;
- 1234 × 5678, 987 × 654 and 2468 × 1357;
- weather in Paris and time in Tokyo, each call offering both tools,
  so the right one has to be picked.

Each part says what it found, never a verdict on the provider:
- whether the answer was the expected one, and what came back;
- the model the reply named, when the ledger would call it another
  model (usage.Swapped, not SameSpelled or ListedAs);
- the provider that answered, when the call was handed on;
- how many input tokens the 118-character prompt was counted as;
- first token, tok/s and the whole time.

The dialog heads the parts with "Answers right: n of m" and "Right tool
calls: n of m". The numbers come from the gateway's own usage records (a
tap in appendUsage keyed on the request's context), not from each
protocol's reply. The tally of each provider's last check is kept in the
window's storage. The Providers table then shows Answers and Tool calls
columns: sortable, amber when short of all, a dash for providers not
checked, so relays are compared side by side. The dialog code is a
lazily loaded root script (relaycheck.js), as app.js has no room left.

Run, at this head:
- mote: go test -timeout 45m ./internal/gateway ./internal/gui
  ./internal/cli ./internal/usage: ok (the full ./... suite passed at
  41d88731c, before the fixed-answer calls; mote and mica were each
  running another session's GUI suite at this head);
- gofmt -l, GOOS=linux go vet -tags nogui ./... and GOOS=windows go
  vet ./...: clean;
- go test -run 'CheckRelay|ReadChatStream' -v ./internal/gateway
  (5 tests pass);
- usage-model-speed.test.cjs, chromium and webkit, en, zh, zh-TW, ja and
  de at 400px: 12/12;
- i18n-keys and old-webkit: their only reds are the three on origin/main,
  each filed (#6877 ", with an image", #5919 :has(), #6030
  headerpresets.js);
- TestCoreScriptBudget and the app.js budget: ok, not raised.
Broken by hand:
- taking tapUsage out of appendUsage turns TestCheckRelayAnsweredAsAsked
  and TestCheckRelaySaysWhatDiffers red;
- dropping the tool-name check turns TestCheckRelayCountsEachAnswer red
  (get_weather for Tokyo read as right);
- pressing Check as the dialog opens turns the GUI test red ("opening the
  dialog sends no call").
Not tried:
- the whole GUI suite at this head (both machines busy with another
  session's suite);
- a real relay (fakes only);
- a context-window probe;
- a comparison with the vendor's own count_tokens;
- a periodic check (the check runs only on a press).
2026-11-17 23:13:03 +08:00
yetone b0674b9ec4 providers: a key's balance shows on its row, as Usage last read it
lyj1115 on X: magpie found the relay's balance (the probe), but the
Providers row showed only the API key; the figure was on Usage alone.

The row's quiet facts line (host · models) now ends in " · $10472.14",
in the line's own colour and size, with "Balance $…" as its tooltip.
Several keys' balances are added up as the Usage card's head adds them
(shared balances counted once), else the key in use's. A failed read, a
signed-in account (its windows are on Usage) and Usage turned off show
none. Opening Providers asks for Usage's own read (never ?asked=1, so
"read only when asked" holds) when it is over a minute old, as Routing
does (#1833); rows are marked after the list is drawn and after a read.

rowBalance, markBalances and keysSum/keysSumTip live in
plugins/usage/page.js (keysSum moved out of app.js) so app.js stays
under its code budget without a raise; app.js calls markBalances?.().
No new words, no CSS.

Run (mote, at this tree rebased on origin/main 6cc7402bd):
- provider-row-balance.test.cjs: 24/24 green, chromium and webkit,
  en zh zh-TW ja de at 900 and 420px, and Usage off.
- Broken by hand: against origin/main's assets (MAGPIE_ASSETS) it is
  22 of 24 red (no .pv-bal); only the Usage-off cases pass.
- go test ./internal/gui -run 'TestCoreScriptBudget|I18n|Words|Asset|Budget': ok.
- i18n-keys, i18n-en-no-cjk and 12 provider-*.test.cjs files: 329 pass,
  1 red: i18n-keys "a plugin's words are its own" (routing's ", with an
  image"), red the same on origin/main 6cc7402bd, filed as #6877.
- A 218-file GUI batch (provider, routing, balance, usage-keys,
  usage-shared-balance, i18n) was still running on mote at push time;
  new reds against origin/main get issues when it ends.
Not tried: the real app with a real relay's probed balance.
2026-11-16 23:11:36 +08:00
yetone 34606000da gui: the tray panel's Usage tab ends in a heatmap of recent weeks (eiyuuzaki2333 on X)
Asked for "a heatmap like GitHub's / Codex's, also in the tray". The
window already has one (Usage › Requests, 53 weeks, #1369), so no second
copy goes on the Overview, which counts gateway calls only while the
heatmap counts session-file calls too. The tray panel had none.

The panel's Usage tab now ends in a card of the recent weeks, one cell a
day, Monday on top, as many weeks as the card fits (8 to 53: about 25 at
the panel's 440, 17 at 320). It goes after the chart and ranking, so
nothing above it moves. Its shades are the existing monochrome accent
ramp (.l0 to .l4) and follow the tab's own Tokens / Cost / Requests
switch, with no new read; a provider or computer picked above narrows it.
A tooltip says the day and its tokens, requests and cost. Weeks with no
call show no card. No animation.

It reads the existing cached /api/usage/heatmap, at most once a minute
and again when a pick changes; the tab's own 10 s reads don't wait for
it, and no endpoint was added. The card, its reads and tooltip live in
plugins/usage/page.js, which shares its grid (heatGridOf, taken out of
drawLedHeat as it was) and tooltip (ledHeatTip, now told the metric and
provider) with the Requests tab. app.js keeps one guarded call in
renderPanelUse: the ledger read can come back before page.js has run, so
page.js draws the tab again when it loads. Both script budgets hold it
at this base with no raise. The card
is .pu-heat, not .pu-card, so the chart's card stays the tab's one
.pu-card. The panel's light pills are its card's white, so a quiet day
there is a 7% shade of the text over the card.

Run (rebased on origin/main 2896e82cc):
- panel-heatmap.test.cjs (new), Chromium and WebKit, en zh zh-TW ja de,
  440 light and 320 dark: 12 of 12, 3 runs on mote. Red 12 of 12 with
  MAGPIE_ASSETS at origin/main's assets.
- Affected files (usage-heatmap, panel-usage, panel-usage-models,
  panel-usage-first-account, panel-currency-provider, panel-units-follow,
  number-units, usage-chart-axis, usage-head-steady, usage-phone-head,
  i18n-keys, phone-no-sideways) and TestCoreScriptBudget: green but
  phone-no-sideways de 375, the same with origin/main's assets (#5869).
- At 2896e82cc again: panel-heatmap, panel-usage, panel-usage-models,
  usage-heatmap, panel-usage-first-account green; i18n-keys red on a
  routing-plugin phrase 2896e82cc's claude_image_budget_test.go added,
  red on origin/main alone (#6877).
- Whole GUI suite on mica at 91b3af847 (concurrency 4): not finished.
  The runner exited 7 with no message twice (after ~2231 and ~2371
  tests); the third part, grip-inset on, is still running, ~10,900
  tests in. None of the red files is touched by this change. Under the
  whole-suite load (#6709, #6782), with their issues:
  agent-details-ready #6369 #6373, agent-switch-accounts #5925,
  claude-quota-onboarding #6179, bark #6543, api-key-theme #6444,
  aside-native #6212, agent-menu-label #6371, allow-ips #4959,
  account-refresh-holds #6003, account-arrange #6010, desktop-tiers
  #6475, quota-refresh-order #6180, provider-max-output and
  provider-many-keys #6209, rest-try-now and key-switch #6232,
  provider-fetch-again, provider-typed, provider-picks-stay,
  provider-models-rest and menu-scroll #6532, omp-roles #6432,
  recovered-file #4320, quota-bars-alike #6700, login-export #6628,
  gateway-key-arrange #6268, first-untick #6660, editor-hints #6156,
  connect-address-kept #6755, recent-call-bodies #6665, quota-credits
  #6807, models-works-only #4391, codex-memories-settings #6372,
  panel-options-fold #6794, reset-providers #6196, quota-curve #6789,
  model-copy-id #4621, modal-backdrop #6663, loop-guard-setting #6662,
  lightweight #6340, keychain-retry #6661, key-replace #3476,
  key-balance-card #6414, gateway-pause #6684, duplicate-pause and
  key-box-once #6424, codex-async-compact #6658, name-suffix-remote
  #5147, menu-input-scroll #3402, rollup-short #6560, remote-magpie
  #6099, plugin-signin-no-url #5938, plugin-signed-out-account #5998,
  plugin-page-foreign-error #6117, plugin-option-placement #6559,
  phone-no-sideways #5869, partners #6664, panel-fold #5796, omarchy
  #4624, old-webkit #6030, model-api-preset #5838, mobile-web #6790,
  library-open-again #6751, key-import #6416, grip-inset #6293,
  fast-ultra and fast-pick #6201, ctx-session-line #5801, context-cap
  #6514, codex-auto-reset #6232, panel-usage-first-account #6181
  (green alone at this head), lan-join #6353, icon-tile #6759,
  model-chip-steady, header-centre, last-page, nav-timeout,
  plugin-card-update #6709. With no issue before, filed as #6876:
  data-folder, plugin-move-unserved, name-suffix-where-named,
  group-editor-selected, found-skill-pick-remove, quota-count-wrap,
  nav-sub-fold, model-suffix-own, account-models,
  account-models-available.
- Looked at screenshots of the panel at 440 and 320, light and dark, en
  zh de ja, with the tooltip shown.

Not tried: the real app's tray panel on macOS, Windows or Linux
webviews, real accounts' usage.
2026-11-16 20:58:35 +08:00
yetone e47abdf468 usage: the allowances' trend takes any last N days; a curve's hover reads the exact numbers
shangyuan0818 on X asked for exact numbers on the Overview's quota
curves when hovered, and for the trend to take any "last N days".

- Usage → Overview, the allowances' "Trends: …" button: the menu now
  has 7 days and 30 days beside Off, 2 days and Cycle, and "Other number
  of days…", which turns the button into a field for 1 to 45 (the days
  of history magpie keeps). Enter or leaving the field keeps it; Escape
  leaves the range as it was; a number out of range says so and keeps
  the old one. A custom N stays in the menu, and is kept across a reload
  (magpie.quotaRange).
- Hovering a quota curve shows a small tip at the reading nearest the
  pointer: when it was read, then each window's left to two decimals
  (70.46%), with a hairline at that time. A balance curve shows the
  balance in the card's currency. The curve's own tooltip (what the
  dashes mean) waits while the tip shows. A touch still zooms, as before.
- The trend menu, the days field and the hover live in the usage
  plugin's page.js, so app.js stays inside its budget.
- No animation: the tip follows the pointer, which a movement would lag.

Run, at d597b4d01 + this change, on mote and mica:
- quota-trend-days.test.cjs (new), 5 languages x 2 engines: red on
  2d106b5c1 ("7 and 30 days are offered"), green 10/10.
- The 18 GUI files that draw or pick the allowances' curves, i18n-keys
  and i18n-en-no-cjk, plus usage-exact-cost and quota-holds: 201 pass. The 6 reds are red alike on origin/main 2d106b5c1, each filed:
  quota-curve's "quota cards draw what was left over time" (#6789) and
  usage-fold's "17 subscriptions and 29 accounts" (#3415, #6003).
- go test ./internal/gui: ok (app.js 228 bytes inside appScriptBudget)

Not tried: Windows (WebView2) and the panel's Allowances tab by hand, a
real account's history, a touch screen.
2026-11-16 04:45:45 +08:00
yetone d597b4d010 usage: a priced cost without "≈", at least two decimals; cache hit rate to two
shangyuan0818 on X: Usage → Requests showed every cost as "≈$…", and
the cache hit rate with one decimal.

- A cost from known prices is what magpie counted, so "≈" is gone from
  every priced cost: Requests' Cost card and tiles, the agent, model and
  account rows, the quick panel's Usage, Routing's live rows. An estimate
  keeps it (a window's whole on an account card, a session file's times).
- fmtCost gives at least two decimals ($1.00, $100.00, $2500.50), three
  under $1 as before, and a sub-mill amount to its first two digits
  ($0.00040, $0.000012) instead of $0.000.
- Requests' Cache hit rate card has two decimals (93.97%); hitPct still
  never rounds up to 100% or down to 0%.
- A whole-window estimate from $100 up stays whole ($1235): its cents
  would claim a precision it hasn't (wholeCost, moved to page.js to keep
  app.js inside its budget).

Run, at 2d106b5c1 + this change, on mote (rebased onto fc41381d6,
whose three commits touch nothing under internal/gui):
- usage-exact-cost.test.cjs (new): red on 2d106b5c1, green 12/12.
- The 91 GUI files that read a cost or a hit rate, both engines, every
  language. Reds beside this change's own (fixed: mobile-web,
  panel-currency-provider, ledger-cache-unknown, usage-ledger-chart) are
  red alike on a 2d106b5c1 checkout, each filed: grip-inset #6293,
  key-balance-card de #6414, usage-cards-hide #6294,
  usage-hidden-way-back #6295, quota-curve #6789, old-webkit #6030,
  tray-cell-click #5215, usage-ledger return-to-live #4078, usage-upload
  #6743, zero-priced-free #5262.
- After the test fixes: mobile-web, panel-currency-provider,
  ledger-cache-unknown, usage-ledger-chart, usage-exact-cost, quota-holds,
  usage-unpriced-sum, currency, i18n-keys: 112 pass. The 14 reds are red
  alike on a 2d106b5c1 checkout: usage-ledger-chart's "metric is
  remembered" (filed in #6790) and mobile-web's "desktop matches
  origin/main", which needs git in the copy (mote-run has none; #5013).
- go test -run Budget ./internal/gui: ok (app.js inside appScriptBudget)

Not tried: Windows (WebView2), the reporter's own data, a real account.
2026-11-16 04:38:36 +08:00
yetone 2e1c0a377b usage: a single-account card folds to its figures, and folded cards are one size (PILIHU2023 on X)
PILIHU2023 asked for a fold on each Usage → Overview card that leaves
only the usage, with the cards all one height and width.

- A card with one account (or one key) and figures to show (windows or a
  balance) now has a disclosure chevron at the end of its head, before
  its ⋯. It reuses the per-account fold (usageAcctFold, usageAccts in
  localStorage), so its state is kept across restarts and its titles
  are the existing ones. Folded, the card keeps its windows' names,
  bars and figures. It drops resets, curves, history, the reading line
  and the auto-reset and credits rows. A plan-only card (OpenCode Zen
  Free) has nothing to fold and gets no chevron.
- Cards with several accounts keep their own folds: each account's
  chevron, and the All N accounts strip's.
- Folded cards are packed to one height: the tallest folded single
  card. A card of several accounts, each in brief, takes whole rows of
  that height. A fully folded page is a grid of one width and one
  height. Open cards keep their natural height, so nothing is stretched
  or clipped (jen_celeus, #860).
- app.js was at its budget with no room. The Usage packing block
  (packUsage and its helpers, about 3.8KB of code) moved from app.js to
  plugins/usage/page.js, which already holds the Usage page's card
  menus. app.js code is now about 3.2KB under its budget. No budget was
  raised.
- The chevron's turn uses --ease-out (cubic-bezier(.23, 1, .32, 1)),
  .15s.

What was run:
- New usage-card-fold.test.cjs: Chromium and WebKit × en, zh, zh-TW,
  ja, de, at 1400, 900 and 400px and after a reload. It folds every
  card and checks they are one width and one height, sit on whole rows
  and don't overlap. It then unfolds two cards and checks they are
  their own height again. Red on origin/main 96d1b93b2 (0 of 1 in
  chromium-en), 10 of 10 on this change.
- usage-fold (one-account case updated), usage-pack, usage-card-fold,
  i18n-keys and go test -run Budget ./internal/gui, on mica after the
  rebase on 45185710e. Everything passed except four usage-fold
  subtests. Those four ('17 subscriptions and 29 accounts' in
  chromium and webkit, 'several accounts…' in webkit en and zh) fail
  the same way alone at origin/main 96d1b93b2. Noted on #6003.
- The first version gave a plan-only card a chevron. That wrapped Zen's
  head at 897px and turned usage-pack's "head's height" check red,
  which is why the windows-or-balance condition was added.
- A 175-file GUI run (the usage-related files and i18n-keys) on mica,
  before the plan-only fix. Only account-eye was red: "a Usage card's
  eye" in Chromium. Eight parallel runs on mote give 1–3 reds each at
  origin/main too, all at the same line. Noted on #5052.
- go test ./internal/gui: ok, before the rebase.

Not tried: the real app (WebKitGTK on Linux, WebView2 on Windows) and
real accounts. Only test fixtures were used.
2026-11-15 14:04:13 +08:00
yetone 5bd41301b9 warm-up: All accounts warms every account in use at one press (CoderMaurice on X)
CoderMaurice on X: with several Claude accounts, Warm up now had to be
pressed once per account. With two or more accounts, the Warm up… menu on
the Warm up now row (a Claude Code or Codex provider's editor, the warm-up
section) now starts with All accounts. It sends POST /api/warm-all, and
provider.WarmAll sends Warm up now to every account that is in use (the
one the agent is on, or one turned on beside it) and whose windows aren't
all running already, going by the cached readings the Usage page shares.
It runs three at a time. An account that is turned off or paused, or
already in its windows, is sent nothing. An account whose sign-in lapsed
is sent nothing and is listed as failed, as Warm up now treats it. The
row's line lists the accounts warmed, the ones already in a window, and
each refusal with its reason (in red).
Accounts that are turned off aren't listed. A gateway rest is not read
(the provider package can't see it). An account rested for a used-up
window is still inside that window, so it is skipped as running.

"All accounts" moves from the usage plugin's i18n.js into core i18n.js,
since the core uses it now. It and two new strings are in zh, zh-TW, ja
and de. app.js stays inside its budget: the single-account and
all-accounts results now go through one formatter.

Run at a1968a0b5 (rebased on origin/main aecf27efb), on mica:
- go test -run 'WarmAll|WarmNow|CoreScriptBudget|Budget' ./internal/provider
  ./internal/gui: ok. New: TestWarmAllWarmsEachIdleAccountInUse,
  TestWarmAllOnlyCodexAndClaude, warm-all cases in TestWarmNowAPISaysWhy.
- Broken by hand: with the "running" skip removed from warmAll,
  TestWarmAllWarmsEachIdleAccountInUse FAILs (busy@ and spent@ warmed).
  With the All accounts item removed from the menu, warm-now.test.cjs
  FAILs ("Warm up all warms every account at one press" and the menu
  list assertion).
- GUI, Chromium and WebKit, en/zh/zh-TW/ja/de, 900px and 440px:
  warm-now, i18n-keys, i18n-en-no-cjk, usage-accounts: 54/54 pass. Before
  the rebase, plan-name-fits, provider-prefs-layout and quota-warm also
  passed (54/54 with usage-accounts).
- gofmt -l: clean. go vet, GOOS=linux go vet -tags nogui and
  GOOS=windows go vet of internal/provider and internal/gui: ok.
  go build, GOOS=linux go build -tags nogui, GOOS=windows go build: ok.

Not run: the full go test ./... and the full GUI suite. Both mote and
mica had other sessions' GUI suites running throughout, and this ships
now per the owner's ship-immediately rule. Both will run when a machine
is free. Not tried: a real Warm up all against several real Claude
accounts (the send per account is the unchanged WarmNow).
2026-11-15 11:00:37 +08:00
yetone 93762f968a usage: small, idle clients fold into one Other row
WJaunita45604 on X: test runs leave dozens of randomly named clients of
~10K tokens each in the Usage page's Agents list, and the page crawls.
renderUsage draws every Agents row again at each refresh whose summary
changed, at ~0.1ms of DOM and layout a row: with 400 clients a redraw
took 30-54ms in Chromium and 45-66ms in WebKit, with 2000 136-178ms and
224-246ms (probe at 1200px, Bun/SiYuan/translate-web and N clients).

A client not hidden folds when it is past the 5 with the most tokens,
under 1% of the period's tokens, and either made no call in the last 3
days (the agent group's new `last`) or is past the top 20; two or more
fold, or none do. No setting. Other sits at the list's foot with the
folded groups' sums (usageSum), so totals stay exact, and opens with a
click, Enter or Space; open, it draws the folded rows with their own
actions 100 at a time (Show {n} more). Closed they aren't drawn at all:
with 400 or 2000 clients a redraw now fits one frame (~13-20ms in both
engines), as with none.

Run at 442964d70 + this change, on mote (then rebased clean onto
9afec644c, which touches sync/library/update only; go test -run
'Budget|Size|I18n|Css' ./internal/gui ./internal/usage ok there):
gofmt -l clean; go vet ./internal/usage ./internal/usageapi
./internal/gui on darwin, linux (-tags nogui) and windows: ok;
go test ./internal/usage (58s), ./internal/usageapi, ./internal/gui
(137s): ok.
GUI, both engines: usage-*, i18n-*, mobile-web, own-requests and
ledger-cache-unknown files: 1740 tests, 1663 pass, 77 fail. The reds:
usage-agents-hide #6003/#3414, mobile-web #3952, usage-cards-hide
#6294, usage-range-times #6499, usage-hidden-way-back #6295,
usage-fold #3415, usage-speed-all-models #5834 fail the same way at
base 442964d70 (those 7 files there: 152 pass, 70 fail, the same
usage-agents-hide error "536.7 -> 586.98"); usage-ledger's "newest
live route needs no return-to-live button" is #5048/#6003 (the
Requests tab, which this doesn't touch); usage-chart-dates (chromium)
timed out launching the browser (180s) under load.
The new usage-agents-other.test.cjs: 33/33 (chromium + webkit, en zh
zh-TW ja de, three widths).
Perf probe at 1200px, one redraw: 400 clients 30–54ms (Chromium) and
45–66ms (WebKit) before, 2000 clients 136–178ms and 224–246ms; after,
both fit one frame (~13–20ms), the same as no clients.
Broken by hand: USAGE_FOLD_TOP=0 turns the rule test red; dropping the
100-row cap turns the page test red ("151 !== 100").
Not run: the full GUI suite (mote and mica were both running other
sessions' suites).
2026-11-15 02:51:18 +08:00
yetone 2a6ab83d8a usage: each account of a provider's card is a card of its own; the ⋯ keeps its room
normalcoder_ on X (v0.1.4079, Usage > Overview): accounts inside a provider
card were told apart by a hairline only, and the card's ⋯ was drawn over
the end of the head ("Show the other accounts in brief" was hidden).

- renderQuotas puts each account of a card with several into a
  .subscription-acct box (a provider's keys, a balance a line, stay
  lines); quotaCardMenu looks through the box for the account's head.
- The head keeps 18px for the ⋯ whether it shows or not; where nothing
  hovers, the ⋯ is always shown.
- Core budgets +57 (app.js) / +81 (core): renderQuotas draws every card,
  so there is no page to move it to.

Run (mote, both engines):
- usage-card-menu-room.test.cjs: 20/20 here; red 20/20 on origin/main
  0b8c4bfc3. usage-account-subcards.test.cjs (next commit) guards the
  sub-cards; red on origin/main too.
- go test ./internal/gui -run Budget: ok.
- ~110 usage/quota/i18n GUI files: every red is the same on origin/main
  0b8c4bfc3 and filed: usage-agents-hide (#3414), usage-cards-hide de 560
  (#6294), usage-fold webkit (#6003, #3415), usage-hidden-way-back (#6295),
  usage-ledger Requests (#5048), usage-range-times (#6499),
  usage-speed-all-models (#5834).
- usage-fold "most on one screen" is red on main (#4790, 12 chromium of
  15 wanted); with the boxes it is 11, one account fewer.

Not run: the whole GUI suite before the push; the real Linux app.
2026-11-14 23:49:01 +08:00
yetone 1ab2c39843 tray: the menu bar and panel leave out what Usage's Overview hides (onkashiko on X)
onkashiko on X: a quota hidden in the main window still showed from the
menu bar. 7ea1e6a4b made the tray panel and the TUI leave out Overview-hidden
cards and rows, but two gaps were left:

- The menu bar's cells, its tooltip and Windows' tray figure still showed a
  hidden card and its hidden rows. trayUsageCards now goes through
  trayShown: a cell naming an account takes the card the Overview still
  shows (its balance with its plan hidden), a cell following the account
  in use (`|*`) picks that account among every card as before and is left
  empty while its card is hidden, never moved to another account. Hidden
  rows are left out, a card never left with none. settings.TrayUsages is
  untouched, so the cell comes back with the card.
- POST /api/usage/arrange now wakes the menu bar (onTrayUsage) when
  cardsHidden or windowsHidden is sent, so a hide or unhide reaches it at
  once rather than at the next tick (3 minutes by default).
- The panel hid a card after keyCards had put a key's balance on its plan's
  card, so "Hide its balance from Overview" left the balance on the panel's
  plan card, and a hidden plan took its unhidden balance with it.
  panelPageCut now takes the quotas as read and leaves the hidden out before
  keyCards, as overviewCards does; gone counts a merged card hidden only
  when its plan and balance both are.

The Go hide rule (cardHideKey/usageShown) moved from internal/tui to
internal/provider (ShownQuotas, QuotaCardHidden, QuotaRowsShown,
QuotaHideKey), shared by the TUI and the menu bar. Not changed: Bark's
daily push still warns about a near-limit hidden card (an alert, not a
display). Docs: settings.go comments, docs/subsystems/gui-shell.md.

Run on mica (mote at load 117 on 18 cores), at base ee6352b63:
- go test -count=1 -timeout 45m ./internal/gui ./internal/tui
  ./internal/provider ./internal/settings: all ok.
- go vet of those packages; GOOS=linux go vet -tags nogui and GOOS=windows
  go vet of internal/gui, internal/tui, internal/provider: clean. gofmt -l
  clean.
- GUI (Chromium + WebKit, en/zh/zh-TW/ja/de): panel-hidden-balance (new),
  panel-page-hidden, panel-arrange: 28/28. panel-balance-order,
  usage-rows-hide pass. usage-cards-hide and usage-hidden-way-back are red
  at "de 560" (no sideways scroll), the same 8 on an origin/main
  ee6352b63 copy (#6294, #6295). tray-cell-click "chromium zh/en" is red
  1 run in 3 on origin/main as on this tree (#5215).
Broken by hand: panel-hidden-balance is red on origin/main's assets
(the plan card carries the hidden balance, MiniMax's balance gone);
TestTrayLeavesOutWhatTheOverviewHides is red with trayShown returning
trayPick, TestUsageArrangeWakesTheMenuBar red with the onTrayUsage call
removed.
At the pushed head (rebased on 534b1a334, which adds installdir_windows.go):
GOOS=windows go vet ./internal/gui ./internal/update and go test -run
"TestTray|TestUsageArrange|TestCoreScriptBudget" ./internal/gui: ok.
Not tried: the real menu bar on a Mac or Windows with a real account; no
full go test ./... (a full suite was running on mica).
2026-11-14 19:37:57 +08:00
yetone 7ea1e6a4b3 usage: the tray panel and the TUI leave out what the Usage page hides
onkashiko on X: a provider whose allowance card was hidden in the main
window (Usage > Overview, "Hide from Overview") still showed in the menu
bar's panel. The panel's Allowances tab had only its own Arrange list
(panelUsageHidden) and read the full cards.

Now the panel leaves out a card whose cardHideKey is in usageCardsHidden
and the rows in usageWindowsHidden (withoutHiddenRows), as Overview does;
a menu bar cell's card still shows (panelPeek). A subscription whose
every card the page hides counts in the foot's "{n} hidden" and shows as
hidden in Arrange; Show there
also drops its keys from usageCardsHidden, since the panel follows the
page. All of it is panelPageCut in the Usage plugin's page.js, which every
window loads, so the core scripts get no bigger (TestCoreScriptBudget
unchanged). Hiding from the panel alone still leaves the page as it is. The
panel reads settings again each time it is shown (loadBack), so a hide or
unhide in the main window reaches it with no restart.

Siblings: magpie tui's Usage page leaves out the same cards and rows
(usageShown, read at every quota read). The menu bar's cells and tooltip
show only the cards picked in Settings, so they keep a hidden card as
before; routing, caps and counting are unchanged.

Run:
- panel-page-hidden.test.cjs (new): chromium + webkit, en/zh/zh-TW/ja/de,
  10/10 green; red on the old app.js/panelarrange.js (cards still drawn).
- TestUsagePageLeavesOutWhatTheAppHides (new): green; red on the old
  pages.go (balance, account and row still listed).
- GUI: the 128 files that read the panel, Usage or tray code, chromium +
  webkit, every language, on mote: 17 files red, rerun alone at
  concurrency 1 here 123/449 red and at origin/main 015860f2d 122/449,
  the same tests but tray-cell-click's chromium en, which is red alone on
  main too (#5215); the rest noted on #5475. tray-cell-click + panel-arrange +
  panel-page-hidden together before the last rebase (no GUI file changed
  in it): 21 of 22, the one red tray-cell-click's (#5215). At this head
  (after the move into page.js): panel-page-hidden, panel-arrange,
  panel-balance-order and i18n-keys green; the reds in key-balance-card
  (de), panel-fold, tray-cell-click (zh) and usage-cards-hide are each
  in the origin/main 015860f2d record above.
- Full suite (go test -tags nogui -count=1 -timeout 45m ./...) on mica
  under suite.lock at 734f06b64 (this change before the move into
  page.js): 97 packages ok; internal/gui red only on TestCoreScriptBudget
  (fixed by the move), internal/gateway red from "too many open files in
  system" at mica's load ~65. At this head on mote: internal/gateway,
  internal/gui, internal/tui, internal/settings and internal/redact (the
  one commit rebased over) ok; gofmt -l clean; go vet, GOOS=linux go vet
  -tags nogui and GOOS=windows go vet ./... clean; go build ok.
- Rebased onto origin/main 667ac8bd6 (5faed634d): internal/gui (budget
  included), internal/tui and internal/settings ok on mote;
  panel-page-hidden + panel-arrange 18 of 18.
Not tried: the real tray panel by hand on a live install.
2026-11-14 14:10:24 +08:00
yetone 27c998aba0 usage: the tray panel's and Requests' costs follow each provider's currency
onkashiko on X: with Currency set to By provider, the menu bar panel
still showed every cost in one currency; providers and models were not
each in their own. drawLedColumns and drawLedRank (shared by the tray
panel and the window's Requests tab) formatted every value with no
provider, so fmtCost fell back to the Totals in currency.

- usageapi.Ledger echoes the provider a page is filtered to
  (`provider`, omitempty).
- app.js: ledProv(l, split, id) names the provider of a value: the
  ledger's filter, the row's provider (provider split), the provider
  part of a modelAt id, or for a model split the provider(s) that served
  it when they all share a currency. ledFormat/ledFormatLong take it,
  so the rank's values and sub-lines, the tooltip's rows and the axis
  (when one provider is picked) are in that provider's currency. Sums
  (the panel total, the tooltip total, a model served in two currencies)
  stay in the Totals in currency.
- page.js: the Requests head and the cost head use the filter's
  provider; the heatmap tip too. Other fmtCost calls are sums or
  sessions with no provider and are unchanged.
- core script budget +491 (1,269,040 -> 1,269,531): drawLedColumns and
  drawLedRank are drawn by the panel, so there is no lazy page to move
  this to; packed to the shortest form.
- docs/subsystems/gui-shell.md says how By provider reaches the panel.

Run:
- At 065fb6a8b (rebased on 7d5475769), mote: gofmt clean;
  TestCoreScriptBudget and TestLedgerSaysItsOneProvider ok;
  panel-currency-provider.test.cjs 20/20 (chromium + webkit x en, zh,
  zh-TW, ja, de; panel 440/320px, window 1100/420px, no sideways
  scroll, no page errors).
- At ff3ab573d (same change on 90932ed1f), mica, under suite.lock:
  go vet darwin, linux nogui, windows ok; builds for all three ok;
  go test -tags nogui -count=1 -timeout 45m ./... : 99 packages ok,
  exit 0. mote: go test usageapi, gui, usage ok.
- GUI suite, the 155 files the change can reach, mote: 2581 tests, 105
  failures in 13 files; the same 13 files give 104 at 90932ed1f. The
  one extra is tray-cell-click webkit en, flaky on both trees run
  alone (head green twice, base red once). Filed: grip-inset,
  key-balance-card, panel-fold, tray-cell-click, usage-* (#6293,
  #6294, #6295, #6499, #6003, #5872, #6414, #5869, #5796, #5215,
  #4790); panel-shortcut's 20 reds newly filed as #6606.

Broken by hand:
- panel-currency-provider on the old assets (MAGPIE_ASSETS): 20/20 red,
  with the reporter's symptom (DeepSeek $1.00, SiliconFlow $0.500
  under By provider).
- TestLedgerSaysItsOneProvider red with `out.Provider = f.Provider`
  removed.

Not tried: the real app's tray panel with real yuan and dollar
providers.
2026-11-14 12:42:46 +08:00
yetone 925bc7188b usage: the Requests card's up arrow opens what the bytes sent upstream were made of
theforeveriris (X, 2121408745616162998) saw 8169 requests send 8.6 GB
up and 1.0 GB down and wanted to know why. About 1 MB a request is
normal: every request sends the whole conversation again, with the
system prompt and the tools' definitions. This shows it.

Gateway: promptOf, which already parses the body off the request path,
now also counts the bytes of the system prompt, the tool definitions
and images in the body it read. upParts scales those to the wire bytes
and puts them on Record.UpParts. Nothing new runs on the request path,
and a body that isn't parsed stays "Not measured".

Usage: a packed row keeps the mix in 255ths under flag rowUpParts
(32768); the row stays 152 bytes. Totals gain up_calls, up_measured,
up_system, up_tools and up_images, and Shares carry up_bytes and
up_calls by agent and by model. settledCountVersion goes 4 -> 5, so
settled days are counted again once on the next start.

GUI (Usage -> Requests): the "↑ 8.6 GB" on the Requests card is a
button that opens a "Sent upstream" card: the average per request, one
sentence on why, a bar and legend for Conversation / Tool definitions /
System prompt / Images / Not measured, and the top 8 agents and models
with bytes sent and per request. The open state is kept; × closes it.
A request's details get a "Made of" line. zh, zh-TW, ja, de strings.
Entrance is 200ms ease-out, no movement under reduced motion.

Run (mote, at this head on 27e43ed26):
- go test ./internal/usage ./internal/usageapi: ok
- go test -run 'Prompt|UpParts|UpBytes|DownBytes|Traffic|Ledger|
  CodexOwnTurn' ./internal/gateway: ok
- go test -run Budget ./internal/gui: ok (after the rebase)
- go vet -tags nogui for darwin, linux, windows on usage, gateway,
  usageapi, gui: ok; gofmt -l clean
- GUI: usage-upload.test.cjs 32/32 (chromium + webkit, 1180 and 420,
  en zh zh-TW ja de); with i18n-keys, i18n-en-no-cjk,
  usage-ledger-bytes, usage-traffic, usage-ledger-detail: 144 pass,
  0 fail
- GUI subset i18n*, usage*, ledger* at f1f34d624: the only reds are
  usage-agents-hide, usage-cards-hide, usage-fold,
  usage-hidden-way-back, usage-ledger, usage-range-times and
  usage-speed-all-models. They are red the same way on origin/main
  f1f34d624 without this change and are already filed (#3414, #3415,
  #6003, #6294, #6295, #6499, #5834).
- Screenshots of the card: chromium en 1180 light, webkit zh 1180
  dark, chromium zh 420 light.
- Benchmark: promptOf on a 1.17 MB body, 2.8-3.9 ms/op with counting
  vs 3.2-3.7 without, same allocations (noise).
- Broken by hand: without the b.again guard,
  TestPromptKnowsWhatItsBytesWere goes red.

Not run: the full go test ./... and the full GUI suite. mote and mica
were loaded, with a suite already queued under suite.lock.
2026-11-14 10:22:25 +08:00
yetone 57dc64ba12 usage: the Overview's lists rank by tokens, cost, calls or name (onducoder on X)
onducoder asked for a ranking of Usage › Overview's Agents, Models,
Gateway keys and Accounts by what each used. Each list's heading now
ends in a quiet pick (the order's name and a chevron) that opens the app
menu: Tokens (the default, the server's order), Cost, Calls or Name.
By tokens the list stays in the server's order (most tokens first,
the cache left out) unless "with cache" is on, when the cache counts
too; other orders fall back to tokens, then calls. By cost, a row
with no price goes last; by name, a row with no name goes last. Each
list keeps its own order in localStorage (magpie.usageSort), and a
folded list hides its pick. The code is in the
Usage plugin (page.js, its i18n.js); "Calls" is a core word, since other
files say it. The core script doesn't grow (TestCoreScriptBudget passes).

gateway-caller-keys and usage-accounts read the heading's .label, since
the heading's text now includes the pick; mobile-web takes the picks out
until BASE_REF has them.

Run: usage-sort.test.cjs (new; chromium and webkit, en zh zh-TW ja de,
1100 and 420 wide). On mica, with the next two commits, these files at
this head and at origin/main 783b69b8c: gui-de gui-ja gui-zh-tw i18n-keys
mobile-web phone-no-sideways usage-agents-hide usage-cards-hide
usage-count-client usage-fold usage-hidden-way-back usage-hit-rate
usage-ledger usage-range-times usage-speed-all-models, plus usage-sort,
gateway-caller-keys, usage-accounts and usage-overview-fold at this head
(333 tests). Red at both, and filed: phone-no-sideways (#5869),
usage-agents-hide (#3414), usage-cards-hide (#6294), usage-fold
(#3415), usage-hidden-way-back (#6295), usage-ledger (#5048),
usage-range-times (#6499), usage-speed-all-models (#5834). Everything
else passes. A first version re-sorted the server's list on the default
order too, which moved rows in usage-hit-rate and usage-count-client's
fixtures; the default keeps the server's order now, and both pass.
usage-*, panel-usage*, phone-* and gui-* ran on mote earlier;
TestCoreScriptBudget ok on mote at 783b69b8c. Rebased on 92e760f3d:
gui-de gui-ja gui-zh-tw i18n-keys mobile-web usage-sort
usage-overview-fold gateway-caller-keys usage-accounts usage-hit-rate
usage-count-client model-key-tag library-subagents-import, 187/187 on
mica; TestCoreScriptBudget is red there on main's own app.js (#6518,
1269382 > 1268961), the same without this change, which adds nothing to
the core.
Broken by hand: against origin/main's assets usage-sort is red (22
cases); with usageSorted returning the list unchanged, 11/11 order cases
fail.
Not tried: the real app, Linux WebKitGTK. The full GUI suite run on
mote was stopped part-way (its copy was replaced by a second run of
mine); its reds outside these files are main's (e.g. #6543, #5869).
2026-11-14 09:31:24 +08:00
yetone 817d35ffa9 usage: a window's whole follows the tokens pick's With cache (Anotiaww on X)
@Anotiaww asked (X 2121248031983194214) that the account cards' "Whole ≈ N
tokens" on Usage → Overview follow the page's tokens pick. With cache, it
now adds the window's routed cache read and written, scaled by the same
share used as the input and output; the line reads "Whole ≈ N tokens with
cache" and its tooltip says cache is included. Without cache nothing
changes. Changing the pick redraws the cards. The tray panel shows no
holds line, so it has nothing to follow.

holdsLine and holdsUnknownLine move from app.js into the Usage plugin's
page.js, beside usageWithCache, so the core script budget stays as it is
(it had 14 bytes left). quotaWindows still calls them as globals. New
words are said in zh, zh-TW, ja and de.

Run (mica, both engines, every language):
- quota-holds, i18n-keys, i18n-en-no-cjk: 16/16 ok. The new quota-holds
  test (pick With cache at 360 and 1000px, reload keeps it, pick back)
  went red in both engines with the cache left out and the old words, and
  again with no redraw on pick.
- 185 GUI files that reach Usage or quotas, plus mobile-web, idle-ticks,
  old-webkit and every i18n file, concurrency 3. Reds: account-eye,
  account-mask, account-refresh-holds, claude-quota-onboarding,
  codex-auto-reset (de), key-balance-card (de), menu-scroll, mobile-web,
  old-webkit, quota-count-wrap. The same files are red at the base
  ac0b5c287 without this change (quota-count-wrap 1100px cut, alone), and
  each is filed (#5052, #3951, #5814, #6179, #4790, #6414, #6532, #3952,
  #6467, #3404).
Run (mote): go vet, GOOS=linux vet -tags nogui, GOOS=windows vet, builds;
go test -tags nogui ./internal/gui (TestCoreScriptBudget), ./internal/provider,
./internal/usage ok.
Rebased on 077421733, where 5211fd3ba gave holdsLine a provider's
currency (prov); page.js carries it. At this head (mica): quota-holds,
quota-curve, currency-provider, currency, i18n-keys, i18n-en-no-cjk,
quota-count-wrap 80/83; the reds are quota-count-wrap (#3404, red at
077421733 too) and quota-curve chromium en/zh (#4768), which passes 31/31
alone here and at 077421733. go test -tags nogui ./internal/gui (budgets) ok.
Not run: the full go test ./... and the full GUI suite (both machines were
loaded); the only Go change is a comment.
2026-11-13 23:12:48 +08:00
yetone 5211fd3ba2 usage: a currency "By provider" shows each provider's costs in what it sells in
onkashiko on X: DeepSeek, Kimi (China), Zhipu and other domestic vendors
price in yuan, the rest in dollars, and one currency for every cost made
the Usage page read wrong for half of them.

Settings > Usage > Currency gains a third choice, By provider. With it,
a figure of one provider's calls (a model's, an account's, a key's row,
a request, a routing try, a quota card's whole) shows in the currency
that provider sells in, and every sum across providers (the total,
agents, sessions, charts, the tray, Bark's daily, the day page) in the
currency a "Totals in" row picks, a row shown only while By provider is
chosen. GUI, TUI and CLI agree. Costs stay stored in dollars; only the
display converts, at the live rate (internal/fx).

Which providers sell in yuan (provider.PricesInYuan): a .cn host; a
preset at its own site that is a yuan preset (deepseek, zhipu,
volcengine, tencent-cloud, bailian, siliconflow…), ends in -cn, or is in
its China region; a plugin id ending in -cn; a provider of one's own
with a yuan models.dev catalog served at that catalog's site. A relay
made from DeepSeek's preset, Z.ai, Kimi's and MiniMax's international
endpoints stay in dollars: they share a catalog with their Chinese
twins, so the catalog alone can't tell.

Known limit: models.dev has only dollar prices (converted from the
vendors' yuan at ~6.7-7.0), so a yuan figure is that dollar price at
today's rate and can differ a few percent from the vendor's own list.

A second ask from onkashiko: set the currency of the menu bar and of
the totals apart, sums converted by themselves.

So Settings > Usage also gains an Advanced fold (closed by default, open while
set) with one row, Menu bar currency: Same as totals (the default), $ or
¥ (settings.TrayCurrency, TrayCostIn). It sets the menu bar's totals
cards and the tray tooltip's cost; the Usage page, the panel, the TUI,
the CLI and Bark's daily message stay in the totals' currency
(totalsCurrency). Like the other menu bar settings it stays on this
computer (KeepOwn). Every sum is still made in dollars and converted
once, at the live rate, so a mixed-currency total is never added up
from yuan and dollars.

Settings' currency rows (Currency, Totals in, Menu bar currency and the
rate in the tooltip) moved out of app.js into currencyprefs.js, imported
when Settings draws its usage prefs, and costInYuan is packed: the core
is 3 bytes under coreScriptBudget, with no raise.

Run:
- go test -count=1 at this tree on mote: internal/settings,
  settingsapi, tui, cli, catalog, provider, fx and gui all ok
  (TestCoreScriptBudget included). The full go test ./... and the whole
  GUI suite are queued behind other sessions' suites on suite.lock
  (mote and mica, load 35 and 60) and had not started at push.
- GUI files at this tree (mica): currency-provider, currency, i18n-keys,
  i18n-en-no-cjk, tray-cost, tray-totals, every settings-*, old-webkit:
  362 pass, 28 red. Every red is red the same at origin/main ac0b5c287
  on mote, and filed: settings-search (#6133, #6353), settings-hints
  (#6107, #6353), settings-lines-wrap de 440px (#6353), old-webkit
  appearance.js (#6467) and :has() (#5919). The one red of this change,
  settings-groups' list of Usage's parts (now with the Advanced fold),
  is fixed here: 14 of 14.
- currency-provider.test.cjs (new): en, zh, zh-TW, ja, de at 900 and
  420px, both engines; By provider, Totals in ¥, then Advanced: $ for
  the menu bar with totals in ¥, totals stay ¥21.60, the fold opens
  itself after a reload. Plus currency.test.cjs (3 choices now),
  i18n-keys, i18n-en-no-cjk, tray-cost: green in both engines.
- TestTrayCostIn (values, refused eur/provider, KeepOwn),
  TestFXByProvider (trayCurrency vs totalsCurrency), TestCoreScriptBudget.
- gofmt -l clean; GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./..., GOOS=linux go build -tags nogui,
  GOOS=windows go build on mote at this tree: ok.
- Broken by hand, each red: costInYuan ignoring the provider (GUI
  test: deepseek showed $1.00 for ¥7.20), PricesInYuan without the
  preset's site check (a relay made from DeepSeek's preset read as
  yuan), CostIn without its By provider branch (settings test),
  TrayCostIn ignoring TrayCurrency (TestTrayCostIn, TestFXByProvider),
  the fold not opening while set (webkit), the row saving into
  totalCurrency (chromium).
- Real app in a sandbox HOME on mote (dev build, magpie web and magpie
  usage) with DeepSeek, OpenAI and Z.ai presets and one call each: the
  window and the CLI both show deepseek-v4-pro ≈¥15.44, gpt-4.1 ≈$1.00,
  glm-4.6 ≈$0.290 and the total ≈¥24.07 at 6.685; /api/settings' fx
  carries yuan ["deepseek"].
Not tried: Windows and Linux windows and trays, the real menu bar with
Menu bar currency changed (drawn natively; covered through trayCurrency
in Go), a real Kimi CN or Zhipu account.
2026-11-13 22:46:00 +08:00
yetone 5d54a990d4 usage: switched-off providers' accounts can be checked in, and Check in all (wxkwxk666 on X)
wxkwxk666 asked for two things on the Usage page. First, a provider
switched off should still show its accounts, at the bottom and folded,
so they can still be checked in each day. Second, one button should check
in every account at once.

- provider.OffCheckins (off_checkins.go) lists every account a
  checkiner reaches whose provider is switched off (Off, not Hidden).
  Each is a card with no windows. Nothing is read or asked for it. Its
  check-in result is matched by its own key, not by its name, since two
  sign-ins can share a name (plugins#254).
  GET /api/usage/checkins/off serves the list.
- The Usage page (plugins/usage) adds a "Switched off · n" line after
  the cards and the hidden line. It is folded until clicked. Each
  account shows today's check-in, and a Check in button when it isn't
  checked in yet. The button uses checkinnow.js's ciNowSend, which
  POSTs /api/usage/checkin-account.
- Check in all, at the head of the allowances, presses every account
  not checked in today, from the cards and from the switched-off line.
  It sends one checkin-account request per account, three at a time,
  shows "Checking in i/n…", then gives the counts (checkinPressSaid).
  When no account is due, it says so and sends nothing.
- Nothing switches a provider back on. The new strings are in zh,
  zh-TW, ja and de. Plugin files only: app.js is unchanged.
- docs/subsystems/provider-plugins.md says all of this.

Run, on mote:
- TestOffCheckinsListsSwitchedOffAccounts, in the fakeco plugin
  sandbox:
  - nothing is listed before the switch-off;
  - after it, two cards with distinct keys;
  - a press on one checks in exactly that account;
  - the provider stays off;
  - only the pressed card carries a result;
  - nothing is listed once the provider is switched on.
- go test ./internal/provider ./internal/gui, at this commit on
  origin/main 0fda3a1c1: gui ok; provider ok but for
  TestHostBuildsNoList, red on main already (#6479)
- gofmt
- go vet for darwin, linux (-tags nogui, ./...) and windows
- usage-checkin-all.test.cjs, in Chromium and WebKit, at 900 and
  420px, in en, zh, zh-TW, ja and de (20 of 20). It covers:
  - the line is folded, at the end, with its count;
  - opening it doesn't scroll;
  - a row's own press asks for that account only;
  - Check in all shows 0/2 while held, presses only the two due
    accounts, and POSTs nothing else (no provider switched on);
  - a second press asks nothing and says every account is in.
- 187 GUI files (the Usage page, panel, tray, settings and their
  neighbours), at the rebased head on mote: 3080 cases, 104 red in 16
  files. Those 16 run again on mote at origin/main 5a2d0ff47 and at
  this commit, under the same load: the same 12 files are red on both
  (checkin-now-account #6029, codex-auto-reset #4790, key-balance-card
  #6414, menu-scroll #5982, mobile-web #3952, old-webkit #6030,
  quota-refresh-order #6180, tray-cell-click #5215, usage-cards-hide
  #6294, usage-fold #4790, usage-hidden-way-back #6295,
  usage-range-times #6499, filed now). account-eye, i18n-keys,
  last-page and quota-warm pass on both in that rerun.
- That wide run found account-alias and account-eye red on an earlier
  draft: a fixture answering {} for the new endpoint made the page
  spread a non-array. The page now takes only an array.

Broken by hand:
- Without checkinAll's not-due skip, all 20 GUI cases go red.
- Without OffCheckins' check-in result (q.Checkin), the Go test goes
  red at off_checkins_test.go:56.
- Matching results by name (WithCheckins), as an earlier draft did,
  also went red.

Not tried: checking in a real switched-off vendor account through the
real app. The press is the existing CheckInAccount path, the same one
Settings' per-account Check in now already uses.
2026-11-13 16:56:19 +08:00
yetone d370bef982 usage: Failed lists the requests a fallback answered, as Routing shows their tries failed (maohy915 on X)
maohy915 runs magpie on a NAS and uses it from another computer's magpie
through Remote magpie. The NAS's Routing page showed failed calls, but
Usage → Requests → Failed found none. Reproduced with two sandbox
instances on mote (B → remote-magpie → A, where A's provider `bad`
answers 429 and falls back to `good`). A's trace had 2 requests and 1
rerouted. Usage had 2 rows, Failed had 0 and Retried had 1. A try that
fails and is handed on writes no row when nothing is billed, and its
request's row is an answer on the second try. Failed kept only
LostRequest, the requests whose agent got the error, so the failed try
was nowhere under Failed. Plain failures, remote or not, were already
listed; only rerouted ones were missing.

Failed now keeps every request a try failed on (Record.FailedTry): the
requests the agent got an error for, the tries handed on, and the
requests a later try answered. Retried still keeps only the answered
ones. The counts are unchanged: each request is counted once, by how it
ended (小一's rule), so a Failed list reads "1 failed · 2 answered on a
retry". The Failed option and the card's "N failed" button now say so in
their tooltip, in every language. Filtered page cells are cached on disk
under the filter, so settledCountVersion goes to 4; the first start after
the upgrade pairs the history again once.

Run (mote):
- go test ./internal/usage ./internal/usageapi ./internal/gui: ok.
- New test TestFailedKeepsRequestsAFallbackAnswered; updated
  TestRequestsCountedOnceWithTheirRetries.
- GUI, both engines: ledger-retried (5 languages, 420/1100), i18n-keys,
  i18n-en-no-cjk, usage-ledger, api-key-usage, purpose-filter,
  usage-ledger-content, usage-phone-head, usage-loops, usage-request-page.
  All pass except known reds: i18n-keys "a plugin's words are its own"
  (#6422/#6423) and usage-ledger "newest live route needs no
  return-to-live button" (#4078/#3104/#4626).
- gofmt; go vet for darwin, linux -tags nogui, and windows.
- Real repro with a binary built from this tree: A's Failed went from 0
  rows to the rerouted request, both in the API and in the real page
  (Chromium).

Broken by hand:
- Filter back to LostRequest: both Go tests red.
- The Failed option's title dropped: ledger-retried red.

Not tried:
- Restoring settledCountVersion to 3 doesn't turn
  TestSettledCountedAsVersioned red: it counts only Filter{}. The bump is
  by reading.
- Not tried on a real NAS or in the desktop app's remote window; the
  page is the NAS's own web page.
2026-11-13 14:17:49 +08:00
yetone 76ceff87c9 usage: a number of hours the reader sets, beside the calendar (eachg0 on X)
The range menu behind Custom has a top row, "[N] hours back". Enter asks
the Usage page for the rolling window last:Nh (1 to 720), which the
backend already answers for every view (totals, chart, models, accounts,
Requests); the chip reads "Last 30 hours". The pick and N are kept on this
device (magpie.usagePeriod, magpie.usageHours). 24 stays the preset's
chip, and an empty page, the credit days and the menu-bar way in know the
new period. zh, zh-TW, ja, de strings added.

Run (mote, at the rebased head): usage-hours, usage-24h, i18n-keys in
chromium and webkit, en and zh. Broken by hand: keptPeriod limited to the
presets turned usage-hours red (expected last:30h, got today).
Not tried: the whole GUI suite (queued on mote's suite.lock behind other
sessions, still running), narrow widths by hand, the tray panel (it has no
24h chip and is unchanged).
2026-11-13 01:00:14 +08:00
yetone 6edf7a69e5 usage: hide and show single quota rows of an Overview card (wangshaowei39 on X)
Antigravity's card lists Claude & GPT, Gemini and more. A row group can now be
hidden from Usage > Overview the way a card can: right-click or long-press a
row, or use the card's "..." menu, and choose "Hide <group> from Overview". The
"Hidden" line under the cards lists hidden cards and rows with an Unhide button
and Show all. The last group of a card cannot be hidden (use the card's own
hide). Persisted as settings usageWindowsHidden ("<card>|<group>"), changed
through /api/usage/arrange { windowsHidden } and kept by the Settings save.
Table view and tray panel are untouched.

Run (on mote):
- go test: TestUsageArrange*, TestUsageArrangeWindowsHidden (new), TestSettingsSave*,
  settings_keep guard, TestCoreScriptBudget, ./internal/settings, ./internal/settingsapi;
  gofmt clean; go vet darwin, linux nogui, windows.
- GUI, chromium and webkit: usage-rows-hide (new, 5 languages x 1200/560/390;
  32/32), usage-card-more 32/32, usage-arrange, usage-all-accounts 24/24,
  i18n-keys 4/4.
- usage-cards-hide and usage-hidden-way-back: "de 560" red (no sideways scroll
  635 vs 560); the same red on a clean origin/main a5e5f539a, filed as #6294.
Broken by hand: withoutHiddenRows returning its input turns usage-rows-hide
16/16 red in chromium.
Not tried: a real Antigravity account (fixtures only); full suite starts after
the tag.
2026-11-12 23:45:43 +08:00
yetone cfd3367df8 usage: a request's details show its service tier (JackyFill on X)
The ledger has kept each call's service tier since #1784 (tier_asked,
tier_sent, tier_served in the log, the CSV and the JSON), but the
Requests page never showed it. A request's details now have a Service
tier line: "asked X", then "sent Y" only when it differs, then
"answered Z" only when the reply named a tier. A call with none shows
no line. Row flag bits are untouched: the tiers are string slots, so no
bit is taken.

Run, on mica: new ledger-service-tier.test.cjs (3 rows: all three tiers,
asked+sent without an answer, none) in chromium and webkit, en zh
zh-TW ja de, 12 of 12 green; with the add("Service tier") line removed
by hand it is 0 of 12; i18n-keys caught a duplicate "Service tier" key
(the core table already has all four languages), which is removed;
ledger-*, i18n-keys, i18n-en-no-cjk and gui-* files rerun green after
(ledger-cache-hit chromium was red once in the first batch, green on
rerun in the same batch's second run).

Not tried: a real Codex priority call end to end (the gateway side is
#1784's); the full suite runs after the tag.
2026-11-12 17:22:03 +08:00
yetone c14fa0ce93 Bring back 919780414 and 88d2962e0, which 698ed4adb undid
698ed4adb (a busy port names its holder) was committed from a tree made
before 919780414 and 88d2962e0 landed (09:38, eight minutes before it),
and took both out with no word in its body: quotatable.js, the Usage
Cards / Table switch and its test, and sessions' 16-byte head and
prefix hashes (digest.go) were gone from main from v0.1.3823. This puts
both back as they were, on top of 698ed4adb's own change, which is kept.

Run at this tree, on mote (cherry-pick of both onto origin/main
db0c1b039, no conflicts):
- gofmt -l internal/sessions: clean.
- go vet ./internal/sessions ./internal/gui; GOOS=windows and
  GOOS=linux -tags nogui go vet ./internal/sessions: ok.
- go test -count=1 ./internal/sessions: ok 83.6s.
- go test -run 'Budget|Lazy|I18n' ./internal/gui: ok (the core script
  budget holds with both changes).
- GUI, chromium and webkit: usage-quota-table, gateway-port-holder,
  i18n-keys, i18n-en-no-cjk, old-webkit: 44 of 46. The two reds are
  old-webkit's "compat.js is the first" (headerpresets.js, #6030) and
  "the styles hold up in Safari 15.0" (#5919), red the same on an
  origin/main db0c1b039 copy.
Not run: the full Go and GUI suites.
2026-11-12 09:57:52 +08:00
yetone 698ed4adb5 gateway: a busy port names the program holding it, and Tailscale's serve gets its fix (pluoki on X)
The Gateway page, `magpie serve` and the app log said only "port N is held by another program". pluoki's was `tailscale serve` on the same port number.

proc.PortHolder reads the holder (lsof on the Mac, /proc on Linux, Get-NetTCPConnection on Windows). Tailscale's daemon is root's and often unreadable, so `tailscale serve status --json` is the fallback for the port. gateway.NoteHeld / PortHeld.Sentence say who holds it, and for Tailscale give `tailscale serve --https=<other> http://127.0.0.1:<port>`. Shown in the `magpie serve` standby line and bind error, the app log, `gatewayHeld` in /api/state (Gateway page) and Start's "taken" answer, in en, zh, zh-TW, ja, de. A holder that can't be read says nothing; the old wording stands. Nothing is killed or touched.

Run: gofmt clean; go vet darwin, linux nogui, windows (mica); go test ./internal/proc ok; targeted holder/gateway tests on macOS (mica), Windows (win-run) and Linux (wsl-run); parser tests with real lsof output; GUI gateway-port-holder, gateway-takeover, gateway-older, gateway-skew, gateway-port, i18n-keys, i18n-en-no-cjk in chromium and webkit. Real run on WSL: a holder named tailscaled on the LAN address with magpie on 0.0.0.0 gives the Tailscale sentence at the bind error; a Python holder on loopback gives "held by python3.12 (pid N)".
Broken by hand: each fix reverted in turn, its test went red.
gateway-card.test.cjs is red on origin/main too (#6029). internal/gateway, gui and cli package runs were still going at push; the full suite follows the tag.
Not tried: a real `tailscale serve` (changes live config), a real Windows holder end to end, the bind-error path on macOS (a wildcard bind coexists with a specific one there).
2026-11-12 09:46:34 +08:00
yetone 9197804144 gui: Usage allowances can be shown as a table beside the cards (zysicyj on X)
With a dozen accounts the packed card grid is hard to scan. The Usage
page's Allowances header now has a Cards / Table switch (a segmented
control, remembered per user in localStorage "quotaView"; the default stays
Cards, and nothing is written until the user picks). The table has one row
per account: subscription, account, then the four most common windows
(used % with a bar and the reset time), an Other column for extra windows
and balances, sortable by any column (click again to reverse, a third
time to clear; rows with no value stay last). Balance-only and error rows
span the window columns. Same data and helpers as the cards (quotaFill,
resetClock, quotaWho). At narrow widths the table box scrolls, not the page.

The code is a lazily imported quotatable.js, so app.js stays inside its
code budget. "Cards" and "Table" are translated in zh, zh-TW, ja and de.
quotatable.js is listed in old-webkit's lazy-script exceptions;
docs/subsystems/gui-shell.md has a paragraph on it.

Run (on mica/mote, Playwright): the new usage-quota-table.test.cjs, 22 of 22
in chromium and webkit, in en/zh/zh-TW/ja/de, at 1100px and 420px (14 faked
accounts: default is cards and saves nothing, row count and figures,
persistence across reload, sort cycle and account sort, no page overflow,
back to cards). TestCoreScriptBudget, i18n tests 8/8, gofmt, go vet for
darwin, linux -tags nogui and windows. Whole GUI suite (make test-ui)
at 1ad0f4cc4+this: started before the tag; first 890 results green except account-arrange (#6010, red the same on origin/main).

Broken by hand: with the default flipped to table, 10 of the new tests
failed; restored.

Not tried: the real app, Linux WebKitGTK, a real account's data (the
fixtures are faked, with the shapes the cards read).
2026-11-12 09:38:54 +08:00
yetone e6bf4adf1f usage: Claude Code's helper requests are labelled, the largest cache write is one click away (recih on X, #6199)
Claude Code's AgentSummary and its auto mode classifier name themselves
nowhere in the request, so there is no client marker to read. The gateway
tells them by their content (inferredKind: a claude-cli/ request on the
Messages API; the classifier by autoModeClassifierAsk, the summary by its
last user text "Describe your ... in 3-5 words") and records them as
agent_summary_inferred and auto_mode_check_inferred. The purpose catalog
names them "Progress summary (inferred)" and "Auto mode check (inferred)"
and puts each with its plain kind's purpose, so the existing Purpose filter
lists both; nothing known and nothing inferred share a name. A tool that
printed the same words, a chat, and another agent's request stay unmarked.

A requests page now also holds BigWrite, the gateway-served row that wrote
the most to the cache (cells, page-v1.json and pageFromLedger all carry it;
rows from session files have no request to open). The Requests line shows
it as "109K largest write", a button that opens that request through
openUsageRoute. settledCountVersion is raised to 3, which keys the cached
pages.

Not done: the per-request branch recovery result asked for in #6199. No
structured field holds it.

Run on mote (load 21-24 of 18 cores, mica was higher): go test ./internal/usage
./internal/usageapi, the gateway and gui purpose tests, go vet for darwin,
linux (nogui) and windows, gofmt; the GUI files usage-big-write (new),
purpose-filter, routing-kind, i18n-keys and usage-ledger in chromium and
webkit. Broken by hand: inferredKind returning "" turns
TestClaudeHelperRequestsAreLabelled red; the larger-than test of BigWrite.add
turned round turns TestRequestPageBigWrite red on both paths; the jump off
turns usage-big-write red. Not tried: a real Claude Code session against a
live subscription, Linux WebKitGTK.
2026-11-12 02:01:31 +08:00
yetone da169135a0 usage: an empty page says session files aren't read yet, and allows them (simonzyzy on X)
Claude Code's and Codex's sessions, and each call's tokens and time, need no provider: with the consent given, a sandbox HOME with no providers lists both agents' sessions and /api/usage/requests returns their calls (source log, ms, tokens). The only gate is sessions/reads asked=false, which the Sessions page asks but the Usage Overview and Requests pages did not mention; they said to point an agent at a catalog model. Now they say the files aren't read yet and offer one button that allows the agents found. The Sessions page says live output speed is measured only on gateway requests and where the files' own figures are.
2026-11-11 21:49:11 +08:00
yetone 50ce30d56e gui: times follow the system's 12 or 24 hour clock (iXerol on X)
An en-US Mac set to 24-Hour Time showed Routing's request times in 12
hours: no webview hands the page the system's clock, and navigator.language
carries only the region. boot.js now says it as hourCycle ("h23" or "h12",
left out when the system names none, and for a browser tab, which keeps its
own): macOS from AppleICUForce24HourTime / AppleICUForce12HourTime, Windows
from Control Panel\International sTimeFormat, Linux from gsettings
clock-format. intlLang() adds -u-hc-<cycle> to its tag, so every formatter
that takes it follows, and the places that forced 24 hours (hour12: false,
hourCycle h23) spread hourClock() instead: 24 unless the system says 12.
Read once per 30s, so a change in System Settings shows at the next load.

Run on mote: new hc-clock.test.cjs (en-US on a 24h system, en-GB on a 12h
one, a silent system), chromium and webkit; Go tests for the three readers
and boot.js; gofmt; go vet darwin, windows and linux nogui; internal/gui
tests; GUI files of gui-*, i18n-*, panel-*, quota-*, reset-*, routing-*,
usage-* in chromium and webkit. TestCoreScriptBudget was over by 77 bytes
and passes with two app.js comments cut, no raise.
Broken by hand: hc-clock goes red (2 of 3) without the intlLang suffix.
Not tried: a real Windows or Linux session's setting (the readers are
unit-tested on their formats), a live Mac.
2026-11-11 04:13:38 -08:00
yetone 31f75dddac i18n: de and ja say a placeholder once where their English key does
8a3dbf023's accounts-list sign-in line had {agent} twice in de and ja, and the
Usage plugin's model-price line had {model} twice in ja. gui-de and gui-ja
'has every zh string, with its placeholders and tags' were red on origin/main
5c02be05b (found while running the balance change's GUI files).

Run: gui-ja, gui-de, gui-zh-tw, i18n-keys via wsl-run, 13 pass 0 fail.
2026-11-11 16:33:41 +08:00
yetone 88c417392e usage: a sortable model speed ranking on the Requests tab (@flying_crp on X)
Usage's Requests tab gets a "Model speed" card: per model, the median output tokens/s, the median wait for the first token and the request count, over the selected range, sortable by every column (aria-sort header buttons, quiet table, no gradients). A request counts when it was answered (not rejected, handed on, failed or canceled), its first token was timed and it wrote 100 tokens or more (usage.MinRankTokens; the tooltip says so). Computed locally: each chunk keeps a 2% log-bin histogram per model beside its cells (speed_rank.go, chunkPart.speeds), a page merges the chunks' histograms, so there is no per-request sort and medians are within ~1%. The settled chunks' histograms are in the page file; its key salt is now page-v2, so the first load after upgrade recounts settled history once. /api/ledger sends speeds and speed_min.

Run (mote): gofmt clean; go vet darwin, linux nogui, windows for the touched packages and ./... earlier; go test internal/usage, internal/usageapi, internal/gui ok at this head; usage-model-speed.test.cjs 12 of 12 (chromium and webkit, en/zh/zh-TW/ja/de, 400px: order, sort by every column, aria-sort, focus kept, no horizontal overflow, ellipsis, hidden when empty); with i18n-keys and i18n-en-no-cjk 20 of 20; the whole GUI suite once on the branch before the rebase: every red is in a file unrelated to this change (account-arrange #6010, account-refresh-holds #5814, account-eye #5052, agent-switch-accounts #5925, bulk visibility and disconnect previews #5982 fixed in e430e2750, accounts-own-signin #6038), each red alone on origin/main 71a68639b or load-only.
Timing: 1M requests added to a chunk in ~185ms (TestModelSpeedRankAtTheLargestLedger).
Broken by hand: dropping the Failed/Canceled exclusion (gpt: 5 requests, 59.7 tok/s) and dropping the page's merge of chunk speeds (ranking empty) each turned the new tests red; restored.
Not tried: the real Linux app (WebKitGTK), a real ledger of hundreds of thousands of rows through the page-v2 file, a Windows run (win-run).
2026-11-11 10:12:23 +08:00
yetone ae449f8e4f gui: the sidebar's tab lists give each tab a mark of its own
Library's, Usage's, Plugins' and Settings' tabs, listed under their page
in the sidebar (navSubs), were names alone while every page above them
has an icon (the owner, with a screenshot of Library's list). Each tab
now has a 14px line mark before its name, from NAV_SUB_IC by page and
tab id: segs gives its buttons data-seg (Usage's own strip too), and
Settings' tabs have data-set. A tab with no mark (none today) keeps an
empty slot, so the names stay in one column. The mark is muted, and
takes the row's ink when the row is hovered or picked.

The marks are in navicons.js, imported with the first list drawn, which
then draws again with them. Its one line in app.js is paid for by two
navSubs comments cut, so the core's script budget is not raised
(1,533,751 of 1,533,802).

German's longest Settings names ("Synchronisierung und Backup") were
cut with an ellipsis at 1100 before this; "Netzwerk und Freigabe" now
is too (7px). Left as is: shortening the word would change it in five
other German sentences that name the tab.

Run:
- nav-sub-icons.test.cjs (new): every row of the four lists has its
  mark, 14px, before its name and level with it, one column per list,
  names whole (not German); en zh zh-TW ja de, Chromium and WebKit, on
  WSL (magpie-desktop): 12 of 12. Red with Library's memory mark taken
  out by hand ("library: Memory has a mark").
- go test ./internal/gui on Windows: 8 reds, the same 8 alone on
  origin/main b46f23ffa (#4115, #5928, #5324; TestCherryStudioImportRow
  added to #4115).
- At this head, on origin/main b50910fee, on mote: 27 GUI files a
  sidebar list, a tab strip or a core script reaches (nav-sub-icons,
  nav-sub-unroll, nav-lamp, sidebar*, side-width, side-toggle,
  settings-sections, settings-tabs-stick, settings-back, segs-glide,
  segs-press-redraw, plugin-pick-sub, plugins-more-discover,
  plugin-updates, usage-refresh, library-items, library-bili, i18n-keys,
  i18n-en-no-cjk, click-scroll, readable-focus, icon-one-tone,
  old-webkit), both engines: 588 of 590. The 2 reds are old-webkit's,
  red the same alone on b50910fee: headerpresets.js unlisted (#6030,
  filed now) and .side-foot:has() (#5919). go test ./internal/gui
  -run 'Budget|Core': ok.
- settings-search is red on b50910fee alone too (the window's
  /api/update/using in its strict list, commented on #5982), so it was
  left out of the run above.
- Not run: the whole GUI suite (mote's suite.lock queue is ~30 deep)
  and the whole Go suite at this head.
2026-11-11 08:31:16 +08:00
yetone 40ca0c88de gui: a model's price is set from the Usage page (soilzhu80 on X)
A model an agent runs is often in no provider's list, so no provider's
Model settings could price it. A model's row on the Usage page (its "…"
or a right-click) and its bar in the Sessions tab's Models card (a
right-click) now offer "Set price…": a sheet with input, output, cache
read and cache write in $ / 1M tokens, the maker's list price greyed in
the empty boxes. It sets the model's price from any provider (*/model),
the key `magpie model price '*/model'` writes, through GET/POST
/api/model-price (modelprice.go). A provider's own price for the model
still comes first. Restore default takes the price away. Sessions' stats
are forgotten on a save, so past calls are counted at the new price too.
A Sessions bar prices the id after its last "/", the id sessions'
priceOf looks up.

Run (mote): go test -run ModelPrice ./internal/gui; node --test
usage-model-price (chromium + webkit, 420px wide, en/zh/zh-TW/ja/de),
usage-clear (its menu now has Set price… above Clear usage…),
i18n-keys; gofmt -l; go vet ./... for darwin, linux -tags nogui and
windows.
Broken by hand: SetModelPrice skipped, TestModelPriceFromAnyProvider red
("set: 200 {Price:<nil>}"); Set price… taken out of the row menu,
usage-model-price red.
Not tried: a real gateway call priced after setting it in the real app.
2026-11-10 17:45:42 +08:00
yetone 662546e78d usage: a cache hit rate reads 100% only when all of the prompt was cached (ZhangXiaof48473 on X)
Routing's request list showed "缓存 100%" for Codex requests of 77.5K
tokens that read 77,200 of them from the cache (99.6%), beside rows at
99%, and the route line said "请求缓存命中率 99%". Every hit rate was
Math.round(100 * h) + "%", so anything from 99.5% up read 100%.

One formatter now says every hit rate: hitPct(h, d) in app.js, whole
percents (d decimals) unless rounding would say 100% or 0% of a prompt
not all or none cached, then one or two decimals (99.6%, 99.95%; never
past 99.99% or under 0.01%). Its callers: Routing's request rows, their
route line and a session's Avg. cache (plugins/routing/client.js); the
tray panel's Cache hit rate and the ranking rows' hit rate (app.js); the
Usage page's tiles, agent rows, Requests table, request detail and its
KPI strip, which keeps its one decimal (plugins/usage/page.js); the
context card's Prompt cache and the session traits Cache-friendly,
Cache misses and Cache hit (context.js). The TUI's and CLI's sessions
line, which floored the integer, use usage.HitPct, the same rule in Go;
it rounds now, so the TUI test's 67% (25.2K of 37.3K, 67.6%) reads 68%.
No new strings; app.js pays its bytes with six ledger comments cut, so
the core scripts are 15 bytes smaller than at its parent, no raise. Main
is over the core budget already (1,534,476 > 1,533,802 at the parent,
#5918); this commit doesn't add to it.

Run on mote:
- new internal/gui/tests/cache-hit-pct.test.cjs (Routing rows 99.6% /
  100% / 99%, the route line, hitPct at its edges) in chromium and
  webkit, en and zh: green; with the escalation line removed by hand,
  red (99.99% where 99.6% is wanted).
- cache-hit-pct, panel-usage, context-window, i18n-keys, usage-ledger,
  tray-totals, ctx-route, ledger-cache-hit, usage-hit-rate,
  routing-request-metrics (both engines; ledger-cache-unknown and
  ledger-cache-tokens in an earlier run): 186 pass, 6 red, all in
  usage-ledger's 'newest live route needs no return-to-live button',
  red the same on origin/main 00e8242e8 (#5048, #4078).
- go test ./internal/usage ./internal/cli ./internal/tui: ok, with
  TestHitPctNeverRoundsToAllOrNone and a 99.6% case in
  TestHitRateCountsCacheWrites (red on the old floor: 99%).
- go test ./internal/gui at the first base: TestCoreScriptBudget ok; one red,
  TestGatewayModeStatsNameTheGatewaySessions, run at 00:25 local (#5690,
  the first hour of a local day).
- gofmt; go vet darwin, GOOS=linux -tags nogui, GOOS=windows: clean.
At the pushed head (rebased, comments cut): cache-hit-pct and
routing-request-metrics again, both engines, 8 of 8.
Not tried: the real app's window, or GUI files beyond those above (a
65-file run waited on mote's suite lock behind four full suites).
2026-11-10 16:28:04 +08:00
yetone add47afd82 usage: a card's ⋯ opens its menu, Hide from Overview where it is seen (jen_celeus on X)
jen_celeus asked to hide providers with no usage information, OpenCode
Zen and the like, from Usage. The hide was already there
(UsageCardsHidden, Hide from Overview, the "n hidden" line with Unhide
and Show all), but it sat behind a right-click, a long press or the drag
handle's menu, and nobody found it. Each card's head now has a ⋯ button
(quotaCardMore), the Agents row's pattern: shown on hover and keyboard
focus, always shown where nothing hovers, opening the same menu
(quotaCardMenu, now anchored on the ⋯), a second click closing it. On a
phone it keeps 22px with a 44px-high hit area that stops at the card's
edge (an even -11px inset spilled past it: usage-accounts-fold,
usage-keys-fold and usage-shared-balance said "card spills"). The long
press leaves the ⋯ alone. Its label reuses "Actions for {name}", already
in every language.

Run (mote): usage-card-more.test.cjs (new: Claude beside a Zen card with
a plan and no windows; en, zh, zh-TW, ja, de at 1200, 560 and a 390 web
phone; chromium and webkit): the ⋯ is there with its label, hidden at
rest where hover is, shown on hover, never over the head's text where
nothing hovers, menu = Hide from Overview, toggles, the hide posts
{cardsHidden:["opencode-zen-free|plan"]}, no scroll, the "1 hidden"
line's Unhide brings it back, no page errors. The 154 GUI files that
load the Usage page plus i18n-keys, both engines: see the next commit's
record. gofmt; go vet darwin, linux -tags nogui, windows;
go test ./internal/gui/ (budgets) ok.

Broken by hand: without head.append(quotaCardMore(...)) the new test is
red in every subtest (chromium 0 of 16).

Not tried: the real app's WebKitGTK and Windows WebView2 windows; the
web page on a real phone.
2026-11-10 11:47:06 +08:00
yetone ca5e537ecb usage: traffic over time in Requests' chart, and how fast it flows now (songlairui on X)
songlairui on X asked for the gateway's bandwidth: many LLM calls, base64
images above all, weigh on the network. Each request's row already kept
its bytes up (UpBytes) and down (DownBytes), shown in its details and as
the period's "↑ · ↓" under the Requests card. What was missing was
bandwidth over time and right now.

- The Requests chart's metrics take Traffic: each hour's/day's bytes up and
  down, stacked by model, provider or agent. Its axis is in bytes ("4 MB"),
  its tooltip splits a column into "↑ up · ↓ down", and the ranking's
  values are bytes with the same split under each. A period with none
  says "No traffic counted in this period". A chart point's Part now
  carries up_bytes/down_bytes, from rows (Part.add) and from the request
  page's cells (Part.plus). The cells already kept Totals, so no cache
  version bump is needed.
- While requests are in flight, the Requests card says how fast traffic
  flows now: "↑ 1.0 MB/s · ↓ 40 KB/s", over the last ~3s, read from the
  new GET /api/usage/traffic a second apart. That route reports the
  gateway's running totals (Server.Traffic) and its requests in flight.
  The totals are atomics added where a row's bytes are added (sentUp,
  downCount.Read). So a stream counts as it arrives, nothing is buffered
  or scanned, and the totals and rows count the same bytes once. Polling
  runs only while Usage → Requests is shown and the window is visible.
  The line goes when nothing is in flight and nothing flowed. When another
  magpie serves the gateway, the route answers {} and the page shows no
  rate.

A Codex turn on the Responses WebSocket (7c1dc198d) is in the totals as
its row is: what the socket was written. The HTTP body sentUp counted is
taken back when the transport chooses the socket (toSocket) and given back
if the turn falls to HTTP after all (toHTTP), so the totals equal the sum
of the rows either way (TestTrafficCountsWhatTheSocketSent, kept and
refused).

Not counted, as before: Claude bridge turns (no HTTP to the vendor). A
plugin's row counts the local hop to the plugin host. An upload is counted
when its try is sent, so a large body shows as a burst in the live rate.
docs/subsystems/gateway-sessions.md has a Bandwidth section.

Run (mote; first at this change on da8480326, then again on 16a2dfac9):
- go test -count=1 -run 'Traffic|Socket|UpBytes|Ledger|Series'
  ./internal/gateway ./internal/usage ./internal/gui: ok.
- Broken by hand, each red, then restored: the down tally in downCount,
  the up tally in addUp, Part.plus's bytes, Part.add's bytes, the
  toSocket call (kept socket: traffic 151020, rows 50469) and the toHTTP
  call (refused: traffic 50360, rows 100551).
- gofmt -l clean; go vet -tags production ./..., GOOS=linux and
  GOOS=windows go vet ./...: ok; darwin, linux and windows builds: ok.
- GUI (mote, this tree): i18n-keys, i18n-en-no-cjk, usage-traffic and
  request-archive-usage, 54/54 in Chromium and WebKit (usage-traffic in
  en, zh, zh-TW, ja and de); usage-traffic red with the rate line broken
  by hand. "Traffic" is in i18n.js, not the Usage plugin's: Go says it
  too, and i18n-keys was red with it in the plugin's file.
- internal/cli TestEveryRouteHasACommandOrIsNamed: ok, with GET
  /api/usage/traffic named in notYet (the full run found it red).
- On 16a2dfac9 (the pushed base): gofmt -l internal clean; go test
  -count=1 -run 'Traffic|Socket|UpBytes|Ledger|Series|
  TestEveryRouteHasACommandOrIsNamed|Budget' ./internal/gateway
  ./internal/usage ./internal/gui ./internal/cli ok; i18n-keys and
  usage-traffic 40/40.
- Not finished at the tag, still running on mote: go test ./... -timeout
  45m and the whole GUI suite (under suite.lock), and the whole
  internal/gui, internal/usage and internal/gateway packages with every
  usage* GUI file. What they find is fixed in follow-ups.
2026-11-10 07:37:34 +08:00
yetone 98c4b2e814 usage: a request opens on a page of its own
geesehowardt7 on X clicked a request on the Usage page to see where it
came from. The click on its time opened Routing, which they hadn't
asked for, and the row's details had no source address.

A row's click, or Enter or Space on it, now pushes that request's own
page (#ledReqPane, ledReqOpen/renderLedReq) over the list. The page
gives the model and status, then ledDetail: time, agent, source IP
(the previous commit's client_ip: loopback reads "This computer ·
127.0.0.1", a gateway row from before the field "Not recorded", rows
read from session files, other computers and magpie's own calls none),
requested, provider, account, sent, served, effort, then status,
error, duration, tokens, cost, credits, speed and the archive. Routing
is the View routing link in it, and the time cell no longer links
there. "Requests ‹" or Escape (not while a menu, dialog or field takes
it) goes back to the list where it was left, with the row focused
(ledReqClose). Leaving the Usage page closes it (ledLeave(true)), and
a refresh keeps it. The in-table expanding row (ledOpen, tr.led-detail)
and its narrow-window lc-opt copies are gone, since the page shows
every field at every width. It slides in 200ms with the ease-out
curve, and only fades with reduced motion. "Source IP" and "Not
recorded" are added in zh, zh-TW, ja and de. The 20 ledger test files
that opened a row's details now open the page. usage-request-page.test.cjs
covers the page, the address, the way back, focus and a 560px window.
docs/subsystems/gui-shell.md describes it.

Run at this commit's tree (rebased on origin/main b4a0a2a1a, with the
two commits beside it):
- mote (macOS 27): gofmt -l clean; go vet ./..., GOOS=linux -tags
  nogui go vet and GOOS=windows go vet ok. go test internal/gui (with
  TestCoreScriptBudget) ok in 164s, internal/usage, internal/usageapi,
  internal/cli and the root package ok, internal/gateway -run
  "Usage|ClientIP" ok, internal/provider -race -count=5 -run Workspace
  ok.
- WSL VM (magpie-desktop), whole suite through the suite lock at
  be9dbce02 plus this change: go test ./... -timeout 45m ok apart from
  the GTK packages, which need a display the VM run lacks (they pass
  on mote), TestGrokInstalled (#3548) and the provider workspace test
  the next commit fixes (#5800). GUI suite: 540 of 23297 red in 114
  files, WebKit timeouts mostly (#4121); those 114 files run again
  give 378 reds here and 365 at be9dbce02, the same files, and
  own-requests was the one this change broke (fixed: a row's click now
  opens the page, and its way back keeps the list's place).
- WSL VM, the 119 Usage and Routing GUI files at the rebased head,
  both engines: 21 red, 20 of them red the same at origin/main
  b4a0a2a1a: click-scroll (#4385), routing-cline-route and
  routing-upstream (#5156), usage-agents-hide (#2276, #3414),
  usage-heatmap (#4718), usage-ledger-ttft (#4489), usage-ledger-chart
  (#4263), usage-focus-steady (#3501), usage-fold (#3415, #2163),
  usage-ledger Requests (#3104, #5048), account-refresh-holds (#5814)
  and usage-speed-all-models (#5834, red since the 24 hours period).
  The 21st, usage-compact-counts chromium "zh 万 at 420px", is the
  flake in #5648 and passes 3 of 3 alone.
Again after rebasing on origin/main b3a57b3d8 (main's WebSocket row in
the ledger, 7c1dc198d): mote go vet, internal/gui, internal/usage,
internal/usageapi, internal/cli, the root package, internal/provider
and gateway -run "Usage|ClientIP|Socket|Memory" ok, apart from
TestCoreScriptBudget, red on main since b3a57b3d8 and fixed there by
4894332d7, which this is now rebased on; the VM's 119 files plus usage-ledger-bytes and
codex-app-back: 1708 of 1782 pass, no red that isn't in the list
above, usage-ledger-bytes passing with the request page.
Not tried: a request from another device over a real LAN share.
2026-11-10 04:44:13 +08:00
yetone 7c1dc198d1 usage: a turn over the Responses WebSocket counts what the socket was sent, and says so
A Codex turn kept on a Responses WebSocket sends only the new items as a
delta, but the row's ↑ was the whole HTTP body magpie built before the
transport ran, so a long conversation read as ~13MB up per turn
(matrix0487 on Discord). overSocket now records what each socket write
carried (wroteSocket) and, when the turn went out on the socket alone,
replaces the HTTP figure with those bytes (sentOnSocket); a turn that fell
back to HTTP keeps the HTTP body and adds any socket write made before the
fallback. errCodexSocketAgain's retry on a new socket counts both writes.

The row remembers that it went over the socket: Record.Socket (json "ws"),
packed as Flags bit 16384 (rowSocket, added to TestRowFlagsApart). The
Requests table's protocol badge says "Responses · WS" and the details'
Protocol line "Responses · WebSocket".

Run on mote at this commit (rebased on origin/main b4a0a2a1a): gofmt -l
clean; GOOS=linux and GOOS=windows go vet of internal/gateway and
internal/usage; go test ./internal/usage ./internal/gui ok; go test
./internal/gateway -run 'Codex|UpBytes|Ledger|Socket' ok; node --test of
every ledger-*, usage-ledger* GUI file and i18n-keys, 502 of 511, both
engines. The reds are filed and untouched by this change: ledger-swipe
webkit (#5223) and usage-ledger's "newest live route needs no
return-to-live button" (#3104, #4078, #4626, #5048).

Broken by hand: without the deferred sentOnSocket,
TestCodexSocketRowCountsWhatTheSocketSent reads 50,360 B for a 253 B
delta; without the Flags set, TestRowKeepsSocket's packed rows lose
Socket.

Not tried: a real Codex Pro account over the socket, and the full suite
(it runs after the tag). There is no "saved by the socket" figure yet,
since PlainBytes isn't packed.

Reported-by: matrix0487 (Discord)
2026-11-10 03:44:19 +08:00
yetone 9d4c338a67 gui: magpie web on a phone no longer scrolls sideways or keeps a band at its foot (#4943)
precis1onz (iOS Safari, dark, English, Usage) saw the page move sideways
and a dark band stay at the screen's foot.

- Sideways: Usage → Requests' "Split by" row (label and five choices) is
  one unwrapped span, 393 to 558px wide at 375 to 430px. It was the only
  thing wider than a phone in any view or language. On the phone layout
  it now wraps inside the screen (app.css, phone block only).
- The band: the Requests table's stand-in scrollbar (#799) is sticky at
  the view's foot, and a touch screen draws no bar in it, so it stood
  there as an empty 12px band. ledHScroll now leaves it hidden on
  (hover: none) and (pointer: coarse); a finger moves the table itself.
  A desktop keeps it as before.

New test, phone-no-sideways.test.cjs: every view (Agents, Sessions,
Providers, Routing, Groups, Gateway, Library, Plugins, Masking, each
Usage tab, Settings' tabs) on an iPhone at 375 in en, zh, zh-TW, ja, de
and at 390 and 430 in en, in Chromium and WebKit, with long ids, emails
and paths; nothing may be wider than the screen and no empty band may
stay sticky at a view's foot. ledger-swipe now expects no bar on a
phone, and that the swipe moves the table.

Run (mote, through mote-run):
- phone-no-sideways: red on the old assets (803d7747e) in every run,
  led-split too wide plus the empty #ledHScroll at the foot; green on
  the new in both engines, again at the rebased head with ledger-swipe
  and usage-ledger-leave.
- mobile-web 14/14 in both engines with a real git base in the copy,
  so the desktop layout matches the base.
- Every GUI file the change can reach (1485 tests, both engines): the
  reds are all red on base and filed: mobile-web desktop subtests in a
  copy without .git (#5013), phone-connect-menu 420 (#4706),
  usage-agents-hide (#2276), usage-computers sync tick in Chromium
  (#5224), usage-fold (#3415), usage-ledger Requests (#5048).
  ledger-swipe in WebKit flakes on base too (#5223).
- go test -tags nogui ./internal/gui ok (size budgets), also at the
  rebased head; gofmt clean; go vet for darwin, linux and windows ok.

Not run: the whole GUI and Go suites. The run was queued over two
hours behind mote's suite.lock and never started; the change touches
no Go code.
2026-11-10 03:00:30 +08:00
yetone a8aeb2cad2 usage: picked days can start and end at a minute
blrbrzkj on Discord asked to see usage from one time to another, not
only whole days. The range menu has a start and an end time under its
month (empty is the whole day; 9:30, 0930 and 09:30 all read 09:30).
Picked with the days, the period is "2026-10-01T09:30..2026-10-01T18:00";
Enter applies new times to the days already picked. A time that isn't
one, or an end not after the start on one day, is marked and asks for
nothing. The opt says "Oct 1 09:30 – 18:00".

The backend reads either end as a date or a date with its minute
(usage.RangeOf, bounds); an untimed end is its next midnight. A timed
range of 48 hours or less is drawn by the hour from the first's hour.
CSV names drop the colons.

Run (mote): node --test usage-range-times (new, chromium + webkit, en +
zh), usage-range, i18n-keys, credit-days: 26/26 ok. go test
./internal/usage ./internal/gui ok (TestCoreScriptBudget fits, the
periodDays comment cut to pay for its regex); gofmt clean; go vet
native, GOOS=windows (usage, gui), GOOS=linux (usage) ok.
Broken by hand: a timed end read as its day's midnight turns
TestPickedMinutesArePeriod red. The page's own typedTime first clashed
with app.js's hhmm and stopped the Usage page mounting; the GUI run
caught it.
Not tried: the real app with a real ledger; ja/de/zh-TW screens.

Reported-by: blrbrzkj (Discord)
2026-11-10 02:01:37 +08:00
yetone 3d49ac069e usage: a 24 hours period, and the period picked is kept
The Usage page's periods were Today, 7 days, 30 days and All. "Today"
starts at midnight, so early in the day it shows almost nothing
(mahiro233 on Discord). A "24 hours" period now sits after Today and
asks the server for its rolling window, last:24h (#2075), with an
hourly chart. Its empty state says "No calls in the last 24 hours."
(en, zh, zh-TW, ja, de). The menu bar's credit days count it as 2.

The period picked from the list is kept in localStorage and the page
opens on it next time. Picked day ranges aren't kept (they go stale),
and neither is a period the URL brings (?period=7d from the menu bar).

Tests: usage-24h.test.cjs (new; Chromium and WebKit, en and zh, 900px):
24 hours sits after Today and asks for last:24h, its empty note, a
reload opens on the kept pick, ?period=7d is not kept. Five usage
tests counted the period list by index and were moved one along.

Run on mote at be2d2db5c + this change: usage-24h, usage-range,
usage-phone-head, usage-ledger, usage-ledger-chart,
usage-ledger-open-settled, usage-refresh-flight, credit-days,
tray-totals, usage-head-steady: pass 148, fail 6. The 6 are
usage-ledger's "newest live route needs no return-to-live button"
(en/zh, both engines), which fail the same 6 on be2d2db5c without
this change (#3104). i18n-keys ok; go test -run "Budget|I18n|Script"
./internal/gui ok. No budget raised.

Broken by hand: none beyond the index shifts the old tests caught.
Not tried: the real app with a day of real calls.

Reported-by: mahiro233 (Discord)
2026-11-10 01:39:27 +08:00
yetone ecc16fe979 usage: the quick panel and the Usage page word unpriced calls alike
The quick panel's Cost said "15 个没有价格" while the Usage page's
said "15 次调用没有已知价格,未计入". Both now say "{n} calls unpriced"
("15 次调用未计价"), as the page's other cost heads already did, with
the whole sentence on hover.

Reported-by: tenacious_eagle on Discord

The Usage page's plugin already had the two count keys; they live in the
core's i18n.js now that the quick panel says them too (i18n-keys: no key
twice, a plugin's words are its own). The Overview calls tile says the
same words, so usage-unpriced-sum's tile wording follows.

Run on mote at origin/main fc9ce34d8 + this: gofmt -l internal clean;
node --test i18n-keys, i18n-en-no-cjk, panel-usage, tray-totals,
usage-unpriced-names, usage-unpriced-sum, usage-stat-sub-wrap, currency,
usage-compact-counts 126/126; go test ./internal/gui ok (TestCoreScriptBudget
under its budget, not raised). usage-ledger's "newest live route needs no
return-to-live button" is red alone on fc9ce34d8 too (#3104, #5048).
2026-11-10 00:13:32 +08:00
yetone 92be1d779b usage: the allowances' head opens Settings › Allowances
The Usage page draws the allowances, but how they are shown (used or
left, the menu bar's figures) and their alerts are set in Settings ›
Allowances, and nothing on the page said so (the scattered settings
audit after netube99 on X). The allowances' head now has a Settings ›
link, as the Routing page has, that opens that tab and lights the
Allowance display row (now #quotaLeftRow). Wired in the usage plugin,
so the core script doesn't grow.

Run (mote, through mote-run, Chromium and WebKit, every language, 1100
and 420): settings-places, mobile-web (with an origin/main baseline;
the button is taken out until the baseline has it, as rtToSet is),
account-mask, quota-curve, i18n-keys: 89 of 89, twice. A first run had
one red whose name a tail cut off; the next two runs of the same files
were 89 of 89, so it is unnamed and not seen again.
Broken by hand: no onclick, settings-places 2 of 2 red (no row lit);
no #quotaLeftRow, 1 of 1 red.
At the pushed head (rebased on f37de8cc4, which changed plugin pages and
the core budget): Budget and I18n Go tests ok; settings-places,
i18n-keys, plugin-page 30 of 30.
Not tried: the real app's window; the whole GUI suite runs after the
last of these changes.
2026-11-09 23:44:16 +08:00
yetone 54af4357c3 usage: the agent filters show each agent's icon
The owner: Usage › Requests' agent menu listed names alone ("这里应该有
Agent的icon"). The ledger's agents already carry their icon (usageapi
Named.Icon), so the menu now draws it beside each name: an agent's own
logo, the generic one for a client magpie doesn't know (AsyncOpenAI,
Go-http-client). Sessions' agent menu does the same, from a session's
icon or, for an agent with none listed, the agent magpie knows. The
shared menu (openSessCombo) draws icons only when its options carry
them, and keeps the room blank on the All row, so every name starts at
one x; the other filters (models, folders, providers...) are unchanged.

usage-agent-filter-icons.test.cjs opens both menus in Chromium and
WebKit, en and zh: each row's icon, the All row's blank room, names at
one x, each icon on its name's line, and the search narrowing them.

Run (mote, at 81798f779 + this): the new test 4 of 4 ok. The 25 GUI
files that use these menus plus i18n-keys: 503 tests, 493 ok, 10 red.
The four red files run alone at 81798f779 without this change give the
same 7 reds: i18n-keys "a plugin's words are its own" (#5482, #5426),
usage-ledger "newest live route needs no return-to-live button"
(#4078); quota-curve (#4768) and usage-computers pass alone.
TestCoreScriptBudget and the other Budget tests ok.
Broken by hand: with app.js and page.js reverted, the new test is red
4 of 4.
Not tried: the real Linux app (WebKitGTK) and Windows WebView2.
2026-11-09 06:51:30 +08:00
yetone f418edffc3 sessions: a session's details show how full its context was, request by request
liang_yongxiang on Discord: Routing tells how full one request's context
window was; does Sessions have the same, each turn's share?

A session's details on the Sessions page (and in Usage's Sessions list,
which draws the same details) get a Context line when the gateway sent
calls of it (s.via): the Context tab's spark of its prompts, request by
request against its window, and the fullest one's share beside it, toned
as the tab tones it. A point's tip says "Request 2: 80K of 200K (40%)" (the
tab's spark says it too now, where the window is known); a point clicked
opens that request in Routing with its card. A session the gateway never
saw asks nothing; one it kept no prompt of shows no line.

The data is the routing history the Context tab already reads. A new
GET /api/context/session?agent=&id=&from=&to= reads only the days from the
session's first to its last (30 at most), through the tab's per-day cache
(daysRecsLocked, split out of contextRecsLocked, so the tab's cached days
are not evicted), and keeps that one session (contextOfRecsFor), with up
to 1000 of its requests. The tab keeps the latest 80 sessions and would
leave an older one out. Subagent and side calls are left out as the tab
leaves them out; the same id under another agent is that agent's.

The line's code is in plugins/usage/page.js (sessCtxLine). context.js only
exports spark and health, and pays for its tip by cutting comments, so
the core's scripts are 10 bytes under main's, no budget raise.

Run at this head (rebased on e215d335a), on WSL (magpie-desktop, Linux;
mote rebooted mid-run):
- gofmt -l clean; go test -tags nogui -run
  'TestContextSessionLine|TestCoreScriptBudget|TestContext' ./internal/gui/: ok
  (also ok on mote at this head).
- node --test sessions-context-line (new: Chromium and WebKit, en zh zh-TW
  ja de, 1100 and 420 wide) and context-window: 44 of 44.
Run on mote before the rebase, at 627fd1a3b:
- the whole internal/gui package: its one red, TestCoreScriptBudget
  (1,536,110 > 1,533,802), is why the line moved into the plugin.
- sessions-context-line: 20 of 20.
- gofmt -l clean; go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./...: ok.
- i18n-keys: "a plugin's words are its own" red, the same on origin/main
  e215d335a (#5327, #5332, #5426, #5482); the new strings pass its other
  checks.

Broken by hand:
- the one-session filter dropped: TestContextSessionLine red ("its
  requests' prompts: [21000]", another session's line).
- the tip back to "Request {n}: {tokens} tokens": sessions-context-line red
  in de ("Anfrage 2: 80K Token" for "Anfrage 2: 80K von 200K (40%)").
- the details line turned off: sessions-context-line red in en and zh.

Not tried: the whole GUI suite (it was running under mote's suite lock
when mote rebooted; not run at push); a real magpie with real routing history (the GUI test stubs
/api/context/session; the Go test reads real history files in a sandbox
config); the Linux app's WebKitGTK.

Reported-by: liang_yongxiang (Discord)
2026-11-08 18:13:30 +08:00
yetone 7a6211d047 providers: a model's own headers, in Model settings
axelburks on Discord: a vendor routes one model by a header of its own.
A key's provider (built-in or custom) can give each model headers
(settings.ModelHeaders["pid/model"]). They go on that provider's
requests for that model alone, after the provider's headers and after
auth: a name both have is sent once, as the model's, so a user's value
is never overridden by the provider's or magpie's key header. The
gateway names the model (provider.WithModel) on every route that asks
one: chat on each API, translated and streamed, count_tokens, System
One's decision, embeddings, images, videos and the model test. A
fallback provider serving the same model id gets its own headers only.
Accounts and plugins carry their sign-in's headers and take none.

The editor's "Name, price and reasoning level" panel is now "Model
settings" (every language), with + Add header per model, staged and
made with the Save; Restore default takes them away.
The rows being typed are kept out of the draft's
compare, so an untouched editor still closes without asking.

Broken by hand: dropping WithModel from gateway.go turns
TestModelHeadersReachTheirModelOnEveryRoute red; dropping the provider
id check in modelOf turns TestModelHeadersStayWithTheirProvider red.

Run, on this stack over origin/main 0fc3455e2 (mote's suite lock had
hours of queue, so the suites ran on WSL magpie-desktop under flock):
- go test -timeout 45m ./internal/{provider,gateway,gui,cli,settings,fx}
  on WSL, ok; ./internal/codexcat on mote, ok; gofmt -l clean;
  go vet on mac, GOOS=linux -tags nogui and GOOS=windows on mote, ok;
  TestCoreScriptBudget ok (paid by cutting comments, no raise).
- GUI, both engines, every language, on WSL at the pushed head and at
  0fc3455e2: every touched test file plus the provider-editor files a
  first run found red. No red at head that isn't red at 0fc3455e2. The
  shared reds have issues: i18n-keys #5332, model-chip-steady #4388,
  model-copy-id #4621, models-works-only #4391, plugin-move-unserved
  #4392, provider-fetch-again #5232, provider-levels-save #4394,
  provider-levels-scroll #4395, provider-models-rest #4396,
  provider-picks-stay #4397, provider-typed #4673, remote-magpie #4398,
  zero-priced-free #5262, model-reasonless (webkit de) #4100,
  name-suffix-no-names #1937.
- Rebased on origin/main 4ab1191bc (gateway.go moved under it) and run
  again at the pushed head: gateway and provider ok on WSL, gofmt,
  vet (mac, linux nogui, windows) and the budget ok, i18n-keys,
  model-headers and routing-groups-back with only #5332's red.
Not run at push: the whole GUI suite (1277 files).

Not tried: a real vendor that routes by header (Ark); fake vendors only.

Reported-by: axelburks (Discord)
2026-11-08 11:28:54 +08:00
yetone b77400826a usage: the Overview read again keeps its cards and its place, and shows it is reading
jiabubu on Discord: a refresh of the Usage page's Overview showed nothing
while it read, flashed the page and dropped cards for a moment, and
pressing Usage again while on the Overview flashed it or moved its scroll.

- Pressing Usage again (show() calls the plugin's open, loadUsage(true))
  put the skeleton up, which hid the sections, collapsed the page and
  clamped its scrollTop. loadUsage now puts the skeleton up only for a
  first read or another period or zone (usageFor/usageKey); a page that
  already shows that read reads again quietly through refreshUsage, so
  nothing is blanked and the scroll stays.
- The refresh beside the period turns while such a read is out
  (#usageReload.reading, after 200ms), and while every card is read
  (loadQuotas) each card's refresh turns (#subscriptionUsage.reading,
  quotaReading in page.js). A card's own busy turn is left to its own
  animation (:not(.busy)). No turning under reduced motion.
- renderQuotas draws the cards again in one go, as their reset
  countdowns need, but now keeps their logo nodes (keepIcons), and the
  Overview's lists do too: a logo made afresh blinked out while its
  picture loaded.
- app.js stays in its budget: a three-line comment in renderQuotas cut
  to one. Core 1,533,507 of 1,533,802 before the rebase on 0b4cda048.

Tests:
- New usage-quiet-refresh.test.cjs: Usage pressed again at the top,
  halfway and at the foot, with the read held: no skeleton, chart not
  hidden, scrollTop the same, the refresh turning, then the same figure,
  row and logo nodes; and Refresh with the allowances held: every card
  stays, each card's refresh is shown and turning, the logos kept.
  Chromium and WebKit, en and zh, 1180 and 560px. Red on the old assets
  (8 of 8 per part: "nothing blanked while it reads ['skeleton','chart
  hidden']", "the cards' logos are the ones drawn before: false,false,
  false"), green on the new.
- usage-quota-head.test.cjs waited for the skeleton on Agents -> Usage;
  it now waits for the quiet read (the page kept, the refresh turning).
- usage-stale-answer.test.cjs lifts loadUsage out of page.js; it now
  lifts usageFor/usageKey with it and stubs the page's loading state.

Run on mote (mote-run), at the rebased head 344cdcde3: go test -run
TestCoreScriptBudget ./internal/gui ok; gofmt -l clean; the nine usage,
quota and panel files above plus panel-fit-tabs, panel-usage and
panel-quota-refresh: 140 of 140. Before the rebase (at d32a7a70c's base,
same change less the stale-answer stub): go test ./internal/gui ok apart
from TestSettingsSaveKeepsWhatItDoesNotSend, fixed on main by c7c05dcf2;
GOOS=linux go vet -tags nogui ./... and GOOS=windows go vet ./... clean;
every GUI file named usage, quota, allowance, click-scroll, sidebar or
last-page (129 files, 1880 tests): red only in files red on main too or
filed: usage-agents-hide (#2276, #3414, red at d32a7a70c alone),
usage-fold (#3415, red at d32a7a70c alone), usage-ledger's Requests
(#5048), and usage-compact-counts' zh-TW 420px tip under load (#5648,
30 of 30 alone); usage-stale-answer's reds there are fixed here (11 of
11).

Not tried: the whole GUI suite (1,274 files; mote at load 60 to 80
from other sessions), the real app and WebKitGTK, languages beyond en
and zh in the new test (no new strings), and the other pages' re-open
by probe (Sessions, Library, Gateway and Masking were read: none puts a
skeleton up over a page already drawn).

Reported-by: jiabubu (Discord)
2026-11-08 03:57:04 +08:00