ac4af582301a4e8a29245dbba767eba31334ddf9
80
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
92be1d779b |
usage: the allowances' head opens Settings › Allowances
The Usage page draws the allowances, but how they are shown (used or
left, the menu bar's figures) and their alerts are set in Settings ›
Allowances, and nothing on the page said so (the scattered settings
audit after netube99 on X). The allowances' head now has a Settings ›
link, as the Routing page has, that opens that tab and lights the
Allowance display row (now #quotaLeftRow). Wired in the usage plugin,
so the core script doesn't grow.
Run (mote, through mote-run, Chromium and WebKit, every language, 1100
and 420): settings-places, mobile-web (with an origin/main baseline;
the button is taken out until the baseline has it, as rtToSet is),
account-mask, quota-curve, i18n-keys: 89 of 89, twice. A first run had
one red whose name a tail cut off; the next two runs of the same files
were 89 of 89, so it is unnamed and not seen again.
Broken by hand: no onclick, settings-places 2 of 2 red (no row lit);
no #quotaLeftRow, 1 of 1 red.
At the pushed head (rebased on
|
||
|
|
54af4357c3 |
usage: the agent filters show each agent's icon
The owner: Usage › Requests' agent menu listed names alone ("这里应该有
Agent的icon"). The ledger's agents already carry their icon (usageapi
Named.Icon), so the menu now draws it beside each name: an agent's own
logo, the generic one for a client magpie doesn't know (AsyncOpenAI,
Go-http-client). Sessions' agent menu does the same, from a session's
icon or, for an agent with none listed, the agent magpie knows. The
shared menu (openSessCombo) draws icons only when its options carry
them, and keeps the room blank on the All row, so every name starts at
one x; the other filters (models, folders, providers...) are unchanged.
usage-agent-filter-icons.test.cjs opens both menus in Chromium and
WebKit, en and zh: each row's icon, the All row's blank room, names at
one x, each icon on its name's line, and the search narrowing them.
Run (mote, at
|
||
|
|
f418edffc3 |
sessions: a session's details show how full its context was, request by request
liang_yongxiang on Discord: Routing tells how full one request's context window was; does Sessions have the same, each turn's share? A session's details on the Sessions page (and in Usage's Sessions list, which draws the same details) get a Context line when the gateway sent calls of it (s.via): the Context tab's spark of its prompts, request by request against its window, and the fullest one's share beside it, toned as the tab tones it. A point's tip says "Request 2: 80K of 200K (40%)" (the tab's spark says it too now, where the window is known); a point clicked opens that request in Routing with its card. A session the gateway never saw asks nothing; one it kept no prompt of shows no line. The data is the routing history the Context tab already reads. A new GET /api/context/session?agent=&id=&from=&to= reads only the days from the session's first to its last (30 at most), through the tab's per-day cache (daysRecsLocked, split out of contextRecsLocked, so the tab's cached days are not evicted), and keeps that one session (contextOfRecsFor), with up to 1000 of its requests. The tab keeps the latest 80 sessions and would leave an older one out. Subagent and side calls are left out as the tab leaves them out; the same id under another agent is that agent's. The line's code is in plugins/usage/page.js (sessCtxLine). context.js only exports spark and health, and pays for its tip by cutting comments, so the core's scripts are 10 bytes under main's, no budget raise. Run at this head (rebased on |
||
|
|
7a6211d047 |
providers: a model's own headers, in Model settings
axelburks on Discord: a vendor routes one model by a header of its own. A key's provider (built-in or custom) can give each model headers (settings.ModelHeaders["pid/model"]). They go on that provider's requests for that model alone, after the provider's headers and after auth: a name both have is sent once, as the model's, so a user's value is never overridden by the provider's or magpie's key header. The gateway names the model (provider.WithModel) on every route that asks one: chat on each API, translated and streamed, count_tokens, System One's decision, embeddings, images, videos and the model test. A fallback provider serving the same model id gets its own headers only. Accounts and plugins carry their sign-in's headers and take none. The editor's "Name, price and reasoning level" panel is now "Model settings" (every language), with + Add header per model, staged and made with the Save; Restore default takes them away. The rows being typed are kept out of the draft's compare, so an untouched editor still closes without asking. Broken by hand: dropping WithModel from gateway.go turns TestModelHeadersReachTheirModelOnEveryRoute red; dropping the provider id check in modelOf turns TestModelHeadersStayWithTheirProvider red. Run, on this stack over origin/main |
||
|
|
b77400826a |
usage: the Overview read again keeps its cards and its place, and shows it is reading
jiabubu on Discord: a refresh of the Usage page's Overview showed nothing while it read, flashed the page and dropped cards for a moment, and pressing Usage again while on the Overview flashed it or moved its scroll. - Pressing Usage again (show() calls the plugin's open, loadUsage(true)) put the skeleton up, which hid the sections, collapsed the page and clamped its scrollTop. loadUsage now puts the skeleton up only for a first read or another period or zone (usageFor/usageKey); a page that already shows that read reads again quietly through refreshUsage, so nothing is blanked and the scroll stays. - The refresh beside the period turns while such a read is out (#usageReload.reading, after 200ms), and while every card is read (loadQuotas) each card's refresh turns (#subscriptionUsage.reading, quotaReading in page.js). A card's own busy turn is left to its own animation (:not(.busy)). No turning under reduced motion. - renderQuotas draws the cards again in one go, as their reset countdowns need, but now keeps their logo nodes (keepIcons), and the Overview's lists do too: a logo made afresh blinked out while its picture loaded. - app.js stays in its budget: a three-line comment in renderQuotas cut to one. Core 1,533,507 of 1,533,802 before the rebase on |
||
|
|
8de63c8b5a |
gateway, usage, gui, otlp: a request its agent canceled is no failure (#2398)
An agent that cancels its request before it is answered is logged 499 "the agent canceled the request": a person stops the reply, or sends the next message while it is coming and Claude Desktop cancels it and asks again, or Codex takes a subagent's report (#2398). The gateway already says nobody failed (no rest, no reroute: TestCanceledRequestRestsNobody), but Record.Failed is a status >= 400 or an error, so every page counted it as a failure: the Requests card's "N failed" and success share, its Failed filter, the CSV's error column, the Routing page's "errors your agent saw", the Context page's error rate, the failed colour in the Requests list, Routing and Recent calls, and the OTLP export's error status. A Claude Desktop session on 2026-10-27 had four, each a message sent mid-reply; #2398 had 91 of a day's 92 failures. usage.CanceledBy tells the agent's cancel (499 with AgentCanceled) from magpie's own limit on a request it asked of itself, logged 499 too and still a failure (#2318). The cancel is logged with an error type of its own, agent_canceled (usage.CanceledErrType, set in failedWith), so the record says what it was and nothing guesses it from a 499, as #2398 asked. Record.Canceled reads the type, and a record logged before it by its status and message, so the old log reads the same with nothing migrated. A middleware's usage rows carry the type, so a module can tell the cancel from magpie's own limit, which its rows (no error text) couldn't. Record.Failed leaves the cancel out; Totals counts it apart (Canceled, in count and plus); RetriedRequest and the first-token and speed sums ask Answered, so a canceled request is timed nowhere, as before; Codex's memory of the last model still skips it. Routes and Recent calls say canceled (set as a route is done and as a day's history is read, so old days read the same); the Routing totals and the Context page's errors leave it out. Ledger rows say canceled, and the pages show it muted, in neither the failed nor the answered colour: the Requests list and its detail ("499 · canceled"), the Requests card ("N canceled", the success share of the requests not canceled), the overview tile, the Routing page (a "gone" outcome, no speed) and Recent calls (muted). New strings are in zh, zh-TW, ja and de. The OTLP export: the records the gateway gives its observers for a request and its try carry the type too (canceledAs), and a root span's error.type follows Record.Failed, so a canceled request's span and its try's go with status code 499, no error and no error.type. TestOTelWaterfallFailureAndCancellation's canceled case held two failed spans (the try the vendor refused as the agent left is recorded canceled, as the request is); it now holds neither failed, both 499 and no error.type. That change to the test is the point of this one. mdwsk88's patch (aea0027fd) ran its tests at |
||
|
|
542ee03b4c |
usage: each request says its cache hit rate, as the Routing page's do
teenux (Discord, #feedback) saw a cache hit rate on each request in the
Routing page's list but none on the Usage page's Requests tab. Each
Usage request now has a Cache hit rate column after Cache read, worked
out as Routing's request list does (promptOf in routing/client.js): the
tokens read from the cache over the whole prompt, uncached input plus
cache reads and writes, through app.js's cacheHitOf. It is said as
Routing says it, a whole percent ("90%"), with Routing's tooltip ("Cache
hit rate: The share of the prompt read from the cache"). A vendor that
counts no cache (cache_unknown, #3464) reads "—" with "The vendor
doesn't count the cache"; a request with no prompt counted reads "—"; a
miss reads 0%. The row's own fields only: nothing new is fetched.
Folding: at the page's 1200px cap the raw cache columns are usually out
already (tight), so the hit rate folds with the first token's column
(lc-opt2, tight2) rather than with them; while it is out the row's
details say it, and while it is in they don't say it twice. Every
string already had its zh, zh-TW, ja and de, so no i18n entries were
added.
Not the same: for a request with billable retries Routing sums every
try's usage, and a Usage row holds one usage record, so the two can
differ there.
Run on mote (macOS 27), Chromium and WebKit, five languages:
- new internal/gui/tests/ledger-cache-hit.test.cjs: 12/12 ok
- 65 GUI files the change reaches (this one included) (every test touching the ledger
table, its details or the Requests tab) plus i18n-keys and
i18n-en-no-cjk: 1147 of 1165 ok. Reds, all filed and not from this
change: i18n-keys "a plugin's words are its own" (#5327, #5332,
#5426, #5482), gateway-caller-keys en at 560px (#3797),
usage-ledger "newest live route needs no return-to-live button"
(#3104, #4078). Two more reds were this change's and are fixed here:
usage-ledger's header list and usage-ledger-detail's always-shown
labels (now leaving lc-opt2 out, as they left lc-opt out);
usage-ledger-ttft's lc-opt2 header locator now names its column.
Rerun of usage-ledger, usage-ledger-detail and ledger-cache-hit:
only the two filed return-to-live subtests red.
- go test -tags nogui ./internal/gui/ (TestCoreScriptBudget and the
other budgets): ok. No Go changed, so no gofmt/vet.
Broken by hand: origin/main's page.js -> ledger-cache-hit red ("a
Cache hit rate column"); the rate as cache_read / in (Routing's
denominator dropped) -> red on the values (deepEqual).
Not tried: the real app with real history; Windows and Linux GUIs.
Reported-by: teenux (Discord)
|
||
|
|
808e569534 |
usage: the refresh picker goes to 5, 15 and 30 minutes
The Usage page's auto-refresh topped out at a minute. A page left open
all day had no slower choice than reading again every 60 s. The picker
(the same app menu) now also offers 5 min, 15 min and 30 min.
The choice lives in localStorage (magpie.usageEvery) and is read back
only if it is one of USAGE_EVERY's values, so the new ones round-trip by
being in that list. Nothing on the Go side reads or clamps it. The labels
"5 min", "15 min" and "30 min" already have zh, zh-TW, ja and de
translations in i18n.js, so no new strings.
usage-refresh.test.cjs now runs in all five languages, checks the eight
choices in order, that half an hour reads none for 29 minutes and once by
31, and that another window opens on 30 min.
Run (mote-run):
- usage-refresh.test.cjs, Chromium and WebKit, en/zh/zh-TW/ja/de: green.
- The 195 GUI files that open the Usage page or its tray tabs, Chromium
and WebKit, every language they cover (node --test, concurrency 6,
mote at load ~35): 1100 ok, 11 red in 6 files. Rerun alone, here and
on an untouched origin/main
|
||
|
|
4f03fdbb55 |
usage: a menu opened in the page's first second closes on a click again
The usage page's guard against the mouse events a phone makes up after
a long press (quotaPressing) ate every click and mousedown outside a
row menu for 1s after quotaPressed. quotaPressed started at 0, so with
no long press at all, any row menu opened in the page's first second
(performance.now() < 1000) could not be closed by its button or by a
click outside it, and nothing else on the page took a click until then.
Found while testing the Library bar's new ⋯: the test opens it within
a second of loading and its second click was swallowed. quotaPressed
now starts at -Infinity, "never".
Run (mote, through mote-run):
- node --test internal/gui/tests/menu-first-second.test.cjs: 2 pass
(Chromium and WebKit). The test sets the page's clock back 10s so it
is all in that first second, and checks it is.
Broken by hand: quotaPressed back to 0, both engines red (".row-menu
to be detached" timed out after the second click on its button).
Not tried: a real long press on a phone (the 1s after one is unchanged).
|
||
|
|
c6b7bbedfc |
usage: a narrow Requests list makes the rest tighter before it leaves the first token's column out
unscientific9 saw Requests' 首字耗时 column on one Windows machine and not
on another, with the same settings and version. The column is left out
when the table doesn't fit the window (ledFit), and that width is each
machine's own: the saved window size (660 by default), Windows' display
scaling and the text size. It was the first thing to go after Sent,
Effort and the cache, before names were cut shorter, headers wrapped and
the price reference line dropped (tighter). Now tighter comes first, and
the column goes (tight2, its value under the duration since
|
||
|
|
f47390bf35 |
usage: the speed chart draws every model timed at a point, over 7 and 30 days too
zzzkl3994 on Discord: Usage → Requests, Speed, on 7 or 30 days, today's
column showed one of the five models used today. The chart's colours were
the ranking's top 7, ranked by speed, so a month's fastest models of a
reply or two on an older day took every colour; a speed chart has no
"Other" column, so a model past the colours was drawn nowhere, in the
columns, the lines and the tooltip alike. Today has fewer models, so it
looked right.
Now the chart's colours (ledCategories with chart set) go to the models
most timed (decode_n), ones with a measured speed only, and a model past
them is a faint mark (and a faint line) of its own and a row in the
tooltip. The ranking keeps its speed order and takes the chart's colours,
as it already did for a picked day (chartBy). Tokens, cost and requests
keep their rule: top 7 by that metric, the rest stacked as grey "Other",
which drops nobody. The tray panel draws through the same functions.
Run on mote:
- new internal/gui/tests/usage-speed-all-models.test.cjs: Today, 7 days
and 30 days, columns and lines, tooltip, ranking colours = chart's;
chromium + webkit, en/zh/zh-TW/ja/de, 1100 and 420: 22/22 pass.
Against origin/main's app.js and usage/page.js: 22/22 red, Today passes
and 7 days loses glm-5.1 etc. (the report's shape).
- node --test internal/gui/tests/{usage,panel,reasoning-speed,i18n}*.test.cjs
(100 files, at
|
||
|
|
640825b09a |
usage: the Requests card's traffic line reads whole, and a row says how many images went by file
matrix0487 on Discord:
- The Requests card's line "↑ 13 GB · ↓ 13 MB · 图片文件省下 44…" was cut
with an ellipsis. It was one nowrap span.
- A row's details say "图片文件省下 10 MB" and should say "10 MB(3 张)".
The card line is now made of whole parts (usageParts, the pattern the
token line has since #2378). A card too narrow for all three puts the
saving on a line of its own. A part that is wider than the card by
itself (German at 420 wide) wraps inside itself; it is never cut.
The count:
- withDeepSeekFiles counts the image blocks it puts a file id in place
of, on each try, and upBytes keeps the most of any one try (a retry
sends the same images again, as the saved bytes are counted).
- It goes into usage.Record as `image_files` (omitempty) beside
image_files_saved.
- packedRow keeps Tries and ImageFiles in int16 each (clamped to
MaxInt16), so the row stays 152 bytes. request_snapshot carries the
new field, and heat_disk hashes Tries as before.
- The detail row says "{size} ({n} image|images)": zh "10 MB(3 张)",
zh-TW 張, ja 枚, de "Bild/Bilder", en "image/images".
- A row from before the count was kept has no image_files and shows
the size alone, with no parentheses. The card's period total gets no
count.
Run on mote, at this tree:
- gofmt -l (clean), go vet ./..., GOOS=linux go vet -tags nogui ./...,
GOOS=windows go vet ./..., go build ./...: ok.
- go test -run 'TestRowImageFilesKept|TestRowBytesKept|TestRowsOfOneSession|
TestDeepSeek|Snapshot|Heat' ./internal/usage ./internal/gateway: ok.
- TestRowImageFilesKept: the count survives pack/unpack beside Tries,
100000 clamps to 32767, an old row reads 0, the JSON has
"image_files":3 and leaves out 0, and packedRow is 152 bytes.
- TestDeepSeekImageFilesCountedInRow: two images in one message and
one again in a later message make 3 in the stored row, twice, and a
request with no image makes 0.
- GUI, BROWSER=chromium and webkit: usage-ledger-bytes runs every
language at 1180 and 420. The 3-image and 1-image rows read in each
language's unit, singular in en and de, and the old row stays bare.
The reporter's period (13 GB, 13 MB, 44 MB) at 1180, 760 and 420 has
every part whole and inside its card.
- The 79 usage-*/led* GUI files (concurrency 2): 641 of 659 pass in
chromium and 637 of 654 in webkit. Every red is filed and red on
origin/main
|
||
|
|
07fd06b4b5 |
usage: a narrow Requests list says each request's first token under its duration
Requests has a TTFT column (#2522), but it is the first column a narrow window leaves out (tight2), and then the value was only in the row's details. unscientific9 asked to see it in the list itself. Now, while that column is left out, each duration cell gets a second, small, muted line: "首字 5.5 秒" / "TTFT 5.5 s" (the core's "TTFT {ms}" string, "≈" for a time told from a session file). app.css draws it from a data-ttft attribute with ::after. That keeps it out of the cell's text, so readers of td.duration's textContent are unchanged. A row with no first token (a failure, or a reply not streamed) gets nothing. A wide window shows only the column, as before. The narrow hint now names only what is left in the details ("Sent, Effort and the cache"). The old "…the first token…" string is gone from all four languages. Run on mote, at this tree: - usage-ledger-ttft, usage-speed, usage-ledger-detail, session-identity, usage-ledger-bytes and i18n-keys, BROWSER=chromium and webkit: all pass except i18n-keys "a plugin's words are its own". That test is red on origin/main for "View routing" and "No session ID" (#5332, #5426), strings this change does not touch. - usage-ledger-ttft runs every language (en, zh, zh-TW, ja, de) at 1600, 760 and 420 wide. At 1600 nothing is under the duration. At 760 the line is the details' first token, "≈" for the Codex row, empty for a failure and for a reply not streamed, smaller than the duration, muted, and the page doesn't scroll sideways. At 420 the same holds. - The 79 usage-*/led* GUI files in both engines (see the next commit). - Broken by hand: with the data-ttft line skipped, usage-ledger-ttft goes red in every language ("expected 'TTFT 5.5 s', actual ''"). Not tried: the real app's WebKitGTK on Linux, and the Windows webview. Reported-by: unscientific9 |
||
|
|
6f0aeec180 |
routing: a request that tells no measured speed shows the least it wrote at, as Usage's Requests tab does (zzzkl3994 on Discord)
zzzkl3994: in Routing's request list some streamed requests showed tok/s and some showed none, while the Usage page's Requests tab gave every one of them a speed. The Requests tab gives a gateway call that tells no measured speed a floor, "≥N tok/s" (usage/page.js ledFloor_): one that reasoned with no first text recorded (a tool call after hidden reasoning), its answer over the time after its first token unless its content came in a burst; else, 1,000 tokens or more over a second or more, its output over its whole time. Routing's rows had only the measured speed. Now a row (and the side panel's row) says the floor by the same rule, with the Requests tab's own tooltip words for it; a measured speed is as before, and the story's per-try line still says only a measured one. The floor's two tooltips are said by two plugins now, so they move from plugins/usage/i18n.js to i18n.js, in every language (i18n-keys: a plugin's words are its own). reasoning-speed, which held that a tool call after reasoning says no speed on Routing while Usage says ≥100, now wants ≥100 on both. Run (mote, via mote-run, Playwright chromium + webkit): - routing-row-floor-speed.test.cjs (new): four gateway rows, a measured one, hidden reasoning before a tool call, a burst, and one too small for either; each row's speed is compared with what usage/page.js's ledRowSpeed/ledFloorSpeed say for the same request, and the floor's tooltip with the Requests tab's words; en, zh, zh-TW, ja, de at 1100px and 390px: 22/22 pass. - routing-request-metrics.test.cjs (rows 6 and 7, two 8,264-token bursts, now say ≥339 and ≥5,509 rather than nothing) and routing-burst-speed.test.cjs: 8/8 pass. - reasoning-speed (updated), panel-routing, routing-speed-first, usage-session-speed, usage-speed-count, usage-speed-every-row: green (10/10 and 48/48 for the first four). - i18n-keys: the floor's two words no longer listed; its "a plugin's words are its own" is still red for "No session ID" and "View routing", the same at origin/main (#5332, #5426). Broken by hand: client.js put back to its parent; the new test is 22/22 red ("waiting for .rt-metric.speed .v" on the hidden-reasoning row). Not tried: the reporter's own requests (no trace of theirs), the real app's WKWebView, Windows and Linux. Reported-by: zzzkl3994 |
||
|
|
8b70b7d976 |
usage: a request's bytes up and down, and what DeepSeek's image files saved, in Requests
Suggested by @faithleysath (matrix0487 on Discord): the usage ledger now keeps what each request received back (down_bytes) beside what it sent up (up_bytes, #4456), and what DeepSeek's image files (#5407) kept out of the upload (image_files_saved). Shown in Usage → Requests: - a row's details: "Sent upstream", "Received" and "Saved by image files", each only when it is above 0. A row from before has none of them, not 0; - under the Requests card, the period's "↑ up · ↓ down", with "{n} saved by image files" when there is a saving. Its title gives the exact bytes. A period with no counted bytes shows no line. What is counted: - Down bytes are counted as the reply body is read, after Go's transport has undone gzip, so a gzipped reply counts its plain size, not wire bytes. A plugin's row counts the local hop to the plugin host. A 101 body is not wrapped. Every try counts, so a refused try plus the answering one add up (TestLedgerKeepsDownBytes). - Image files saved, per try: the body before the swap minus the body sent, minus the upload bytes this request itself paid (len(b64)/4*3). It can be negative on the turn that uploads; the GUI shows only a saving above 0. Gaps: an upload that finishes after the wait timeout or ctx-done is not subtracted (as with up_bytes); a joined upload flight is paid by the request that started it; multipart overhead is approximate. - packedRow grows by three int32 (152 bytes, still within the test's bound), clamped to the int32 range. Totals sum all three. - settledCountVersion goes 1 → 2, because Totals now count bytes. The settled page, heat and effort caches recount once, on the first start after the update. The heat key hash includes the new fields. Run on mote at |
||
|
|
814a625a24 |
usage: the top refresh reads saved Claude accounts again (#5380)
The tray panel's Allowances refresh said "Allowances refreshed" but a
saved, non-active Claude account kept its old reading: claudeWindows runs
Claude Code's /usage for a saved account only under savedRefresh, which
only that account's own card refresh sets.
Now a refresh of every allowance by hand asks usage/quotas?asked=1&all=1
(AskEveryClaudeUsage). It marks its ask generation in claudeEveryAsked,
and for claudeEveryFor (2 minutes) each saved account not read since is
read as its card's refresh would, under the same due check, the
30-second per-account floor and the same running holds. Opening the
Usage page or the Allowances tab (?asked=1 alone), the timed refresh and
every background read are unchanged, so nothing polls more. Callers:
the panel's top refresh (refreshPage "allowances"), the Usage page's
refresh and sidebar reload (refreshUsage -> loadQuotas("all")),
Routing's Read allowances, and the TUI's r. loadQuotas no longer lets a
lesser load on its way (an opening's asked read) swallow a Refresh.
Siblings: saved Codex accounts are already read anew on every asked
whole read (loginReading over HTTP after AskUsage clears the cache), so
Codex is unaffected. PlanQuotas and KeyBalances keep their 1-minute cache
on an asked read; left as is. The core scripts' budget is not raised:
the ~140 bytes are paid for by two loadQuotas/quotasOpened comments cut.
Run (mote, at 807341cdc on origin/main 5666cb049; rebased onto
|
||
|
|
d17a0b3ca0 |
usage: opening the Usage page no longer stutters (_hii11 on Discord)
_hii11 (Discord #general): switching sidebar pages stutters a little,
most of all on Usage. The click that opened Usage built every allowance
card and curve twice, the first time inside the click:
- renderUsageLoading drew the cards again although the read of the
allowances that goes with every load (loadQuotas) draws them once it
answers. Cards already drawn now stay until then.
- every card's draw parsed each history line's readings (up to 6000 a
window, 45 days) three times. quotaPoints parses a line once for each
read of the history (loadQuotaHist puts a new quotaHist), and the
recorded cycles are found once for those points.
The UI is the same; nothing new moves.
Measured on mote, headless Chromium, 1280x820, a busy user's data (10
accounts, 45 days of history, 30 days of usage), Usage clicked 4 times,
frames dropped in the 900ms after the click:
- CPU x1: before 4/4/1/1 (worst gap 50ms), after 1/1/0/1 (33ms)
- CPU x4: before 43/37/33/32, after 32/17/20/19; the click's own task
~250ms before, ~70-85ms after; click handling in the trace 303ms -> 89ms.
Agents and Providers switches were 0-1 dropped before and after.
Run (mote):
- usage-open-light.test.cjs (new), Chromium and WebKit, en/zh/zh-TW/ja/de:
green. Red on the old assets: 17292 dates parsed again per redraw; with
only page.js put back by hand, the cards are rebuilt inside the click.
- the 195 GUI files that touch the Usage page or its cards, both engines:
3243 of 3295 pass. Each red file was then run alone on this change and
on origin/main
|
||
|
|
ce21ea8566 |
usage, routing: counts are said short (K/M, 万/亿), the exact number on hover (skyhuang1994)
skyhuang1994 on Discord: long token and request counts on Usage and
Routing are hard to read at a glance. They now go through fmtN (K/M/B,
in Chinese 万/亿), with the exact grouped number (ledNum) as the title,
so hovering shows it. A count that fmtN already writes in full gets no
title.
- Usage (plugins/usage/page.js): the Requests table's input, output and
cache cells (output keeps its reasoning line, cache write its TTLs
under the exact number), the Requests block, retried, the sources
tile and the ledger's sum line. sameRead moves here from app.js,
beside loadSessions, its only reader.
- app.js: the Tokens and Requests blocks (blk takes a title), the
ledger's call count, the rank's values and "{n} requests".
- Routing (plugins/routing/client.js): the day menu's note, the "more
days" name, the day rows and the stats.
Core scripts: 22 bytes smaller than their base (1533979 at this head;
TestCoreScriptBudget stays red on #5139 as on main, not worse).
Tests: usage-compact-counts.test.cjs is new (Usage and Routing, every
language, chromium and webkit, 420 and 1100px). panel-usage's rank
value expects "900K" with title "900,000"; ledger-cache-unknown's
counted cells expect fmtN text with ledNum as the title.
Run (mote-run):
- at ded9e4a62 (on
|
||
|
|
70a98dd85c |
routing: a long Accounts and keys shows its first rows, the rest behind Show N more (ferock4669, iyou00 on Discord)
With many keys the Routing page's Accounts and keys ran on and on: each card held every window, the models it answered and a meter. Now a card keeps its name, one line of what is left (or its rest) and how it fares, with Try now or Sign in again when it needs one. The models it answered are in its tooltip under its id, and a subscription's other windows are on hover over its figure. A list longer than 8 rows shows the first 8 and puts the rest behind "Show N more" at its foot (kept across a reload in magpie.routingActsAll). Never behind it: a row to sign in again, a resting account or model, failures with no answer, a remote whose allowance can't be read, rows under a fold the reader opened, and the heading of a provider with a row shown. Two more alone aren't folded. The button clicked stays where it is on the screen. "View usage" beside it opens Usage's Overview, where each account's card says it all, without making that tab the reader's own (window.openUsageOverview). The foot writes only what changed, so an idle page writes nothing (routing-live-calm). Tests: routing-acts-compact.test.cjs (new; chromium and webkit, en zh zh-TW ja de, 1300px and 420px). routing-account-windows, routing-read-allowances, routing-wallet-lapse, routing-accounts-narrow and routing-columns follow the card's new shape and the foot. Run on mote via mote-run, worktree based on origin/main |
||
|
|
9ce59b8340 |
routing: a request's row says the credits its reply said it cost (jiabubu)
jiabubu on Discord (#feedback): the Routing page's request list showed no credits for a request that spent them. The gateway already read a reply's usage.credit (#2512) into the usage ledger, which the Usage page shows, but the route trace's RouteUsage had no field for it. RouteUsage now carries Credits (the reply's, nil when it said none). The Routing page's request row shows "N credits" after its cost, or alone when the request has no known price (it read "—" before), with the Usage page's help text under the pointer; By session sums them in the session's cost, shown even when no request in it was priced. The help text "What it cost in its plan's credits, as the reply said" moves from the Usage plugin's i18n.js to the core's, since two plugins say it now. Tests: TestPluginPlanCreditsReachTheLedger also checks the route's usage carries 0.01 on every endpoint (red without the field: Credits <nil>). routing-credits.test.cjs: credits alone, priced plus credits, none, and a session's sum, in chromium and webkit, en zh zh-TW ja de, at 1100 and 420, with no overflow. Broken by hand: the old client.js makes routing-credits 10 of 10 red. Run at the pushed head on mote: gofmt -l clean; go test -run 'TestDailyCredits|TestPluginPlanCredits|Credits' ./internal/provider ./internal/gateway ok; GOOS=linux go vet -tags nogui and GOOS=windows go vet of provider, gateway, gui ok (rebased on origin/main |
||
|
|
187f3e2727 |
usage: a swipe across the Requests table is never written back by its scrollbar's echo (Pluviophile)
Pluviophile on Discord (a phone, magpie's web page and the installed PWA): swiping the Usage › Requests table left or right trembles and sticks (左右滑动震颤, 粘滞卡顿). The cause: the table (#ledWrap) and the scrollbar kept at the window's foot (#ledHScroll, #799) followed each other both ways, each scroll handler copying its scrollLeft to the other when they differed. The scroll a copy sets off is told a frame later in WebKit, and on a phone the finger (the UI side's own scrolling) has moved the table on by then, so the bar's echo saw bar != table and wrote the table back to where it was a frame ago, every other frame of a swipe. Now each copy records the value it set (ledFollow), and that box's next scroll at that value is its echo and is passed on to nobody (ledFollowed). A scroll of the reader's on either box still moves the other, in both directions; ledHScroll's own copy at a redraw goes through ledFollow too. Measured with Playwright at an iPhone 13 profile (390x664, touch, dpr 3), the table moved 2.5px every 7ms off the frame, as a phone's own scrolling moves it, 60 frames: - WebKit before: 44 writes of the table by the page, the table stood still in 29 of 59 frames (5,5,15,15,22,22,...). - WebKit after: 0 writes, 0 frames standing still. - Chromium before and after: 0 writes, 0 still; a real touch gesture (CDP Input.synthesizeScrollGesture, touch) also showed none. The report is WebKit's (iOS), which Chromium doesn't reproduce. New test, internal/gui/tests/ledger-swipe.test.cjs: the table swiped off the frame is never written back nor stands still, and the bar follows; the bar dragged off the frame is never written back, and the table follows. en and zh, Chromium and WebKit, iPhone 13 profile. Broken by hand: page.js at its base ( |
||
|
|
69167bc299 |
usage: a reply let go under a second after a wait four times longer tells no speed
pluviophile714 on Discord: a gpt-6.1-sol row on Routing read 1,539 tok/s (input 21,617, output 392, first token 8.2 s, total 8.3 s), where another monitor measures ~70. The reply came whole about 255 ms after an 8.2 s wait. Its content was spread over that short window (flow 230 ms), so the HeldShare flow check passed, and so did the 100 ms floor, and 392/0.255 s read as 1,539 tok/s. New rule, usage.HeldWindowMs: a window under 1,000 ms whose start (first token, first text or first reasoning) is more than HeldShare (4) times the window tells no speed. One rule in every place that computes one: - usage.DecodeOf: the Usage page's speed and totals, the CLI, the GUI's model speeds, and the gateway's Speed first pacing (noteTrySpeed); - routing/client.js decodeOf: the Routing row's speed and its story line; - usage/page.js ledDecode, plus a ledNoSpeed_ reason for the dash's tooltip, in en, zh, zh-TW, ja and de. docs/reference.md and docs/subsystems/gateway-sessions.md say so. On the owner's usage.jsonl (read only), 103 of the 106 rows over 600 tok/s were such windows (e.g. 448 tokens in 107 ms after 8.1 s) and are dropped. The 3 that stay have windows of 2 to 5 s. The overall speed goes from 103.8 to 97.9 tok/s. What it costs: a short reply that really streamed after a long wait tells no speed either. The live visible-reasoning fixture (76 tokens over 731 ms after 6.8 s, ~104 tok/s) and #2637's grok record (307 tokens 403 ms after a 4.6 s first token, 531 tok/s) now read "—". Their tests keep their guarantees with the same timings after a short wait, and also check the long-wait case. Tests: - New: internal/usage TestShortWindowAfterLongWaitTellsNoSpeed (the reporter's numbers, a reasoned row from the ledger, the boundary, a second after a long wait, Totals) and internal/gateway TestShortWindowAfterLongWaitNotesNoPace. - GUI: usage-speed-every-row has the reporter's row (dash, and the tooltip in all five languages); routing-burst-speed has it (first token 8.2 s, no tok/s). - Updated to the new rule: TestVisibleReasoningSpeed's decode-minimum and max-speed cases (short wait now), TestCodexTurnMeasured...'s gateway/Claude rows, TestLiveVisibleReasoningFixture and TestUsageIngestTellsSpeed. Run on mote at this tree (rebased on |
||
|
|
d10f377657 |
providers: Names & levels is Names, prices & levels, where a model's own price at one provider is set (ferock4669)
ferock4669 asked on Discord whether magpie has a screen to price each model, since one model can cost differently on each provider. It has: each row in a provider's per-model list has a price box (input, output, cache read, cache write, 1h cache write, long-context tier, $ / 1M tokens), saved in settings' ModelPrices under pid/model. It wins over the list price in Usage (usage.Pricer through provider.BasePriceIn) and in a key's spend cap (usage.KeySpent through NewCoster). Nothing has to be built; the button opening it said only "Names & levels", so nobody finds a price there. What changed: - The button, its panel's heading and fold, and every note that sends the user there say "Names, prices & levels" (zh 名称、价格与推理档位, zh-TW 名稱、價格與推理檔位, ja 名前・価格・推論レベル, de "Namen, Preise & Stufen"); the gateway's vision and compaction notes, the provider package's text, the subsystem pages and the site's start docs (en, zh, ja) follow. - The button's tooltip says it sets what each model costs at this provider; Usage's "estimated" tooltip says where a provider's own price is set and that it counts over the list price. Both in en, zh, zh-TW, ja and de. - Not changed: the Codex model description text in internal/codexcat (it goes to Codex, so a vendor sees it) and core_budget_test's history comment. - app.js: a comment above the price box is shortened so the core script stays under its budget, not raised (app.js 116 bytes under origin/main). Run at the pushed head (rebased on origin/main |
||
|
|
c9824bb364 |
usage: each request's row says the credits its reply said
jiabubu (Discord, #feedback) saw a WorkBuddy request's credits shown before, and now nowhere. The gateway still keeps them: usage.Record.Credits from the chat usage's `credit` (#2512) reaches the ledger through the WorkBuddy plugin on every endpoint shape. The ranking, Overview, tiles and Sessions show them too. The Requests list's rows never did: a plan's model there reads "—" for a price, and its detail had no line for credits. Now the cost cell of a row whose reply said credits shows "N credits" (the same ledCredits words as the ranking) in place of the dash, or under the API price reference when the model also has a price. The expanded row has a Credits line. A reply that said none still shows "—". This applies to every credit-priced provider, since it reads the record's credits and not the provider. Tests: - internal/gateway/plugin_plan_credits_test.go: a moved workbuddy-ai plugin replies with WorkBuddy's credit usage. Chat, Messages and Responses, each streamed and whole, each land 0.01 credits in the ledger. - internal/gui/tests/plan-credits.test.cjs: a new test checks the row's cell, its title, a row with no credits, a priced row with credits and the detail, at 1400px and 420px. Run at this head (mote, via mote-run): - plan-credits.test.cjs: 36/36 in Chromium and WebKit, en, zh, zh-TW, ja, de, 1400px and 420px. - go test -run 'PlanCredits|TestCoreScriptBudget|I18n|Lang' over internal/gateway, gui, usage and usageapi: ok. - gofmt -l is clean. GOOS=linux and GOOS=windows go vet for gateway, gui and usage: ok. - The other Usage page files the change reaches, alone, fail the same on the base as with it: - usage-agents-hide: 22 (#3414, #2276). - usage-fold: 4 (#3415). - usage-ledger: 6, "newest live route needs no return-to-live button" (#4078, #3104). usage-curve-zoom-back passes alone. - Rebased from |
||
|
|
84da86ebd5 |
gui: Hide accounts is one switch for every page, window and the panel (paultian)
paultian on Discord (#feedback): Routing, Usage and Providers each kept their own "Hide accounts" state, so turning it on in one page left the others showing emails. Now window.hideAccounts is one switch, one localStorage value (magpie.maskEmails), behind #rtMask, #usageMask and #pvMask alike. Flipping it in any page applies to every page at once, and a storage event carries it to other windows and the tray panel. The old magpie.maskProviders value is folded in on first load (hidden if either value was on) and then removed, so nobody who hid accounts on one page sees them shown after updating. The tooltip and the Settings line now say "on every page" instead of "on this page", in every language. Tests: provider-mask.test.cjs checks that one switch hides accounts on every page and in a second window, that the state survives a reload, and that an old maskProviders=1 comes through as hidden. account-mask's expected tooltip text is updated. Run on mote (GUI files at base 05aba5ca4; the Go asset/budget tests again at this head after rebasing on |
||
|
|
cb7d7f9aa6 |
routing, usage: a request names who answered with the provider's logo (Jiabubu)
Jiabubu on Discord asked for the provider's icon before the answering provider or account in the request lists. Routing's Requests rows now draw icon(logoOf(member)) for the try's member (tried(r, tr)), the same logo the request's story uses, between the dot and the name, at 14px. A request nobody answered has no try and no logo. In Usage → Requests, the "Provider · account" cell holds the ledger's provider icon (l.providers) before .where-name, inside a new .where-line. A row read from a session file (source "log") names no provider for sure and gets none. .where-name's text is unchanged. No new strings, no new icons. Test: request-provider-icon.test.cjs. Routing has codex-color and deepseek-color, none on the failed row, a 14px logo before and level with the name. Usage has openai and zhipu-color, none on the log row, the name alone in .where-name, the logo inside the cell. Chromium and WebKit, en zh zh-TW ja de, at 1100 and 420px. Run at the pushed head on mote: see the head run below. Also routing-log-icons, routing-row-reuse, routing-live-patch, usage-ledger, usage-ledger-search, usage-ledger-fit, usage-ledger-agent-middle, session-identity, i18n-keys, phone-rows. Budget tests ok: app.js is untouched, and the plugin files are outside the script budget. Broken by hand: dropping the Routing logo makes 22 of 22 red; dropping the Usage logo makes the Usage checks red in every case. Not tried: the whole GUI suite (mote was busy with two other whole suites); the real Windows app. Head run (mote, 1e6a29337 on |
||
|
|
dcc84dbc04 |
usage: the Overview says each account's credits, and the period's (lcyksp)
lcyksp (Discord #feedback) asked to see the WorkBuddy credits (积分) the
calls spent, per account too, not only tokens. The summary already summed
each reply's usage.credit into every group's Totals, and the Requests
page's ranking showed it, but the Overview's Accounts, Models and Agents
rows and its tiles never said it. Each row's line now says "{n} credits"
when a reply said any, and the calls tile says the period's sum. No tile
is added, so the four-tile grid is as it was; the text was translated
already.
Run on mote:
- go test ./internal/usage ./internal/usageapi: ok. TestPlanCreditsByAccount
(new) checks each account's sum in the summary and the Requests page;
with Totals.count not adding credits it is red (summary a@x: 0 of 0).
- GUI, every usage*, i18n*, ledger and credits file (both engines):
1322 pass, 31 fail. plan-credits' new Overview test (5 languages, 420px)
is red with page.js as before ("WorkBuddy · 70 calls"). The reds are
usage-agents-hide (#2276, #3414), usage-fold "most on one screen"
(#4790) and usage-ledger's return-to-live (#3104, #4078, #4626). Run
alone at
|
||
|
|
5ec2375688 |
gateway: a call's HTTP headers both ways, masked, folded under its bodies
usrname1833 on Discord asked to see the raw request and response HTTP headers (查看原始请求和原始响应的http头), to debug as with a capture. magpie kept the client's request headers and its own response headers only in the request archive, and nothing of what went upstream. Now a call keeps its headers both ways (internal/gateway/wire_headers.go): - the client's, as they reached magpie: headerLogged in Handler() clones them for every request that isn't a GET, HEAD or OPTIONS; - each request magpie sent upstream for the call: method, address, headers, and the answer's status, protocol, headers and time, or the error. rpmTransport (under s.client) records it as it is sent; provider.SendsThroughPlugin records a plugin account's hand-off, shown as handed to the plugin, since the plugin's own request to its vendor is made in Bun and magpie doesn't see it (the view says so). The first 8 tries are kept, the rest counted. Recording copies each header map; nothing is masked or sorted as a request goes. Secrets are taken out when the headers are read (Call.Headers): by what each header is (new redact.SecretHeader, now behind redact.ScrubHeader: Authorization, cookies, x-api-key, api-key, any *-Key, *-Token, *-Secret, *-Auth, *-Signature, but Idempotency-Key and a count of tokens such as anthropic-ratelimit-tokens-remaining), any Bearer or Basic value, and redact.Scrub on the rest; an address loses its password, a secret-named query value (?key=) and its fragment. They live with the call in the 40-call ring; /api/gateway/call gives them as "headers". The request archive keeps the upstream ones as "upstream" beside the request's and response's headers, masked the same way. No body is stored that wasn't before. GUI: under a recent call's bodies on Gateway and a request's on Routing, "HTTP headers" folds open the client's headers, then each upstream request beside its answer (wireHeadersView, plugins/usage/page.js); the archive's copy shows its upstream requests too. Strings in all four languages. docs/subsystems/gui-shell.md describes it. Also changed by SecretHeader: the request archive no longer masks a rate-limit count header (…-tokens-remaining), which the old name rule took for a token. (provider.SecretHeader, which backups use, is another function and unchanged.) Tests: TestRecentCallHeadersBothWays (a fake vendor; the client's key and cookie, magpie's upstream key and the vendor's Set-Cookie all masked; status, protocol and response headers kept), TestRecentCallHeadersEachTry (a 429 then the next key, both kept in order), TestPluginHandOffHeaders, TestScrubURL, TestSecretHeaderRealNames (real header names both ways), TestArchiveOnThisComputer and TestRecentCallBodiesOnDemand extended, call-headers.test.cjs (Gateway, Routing and the archive's copy; chromium and webkit; en at 1100px, zh, zh-TW, ja, de at 380px and Routing at 440; nothing out of the box, no left-border accent). Run (on mote, macOS 27.2, through mote-run, unless named): - Full suite at ebd22b1b4 (the same change on |
||
|
|
1a864f156e |
usage: a hidden card a menu bar cell showed offers Show in Overview, not Hide again
Found while fixing yuu003348's report ( |
||
|
|
dee1afa400 |
usage: what is hidden from the Overview can be found again (yuu003348 on Discord)
yuu003348 on Discord: "观测/用量/概览 从概览中隐藏 后 无法取消隐藏". The way
back was there: a "{n} hidden" line under the cards (#quotaHid), each row with
Unhide, Show all from two. But it was drawn in --faint (#b9b9c2 on #f4f4f6,
1.77:1, 11.5px), so it couldn't be found; the Agents list's line (ikunbots on
X) is the same class.
- app.css: .us-hid .us-hidline is --muted (3:1 or more in light; ~5:1 in
dark by the tokens), for both lines.
- plugins/usage/page.js: while any are hidden, a card's menu and an Agents
row's menu end with "Show {n} Hidden". It opens the line under its list,
puts the keyboard on it and brings it into sight on the menu's click
(openHidden, scrollOnPurpose). hiddenQuotas() is the one count both the
line and the menu read.
- i18n: "Show {n} Hidden" in zh, zh-TW, ja, de.
- docs/subsystems/gui-shell.md says both.
- usage-cards-hide / usage-agents-hide now expect the new item when
something is hidden already.
Run (mote, node --test):
- usage-hidden-way-back.test.cjs (new): chromium and webkit, en/zh/zh-TW/ja/
de, 1200, 560 and 390 (touch long-press): 2 of 2 ok (32 cases).
- 130 Usage/menu/tray GUI files: the only reds the change made were
usage-cards-hide and usage-agents-hide's exact menu lists, now updated.
Every other red there is red at origin/main
|
||
|
|
2f4c088dce |
usage: Warm up on a Codex or Claude account's card whose 5 hours haven't started
01huadalang on Discord looked for a way to start one account's 5-hour
countdown on the Usage page, not in Settings. A Codex or Claude account
card whose 5-hour window isn't running now has a Warm up (预热) button on
its account line. It sends the request Settings › Warm-up's Warm up now
sends (POST /api/warm-now {agent, user}), to that account alone: for a
ChatGPT account the scheduled warm-up's one "hi" with the account's own
sign-in, on its cheapest model at low effort (warmModel); for a Claude
account Claude Code's own run on haiku (WarmClaudeVia), so magpie sends
nothing that imitates Claude Code. No new server code.
When it shows: the account is one magpie is signed in to (codexUsers /
claudeUsers), its read has no error, and its 5-hour window is idle as the
scheduled warm-up tells it (idle in codex_warmup.go): nothing used and the
reset a whole window away (within warmSlack), or the reset gone by. A
Claude account never used has no window read and shows it too, as
claudeWindowsExpected fills in; a Codex account with no 5-hour window
doesn't. While the request is out the button is disabled (busy), so a
second press sends nothing; once it went, the account's button stays away
for warmSlack (10 minutes), the time a just-started window still reads as
idle, and the quotas are read again (the server marks the account stale).
Refused, the vendor's reason goes in the status line and the button
comes back. Words in en, zh, zh-TW, ja, de (the tooltip is new; the
button and status lines reuse Warm up now's).
Run (at the head before the last rebase onto
|
||
|
|
947377307b |
usage: the Sessions tab's token totals count the cache, as the Overview's do (#2591)
n1majne3 reports the usage totals ignoring the cache reads the same page
shows beside them. The Overview's totals have counted the cache on request
since #2378 (magpie.usageWithCache); the Sessions tab counted tokens in and
out alone wherever they showed: the tokens tile, a session's row in both
lists (the Usage page's and the Sessions page's, sessSpent), the projects
and models bars and pickers (sessSums, spent), the day chart's bars,
tooltips and calendar, and the top sessions. A reader who asked for the
cache on the Overview saw two different totals for the same period.
The tab now reads usageTokens everywhere, so the one pick decides for both
pages. Its tokens tile carries the same label pop-up and says the cache's
count in its line; a pick made there refreshes the tab it is on, not the
Overview. The chart's day and week buckets carry the cache's counts now
that their value reads them, and the top sessions, ranked without the
cache, are ranked again by the count the reader sees. The default stays
without the cache, as #2378 left it; the per-session median and p90 stay
counted in and out (Stats.Overview ranks them), and the Requests tab's
totals always counted every token (allTokens).
Run at
|
||
|
|
9097687a31 |
gui: Hide accounts leaves the user's own account names and plans in sight (#3656)
With Hide accounts (账号打码) on, the name a user gave an account (#1515) was blurred like the account, so faketrader's several Antigravity accounts couldn't be told apart; and an Antigravity account whose value is "Google" blurred "Google" of its plan "Google AI Pro" on Usage and on the Providers row. The name the user gave an account is shown text, not an identity. The account is. - provider: a card's Alias says whether it is the user's own name (SubscriptionQuota.Named, set by withAccountNames from AccountNameOf), since Alias is also a plugin's name for an account (PluginUserOf, a masked phone, #4416) or a seat's key plan, and the Usage page and tray panel may have no /api/providers to tell them apart. labelProvider is AccountLabelOf's "plugin:" lookup, shared. - app.js names(): the user's own names (accountNames) and named aliases are no longer accounts to hide; accountUsers, an unnamed alias and a seat still are (noteAccounts keeps an alias without named). - app.js mask(): labels are scoped by element, never by value (LESSONS: scope an exemption by where the value sits). In .own-name, .plan, .acct-plan (the Providers row's plan pill, new class), .model-value and .subscription-head > b only an address is hidden; a plan's and a model's tooltip too (TIPS). The own name's tooltip ("name · account") is masked in full. - .own-name is set only where the text is the user's own: the editor's rename span when it has one (else it shows the raw account and stays hidden), Usage's quota-alias and the panel's pq-user when q.named. From skygunner's patch (95c0511 on |
||
|
|
457cfd7c63 |
usage: a phone's head is the tabs over one line of days, sum and refresh
The owner's pick of three phone designs (B): Usage's tabs run across the
head, and under them one line holds the days as a menu ("7 days ⌄", the
app's own menu, never a <select>), the sum, and the refresh as a dot and
its figure ("● 5s", green while live). The days strips (#period,
#sessRange, #ctxRange) are hidden behind the menu. It follows whichever
the open tab shows, and a pick clicks that strip's option, so each choice
keeps its one handler; Custom opens the range menu from the head. Each
control is drawn about 30px and tapped at 44. A desktop window keeps its
strips. The refresh keeps its own menu and
its reload icon, unlike the mock-up, which had neither.
usage-phone-head.test.cjs checks the layout, the menu and the taps in
every language and both engines at 390 and 320px, and a desktop
window at 1100px.
Run (mote, at this branch's head after the rebase onto
|
||
|
|
f7a80bc904 |
usage: a Model filter beside the Provider filter on Requests (OHHHHHH05 on X)
OHHHHHH05 asked for 按模型筛选 next to the provider filter, with requests,
input/output tokens, cache and estimated cost for the range, gateway and
session-log calls alike. Usage › Requests could already be narrowed to a
model, but only by clicking it in the chart's ranking or typing it in the
search box. Now it has its own filter, after Provider, in the app's menu
(sessPick/openSessCombo, no <select>). It lists the models the other
filters keep, by tokens (/api/usage/requests' by.model, which is counted
without the model's pick). Picking one sends model=, which the server
already applied to both sources, so the sum line (requests, in, out,
cache read/write), the cost head, the through/not-through-magpie cells,
the chart and the rows are all that model's. All models clears it. A
pick made in the ranking shows in the filter too. No API change, no new
strings ("All models", "Model", "{n} tokens" are already in every
locale), app.js untouched (the plugin's page.js only).
Run (at
|
||
|
|
c420559fdf |
usage: a search API's asks, and a plan's own searches, are rows of the request log (#3528)
cybercaius on Discord: "能记录代搜 API 的用量信息吗,在使用过程中看不到它用了哪些代搜 API". Nothing recorded which search API answered a search, how often, or whether it failed. Each ask of a search API (askSearchAPIKeys) and each search sent to Kimi Code's or WorkBuddy's own search service (ownSearch) is now a row of Usage › Requests, source "search" (usage.SourceSearch, kind web_search): the vendor or plan, the host asked, ok / found nothing / refused / the error, and the time. The row is a probe: it is listed, never counted in a total or a chart, and never exported. Telemetry reads no usage rows, so nothing is added to it. The query is not written: an error's text is scrubbed of it (url.Error reduced to op and host, and the plain, QueryEscape and PathEscape forms replaced). The Usage page badges the row "Search API", or "Web search" under a plan's provider, muted. Run (rebased on |
||
|
|
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 |
||
|
|
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
|
||
|
|
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
|
||
|
|
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
|
||
|
|
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 |
||
|
|
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 ( |
||
|
|
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 |
||
|
|
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
|
||
|
|
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
|
||
|
|
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. |
||
|
|
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
|
||
|
|
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
|
||
|
|
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.
|
||
|
|
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 |