Repository navigation
fix(ui): Usage shows unknown totals and hides analytics when one response ends early - #176404
Conversation
One interrupted response made the whole range read "unknown" and hid the chart and every analytics section. The known subtotal is a lower bound: totals now read "≥ value", the analytics stay visible with a note that explains the bound, and usage with no known price reads "Unpriced" instead of $0.00.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR displays interrupted usage as lower bounds, preserves analytics, hides indeterminate ratios, and labels unpriced attribution entries. Example: A range contains 917 sessions, recorded usage of 3.3B tokens and $5,780.77, and an interrupted response.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR remains useful: both prior findings are resolved, and no new actionable defect was found in the reviewed head. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe Control UI Usage page consumes Gateway usage totals, daily buckets, and completeness facts, then renders summaries, charts, attribution, and activity views. flowchart TD
A[Recorded session usage] --> B[Gateway usage aggregation]
B --> C[Totals and completeness facts]
C --> D[Usage page]
D --> E[Shared usage formatters]
E --> F[Summaries and analytics]
Technical reviewBest possible solution: Merge the focused presentation fix once existing required checks pass. Do we have a high-confidence way to reproduce the issue? Current-main source deterministically renders unknown totals and suppresses analytics when the aggregate completeness fact is unavailable; the supplied live before screenshot shows that outcome. Is this the best way to solve the issue? The patch reuses authoritative completeness and shared formatters, preserves exact selections, and suppresses indeterminate ratios; this is a focused fix using existing owners. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against cd28ccb53460. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +53, Tests +75. Total +128 across 12 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed October 18, 2026, 4:47 PM ET / 20:47 UTC (Revision 2). |
… unknown With analytics no longer hidden for interrupted ranges, partial sums in the daily chart, type breakdown, cost windows, Started by, activity and heatmap now carry the lower-bound marker. Ratios built from partial counters (per-message averages, throughput, cache hit rate) show as unknown, and cost shares are hidden while the overall total is a lower bound.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…onse ends early (openclaw#176404) * fix(ui): show Usage totals as lower bounds when a response ended early One interrupted response made the whole range read "unknown" and hid the chart and every analytics section. The known subtotal is a lower bound: totals now read "≥ value", the analytics stay visible with a note that explains the bound, and usage with no known price reads "Unpriced" instead of $0.00. * test(ui): give the unpriced provider fixture its message count * fix(ui): mark every restored Usage analytic as exact, lower bound, or unknown With analytics no longer hidden for interrupted ranges, partial sums in the daily chart, type breakdown, cost windows, Started by, activity and heatmap now carry the lower-bound marker. Ratios built from partial counters (per-message averages, throughput, cache hit rate) show as unknown, and cost shares are hidden while the overall total is a lower bound.
## What Problem This Solves The repo has no written rules for agents that work on model listing, provider plugins or usage/cost. So the same classes of bugs keep coming back across providers and on the Models and Usage pages. ## User Impact There is no user-visible change. Agents that work in these areas now get short rules from the scoped guide they already read. ## Why This Change Was Made Each rule records a lesson that came back 2 or more times in merged work. Each rule is one line, in the guide that owns the area: - **`src/plugins/AGENTS.md` "Model Listing":** - The hot path has no network request. - `models.list` has p99 under 300 ms. Rows and prices publish as one snapshot, and removals apply at once. - The authenticated listing decides which models show. - List with the credential and runtime that will execute the turn, with one row per model per provider. - Failed and empty listings each have defined semantics. - Capabilities come from the listing, not from model-ID rules. - One core admission rule. - **`extensions/AGENTS.md`:** - Host policy that every provider shares stays core. - Sign-in goes through the Models page and `/login`. Setup saves the connection only. - Native CLIs own their login and model menu. - Refusals are classified by cause. - Attribution headers come from one helper. - **`src/agents/AGENTS.md` "Run Authority":** - One model resolver for every entry path. - No silent fallback to another runtime or billing. - Native-runtime consent is asked once. - **`src/gateway/AGENTS.md` "Usage And Cost" (new section):** - Measured, unpriced, partial and unknown usage stay distinct. - Each route is priced from the provider that bills it. - Reports are complete or flagged as partial. - **`ui/AGENTS.md`:** - A route waits only for its first-paint data. - New "Layout Stability" section: zero layout shift, how to prove it, and a 200 ms load budget for Models and Usage. - **Root `AGENTS.md`:** one line in "Read when relevant" that points to these sections. Examples of the incidents behind the rules: #140139, #158000, #167444, #167658, #168033, #172608, #172773, #173792, #174641, #176404, #180838, #184066. ## Evidence - `pnpm check:agents-md-size`: all 27 files are within 20000 chars. - `oxfmt --check` passes on each of the 6 changed files. - I checked the cited names on current `main`: `buildLiveModelProviderConfig`, `readModelId` and `modelPricing.providers.<id>.priceAs`. Co-authored-by: Ayaan Zaidi <[email protected]>
…87141) ## What Problem This Solves The repo has no written rules for agents that work on model listing, provider plugins or usage/cost. So the same classes of bugs keep coming back across providers and on the Models and Usage pages. ## User Impact There is no user-visible change. Agents that work in these areas now get short rules from the scoped guide they already read. ## Why This Change Was Made Each rule records a lesson that came back 2 or more times in merged work. Each rule is one line, in the guide that owns the area: - **`src/plugins/AGENTS.md` "Model Listing":** - The hot path has no network request. - `models.list` has p99 under 300 ms. Rows and prices publish as one snapshot, and removals apply at once. - The authenticated listing decides which models show. - List with the credential and runtime that will execute the turn, with one row per model per provider. - Failed and empty listings each have defined semantics. - Capabilities come from the listing, not from model-ID rules. - One core admission rule. - **`extensions/AGENTS.md`:** - Host policy that every provider shares stays core. - Sign-in goes through the Models page and `/login`. Setup saves the connection only. - Native CLIs own their login and model menu. - Refusals are classified by cause. - Attribution headers come from one helper. - **`src/agents/AGENTS.md` "Run Authority":** - One model resolver for every entry path. - No silent fallback to another runtime or billing. - Native-runtime consent is asked once. - **`src/gateway/AGENTS.md` "Usage And Cost" (new section):** - Measured, unpriced, partial and unknown usage stay distinct. - Each route is priced from the provider that bills it. - Reports are complete or flagged as partial. - **`ui/AGENTS.md`:** - A route waits only for its first-paint data. - New "Layout Stability" section: zero layout shift, how to prove it, and a 200 ms load budget for Models and Usage. - **Root `AGENTS.md`:** one line in "Read when relevant" that points to these sections. Examples of the incidents behind the rules: openclaw#140139, openclaw#158000, openclaw#167444, openclaw#167658, openclaw#168033, openclaw#172608, openclaw#172773, openclaw#173792, openclaw#174641, openclaw#176404, openclaw#180838, openclaw#184066. ## Evidence - `pnpm check:agents-md-size`: all 27 files are within 20000 chars. - `oxfmt --check` passes on each of the 6 changed files. - I checked the cited names on current `main`: `buildLiveModelProviderConfig`, `readModelId` and `modelPricing.providers.<id>.priceAs`. Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
Fixes: when any one response in the selected range ends before its final usage arrives, the Usage page shows "unknown" for total tokens, total cost and the per-session average, and replaces the chart and every analytics section with a single warning. On a busy gateway that happens in almost every range, so the page shows no totals and no analytics.
User Impact
User impact:
Why This Change Was Made
An interrupted response still counts the tokens and cost it recorded before it stopped. So the true total is at least the recorded subtotal, and "≥" states exactly that. Exact totals are unchanged: selecting only complete sessions or days still shows plain numbers and no note.
Every restored value states what it is (from review):
Evidence
Live, against a real gateway through an SSH tunnel; screenshots cropped to exclude session titles:
Tests:
mainwith$0.00and passes here.476afbe9049. An earlier run on a heavily loaded host had a harness cleanup failure inusage-sessions-owner-attribution, which this change does not touch; it passes alone and on this run.pnpm ui:i18n:baselineandpnpm ui:i18n:verifypass. The new English keys need no baseline update.Related: #176358 (Usage load path). The two PRs are independent.