Skip to content

fix(ui): Usage shows unknown totals and hides analytics when one response ends early - #176404

Merged
obviyus merged 3 commits into
mainfrom
fix/usage-lower-bound
Oct 18, 2026
Merged

obviyus merged 3 commits into
mainfrom
fix/usage-lower-bound

Conversation

@obviyus

@obviyus obviyus commented Oct 18, 2026 •

Copy link
Copy Markdown
Collaborator

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:

  • Totals show the known subtotal as a lower bound, such as "≥ 3.3B" tokens and "≥ $5,780.77" cost.
  • The chart, insights and activity sections stay visible, with a one-line note that explains the lower bound.
  • Usage with no known price reads "Unpriced" instead of "$0.00".

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):

  • Partial sums show "≥": daily chart labels and tooltips, the token/cost breakdown, cost windows, Started by, activity by time, and the heatmap.
  • Ratios built from partial counters show "—": tokens and cost per message, throughput, and cache-hit rate. A ratio of partial counters is not a lower bound.
  • Cost shares are hidden while the overall total is a lower bound, because a share of an incomplete total is unknown.

Evidence

Live, against a real gateway through an SSH tunnel; screenshots cropped to exclude session titles:

  • Before: "unknown" totals, and the analytics area replaced by the warning.
  • After: "≥" totals, the lower-bound note, and the chart and analytics visible.

Tests:

  • Usage unit tests: 184/184 pass.
  • Regression tests that fail on the previous head and pass now:
    • "hides cost shares while the overall total is a lower bound": a complete provider next to an incomplete total no longer shows "100.0% of cost".
    • The availability test asserts the "≥" breakdown total and the "—" cache-hit rate and average for a partial range, and exact values again once the selection is complete.
  • New regression test: "labels usage without a known price as unpriced, never free". It fails on main with $0.00 and passes here.
  • The availability tests now assert the lower-bound values, visible analytics, and that the note disappears once the selection is exact.
  • Usage E2E (11 files): 34/34 pass on 476afbe9049. An earlier run on a heavily loaded host had a harness cleanup failure in usage-sessions-owner-attribution, which this change does not touch; it passes alone and on this run.
  • pnpm ui:i18n:baseline and pnpm ui:i18n:verify pass. The new English keys need no baseline update.

Related: #176358 (Usage load path). The two PRs are independent.

Before: unknown totals, analytics hidden

After: lower-bound totals, analytics visible

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.
@clawsweeper

clawsweeper Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 18, 2026
@clawsweeper

clawsweeper Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This 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.

  • Before: Totals read “unknown” and the analytics area is hidden.
  • After: Totals read “≥ 3.3B” and “≥ $5780.77”, with an explanatory note and the daily chart visible.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Focused, useful presentation repair with directly inspected live visual evidence, meaningful regressions, and both earlier findings resolved; required CI is still running.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (screenshot): Inspected before/after screenshots from the real Gateway-backed Usage page show the changed totals, lower-bound note, and restored daily chart; rendered regression tests support the subsequent completeness propagation and exact-selection behavior.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: One interrupted response makes a busy range lose usable totals and analytics.
Reason: The collaborator-authored direction restores useful reporting while visibly distinguishing known subtotals from exact totals and unknown ratios.

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
Reviewed head: 476afbe9049cc0bd4017ec855cefb4f957cf220f

Before merge

None.

Findings

None.

Agent review details

How this fits together

The 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]
Loading

Technical review

Best 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

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +53, Tests +75. Total +128 across 12 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 10 101 48 +53
Tests 2 95 20 +75
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 12 196 68 +128

Review metrics

Metric Value Why it matters
Production versus tests Production +101/-48; tests +95/-20 Growth carries completeness through existing renderers and adds distinct rendered regressions without new runtime machinery.

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: A single interrupted response hides useful Usage analytics, but the problem is confined to reporting presentation.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-18T20:27:23.643Z sha 2fa5882 :: needs changes before merge. :: [P2] Carry completeness into the restored analytics labels | [P2] Check denominator completeness before showing cost shares

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.
@obviyus

obviyus commented Oct 18, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 18, 2026
@clawsweeper clawsweeper Bot removed clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 18, 2026
@obviyus
obviyus merged commit ea3aca8 into main Oct 18, 2026
120 checks passed
@obviyus
obviyus deleted the fix/usage-lower-bound branch October 18, 2026 22:47
@obviyus

obviyus commented Oct 18, 2026

Copy link
Copy Markdown
Collaborator Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 19, 2026
…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.
obviyus added a commit that referenced this pull request Oct 29, 2026
## 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]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 29, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant