Commit Graph
44 Commits
Author SHA1 Message Date
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
yetone 8bc72bf10a gui: the Sessions tab's 15 s reads send only what changed, not the ~8 MB list
Every 15 s the Sessions tab read /api/sessions (7.9 MB over a long
history, 5000 rows) and /api/sessions/stats (0.7 to 5.7 MB), parsed both
and ran JSON.stringify over the old and new answers to find them the
same. While an agent works one row changes, so it was all of it, every
poll, in the WebView.

- writeJSONSame (api.go) tags an answer with a hash of its bytes. An ask
  whose X-Magpie-Had is that tag gets X-Magpie-Same and no body, and the
  page keeps the object it has. Used for the stats.
- writeJSONRows does the same for the list, and keeps each row's hash
  for the last 4 lists it sent. Asked with the tag of one of those, it
  sends X-Magpie-Delta: sessions and a list of only the new rows, each
  run of old rows written [from, count].
- api() in app.js sends the tag it has, rebuilds a delta on the rows it
  holds (the same objects), and remembers each answer's tag. The tab
  compares answers by tag, so it no longer stringifies 8 MB twice.
- Not an ETag and a 304: on Windows Wails strips If-None-Match from
  WebView2's requests and turns a 304 into a 505.

Run at this head (macOS, go1.27, parent eee571999 = origin/main):
- TestSessionsSentOnceWhileTheSame: an unchanged answer is sent with no
  body, another tag gets it whole, and after a new session the list is
  the new row plus [0,1], which rebuilt on the old list equals the whole
  answer. Red with the Had check or the delta turned off by hand.
- tests/sessions-same.test.cjs (chromium and webkit, en and zh): no body
  sent again while unchanged, and the very objects kept. One new session
  sends a delta, and the old row is the object the tab had. The new
  title is drawn. Red in chromium with the client's rebuild removed.
- go test -tags nogui -timeout 45m ./internal/gui/ ./internal/sessions/
  ./internal/usage/: ok. gofmt -l clean; GOOS=linux and GOOS=windows
  go vet -tags nogui ./internal/gui/ ./internal/sessions/: ok.
- GUI: the 72 files that read /api/sessions or its stats, and
  i18n-keys, both engines: 1081 tests, 1053 pass, 28 fail. The fails are
  usage-agents-hide (#3414) and usage-ledger's "newest live route needs
  no return-to-live button" (#3104). Each file fails the same alone
  with eee571999's app.js and page.js (5/11 and 14/3 in chromium).
- A built binary on the real history (~15.9k sessions, a Claude Code
  session being written), six reads 15 s apart sending the last tag:
  20,753 B once (only this session's row), then 0 B with Same five
  times; the list was 7,928,438 B whole. Each rebuilt list equalled a
  whole read taken just after it. Stats asked again: 0 B, against
  5,688,332 B whole.

Not run: the whole GUI suite (~12.5k tests, ~5 h at this load). It was
stopped at 1,218 tests with only account-discovery red, which is #3497
and is red the same with this change's app.js and page.js put back.
Not tried: the Windows app (WebView2) and the Linux app.
2026-10-27 06:18:24 +08:00
yetone d3191a51c8 gui: with Hide accounts on, an account's eye shows that one account in this window (yogurt36)
yogurt36 on Discord, for a screen share: with Hide accounts on, one
account should be readable while the others stay masked. Now an
account's name on the provider editor's row (accountNameButton and the
one-account line) and on its Usage card (quotaWho) has a quiet eye, in
sight on hover or keyboard focus, with an aria-label. A click shows
that account, its address and the name the user gave it together
(kin), everywhere the window draws it, tooltips included: the shown
set is skipped in hits(), which every mask goes through. It lives in
memory only. The tray panel keeps hiding it, and closing the window
hides it again: the page stays loaded while the window is hidden, so
hideMain runs mainClosedJS (hideAccounts.closed) first. With Hide
accounts off there is no eye. Strings in zh, zh-TW, ja and de.

Run (macOS, playwright 1.62.0, rebased on 630fd1d69; at push 0f6615ffc, site only, came under it):
- account-eye.test.cjs: 20/20 in chromium and webkit, en zh zh-TW ja
  de, 900px and 360px (no select, no stripe, no sideways scroll, a
  click scrolls nothing, Tab (Alt+Tab in WebKit) reaches the eye).
- Red on the old code (feature stashed): both tests fail.
- Broken by hand, each red, then restored: the shown check in hits();
  closed() without shown.clear(); kin() returning only the address.
- TestClosingHidesShownAccounts (new): red without shown.clear() and
  without the ExecJS(mainClosedJS) call in hideMain.
- go test -run 'TestCoreScriptBudget|TestBuiltinClientsLoaded|
  TestClosingHidesShownAccounts' ./internal/gui: ok. app.js
  1,306,355 bytes, under 1,321,319; budgets not raised.
- i18n-keys.test.cjs: 4/4.
- gofmt -l clean; go vet (mac), GOOS=linux go vet -tags nogui,
  GOOS=windows go vet ./internal/gui; go build, GOOS=linux go build
  -tags nogui, GOOS=windows go build: ok.

After the last rebase one chromium en/zh run of account-eye showed 1
fail of 4 with 179MiB free on the disk; its log wasn't kept, so the
test is unnamed. Every run since, with its log kept, passed: 4/4 and
then 20/20 in both engines.

Not run: the whole GUI suite and the full go test ./internal/gui
(another session's suite held the machine and the disk was full; one
link hit ENOSPC and passed on retry). They run after the push.
Not tried: the real Wails window's close (hideMain) by hand.
2026-10-26 18:18:24 +08:00
yetone 2620dc319f gui: Routing's countdowns, Usage's refresh look and the lanes' read tick only while in sight (#3185)
#3185 reports magpie's Energy Impact while nobody uses it. In the real
app (sandbox HOME, main window open on Providers, panel hidden) the two
WebKit WebContent processes woke ~5.9 and ~6.0 times a second. A census
of every setInterval in WebKit over 30s idle found three that fired from
anywhere, drawing nothing:
- routing/client.js's 1s countdown tick (30 in 30s),
- usage/page.js's 1s look at the refresh period (30 in 30s),
- app.js's refreshLanes every 2s (15 in 30s), which returned at once
  with no lane pill in sight.
Each now runs only while its page (or a lane pill) is in sight and stops
itself otherwise: Routing's starts again from start() when the page is
seen, Usage's from its view's hidden attribute, visibilitychange and
focus, the lanes' from laneText drawing a pill and visibilitychange.

Measured on the built app (go build -tags production, sandbox HOME,
`magpie app`, 90s warm-up, then 120s of proc_pid_rusage wakeups):
- before (e5dd86965): WebContent 5.93 and 6.01 /s, main 6.69 /s
- after: WebContent 1.61 and 0.93 /s, main 7.70 /s
The main process is unchanged: its threads are Go's (sample + per-thread
CPU: ~10ms CPU in 30s, ~0.03%), and a Go trace of the new build shows
~2.6 goroutine starts/s, mostly the minute loops lined up at :10 and :40
and the 2-min forced GC. That is left to its own change.

Test: tests/idle-ticks.test.cjs counts each interval's ticks by script
and period under Playwright's clock: on Providers none of the three
ticks in 10s; on Usage its look ticks and Routing's doesn't; on Routing
the reverse. Red on e5dd86965 in both engines ("plugins/routing/
client.js ticked out of sight, 10 !== 0"), green here.

Run at this head (rebased on origin/main e5dd86965):
- go test -count=1 -timeout 45m ./internal/gui: ok (budgets included;
  app.js 1,326,086 under 1,326,105, core scripts under 1,542,418)
- GUI, both engines: idle-ticks, i18n-keys, lane-limit, usage-refresh,
  quota-curve, quota-holds, sess-agent-strip, usage-head-steady,
  click-scroll, routing-time, routing-time-went, routing-reset-deadline,
  routing-auto-reset, usage-card-refresh, usage-refresh-flight,
  usage-loops, routing-idle-frame, routing-hidden-stage,
  panel-routing-hidden, routing-js, routing-sessions,
  usage-focus-steady: all pass.
- routing-steady (2 red) and routing-live-patch (6 red) fail the same
  on origin/main e5dd86965 run alone: #3412 and #3637.
Not tried: the window minimised or closed (WebKit's own throttling), and
Linux/Windows webviews; the change is plain JS timers.
2026-10-26 14:59:13 +08:00
yetone ffe493773c usage: magpie's own Test, Detect APIs and model list requests are rows of the request log, counted nowhere
neiko and gys619 on Discord: a provider's Test or Detect APIs left no
trace in Usage > Requests, so a failing test couldn't be read back.

The provider package marks the context of the editor's Test, Detect APIs
(and per-model detection) and a model list's refresh with a kind
(internal/probelog). Each request sent under the mark is written once:
by the provider's Do, or by probelog.Transport under http.DefaultClient
(netproxy.Install), whichever sends it first; the Claude Code run and
the gateway's translated test write theirs from their result. A row
keeps time, provider, account, model, host, path (no query, no
user:password), method, status, ms and the first 500 bytes of the error.

The row is usage.SourceProbe, agent "magpie", Kind provider_test /
api_detect / model_list ("Test", "Detect APIs", "Model list" in Called
for; purposes.js regenerated). The log index keeps probes apart
(logSnapshot.probes), so Visit, Load, Summarize, budgets, Vias, heatmap,
shared days, LastSeen and observers never meet one. The request page
lists them (probeChunk) and counts none: Row.IsProbe, since a packed row
keeps the row's Source and not its record's. The page shows a muted
badge "magpie's own · not counted in any total" (en, zh, zh-TW, ja, de);
no new control, no layout change.

Tests, each red on the old code:
- usage TestProbeRowsListedNotCounted: listed, clipped, and absent from
  Sum, Through, every By group, Summarize, Load, LastSeen, OwnDays and
  the observer; a provider filter lists it and sums 0.
- provider TestTestWritesItsRequestsDown / TestDetectWritesItsRequestsDown:
  every request the fake server saw is exactly one row, with the right
  kind, model and 401 text; an unmarked Do writes nothing.
- probelog TestNoteKeepsNoSecret, TestTransportOnce.
- GUI usage-ledger-probe: badge per language, both engines, 1180/420,
  light and dark, no left border, no sideways scroll.
- gui TestProviderDetectDraft now expects the log line (source probe,
  kind api_detect, no key) and leaves usage.jsonl out of the unchanged
  config comparison.

Broken by hand, each went red: request_page's uncounted check,
log_index's probe skip, Append's observer skip, Do's Taken (6 rows for
4 requests), Test's and Detect's marks, probelog's query strip,
page.js's badge (11 GUI fails).

Run at this head (on origin/main 22a7f86c9): gofmt -l clean; go vet
./..., GOOS=linux -tags nogui and GOOS=windows clean; go test -count=1
usage, probelog, netproxy, usageapi, provider and gui packages ok (the
rebase over 22a7f86c9 applied cleanly; upstream's 8b460833e chunk
cache leaves probeChunk, built per query, alone).

Run one rebase earlier (on origin/main 0b72ccbef; request_page.go
merged by hand onto 7d67910f7/66b6d6ade's per-row Totals, with
uncounted rows skipping the caller and account groups too):
- go test -tags nogui -timeout 45m ./... in a sandbox HOME, log tee'd:
  every package ok (gateway 640s, agent 514s, provider 278s, usage 77s)
  but internal/gui's TestRestartHandsTheGatewayOver (7 of 8 requests
  answered during the restart), 3 of 3 green alone after (#3451).
- gofmt -l clean; go vet ./..., GOOS=linux -tags nogui and GOOS=windows
  go vet ./... clean.
- GUI usage-ledger-probe, usage-ledger-reported, i18n-keys,
  purpose-filter, quota-pool-model: 72/72. usage-ledger's "newest live
  route needs no return-to-live button" is red on origin/main 0b72ccbef
  alone too (#3104).
- Whole GUI suite, both engines, at the pre-rebase base 761904b5a:
  1313 tests; reds, each also red on origin/main 7b1faf99f alone:
  account-discovery "agents' sign-ins read" (#3497), builtins
  "Plugins > Built-in" (Masking page in the list, #3518 filed), and
  context-map "two tiles overlap" chromium ja 420 (#3488; 1 of 2 red on
  main alone, 3 of 3 green on this branch alone). Earlier package run:
  TestRestartHandsTheGatewayOver red under load, passes alone (#3451).
- No size budget raised.

Not tried: no real vendor account (fake servers only); a plugin's model
list, fetched in the JS plugin host, isn't written down; the real GUI
app wasn't launched (Playwright only).
2026-10-25 04:12:06 +08:00
yetone 761904b5ab whatsnew: Settings' What's new can show this version and the 10, 20, 50 or 100 before it (Linka)
Linka (linkaww, Discord, 10-25): 希望「关于 - 更新内容」加个可选项,查看
「上次更新以来 / 当前版本前 10 / 20 / 50 / 100 个版本」的更新说明.

Settings › About › What's new now has a pill in its head (the app's
menu, sess-pick, never a native select): "Since the last update", the
default and what it showed before, or "This version and {n} before" for
10, 20, 50 and 100. The dialog shown by itself after an update has no
pill and is unchanged.

- site/worker.js: /api/notes takes limit=, the newest that many after
  upto, so a request for 11 isn't answered with 100.
- internal/update: NotesBack(ctx, upto, n, lang) asks upto and limit
  n+1; Back(notes, upto, n) keeps upto and the n releases before it,
  newest first, Install sections stripped, empties dropped. It is not
  capped at MaxNotes (40), which only Between keeps.
- internal/gui/whatsnew.go: /api/whatsnew?all=1&last=N, for N in
  10/20/50/100 only (anything else is the default). Cached per language,
  the longest range asked kept, and a shorter one cut from it, so
  picking 10 after 100 asks nothing and a reopen asks nothing. A failed
  fetch is unknown: the reply carries error and whatever range was had
  before.
- app.js: openWhatsNew(b, last) and wnRange. A pick that fails keeps
  the notes last shown, says "Couldn't load the release notes" with Try
  again above them, and Try again asks the same range.
- The archive helpers (archivedCalls, headersPanel, downloadArchive,
  archiveBodyPanel), used only by the Usage page, moved to
  plugins/usage/page.js as d08b6118b did, so app.js stays under its
  budget (1,319,177 of 1,321,336); no budget raised.
- i18n: three strings in zh, zh-TW, ja and de.

Run at the pushed head (rebased on origin/main 0d2a10116):
- go test -count=1 -tags nogui ./internal/update/ ./internal/gui/ in a
  sandbox HOME: ok (TestNotesBack, TestWhatsNewBackRanges,
  TestCoreScriptBudget among them).
- gofmt -l: none. go build ./...; go vet ./...; GOOS=linux go vet -tags
  nogui ./...; GOOS=windows go vet ./...: ok.
- node --test site/worker.test.mjs: 21 pass (new: limit keeps the
  newest that many up to upto; "", 0, x and -1 mean no limit).
- GUI at this head, both engines: whats-new-range (new), whats-new,
  whats-new-failed, i18n-keys, ledger-cache-unknown, request-archive and
  request-archive-usage (the Usage page holds the moved helpers): 50 of
  50. whats-new-range.test.cjs alone is 12 of 12: five languages x two
  engines plus the post-update dialog in both. Covers the default label
  and no last= asked, the menu's head and five items, 10 then 100,
  the same pick asking nothing, a failed 50 keeping the 100 shown with
  the error above, Try again, no scroll, no left-border accent, and a
  440px window with the pill inside the dialog.
- Whole GUI suite (869 files), chromium then webkit, concurrency 4:
  still running at push time, started at 1f156ba40 (the same change on
  e57e78563); the tree was rebased under it at 01:45. Chromium at 01:46:
  1725 top-level tests passed, 7 red, none in a What's new or Usage file:
  agents' sign-ins, Plugins › Built-in, zh-TW 420px context map, gateway
  mode, an MCP server out of the library, and "a menu opened from a long
  text box's rule stays open" (en, zh). They will be checked against
  origin/main and filed or fixed when the run ends. Before the rebase,
  usage-ledger's "newest live route needs no return-to-live button" was
  red here and on an origin/main e57e78563 copy alike (#3104, #3001).

Broken by hand, each red, then restored:
- the pill not added to the head: whats-new-range red.
- the kept notes not used on a failure: red at "the notes shown before
  are kept".
- the ?last= route skipped: TestWhatsNewBackRanges red.
- Back not cutting to n+1: TestNotesBack red.

Not tried:
- the real site: the test fakes /api/notes and /api/whatsnew. The site
  holds GitHub's newest 100 releases, so "100 before" on the newest
  version can show at most 100. An undeployed site ignores limit; the
  app cuts the list itself.
- the real app window (Wails/WebKitGTK); only Playwright's engines.
- go test ./... in full was not run: the machine had a queue of other
  sessions' full suites, and the owner's rule is not to hold a verified
  commit behind one.

Known limits: a range view carries no pending (waiting update) notes;
if a longer cached range dropped an Install-only release, a range cut
from it can reach one release further back than a fresh ask would.
2026-10-25 01:46:55 +08:00
yetone 3a47e377e0 usage: a call whose vendor counts no cache is left out of every hit rate (#3464)
#3464 (zeewell on X): Kiro caches on its side, but its replies give only
credits and a context share, never cache tokens. Every hit rate outside
the Routing page read those calls' CacheRead of 0 as a miss. A Kiro-heavy
day showed "hit rate 6%" when the counted calls hit 90%.

The plugin already says so (opencode-kiro-auth 0.1.16 sends
usage.magpie_cache_unknown), and the gateway already kept it as
RouteUsage.CacheUnknown for Routing. This carries it the rest of the way:

- gateway: Usage.cacheNotCounted() (the vendor said so and no try
  reported a cache token) goes into usage.Record.CacheUnknown on every
  path that records a call: the gateway's own record, the OTel attempt
  path in observe.go, and trace's routeUsage.
- usage: Record.CacheUnknown is kept as ledger row flag 8192
  (rowCacheUnknown; grepped, no other flag uses that bit). Totals sums
  such calls' prompt into cache_unknown and counts them in
  cache_unknown_calls. Totals.HitRate leaves that prompt out of its
  denominator, and gives no rate when nothing is left.
- Old records: calls kept before the plugin said so carry no flag. A
  Kiro call (provider kiro or kiro-plugin) with no cache counted is read
  as uncounted (usage.CountsNoCache): in the ledger's row read, in
  Totals, and for Routing's history in internal/gui/trace.go
  (cacheCounted). The rule is scoped to Kiro's two ids, so another
  vendor's 0 stays a miss (tested).
- GUI: cacheHitOf in app.js drives the tray panel's card, the Usage
  page's agent rows and cache tile, the requests' Cache hit rate card and
  each ranking row. When only uncounted calls are left it shows "—" or
  nothing instead of 0%. Otherwise it says "{n} requests left out: their
  vendor doesn't count the cache". A request row's cache cells show "—",
  and its details say the vendor doesn't count the cache. The Context
  page (context.go, context.js) shows no cache for such a call and doesn't
  score it as a miss.
- No budget raised. This adds 625 bytes to app.js (1,320,224 to
  1,320,849, under its 1,321,336); d08b6118b had already moved the
  masking page's maskWho, maskProv and stillMotion out to
  plugins/redact, which an earlier version of this change did too.
- Strings in zh, zh-TW, ja and de. docs/subsystems/provider-plugins.md
  now describes the ledger side and what is not covered.

Not covered, filed: hit rates read from the agents' own session files
(the TUI and CLI session lists, the Sessions tab's totals) still count
Kiro's 0 as a miss (#3470). Found on the way: System One's calls are
recorded without their cache tokens (#3471).

Run at this tree (on origin/main e57e78563, fetched just before; the
54-file GUI run was at a84d2ec80, and the 14 files that main's
redact page change since could reach were run again here):
- gofmt -l . prints nothing. go build ./... ok. go vet ./... ok,
  GOOS=linux go vet -tags nogui ./... ok, GOOS=windows go vet ./... ok.
- go test -count=1 -timeout 45m ./internal/usage ./internal/gui
  ./internal/gateway: all ok (gateway 388s), TestCoreScriptBudget
  included.
- GUI, 54 files (ledger-*, panel-*, i18n-*, context-*, request*,
  usage-card*, usage-ledger and the masking/redact files),
  concurrency 2: WebKit 439/452, Chromium 444/457. The new
  ledger-cache-unknown test passed in both. Again here (ledger-*,
  masking-*, redact-*, mask-*, usage-ledger): WebKit 104/117,
  Chromium 109/122, the same reds. The reds, both already
  red alone on main before this change:
  - redact-words-any-case, 10/10 in each engine (#3500)
  - usage-ledger "newest live route needs no return-to-live button",
    en and zh in each engine (#3104)
- At earlier bases, with the same change: usage-agents-hide (#3414),
  usage-checkin's WebKit Qoder tab (#3091), usage-fold (#3415),
  usage-focus-steady (#3501) were red, each red alone on main too;
  usage-card-refresh read a row before it was laid out, under load
  (#3509); context-picks (#3483) and
  context-map's tile overlap (#3488) in Chromium. Filed while doing
  this: TestUsageReadAfterAppendHashesNothingOnAFineClock goes red
  about 1 in 20 on main aa3112f4e (#3511); it passed in this run.
- Red on the old code: the new Go tests in usage, gateway and gui, and
  ledger-cache-unknown.test.cjs (the old page shows "hit rate 6%"
  where this shows 90%). Each changed piece was broken by hand and
  turned a test red. The exception is the OTel attempt path in
  observe.go, which no test reaches.

Not tried: a real Kiro account through the GUI.
2026-10-25 01:23:42 +08:00
yetone d08b6118bd agents: Restart a desktop app that started before magpie's change, after asking
微雨南山 and stones on Discord: Claude Desktop, WorkBuddy and the Codex
app read magpie's settings only as they start, so a change made in
magpie did nothing until they quit and reopened the app themselves.

The agent's row now carries a Restart when the app is installed, running,
and started before its config last changed (agent.AppBehind):
Claude Desktop, WorkBuddy and WorkBuddy AI on macOS (bundle executable
via pgrep), Claude Desktop and WorkBuddy on Windows (process tree, main =
earliest process whose parent is outside it). A press opens magpie's own
dialog first (confirmAction); Cancel and Escape send nothing. On accept
POST /api/agents/restart/{id} quits the app gracefully (AppleScript quit
on macOS; taskkill without /F on Windows, then /F /T after appCloseWait
for a tray that holds on), waits, and opens it again. On macOS an app
that won't quit is reported (StillOpen) and never forced. The Codex
app's existing Restart now asks first too. CLI agents get none.

changedAt: a stash digest that changed with no file written since the
app started now counts the change as now, so a change magpie made while
the app ran is seen (it was dated to the old write and missed).

app.js budget, not raised: archivePanel moved into plugins/usage/page.js
(its own comment called it the Usage page's; Routing's trace calls it at
draw time, after page.js has loaded), maskWho, maskProv and stillMotion
into plugins/redact, and usageHidOpen into plugins/usage. app.js is
1,108 bytes smaller than on main, budget unchanged.

Run (the first five at the pre-rebase head, same code):
- GUI agent-app-restart + agent-stale-copies: 120/0, chromium and webkit,
  en/zh/zh-TW/ja/de, window 980 and 440 and panel 440, no sideways scroll,
  no placeholder in aria-label or title.
- Broken by hand: without the confirm the GUI test is red; without the
  changedAt fix TestChangedAtWithoutAWrite is red; without the since gate
  TestWorkBuddyRestartOnMac and TestWorkBuddyRestartOnWindows are red.
- macOS, real fake-app processes in a sandbox HOME with a stubbed
  launcher: quit in 100ms and reopened; a held quit returns StillOpen
  after 4s, not forced.
- Windows box, console session (schtasks /IT), fake app and stub
  launcher: graceful close in 407ms; a tray that holds on is ended after
  5.66s; reopened through the stub.
- gofmt -l clean; go vet darwin (agent, gui), GOOS=linux and
  GOOS=windows; builds.
- At 2c5327925 (on origin/main 703437866): go test -tags nogui
  ./internal/agent ./internal/gui ok. 95 GUI files (mask, redact, usage,
  request-archive, routing-bodies, agent-app-restart, agent-stale-copies,
  i18n, insights, panel), 6 wide: 1380/53. 52 of the reds are the same
  tests red on origin/main 3b5a2f612 run alone, all filed: #3500
  (redact-words-any-case), #3414 (usage-agents-hide), #3415 (usage-fold),
  #2549/#3091 (usage-checkin Qoder tab, WebKit), #3001 (usage-ledger's
  route callback). The 53rd, usage-curve-zoom-back chromium zh-TW, passes
  alone 20/0 twice; noted on #2399.
- At the pushed head (on origin/main 20d63621d, which changed app.js,
  routing/client.js and the panel tests, not internal/agent):
  TestCoreScriptBudget (budget unchanged), go test ./internal/gui ok,
  gofmt clean, go vet gui for linux, windows and darwin. 45 GUI files
  (routing-bodies, request-archive*, panel*, agent-app-restart,
  agent-stale-copies, i18n-keys, library-mcp*, mask-actions,
  masking-records, usage-agents*, usage-ledger*): 720/28. The only reds
  are #3414's and #3001's. Then rebased on aa3112f4e (app.js's panel fit()
  only): TestCoreScriptBudget, i18n and notice tests ok; agent-app-restart,
  i18n-keys and panel-fit-tabs 54/0.
- Not run at this head: the full go test ./... and the whole GUI suite
  (the machine's disk filled mid-run once; shipped on the packages and
  files above, per ship-immediately).

Not tried: a real AppleScript quit from a GUI session (this session is
Background, so the fake was quit by SIGINT and opened by exec), the real
Claude Desktop and WorkBuddy apps (never quit the user's running apps),
Codex app and WorkBuddy AI on Windows (process names unknown, so no
button there), Linux (no desktop app of these runs there).
2026-10-25 00:30:31 +08:00
yetone c819e00c4e routing: a ClinePass route reads as its route, with what was asked for (zRain)
zRain (Discord #feedback, 10-24; magpie 0.1.1377, Windows, Codex CLI
0.164.0) asked clinepass/cline-pass/deepseek-v4.1-flash-1017 from Codex
(/backend-api/codex/responses -> /v1/chat/completions, 200). The reply
named vmc/deepseek-v4p1-flash-1017-contributor-fallbacks. Routing showed
"served vmc/..." titled "likely another model", with no upstream.

What was found:
- The pin goes out on Codex's Responses path the same as on a Chat
  client's. The test below checks the sent body on both paths. The
  built-in ClinePass pins only with "DeepSeek and GLM models only from
  their makers' own APIs" ticked. The Cline plugin pins Pass DeepSeek by
  default. zRain's id is the built-in, so with the tick off nothing asked
  for DeepSeek.
- upstreamOf reads finalProvider from choices[].delta/message
  provider_metadata on every path (Codex streamed, chat streamed,
  Responses streamed and not). zRain's rows had none, so the reply most
  likely carried none there. canonicalSlug is not recorded; left alone.
- The contributor-fallbacks name is ClinePass's own route. Its name does
  not mean another model.

Change:
- provider.ClinePassAsked: the upstream a request asks the Cline API for
  (ClinePin with the tick, or deepseek on the plugin's provider).
- Try.Pin records it on the answering try.
- Routing: a cline-pass/ model served as vmc/... is tagged "ClinePass
  route ...". Its title and story say it is the route's name, not another
  model's, and then one of:
  - who answered, when the reply said;
  - that the asked provider wasn't confirmed;
  - that nothing was asked, naming the tick for DeepSeek/GLM.
- The Usage page's Requests title says the route too, without the pin it
  doesn't keep.
- Strings in zh, zh-TW, ja and de.

What was run (rebased on origin/main 7edf5b0a3):
- TestClinePassAsked (provider) and TestClinePassTryKeepsWhatWasAsked
  (gateway: chat and responses, tick on/off, sent body and try pin).
- Broken by hand: the try literal without Pin, and the tick-on cases go
  red ("try pin \"\" (want \"deepseek\")").
- go test -count=1 ./internal/provider in a sandbox HOME: ok (280s).
- ./internal/gateway -run 'Cline|Upstream|Swap|Served|Try|Trace|Route':
  ok.
- gofmt -l clean; go vet darwin, linux -tags nogui, windows on gateway
  and provider.
- go test -run 'Budget|I18n|Strings|Plugin' ./internal/gui: ok.
- GUI: routing-cline-route.test.cjs, new, Chromium+WebKit, en+zh, every
  string in all 4 languages. Pointed at the old assets
  (MAGPIE_ROUTE_ASSETS): 4 of 4 red. Now 4 of 4 green.
- GUI: every routing-*, usage-* and gui-* file, plus i18n-keys,
  panel-routing, remote-group-served and session-identity, at
  concurrency 3, load ~110. Reds: routing-held-dot (WebKit zh 560px,
  timeout; passes alone at the rebased head) and routing-intent-entry
  "Add a rule makes a rule by intent" (also red on origin/main 117937b8d
  in WebKit alone: #3408).

Not tried:
- No real ClinePass account. The raw bytes of a contributor-fallbacks
  reply are unseen, so whether ClinePass puts finalProvider elsewhere for
  that route is unknown. No parser change was made without them.
- Full go test ./... was not run: the machine is at load ~110 with other
  sessions' suites.
- Not run on the Windows box.
2026-10-24 19:21:02 +08:00
yetone 7dd69d6e70 gui: a conversation's said-part (ledSaid) moves from app.js to the Usage page's script
app.js is at its budget (1,343,323 of 1,343,324 on origin/main
5a85a2a91), and the next commit, the Codex app's used-up notice
(MasterYi on Discord), adds ~650 bytes to it. The budget is not raised
(#2710); this moves code out instead, as 34ad18ed8 did.

What moved: ledExpanded, LED_KINDS, LED_ROLES and ledSaid, unchanged,
from app.js into plugins/usage/page.js beside viaText (1,803 bytes).
Nothing in app.js or the other core scripts calls them. Their callers
are plugins/usage/page.js (the Requests ledger's content) and
plugins/sessions/client.js (a session's conversation), which calls
ledSaid only in its render after a fetch, after page.js has loaded
(index.html loads page.js after app.js and before start.js). Their
words stay in i18n.js.

What was run, at this tree plus the next commit:
- go test -tags nogui ./internal/gui: ok (TestCoreScriptBudget with
  the budgets unchanged).
- GUI (chromium, webkit): gateway-conversations, sessions-subagents,
  sessions-talk, sessions-talk-model, usage-ledger-content, i18n-keys,
  plus the next commit's files: 164 of 164.
2026-10-24 17:38:50 +08:00
yetone c30af359b4 usage: the line chart's lines are smooth curves, not straight segments (owner, after molvqingtai's reference)
The Requests chart's line mode (1c617c153) joined its points with straight
segments, so every change of hour turned a sharp corner. The owner compared
it with molvqingtai's reference chart, whose lines curve, and asked why ours
looked so stiff.

Each unbroken run is now one cubic curve through its points, drawn the way
d3's curveMonotoneX draws it (Fritsch-Carlson tangents): it bends between
points but never past one, so a quiet hour is never drawn dipping below
zero and a peak is never drawn above its value. The stacked bands follow
the same curves on both edges, so a band still meets its line. The dots at
every point are gone, as in the reference; a point alone in its run (no
neighbour to curve to) still gets its dot, or it would not show. Lines are
1.8 wide instead of 1.6. Bars, the tooltip, hover, day pick and the speed
tab's dashed and broken lines are unchanged.

Tests: usage-chart-line's point reader takes each command's end point (M,
L or C). The speed check now requires luna's run to be 13 curves between
its 14 points, and a new check fails if any line's box reaches past its
highest or lowest point (an overshooting curve).

Run at origin/main 5a85a2a91 plus this change (and before the rebase at 2027381ac):
- usage-chart-line and i18n-keys: 48/48, chromium and webkit (en, zh,
  zh-TW, ja, de x light, dark x 1180, 420).
- go test ./internal/gui: ok.
Screenshots of the token chart checked by eye: the steps between hours are
curved, the band and line agree, nothing goes under the axis.

Not tried: the whole GUI suite, the real Linux app (WebKitGTK) and Windows.
Only page.js, app.css and the one test changed; nothing else draws lines.
2026-10-24 17:27:27 +08:00
yetone 2027381acf gui: Usage's empty Sessions text is translated again (Outvi V on Discord)
Usage's Sessions tab, with no sessions on this computer, said "No sessions
yet. Claude Code's, Codex's, OpenCode's and Pi's sessions..." in English
in every language. 5a4104632 (#569) added Hermes to that text's key in
i18n.js, and the page kept the old wording, which has no key. The page now
says the key's text, Hermes included (Hermes sessions are listed there).

i18n-keys gains "every word the window says has a key": every t("...")
literal in assets' scripts must have a zh key, "magpie" and "ID" excepted
as English on purpose. This was the only one missing.

Run: node --test internal/gui/tests/i18n-keys.test.cjs, 4 of 4 pass; with
the old page.js the new test fails naming page.js:2532. No other test or
source names the old wording.
Not tried: the window itself in each language.
2026-10-24 17:04:32 +08:00
yetone 1c617c1532 usage: the Requests chart can be drawn as lines, kept per viewer (molvqingtai, Discord)
molvqingtai asked on Discord for the request chart on Usage > Requests to be
a line chart. A small two-icon switch (bars, lines) now sits in the chart's
header row beside the Token / Cost / Requests / Speed tabs. Bars stay the
default. The choice is kept in localStorage magpie.ledChart, next to
magpie.ledMetric; any other value, or a read that throws, gives bars.

Lines cover every tab. Tokens, cost and requests draw the stacked totals as
cumulative lines with a faint band per model and "other" last, so the top
line meets the stacked column's top. Speed draws a dashed all-models line
and each model's own line, broken where a model has no value. Tooltip, day
pick, ranking hover (it now strokes a series instead of filling it), the
time-zone handling and the empty state are the columns'.

drawLedColumns in core app.js gets one hook, box.drawn, which the Usage
page sets; the line code lives in plugins/usage/page.js. The tray panel's
chart is unchanged (bars). app.js is 1,343,276 bytes, under
TestCoreScriptBudget's 1,343,324; the budget is not raised.

New test usage-chart-line.test.cjs (en, zh, zh-TW, ja, de x light, dark x
1180, 420): bars by default, translated labels, the switch inside the
header with no sideways scroll and no left border, a click doesn't scroll
the page, lines still chosen and drawn after a reload, the top line within
1px of the column top for tokens, cost and requests, speed's dashed line
and broken runs, tooltip and ranking hover, the empty state; a "pie" value
and a throwing getItem give bars.

Run at a93190ae1 plus this change:
- usage-chart-line: 44/44 in chromium and webkit.
- go test ./internal/gui (TestCoreScriptBudget included): ok.
- gofmt -l: nothing. go vet ./... (darwin), GOOS=linux go vet -tags
  nogui ./..., GOOS=windows go vet ./...: ok.
- Whole GUI suite, chromium: 6141 tests, 49 red. The 14 red files were run
  alone on a clean origin/main a6a3dbde8 and on this branch: 43 red on
  each, the same tests (a few routing-rule-remove subtests flip, #3094,
  #3096). All are filed: usage-agents-hide #2276 #3414, usage-fold #3415,
  usage-ledger #3001 #3104, routing-pause #3410, routing-rule-effort
  #3411, routing-intent-entry #3408, routing-steady #3412,
  menu-input-scroll #3402, old-webkit #3403, quota-count-wrap #3404,
  plugin-github #3218, library-mcp-health-wsl #3350. routing-busy-frames
  was red in the full run only and passed alone on both.
- Whole GUI suite, webkit: still running at commit time (1236 tests in,
  0 red); the result follows on this commit's issue thread.

Rebased onto edff2f819 and run again there: TestCoreScriptBudget ok
(app.js 1,343,276), usage-chart-line and i18n-keys 25/25 in chromium
and webkit.

Broken by hand: without the localStorage read the test fails "lines kept
across a reload" (bars, not line); with chart.drawn = null it times out
waiting for #ledChart g.ln.

Not tried: the real Linux app (WebKitGTK) and the Windows box. Screenshots
of both styles in light and dark were checked by eye.
2026-10-24 05:55:44 +08:00
yetone 34ad18ed86 gui: a session's row helpers move from app.js to the Usage page's script (#3367)
TestCoreScriptBudget was red on main since db48697d6 (app.js 1,338,090
over its 1,337,735 budget), and 673651e8d took app.js to 1,338,819 and
the core's scripts to 1,530,579 (budget 1,529,495). The budget is not
raised.

What moved: sessModelNames, wslBadge, sessModelsText, sessUsageDetail
and viaText, unchanged, from app.js into plugins/usage/page.js's
"sessions" section. Nothing in app.js calls them. Their callers are
plugins/usage/page.js (the Usage page's Sessions tab) and
plugins/sessions/client.js (the Sessions page), which calls them only
from inside its mount/render callbacks, after page.js has loaded
(index.html loads page.js after app.js and before start.js, which
mounts the pages). Their words stay in i18n.js, since both pages say
them.

Bytes (at this commit):
- app.js: 1,338,819 -> 1,336,507 (budget 1,337,735; 1,228 under)
- core scripts: 1,530,579 -> 1,528,267 (budget 1,529,495; 1,228 under)
- plugins/usage/page.js: 170,601 -> 173,032, +2,431 with the section's comment (not core)

Run at 673651e8d + this change (origin/main fetched, unmoved):
- go test -tags nogui ./internal/gui/...: ok (TestCoreScriptBudget, the
  i18n and guard tests included)
- GUI, node --test, Chromium and WebKit, playwright 1.62.0: 39 files,
  467/467 pass: every sessions-*, session-*, usage-sessions*,
  usage-session-speed, usage-unpriced-*, sess-agent-strip,
  account-mask-sessions, i18n-keys, old-webkit, mobile-web, phone-web
  and web-page test.
- gofmt -l: none; go vet ./internal/gui/... on darwin, linux (nogui)
  and windows: ok.

Not run: the whole GUI suite (other sessions were queued on the
machine's suite turn), and no Go code changed, so no full go test ./....
2026-10-23 17:41:11 +08:00
yetone e00fbdbbc7 usage: times and days follow the viewer's time zone, not the server's (Outvi V, Discord)
Outvi V reads a remote magpie through `magpie web`. The Usage page
bucketed calls by the server's days and hours, so a call at 9:00 in
UTC+8 showed under 1:00.

What changed:
- The Usage page (plugins/usage/page.js) names its browser's IANA zone
  in ?tz= on /api/usage, /api/usage/requests, /api/usage/heatmap, the
  CSV link and the export.
- usage.Zone turns the name into one cached *time.Location per name, so
  a Filter holding it stays a comparable cache key. An empty or unknown
  name, or a zone that keeps this computer's clock, is time.Local, so
  the desktop page, the tray and the TUI see no change and share caches.
- Filter.Zone carries the zone. Today/7d/30d, the chart's hour and day
  buckets and labels, the Day filter and the heatmap's days are all
  read in it (Clock().In(zone)). The summary cache is keyed by period
  and zone, and the request-page cache by the reader's date.
- Shared days from other computers are read with a 2-day margin, not
  1, since two zones can be 26h apart.
- Limit and quota resets are unchanged. The gateway's
  /v1/magpie/usage stays on the computer's zone.

Run at e435b8867 + this change:
- gofmt -l and go vet on internal/usage, internal/usageapi and
  internal/gui: darwin, GOOS=linux -tags nogui, and GOOS=windows. The
  vet ran before the new _test files were added.
- go test ./internal/usage ./internal/usageapi and
  -tags nogui ./internal/gui: ok with TZ=UTC and with
  TZ=Asia/Shanghai.
- New tests:
  - TestUsageReadsTheViewersZone and TestZoneNames (internal/usage).
  - TestUsageRoutesReadTheViewersZone (internal/gui) asks the routes
    with ?tz= naming a zone other than the server's.
  - Each holds usage.Clock and checks the hour label, today's
    membership, the Day filter, the week chart's day label and the
    heatmap's days. With no ?tz=, the server's days are kept.

Broken by hand:
- Clock().In(zone) / Clock().In(f.loc()) back to Clock(): red in both
  zones (Summary, Requests, ledger, heatmap, /api/usage,
  /api/usage/requests, /api/usage/heatmap).
- The Day filter read in time.Local: red under TZ=UTC.
- The summary's and chart's bucketing in time.Local: the week-day label
  check goes red under TZ=UTC. Under TZ=Asia/Shanghai the chosen
  moment falls on one date in both zones, so it can't tell there.
Each was restored after.

Not tried:
- A Playwright GUI test with timezoneId in Chromium and WebKit was
  not written. The GUI suite and usage-stale-answer.test.cjs (which got
  a usageZoneQ stub) were not run: the disk was at ~350 MB free.
- TestCoreScriptBudget was not run again after the change. app.js is
  untouched, and page.js is a plugin page outside the core budget.
- A real remote `magpie web` from another zone, and the Windows box.
- Siblings left alone:
  - The Sessions tab buckets by the server's days and hours in its
    cached rollups, and its "By hour" card labels them with the
    browser's zone name.
  - The Routing history's day files are the server's days.
  These need issues of their own.
2026-10-23 10:54:27 +08:00
yetone e435b88670 usage: nothing under the Requests table's scrollbar at the window's foot
碳碳双键 on Discord #general (10-23, macOS app): on Usage → Requests a
wide table showed a strip of the page under its horizontal scrollbar,
between the bar and the bottom of the window.

Cause: the bar under the table (#ledHScroll, #799) is position: sticky,
bottom: 0 inside the view. A sticky box keeps clear of its scroller's
padding in both engines, so it stood the view's bottom padding (8px in
the window, 4px in the panel, 12px in a phone browser) above the view's
visible bottom, and the table's card and cells showed through the strip
under it. Measured on c4a5e6153 at 600x640: view bottom 612, bar bottom
604, the pixel row above the foot is a table cell, in Chromium and WebKit.

Fix: ledHScroll(), which already runs whenever the bar is shown or the
wrap resizes, sets the bar's bottom to minus its view's computed bottom
padding, so it sits on the view's foot. At the page's end the bar is in
flow under the table and does not move (sticky only shifts it while the
table runs past the foot). No CSS or other layout changes.

Test: ledger-hscroll-foot.test.cjs, Chromium with classic and with
overlay (default --hide-scrollbars) scrollbars and WebKit, zh and en, at
600 and 420 wide: mid-table the bar's bottom is the view's bottom (±0.5px)
and the view's last pixel row is the bar; at the page's end the bar sits
2px under the table. Red on c4a5e6153's page.js, 15 of 15 ("the bar's
bottom is the view's bottom, no gap under it: {"foot":612,"bar":604,...
"under":"where-name"}"), green with the change.

Run at c4a5e6153 + this change (rebased onto ed71fa774, which changes only
routing files; at the pushed head ledger-hscroll-foot, ledger-hscroll and
i18n-keys pass in both engines, 24 of 24):
- GUI, BROWSER=chromium and webkit, concurrency 4, 66 files (usage-*,
  ledger-*, request-archive*, own-requests, i18n-keys, click-scroll,
  old-webkit, gui-zh-tw, gui-ja, gui-de): chromium 477 pass / 16 fail,
  webkit 472 pass / 16 fail. Every red is the same on c4a5e6153's
  page.js (the four files run again with it: 36 pass / 16 fail in each
  engine) and already filed: usage-agents-hide (#2276), usage-fold
  "several accounts" in chromium (#2163), usage-ledger "newest live
  route needs no return-to-live button" (#3104), usage-checkin Qoder tab
  in WebKit (#3091, #2549). ledger-hscroll (#799) passes in both.
- go test -tags nogui -count=1 ./internal/gui/... under a temp HOME: ok.

Not tried: the real macOS app (the reporter's screenshot) and a real
overlay scrollbar in WKWebView; Playwright's WebKit and Chromium's
overlay mode stand in. No full `go test ./...` (JS-only change), no
Linux WebKitGTK or Windows WebView2 run.
2026-10-23 10:15:01 +08:00
yetone 4f6498f822 routing, usage: an account renamed in magpie reads by its new name (magpie-community/plugins#310, molvqingtai)
molvqingtai renamed a Kiro (plugin) account from "example@gmail.com (foo)"
to "example@gmail.com (bar)", and the Routing page kept saying "(foo)" on
every request made after. Cause: the Routing page never looked up the
user's name at all. A trace's `who` is the vendor's account name
(Weighed.Who), and plugins/routing/client.js showed it as it was. Usage
records (ProviderAccount) keep the vendor's name the same way, and the
Usage page's Accounts, the request log's Account filter, `magpie usage`,
a gateway key's accounts (AccountNames, /api/caller-keys) and Routing's
"Several accounts" pools (onOf) all showed it raw too. This affected
built-in and plugin providers alike.

Records still keep the vendor's name. It is the key the user's name is
stored under (providers.json AccountNames, in lower case), so it stays
the identity: Routing still groups and ranks by `who`. The name is looked
up when it is shown: provider.AccountShown / AccountShownOf /
AccountRef.Shown in Go, and userShown (accountNameOf over /api/providers'
accountNames) on the Routing page. So requests from before the rename
read by the current name too, and a cleared name goes back to the
vendor's. A key's name and an unnamed account read as before.
Already right before this change: quota cards and the menu bar (Alias),
`magpie accounts`, and the editor's account row.

Record for this push: 13 commits on origin/main ca4a1cde0, head tree
539c84e92. Go 1.26.8, sandbox HOME, GOMODCACHE/GOCACHE pinned. The full Go
run and vet were at tree d6393dfc8, the same Go code as this head: only
app.js comments (cut under the core script budget) and one ja string
changed after it.
- gofmt -l: nothing. go build ./...; go vet ./... (darwin), GOOS=linux
  go vet -tags nogui ./..., GOOS=windows go vet ./...: clean.
- go test -timeout 45m ./..., through tee, one suite on the machine:
  68 packages ok. The one red was internal/gui's
  TestCoreScriptBudget: app.js 1,335,314 > 1,335,000, since main grew
  app.js under the stack. The autoscroll commit's own comments were cut
  (to 1,334,629) rather than the budget raised, and go test -count=1
  ./internal/gui is ok at this head (113s). Packages the run took from
  Go's test cache had the same inputs.
- GUI: the 18 files this stack touches or names, both engines,
  202 of 204 pass (tree 068acf128, this push less the last commit). The
  two reds: gui-ja, red on main since c2636b7b5 and fixed by this push's
  last commit (gui-ja and i18n-keys 6 of 6 there), and usage-fold's
  chromium "several accounts" (#2163, red on main the same way).
- Red on the old code: TestAccountNameOfAPluginAccount, with
  AccountNames put back to a.User, fails with "a gateway key's accounts
  read [fakeco/31****36@qq.com]". The new GUI test
  routing-account-name.test.cjs, with the old client.js, fails with
  "renamed, the account reads by its new name: Kiro example@gmail.com
  (foo) Pro".
- routing-account-name passes, en and zh, both engines. internal/provider,
  internal/usageapi, internal/cli and internal/gateway ok.
- The five usage files this change's first run found red: usage-agents-hide
  (#2276), usage-checkin (#3091), usage-fold (#2163) and usage-ledger
  (#3104) are red alone at the stack and on main the same way.
  usage-overview-fold now passes alone at both.
  The whole GUI suite ran at 1c1fc7183 (this stack's first 12 commits on
  0ddcf28a1): 11713 of 11769 pass. Each of the 21 red files was then run
  alone at the stack and at origin/main 8278fd9b0. Eight are red the same
  way on main: plugin-card-update (#3079), quota-count-wrap and
  quota-name-translated (#2228), s3-sync (#2448), usage-agents-hide
  (#2276), usage-checkin (#3091), usage-fold's chromium "several
  accounts" (#2163), usage-ledger (#3104). The other 13 pass alone on both
  and were red only under that run's load (50 to 335): currency #3101,
  plugin-github #3218, provider-fetch-again #3292, rest-try-now #2564,
  routing-auto-reset #3293, routing-keys-fold #1612, routing-steady #1804,
  routing-wb-restricted #1905, sessions-folder-delete #2218,
  sessions-manage #3294, switch-only #3295, text-size #1866, usage-pack
  #3296.

Not tried: a real Kiro account. The fixture is the reporter's case, with
their names.
2026-10-23 01:58:01 +08:00
yetone f050818f71 usage: every request on the Requests tab says its speed, or why it has none (夜松云 on Discord)
夜松云 on Discord: the Requests tab's Speed column was blank for some rows
and not others, with nothing saying why.

What changed (internal/gui/assets/plugins/usage/page.js, i18n.js):
- A gateway call with no speed of its own now tells the least it wrote at,
  as a "≥" floor, the way a session file's call already did: one that
  reasoned with no first text recorded (a tool call after hidden
  reasoning) its answer tokens over the time after its first token,
  unless the content came in a burst; else one not streamed or not timed,
  its output over its whole time, by the same 1,000-token rule. The
  tooltip says which floor it is and why it is only a floor. The
  request's detail sheet (the other caller of ledFloorSpeed) shows the
  same floor. The period's speed KPI is unchanged: it never counts a
  gateway floor.
- A dash that is left always has a tooltip saying why (ledNoSpeed_):
  failed, no duration, no output, not streamed / no first token, all
  reasoning, too little after the first token, or let go in one burst.
- Eight new strings with zh, zh-TW, ja and de.
- reasoning-speed and usage-session-speed now expect the floor on the
  rows that showed a dash before (reasoning then tool calls only: ≥100;
  not streamed: ≥500).

Guarded by internal/gui/tests/usage-speed-every-row.test.cjs (rows shaped
as real usage.jsonl gateway rows, en and zh, both engines).

Broken by hand:
- page.js put back to its base: usage-speed-every-row 0/6 pass ("row 2's
  dash says why").
- Only the gateway floors off (ledFloor_ returns null for a gateway row):
  0/3 in Chromium.

Record for this push: 13 commits on origin/main ca4a1cde0, head tree
539c84e92. Go 1.26.8, sandbox HOME, GOMODCACHE/GOCACHE pinned. The full Go
run and vet were at tree d6393dfc8, the same Go code as this head: only
app.js comments (cut under the core script budget) and one ja string
changed after it.
- gofmt -l: nothing. go build ./...; go vet ./... (darwin), GOOS=linux
  go vet -tags nogui ./..., GOOS=windows go vet ./...: clean.
- go test -timeout 45m ./..., through tee, one suite on the machine:
  68 packages ok. The one red was internal/gui's
  TestCoreScriptBudget: app.js 1,335,314 > 1,335,000, since main grew
  app.js under the stack. The autoscroll commit's own comments were cut
  (to 1,334,629) rather than the budget raised, and go test -count=1
  ./internal/gui is ok at this head (113s). Packages the run took from
  Go's test cache had the same inputs.
- GUI: the 18 files this stack touches or names, both engines,
  202 of 204 pass (tree 068acf128, this push less the last commit). The
  two reds: gui-ja, red on main since c2636b7b5 and fixed by this push's
  last commit (gui-ja and i18n-keys 6 of 6 there), and usage-fold's
  chromium "several accounts" (#2163, red on main the same way).
- usage-speed-every-row, reasoning-speed and usage-session-speed pass,
  both engines; i18n-keys and gui-zh-tw/ja/de too.
- The Requests tab's other file, usage-ledger, is red alone on main the
  same way (#3104, the return-to-live button).
  The whole GUI suite ran at 1c1fc7183 (this stack's first 12 commits on
  0ddcf28a1): 11713 of 11769 pass. Each of the 21 red files was then run
  alone at the stack and at origin/main 8278fd9b0. Eight are red the same
  way on main: plugin-card-update (#3079), quota-count-wrap and
  quota-name-translated (#2228), s3-sync (#2448), usage-agents-hide
  (#2276), usage-checkin (#3091), usage-fold's chromium "several
  accounts" (#2163), usage-ledger (#3104). The other 13 pass alone on both
  and were red only under that run's load (50 to 335): currency #3101,
  plugin-github #3218, provider-fetch-again #3292, rest-try-now #2564,
  routing-auto-reset #3293, routing-keys-fold #1612, routing-steady #1804,
  routing-wb-restricted #1905, sessions-folder-delete #2218,
  sessions-manage #3294, switch-only #3295, text-size #1866, usage-pack
  #3296.

Not tried: the real app against a real usage.jsonl with such rows; only
the faked API in the tests.
2026-10-23 01:58:01 +08:00
yetone 8c68b6802a gui: time to first token reads 首字耗时 in Chinese, not 首响 (Outvi V)
Outvi V on Discord: "首响 2.7 秒" makes a reader stop and decode it.
The rest of the GUI already says 首字 for the first token (首字平均,
厂商首字等待, 没有首字时间), so 首响 was the odd one out. The label
(First token, TTFT) now reads 首字耗时 / 首字耗時 beside 耗时, the
Routing step reads "{ms} 后出首字", and the other mentions say 首字. zh
and zh-TW both; ja, de and en are unchanged.

routing-request-metrics checked that 首字 was gone from Routing's steps;
that guarded a since-removed "first text in {ms}" string (4c5a30dc0),
which nothing translates any more. It now checks that 首响 is gone.

Run at origin/main 3a213e1dc plus this change: routing-request-metrics,
routing-burst-speed, routing-columns, usage-ledger, usage-ledger-detail,
usage-ledger-ttft, usage-speed and i18n-keys in chromium and webkit:
67 pass, 6 fail. All 6 are usage-ledger's "newest live route needs no
return-to-live button" (en and zh, both engines), which fails the same
way at 3a213e1dc without this change (#3104).
2026-10-22 21:51:29 +08:00
yetone f21dd99f5a privacy: every masking is recorded, and Settings › Privacy shows it
What was masked is now kept, so the user can see it. Settings › Privacy
opens on a summary card: how many values were kept from vendors over 1,
7 or 30 days, by kind, by finder (rules, your words, the local model,
known values) and by where they went, with a day strip. The page is
grouped into What to mask, How it's found (rules and the local model are
layers, not a toggle: the model adds names and addresses rules can't
see) and Sharing. A records view lists each masked request: its kinds,
finders, placeholders and, while magpie runs, the line around each
value. Gateway › Recent calls and the Routing log carry a masked-N badge
that opens the record.

Originals never go to disk. internal/maskrec writes day files under
~/.config/magpie/masking (0600, 30 days, 100MB at most) holding kinds,
finders, placeholders, a first character or key prefix and a length.
The lines around values are kept in memory for the last 400 records
only, and /api/masking/value answers only while the masker remembers a
placeholder. Nothing is written under MAGPIE_TEST_SANDBOX.

A masker says what it masked through gwmw.Teller (JSONHits, TextHits,
Value); a plugin masker that doesn't is counted only, so older redact
plugins keep working. Every route that masks notes it: chat, Responses,
Codex backend and search, embeddings, images, video, transcription,
decide and the search MCP query. Masking still fails closed: a masker
that panics on any path refuses the request (TestMaskingOnAndOff's fake
now panics on JSONHits and TextHits too, since the gateway asks a Teller
through those).

app.js grows to 1,314,432 bytes, so its budget rises to 1,335,000 and
the core's to 1,528,800 (+1.5%): Settings is the core's own page.

Run at this head (rebased on origin/main a3ebed202):
- go vet clean on macOS, GOOS=linux -tags nogui and GOOS=windows;
  go test ./internal/gateway ok (561s).
- On origin/main c922225f1 (one commit back, the packages either side
  touches): agent, gateway, gui, gwmw, maskrec, provider, redact ok.
- On origin/main 592899467: go test ./... -timeout 45m, 65 packages ok;
  agent and gateway hit the 45m timeout under load ~26 (each mid-way
  through a short test, not a hang) and pass alone with -timeout 100m
  (1133s, 890s).
- GUI, on 592899467, the 42 files this change or main's new commits reach (privacy-*,
  redact-*, masking-records, settings-*, gateway-*, routing-bodies,
  routing-request-metrics, routing-log-icons, account-discovery,
  click-scroll, i18n-keys, old-webkit), both engines, every language:
  475 tests, 475 pass. routing-bodies is green here since 2543fb2c1.

Run on the previous base, origin/main c84864ffc (the whole suites):
- go test ./... -timeout 45m: every package ok (66), exit 0. An earlier
  run found TestMaskingOnAndOff/panics (its fake, above) and
  TestCoreScriptBudget (the budget, above); both fixed.
- gofmt -l clean; go vet on macOS, GOOS=linux -tags nogui and
  GOOS=windows clean; node --check on the changed scripts.
- GUI suite, both engines, every language, --test-concurrency=6:
  11533 tests, 11483 pass, 50 fail. Each failing file rerun alone here
  and on origin/main:
  - red the same on main, filed: codex-predictions (#2624),
    usage-checkin (#2549), usage-agents-hide (#2276), usage-fold
    (#2163), s3-sync (#2448), quota-count-wrap and
    quota-name-translated (#2228), routing-request-metrics (#2571),
    routing-bodies (#2559: red at its "second request pressed" step;
    this change's badge checks before and after it pass),
    routing-rule-remove (#3096, filed now: 0 2 1 alone here, 0 0 2 on
    c84864ffc).
  - load, pass alone: group-member-weight (#2387), routing-model-rest,
    context-tune (Chromium didn't launch in 180s at load average ~45;
    0 0 0 alone on both). An earlier whole run's library-chip-fan red is
    #3072 (filed), plugin-card-update #3079, lightweight #2638,
    segs-glide #2683.
  - mine, fixed: old-webkit, three ":hover, :focus-visible" lists
    Safari before 15.4 drops; split, 6/6.
- Broken by hand, each went red: masked values kept on disk
  (TestNoValueOnDisk), a snip that runs past an escaped quote
  (TestSnipStaysInItsString), the shared-line dedup in the records view
  (masking-records, 10 of 12).
- Real app in a sandbox HOME with the local model on: the summary card,
  flow, chips and records view in light and dark; persons and
  addresses, Chinese names among them, recorded by=model; a grep of the
  masking folder and the sandbox config for the masked values found
  none.
2026-10-21 06:12:37 +08:00
yetone f73378365f gui: a filter a click set on Usage's Requests goes when they are left (TJHHHH on Discord)
TJHHHH: after a jump to Codex's requests on the Usage page, every later
visit listed only Codex's. The Requests' filters are module state in
plugins/usage/page.js and nothing ever reset them, so a click on Codex in
the ranking split by agent stuck for the app's lifetime.

Now a filter a click lent the Requests (a ranking click on an agent,
provider, model or gateway key, a chart day, the address's ?agent= and
the like, a route from Routing) is remembered in ledLent and given back
by ledLeave when the reader leaves the Requests: for another Usage tab
(renderUsageTab), or another page through a new page hook, `leave`, that
show() calls on the page it leaves. A filter picked in its own menu or
typed in the search stays, as a menu choice does in a Mac app. A route's
saved filters keep their lent marks, and leaving with a route on gives
back the route too. Docs: plugin-runtime.md's Usage hooks.

Siblings judged and left: the tray panel's Usage tab ranking (its own
view, not the page's Requests), the Sessions reveal (per agent, no "all"), the KPI
failed/retried jumps (shown in the status segment, read as own picks).

Test: tests/usage-ledger-leave.test.cjs, chromium and webkit, en zh
zh-TW ja de: ranking click leaves for a page and for a tab, menu pick
stays, ?agent= goes, a route goes. On the old app.js/page.js/client.js
it is red, 20 of 25 in chromium ("back from another page: last asked
period=today&agent=codex"); only the menu-pick case passes there.
Green with the fix, in both engines.

Run at 5b267fbd8 (load 200-400):
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows ok.
- go test -timeout 45m ./...: 60 ok; internal/agent, gateway, library
  past 45m (#2544, #2870, #2853), internal/gui
  TestSetAnswersWhileDevinAndProvidersHang 13s (#1375). All filed, none
  touch these files.
- Whole GUI suite (node --test --test-concurrency=4, both engines):
  i18n-keys was red on my comment saying "View usage" (routing's word);
  reworded, i18n-keys green. codex-auto-reset, codex-auto-reset-settings
  and codex-predictions red in the full run; rerun alone: codex-auto-reset 20/20 and codex-auto-reset-settings 22/22
  green (load); codex-predictions 7 of 20 red at 420px, the same as
  #2624 on main. usage-ledger-leave 52/52 alone. The whole suite was
  still running at commit time (load ~400); its reds so far are these.
2026-10-19 21:59:40 +08:00
yetone b9f790d37b plugins: panels in magpie's pages, a page that replaces a built-in one, titles in the window's language, and a look that matches
P5 of the plugin runtime (docs/subsystems/plugin-runtime.md):

- Panels (magpie.panels): a plugin draws a frame into a slot of a
  built-in page (a provider's editor, Settings, Usage); magpie.context
  says where it is, and the frame is as tall as what it draws.
- A page can replace a built-in one (magpie.page.replaces); show() opens
  it in that page's place, and the sidebar row goes to it.
- page.titles and a panel's titles name it in the window's language
  ({"zh": …}); a malformed map is dropped, the title kept
  (TestWindowTitles).
- main's #2501 already names wails:// in the policy of a page in the
  desktop window (through ownWindow), which is why the usage page drew as
  bare HTML from v0.1.1259. TestPluginPageLoadsItsFilesInTheWindow loads
  a page through ownWindow in a real WKWebView, which Playwright on http
  can't; the subsystem page says how.
- The bridge adds magpie's look for what a page leaves unstyled, every
  rule in :where() so any rule of the page's wins, and the theme's
  colours as --magpie-* variables.

One commit: the panels, the replacing pages and the titles share hunks
in page.go, pluginpage.go, pluginpages.js and the docs, and couldn't be
split cleanly.

Run:
- Full: this series (P5, the Plugins dot, the probe test, P6, and a
  built-ins-on commit since dropped for main's own 5a2414acd) was run
  together, at load 200-660.
  At the pushed tree, 88dfab2d3 on origin/main 5380114da (rebased
  from 210bc2b77, no conflicts; its GUI assets and tests are the same
  bytes as the tree the GUI runs below used, diff -rq): gofmt clean,
  vet darwin/linux nogui/windows ok, TestCoreScriptBudget ok
  (1,446,845 of 1,447,000). go test -timeout 45m ./... at load
  193-278: 62 packages ok, red in TestMainWindowCorners (#1936) and
  TestPluginStreamLargeReplies JSON_fast (client timeout; alone 1 of
  3 red here, 0 of 3 on 5380114da side by side at load ~280; the
  series doesn't touch the stream path; #2551 reopened with the
  output, taken). Two earlier runs at this tree are discarded: one
  stopped when the disk filled, one when another session's go clean
  -cache emptied the build cache mid-run. The whole GUI suite at
  this tree was not finished (the disk filled); the files the series
  reaches ran (1318 tests, 124 red), and the 39 red files ran again
  at concurrency 1 on both trees: here 148 ok 120 red, origin/main
  135 ok 127 red. Both sides' reds are page.goto/launch timeouts
  under load (66 here, 71 there) and the same assertions:
  title-bar-tools' and settings-proxy-auth's "access control checks"
  on a cut-off /api/providers read (#2740, taken next), sidebar's
  "the list unrolls" and WebKit "#prefs pressed darkens" (#2684;
  alone, 1 red here, 3 on main), side-toggle (#2732); plugin-move
  red on main only. Six files again one by one on both trees:
  plugin-actions red 1 of 6 here, a 5s goto of ?view=plugins at load
  260; plugin-clash red on both; plugin-own-icon, plugin-gateway,
  plugin-checkin ok on both; settings-proxy-auth ok here, 3 red on
  main.
  At 976c9893a (on origin/main 6f950653f): go test -timeout 45m ./...
  red only in TestMainWindowCorners (#1936, the window's process
  killed at its deadline) and TestSetAnswersWhileDevinAndProvidersHang
  (#1375, 3 of 3 alone). The whole GUI suite, both engines: 10834
  tests, 237 red in 73 files, 184 of them a 180s browser launch. Those
  73 files run again at concurrency 2: 52 green, among them every
  plugin-* and agent-* file and plugin-actions; the 21 still red were
  run at origin/main f191d6423 and are red there too: codex-predictions
  (#2624), lightweight (#2638), segs-glide (#2683), usage-agents-hide
  (#2276), provider-advanced-fold (#2552), routing-bodies (#2559),
  routing-model-rest and rest-try-now (#2115, #2564), routing-keys-fold
  (#1612), routing-wb-restricted (#1905), routing-request-metrics
  (#2571), quota-count-wrap and quota-name-translated (#2228), s3-sync
  (#2448), usage-checkin (#2549), usage-ledger-abort (#2700),
  tencent-access-key (#2733), usage-range (#2734); side-toggle's WebKit
  motion red 1 of 3 on main, 0 of 3 here (#2732); usage-fold green alone.
  Rebased onto origin/main 717b69f78 (60725faa1, no conflicts): gofmt
  clean, vet darwin/linux nogui/windows ok; go test -timeout 45m ./...
  red in TestSetAnswersWhileDevinAndProvidersHang (#1375) and agent and
  gateway at the 45m alarm with tests still moving at load 400+, both ok
  alone (1173s, 1167s); 105 GUI files the series reaches (plugin*,
  sidebar*, side-*, settings*, title*, header*, agent-*): 1322 tests,
  23 red, run alone 214 of 218 ok, the 4 left in sidebar and
  sidebar-overlay-scrollbar (WebKit), red on 717b69f78 too (#2684,
  #1863). The whole GUI suite was not run again after the rebase.
- plugin-panels' tall panel (body{margin:0}) measured 220, not 180,
  after the look above gave an unstyled body 20px of padding; the
  fixture now sets padding:0 too, as a page that wants none would.
  plugin-panels ok in chromium and webkit after.
- gofmt -l clean; go vet darwin, linux (-tags nogui) and windows ok.
- GUI: plugin-page and plugin-panels in chromium and webkit, en zh zh-TW
  ja de, wide and narrow, ok.
- Broken by hand, each red then green: titled() in pluginpages.js
  (the "draws in its frame" test), the wails:// scheme in pagePolicy
  (the WKWebView test, before the rebase onto #2501), titles' parsing
  (TestWindowTitles).
- Real use: the published @magpie-community/page-usage 0.1.1 in a
  sandbox magpie window, its tiles styled.
2026-10-18 07:13:09 +08:00
yetone 2c72563dd1 usage: Requests splits and filters by gateway key, with "No gateway key" for the calls none made (#2521)
MauriceCarlo asked for two things on Usage → Requests.

1. The gateway-key filter should show even when one key has calls. The
   picker hides itself under two options, and with one key it had one,
   so calls made with that key couldn't be told from calls made with no
   key. A "No gateway key" choice (callerKey=none) now sits beside the
   keys whenever the period has calls with no key, or it is the current
   pick. A single key's picker therefore shows and separates the two.
   The hidden condition itself is left to #2499, which another session
   has.
2. The trend chart and the ranking can split by gateway key. LED_SPLITS
   gains "Gateway key". It's offered only while the period has a key's
   calls, and it falls back to Model otherwise. A click on a rank row
   picks that key, or none, and a second click lets go, as the other
   splits do.

Server:
- usage.Dimensions gains "callerKey". A row's key is its CallerKeyID, or
  NoCallerKey ("none") when it has none, and the filter takes "none" as
  calls without a key.
- Filter.Without(d) is the one place that clears a dimension's own pick,
  so the by-split lists every value. RequestPage's fast and slow paths
  both use it now; they each had their own switch.
- usageapi names the split's shares from the key labels: "No gateway key"
  for none, the ID if a key was deleted.
- OwnPage keeps a held key's view to its own share in by and in the
  chart's split, so one key never learns another's name or numbers. The
  series was already only its own rows.
- docs/reference.md documents callerKey=none and by.callerKey.

"No gateway key" goes into the core i18n.js. The gateway keys page says
"No gateway keys yet", and i18n-keys' "a plugin's words are its own"
matches on substrings.

Tests:
- TestCallerKeySplitAndNone runs the fast and the slow path over {},
  one key, none, and none+an agent, and checks by.callerKey. Broken by
  hand, it goes red: once with the none clause in the filter removed, and
  once with Without's callerKey case removed.
- TestUsageOverGateway: on loopback the split names both keys. A held
  key's by.callerKey is only its own. With the OwnPage scrub skipped, it
  goes red (another key's name leaked).
- usage-ledger-key-split is new, in both engines, all five languages, and
  1400 and 760 px. It checks:
  - the picker's options with the none choice;
  - filtering on none;
  - the split's rows, and a click picking and letting go;
  - no sideways scroll;
  - that a period with no key's calls shows neither the picker nor the
    pill.
  32/32 pass. With the none option removed by hand, 11 go red.

Run on origin/main d9b943555 (head 663db0ecf), with the #2517,
#2521 and #2522 changes, load ~240:
- gofmt -l clean; go vet -tags nogui for darwin, linux and windows: ok.
- go test -timeout 120m -count=1 ./... (pipefail): exit 0, every package
  ok (gateway 1416.8s, agent 1535.5s). Before the rebase, on 63be47717:
  - The 45m run had agent and gateway past 45m (#2544, #2108).
  - TestMainWindowCorners was killed at its deadline (#1936).
  - TestSkillRelinkKeepsUnreadableCopy failed (#2555; it passes alone).
  - gateway alone with 120m was ok.
- GUI, the 41 Requests/Usage files in serial, both engines, before the
  rebase: 493 pass, 3 fail. The 3 were usage-refresh "not yet 2 !== 1",
  the same on 63be47717 alone (1 of 3); seen again on #2184.
- Rebased, these all pass, 102/102: i18n-keys, usage-ledger-ttft,
  usage-ledger-key-split, usage-ledger, usage-speed, usage-ledger-detail,
  gui-ja, gui-de and gui-zh-tw.
- Rebased again onto 9b04c4e20, which touches ledger.go, request_page.go
  and gateway.go:
  - vet ×3: ok.
  - internal/usage, internal/usageapi and internal/cli: ok.
  - internal/gateway -run 'NativeCompaction|UsageOverGateway|Capped|Cap':
    ok.
  - usage-ledger-ttft, usage-ledger-key-split, usage-ledger and
    usage-speed: 86 pass. i18n-keys was red from main's own words (#2586,
    fixed in the next commit).
2026-10-16 21:59:33 +08:00
yetone dc1a9cde27 gui: Usage → Requests lists the first token's time in a column of its own (#2522)
tianxia3111 asked to compare time to first token down the request list
(首字时间). Until now it showed only inside a row's details and the
Duration tooltip. A "TTFT" column (zh 首响, zh-TW 首響, the word the
row details and Routing already use) now sits before Duration. Its
header tooltip reads "Time to first token". A row told from a session
file's times gets "≈", like Duration does. A row with none (not
streamed, or failed before a token) shows a faint dash, not 0 ms.

Narrow windows: ledFit used to have two stages, tight (Sent, Effort,
cache) and tighter (the price reference, shorter names). The new column
pushed the reporter-sized 975px window of #860 into tighter, so the
price reference went. A stage between them, tight2, now hides only the
TTFT column (LED_COLS opt level 2 → .lc-opt2). The hint then says the
first token is in each row's details too.

"TTFT" and "Time to first token" go into the core i18n.js, not the
plugin's. Other code says those words too, and i18n-keys' "a plugin's
words are its own" would fail otherwise.

Tests:
- usage-ledger-ttft is new: the header and its tooltip, the value and the
  dash, the ≈, and the column leaving at a narrow width with the hint. It
  runs in both engines and all five languages, 12/12.
- usage-ledger's column lists and usage-speed's narrow hint are updated,
  and usage-ledger-detail finds Duration by its class.
- The staged tree alone (index checked out): i18n-keys, usage-ledger-ttft,
  usage-ledger, usage-speed and usage-ledger-detail all pass, 61/61.

Run on origin/main d9b943555 (head 663db0ecf), with the #2517,
#2521 and #2522 changes, load ~240:
- gofmt -l clean; go vet -tags nogui for darwin, linux and windows: ok.
- go test -timeout 120m -count=1 ./... (pipefail): exit 0, every package
  ok (gateway 1416.8s, agent 1535.5s). Before the rebase, on 63be47717:
  - The 45m run had agent and gateway past 45m (#2544, #2108).
  - TestMainWindowCorners was killed at its deadline (#1936).
  - TestSkillRelinkKeepsUnreadableCopy failed (#2555; it passes alone).
  - gateway alone with 120m was ok.
- GUI, the 41 Requests/Usage files in serial, both engines, before the
  rebase: 493 pass, 3 fail. The 3 were usage-refresh "not yet 2 !== 1",
  the same on 63be47717 alone (1 of 3); seen again on #2184.
- Rebased, these all pass, 102/102: i18n-keys, usage-ledger-ttft,
  usage-ledger-key-split, usage-ledger, usage-speed, usage-ledger-detail,
  gui-ja, gui-de and gui-zh-tw.
- Rebased again onto 9b04c4e20, which touches ledger.go, request_page.go
  and gateway.go:
  - vet ×3: ok.
  - internal/usage, internal/usageapi and internal/cli: ok.
  - internal/gateway -run 'NativeCompaction|UsageOverGateway|Capped|Cap':
    ok.
  - usage-ledger-ttft, usage-ledger-key-split, usage-ledger and
    usage-speed: 86 pass. i18n-keys was red from main's own words (#2586,
    fixed in the next commit).
2026-10-16 21:59:33 +08:00
yetone 6f92815335 routing: each try says where its time went: magpie, the network, the vendor (Discord, Magic_zero)
A user read a slow turn as the gateway being slow. The try loop's
httptrace now also records DNS, connect, TLS, GotConn (reused or not)
and the first response byte. Each Try keeps a TryNet ("net"): magpie's
own time, requests made before it, the wait for a pooled connection,
DNS, connect, TLS, sending, the vendor's wait for its first byte, and
Head (from the try's start to that byte). A Route also carries the usage
record's Sent/Own/Retried/Queued split. Usage records are unchanged.

The Routing page's story shows "Where the time went" under each finished
try. It is one stacked bar plus named values, in three groups (magpie,
network, vendor): Waiting for a slot (tr.queued, which was never shown
before), In magpie, DNS, Connecting, TLS, Sending, Vendor (first byte),
First token, Streaming. Parts that took no time are left out. The
strings are in every language. "Waiting for a slot" moves from the
Usage plugin's i18n into i18n.js, since Routing uses it too.

Not covered: plugin providers (and any other request sent by something
other than Go's client). Their request goes out through the Bun host's
fetch, so no httptrace fires. Such a try has no net and shows no
breakdown, only the time it took, as before (and so does a trace from
before this change).

Run (worktree at origin/main b03031738):
- gofmt -l: clean. go vet -tags nogui ./... for GOOS darwin, linux and
  windows: ok.
- TestTryTellsWhereItsTimeWent uses a TLS fake whose headers are held
  300 ms. Wait must land in [hold-1, hold+5000]. On a new connection
  TLS is > 0. The steps sum to no more than Head, and Head is no more
  than TTFT. A reused connection has no DNS, connect or TLS.
  -race -count=3: ok.
- Broken by hand: with the old two-hook trace back in gateway.go, the
  test fails ("no timing").
- routing-time-went.test.cjs: chromium and webkit × en, zh, zh-TW, ja,
  de at 440px: 10/10. It checks that the bar is to scale, that nothing
  spills out of the story, that there is no left border, and that the
  plugin try shows no breakdown. i18n-keys: ok. Rerun on the committed
  tree: 13/13 with i18n-keys.
- routing-*, usage-ledger*, lane-limit at --test-concurrency=4:
  4 reds, all webkit click timeouts in routing-busy ("trace updates
  keep the rows…", en and zh) and routing-idle-frame ("hiding a running
  replay…", 2). Both files run alone: 13/13, twice. Recorded on #2211 (the same files go red under load on main cf21b71ff).
- Real use: magpie serve --web on 3571/3572 in a sandbox HOME, against
  a fake vendor (900 ms before its headers, 300 ms to its first token,
  then 1 s of chunks). New connection: In magpie 1.3 ms, DNS 0.3,
  Connecting 0.4, Sending 0.1, Vendor (first byte) 912 ms, First token
  294 ms, Streaming 1.0 s. A reused connection had no DNS or connect.
  Both were seen in the page, in headless Chromium.
- Not tried: a real vendor over TLS through the app; the Linux
  WebKitGTK app; Windows.

Full suite: go test -tags nogui -count=1 -timeout 45m ./... ok
(66 packages; gateway 811s, agent 728s, provider 359s).
2026-10-16 01:55:47 +08:00
yetone d6b045a7e7 usage: the Overview's lists fold under their headings and stay folded, the token totals can count the cache, and the Requests Tokens card wraps its cache count instead of cutting it (#2378)
The reporter asked for three things on the Usage page: fold Agents,
Models and Accounts from their titles and remember it (日常看账号维度
较多,都要拉到最底下); an option to count the cache in the token totals;
and the Requests tab's Tokens card cut its cache count off on a wide
window ("缓存 879…").

- Folds: each Overview list's heading (Agents, Models, Accounts, and
  Gateway keys beside them) is a .fold button with its chevron, the
  Gateway page's pattern. A click keeps the page still (backToReader).
  What is folded is kept per viewer in localStorage magpie.usageFolded
  (mountUsageFolds at the plugin's mount, showUsageFolds per render).
- Cache: the tokens tile's label is a pop-up (usageTokensPick, the app
  menu, no <select>) of Without cache / With cache, kept in
  localStorage magpie.usageWithCache. With cache, the tile, the chart,
  and every row's count and share add cache read and written
  (usageTokens), and the tile says the cache's count. Default unchanged.
- Cut count: a token line in parts (the Requests strip's Tokens card,
  the Overview's tokens tile) wraps between its counts and keeps each
  whole (usageParts, .parts); only a count wider than its card on its
  own is cut. The part spans undo .kpi span's label capitals.
- Strings in zh, zh-TW, ja, de. docs/subsystems/gui-shell.md bullet.
- mobile-web.test.cjs: until BASE_REF has mountUsageFolds, the
  desktop Usage comparison puts the new fold buttons and the pop-up
  back to their plain labels and compares the rest as before. That
  comparison caught the tile's line in the label's capitals and 5px
  taller; both fixed, and usage-overview-fold now checks them.

Run at this head (base dd25997a4), BROWSER=chromium and webkit each,
single files:
- usage-overview-fold (new, en/zh/zh-TW/ja/de at 1100 and 420 on the
  Overview, 1500/1100/420 on Requests; the ledger fixture is the
  reporter's numbers, zh in 万/亿 as they read them): 26/26 both.
- usage-accounts, usage-hit-rate, usage-ledger-fit, usage-ledger,
  usage-ledger-agent-middle, own-requests, mobile-web,
  usage-speed-count, usage-sum-whole, usage-head-steady, i18n-keys,
  click-scroll, number-units, gui-zh-tw, gui-ja, gui-de: all pass
  both engines.
- usage-agents-hide: 5 pass, 11 fail in both, "unhiding a row leaves
  the hidden line where it was", identical with this change taken out
  at dd25997a4: #2276, open.
Broken by hand, chromium, each red then restored: the .parts CSS gone
(9 red, among them zh 1500 cut at "缓存 8793.3 万"); folded lists not
hidden (11 red); the cache never counted (11 red, 8.1M vs 568M); the
parts' label-style reset gone (11 red, uppercase/600).
No Go changes, so no gofmt or vet. Not tried in the real app.

Full suite: SUITE_LINE
2026-10-15 23:08:05 +08:00
yetone 6e17d58ebf usage: a top session only the gateway saw says "Gateway session", not "(no prompt)" with no folder (#2285)
The reporter's Usage › Sessions card listed seven Pi sessions on
deepseek-v4-pro as "(no prompt)" with no folder, and their routing group
has no DeepSeek. Those rows were gateway projections: Pi asked magpie for
deepseek/deepseek-v4-pro (every served model is in Pi's models.json), most
likely through a pi-subagents child, whose session file is in a temp folder
magpie never reads. The card gave no sign of that, so it read as Pi's own
sessions with an empty prompt, and our first reply took it that way.

The overview's summaries from MergeExternalStats now carry gateway: true,
as MergeExternal's list rows already did. The card shows "Gateway session"
where the folder would be, "(prompt not recorded)" as the title when no
text was kept, and a tooltip pointing to Record gateway conversations.
Strings in zh, zh-TW, ja and de. gateway-sessions.md says it.

Run in this worktree (a1f7b8c13 base):
- go test -tags nogui -p 1 -count=1 -run 'TestTopSessionsMarkWhatOnlyTheGatewaySaw|TestGatewaySession|Overview|Session' ./internal/gui/: ok
- go test -tags nogui -p 1 -count=1 -run 'External|Overview|Stats|Gateway' ./internal/sessions/: ok
- Gateway: true removed by hand: TestTopSessionsMarkWhatOnlyTheGatewaySaw red
  (the Pi record, provider deepseek, came back with cwd "" and title "",
  no gateway field), green with it back.
- sessions-overview.test.cjs: 28/28 in chromium and webkit; with the
  page.js change undone by hand, red in en and zh ("(no prompt)").
- i18n-keys, gui-zh-tw, gui-de, gui-ja (chromium): pass.
- gofmt -l clean; go vet -tags nogui for darwin, linux, windows on
  internal/sessions and internal/gui: ok.
Not run: the full Go suite and the full GUI suite.

Full suite: SUITE_LINE
2026-10-15 23:08:05 +08:00
yetone 9810648726 usage: a filter picked on Requests is seen taken at once, the rows shown wait dimmed till its read comes (#1990)
overstarry (Windows, v0.1.1224): picking an agent on Usage > Requests
"has no response" and "the selection change does not take effect". The
menu closed, but the button kept the old name and the table its old rows,
with nothing to say a read was on its way. Over a long history that read
takes seconds. The read's own cost (the whole history, twice) is not
changed here; it is asked about on the issue.

- sessPick (app.js) writes the pick on its button at once, before
  choose(), for every picker built on it (Requests' six, Sessions' two,
  the panel's two).
- loadLedger (usage/page.js), on a pick over rows already shown, marks
  #ledWrap led-pending and aria-busy; the rows stay, dimmed, till the
  answer is drawn, and are undimmed on a failed read too. An aborted read
  leaves it to the read that replaced it.
- app.css: the dim, and no transition under reduced motion.

Run: new usage-ledger-pick-pending.test.cjs (read held by the test; en,
zh, zh-TW, ja, de; Chromium and WebKit) 10/10, three runs in a row.
Neighbours in both engines 67/67 + 79/80 then 80/80: usage-ledger,
-abort, -agent-middle, -fit, -content, -detail, ledger-hscroll,
panel-usage, sessions-toolbar, -folder-paging, -talk-model, -search,
i18n-keys. The one red first time was this test reading opacity mid
transition (chromium zh/zh-TW/ja, 2-3 of 5 per run); fixed by the
reduced-motion rule, not by waiting.
Broken by hand, then restored: sessPick passing choose straight through
-> 5/5 FAIL in WebKit ("the picker says the pick at once"); loadLedger
never setting pending -> 5/5 FAIL in Chromium. node --check on both
files ok.
Not run: go tests (no Go changed; disk at 2 GB free), the real Windows
app over a long history.

Full suite: SUITE_LINE
2026-10-15 23:08:02 +08:00
yetone 206dc24cd5 gui: with the Sessions page switched off, a latest session on Usage unfolds its details, not a click that does nothing (#2311, betacatZ)
Usage › Sessions' latest sessions open on the Sessions page. With that
page switched off in Plugins › Built-in (the reporter's screenshot has no
"All sessions" beside the search, which is hidden the same way), the row
still looked like a link, with a chevron and a pointer, and a click
returned without doing anything.

Now, with Sessions off, the row is a button (aria-expanded) that unfolds
the session's details in place, as a top session's do: time, folder,
session id, the resume command, what each model spent, the file. One is
open at a time, Enter and Space fold it, and nothing scrolls. With the
page on, a row still opens there.

Run: internal/gui/tests/sessions-usage-off.test.cjs (new, 12 cases:
Chromium and WebKit, en and zh, 900 and 420px) passes; with page.js put
back to HEAD its 4 Chromium "off" cases fail and the "on" cases pass.
sessions-usage-open, sessions-paging, sessions-in-range,
sessions-overview and builtins pass (84). Go tests not run here (disk
under 6G free); no Go file changed.

Full suite: SUITE_LINE
2026-10-15 23:08:01 +08:00
yetone 8a1b5916f3 sessions, usage, gui: one read of every call at a time, the Codex effort built once and kept, and the Sessions page asks for an overview once, so the app no longer grows to 85 GB (#2278)
On a long history (the reporter's: 68k call files in calls-v15, 415 MB;
42 MB usage.jsonl; 75k calls in 7 days), the app's main process grew to
85 GB in about 90 minutes and the gateway froze. `magpie serve` alone held
83-153 MB for 20 minutes (the reporter's follow-up), so the growth is in
the app's Sessions path:
/api/sessions/overview -> usage.CodexModelEffort -> LedgerOfAt ->
sessions.Calls(all history).

Why it grew:
- CodexModelEffort's cache key changes on every gateway write, and it
  never kept an answer when usage.jsonl was missing or grew during the
  build. So every /api/sessions, overview, /one and /manage ask with a Codex
  session rebuilt the all-history ledger, gob-decoding every shard (only
  64 stay in memory).
- Nothing joined concurrent asks.
- The page's 15s reload asked for an overview again while the last one
  was still under way, so slow asks piled up.

What changes:
- sessions.Calls and the new AgentCalls go through sharedCalls. An ask
  while the same read is under way waits for it and gets a copy, and
  reads run one at a time.
- AgentCalls(since, "codex") reads Codex's files only. pruneCalls still
  sees every file.
- CodexModelEffort is built from Codex's calls plus the gateway's records.
  Only those name a Codex actor, and TestCodexModelEffortIsTheWholeLedgers
  checks the answer equals the whole ledger's on a mixed Claude + Codex +
  gateway fixture.
  - One build per period at a time. An ask during a build gets the last
    answer for the same home (root), or waits if there is none.
  - The answer is kept when usage.jsonl is missing or grows during the
    build.
  - At most 8 periods are kept.
- page.js: sessOverview shares one promise per query, so the filter's ask
  and the 15s reload's ask for the same overview send one request.
- docs/subsystems/gateway-sessions.md says this.

Reproduced (temporary test, not committed): a sandbox HOME with 62k
Claude Code session files, 5.9k Codex rollouts and 100k gateway records.
Sessions routes in-process, 4 rounds x 6 concurrent asks
(overview?days=0 and /api/sessions), a usage record appended every 300ms:
  before (2b0037f41): 7m39s total, slowest ask 2m01s; 66264 MB allocated
    (2761 MB per ask); peak heap in use 4620 MB, peak Go sys 6274 MB,
    peak RSS 5325 MB
  after:              20.4s total, slowest ask 7.1s; 20728 MB allocated
    (863 MB per ask); peak heap in use 1168 MB, peak Go sys 1487 MB,
    peak RSS 1415 MB
Cold warm-up (index plus every shard) was 21m before and 18.5s after on the
same home. The after run reused the shards on disk, so it is not a
comparable number.

Tests, each red on the old code:
- TestConcurrentCallsShareOneRead: 8 reads, not 1. It also goes red when
  the join is broken by hand.
- TestCodexModelEffortConcurrentAsksBuildOnce: 8 builds.
- TestCodexModelEffortAnswersLastWhileBuilding: 3 builds.
- TestCodexModelEffortKeptWithoutLogAndAcrossAWrite: 2 builds.
- sessions-overview-once.test.cjs: 2 overview requests, not 1. That is
  chromium and webkit; en, zh, zh-TW and ja at 1100/900px, de at 420px.
  It was red with the old page.js served.
TestAgentCallsReadsOneAgent and TestCodexModelEffortIsTheWholeLedgers pass
on both versions.

Run:
- gofmt -l: clean.
- go vet -tags nogui for darwin, linux and windows: sessions, usage,
  gui. Before that, the whole tree for linux and windows.
- go test -race on ./internal/sessions/ and ./internal/usage/.
- go test of internal/sessions, internal/usage and internal/gui at the
  rebased head (on 95e7c6bcc): green. gui was red once, in a run whose
  output was cut, at load ~100; it was green on two reruns.
- Full suite: SUITE_LINE
- GUI: the 13 files that ask for sessions/overview, at the rebased head,
  in chromium and webkit: 198/198. Before the rebase, those plus every
  usage*.test.cjs,
  in chromium and webkit: 749 pass. The 24 failures are usage-fold
  (#2163) and usage-agents-hide (#2276). The same 24 fail with the old
  page.js on 2b0037f41, and both are filed.

Not tried: the real app on the reporter's data; an hour-long run.
2026-10-15 23:08:00 +08:00
yetone 3c7ec4ba24 gui: Usage is a plugin's page, its code, markup and words in plugins/usage (P2)
P2 of docs/subsystems/plugin-runtime.md, the fourth page after Sessions,
Library and Routing, and the largest part of app.js.

- The Usage page's code (~3000 lines: the Overview's cards, the
  Requests ledger and heatmap, the Sessions tab, the Agents list) moves
  from app.js to assets/plugins/usage/page.js; its markup, index.html's
  <main id="view-usage">, is client.js's part html. app.js 25756 →
  22675 lines (1,355,376 → 1,198,239 bytes).
- page.js builds on app.js at the top level (its timers, ?view=usage's
  tab and filters), so it is the one plugin script that loads after
  app.js. index.html: kernel.js, the plugins' other scripts, app.js and
  the scripts beside it, each page.js, then start.js, which is app.js's
  old tail (magpie.start(), navHides, OPEN_VIEWS, the first page shown,
  load()), so the first page has its code. TestBuiltinClientsLoaded
  holds that order.
- Hooks: open loads it, refresh(again) is load()'s read of it, reload is
  Refresh now, costs redraws costs on a currency change, tab says the
  tab for focusQuotaCard. app.js calls those through magpie.call. The
  allowance cards, quotasOpened, panelQuotaFocus and panelUseFocus stay
  in app.js: the tray panel draws them too.
- plugins/usage: Essential, Requires window, no InUse. Off, its nav tab
  goes and so do the ways to it (data-feature="usage": the panel's Open
  Usage, Routing's View usage); show("usage") gives way to Agents; the
  panel's Allowances tab stays. builtins.test.cjs switches it off and
  checks each.
- The 173 strings only Usage says move to plugins/usage/i18n.js;
  i18n.js 15032 → 14344 lines. "{n}s" and
  "All sessions" stay: context.js says them too since #1591.
- context.js: with context.js now in before the first page is shown,
  the page's open and load()'s first refresh both reached loadContext,
  and the second drew "Reading…" again over the advice the first had
  just drawn, so its curves never played their entrance (context-tune,
  3 of 3 red). loadContext draws the waiting pane once for the same
  days. Its dead last line, which loaded the tab once context.js came
  in late, goes.
- context-window.test.cjs's "arrives after the state" becomes "loads at
  once though context.js is slow": start.js now waits for it.
  usage-stale-answer reads page.js beside app.js. quota-refresh-order
  (#1630) cut app.js at the period picker's comment, now in page.js; it
  ends at the next comment that stays (5 of 5; without keepRefreshedQuotas'
  call, 2 of 5 red).
- docs: plugin-runtime.md, gui-shell.md.

Run, at this tree on origin/main af27b70b4 (main's keepRefreshedQuotas
and quotaRefresh changes, #1630, stay in app.js beside loadQuotas: the
tray panel draws those cards too):
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows.
- go test -count=1 ./internal/gui ./internal/pluginrt ./plugins/...: ok
  (-skip TestMainWindowCorners, #1936); gateway and usage as above.
- usage-card-refresh, quota-refresh-order, builtins, editor-picker-clicks,
  context-window, usage-stale-answer: Chromium and WebKit green.
- The full GUI set: see the Routing commit; every Usage red there is the
  same on main or red only under load.
2026-10-15 01:32:13 +08:00