Repository navigation
fix(ui): Usage page waits for provider plans before showing session totals - #176358
Conversation
The Usage route awaited usage.status beside sessions.usage, so every visit waited on the slowest provider API before showing any session data. Provider plans now load on the page after the route data applies; incomplete-plan retries never re-read session usage, and a disconnect that cuts a plan read short resumes it on reconnect. Keep the header layout fixed while data arrives: metric badges render with placeholders before totals, filter pills render before their options, the identity picker has a fixed width, the session count sits at the end of the filter row, and narrow layouts use a fixed badge grid.
|
🦞👀 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 loads session usage independently of provider plans and reserves header space while data arrives. Example: Open Usage at 400 px while provider plans are still loading.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this PR fixes a current Usage loading dependency, and both prior findings are resolved without new actionable defects. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe Control UI Usage route requests session aggregates from the Gateway; the page renders those results and separately requests provider plan limits through usage.status. flowchart TD
A[Usage navigation] --> B[Session route loader]
B --> C[Gateway sessions usage]
C --> D[Usage page]
D --> E[Provider plan loader]
E --> F[Gateway usage status]
F --> D
Technical reviewBest possible solution: Keep session reads independent while retaining the existing refresh policy, provider retry budget, and stable header layout. Do we have a high-confidence way to reproduce the issue? Current main's Promise.all directly establishes that a pending usage.status response delays the session snapshot; no target code was executed during this review. Is this the best way to solve the issue? The separation fixes the dependency at the page boundary, removes provider results from route data, and preserves the existing request and refresh owners. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against a9978015ab6e. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +81, Tests +46. Total +127 across 19 files. Added test files: 0. View PR surface stats
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:11 PM ET / 20:11 UTC (Revision 2). |
A provider plan result no longer marks a failed or stale session read fresh, so focus and reconnect still recover session usage. A provider retry deferred while session usage loads replays as a provider-only retry instead of a full reload that resets the retry budget.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…otals (openclaw#176358) * fix(ui): load Usage session totals without waiting for provider plans The Usage route awaited usage.status beside sessions.usage, so every visit waited on the slowest provider API before showing any session data. Provider plans now load on the page after the route data applies; incomplete-plan retries never re-read session usage, and a disconnect that cuts a plan read short resumes it on reconnect. Keep the header layout fixed while data arrives: metric badges render with placeholders before totals, filter pills render before their options, the identity picker has a fixed width, the session count sits at the end of the filter row, and narrow layouts use a fixed badge grid. * test(ui): drop provider plans from Usage route data in source replacement test * fix(ui): keep Usage session freshness owned by the session read A provider plan result no longer marks a failed or stale session read fresh, so focus and reconnect still recover session usage. A provider retry deferred while session usage loads replays as a provider-only retry instead of a full reload that resets the retry budget.
What Problem This Solves
Fixes: the Usage page shows nothing until every provider plan API has answered. The header also jumps as data arrives: badges, filter pills, the identity picker and the session count appear late and push the controls around.
User Impact
User impact: session totals, the chart and the session list appear as soon as session usage is ready, and provider plans fill in afterwards. The header keeps its layout while it loads. No visual redesign.
Why This Change Was Made
Load path: the route loader awaited
usage.statusbesidesessions.usage. Provider plans now load on the page after the route data applies. Retries for incomplete plans re-read onlyusage.status, never session usage. A plan read cut short by a disconnect resumes on reconnect.Layout:
Refresh ownership (from review):
sessions.usagestays stale and focus or reconnect still recovers it.Evidence
Live, against a real gateway over an SSH tunnel; dev build, navigating from /agents to /usage:
sessions.usageis sent at once, andusage.statusonly after the route data applies.sessions.usage≈ 90 ms). Cold-cache visits are bound by gateway time.layout-shiftPerformanceObserver:Known gap: one cold-cache run at 400 px still recorded a 0.010 shift below the header. It comes from the existing body content swap and is outside this change.
Tests:
usage-page.test.ts: "keeps a failed session read stale after provider plans load". It mounts the page with a failed route session read and a successful provider read; focus must re-readsessions.usage.refresh-policy.test.ts: deferred provider retries replay aspoll, and a deferred broader refresh outranks them.usage-sessions-owner-attribution; it passed alone and on the full re-run.Screenshots: header only, dark mode, live data, before and after.