feat(web): display reported chat throughput tokens context and cost

This commit is contained in:
2026-10-21 00:27:12 +01:00
parent 910028a75c
commit 0b8595f16e
12 changed files with 314 additions and 12 deletions
+28
View File
@@ -8,6 +8,34 @@ test, or a code change without a capture, is `partial` at best.
Status legend: `todo` · `partial` (some of it works) · `done` (working + captured).
### Chat performance and usage (2026-10-21)
The chat header now shows reported output tokens/sec, total processed tokens,
last prompt/context usage and context-window limit, and reported USD cost.
Missing values are explicitly **Unavailable**; a genuine reported zero stays
zero. Native snapshots replace previous values, including duplicate/reconnect
updates and context reductions after compaction. Cumulative processed tokens are
never used as context size, output text is never used to estimate tokens, and
unreported subscription costs are not guessed from a pricing table.
Metrics-only updates patch the header rail without repainting the transcript or
composer, changing focus/selection, creating messages, or advancing a queued
prompt. Last reported values remain available when the turn settles.
`test/chat-usage-browser.mjs` captures known, missing, partial and zero-valued
snapshots at 390/420/1100px plus a 390px short viewport. It checks formatting,
no horizontal overflow, unchanged message count, no spurious Stop control,
duplicate-snapshot replacement and preserved composer/transcript DOM and cursor.
Captures: approved OpenCode temporary `chat-usage-captures/` directory. These
fixtures initiate no provider turns. Native adapters have separate regression
fixtures and retain/replay numeric snapshots without synthetic transcript items.
OpenCode V2 reports session counters/cost and model metadata; measured rates use
non-reasoning output and native request-to-stream timing (including request
latency, excluding tool execution). Codex reports token/context snapshots but
provides no compatible generation-rate or USD billing data, so those values
remain unavailable. Shell cache v12 refreshes the changed modules on reload.
### Context compaction activity (2026-10-20)
**Partial against the live-provider gate.** A native compaction frame shows