Commit Graph
80 Commits
Author SHA1 Message Date
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
yetoneandmdwsk88 8de63c8b5a gateway, usage, gui, otlp: a request its agent canceled is no failure (#2398)
An agent that cancels its request before it is answered is logged 499
"the agent canceled the request": a person stops the reply, or sends the
next message while it is coming and Claude Desktop cancels it and asks
again, or Codex takes a subagent's report (#2398). The gateway already
says nobody failed (no rest, no reroute: TestCanceledRequestRestsNobody),
but Record.Failed is a status >= 400 or an error, so every page counted
it as a failure: the Requests card's "N failed" and success share, its
Failed filter, the CSV's error column, the Routing page's "errors your
agent saw", the Context page's error rate, the failed colour in the
Requests list, Routing and Recent calls, and the OTLP export's error
status. A Claude Desktop session on 2026-10-27 had four, each a message
sent mid-reply; #2398 had 91 of a day's 92 failures.

usage.CanceledBy tells the agent's cancel (499 with AgentCanceled) from
magpie's own limit on a request it asked of itself, logged 499 too and
still a failure (#2318). The cancel is logged with an error type of its
own, agent_canceled (usage.CanceledErrType, set in failedWith), so the
record says what it was and nothing guesses it from a 499, as #2398
asked. Record.Canceled reads the type, and a record logged before it by
its status and message, so the old log reads the same with nothing
migrated. A middleware's usage rows carry the type, so a module can tell
the cancel from magpie's own limit, which its rows (no error text)
couldn't.

Record.Failed leaves the cancel out; Totals counts it apart (Canceled, in
count and plus); RetriedRequest and the first-token and speed sums ask
Answered, so a canceled request is timed nowhere, as before; Codex's
memory of the last model still skips it. Routes and Recent calls say
canceled (set as a route is done and as a day's history is read, so old
days read the same); the Routing totals and the Context page's errors
leave it out. Ledger rows say canceled, and the pages show it muted, in neither the
failed nor the answered colour: the Requests list and its detail ("499 ·
canceled"), the Requests card ("N canceled", the success share of the requests not
canceled), the overview tile, the Routing page (a "gone" outcome, no
speed) and Recent calls (muted). New strings are in zh, zh-TW, ja and de.

The OTLP export: the records the gateway gives its observers for a
request and its try carry the type too (canceledAs), and a root span's
error.type follows Record.Failed, so a canceled request's span and its
try's go with status code 499, no error and no error.type.
TestOTelWaterfallFailureAndCancellation's canceled case held two failed
spans (the try the vendor refused as the agent left is recorded canceled,
as the request is); it now holds neither failed, both 499 and no
error.type. That change to the test is the point of this one.

mdwsk88's patch (aea0027fd) ran its tests at e056779a, a3768cdd,
c86fa2a3 and fcc0daa2, broke each check by hand (each red), and sent
real Claude Desktop cancels through a nogui build with a stand-in
upstream and OTLP collector. Its full record is on aea0027fd. Since
58541e5b (#4866) Codex's own-sign-in relay logs Codex gone mid-reply as
499 through canceled() too, so it counts as canceled
(TestCodexGoneMidReplyIsNoFailure). drawing_route.go still reads a
canceled request as not served when it decides whether a picture's
next request may stay on its provider: that is routing, not a count.

Ported to origin/main 400b66ec3 on 2026-11-07, reviewed line by line.
Two siblings it left on the old rule, and a colour, now covered:
- usage.Row.Floor (the Claude Code speed floor) asked !Failed, so a
  canceled row, whose Failed is now false, told a floor: "3000 tokens
  in 4000 ms" for a reply no one waited for. It asks Answered now, as
  the speed and first-token sums do. TestAgentCanceledTellsNoFloor.
- The route-events feed (activityOf, #3387) told a canceled try and
  done route as failed. It leaves usage.CanceledBy out, and still
  counts magpie's own 499 limit. TestRouteEventsCanceledIsNoFailure.
- routing.css: a canceled Routing row ("rt-req gone") had the
  answered green dot. Its dot is muted now.
  routing-canceled-row.test.cjs checks the row, its dot and the errors
  stat in Chromium and WebKit, in en, zh, zh-TW, ja and de.

Run at this tree (mote-run, macOS):
- go test -count=1 internal/usage, usageapi, otlp, settings,
  settingsapi and cli: ok. internal/gateway: ok with -timeout 45m
  (847s; the default 10m ran out under load). internal/gui: ok but
  TestMainWindowCorners/macOS_26_SDK (#3949, mote is on macOS 27).
- Broken by hand: Floor on Failed again makes
  TestAgentCanceledTellsNoFloor fail ("a canceled row tells a speed
  floor: 3000 tokens in 4000 ms"). activityOf without CanceledBy makes
  TestRouteEventsCanceledIsNoFailure fail ("a done route its agent
  canceled is told failed"). Restored, both pass.
- GUI: node --test --test-concurrency=4 over routing-*, usage-*,
  ledger-*, panel-*, call-*, search-*, searcher-*, settings-*, i18n-*
  and gui-* (Chromium and WebKit; the files cover en, zh, zh-TW, ja
  and de), with #2398 and #5545 in one tree: 4961 of 5016 ok. The 55
  reds are in 12 files. i18n-keys' "a plugin's words are its own"
  names other files' strings (#5327, #5426, #5482). The other 11 files
  were run alone at dc49feca9 (this tree without either change) and at
  this tree: 52 and 51 reds, the same tests. The one apart is
  usage-focus-steady, which flakes (#3501). Each is filed: #5392,
  #3414, #5048, #3799, #3415, #3954, #4627, #4628, #5223, #1529.
  routing-canceled-row.test.cjs: 10 of 10. With the .rt-req.gone rule
  taken out, its dot is the answered green rgb(24, 154, 88) and it
  fails. Restored, it passes.
- Not tried: a real Claude Desktop cancel through this tree; Windows
  and Linux runs.

Co-authored-by: mdwsk88 <11055210+mdwsk88@users.noreply.github.com>
Reported-by: mdwsk88 (dawei on Discord)
2026-11-07 04:03:01 +08:00
yetone 542ee03b4c usage: each request says its cache hit rate, as the Routing page's do
teenux (Discord, #feedback) saw a cache hit rate on each request in the
Routing page's list but none on the Usage page's Requests tab. Each
Usage request now has a Cache hit rate column after Cache read, worked
out as Routing's request list does (promptOf in routing/client.js): the
tokens read from the cache over the whole prompt, uncached input plus
cache reads and writes, through app.js's cacheHitOf. It is said as
Routing says it, a whole percent ("90%"), with Routing's tooltip ("Cache
hit rate: The share of the prompt read from the cache"). A vendor that
counts no cache (cache_unknown, #3464) reads "—" with "The vendor
doesn't count the cache"; a request with no prompt counted reads "—"; a
miss reads 0%. The row's own fields only: nothing new is fetched.

Folding: at the page's 1200px cap the raw cache columns are usually out
already (tight), so the hit rate folds with the first token's column
(lc-opt2, tight2) rather than with them; while it is out the row's
details say it, and while it is in they don't say it twice. Every
string already had its zh, zh-TW, ja and de, so no i18n entries were
added.

Not the same: for a request with billable retries Routing sums every
try's usage, and a Usage row holds one usage record, so the two can
differ there.

Run on mote (macOS 27), Chromium and WebKit, five languages:
- new internal/gui/tests/ledger-cache-hit.test.cjs: 12/12 ok
- 65 GUI files the change reaches (this one included) (every test touching the ledger
  table, its details or the Requests tab) plus i18n-keys and
  i18n-en-no-cjk: 1147 of 1165 ok. Reds, all filed and not from this
  change: i18n-keys "a plugin's words are its own" (#5327, #5332,
  #5426, #5482), gateway-caller-keys en at 560px (#3797),
  usage-ledger "newest live route needs no return-to-live button"
  (#3104, #4078). Two more reds were this change's and are fixed here:
  usage-ledger's header list and usage-ledger-detail's always-shown
  labels (now leaving lc-opt2 out, as they left lc-opt out);
  usage-ledger-ttft's lc-opt2 header locator now names its column.
  Rerun of usage-ledger, usage-ledger-detail and ledger-cache-hit:
  only the two filed return-to-live subtests red.
- go test -tags nogui ./internal/gui/ (TestCoreScriptBudget and the
  other budgets): ok. No Go changed, so no gofmt/vet.

Broken by hand: origin/main's page.js -> ledger-cache-hit red ("a
Cache hit rate column"); the rate as cache_read / in (Routing's
denominator dropped) -> red on the values (deepEqual).

Not tried: the real app with real history; Windows and Linux GUIs.

Reported-by: teenux (Discord)
2026-11-07 04:02:36 +08:00
yetone 808e569534 usage: the refresh picker goes to 5, 15 and 30 minutes
The Usage page's auto-refresh topped out at a minute. A page left open
all day had no slower choice than reading again every 60 s. The picker
(the same app menu) now also offers 5 min, 15 min and 30 min.

The choice lives in localStorage (magpie.usageEvery) and is read back
only if it is one of USAGE_EVERY's values, so the new ones round-trip by
being in that list. Nothing on the Go side reads or clamps it. The labels
"5 min", "15 min" and "30 min" already have zh, zh-TW, ja and de
translations in i18n.js, so no new strings.

usage-refresh.test.cjs now runs in all five languages, checks the eight
choices in order, that half an hour reads none for 29 minutes and once by
31, and that another window opens on 30 min.

Run (mote-run):
- usage-refresh.test.cjs, Chromium and WebKit, en/zh/zh-TW/ja/de: green.
- The 195 GUI files that open the Usage page or its tray tabs, Chromium
  and WebKit, every language they cover (node --test, concurrency 6,
  mote at load ~35): 1100 ok, 11 red in 6 files. Rerun alone, here and
  on an untouched origin/main 2f660ca86 copy: account-eye, account-mask
  and context-map pass in both; codex-auto-reset (webkit de) and
  tray-cell-click are red the same in both, and gateway-caller-keys
  (webkit en) red on main only. All filed: #4790, #5215, #5052, #3951,
  #3797, #2572, #3488.
- go test -run Budget ./internal/gui (TestCoreScriptBudget): ok.
- i18n-keys.test.cjs: green except "a plugin's words are its own",
  red on origin/main too and filed (#5327, #5332, #5426, #5482); none of
  its words are touched here. i18n-en-no-cjk: green.
Broken by hand: usage-refresh.test.cjs against the old page.js is red in
all five languages (the menu lists five, and 30 min isn't there).
Not tried: the real app on a page left open for half an hour.

Reported-by: 114514 (Discord)
2026-11-07 01:17:05 +08:00
yetone 4f03fdbb55 usage: a menu opened in the page's first second closes on a click again
The usage page's guard against the mouse events a phone makes up after
a long press (quotaPressing) ate every click and mousedown outside a
row menu for 1s after quotaPressed. quotaPressed started at 0, so with
no long press at all, any row menu opened in the page's first second
(performance.now() < 1000) could not be closed by its button or by a
click outside it, and nothing else on the page took a click until then.
Found while testing the Library bar's new ⋯: the test opens it within
a second of loading and its second click was swallowed. quotaPressed
now starts at -Infinity, "never".

Run (mote, through mote-run):
- node --test internal/gui/tests/menu-first-second.test.cjs: 2 pass
  (Chromium and WebKit). The test sets the page's clock back 10s so it
  is all in that first second, and checks it is.

Broken by hand: quotaPressed back to 0, both engines red (".row-menu
to be detached" timed out after the second click on its button).

Not tried: a real long press on a phone (the 1s after one is unchanged).
2026-11-06 22:22:21 +08:00
yetone c6b7bbedfc usage: a narrow Requests list makes the rest tighter before it leaves the first token's column out
unscientific9 saw Requests' 首字耗时 column on one Windows machine and not
on another, with the same settings and version. The column is left out
when the table doesn't fit the window (ledFit), and that width is each
machine's own: the saved window size (660 by default), Windows' display
scaling and the text size. It was the first thing to go after Sent,
Effort and the cache, before names were cut shorter, headers wrapped and
the price reference line dropped (tighter). Now tighter comes first, and
the column goes (tight2, its value under the duration since 07fd06b4b)
only if the table still doesn't fit. ledGrow's "nothing left to leave
out" check follows it to tight2.

Measured with usage-ledger-ttft's rows: the column now stays down to
~650px in zh (was 760) and ~770px in en (was 870), in Chromium and
WebKit on mote; on the Windows box the old order dropped it at 720 (zh)
and 800 (en).

Run on mote, at this tree:
- usage-ledger-ttft, usage-speed, usage-ledger-detail, usage-ledger-bytes,
  BROWSER=chromium and webkit: 43 of 43 each.
- usage-ledger-ttft on xiaomi-gpu (win-run, chromium): 6 of 6.
- usage-ledger-ttft now steps from 1600 to 600 wide in every language and
  checks the column is out exactly while tight2 is on, tight2 only after
  tighter, and some width keeps the column with tighter on.
- Broken by hand: with the old order (tight2 before tighter) it goes red
  in every language ("the column goes only after the rest is made
  tighter, at 760").
- The wider run (every usage-*/led* file and the other ledger files,
  i18n-keys, both engines) was still going when this was pushed.

Not tried: the real WebView2 app on Windows, WebKitGTK on Linux, the
reporter's own window size and rows.

Reported-by: unscientific9 (Discord)
2026-11-06 17:55:46 +08:00
yetone f47390bf35 usage: the speed chart draws every model timed at a point, over 7 and 30 days too
zzzkl3994 on Discord: Usage → Requests, Speed, on 7 or 30 days, today's
column showed one of the five models used today. The chart's colours were
the ranking's top 7, ranked by speed, so a month's fastest models of a
reply or two on an older day took every colour; a speed chart has no
"Other" column, so a model past the colours was drawn nowhere, in the
columns, the lines and the tooltip alike. Today has fewer models, so it
looked right.

Now the chart's colours (ledCategories with chart set) go to the models
most timed (decode_n), ones with a measured speed only, and a model past
them is a faint mark (and a faint line) of its own and a row in the
tooltip. The ranking keeps its speed order and takes the chart's colours,
as it already did for a picked day (chartBy). Tokens, cost and requests
keep their rule: top 7 by that metric, the rest stacked as grey "Other",
which drops nobody. The tray panel draws through the same functions.

Run on mote:
- new internal/gui/tests/usage-speed-all-models.test.cjs: Today, 7 days
  and 30 days, columns and lines, tooltip, ranking colours = chart's;
  chromium + webkit, en/zh/zh-TW/ja/de, 1100 and 420: 22/22 pass.
  Against origin/main's app.js and usage/page.js: 22/22 red, Today passes
  and 7 days loses glm-5.1 etc. (the report's shape).
- node --test internal/gui/tests/{usage,panel,reasoning-speed,i18n}*.test.cjs
  (100 files, at 09812e66b): 1536 pass, 34 fail, in usage-agents-hide,
  usage-fold, usage-ledger "the Usage page's Requests", i18n-keys and one
  reasoning-speed webkit zh case. Run alone on origin/main 1615e5a14 the
  same reds come back except reasoning-speed (passes there, and at this
  head); they are filed: #3414, #3415, #5048, #5332/#5426/#5482.
- At this head (rebased on 1615e5a14): usage-speed-all-models,
  usage-speed-tip, usage-chart-line, reasoning-speed: 86/86 pass;
  go test ./internal/gui -run Budget: ok. app.js is 28 bytes smaller than
  before: the new lines are paid for by drawLedColumns' comments cut, no
  raise.

Not tried: the real app with a real ledger (fixture only); models whose
speed is only a session-file floor (≥ tok/s) still have no mark, as before.

Reported-by: zzzkl3994 (Discord)
2026-11-06 16:25:04 +08:00
yetone 640825b09a usage: the Requests card's traffic line reads whole, and a row says how many images went by file
matrix0487 on Discord:
- The Requests card's line "↑ 13 GB · ↓ 13 MB · 图片文件省下 44…" was cut
  with an ellipsis. It was one nowrap span.
- A row's details say "图片文件省下 10 MB" and should say "10 MB(3 张)".

The card line is now made of whole parts (usageParts, the pattern the
token line has since #2378). A card too narrow for all three puts the
saving on a line of its own. A part that is wider than the card by
itself (German at 420 wide) wraps inside itself; it is never cut.

The count:
- withDeepSeekFiles counts the image blocks it puts a file id in place
  of, on each try, and upBytes keeps the most of any one try (a retry
  sends the same images again, as the saved bytes are counted).
- It goes into usage.Record as `image_files` (omitempty) beside
  image_files_saved.
- packedRow keeps Tries and ImageFiles in int16 each (clamped to
  MaxInt16), so the row stays 152 bytes. request_snapshot carries the
  new field, and heat_disk hashes Tries as before.
- The detail row says "{size} ({n} image|images)": zh "10 MB(3 张)",
  zh-TW 張, ja 枚, de "Bild/Bilder", en "image/images".
- A row from before the count was kept has no image_files and shows
  the size alone, with no parentheses. The card's period total gets no
  count.

Run on mote, at this tree:
- gofmt -l (clean), go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./..., go build ./...: ok.
- go test -run 'TestRowImageFilesKept|TestRowBytesKept|TestRowsOfOneSession|
  TestDeepSeek|Snapshot|Heat' ./internal/usage ./internal/gateway: ok.
  - TestRowImageFilesKept: the count survives pack/unpack beside Tries,
    100000 clamps to 32767, an old row reads 0, the JSON has
    "image_files":3 and leaves out 0, and packedRow is 152 bytes.
  - TestDeepSeekImageFilesCountedInRow: two images in one message and
    one again in a later message make 3 in the stored row, twice, and a
    request with no image makes 0.
- GUI, BROWSER=chromium and webkit: usage-ledger-bytes runs every
  language at 1180 and 420. The 3-image and 1-image rows read in each
  language's unit, singular in en and de, and the old row stays bare.
  The reporter's period (13 GB, 13 MB, 44 MB) at 1180, 760 and 420 has
  every part whole and inside its card.
- The 79 usage-*/led* GUI files (concurrency 2): 641 of 659 pass in
  chromium and 637 of 654 in webkit. Every red is filed and red on
  origin/main d2c29abe7 too (run alone there in chromium, the same 17
  subtests): usage-agents-hide (#2276, #3414), usage-fold (#3415, #2163;
  in webkit also a timeout in "several accounts"), usage-ledger's
  return-to-live (#4078, #5048) and usage-overview-fold (#3947).
- Broken by hand, each red:
  - The count left out of packedRow: TestRowImageFilesKept.
  - The count not kept in withDeepSeekFiles:
    TestDeepSeekImageFilesCountedInRow ("0 images by file, want 3").
  - The detail's count dropped: usage-ledger-bytes in every language
    ("expected '10 MB(3 张)', actual '10 MB'").
  - The in-part wrap dropped: "de big 420" ("cut: 0,0,0,11").

Not tried: a real DeepSeek account (the count rides the same path as the
saved bytes, which were tried for #5407), and Linux WebKitGTK.

Reported-by: matrix0487
2026-11-06 11:46:25 +08:00
yetone 07fd06b4b5 usage: a narrow Requests list says each request's first token under its duration
Requests has a TTFT column (#2522), but it is the first column a narrow
window leaves out (tight2), and then the value was only in the row's
details. unscientific9 asked to see it in the list itself.

Now, while that column is left out, each duration cell gets a second,
small, muted line: "首字 5.5 秒" / "TTFT 5.5 s" (the core's "TTFT {ms}"
string, "≈" for a time told from a session file). app.css draws it from
a data-ttft attribute with ::after. That keeps it out of the cell's text,
so readers of td.duration's textContent are unchanged. A row with no
first token (a failure, or a reply not streamed) gets nothing. A wide
window shows only the column, as before. The narrow hint now names only
what is left in the details ("Sent, Effort and the cache"). The old
"…the first token…" string is gone from all four languages.

Run on mote, at this tree:
- usage-ledger-ttft, usage-speed, usage-ledger-detail, session-identity,
  usage-ledger-bytes and i18n-keys, BROWSER=chromium and webkit: all pass
  except i18n-keys "a plugin's words are its own". That test is red on
  origin/main for "View routing" and "No session ID" (#5332, #5426),
  strings this change does not touch.
- usage-ledger-ttft runs every language (en, zh, zh-TW, ja, de) at 1600,
  760 and 420 wide. At 1600 nothing is under the duration. At 760 the line
  is the details' first token, "≈" for the Codex row, empty for a failure
  and for a reply not streamed, smaller than the duration, muted, and the
  page doesn't scroll sideways. At 420 the same holds.
- The 79 usage-*/led* GUI files in both engines (see the next commit).
- Broken by hand: with the data-ttft line skipped, usage-ledger-ttft goes
  red in every language ("expected 'TTFT 5.5 s', actual ''").

Not tried: the real app's WebKitGTK on Linux, and the Windows webview.

Reported-by: unscientific9
2026-11-06 11:46:25 +08:00
yetone 6f0aeec180 routing: a request that tells no measured speed shows the least it wrote at, as Usage's Requests tab does (zzzkl3994 on Discord)
zzzkl3994: in Routing's request list some streamed requests showed tok/s
and some showed none, while the Usage page's Requests tab gave every one
of them a speed. The Requests tab gives a gateway call that tells no
measured speed a floor, "≥N tok/s" (usage/page.js ledFloor_): one that
reasoned with no first text recorded (a tool call after hidden
reasoning), its answer over the time after its first token unless its
content came in a burst; else, 1,000 tokens or more over a second or
more, its output over its whole time. Routing's rows had only the
measured speed. Now a row (and the side panel's row) says the floor by
the same rule, with the Requests tab's own tooltip words for it; a
measured speed is as before, and the story's per-try line still says
only a measured one. The floor's two tooltips are said by two plugins
now, so they move from plugins/usage/i18n.js to i18n.js, in every
language (i18n-keys: a plugin's words are its own). reasoning-speed,
which held that a tool call after reasoning says no speed on Routing
while Usage says ≥100, now wants ≥100 on both.

Run (mote, via mote-run, Playwright chromium + webkit):
- routing-row-floor-speed.test.cjs (new): four gateway rows, a measured
  one, hidden reasoning before a tool call, a burst, and one too small
  for either; each row's speed is compared with what usage/page.js's
  ledRowSpeed/ledFloorSpeed say for the same request, and the floor's
  tooltip with the Requests tab's words; en, zh, zh-TW, ja, de at
  1100px and 390px: 22/22 pass.
- routing-request-metrics.test.cjs (rows 6 and 7, two 8,264-token bursts,
  now say ≥339 and ≥5,509 rather than nothing) and
  routing-burst-speed.test.cjs: 8/8 pass.
- reasoning-speed (updated), panel-routing, routing-speed-first,
  usage-session-speed, usage-speed-count, usage-speed-every-row: green
  (10/10 and 48/48 for the first four).
- i18n-keys: the floor's two words no longer listed; its "a plugin's
  words are its own" is still red for "No session ID" and "View
  routing", the same at origin/main (#5332, #5426).
Broken by hand: client.js put back to its parent; the new test is 22/22
red ("waiting for .rt-metric.speed .v" on the hidden-reasoning row).
Not tried: the reporter's own requests (no trace of theirs), the real
app's WKWebView, Windows and Linux.

Reported-by: zzzkl3994
2026-11-06 11:23:46 +08:00
yetone 8b70b7d976 usage: a request's bytes up and down, and what DeepSeek's image files saved, in Requests
Suggested by @faithleysath (matrix0487 on Discord): the usage ledger now
keeps what each request received back (down_bytes) beside what it sent up
(up_bytes, #4456), and what DeepSeek's image files (#5407) kept out of the
upload (image_files_saved).

Shown in Usage → Requests:
- a row's details: "Sent upstream", "Received" and "Saved by image files",
  each only when it is above 0. A row from before has none of them, not 0;
- under the Requests card, the period's "↑ up · ↓ down", with
  "{n} saved by image files" when there is a saving. Its title gives the
  exact bytes. A period with no counted bytes shows no line.

What is counted:
- Down bytes are counted as the reply body is read, after Go's transport
  has undone gzip, so a gzipped reply counts its plain size, not wire
  bytes. A plugin's row counts the local hop to the plugin host. A 101
  body is not wrapped. Every try counts, so a refused try plus the
  answering one add up (TestLedgerKeepsDownBytes).
- Image files saved, per try: the body before the swap minus the body
  sent, minus the upload bytes this request itself paid (len(b64)/4*3).
  It can be negative on the turn that uploads; the GUI shows only a
  saving above 0. Gaps: an upload that finishes after the wait timeout or
  ctx-done is not subtracted (as with up_bytes); a joined upload flight is
  paid by the request that started it; multipart overhead is approximate.
- packedRow grows by three int32 (152 bytes, still within the test's
  bound), clamped to the int32 range. Totals sum all three.
- settledCountVersion goes 1 → 2, because Totals now count bytes. The
  settled page, heat and effort caches recount once, on the first start
  after the update. The heat key hash includes the new fields.

Run on mote at 84ad780b6 (origin/main, fetched):
- go test ./internal/usage: ok.
- go test ./internal/gateway -run 'TestLedgerKeepsDownBytes|TestDeepSeek|
  TestCodexOwnTurnKeepsUpBytes|TestLedgerKeepsUpBytes|
  TestLedgerCountsATrysSecondAsk': ok.
- go test ./internal/gui: only TestMainWindowCorners/macOS_26_SDK fails,
  as on main (#3949).
- gofmt -l clean; go vet of usage and gateway for darwin, linux (nogui)
  and windows; go build ./...
- New GUI test usage-ledger-bytes.test.cjs: 30 of 30 in Chromium and
  WebKit, en/zh/zh-TW/ja/de, at 1180 and 420 wide. It is red on the old
  page.js.
- usage-*, ledger-*, i18n-* and nav-timeout GUI files: 1231 of 1267.
  Every red is red on a clean 84ad780b6 too: usage-agents-hide (#3414),
  usage-fold (#3415), usage-ledger's "newest live route" (#5048),
  usage-overview-fold, which flakes in other languages on each run
  (#3947), i18n-keys (#5332, and #5426 filed now for "No session ID"),
  and nav-timeout (#5425, filed now).

Broken by hand:
- gotDown not wrapping the body: red, "down 0; the vendors answered
  141/265 bytes" and "the backend answered 105 bytes".
- the saved += removed: red, "saved 0".
- the settled guard red with the bytes fixture until the version raise.

Not tried: a real DeepSeek or other vendor account through a built app,
and a screenshot of the real app. The CSV export does not have the new
columns yet.
2026-11-06 09:17:10 +08:00
yetone 814a625a24 usage: the top refresh reads saved Claude accounts again (#5380)
The tray panel's Allowances refresh said "Allowances refreshed" but a
saved, non-active Claude account kept its old reading: claudeWindows runs
Claude Code's /usage for a saved account only under savedRefresh, which
only that account's own card refresh sets.

Now a refresh of every allowance by hand asks usage/quotas?asked=1&all=1
(AskEveryClaudeUsage). It marks its ask generation in claudeEveryAsked,
and for claudeEveryFor (2 minutes) each saved account not read since is
read as its card's refresh would, under the same due check, the
30-second per-account floor and the same running holds. Opening the
Usage page or the Allowances tab (?asked=1 alone), the timed refresh and
every background read are unchanged, so nothing polls more. Callers:
the panel's top refresh (refreshPage "allowances"), the Usage page's
refresh and sidebar reload (refreshUsage -> loadQuotas("all")),
Routing's Read allowances, and the TUI's r. loadQuotas no longer lets a
lesser load on its way (an opening's asked read) swallow a Refresh.

Siblings: saved Codex accounts are already read anew on every asked
whole read (loginReading over HTTP after AskUsage clears the cache), so
Codex is unaffected. PlanQuotas and KeyBalances keep their 1-minute cache
on an asked read; left as is. The core scripts' budget is not raised:
the ~140 bytes are paid for by two loadQuotas/quotasOpened comments cut.

Run (mote, at 807341cdc on origin/main 5666cb049; rebased onto
505534992 after, which touches only internal/plugin and internal/proc;
the core script budget rechecked at the pushed head, 193 bytes under):
- go test ./internal/provider/ ./internal/gui/ ./internal/tui/ ok
  (TestMainWindowCorners/macOS_26_SDK red on mote's macOS 27, #3949;
  green when run with the -run set at the pushed head)
- go vet the three packages; GOOS=linux go vet -tags nogui and
  GOOS=windows go vet of them ok; go vet provider+tui in WSL ok; gofmt -l
  clean
- GUI, Chromium and WebKit, en+zh: refresh-page, claude-usage-asked,
  usage-refresh, routing-read-allowances, allowance-open-read,
  quota-refresh-order, usage-refresh-flight all pass. A wider set of 119
  files (quota*, panel-quota*, usage-*, allowance*, routing-read/account,
  menu-*, tray-*, i18n-keys) has reds in 6 files, identical at the parent
  commit and filed: i18n-keys #5332, menu-input-scroll #3402,
  tray-cell-click #5215, usage-agents-hide #3414, usage-fold #3415,
  usage-ledger #5048.
- New TestRefreshEveryReadsSavedClaude: an opening's ask runs nothing
  for saved accounts; a top refresh reads each anew; an unasked read and
  a plain asked read after it don't; rapid refreshes keep the floor; the
  every-ask lapses after claudeEveryFor.

Broken by hand: dropping "|| every" from claudeWindows' read turns
TestRefreshEveryReadsSavedClaude red ("top refresh read no allowance of
saved max@x.com"); the panel's refreshPage back on loadQuotas(true)
turns refresh-page's panel subtests red in both engines.

Not tried: a real saved Claude account's /usage run from the real tray
panel (the test fakes Claude Code's /usage per account directory); the
full GUI suite; the de/ja/zh-TW GUI runs (no string changed).
2026-11-06 00:35:39 +08:00
yetone d17a0b3ca0 usage: opening the Usage page no longer stutters (_hii11 on Discord)
_hii11 (Discord #general): switching sidebar pages stutters a little,
most of all on Usage. The click that opened Usage built every allowance
card and curve twice, the first time inside the click:

- renderUsageLoading drew the cards again although the read of the
  allowances that goes with every load (loadQuotas) draws them once it
  answers. Cards already drawn now stay until then.
- every card's draw parsed each history line's readings (up to 6000 a
  window, 45 days) three times. quotaPoints parses a line once for each
  read of the history (loadQuotaHist puts a new quotaHist), and the
  recorded cycles are found once for those points.

The UI is the same; nothing new moves.

Measured on mote, headless Chromium, 1280x820, a busy user's data (10
accounts, 45 days of history, 30 days of usage), Usage clicked 4 times,
frames dropped in the 900ms after the click:
- CPU x1: before 4/4/1/1 (worst gap 50ms), after 1/1/0/1 (33ms)
- CPU x4: before 43/37/33/32, after 32/17/20/19; the click's own task
  ~250ms before, ~70-85ms after; click handling in the trace 303ms -> 89ms.
Agents and Providers switches were 0-1 dropped before and after.

Run (mote):
- usage-open-light.test.cjs (new), Chromium and WebKit, en/zh/zh-TW/ja/de:
  green. Red on the old assets: 17292 dates parsed again per redraw; with
  only page.js put back by hand, the cards are rebuilt inside the click.
- the 195 GUI files that touch the Usage page or its cards, both engines:
  3243 of 3295 pass. Each red file was then run alone on this change and
  on origin/main 4a9cfb52e: the same reds on main, all filed already:
  tray-cell-click #5215, usage-agents-hide #2276, usage-fold #3415,
  context-map #3488, codex-auto-reset (webkit de) #4790, usage-ledger
  Requests #5048. account-eye's '' for 'none' is #5052 (on main too;
  4 of 4 green here alone). plugin-checkin passed alone on both.
- quota-curve.test.cjs both engines green; TestCoreScriptBudget passes.

Not tried: the real app at 60fps (ffmpeg), WebKitGTK on Linux, Windows
WebView2, the reporter's own data.
2026-11-05 00:41:16 +08:00
yetone ce21ea8566 usage, routing: counts are said short (K/M, 万/亿), the exact number on hover (skyhuang1994)
skyhuang1994 on Discord: long token and request counts on Usage and
Routing are hard to read at a glance. They now go through fmtN (K/M/B,
in Chinese 万/亿), with the exact grouped number (ledNum) as the title,
so hovering shows it. A count that fmtN already writes in full gets no
title.

- Usage (plugins/usage/page.js): the Requests table's input, output and
  cache cells (output keeps its reasoning line, cache write its TTLs
  under the exact number), the Requests block, retried, the sources
  tile and the ledger's sum line. sameRead moves here from app.js,
  beside loadSessions, its only reader.
- app.js: the Tokens and Requests blocks (blk takes a title), the
  ledger's call count, the rank's values and "{n} requests".
- Routing (plugins/routing/client.js): the day menu's note, the "more
  days" name, the day rows and the stats.
Core scripts: 22 bytes smaller than their base (1533979 at this head;
TestCoreScriptBudget stays red on #5139 as on main, not worse).

Tests: usage-compact-counts.test.cjs is new (Usage and Routing, every
language, chromium and webkit, 420 and 1100px). panel-usage's rank
value expects "900K" with title "900,000"; ledger-cache-unknown's
counted cells expect fmtN text with ledNum as the title.

Run (mote-run):
- at ded9e4a62 (on c03dee7e3): TestCoreScriptBudget 1533979 (red, #5139),
  usage-compact-counts, ledger-cache-unknown, panel-usage, i18n-keys:
  50/50.
- at c533a569d (on 69eb93e0a): 136 GUI files (usage-*, ledger-*,
  panel-usage, i18n-keys, routing day/stats files) 1868/1917. The reds,
  rest-try-now (#5035, #2564), usage-agents-hide (#2276), usage-fold
  (#3415), usage-ledger (#5048), ledger-swipe (#5223), usage-computers
  (#5224), are red the same or worse on origin/main 0a5dc40ab in a
  4-file run under the same load; c533a569d's 4-file run had a subset.
- at 56fff616a (on d5d48f4f9): 206 GUI files; besides the above,
  tray-cell-click (#5215) red the same on origin/main 009076a2a.
Broken by hand: page.js, client.js and app.js put back to main's ->
usage-compact-counts and ledger-cache-unknown 0 pass / 42 fail;
restored.
Not tried: the real app with real usage data, the Linux WebKitGTK app,
Windows.
2026-11-04 18:44:11 +08:00
yetone 70a98dd85c routing: a long Accounts and keys shows its first rows, the rest behind Show N more (ferock4669, iyou00 on Discord)
With many keys the Routing page's Accounts and keys ran on and on: each
card held every window, the models it answered and a meter. Now a card
keeps its name, one line of what is left (or its rest) and how it fares,
with Try now or Sign in again when it needs one. The models it answered
are in its tooltip under its id, and a subscription's other windows are
on hover over its figure.

A list longer than 8 rows shows the first 8 and puts the rest behind
"Show N more" at its foot (kept across a reload in
magpie.routingActsAll). Never behind it: a row to sign in again, a
resting account or model, failures with no answer, a remote whose
allowance can't be read, rows under a fold the reader opened, and the
heading of a provider with a row shown. Two more alone aren't folded.
The button clicked stays where it is on the screen. "View usage" beside
it opens Usage's Overview, where each account's card says it all,
without making that tab the reader's own (window.openUsageOverview).

The foot writes only what changed, so an idle page writes nothing
(routing-live-calm).

Tests: routing-acts-compact.test.cjs (new; chromium and webkit, en zh
zh-TW ja de, 1300px and 420px). routing-account-windows,
routing-read-allowances, routing-wallet-lapse, routing-accounts-narrow
and routing-columns follow the card's new shape and the foot.

Run on mote via mote-run, worktree based on origin/main c7bbd3faf:
- Whole Routing GUI set (routing-*, panel-routing*) + i18n-keys,
  chromium and webkit: 2487 pass, 29 fail, every red one of those
  below (many-keys and routing-levels #3620 too)
- Same reds on clean origin/main c7bbd3faf (11 files run there): the
  routing-rule-remove (#3096), rule-drag (#3789), row-swap (#3799),
  order-unknown (#4627), rules-line (#3593), steady, steps-cap and
  story-shrinks reds of #5088, in different languages run to run.
- routing-folder went red 2 of 3 with this change (30/30 on main):
  its press() clicked Save while the group editor was still growing
  open, and the foot moved .rt-gsec 8px. press() now waits for the
  button to hold still: 3 runs x both engines 20/20, webkit alone
  10/10.
- TestCoreScriptBudget red, 1534154 > 1533802, identical on clean
  c7bbd3faf (#5139): this change adds nothing to the core scripts.
- routing-acts-compact twice, alone and beside 5 files: 22/22, 20/20.
- Rebased onto origin/main 14f6d10de (its routing client.js changes
  merged clean), at this commit, both engines: routing-remote-windows,
  week-low, free-expiring, group-strategy, acts-compact, live-calm,
  folder, account-windows, read-allowances, accounts-narrow,
  wallet-lapse, columns and i18n-keys all green.
  Pushed on c4245c4c2, which changes only internal/gateway's
  object_root and its doc after 14f6d10de; not run again on it.

Broken by hand:
- rows needing the reader no longer kept out of the collapse (m.keep
  ignored): routing-acts-compact red (Show 4 more never shown).
- a row to sign in again under a shut fold not drawn: red (Zed's fold
  row 0 !== 1).
- the foot's hidden/aria-expanded written every draw: routing-live-calm
  red in both engines (attrs: 6 !== 0), as in an earlier run of this.
- the button's hold removed: routing-acts-compact red (chromium en
  1300px, "the click moved the button: 572.9 → 592.1").

Not tried: the real app with a real long key list (fixtures only), the
Linux WebKitGTK app, Windows.
2026-11-04 18:33:07 +08:00
yetone 9ce59b8340 routing: a request's row says the credits its reply said it cost (jiabubu)
jiabubu on Discord (#feedback): the Routing page's request list showed no
credits for a request that spent them. The gateway already read a reply's
usage.credit (#2512) into the usage ledger, which the Usage page shows,
but the route trace's RouteUsage had no field for it.

RouteUsage now carries Credits (the reply's, nil when it said none). The
Routing page's request row shows "N credits" after its cost, or alone
when the request has no known price (it read "—" before), with the Usage
page's help text under the pointer; By session sums them in the session's
cost, shown even when no request in it was priced. The help text "What it
cost in its plan's credits, as the reply said" moves from the Usage
plugin's i18n.js to the core's, since two plugins say it now.

Tests: TestPluginPlanCreditsReachTheLedger also checks the route's usage
carries 0.01 on every endpoint (red without the field: Credits <nil>).
routing-credits.test.cjs: credits alone, priced plus credits, none, and
a session's sum, in chromium and webkit, en zh zh-TW ja de, at 1100 and
420, with no overflow.

Broken by hand: the old client.js makes routing-credits 10 of 10 red.

Run at the pushed head on mote: gofmt -l clean; go test -run 'TestDailyCredits|TestPluginPlanCredits|Credits' ./internal/provider ./internal/gateway ok; GOOS=linux go vet -tags nogui and GOOS=windows go vet of provider, gateway, gui ok (rebased on origin/main b92b3bc5b). The full GUI suite (WSL, both engines, every language) ran at the earlier base 50265256b; its 58 files red on head but not in main's run were run again, and the 11 files still in question were run on head and on origin/main b92b3bc5b side by side: routing-credits and i18n-keys pass, and every other red is a test main fails too, with an open issue (#4489 usage-ledger-ttft, #4719 usage-speed, #3593/#4560/#4585 routing-rules-line, #4713 routing-time-went, #2559/#4966 routing-bodies, #4400 sessions-bar-names, #1745 group-member-info, #5052 account-eye); head shows a few more languages of those same tests.

Not tried: a real WorkBuddy request through the GUI; history written
before this release has no credits in its routes and reads as before.
2026-11-04 01:27:06 +08:00
yetone 187f3e2727 usage: a swipe across the Requests table is never written back by its scrollbar's echo (Pluviophile)
Pluviophile on Discord (a phone, magpie's web page and the installed
PWA): swiping the Usage › Requests table left or right trembles and
sticks (左右滑动震颤, 粘滞卡顿).

The cause: the table (#ledWrap) and the scrollbar kept at the window's
foot (#ledHScroll, #799) followed each other both ways, each scroll
handler copying its scrollLeft to the other when they differed. The
scroll a copy sets off is told a frame later in WebKit, and on a phone
the finger (the UI side's own scrolling) has moved the table on by
then, so the bar's echo saw bar != table and wrote the table back to
where it was a frame ago, every other frame of a swipe.

Now each copy records the value it set (ledFollow), and that box's next
scroll at that value is its echo and is passed on to nobody
(ledFollowed). A scroll of the reader's on either box still moves the
other, in both directions; ledHScroll's own copy at a redraw goes
through ledFollow too.

Measured with Playwright at an iPhone 13 profile (390x664, touch, dpr
3), the table moved 2.5px every 7ms off the frame, as a phone's own
scrolling moves it, 60 frames:
- WebKit before: 44 writes of the table by the page, the table stood
  still in 29 of 59 frames (5,5,15,15,22,22,...).
- WebKit after: 0 writes, 0 frames standing still.
- Chromium before and after: 0 writes, 0 still; a real touch gesture
  (CDP Input.synthesizeScrollGesture, touch) also showed none. The
  report is WebKit's (iOS), which Chromium doesn't reproduce.

New test, internal/gui/tests/ledger-swipe.test.cjs: the table swiped
off the frame is never written back nor stands still, and the bar
follows; the bar dragged off the frame is never written back, and the
table follows. en and zh, Chromium and WebKit, iPhone 13 profile.

Broken by hand: page.js at its base (d8501848a) turns the new test red
in WebKit, en and zh (the table written back, values in pairs); green
in Chromium, which never had it.

Run at the pushed head, on mote, through mote-run:
- at f5c709ddc (this commit rebased on origin/main 3f1f1882a): node
  --check page.js; ledger-swipe, ledger-hscroll, ledger-hscroll-foot,
  usage-ledger-fit, usage-ledger-detail, phone-web, usage-phone-head:
  55 of 55 pass, Chromium and WebKit.
- before the rebase (base d8501848a): the 33 ledger-*, usage-ledger-*,
  phone-*, mobile-web, usage-phone-head, plugin-page* and i18n-keys
  files, 527 of 547 pass. The 20 reds (mobile-web "magpie web on
  phones", phone-connect-menu 420 "the address clicked from the
  page's top", usage-ledger "newest live route needs no
  return-to-live button") fail the same 20 with page.js at d8501848a
  and are filed: #3952, #5013, #4706, #4707, #3104, #4078, #5048.

Not tried: a real phone (iOS Safari, an iOS PWA, Android Chrome); the
model is WebKit on macOS with the table moved between frames. Desktop
is covered by ledger-hscroll (600px, bar moves the table and the table
the bar, both engines), which passes unchanged.
2026-11-03 19:39:27 +08:00
yetone 69167bc299 usage: a reply let go under a second after a wait four times longer tells no speed
pluviophile714 on Discord: a gpt-6.1-sol row on Routing read 1,539
tok/s (input 21,617, output 392, first token 8.2 s, total 8.3 s), where
another monitor measures ~70. The reply came whole about 255 ms after an
8.2 s wait. Its content was spread over that short window (flow 230 ms),
so the HeldShare flow check passed, and so did the 100 ms floor, and
392/0.255 s read as 1,539 tok/s.

New rule, usage.HeldWindowMs: a window under 1,000 ms whose start
(first token, first text or first reasoning) is more than HeldShare (4)
times the window tells no speed. One rule in every place that computes
one:
- usage.DecodeOf: the Usage page's speed and totals, the CLI, the GUI's
  model speeds, and the gateway's Speed first pacing (noteTrySpeed);
- routing/client.js decodeOf: the Routing row's speed and its story line;
- usage/page.js ledDecode, plus a ledNoSpeed_ reason for the dash's
  tooltip, in en, zh, zh-TW, ja and de.
docs/reference.md and docs/subsystems/gateway-sessions.md say so.

On the owner's usage.jsonl (read only), 103 of the 106 rows over 600
tok/s were such windows (e.g. 448 tokens in 107 ms after 8.1 s) and are
dropped. The 3 that stay have windows of 2 to 5 s. The overall speed
goes from 103.8 to 97.9 tok/s.

What it costs: a short reply that really streamed after a long wait
tells no speed either. The live visible-reasoning fixture (76 tokens
over 731 ms after 6.8 s, ~104 tok/s) and #2637's grok record (307 tokens
403 ms after a 4.6 s first token, 531 tok/s) now read "—". Their tests
keep their guarantees with the same timings after a short wait, and also
check the long-wait case.

Tests:
- New: internal/usage TestShortWindowAfterLongWaitTellsNoSpeed (the
  reporter's numbers, a reasoned row from the ledger, the boundary, a
  second after a long wait, Totals) and internal/gateway
  TestShortWindowAfterLongWaitNotesNoPace.
- GUI: usage-speed-every-row has the reporter's row (dash, and the
  tooltip in all five languages); routing-burst-speed has it (first
  token 8.2 s, no tok/s).
- Updated to the new rule: TestVisibleReasoningSpeed's decode-minimum
  and max-speed cases (short wait now), TestCodexTurnMeasured...'s
  gateway/Claude rows, TestLiveVisibleReasoningFixture and
  TestUsageIngestTellsSpeed.

Run on mote at this tree (rebased on e41ef6288):
- go test -timeout 45m: internal/usage ok, internal/tui ok.
- internal/gateway: red only in TestCompactionOverByteCapEveryTime
  (#4862, full package run; passes 3 of 3 alone).
- internal/gui: red only in TestMainWindowCorners (#3949, macOS 27).
- internal/cli: red only in TestEveryRouteHasACommandOrIsNamed (#5026,
  red on main since 0872bc2a0).
- The two speed fixtures that failed in the gateway run pass on rerun.
- GUI, chromium and webkit: 36 files (every speed, ledger, i18n,
  routing-request and burst file), 609 tests, 603 pass. The 6 reds are
  usage-ledger's "newest live route needs no return-to-live button"
  (#5048, #4078, #3104 on main).
- Rebased on 1af868a15 (f0e0385a0 changed routing/client.js), then
  run again at the pushed head: internal/usage ok; the gateway speed
  tests (-run ...Speed|Pace|Decode|TTFT...) ok; 8 GUI files (both
  speed files, routing-request-metrics/-model, routing-speed-first,
  i18n-keys, reasoning-speed, usage-speed-tip) 94 of 94 in both engines.
- gofmt -l clean. GOOS=windows go vet of usage, gateway, gui and cli ok.
  GOOS=linux go vet of usage and gateway ok; gui and cli need cgo/GTK
  for Linux, the same on main.

Broken by hand: with the check off in usage.go, client.js and page.js,
the new Go tests, TestCodexTurnMeasured..., TestLiveVisibleReasoningFixture,
TestUsageIngestTellsSpeed and both GUI files (1537 tok/s shown) go red.

Not tried:
- the reporter's own request;
- a real GPT stream, to confirm that a 255 ms window after 8.2 s is a
  held reply from this vendor;
- the whole GUI suite (no new API call or layout change);
- the Linux and Windows app.
2026-11-03 17:01:51 +08:00
yetone d10f377657 providers: Names & levels is Names, prices & levels, where a model's own price at one provider is set (ferock4669)
ferock4669 asked on Discord whether magpie has a screen to price each
model, since one model can cost differently on each provider. It has:
each row in a provider's per-model list has a price box (input, output,
cache read, cache write, 1h cache write, long-context tier, $ / 1M
tokens), saved in settings' ModelPrices under pid/model. It wins over
the list price in Usage (usage.Pricer through provider.BasePriceIn) and
in a key's spend cap (usage.KeySpent through NewCoster). Nothing has to
be built; the button opening it said only "Names & levels", so nobody
finds a price there.

What changed:
- The button, its panel's heading and fold, and every note that sends
  the user there say "Names, prices & levels" (zh 名称、价格与推理档位,
  zh-TW 名稱、價格與推理檔位, ja 名前・価格・推論レベル, de "Namen,
  Preise & Stufen"); the gateway's vision and compaction notes, the
  provider package's text, the subsystem pages and the site's start
  docs (en, zh, ja) follow.
- The button's tooltip says it sets what each model costs at this
  provider; Usage's "estimated" tooltip says where a provider's own
  price is set and that it counts over the list price. Both in en, zh,
  zh-TW, ja and de.
- Not changed: the Codex model description text in internal/codexcat
  (it goes to Codex, so a vendor sees it) and core_budget_test's
  history comment.
- app.js: a comment above the price box is shortened so the core
  script stays under its budget, not raised (app.js 116 bytes under
  origin/main).

Run at the pushed head (rebased on origin/main 1af868a15), on mote:
- go test -run 'Budget|ModelPrice|ModelPref|Vision|Compaction'
  ./internal/gui ./internal/provider ./internal/gateway: ok.
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows:
  ok (before the rebase, which touched no Go of this change).
- GUI, both engines, every language each file runs: the 149 files that
  name the label or open a provider's editor (before the rebase): 1191
  ok, 30 red in 7 files. Each of the 7 is red the same way alone at
  origin/main without this change: provider-fetch-again (#5057),
  provider-typed (#4673), provider-levels-scroll webkit (#4395),
  provider-picks-stay (#4397), usage-agents-hide (#3414), usage-ledger
  Requests (#5048), mobile-web (#3952, no .git in mote-run's copy).
  name-suffix-remote "chromium de" (ERR_NAME_NOT_RESOLVED once) passed
  alone at the head. After the rebase: model-price-edit, i18n-keys,
  name-suffix-remote, usage-ledger, usage-agents-hide again: go tests above ok; model-price-edit, i18n-keys and
  name-suffix-remote (all 10 cases) ok; usage-ledger Requests and
  usage-agents-hide red as at origin/main 1af868a15.
Broken by hand: model-price-edit.test.cjs at origin/main's label is red
in all 4 cases (the button "Names, prices & levels" is not found).
Not tried: the whole GUI suite (another session's full suite was on
mote, WSL at load ~100 with 31 test runners); the real app.
2026-11-03 17:00:38 +08:00
yetone c9824bb364 usage: each request's row says the credits its reply said
jiabubu (Discord, #feedback) saw a WorkBuddy request's credits shown
before, and now nowhere. The gateway still keeps them: usage.Record.Credits
from the chat usage's `credit` (#2512) reaches the ledger through the
WorkBuddy plugin on every endpoint shape. The ranking, Overview, tiles and
Sessions show them too. The Requests list's rows never did: a plan's model
there reads "—" for a price, and its detail had no line for credits.

Now the cost cell of a row whose reply said credits shows "N credits"
(the same ledCredits words as the ranking) in place of the dash, or under
the API price reference when the model also has a price. The expanded row
has a Credits line. A reply that said none still shows "—". This applies
to every credit-priced provider, since it reads the record's credits and not
the provider.

Tests:
- internal/gateway/plugin_plan_credits_test.go: a moved workbuddy-ai plugin
  replies with WorkBuddy's credit usage. Chat, Messages and Responses, each
  streamed and whole, each land 0.01 credits in the ledger.
- internal/gui/tests/plan-credits.test.cjs: a new test checks the row's
  cell, its title, a row with no credits, a priced row with credits and
  the detail, at 1400px and 420px.

Run at this head (mote, via mote-run):
- plan-credits.test.cjs: 36/36 in Chromium and WebKit, en, zh, zh-TW, ja,
  de, 1400px and 420px.
- go test -run 'PlanCredits|TestCoreScriptBudget|I18n|Lang' over
  internal/gateway, gui, usage and usageapi: ok.
- gofmt -l is clean. GOOS=linux and GOOS=windows go vet for gateway, gui
  and usage: ok.
- The other Usage page files the change reaches, alone, fail the same on
  the base as with it:
  - usage-agents-hide: 22 (#3414, #2276).
  - usage-fold: 4 (#3415).
  - usage-ledger: 6, "newest live route needs no return-to-live button"
    (#4078, #3104).
  usage-curve-zoom-back passes alone.
- Rebased from f49f6ba68 onto origin/main 6b8134430. plan-credits
  (36/36) and the Budget|PlanCredits Go tests ran again at the rebased
  tree: ok. vet and the other GUI files ran on f49f6ba68.

Broken by hand:
- With the old page.js, plan-credits goes 12 red (the new test in each
  engine and language).
- With chat.go's `out.Credits = c` dropped, all six cases of
  TestPluginPlanCreditsReachTheLedger go red.

Not tried: WorkBuddy China's Claude models, which the plugin sends to
/v1/messages. No real bytes were captured (the account answers 401), and
the gateway reads credit from chat usage only (#5011). There was no real
WorkBuddy request through the GUI; the fixture's usage follows #2512's.
2026-11-03 12:37:37 +08:00
yetone 84da86ebd5 gui: Hide accounts is one switch for every page, window and the panel (paultian)
paultian on Discord (#feedback): Routing, Usage and Providers each kept
their own "Hide accounts" state, so turning it on in one page left the
others showing emails. Now window.hideAccounts is one switch, one
localStorage value (magpie.maskEmails), behind #rtMask, #usageMask and
#pvMask alike. Flipping it in any page applies to every page at once,
and a storage event carries it to other windows and the tray panel.
The old magpie.maskProviders value is folded in on first load (hidden
if either value was on) and then removed, so nobody who hid accounts
on one page sees them shown after updating. The tooltip and the
Settings line now say "on every page" instead of "on this page", in
every language.

Tests: provider-mask.test.cjs checks that one switch hides accounts on
every page and in a second window, that the state survives a reload,
and that an old maskProviders=1 comes through as hidden.
account-mask's expected tooltip text is updated.

Run on mote (GUI files at base 05aba5ca4; the Go asset/budget tests again
at this head after rebasing on a92cc3f33):
- go test -run 'Budget|I18n|Asset|Script|Strings|Lang' ./internal/gui: ok
- The masking/privacy GUI files at --test-concurrency=2, chromium and
  webkit, every language (account-mask-alias-plan, account-eye,
  window-mask, usage-fold, masking-demo-unblurred, account-alias,
  provider-mask, account-eye-provider, account-mask,
  privacy-hides-accounts, account-mask-sessions, mask-emails,
  plugin-name-unmasked, i18n-keys, masking-records): 403 of 408 pass.
  The 5 reds:
  - provider-mask "chromium en 420" (a click timed out). Rerun with
    usage-fold at concurrency 1: provider-mask is all green, and that
    run is 146 of 150.
  - usage-fold, 4 subtests: "17 subscriptions and 29 accounts" in
    chromium and webkit, and "several accounts" in webkit en and zh.
    They fail the same 4 at origin/main 625938a2f at concurrency 1
    (6 of 10 pass). That is #3415 / #4790, not this change.
- Not touched: Go code, so no go vet.

Broken by hand: with the old assets, provider-mask's one-switch tests
go red; with the maskProviders migration taken out, the
old-value-comes-through test goes red.

Not tried: the whole GUI suite (the owner's rule is to ship each
verified fix right away), and the real tray panel on Windows/Linux
following a switch flipped in the main window. Only the browser
storage event is tested.
2026-11-03 11:32:47 +08:00
yetone cb7d7f9aa6 routing, usage: a request names who answered with the provider's logo (Jiabubu)
Jiabubu on Discord asked for the provider's icon before the answering
provider or account in the request lists. Routing's Requests rows now draw
icon(logoOf(member)) for the try's member (tried(r, tr)), the same logo the
request's story uses, between the dot and the name, at 14px. A request
nobody answered has no try and no logo. In Usage → Requests, the "Provider ·
account" cell holds the ledger's provider icon (l.providers) before
.where-name, inside a new .where-line. A row read from a session file
(source "log") names no provider for sure and gets none. .where-name's text
is unchanged. No new strings, no new icons.

Test: request-provider-icon.test.cjs. Routing has codex-color and
deepseek-color, none on the failed row, a 14px logo before and level with
the name. Usage has openai and zhipu-color, none on the log row, the name
alone in .where-name, the logo inside the cell. Chromium and WebKit, en zh
zh-TW ja de, at 1100 and 420px.

Run at the pushed head on mote: see the head run below. Also
routing-log-icons, routing-row-reuse, routing-live-patch, usage-ledger,
usage-ledger-search, usage-ledger-fit, usage-ledger-agent-middle,
session-identity, i18n-keys, phone-rows. Budget tests ok: app.js is
untouched, and the plugin files are outside the script budget.
Broken by hand: dropping the Routing logo makes 22 of 22 red; dropping the
Usage logo makes the Usage checks red in every case.
Not tried: the whole GUI suite (mote was busy with two other whole suites);
the real Windows app.

Head run (mote, 1e6a29337 on 173b7e274): Budget ok. The 16 files above plus
the two new ones: 242 ok, 6 red, all in usage-ledger's "newest live route
needs no return-to-live button", which is red the same way on 173b7e274 alone
(2 of 2; #3104, #4078). routing-row-swap, routing-steady, routing-steps-cap,
routing-story-shrinks, routing-order-unknown and routing-rule-* were red in
the wider run. Run at 173b7e274 and at this head together, they gave 26 and
25 reds in the same tests (#4932, #4628).
2026-11-03 06:25:07 +08:00
yetone dcc84dbc04 usage: the Overview says each account's credits, and the period's (lcyksp)
lcyksp (Discord #feedback) asked to see the WorkBuddy credits (积分) the
calls spent, per account too, not only tokens. The summary already summed
each reply's usage.credit into every group's Totals, and the Requests
page's ranking showed it, but the Overview's Accounts, Models and Agents
rows and its tiles never said it. Each row's line now says "{n} credits"
when a reply said any, and the calls tile says the period's sum. No tile
is added, so the four-tile grid is as it was; the text was translated
already.

Run on mote:
- go test ./internal/usage ./internal/usageapi: ok. TestPlanCreditsByAccount
  (new) checks each account's sum in the summary and the Requests page;
  with Totals.count not adding credits it is red (summary a@x: 0 of 0).
- GUI, every usage*, i18n*, ledger and credits file (both engines):
  1322 pass, 31 fail. plan-credits' new Overview test (5 languages, 420px)
  is red with page.js as before ("WorkBuddy · 70 calls"). The reds are
  usage-agents-hide (#2276, #3414), usage-fold "most on one screen"
  (#4790) and usage-ledger's return-to-live (#3104, #4078, #4626). Run
  alone at d8a34cbcf they fail the same way.
At the pushed head (on b328a7790): usage and usageapi ok; plan-credits,
usage-accounts and i18n-keys 32 pass, 0 fail.
Not tried: a real WorkBuddy account's Overview in the app. Calls from
before replies carried usage.credit say no credits.
2026-11-03 05:16:57 +08:00
yetone 5ec2375688 gateway: a call's HTTP headers both ways, masked, folded under its bodies
usrname1833 on Discord asked to see the raw request and response HTTP
headers (查看原始请求和原始响应的http头), to debug as with a capture.
magpie kept the client's request headers and its own response headers
only in the request archive, and nothing of what went upstream.

Now a call keeps its headers both ways (internal/gateway/wire_headers.go):
- the client's, as they reached magpie: headerLogged in Handler() clones
  them for every request that isn't a GET, HEAD or OPTIONS;
- each request magpie sent upstream for the call: method, address,
  headers, and the answer's status, protocol, headers and time, or the
  error. rpmTransport (under s.client) records it as it is sent;
  provider.SendsThroughPlugin records a plugin account's hand-off, shown
  as handed to the plugin, since the plugin's own request to its vendor
  is made in Bun and magpie doesn't see it (the view says so). The first
  8 tries are kept, the rest counted.
Recording copies each header map; nothing is masked or sorted as a
request goes. Secrets are taken out when the headers are read
(Call.Headers): by what each header is (new redact.SecretHeader, now
behind redact.ScrubHeader: Authorization, cookies, x-api-key, api-key,
any *-Key, *-Token, *-Secret, *-Auth, *-Signature, but Idempotency-Key
and a count of tokens such as anthropic-ratelimit-tokens-remaining),
any Bearer or Basic value, and redact.Scrub on the rest; an address
loses its password, a secret-named query value (?key=) and its fragment.
They live with the call in the 40-call ring; /api/gateway/call gives
them as "headers". The request archive keeps the upstream ones as
"upstream" beside the request's and response's headers, masked the same
way. No body is stored that wasn't before.

GUI: under a recent call's bodies on Gateway and a request's on Routing,
"HTTP headers" folds open the client's headers, then each upstream
request beside its answer (wireHeadersView, plugins/usage/page.js); the
archive's copy shows its upstream requests too. Strings in all four
languages. docs/subsystems/gui-shell.md describes it.

Also changed by SecretHeader: the request archive no longer masks a
rate-limit count header (…-tokens-remaining), which the old name rule
took for a token. (provider.SecretHeader, which backups use, is another
function and unchanged.)

Tests: TestRecentCallHeadersBothWays (a fake vendor; the client's key and
cookie, magpie's upstream key and the vendor's Set-Cookie all masked;
status, protocol and response headers kept), TestRecentCallHeadersEachTry
(a 429 then the next key, both kept in order), TestPluginHandOffHeaders,
TestScrubURL, TestSecretHeaderRealNames (real header names both ways),
TestArchiveOnThisComputer and TestRecentCallBodiesOnDemand extended,
call-headers.test.cjs (Gateway, Routing and the archive's copy; chromium
and webkit; en at 1100px, zh, zh-TW, ja, de at 380px and Routing at 440;
nothing out of the box, no left-border accent).

Run (on mote, macOS 27.2, through mote-run, unless named):
- Full suite at ebd22b1b4 (the same change on 5daba8337): gofmt -l
  empty, GOOS=windows go vet ./... ok, GOOS=linux go vet -tags nogui
  ./... ok, go test -count=1 -timeout 45m ./...: every package ok but
  four tests, none in this change's code, each filed:
  TestEveryRouteHasACommandOrIsNamed (internal/cli,
  /api/usage/checkin-account from e87140242, #4826),
  TestCodexPoolSaysTheClientsVersion (#4807: another test's Codex
  identity, passes alone, 3 of 3 here), TestMainWindowCorners/macOS_26_SDK
  (#3949, macOS 27), TestClosingWindowMarksPageOutOfSight (passes
  alone; filed #4924).
- Rebased on a3768cdd1 (it changed internal/gateway, routing/client.js
  and i18n.js): gofmt, go vet, Linux (nogui) and Windows vet of
  internal/... ok; go test of internal/gateway, gui, redact, provider:
  ok but TestCodexPoolSaysTheClientsVersion (#4807, ok 3 of 3 alone
  with this change's gateway tests) and TestMainWindowCorners (#3949);
  TestCoreScriptBudget ok. GUI: call-headers, routing-bodies,
  recent-call-bodies, request-archive and i18n-keys, 58 of 58.
- Rebased again on 2c90922b0 (app.js and internal/provider, no file of
  this change): TestCoreScriptBudget and TestRecentCall* ok;
  i18n-keys plus call-headers 24 of 24 three times out of four at load
  ~130 on mote. The first try had 1 red of 24 whose name was lost
  (its output was grepped, not kept); it did not come back in 3 runs.
- At the pushed head, rebased on 898c314b7, then 3e61d814e and 8d4d8b2d5 (gateway search, redact; vet, internal/redact and the header tests again ok) (app.css, app.js, i18n.js,
  gui-shell.md and internal/gateway changed): gofmt, vet of gateway and
  gui ok; TestCoreScriptBudget, TestRecentCall*, TestRouteCall,
  TestPluginHandOffHeaders, TestArchiveOnThisComputer, TestScrubURL ok;
  i18n-keys, call-headers, routing-bodies, recent-call-bodies 54 of 54.
- call-headers.test.cjs 20 of 20 (chromium and webkit; en at 1100, zh,
  zh-TW, ja, de at 380; Routing at 440), screenshots looked over.
- GUI: not the whole suite. mote had three other sessions' full GUI
  suites running and the Linux box one, so 131 files the change can
  reach (gateway*, routing bodies/log/steady/story/time, recent*,
  call-*, request-archive, masking*, usage*, i18n*, gui-*, account-eye)
  ran on the Windows box: 1739 of 1862. Every red file was run again at
  5daba8337 on the same box: routing-bodies, gateway-card,
  gateway-systemone, masking-demo, usage-ledger's Requests and the rest
  are red there too (Windows WebKit and Windows-only), and account-eye,
  routing-log-icons, usage-ledger-leave and -probe pass alone at this
  change. call-headers' 4 webkit Routing reds on Windows are
  routing-bodies' own (".rt-day" never visible in Windows WebKit).

Broken by hand, each then put back:
- ScrubHeader back on the name rule: TestSecretHeaderRealNames red
  ("a count of tokens: [REDACTED]").
- rpm.go's upstreamBegins taken out: TestRecentCallHeadersBothWays,
  TestRecentCallHeadersEachTry, TestArchiveOnThisComputer and
  TestRecentCallBodiesOnDemand red.
- scrubHeaders off the sent headers: TestPluginHandOffHeaders red with
  the plugin's key shown.
- Gateway client.js's toggle taken out: the 5 chromium recent-call GUI
  tests red.

Not tried:
- The whole GUI suite (above), and the GUI on Linux.
- A real account or the real app: only fakes.
- What a plugin sends its vendor (made in Bun, not seen by magpie; the
  view says so), and headers Go's transport adds itself
  (Accept-Encoding, Content-Length).
- magpie's own requests (System One's decision, titles, search) keep no
  headers; a gateway served by another magpie shows none.

Asked by usrname1833 on Discord.
2026-11-03 02:25:23 +08:00
yetone 1a864f156e usage: a hidden card a menu bar cell showed offers Show in Overview, not Hide again
Found while fixing yuu003348's report (dee1afa40). A card hidden from
Usage › Overview still shows when a menu bar cell asks for it (usagePeek),
and the "{n} hidden" line leaves it out while it shows. Its menu offered
only "Hide from Overview" again, so from that card there was no way back.
Now its menu has "Show in Overview" (unhides what of it is hidden) and no
Hide items. Translated in zh, zh-TW, ja, de; gui-shell.md says it.

Run (mote, node --test, chromium and webkit):
- usage-hidden-way-back (now with the peek case, every language and
  width), usage-cards-hide, usage-count-client, i18n-keys: ok.
- usage-agents-hide and tray-cell-click: red as at origin/main fdfce4d98
  (#2276/#3414, #4790), same messages.

Broken by hand: the new test on dee1afa40's page.js is 32 of 32 red,
the peek card's menu reads ['Hide from Overview'], not ['Show in Overview'].

Not tried: a real menu bar cell click in the real app.

At the pushed head (rebased on d39358f1b, both commits): usage-hidden-way-
back, usage-cards-hide, usage-count-client, i18n-keys and
claude-quota-onboarding, 100 of 100 ok.
2026-11-02 10:32:37 +08:00
yetone dee1afa400 usage: what is hidden from the Overview can be found again (yuu003348 on Discord)
yuu003348 on Discord: "观测/用量/概览 从概览中隐藏 后 无法取消隐藏". The way
back was there: a "{n} hidden" line under the cards (#quotaHid), each row with
Unhide, Show all from two. But it was drawn in --faint (#b9b9c2 on #f4f4f6,
1.77:1, 11.5px), so it couldn't be found; the Agents list's line (ikunbots on
X) is the same class.

- app.css: .us-hid .us-hidline is --muted (3:1 or more in light; ~5:1 in
  dark by the tokens), for both lines.
- plugins/usage/page.js: while any are hidden, a card's menu and an Agents
  row's menu end with "Show {n} Hidden". It opens the line under its list,
  puts the keyboard on it and brings it into sight on the menu's click
  (openHidden, scrollOnPurpose). hiddenQuotas() is the one count both the
  line and the menu read.
- i18n: "Show {n} Hidden" in zh, zh-TW, ja, de.
- docs/subsystems/gui-shell.md says both.
- usage-cards-hide / usage-agents-hide now expect the new item when
  something is hidden already.

Run (mote, node --test):
- usage-hidden-way-back.test.cjs (new): chromium and webkit, en/zh/zh-TW/ja/
  de, 1200, 560 and 390 (touch long-press): 2 of 2 ok (32 cases).
- 130 Usage/menu/tray GUI files: the only reds the change made were
  usage-cards-hide and usage-agents-hide's exact menu lists, now updated.
  Every other red there is red at origin/main fdfce4d98 too, run alone side
  by side (216 tests at base, 248 at head, the same 72 fail by name):
  balance-fix (#4683), menu-input-scroll (#3402), tray-cell-click and
  usage-fold "most on one screen" (#4790, #3415), usage-ledger "newest
  live route" (#3104, #4078), usage-agents-hide "unhiding a row leaves the
  hidden line where it was" (#2276, #3414; it fails after the menu checks).
  usage-cards-hide is ok at head.
- go test ./internal/gui: ok but TestMainWindowCorners/macOS_26_SDK (#3949).
  No Go changed, so no gofmt or vet.

Broken by hand: on the old assets the new test is red on contrast
("#quotaHid .us-hidline reads rgb(185, 185, 194) on rgb(244, 244, 246):
1.77:1"); with the new CSS and the old page.js it is red on the menu (no
"Show 1 Hidden").

Not tried: the real app or a real account; dark mode's contrast is from
the tokens, not measured in a test; Windows and Linux webviews; the whole
GUI suite (the change is a menu item and a colour, no new API call or
layout).
2026-11-02 10:29:13 +08:00
yetone 2f4c088dce usage: Warm up on a Codex or Claude account's card whose 5 hours haven't started
01huadalang on Discord looked for a way to start one account's 5-hour
countdown on the Usage page, not in Settings. A Codex or Claude account
card whose 5-hour window isn't running now has a Warm up (预热) button on
its account line. It sends the request Settings › Warm-up's Warm up now
sends (POST /api/warm-now {agent, user}), to that account alone: for a
ChatGPT account the scheduled warm-up's one "hi" with the account's own
sign-in, on its cheapest model at low effort (warmModel); for a Claude
account Claude Code's own run on haiku (WarmClaudeVia), so magpie sends
nothing that imitates Claude Code. No new server code.

When it shows: the account is one magpie is signed in to (codexUsers /
claudeUsers), its read has no error, and its 5-hour window is idle as the
scheduled warm-up tells it (idle in codex_warmup.go): nothing used and the
reset a whole window away (within warmSlack), or the reset gone by. A
Claude account never used has no window read and shows it too, as
claudeWindowsExpected fills in; a Codex account with no 5-hour window
doesn't. While the request is out the button is disabled (busy), so a
second press sends nothing; once it went, the account's button stays away
for warmSlack (10 minutes), the time a just-started window still reads as
idle, and the quotas are read again (the server marks the account stale).
Refused, the vendor's reason goes in the status line and the button
comes back. Words in en, zh, zh-TW, ja, de (the tooltip is new; the
button and status lines reuse Warm up now's).

Run (at the head before the last rebase onto 09d5dfb87, which changed no GUI asset or internal/gui file, unless said):
- quota-warm.test.cjs (new), on mote: 20 of 20 pass, Chromium and
  WebKit, en/zh/zh-TW/ja/de, 1100px and 390px. On origin/main with only
  the test copied in, 10 of 10 Chromium cases are red (no button.acct-warm).
- Broken by hand: the 10-minute hold taken out (now - busy < 600e3 ->
  false): red 2 of 2 (the button comes back after the warm-up).
- go test ./internal/gui/... ./internal/provider on mote (before the last
  rebase onto df03aeb35, which touched none of these files): provider ok;
  gui red only in TestMainWindowCorners/macOS_26_SDK, #3949 (macOS 27).
- 25 GUI files near the change on WSL (account-mask, privacy-hides-accounts,
  quota-*, usage-fold/-pack/-accounts/-keys/-card-refresh, warm-now,
  codex-auto-reset, tray-cell-click, panel-usage, i18n-keys, gui-de/-ja/
  -zh-tw ...): i18n-keys caught a comment saying Library's "Not running",
  fixed. The other reds are the same on origin/main 85e37162e run the
  same way: usage-fold "most on one screen", tray-cell-click and
  codex-auto-reset webkit de (filed #4790), warm-now 440px (#4322).
- The whole GUI suite was started at this head on mote (concurrency 3,
  another session's suite beside it); it was not finished at push. One
  red by then, account-eye chromium zh-TW (opacity '' read before the
  styles), which passes 15 of 15 alone on WSL; its fixture's windows are
  used, so no Warm up is drawn there.

Not tried:
- A real account's warm-up from this button. The request is Warm up
  now's, whose own commit (1801c96bf) didn't try a real account either;
  a Codex sign-in copied into a sandbox can rotate the live refresh token,
  and a Claude one lives in the Keychain.
- The tray panel's Allowances, which draws the same account line.
2026-11-01 22:50:45 +08:00
ggbdpq 947377307b usage: the Sessions tab's token totals count the cache, as the Overview's do (#2591)
n1majne3 reports the usage totals ignoring the cache reads the same page
shows beside them. The Overview's totals have counted the cache on request
since #2378 (magpie.usageWithCache); the Sessions tab counted tokens in and
out alone wherever they showed: the tokens tile, a session's row in both
lists (the Usage page's and the Sessions page's, sessSpent), the projects
and models bars and pickers (sessSums, spent), the day chart's bars,
tooltips and calendar, and the top sessions. A reader who asked for the
cache on the Overview saw two different totals for the same period.

The tab now reads usageTokens everywhere, so the one pick decides for both
pages. Its tokens tile carries the same label pop-up and says the cache's
count in its line; a pick made there refreshes the tab it is on, not the
Overview. The chart's day and week buckets carry the cache's counts now
that their value reads them, and the top sessions, ranked without the
cache, are ranked again by the count the reader sees. The default stays
without the cache, as #2378 left it; the per-session median and p90 stay
counted in and out (Stats.Overview ranks them), and the Requests tab's
totals always counted every token (allTokens).

Run at 89521b03 + this: sessions-cache-tokens.test.cjs (new; Chromium and
WebKit, en and zh, APIs faked) fails on the base with "AssertionError: the
tile's tokens: '57.0K' !== '168K'" and passes with the change;
sessions-overview, usage-overview-fold, api-key-usage and
sessions-usage-open pass with it (120 tests, both engines, en and zh).
Broken by hand, each red at its own assertion: the pick's callback pinned
back to renderUsage() (the tab doesn't follow the pick), the top list's
re-ranking left out ("ranked by the count shown"), and the day buckets
without their cache counts ("the day's tokens count the cache").

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-01 16:43:21 +08:00
9097687a31 gui: Hide accounts leaves the user's own account names and plans in sight (#3656)
With Hide accounts (账号打码) on, the name a user gave an account
(#1515) was blurred like the account, so faketrader's several
Antigravity accounts couldn't be told apart; and an Antigravity
account whose value is "Google" blurred "Google" of its plan
"Google AI Pro" on Usage and on the Providers row. The name the user
gave an account is shown text, not an identity. The account is.

- provider: a card's Alias says whether it is the user's own name
  (SubscriptionQuota.Named, set by withAccountNames from
  AccountNameOf), since Alias is also a plugin's name for an account
  (PluginUserOf, a masked phone, #4416) or a seat's key plan, and the
  Usage page and tray panel may have no /api/providers to tell them
  apart. labelProvider is AccountLabelOf's "plugin:" lookup, shared.
- app.js names(): the user's own names (accountNames) and named
  aliases are no longer accounts to hide; accountUsers, an unnamed
  alias and a seat still are (noteAccounts keeps an alias without
  named).
- app.js mask(): labels are scoped by element, never by value
  (LESSONS: scope an exemption by where the value sits). In
  .own-name, .plan, .acct-plan (the Providers row's plan pill, new
  class), .model-value and .subscription-head > b only an address is
  hidden; a plan's and a model's tooltip too (TIPS). The own name's
  tooltip ("name · account") is masked in full.
- .own-name is set only where the text is the user's own: the
  editor's rename span when it has one (else it shows the raw
  account and stays hidden), Usage's quota-alias and the panel's
  pq-user when q.named.

From skygunner's patch (95c0511 on 19253f67), changed:
- Its .acct-who .rename exemption showed a raw non-email account
  (the rename span shows the account when it has no name of the
  user's). Now only an own-name span is exempt.
- Its [title]:not(LABELS) skipped those elements' tooltips
  altogether, so the address in "alias · user" (quota-alias, rename)
  went unmasked. Tooltips are masked; only a plan's or model's hides
  just an address.
- Dropping every alias from names() would have shown a plugin's name
  for an account (#4416 came after the patch's base). Named tells
  the user's own apart.
- The n.data.length < 2 skip the patch removed is kept.
- Its test is rewritten on the new fixtures: an unnamed plugin
  alias, an address in a plan, the editor with and without an own
  name, the panel, a model value, tooltips.

account-alias.test.cjs and account-eye.test.cjs said Hide accounts
hides the user's own name; they now say it stays in sight, the
accounts still hidden. account-alias brings the window's page to the
front before clicking #usageMask, and the panel's before waiting on
it: behind the panel's page it gets no
frames and the click waited for one, red 5 times in 2 runs at
fb3942ee6 (#2984's account-alias half), 0 in 100 after.

Not changed: the tray panel card's tooltip is one string of account
and plan, so a plan word that equals an account's value is still
hidden there (#4677). OpenCode Zen's "Signed in as <account>"
in the issue's screenshot is the raw account, hidden as before.

Core scripts: app.js's own comments in the masking module are cut, so
the core is 742 bytes under its budget at the pushed head (no raise).

What was run:
- At this on 4c815ac2a, on mote (then rebased onto 39bade71d, whose 8
  commits change only i18n.js and plugins/gateway/settings.js; the
  budget measured again, 742 under): gofmt -l; go vet
  of provider, gui, usageapi; go test -tags nogui ./internal/provider
  ./internal/usageapi ok; TestCoreScriptBudget ok; the 19 masking GUI
  files (account-*, mask-*, masking-records, privacy-*, provider-mask,
  provider-unmasked, routing-masking, window-mask, click-scroll,
  i18n-keys), both engines: 539/540. The red was account-alias's
  panel wait behind the window's page, fixed by the panel bringToFront
  above. account-alias + account-mask-alias-plan after it: 4 runs,
  159/160 (one red in "renamed in place", whose body this change doesn't
  touch, #4749). account-alias 6 more runs: 120/120 here, 117/120 on
  origin/main 90c02326b (#2984).
- account-mask-alias-plan: 20/20 on the fix (Chromium, WebKit; en, zh,
  zh-TW, ja, de; 1100 and 420), 20/20 red at fb3942ee6 (the alias is
  masked); red with the plan selectors taken out of LABELS by hand.
  account_plugin_user_test red with Named always false by hand.
- At 4eeba1ca6 (this on 90c02326b): go vet ./..., GOOS=linux go vet
  -tags nogui ./..., GOOS=windows go vet ./..., go build for darwin,
  linux (nogui) and windows: ok. go test -tags nogui ./... on the
  Linux box: every package ok except internal/agent (8 install tests
  red the same on origin/main there, #4033, #3548) and internal/gui
  (TestSettingsSaveKeepsWhatItDoesNotSend, red on main, #4514;
  TestColdTurnsTaken on mote once, #4510). The whole GUI suite on the
  Linux box, 6 wide: 16857 pass, 491 fail in 100 files, none of them
  the masking files but account-every-reset; being run against
  origin/main to sort.

Co-authored-by: skygunner <84759+skygunner@users.noreply.github.com>
Co-authored-by: vincent <vincent@users.noreply.github.com>
Co-authored-by: Fake Trader <9635792+faketrader@users.noreply.github.com>
2026-11-01 15:15:08 +08:00
yetone 457cfd7c63 usage: a phone's head is the tabs over one line of days, sum and refresh
The owner's pick of three phone designs (B): Usage's tabs run across the
head, and under them one line holds the days as a menu ("7 days ⌄", the
app's own menu, never a <select>), the sum, and the refresh as a dot and
its figure ("● 5s", green while live). The days strips (#period,
#sessRange, #ctxRange) are hidden behind the menu. It follows whichever
the open tab shows, and a pick clicks that strip's option, so each choice
keeps its one handler; Custom opens the range menu from the head. Each
control is drawn about 30px and tapped at 44. A desktop window keeps its
strips. The refresh keeps its own menu and
its reload icon, unlike the mock-up, which had neither.
usage-phone-head.test.cjs checks the layout, the menu and the taps in
every language and both engines at 390 and 320px, and a desktop
window at 1100px.

Run (mote, at this branch's head after the rebase onto 8ac1c7a56, beside
8ac1c7a56 itself): go test ./internal/gui/, and 116 GUI files (every
usage-*, view-*, *scroll*, phone-* and thumb file, Routing's rules and
the sign-in files) in both engines, concurrency 4. 1903 tests, 64 red on
the head; 1891, 64 red on main. The branch's own tests pass:
usage-phone-head in all 5 languages and both engines, usage-range,
credit-days, routing-held-dot, routing-rule-columns, segs-glide.
Red on both, each with an issue: TestSettingsSaveKeepsWhatItDoesNotSend
(#4514), TestMainWindowCorners/macOS_26_SDK (#3949), provider-typed
(#4673, filed now), tencent-cloud (#4321), usage-agents-hide (#3414),
usage-ledger Requests (#3104), mobile-web (#3952), phone-connect-menu
(#3524), menu-input-scroll (#3402), provider-levels-scroll (#4395),
view-open-wheel in WebKit under load (#4132).
Before the last three commits and the rebase, the whole GUI suite ran on
this branch: 17076 tests; the reds it alone had were routing-held-dot and
routing-rule-columns (fixed by the thumb commit), credit-days and
usage-range (the two test commits).
Not tried: a real phone; Playwright at 390 and 420px stands in for one.
2026-11-01 12:53:13 +08:00
yetone f7a80bc904 usage: a Model filter beside the Provider filter on Requests (OHHHHHH05 on X)
OHHHHHH05 asked for 按模型筛选 next to the provider filter, with requests,
input/output tokens, cache and estimated cost for the range, gateway and
session-log calls alike. Usage › Requests could already be narrowed to a
model, but only by clicking it in the chart's ranking or typing it in the
search box. Now it has its own filter, after Provider, in the app's menu
(sessPick/openSessCombo, no <select>). It lists the models the other
filters keep, by tokens (/api/usage/requests' by.model, which is counted
without the model's pick). Picking one sends model=, which the server
already applied to both sources, so the sum line (requests, in, out,
cache read/write), the cost head, the through/not-through-magpie cells,
the chart and the rows are all that model's. All models clears it. A
pick made in the ranking shows in the filter too. No API change, no new
strings ("All models", "Model", "{n} tokens" are already in every
locale), app.js untouched (the plugin's page.js only).

Run (at d83823d26 + this; rebased onto b1a1b950f, a routing-classifier
change that touches no Usage file):
- new usage-ledger-model-pick.test.cjs, en zh zh-TW ja de at 1100 and
  420: webkit 14/14 on wsl-run (magpie-desktop), chromium 10/10 on
  wsl-run. mote's browsers were crashing/timing out on launch under
  another session's full GUI suite there, so the GUI runs moved to WSL.
- usage-model-at-provider and usage-ledger-leave: green in both engines.
- usage-ledger: 2 reds, "newest live route needs no return-to-live
  button", the same at origin/main d83823d26 run whole (filed #3104,
  #4078).
- i18n-keys: 1 red, "Unmarked" in plugins/routing (filed #4524).
- go test -tags nogui ./internal/gui on mote: only
  TestSettingsSaveKeepsWhatItDoesNotSend red (SearchAll, filed #4514).
Broken by hand: with the sessPick line taken out of page.js the new
test is 0/10 in chromium (wsl-run); its token note, first written with
a wrong sum, went red in every language before it was corrected.
Not tried: a real gateway's ledger in the running app; the full GUI
suite (one is already running on mote).
2026-10-31 16:44:31 +08:00
yetone c420559fdf usage: a search API's asks, and a plan's own searches, are rows of the request log (#3528)
cybercaius on Discord: "能记录代搜 API 的用量信息吗,在使用过程中看不到它用了哪些代搜 API".
Nothing recorded which search API answered a search, how often, or whether
it failed.

Each ask of a search API (askSearchAPIKeys) and each search sent to Kimi
Code's or WorkBuddy's own search service (ownSearch) is now a row of
Usage › Requests, source "search" (usage.SourceSearch, kind web_search):
the vendor or plan, the host asked, ok / found nothing / refused / the
error, and the time. The row is a probe: it is listed, never counted in a
total or a chart, and never exported. Telemetry reads no usage rows, so
nothing is added to it. The query is not written: an error's text is
scrubbed of it (url.Error reduced to op and host, and the plain,
QueryEscape and PathEscape forms replaced). The Usage page badges the row
"Search API", or "Web search" under a plan's provider, muted.

Run (rebased on 3e5aa1151):
- go test ./internal/gateway ./internal/usage ./internal/settings
  ./internal/budget on Linux (WSL magpie-desktop): ok. With -tags nogui
  there the root package is ok; internal/cli and internal/gui were still
  running at the push (owner: ship at once), any red they show is filed.
- TestSearchAPIAsksAreLogged, TestSearchAPIFailureKeepsNoURL,
  TestOwnSearchIsLogged, TestWorkBuddyPluginSearches,
  TestSearchAPIRowsListedNotCounted; TestCoreScriptBudget ok.
- go vet for darwin, linux and windows on gateway, usage, settings; gofmt.
- usage-ledger-search.test.cjs in Chromium and WebKit, en zh zh-TW ja de,
  wide and narrow; i18n-keys.
Broken by hand: without logSearch the gateway tests go red; with the
query left in an error's text TestSearchAPIFailureKeepsNoURL goes red;
with IsProbe not naming search, the totals test goes red; the old page.js
fails the GUI test.
Reds the same at base 3e5aa1151, filed: usage-ledger, -chart, -ttft,
-open-settled (#3104, #4078, #3001, #4263, #4489); internal/agent on Linux
(#4033).
Not tried: real Tavily, Kimi Code or WorkBuddy accounts; the Routing page
shows no search rows; the whole GUI suite.
2026-10-31 10:32:00 +08:00
yetone 1bbaded622 usage: an agent's call to magpie's own MCP tools is a row of Requests
ferock (Discord) asked to see calls to magpie's MCP tools, such as
magpie-image's generate_image, generate_video and generation_result, in
Routing > Requests.

Each tools/call to magpie's own MCP servers (image, vision, web search,
tools and the Library hub) is now a row of the request log. The row has
Source and Kind "mcp", the tool as its model, the server as its host,
how long the call took, and its error if it failed. The provider and
model it shows are those of the model requests the call made, collected
through the request's context in appendUsage. generation_result names
the model of the job it answers. The stdio Magpie Image server reports
each call it answered to the gateway as "magpie/toolCalled". That report
carries the tool, ms, model and error, never the prompt.

The arguments are never stored at all, so there is nothing to mask. The
rows go down the probe lane: they are listed, but no total, host list,
budget or key limit counts them. The model requests a call made are rows
of their own.

In the GUI the row reuses the Requests list. It gets a muted "MCP" badge
with a tooltip, the server beside the provider, and a Succeeded/Failed
status. The Purpose filter gains "MCP tool" in every language. There is
no new page, no <select> and no left border.

The core scripts went over their budget with the new purpose.
genpurposes now writes purposes.js as compact JSON, which makes the core
448 bytes smaller than main in all, and coreScriptBudget is lowered to
the new total, 1,538,975. No room is added.

Run on mote, at the rebased head:
- gofmt -l: clean. go vet -tags nogui ./... with GOOS darwin, linux
  and windows: ok.
- go test -tags nogui -timeout 45m: ./internal/usage, ./internal/imagemcp,
  ./internal/usageapi and ./internal/gui ok. internal/budget has no test
  files. ./internal/gateway (805s): every test ok except five Antigravity
  and Codex/Grok tests. They fail the same on a clean origin/main
  3bebc3839 and are filed as #4362.
- GUI, the usage-ledger*, routing-request*, purpose*, i18n* and
  gui-zh/ja/de files (25). On mote, Chromium: 32 of 32 ok; WebKit
  could not launch (10 other sessions' suites on mote). On Linux
  (wsl-run), both engines: 335 of 355 ok. The 20 reds are
  routing-request-model, usage-ledger, -ttft, -chart and
  -open-settled, which fail the same at the parent 1534474c8 (#4120).
  usage-ledger-mcp, purpose-filter and i18n-keys are ok in both.
  The whole GUI suite runs after the push, and each red it finds gets
  an issue.
- At the pushed head, rebased on 0804f2d97: ./internal/gui (the
  budget and purpose asset tests among them), ./internal/usage,
  ./internal/imagemcp and ./internal/usageapi ok, and ./internal/gateway
  -run "MCP|Purpose|Probe" ok.
- usage-ledger-mcp.test.cjs covers 5 languages, widths 1180 and 420,
  light and dark, with no sideways scroll.

Broken by hand. Each break went red:
- sawHost's MCP skip removed: TestMCPCallRowsListedNotCounted (the hosts
  list had magpie-image).
- Row/Record.IsProbe's MCP case removed: the same test (3 calls counted),
  and TestMCPCallCountsInNoKeyLimit (Calls: 1).
- The callMCPTool hook removed: TestMCPToolCallIsARequestRow and its
  siblings (no rows).
- The appendUsage hook removed: the row had no provider or model.
- imagemcp's report removed: TestToolCallsAreReported.
- The gateway's magpie/toolCalled case removed:
  TestMCPCalledFromStdioIsARow.
budget's in-memory counts() now skips these rows too. Breaking only that
stays green, because budget.Of reads the file through usage.Visit, which
already skips probes, and limits count tokens and cost.

Not tried:
- no real agent calling a real vendor's drawing;
- no test run on Windows or Linux;
- the page not checked in the real app or in WebKitGTK.
A generate call that answers while its drawing still runs has no model on
its row. The generation_result row that follows names it.
2026-10-30 15:00:16 +08:00
yetone bcf0cfa232 sessions: usage counts a session Claude Desktop's Code tab ran under Desktop
CyberCaius on Discord: Usage's Claude Code filter listed Claude Desktop's
sessions. Desktop's Code tab runs Claude Code, which keeps the session in
~/.claude/projects like a terminal one; only each line's `entrypoint`
(claude-desktop, claude-desktop-3p) tells them apart. The calls were
counted under Desktop already (desktopEntrypoint), but the session, its
stats rows and its summary were Claude Code's, and the gateway's own
record of the session ("claude-desktop|<id>") wasn't matched with it, so
it could be listed twice.

The parse now keeps the entrypoint (state.Entry, on both the ccWhere fast
path and the full parse; cacheVersion 29) and a Code tab session gets
Session.App "claude-desktop". Its Agent, key claude:<id>, resume and
transcript stay Claude Code's. Stats rows and the summary use the app,
GatewayKeys and MergeExternal know the claude-desktop|<id> pair, the GUI
names it Claude Desktop, and Usage › Sessions filters by app || agent.

Run at the pushed tip (the AnySearch commit after this one, on
e8d42c02d): go test ./internal/sessions ./internal/library ok (mote);
go vet darwin, linux -tags nogui, windows over ./internal/... VET-OK;
i18n-keys ok; usage-sessions-desktop-app.test.cjs (new) 4/4 chromium +
webkit, en + zh, on the Linux box (on mote its webkit.launch timed out at
load ~40, before any page code).
This commit alone, before the last rebase (8bd8f50d5 on 1534474c8):
go test ./internal/sessions ok and the new GUI test 4/4 (mote).
Run at 7ec95b5dd (both commits on 1534474c8):
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows
  (mote): VET-OK.
- Full go test -tags nogui ./... -timeout 45m on the Linux box (wsl-run).
  Red only where origin/main eadeb89c4 is red on the same box, each filed:
  internal/agent install detection (#4033, #3548), internal/gateway
  Antigravity turned-away and TestCodexSpentGrokFailingIsTold (#4362);
  internal/cli TestAgentFieldNameShowsIt and
  TestEveryAgentFieldNameWritesNothing red in the full run, ok alone at
  this tip (#4247).
- GUI: i18n-keys and gui-de/ja/zh-tw ok on mote; the other sessions-*
  and usage-* files hadn't finished on mote when pushed.
- The whole GUI suite has not finished: a WSL run at the tip was about
  half way (2226 ok) when this was pushed, with reds only in files these
  changes don't reach (routing key models, panel name width, LAN
  addresses, Codex composer, Copilot GHE, gateway key limits, ...);
  they'll be checked against origin/main and filed on their own.
Earlier, before the rebase (da5f1e5bd on ffa07395e): full go test
-tags nogui ./... on mote, 80 packages ok.

Broken by hand, each red: stats not using appsOf (usage agent stays
claude); the Entry in claudeFull; the Entry in ccWhere (the test's first
line is an attachment so the fast path is taken); MergeExternal without
the App pair (3 sessions become 4); page.js's byAgent on agent only (GUI
test times out).

Not tried: a real Code tab transcript (none on this machine; fixtures are
written from the field names only). A Code tab that sends the plain
magpie key through settings.json env would be recorded by the gateway as
claude, not looked at. NativeIDs for claude-desktop doesn't read Claude
Code's files yet: #4333.
2026-10-30 14:38:22 +08:00
yetone 75a7db27b9 usage: an allowance card can be hidden from the Overview (whqtian_07012 on Discord)
whqtian wanted StepFun's plan card on Usage › Overview without its
balance card. Right-click a card (or long-press it on a touch screen)
and the app menu offers "Hide from Overview". With several accounts on
one card it says "Hide this account from Overview". A plan card that
carries its key's balance also offers "Hide its balance from Overview",
which keeps the plan. Each hidden card is saved as its tray card id plus
its kind (stepfun|balance, kimi|me@x|plan) in settings.UsageCardsHidden,
through POST /api/usage/arrange (cardsHidden). The Settings save keeps
it. Under the cards, a quiet "{n} hidden" line opens them, each with
Unhide, and Show all from two. It is the same pattern as the Agents
list's hide.

Display only: routing, caps, counting, the Accounts list, the tray
panel's Allowances (it has its own Arrange) and the menu bar cells
never see it. A cell clicked for a hidden card shows it until the page
is left (usagePeek). UI: the app menu, not a native select, no
coloured stripes, no new button on the cards.

Run at this head (rebased on 96a703a59):
- mote: go test -timeout 45m ./internal/gui ./internal/settings.
  settings ok. gui: only TestMainWindowCorners/macOS_26_SDK red, and it
  is red on origin/main 96a703a59 too (#3949, macOS 27).
  TestUsageArrangeCardsHidden and TestSettingsSaveKeepsWhatItDoesNotSend
  pass.
- Linux box (wsl-run): 107 GUI files that reach the Usage page, the
  quotas, the panel, i18n and gui-de/ja/zh-tw, in Chromium and WebKit:
  1362 of 1419 pass. usage-cards-hide passes in both engines, in en, zh,
  zh-TW, ja and de, at 1200px, 560px and 390px (touch, magpie web).
  i18n-keys passes. The 9 red files were run alone at origin/main
  96a703a59 and are red there too (57 red at the base, 51 at the head).
  #4120 has 7 of them. usage-ledger-open-settled (#4262) and
  usage-ledger-chart (#4263) are newly filed.

Rebased again on 9f36d768d, which changed app.js elsewhere. At this
head: usage-cards-hide, i18n-keys, usage-arrange, panel-arrange,
key-balance-card and usage-shared-balance on the Linux box, 72 of 72
pass. On mote, go test -run 'TestUsageArrange|TestSettingsSave'
./internal/gui: ok.

Not tried: a real StepFun account in the real app. The fixture is a
StepFun plan card with its key's balance plus a balance-only card. Not
run on Windows.
2026-10-29 18:52:05 +08:00
yetone 792f0f2860 usage: Requests opened again on the same rows aren't drawn or fit again, and new rows wait for the sidebar to settle (#4064, xisdumpling)
xisdumpling (Discord dumplings04605) sees frames drop when switching into
Usage > Requests at 7 days (~1,670 requests): the ledger's redraw and
ledFit's reflows land inside the sidebar's 460ms navSubEnter move.

Two causes, both fixed in internal/gui/assets/plugins/usage/page.js:
- Coming back, open() -> loadUsage(true) -> loadLedger read the same page
  again and redrew 100 rows even when nothing changed. The ledger now
  remembers the ledParams it was read with; on open with the same params
  it is read quietly ("open"), and same rows keep the table shown.
- #ledWrap's ResizeObserver refit the table at width 0 when the view was
  hidden and again when shown. It now skips a fit while the wrap has no
  width, so the table keeps the fit it had.
- Rows that did change on open are drawn after the sidebar settles
  (navSettled: rAF until navTop.raf and .nav-sub.moving are gone, capped
  at 700ms), and dropped if the reader moved on meanwhile.
No layout change: the table keeps its class (led tight) and the page its
scroll position in every run.

Measured with a harness (1,670 requests, 100 rows shown, 1280x800,
Gateway -> Usage click; Chromium trace counting full-tree style recalcs
(>1000 elements) and layouts (>1000 objects) within 480ms of the click):
- Chromium on mote, same rows, 4x CPU throttle: full restyles/layouts in
  the move 8/5 -> 2/1, longest task 194 -> 108ms, style 280 -> 126ms,
  layout 112 -> 46ms. Unthrottled: 8/5 -> 2/1, style 73 -> 37ms.
- Chromium, changed rows, 4x: 8/5 -> 2/1, longest frame gap in the move
  167 -> 100ms, longest task in it 147 -> 67ms, busy 464 -> 230ms.
  Unthrottled: in-move gap 33 both, longest task 40 -> 32ms; the gap
  after the move is 33 -> 50ms, since the redraw now comes after it.
- WebKitGTK on WSL (software rendering, noisy): changed rows max gap
  522 -> 339ms, in-move gap 222 -> 188ms; same rows 561 -> 490ms,
  211 -> 195ms.

New test usage-ledger-open-settled.test.cjs (Chromium and WebKit): same
rows keep the table, draw nothing, refit 0; changed rows draw once with
the sidebar at rest, newest first, same fit, no scroll move.
Broken by hand: old page.js is red in both engines ("the table shown is
kept"); without the "open" wait red ("once, with the sidebar at rest");
without the width guard red ("nor fit again at the width it had").

Run at this head (rebased on bfe1f9a2b):
- The new test, click-scroll and i18n-keys, Chromium on mote: new test
  ok; click-scroll red twice in a 3-file run at load 30-80 (.rt-days
  timeouts), then 12/12 alone both at bfe1f9a2b and here.
- go test -run 'Budget|Asset|I18n|Script' ./internal/gui on Windows: ok.
At aad6546cd (the rebase's previous base; origin/main since changed
app.js, not page.js or the nav motion):
- GUI files that reach the change (*usage*, *led*, view-open*,
  click-scroll*, nav-sub*, nav-top*, *period*) in Chromium on Windows:
  765 tests, 69 red, the same 22 red subtests at base and here, in
  tray-usages, usage-agents-hide, usage-ledger-ttft, usage-ledger,
  usage-speed (#4124).
- The same set in WebKit on Windows: 586 tests, 25 red. Run head to
  head with bfe1f9a2b: 26 red here, 28 at main, here a subset of main.
  currency and usage-accounts filed as #4204; gateway-caller-keys
  #3797, usage-focus-steady #3501, the rest #4124. view-open-wheel
  WebKit: 51/80 red at base and here.
- go test ./internal/gui on Windows: 9 reds, all on #4115, #1827, #4177
  or #4195 (TestUsageLedgerRoutes/DayRoutes red at base alone).
- Whole GUI suite in WebKit on WSL: still running at push, 3051 ok and
  82 red through routing-*; no red in a usage or ledger file, 17 red
  files not on #4120/#4121 are being run at main to file.
No Go file changed, so gofmt and vet have nothing new.

Not tried: macOS WebKit (mote's Playwright WebKit doesn't launch), the
whole Chromium GUI suite (mote at load 180-350 crashed browsers; run
abandoned), the reporter's own machine.
2026-10-29 15:59:45 +08:00
yetone ff6fdffd60 usage: opening the page on Requests or Sessions asks no vendor for allowances (#4064)
Opening Usage called quotasOpened() whatever tab it opened on, so a
switch to the page on its Requests or Sessions tab started an asked
read of every vendor's allowance and the allowance history beside the
tab's own read, and the frame the switch drew waited on all of it.
Only the Overview shows the allowances; it now alone asks for them.
Clicking the Overview subtab still asks (loadUsage(true)).

allowance-open-read: leaving the page on Requests and coming back past
the 30s gap asks no vendor and no history; clicking the Overview then
asks once.

Run on mote at this tree, rebased on origin/main 96115018c (its one
new commit, #4072, touches the gateway keys page and CSS only; the
list below ran again after that rebase):
- node --test allowance-open-read, claude-usage-asked, refresh-page,
  usage-refresh, usage-refresh-flight, usage-stale-answer, quota-reads,
  quota-refresh-order, usage-quota-head, usage-loops, i18n-keys
  (chromium and webkit, en and zh): pass 123, fail 0.
- go test -tags nogui -run Budget ./internal/gui: ok.
- Broken by hand (back to `if (asked) quotasOpened()`): the four
  allowance-open-read Usage-page runs go red, 5 !== 4.
- usage-ledger's 'newest live route needs no return-to-live button' is
  red in both engines, the same alone on a clean origin/main 11cbf4de1
  copy; filed as #3104 and #4078.

Not tried: part two of #4064 (Routing's frame loop while an agent
runs) is not in this commit.

Reported-by: xisdumpling (#4064)
2026-10-28 23:00:55 +08:00
yetone 11cbf4de1d usage: Sessions' agent filter is a menu, as the model and folder ones beside it
The owner (10-28, screenshot of Usage › Sessions with 13 agents in a strip
across the page): "这应该是个 Combo Box". The agent filter was a segmented
strip, one segment per agent in range, that scrolled sideways in itself
once it ran past the window (#929). It is now the same sessPick button
as 全部模型 and 全部文件夹, with the same searchable menu: "All agents",
then every agent with sessions or usage in the range, the most used
first, each with its tokens under the other two filters. One agent in
range still leaves it hidden; the pick still resets to All when its agent
leaves the range. The request ledger's agent filter was already this menu.

#sessAgent left the CSS rules for scrolling strips; the strip's own test
(sess-agent-strip, #929's sideways scroll) is gone with the strip, and
usage-sessions-agents-fit now checks the menu: no sideways scroll at 860
and 560 wide, the three filters on one line inside the window, the
menu's order, search, a pick shown on the button and kept when the page
is drawn again, All clearing it, one agent hidden. sessions-empty-range
and sessions-overview-once pick their agent from the menu.

Run on mote (node 22, Playwright 1.62.0):
- usage-sessions-agents-fit, sessions-empty-range, sessions-overview-once:
  24 of 24, Chromium and WebKit, every language they cover.
- usage-sessions-agents-fit against origin/main's page.js, client.js and
  app.css: red in all four (BUTTON.sess-pick expected, a div of segments).
- go test -tags nogui -run Budget ./internal/gui: ok.
- 122 other GUI files that touch Usage, sess-pick or i18n, concurrency 3,
  beside another session's full GUI suite (load 36-75): 1944 pass, 24
  fail in gateway-caller-keys, gateway-key-cycle, i18n-keys,
  mcp-oauth-app, usage-ledger and web-page. Rerun alone at concurrency
  1 on this tree and on origin/main (d4f1d6480, then c4972b36e after the
  rebase): the same reds on both. gateway-key-cycle is #4072,
  gateway-caller-keys #3797, usage-ledger's "newest live route" #4078,
  web-page's #gateway .dot #4079. i18n-keys' "masking…" was fixed on
  main in 174250b27. mcp-oauth-app passes alone on both.
- At this tree, rebased onto 6ecc65b6d (the pushed tree):
  usage-sessions-agents-fit, sessions-empty-range,
  sessions-overview-once, i18n-keys and click-scroll 50 of 50, and
  go test -tags nogui -run Budget ./internal/gui ok.
Not run: the whole GUI suite (another session's was running on mote).
2026-10-28 22:52:30 +08:00
yetone 012c584cc1 usage: clear a model's usage, or all of it, from the Usage page
CrazyMouse_TT on X asked for a way to clear usage, all of it or one
model's, to measure a local model fresh after deploying it.

The Usage page's Models list has a "…" on each row (and a right-click
menu) with "Clear usage…", and "Clear all usage…" sits under the lists
below the "Counted from…" note. Each asks first, in a confirmation that
says what is deleted, that it can't be undone, and that key spending
limits and allowances still count the calls.

A clear is a mark in settings (usageCleared: provider, model, unix ms),
read at read time; usage.jsonl is never rewritten. The Overview hides
calls up to the mark in summarizeFrom; the Requests page, heatmap and
ledger/CSV hide them in Filter.keepsRow, their one choke point, and the
request index's meta carries the marks so its cache is dropped. Key
budgets, window holds and Codex reads go through usage.Visit and the raw
log, so a clear never resets a key's spending limit or a quota. A later
clear of the same model or of everything takes the place of an earlier
one. The marks ride the settings part of a sync (sync-backup.md) and a
save of the Settings page keeps them (api.go's keep list; the guard
test TestSettingsSaveKeepsWhatItDoesNotSend caught it missing).
gateway-sessions.md and sync-backup.md say so.

Run on mote (mote-run) at this tree, rebased on origin/main c26b2992e
(the Go packages and usage-clear.test.cjs; vet and the 68 GUI files
ran at the earlier base f835bd713, four commits behind):
- go test -tags nogui -timeout 45m ./internal/usage ./internal/settings
  ./internal/usageapi ./internal/gui: all ok after the
  keep-list fix (before it, TestSettingsSaveKeepsWhatItDoesNotSend red).
- gofmt -l: clean. GOOS=linux go vet -tags nogui ./... and
  GOOS=windows go vet ./...: exit 0. (Linux vet without nogui fails in
  wails' cgo, as on main.)
- usage-clear.test.cjs: 32/32 in Chromium and WebKit, en/zh/zh-TW/ja/de,
  at 1200, 560 and 390 (web). With the old page.js/client.js/i18n.js it
  fails (TimeoutError).
- 68 GUI files the change can reach (every usage-*, gui-de/ja/zh-tw,
  i18n-keys, click-scroll, idle-ticks, mobile-web, panel-usage,
  sessions-purge): 941/980. The reds are filed and red on main
  (usage-ledger run alone at origin/main 84a6a2c42 too): i18n-keys "masking…" (#4053), mobile-web
  (#3952), usage-agents-hide (#2276, #3414), usage-ledger "newest live
  route needs no return-to-live button" (#3104, run alone at main too).
  i18n-keys first also named "Clear usage…" in Go comments of this
  change; reworded.
Broken by hand, each red: hides() always false (usage and gui tests),
keepsRow's clear check removed ("Requests after the clear: 5 rows"),
clearedKey out of the request meta ("after clearing everything: 3"),
the api.go keep line removed (UsageCleared [] after a save).

Not tried: the full go ./... suite and the whole GUI suite (mote was
busy with other sessions' full suites), the real app, a sync between
two computers. usage.jsonl doesn't shrink, and the Sessions tab's
figures are not cleared.
2026-10-28 21:13:09 +08:00
yetone a6f6e86e80 gui: an account's eye shows that provider's account, and a Kiro account's eye works
outloudvi on Discord (#feedback, 1564924864052207627): on Usage's overview
with Hide accounts on, Kiro's eye did nothing, and one username on two
platforms was shown or hidden by either card's eye.

- Kiro: the plugin names an account "email (Google)" (nameOf in
  packages/kiro). The finder tried the address pattern first, so only the
  address was hidden. The eye kept the whole name, which never matched
  what was hidden. A name with an address in it is now found whole,
  before the address pattern.
- One name on two providers: shown was keyed by the account alone, and
  kin() gathered names from every provider. Each entry is now keyed
  "provider\naccount". eye(u, p) takes the provider id at every call: the
  provider editor, the account button, the panel's quota card and Usage's
  quotaWho. Text by an eye (its row, or its card one level down) follows
  that eye's provider. Text that is near no eye, like a sentence elsewhere
  in the window, shows when the account is shown under any provider, as
  before.

New test account-eye-provider: Usage cards for Kiro (one email, Google
and GitHub), Codex and ZCode (the same address) are rendered with Hide
accounts on. It runs en and zh, at 900 and 360px, in both engines.

Run on mote:
- account-eye-provider at this tree: 4/4.
- go test -tags nogui -run Budget ./internal/gui: ok (no budget raised).
- 124 GUI files the masking, Usage, panel and storage code reaches, both
  engines, run with the next commit on top: 1761/1792. All 7 red top-level
  tests are in quota-count-wrap (#3404, #2228), usage-agents-hide (#3414,
  #2276) and usage-ledger (#3104), plus one masking-records zh-TW and one
  quota-refresh-order. Those five files were run again at origin/main
  33af28ed6 and at this tree: the same 29 reds on both. masking-records
  and quota-refresh-order were green in that rerun (quota-refresh-order
  had failed on keep(), fixed in the commit before).
Broken by hand:
- Back to the old eye and finder: every case red at "the Kiro account's
  eye shows it" (chromium and webkit, en and zh).
- Only the provider keying undone: every case red at "the same address
  on ZCode stays hidden".
Not tried: a real Kiro account (the name's shape comes from the plugin's
source), and Linux and Windows.
2026-10-28 17:58:50 +08:00
yetone 9e33962c05 gui: Settings has Reduce motion, stilling magpie as the system's does (#3813)
CupOfBread asked for a switch that turns magpie's motion off to save
resources on the desktop, and linull24 saw the Routing page keep a
phone's browser busy. magpie already stills its animations under the
system's Reduce Motion: 46 @media (prefers-reduced-motion: reduce)
rules across app.css and the plugins' styles, and calm() in the
scripts. Settings -> General now has "Reduce motion" (Off / On) that
does the same without the system setting.

- settings.json keeps reduceMotion; boot.js passes it; a POST that
  leaves it out keeps it, as the other prefs.
- theme.js's holdStill(on) sets data-motion="reduce" on <html> and sets
  the media of every stylesheet rule written for reduced motion to
  "all" (and back when turned off), so the same rules apply and no CSS
  is written twice. layout.js calls it before the first paint when the
  saved setting is on; applyPrefs calls it on a change.
- calm() is true when data-motion is reduce too, so the scripts'
  motion (Routing's stage, Library, Usage) holds still with it.
- routing.css: the reduced-motion rule for the live dot was
  .rt-livedot, which lost to .rt-livedot.on's animation; it is now
  .rt-livedot.on, so the dot stands still with either setting.

Measured on mote (Chromium 390x844, 4x CPU throttle, live Routing
traffic, CDP Performance over 10s, two runs each): main-thread task time
0.18 and 0.22 s/s with it off, 0.090 and 0.085 s/s on; style recalc
0.021/0.025 off, 0.008/0.011 on.

Tests: reduce-motion.test.cjs (new, both engines): saved on, the
reduced-motion rules apply from the start (a probe's live dot has no
animation, calm() is true); Off restores them and posts false; On again
posts true. TestSettingsReduceMotion: off by default, kept by a POST
that leaves it out, cleared by false, in settings.json and boot.js.
The Settings row is in settings-general's list of rows.

Run on mote at this head (rebased on e8c7dddcb): go test -run
"TestCoreScriptBudget|TestAppScriptBudget|TestSettings|TestBoot|TestI18n"
./internal/gui ./internal/settings: ok (the core budget not raised);
GOOS=linux, windows and darwin go vet -tags nogui of both: clean.
reduce-motion, settings-general, i18n-keys, routing-live-calm,
codex-descriptions, codex-predictions, codex-titles and old-webkit:
61 pass, 1 fail, the Safari 15.0 styles check below.
gofmt -l: clean.

Not tried: the real Linux (WebKitGTK) and Windows (WebView2) apps; the
setting changes only which existing CSS rules apply. old-webkit's
"Safari 15.0" check is red on origin/main from c490165b1's :has() in
.proto-menu (#4020), not from this change.
2026-10-28 16:50:16 +08:00
yetone 0c973cd9a4 usage: the Sessions bars are rows of their own, not a subgrid (#3955)
The Sessions overview's bars (Projects, Models, Tool use) and Top
skills were each a subgrid of their card, the same layout that crashed
Safari 16's WebKit sizing the Routing requests (#3731). Each row is now
a grid of its own. sessLineUp reads each column's width with the rows at
their natural width, once, when the card is first shown, and sets it on
the card as --sb<i>. The widths don't change with the window's, and text
size is the window's zoom, so it never measures again on a resize. The
@supports not (subgrid) fallback is gone: Safari 16 has subgrid, so it
never helped.

sessions-bar-names now checks that no rule of the bars says subgrid,
that every row's bar starts and ends at one x (wide, at 420 and wide
again), and runs in every language, not only en and zh.

Run on mote at this head:
- sessions-bar-names: 41/41 pass. At origin/main's assets
  (MAGPIE_SESS_ASSETS) 40/41: only the subgrid check fails, so the bars
  line up as they did.
- Broken by hand (sessLineUp returns at once): 20 of 21 red, bars' left
  at 527,338.
- sessions-overview, account-mask-sessions, i18n-keys: pass.
- go test -run 'Budget|Asset|CSS' ./internal/gui: ok.
- node --check page.js: ok.

Not tried: a real Safari 16 (no macOS 13 machine). Next for #3955:
.quota-windows .quota's rows subgrid.
2026-10-28 12:09:02 +08:00
yetone 396e0e4638 usage: a deleted provider's requests merged into another, or named, from the Requests filter
CyberCaius on Discord: a deleted provider's requests sat under its old id
("<date> 已删除"), and the only way to put them under a provider they
have was renaming that provider onto the old id. Now, with a deleted
provider picked in Usage › Requests' Provider filter, a "…" beside it
offers Merge into… (an app menu of the providers there are now) and
Rename… (the filter's button turns into a name field; Enter or leaving
it saves, Escape keeps it). With the merged-into provider picked, the
same "…" lists Separate <name> for each, the undo.

Nothing in the log is rewritten. Both live on the deletion's own record
in providers.json (Deleted.Into/MergedAt, Deleted.Label), so a provider
added later under the old id inherits neither: it is a different
provider, and its record of its own is what it has. Renaming the target
carries the merge (Rename rewrites Into); deleting the target ends it.

Renames.Both(id, time) gives the id a call is shown under and the one it
was made to (Own). Listing, filtering, the summary and vias go by the
shown id; pricing (Record.priceID, block_price's as), window holds and
the gateway's loggedAnswers go by the own one, so a merge moves no cost
or token, only whose name they sit under. The target's face lists what
was merged into it (Named.Merged). Routes: GET /api/usage/deleted/into,
POST /api/usage/deleted {id, into?, name?}; a field not sent stays.

Run (mote, at this tree on d50f84c9f):
- go test -tags nogui -timeout 45m ./... : every package ok, exit 0.
- GOOS=linux and GOOS=windows go vet -tags nogui on usage, usageapi,
  provider, gui, gateway: ok. gofmt -l clean.
- New: TestDeletedProviderMergedIntoAnother (usage: cost 306 before and
  after the merge, 3 calls under main, coster/pricer price a relay call
  at its own price, a new "relay" keeps only its own call, rename and
  delete of the target, undo), TestDeletedProviderNamedAndMerged
  (usageapi), TestUsageDeletedProviderRoutes (gui).
- GUI: usage-ledger-deleted-merge.test.cjs, chromium and webkit, en zh
  zh-TW ja de at 1400 and 760px: ok. All 63 usage-*/ledger-* files and
  i18n-keys, both engines: 923 of 954 ok. The reds are red the same on
  origin/main c3b0484a9 run alone: usage-agents-hide (#3414),
  usage-fold (#3415), usage-ledger's "newest live route needs no
  return-to-live button" (#3104), and i18n-keys' "a plugin's words are
  its own" on library's "Runs as" (#3897).

After rebasing on origin/main 3e96197da (i18n.js merged with c3b0484a9's
balance keys): go build ./..., go test of internal/usage/...,
usageapi/..., provider/..., gui/... ok; the new GUI file in both
engines and every language ok; i18n-keys only #3897's red.

Broken by hand:
- Both returning (to, to): TestDeletedProviderMergedIntoAnother red,
  "cost 900, before 306".
- renamesOf not setting into: both Go tests red (relay still listed).
- ledProviderMore returning at once: the GUI test red (timeout waiting
  for the …), 5 of 5 subtests in chromium.
- On the old code the new tests don't compile (no MergeDeleted).

Not tried: the real app on a real providers.json with a deleted
provider; Linux/Windows GUI. gateway_sessions still prices by the raw
id, and a deleted provider's per-provider price stops applying once its
id is reused (both before this change, unchanged by it).
2026-10-28 11:15:57 +08:00
yetone c3b0484a96 usage: keys of one account show its balance once (mimi)
mimi on Discord (#feedback): "同一个网站,添加多个key时,余额会重复展示" -
a site's keys 1-A031-Pro, 2-S009-Plus and 3-S010-Team-2 each showed the
account's $8.39 and its own curve.

KeyBalances still reads, keeps and charts every key on its own. What
changed is what the Usage page draws:
- balanceRead says whether the reading is the account's (balanceAccountWide),
  going by the source, not the vendor's name:
  - account-wide: a balance token (new-api /api/user/self, sub2api
    /api/v1/user/profile, AiHubMix), a known host's account query
    (DeepSeek, Moonshot, OpenRouter credits, SiliconFlow, StepFun, ...),
    and sub2api /v1/usage when its mode is "unrestricted" (wallet or the
    group's subscription, per sub2api's gateway_handler.go Usage);
  - per key: AiHubMix's /dashboard/billing/remain, new-api's
    /api/usage/token, sub2api in quota_limited mode, any other Balance
    URL the user named.
- Two such keys of one provider with the same amount are one account only
  when their balances moved together: the same latest change (from and
  to), first read within balanceHistGap. Two accounts with the same
  amount stay apart until one is spent from; keys whose amounts differ
  are never one. SharedBalance (the first key's name) says so in
  /api/usage/quotas, magpie quota --json and /v1/magpie/quotas.
- Refreshing a shared card reads every key it stands for (sharesAskedCard),
  so it stays one card. The history is read outside the cache's lock.
- The Usage page draws them as one row, one balance, one curve, with
  "+2 keys" beside the key and the keys on hover; the head's sum counts
  the account once. The code is in plugins/usage/page.js, so app.js is 9
  bytes smaller than before; no budget raised.

Run (mote-run, at the pre-rebase base d50f84c9f):
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet
  ./...: ok. gofmt -l: clean.
- go test -tags nogui -timeout 45m ./...: every package ok except
  internal/gui's TestCoreScriptBudget (app.js 676 bytes over; fixed by
  moving the code into the Usage plugin, then ok) and internal/update's
  TestRelaunchOpenTriedAgain (TempDir cleanup under load, #3881; 3 of 3 ok
  alone).
- go test -race on internal/provider's balance tests: ok.
- GUI, both engines, en and zh: 122 files (balance-*, usage-*, quota-*,
  tray-*, panel-*, gui-ja/de/zh-tw, i18n-keys, key-balance-card,
  routing-wallet-balance, ...): 1637 pass, 42 fail in 6 files, all the
  same at base a05b37353 run alone and all filed (#3679 quota-refresh-
  order, #3404 quota-count-wrap, #3414 usage-agents-hide, #3415
  usage-fold, #3104 usage-ledger, #3897 i18n-keys "Runs as"). After the
  move into the plugin, 17 of those files again: only #3897's red.

Broken by hand, each red:
- SharedBalance never set (the old code): "after they moved together".
- Shared on equal amount alone: "first reading" ("other" merged).
- Every query taken as account-wide: quota'd and new-api token keys
  merged.
- No sharesAskedCard: the shared card's refresh didn't read sk-plus.
- keyCards without sharedBalances: usage-shared-balance red in all four
  (chromium/webkit x en/zh).

Not tried: a real sub2api or new-api account (fake server with sub2api's
literal replies). A key's balance is shown once only after the account's
next change is seen by every key, not on the first read. Multi-currency
balances (DeepSeek "$ · ¥") and balances with parts are never shared.
2026-10-28 10:52:46 +08:00
yetone 3e22123c9c usage: a deleted provider's calls stay apart from a new one under its id
cybercaius (Discord): after deleting a provider and adding a new one
that took the same id, the old provider's usage showed under the new one.

Delete now records the provider in providers.json ("deleted": id, name,
icon, when, its Was and Gave). UsageRenames gives a deleted id to
<id>~<when> only once something reuses it (a live provider, a later
deleted record, or a later Was), so a deleted provider nobody replaced
keeps its raw id and the existing probe/usage tests stay as they were.
/api/usage's provider faces name a deleted id from its record and set
Named.deleted; the Usage provider picker notes "Deleted {date}" (zh, zh-TW,
ja, de translated). Old deletes, made before this, have no record and
stay merged: nothing tells their calls apart now.

Run (mote): go test -tags nogui -run 'Deleted|Rename|NotSetUp|Probe'
./internal/usage ./internal/usageapi ./internal/provider ok; gofmt -l
clean; go vet -tags nogui ok.
Broken by hand: dropping the f.Deleted append turns
TestDeletedProviderKeepsItsCallsFromOneAddedUnderItsID and
TestDeletedProviderListedApartAndMarked red; restored, green.
Not tried: a real delete-and-re-add in the GUI app.
2026-10-28 04:18:21 +08:00
yetone 8fba65d0bc gateway: what masking took a request is kept, and shown as Masking in its time
fremontdango on Discord asked, after the request that sat as "routing…"
while it was masked, how long masking took. Now each request keeps it.

noteRedacting adds up the time from the first masking at once to the
last's end (redaction.spent); maskingMs gives it in ms, at least 1 when
there was any, never more than Own, magpie's own time before the request
went out (splitSent), since masking happens inside it. It goes on the
route (Route.Masking, /api/gateway/trace) and in the usage record
(Record.Masking, masking_ms; packedRow's int32 fits in its padding, so
TestRowsOfOneSessionShareAShape's 216 bytes are unchanged, and the
process-private snapshot carries it). It is a duration, no text.

The Routing page shows it as magpie's "Masking" part, first in where the
first try's time went (timeParts, renderSteps); the Usage page's detail
splits it out of "In magpie" (page.js). Both use the core "Masking"
string every language already has (脱敏, 脫敏, マスク, Maskierung).

Why masking can be slow, measured on this machine (go1.27, M-series):
the rules are linear, ~0.25 ms/KB. redact.MaskJSON over a Claude Code
shaped body: 283 KB 35 ms (secrets) / 63 ms (+ personal data); 511 KB
70 / 122 ms; a dense 402 KB with 7,821 hits 173 ms with personal data,
144 ms with the user's words too. Through the gateway (redactedHits,
secrets + personal, 402 KB dense) 145 ms the first time, 123 ms again;
noteMasked ~2.6 ms. Doubling the body doubles the time; nothing
quadratic or repeated per hit. So a request held "routing…" for 15 s or
more (unroutedShow) while masked is the local model (Settings → Privacy
→ Find with a local model, internal/pii): it reads each text it hasn't
seen (a new turn's tool results are the misses), one model turn at a
time, so requests queue behind each other (#3682: 480 KB took 90 s on an
RX 470/580). No change to masking's speed here; the phase and the time
now say which it was.

Run at this head, on origin/main 9ae791221 (Go, M-series macOS):
- go test -timeout 45m ./internal/gateway ./internal/gui ./internal/redact
  ./internal/usage: ok (gateway 425s, gui 99s); ./internal/masking and
  ./internal/pii ok at the pre-rebase head 3a4a13d04
- gofmt -l internal: clean; go vet ./..., GOOS=linux go vet -tags nogui
  ./..., GOOS=windows go vet ./...: clean; go build: ok
- go test -race -count=3 TestMaskingIsAPhaseWithItsTime,
  TestNoMaskingNoMaskingTime: ok
- GUI, chromium and webkit: routing-masking (every language) 10/10,
  usage-ledger-detail 6/6, i18n-keys and routing-levels green. The whole
  routing-*, panel-routing*, usage-ledger* and i18n-keys set: 1,824
  tests, 96 red at load ~47, in 15 files. The first run's i18n-keys red
  was this change's (a Go comment quoting the core word), fixed in the
  commit before. The other 14 files, rerun two at a time at this head
  and at origin/main 9ae791221: the same files red on both (89 here, 86
  there; routing-rule-remove alone 5 red here, 7 on main). Each has an
  issue: #2115, #3410, #3411, #1905, #3593, #3408, #3096, #3094, #3001,
  #3104, #3786.

Broken by hand, each red: spent not added (route and record Masking 0),
no t.Masking on the route, no Masking in the usage record, the snapshot's
put/take of Masking (TestRowsOfOneSessionShareAShape), timeParts without
Masking or renderSteps without the first try's masking
(routing-masking), the Usage page without the Masking line
(usage-ledger-detail, 3 red).

Not tried: a real local model (Settings → Privacy → Find with a local
model) on the reporter's Windows box or any GPU, so a long masking was
only held by a fake masker; the Codex backend's usage record has no
Masking yet; the Windows test box wasn't used.

Reported by fremontdango on Discord.
2026-10-27 08:08:23 +08:00