Skip to content

perf(usage): the Usage page shows numbers in under a second and dims only what is still loading - #17147

Merged
t3dotgg merged 4 commits into
mainfrom
t3/usage-loading-state
Oct 8, 2026
Merged

t3dotgg merged 4 commits into
mainfrom
t3/usage-loading-state

Conversation

@t3dotgg

@t3dotgg t3dotgg commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

The Usage page waited on every source before it showed anything. Cursor's account API alone took 19–32s, and the only sign of loading was a tiny spinner, so it was hard to tell the numbers were stale.

Takeover of #16376 by @bmdavis419, rebased onto current main. His work is imported as one commit with his authorship. My fixes are in a separate commit.

What it does (from #16376)

  • Cursor account records are cached per login for 90+ days. The server answers from that cache right away and marks Cursor refreshing. The client then sends one follow-up with awaitRefresh to get the fresh Cursor numbers. Older servers ignore the flag.
  • Transcript, OpenCode, Antigravity and Cursor sources scan at the same time. The scan cache is written after the response.
  • Only the figures still loading are dimmed: a provider's row, its models, and the totals. Switching period keeps the previous period on screen, dimmed, until the new one answers.
  • Shared loading rules live in client-runtime. Mobile gets the server speedups and keeps its current loading state.

Revisits drop from ~19s to 60–80ms. After a server restart, the page answers in ~120ms from the Cursor cache.

What I changed

Screenshots (from #16376)

Before: a small spinner after "All environments" was the only sign of loading.

before

Cursor still loading: only Cursor's row and models, plus the totals, are dimmed.

partway

Every figure updating, e.g. while a new period loads:

refreshing

Verification

Usage tests (248) pass. Typecheck passes in server, web, mobile, client-runtime and contracts. I did not run the app in a browser for this rebase.

Original work by @bmdavis419 with Claude Opus 5.5 in T3 Code via Claude Code. Takeover by Claude Opus 5.5 in T3 Code via Claude Code.

🤖 Generated with Claude Code

@github-actions github-actions Bot added the vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. label Oct 8, 2026
@juliusmarminge juliusmarminge added the macroscope-review Opt PRs made by unvouched contributors in for Macroscope review. Vouched contributors auto-reviews label Oct 8, 2026
@github-actions github-actions Bot added the size:XXL 1,000+ changed lines (additions + deletions). label Oct 8, 2026
Comment thread apps/web/src/state/usage.ts Outdated
Comment thread apps/server/src/usage/UsageService.ts
Comment thread apps/web/src/components/usage/UsagePage.tsx
@macroscopeapp

macroscopeapp Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Not approved

Macroscope's review found this PR not approvable — This is a large production behavior change introducing persistent Cursor account caching, background refresh coordination, concurrent scanning, shared query-runtime changes, and new stale/provisional Usage-page rendering. Its broad runtime and data-persistence impact goes beyond a self-contained performance fix and warrants human review.

Notes:

  • No code objects were reviewed. Approvability was decided on eligibility alone.

No code changes detected at 23a4c36. Prior analysis still applies.

You can add or adjust custom eligibility rules. Learn more.

@coderabbitai

coderabbitai Bot commented Oct 8, 2026

Copy link
Copy Markdown

Review in Change Stack →

✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Codex Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Codex Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Codex Live turn WebSocket decoded 20.9 KiB 20.9 KiB 0 B (0.0%) 29.3 KiB ✅
Codex Live turn messages 2 2 0 (0.0%) 8 ✅
Claude Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Claude Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Claude Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Claude Live turn WebSocket decoded 21.2 KiB 21.2 KiB 0 B (0.0%) 29.3 KiB ✅
Claude Live turn messages 2 2 0 (0.0%) 8 ✅

Baseline: 0ce6b9d · PR result: 23a4c36 · Source CI: success

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 108.5 KiB
  • Claude decoded thread snapshot: 108.8 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

bmdavis419 and others added 4 commits October 8, 2026 02:42
…only what is still updating

Imported from #16376 (5 commits squashed onto current main):
- perf(usage): the usage page loads in a fraction of a second and dims only what is still updating
- refactor(usage): simpler loading states and Cursor cache
- fix(usage): cache writes finish before the usage service shuts down
- fix(usage): address review findings
- fix(web): a window that fails everywhere keeps the last usage on screen

Conflicts with main resolved: Antigravity scan cache (#17139) and the
Usage provider filter (#16970).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- Cursor paging goes back to main's ordered reader. The parallel
  `mapBounded` pager kept assigning pages after a failure; #17140 owns
  that speedup with a smaller reader change. The `CursorAccountReader`
  service stays.
- Hidden providers no longer add a refreshing row or mute the totals.
- The period label names the period on screen while the previous one
  is kept.
- The kept-window test now switches windows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@t3dotgg
t3dotgg force-pushed the t3/usage-loading-state branch from dd79348 to 23a4c36 Compare October 8, 2026 09:42
@t3dotgg
t3dotgg merged commit 8597558 into main Oct 8, 2026
29 of 31 checks passed
@t3dotgg
t3dotgg deleted the t3/usage-loading-state branch October 8, 2026 09:48
github-actions Bot added a commit to omarcresp/t3code-flake that referenced this pull request Oct 8, 2026
## What's Changed
* feat(providers): run Muse Code as a native provider by @t3dotgg in pingdotgg/t3code#17082
* feat(web): compact-before-send is a chip that shows the token count by @t3dotgg in pingdotgg/t3code#17127
* fix(clients): copy button is back in its old spot, before fork by @t3dotgg in pingdotgg/t3code#17137
* fix(usage): repeat usage scans no longer decode unchanged Antigravity databases by @t3dotgg in pingdotgg/t3code#17139
* fix(server): shell snapshots no longer block other database reads while decoding by @t3dotgg in pingdotgg/t3code#17141
* perf(server): ACP tool updates no longer persist a snapshot per streamed chunk by @darjss in pingdotgg/t3code#16682
* feat(web): filter the Usage page to just the providers you want by @t3dotgg in pingdotgg/t3code#16970
* fix(usage): Cursor account history loads about 4x faster by @t3dotgg in pingdotgg/t3code#17140
* fix(server): threads settle as soon as branch status sees their PR merge by @t3dotgg in pingdotgg/t3code#17148
* perf(usage): the Usage page shows numbers in under a second and dims only what is still loading by @t3dotgg in pingdotgg/t3code#17147
* fix(server): an agent can settle its own thread when its turn ends by @t3dotgg in pingdotgg/t3code#17145
* feat(web): Add provider button sits with the provider list by @t3dotgg in pingdotgg/t3code#17152

## New Contributors
* @darjss made their first contribution in pingdotgg/t3code#16682

**Full Changelog**: pingdotgg/t3code@v0.0.46-nightly.20261008.2813...v0.0.46-nightly.20261008.2819

Upstream release: https://github.com/pingdotgg/t3code/releases/tag/v0.0.46-nightly.20261008.2819
github-actions Bot added a commit to davidvanderklay/t3code-flake that referenced this pull request Oct 8, 2026
## What's Changed
* feat(providers): run Muse Code as a native provider by @t3dotgg in pingdotgg/t3code#17082
* feat(web): compact-before-send is a chip that shows the token count by @t3dotgg in pingdotgg/t3code#17127
* fix(clients): copy button is back in its old spot, before fork by @t3dotgg in pingdotgg/t3code#17137
* fix(usage): repeat usage scans no longer decode unchanged Antigravity databases by @t3dotgg in pingdotgg/t3code#17139
* fix(server): shell snapshots no longer block other database reads while decoding by @t3dotgg in pingdotgg/t3code#17141
* perf(server): ACP tool updates no longer persist a snapshot per streamed chunk by @darjss in pingdotgg/t3code#16682
* feat(web): filter the Usage page to just the providers you want by @t3dotgg in pingdotgg/t3code#16970
* fix(usage): Cursor account history loads about 4x faster by @t3dotgg in pingdotgg/t3code#17140
* fix(server): threads settle as soon as branch status sees their PR merge by @t3dotgg in pingdotgg/t3code#17148
* perf(usage): the Usage page shows numbers in under a second and dims only what is still loading by @t3dotgg in pingdotgg/t3code#17147
* fix(server): an agent can settle its own thread when its turn ends by @t3dotgg in pingdotgg/t3code#17145
* feat(web): Add provider button sits with the provider list by @t3dotgg in pingdotgg/t3code#17152

## New Contributors
* @darjss made their first contribution in pingdotgg/t3code#16682

**Full Changelog**: pingdotgg/t3code@v0.0.46-nightly.20261008.2813...v0.0.46-nightly.20261008.2819

Upstream release: https://github.com/pingdotgg/t3code/releases/tag/v0.0.46-nightly.20261008.2819
saphid pushed a commit to saphid/t3code that referenced this pull request Oct 9, 2026
Brings in Theo's Usage work: progressive loading with a Cursor cache and the
awaitRefresh follow-up (pingdotgg#17147), the provider filter (pingdotgg#16970), faster Cursor
paging (pingdotgg#17140) and the Antigravity scan cache (pingdotgg#17139).

Resolution:
- Contract keeps both groupByThread and awaitRefresh.
- Server: upstream's parallel source scans; transcript scans still carry the
  account, each session's folder and sub-agent labels; attribution runs
  alongside the scans.
- Web: statuses carry upstream's isConnected next to the offline fields; the
  provider filter applies before saved usage is trimmed; the page keeps the
  previous period on screen while a new one loads, and the explorer mutes its
  totals, chart, by-type section and list while figures are still coming in,
  and each provider row while that provider refreshes.

Also fixes a Macroscope finding: a resumed Claude scan no longer replaces a
session's original folder with one from later records, which could move it
to another project.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

macroscope-review Opt PRs made by unvouched contributors in for Macroscope review. Vouched contributors auto-reviews size:XXL 1,000+ changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants