Commit Graph
6 Commits
Author SHA1 Message Date
yetone 542ee03b4c usage: each request says its cache hit rate, as the Routing page's do
teenux (Discord, #feedback) saw a cache hit rate on each request in the
Routing page's list but none on the Usage page's Requests tab. Each
Usage request now has a Cache hit rate column after Cache read, worked
out as Routing's request list does (promptOf in routing/client.js): the
tokens read from the cache over the whole prompt, uncached input plus
cache reads and writes, through app.js's cacheHitOf. It is said as
Routing says it, a whole percent ("90%"), with Routing's tooltip ("Cache
hit rate: The share of the prompt read from the cache"). A vendor that
counts no cache (cache_unknown, #3464) reads "—" with "The vendor
doesn't count the cache"; a request with no prompt counted reads "—"; a
miss reads 0%. The row's own fields only: nothing new is fetched.

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

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

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

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

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

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

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

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

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

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

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

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

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

Reported-by: unscientific9
2026-11-06 11:46:25 +08:00
yetone ce8b67de37 gui tests: a page's first load gets a minute, not a click's 5s (#4470)
claude-switch-only set page.setDefaultTimeout(5000) and then called
page.goto with no timeout of its own, so Playwright held the first load
of app.js, i18n.js and the plugins to the 5s bar meant for clicks. On a
busy box (a whole-suite run at load 130-160) that load took longer and
goto timed out. The same pattern is in 988 GUI test files (1174 pages):
every one of them now also sets setDefaultNavigationTimeout(60000) on
the same page, right after its default, so goto, reload and waitForURL
wait on the load itself with room, while clicks and waits keep their
short bar. group-from-model-add's own 20s navigation bar is raised to the
same minute. claude-switch-only also gives its first provider row (drawn
from the page's first reads) a minute before clicking it.

nav-timeout.test.cjs (no browser) reads every GUI test file and names
each page given a default under a minute without a navigation timeout of
at least a minute, so a new file can't bring the pattern back.

What was run (WSL magpie-desktop, Playwright 1.62.0, load 70-260 from
other sessions):
- node --check on every file in internal/gui/tests: all parse.
- nav-timeout.test.cjs against origin/main's test files: red (names the
  1174 pages); against this tree: its only reds were my own probe copies
  of the old files, since removed.
- By hand: claude-switch-only with app.js served 7s late (a busy box's
  first load), --test-name-pattern "1100 en": origin/main's file 4 of 4
  red with "page.goto: Timeout 5000ms exceeded"; this file 4 of 4 green.
- claude-switch-only.test.cjs, both engines, en/zh/ja/de, 1100 and 420:
  32 of 32. group-from-model-add, usage-access-key-card and i18n-keys:
  green. agent-plugin-agents: Chromium green; WebKit's de 420 subtest red
  on a 5s waitForFunction at line 115 (a wait after load, not the
  navigation), at load ~230.

Not tried: the whole GUI suite (about 1000 files; the change is one
mechanical line per page), Windows or mote (mote's browsers, #4125).
2026-10-31 02:09:18 +08:00
yetone 8c68b6802a gui: time to first token reads 首字耗时 in Chinese, not 首响 (Outvi V)
Outvi V on Discord: "首响 2.7 秒" makes a reader stop and decode it.
The rest of the GUI already says 首字 for the first token (首字平均,
厂商首字等待, 没有首字时间), so 首响 was the odd one out. The label
(First token, TTFT) now reads 首字耗时 / 首字耗時 beside 耗时, the
Routing step reads "{ms} 后出首字", and the other mentions say 首字. zh
and zh-TW both; ja, de and en are unchanged.

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

Run at origin/main 3a213e1dc plus this change: routing-request-metrics,
routing-burst-speed, routing-columns, usage-ledger, usage-ledger-detail,
usage-ledger-ttft, usage-speed and i18n-keys in chromium and webkit:
67 pass, 6 fail. All 6 are usage-ledger's "newest live route needs no
return-to-live button" (en and zh, both engines), which fails the same
way at 3a213e1dc without this change (#3104).
2026-10-22 21:51:29 +08:00
yetone dc1a9cde27 gui: Usage → Requests lists the first token's time in a column of its own (#2522)
tianxia3111 asked to compare time to first token down the request list
(首字时间). Until now it showed only inside a row's details and the
Duration tooltip. A "TTFT" column (zh 首响, zh-TW 首響, the word the
row details and Routing already use) now sits before Duration. Its
header tooltip reads "Time to first token". A row told from a session
file's times gets "≈", like Duration does. A row with none (not
streamed, or failed before a token) shows a faint dash, not 0 ms.

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

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

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

Run on origin/main d9b943555 (head 663db0ecf), with the #2517,
#2521 and #2522 changes, load ~240:
- gofmt -l clean; go vet -tags nogui for darwin, linux and windows: ok.
- go test -timeout 120m -count=1 ./... (pipefail): exit 0, every package
  ok (gateway 1416.8s, agent 1535.5s). Before the rebase, on 63be47717:
  - The 45m run had agent and gateway past 45m (#2544, #2108).
  - TestMainWindowCorners was killed at its deadline (#1936).
  - TestSkillRelinkKeepsUnreadableCopy failed (#2555; it passes alone).
  - gateway alone with 120m was ok.
- GUI, the 41 Requests/Usage files in serial, both engines, before the
  rebase: 493 pass, 3 fail. The 3 were usage-refresh "not yet 2 !== 1",
  the same on 63be47717 alone (1 of 3); seen again on #2184.
- Rebased, these all pass, 102/102: i18n-keys, usage-ledger-ttft,
  usage-ledger-key-split, usage-ledger, usage-speed, usage-ledger-detail,
  gui-ja, gui-de and gui-zh-tw.
- Rebased again onto 9b04c4e20, which touches ledger.go, request_page.go
  and gateway.go:
  - vet ×3: ok.
  - internal/usage, internal/usageapi and internal/cli: ok.
  - internal/gateway -run 'NativeCompaction|UsageOverGateway|Capped|Cap':
    ok.
  - usage-ledger-ttft, usage-ledger-key-split, usage-ledger and
    usage-speed: 86 pass. i18n-keys was red from main's own words (#2586,
    fixed in the next commit).
2026-10-16 21:59:33 +08:00