Skip to content

fix(ui): Usage page waits for provider plans before showing session totals - #176358

Merged
obviyus merged 3 commits into
mainfrom
fix/usage-load-path
Oct 18, 2026
Merged

obviyus merged 3 commits into
mainfrom
fix/usage-load-path

Conversation

@obviyus

@obviyus obviyus commented Oct 18, 2026 •

Copy link
Copy Markdown
Collaborator

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.status beside sessions.usage. Provider plans now load on the page after the route data applies. Retries for incomplete plans re-read only usage.status, never session usage. A plan read cut short by a disconnect resumes on reconnect.

  • Layout:

    • metric badges render with "—" until totals arrive;
    • filter pills render before their options;
    • the identity picker has a fixed width;
    • the session count moved to the end of the filter row;
    • narrow layouts use a fixed badge grid, so values never re-wrap the row.
  • Refresh ownership (from review):

    • Only the session read sets freshness. A provider result reuses the last session timestamp, so a failed sessions.usage stays stale and focus or reconnect still recovers it.
    • A provider retry that is deferred while session usage loads replays as a provider-only retry, not as a full reload that resets the retry budget.

Evidence

Live, against a real gateway over an SSH tunnel; dev build, navigating from /agents to /usage:

  • sessions.usage is sent at once, and usage.status only after the route data applies.
  • With a warm gateway, session rows render in 114–170 ms (sessions.usage ≈ 90 ms). Cold-cache visits are bound by gateway time.
  • Header layout shift, measured with a layout-shift PerformanceObserver:
    • before: 0.039 at 1280 px;
    • after: 0 in every run at 400, 700, 1280 and 1700 px.

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 unit tests: 196/196 pass.
  • New regression tests, which fail on the previous head and pass now:
    • 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-read sessions.usage.
    • refresh-policy.test.ts: deferred provider retries replay as poll, and a deferred broader refresh outranks them.
  • Usage E2E (11 files): 34/34 pass. One earlier run under very high host load had a harness cleanup failure in usage-sessions-owner-attribution; it passed alone and on the full re-run.

Screenshots: header only, dark mode, live data, before and after.

Before, 1280px: session count sits beside Filter

After, 1280px: session count at the end of the filter row

Before, 400px

After, 400px: fixed badge grid

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.
@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-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. 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-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 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.

  • Before: Session results wait for usage.status, and arriving metrics move the header controls.
  • After: Session results render independently, with placeholder badges occupying the fixed mobile grid.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Useful, focused repair with inspected visual evidence, reported live behavior, and both earlier findings resolved.
Proof confidence 🐚 platinum hermit (4/6) ✨ media proof bonus Sufficient (screenshot): The supplied real-Gateway navigation results exercise the separated session/provider loading path, and inspected desktop/mobile screenshots demonstrate the changed header layout; focused regressions cover both repaired refresh-policy findings.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Opening Usage waits on provider plans before displaying available session results, and arriving data moves header controls.
Reason: The maintainer-authored change removes an unnecessary loading dependency and addresses the associated layout movement without adding configuration or changing stored data.

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
Reviewed head: 74e3308dc31a051fbfca9364249c3330adeb63a9

Before merge

None.

Findings

None.

Agent review details

How this fits together

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

Technical review

Best 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

  • Provider usage in the route snapshot changes intended behavior with a stated reason (e9620fb: Represent incomplete provider reads explicitly and retain bounded recovery instead of silently presenting empty plans.)
  • Usage refresh and request lifecycle keeps the original intent (376ccd5: Scope Usage to its Solid owner while preserving synchronous request, cancellation, and recovery decisions.)
  • Header metrics, filters, and exports changes intended behavior with a stated reason (983ecf3: Simplify rendering while preserving existing controls, selection behavior, markup contracts, and lazy loading.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +81, Tests +46. Total +127 across 19 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 10 294 213 +81
Tests 9 103 57 +46
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 19 397 270 +127

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • 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: 🐚 platinum hermit, 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: Provider latency delays Usage results and causes header movement, with limited impact outside this page.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • 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-18T19:58:53.124Z sha cc7452e :: needs changes before merge. :: [P2] Preserve session freshness when provider plans finish | [P2] Keep deferred provider retries on the provider-only path

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.
@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-repro Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary 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. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 18, 2026
@obviyus
obviyus merged commit 18d0321 into main Oct 18, 2026
110 checks passed
@obviyus
obviyus deleted the fix/usage-load-path branch October 18, 2026 20:46
@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
…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.
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: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L 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