f2eb56c6bbde1300dddc402861b59cd4e45e0215
44
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
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 |
||
|
|
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
|
||
|
|
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
|
||
|
|
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 ( |
||
|
|
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
|
||
|
|
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
|
||
|
|
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); |
||
|
|
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
|
||
|
|
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 |
||
|
|
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 |
||
|
|
c30af359b4 |
usage: the line chart's lines are smooth curves, not straight segments (owner, after molvqingtai's reference)
The Requests chart's line mode ( |
||
|
|
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.
|
||
|
|
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 |
||
|
|
34ad18ed86 |
gui: a session's row helpers move from app.js to the Usage page's script (#3367)
TestCoreScriptBudget was red on main since |
||
|
|
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
|
||
|
|
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 |
||
|
|
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 |
||
|
|
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
|
||
|
|
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 (
|
||
|
|
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 |
||
|
|
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
|
||
|
|
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
|
||
|
|
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 |
||
|
|
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 |
||
|
|
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
|
||
|
|
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
|
||
|
|
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 (
|
||
|
|
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
|
||
|
|
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 |
||
|
|
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 (
|
||
|
|
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
|