Skip to content

fix(usage): Cursor account history loads about 4x faster - #17140

Merged
t3dotgg merged 1 commit into
mainfrom
t3/cursor-usage-parallel-pages
Oct 8, 2026
Merged

t3dotgg merged 1 commit into
mainfrom
t3/cursor-usage-parallel-pages

Conversation

@t3dotgg

@t3dotgg t3dotgg commented Oct 8, 2026

Copy link
Copy Markdown
Member

Usage waits for every source before it shows anything. On a busy Cursor account, the Cursor history reader was nearly all of that wait: it asked for one 1,000-event page at a time, and each page takes about a second. A 30-day window with 36k events took about 46 s, close to the reader's 60 s deadline.

The reader now keeps up to six pages requested ahead of the one it reads. It still reads pages in order, so the count check, overlap reconciliation, end-of-history rule and "Sign in to Cursor again" result do not change. When the read ends, it cancels the requests still in flight. Krishna measured 45.9 s → 9.6 s on a real account with identical records.

This continues #14384 by @im-kvijay, whose commit is imported unchanged with its authorship. I could not update that PR's branch from here, so this PR carries it onto current main.

Proof: the new ordering test fails against main's reader and passes with this change. Lint, server typecheck and the 144 usage tests pass on current main.

Takeover and verification by Claude Opus 5.5 in Claude Code. Original change by @im-kvijay with Claude Opus 5.5 in 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:S 10-29 changed lines (additions + deletions). label Oct 8, 2026
@macroscopeapp

macroscopeapp Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at ddf404e

Macroscope's review found this PR approvable — This is a narrowly scoped performance improvement to Cursor history retrieval, with bounded concurrency, ordered consumption, cancellation, and tests covering the key runtime cases. Existing usage output and caller behavior remain unchanged.

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

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

@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: 10e29a2 · PR result: 23d29e2 · 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.

@coderabbitai

coderabbitai Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

⚙️ Run configuration
  • Configuration used: Path: .coderabbit.config.ts
  • Review profile: CHILL
  • Plan: Team
  • Run ID: 042808d8-ad22-4899-abf8-31c6f21e7f6a
📥 Commits

Reviewing files that changed from the base of the PR and between ddf404e and 23d29e2.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Path: .coderabbit.config.ts
  • Review profile: CHILL
  • Plan: Team
  • Run ID: f2abd08d-d950-402a-a5fd-07e7744b88f3
📥 Commits

Reviewing files that changed from the base of the PR and between 2ea7684 and ddf404e.

📒 Files selected for processing (2)
  • apps/server/src/usage/cursorUsageReader.test.ts
  • apps/server/src/usage/cursorUsageReader.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.


📝 Walkthrough

Walkthrough

readCursorAccountUsage now fetches up to six usage pages concurrently and consumes their results in page order. It aborts outstanding requests when reading exits. New tests cover request concurrency, record ordering, and failures from later pages.

Changes

Cursor usage pagination

Layer / File(s) Summary
Concurrent page reads and cancellation
apps/server/src/usage/cursorUsageReader.ts, apps/server/src/usage/cursorUsageReader.test.ts
The reader queues up to six page requests and consumes responses in page order. A shared abort signal cancels outstanding requests when reading exits. Tests check concurrency, ordered records, and later-page network and authorization failures.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Refactor

Sequence Diagram(s)

sequenceDiagram
  participant Reader as readCursorAccountUsage
  participant Requests as Cursor page requests
  participant Controller as AbortController
  Reader->>Requests: Start up to six page reads
  Requests-->>Reader: Return page results
  Reader->>Reader: Consume results in page order
  Reader->>Controller: Abort shared signal on exit
  Controller-->>Requests: Cancel outstanding requests
Loading

Suggested reviewers: juliusmarminge

Merge Risk: ⚪ Minimal · up to ddf40

The concurrent history reader preserves page order and the existing end-of-history behavior. No merge-blocking issue was established.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: faster Cursor account history loading through usage improvements.
Description check ✅ Passed The description covers the problem, implementation, scope context, measured performance improvement, verification results, and agent attribution. It provides a linked related pull request but does not…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ 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.

The reader requested one page of account events at a time. Cursor caps a
page at 1,000 events and takes about a second to answer one, so a busy
account spent most of a minute here before Usage could show anything.

Keep up to six pages requested ahead of the one being consumed. Pages are
still consumed in page order, so the read ends as it did before, and any
request still in flight is cancelled when it does.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@t3dotgg
t3dotgg force-pushed the t3/cursor-usage-parallel-pages branch from ddf404e to 23d29e2 Compare October 8, 2026 09:22
@t3dotgg
t3dotgg merged commit 9381533 into main Oct 8, 2026
30 checks passed
@t3dotgg
t3dotgg deleted the t3/cursor-usage-parallel-pages branch October 8, 2026 09:26
t3dotgg added a commit that referenced this pull request Oct 8, 2026
- 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>
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:S 10-29 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