d3a2369d1f
Timeline stage rows add the cached share (when cache_known) and a positive cost: 20.1M tokens · 97% cached · $1.42. The file viewer words each server no_patch_reason, keeping the old truncated/binary text as the fallback.
2.9 KiB
2.9 KiB
Run token usage beside size
Runs that spend 20M+ tokens now show it the way they show disk size.
Server (payload)
RunSummary.usage(protocol.RunUsage) moved up fromRunDetail, solist_runsrows carry the run total too.get_runstill sendsusageat the same JSON key, now through the embedded summary.- The list fills it with one grouped
step_usageaggregate per 100-run batch (internal/pipeline/run_usage.go), using the same column sums as the history-wide stats (usageSumColumnsinstats.go). It is joined torun_steps, so orphaned usage rows (reported: about 650 rows, 1.47B tokens, left by an Oct 19 history wipe) no longer count in stats or per-run totals. The rows are not deleted. If a wiped run id was reused, an orphan row that matches a new run's (run_id, sequence) still cannot be told apart. StageUsagenow keepstokens_reasoning,cache_readandcache_writewithcache_known(the runner dropped them before). They are JSON keys inusage_json, so old rows need no migration: they lackcache_known, so their cache share is unknown, not zero. Run totals addcache_known_stagesandcache_known(every token-reporting stage recorded the split).
App
lib/features/runs/domain/run_tokens.dart: parsing and formatting.22.4M tokens,≥9.1M tokenswhentokens_known_stages < stages. Nothing is estimated, and a row withoutusage(an older server) shows nothing.- List row: tokens after the size, in both the full and the compact subtitle.
- Sort:
Most tokens(most_tokens) afterLargest first, flat like it. Runs without a reported total sort last. - Summary:
Size on disk,Tokens(22.4M · 2.1M fresh, 20.3M cached · 1.8M in, 240K out; fresh is total minus cache reads, shown only whencache_known) andCost. - Stage rows: the Timeline row subtitle adds
· 20.1M tokens · 97% cached · $1.42(stageTokenRowLabel). The cached share (cache reads over the total, rounded) appears only when the stage recordedcache_known; the cost only when positive, to two places,<$0.01below half a cent. The visit facts addTokensandCost(Not reportedstays there). - Cost is shown only when a positive
cost_usdwas reported. Subscription models reportcost_knownwith no amount, which shows asNot reported. The stats page'sReported costuses the same rule. usageis no longer treated as detail-only inRunsController.acceptRunDetail, so opening a run refreshes its row's total.
Evidence
Fixture: tool/probe_usage_fixture.dart, opt-in ?usage=1 on the capture
entry (run 7: 340 MB, 22.4M tokens, mostly cached, $1.42; run 6: partial
≥9.1M). Captures were taken with tool/capture at 560x1000 and 1400x900:
the list, the sort sheet, Most tokens, the run 7 Summary and Timeline, the
build and plan visits, and the no-usage (old-server) list and Summary.