Skip to content

Fix Usage & Spend scroll lag on long ranges - #3998

Closed
Yuxin-Qiao wants to merge 2 commits into
steipete:mainfrom
Yuxin-Qiao:fix/spend-ledger-scroll-perf
Closed

Yuxin-Qiao wants to merge 2 commits into
steipete:mainfrom
Yuxin-Qiao:fix/spend-ledger-scroll-perf

Conversation

@Yuxin-Qiao

@Yuxin-Qiao Yuxin-Qiao commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Scrolling Settings → Usage & Spend with the All range stutters badly. Sampling the running app (0.66.0) while scrolling showed where the time goes:

Range Main-thread samples NSWindow _resetDragMarginsIfNeeded
All 2699 1181 (~44%)
7d 1824 49 (~3%)

On every scroll frame AppKit rebuilds the window's titlebar drag region by unioning the opaque content paths of the hosted SwiftUI views (CGRegionCreateWithBoundsBlock → shape_union). The daily ledger renders one row per day, so All gives 365 rows. Its LazyVStack sits inside a horizontal ScrollView nested in the pane's vertical ScrollView, so it isn't lazy on the vertical axis and every row gets built. Each provider icon also had its own .help, which adds tracking areas (about 100 more samples went to cursorUpdate: forwarding).

Changes:

  • Daily ledger shows the newest 30 days by default, with the existing Show all (N) / Show less toggle (same pattern as the Projects list). I replaced the non-functional LazyVStack with a plain VStack.
  • Provider tooltip moves from one .help per icon to one .help per row, listing all active providers. Accessibility labels are unchanged.
  • DockIconController.ensureRegularPolicy runs on every NSWindow.didUpdateNotification, and it called NSApp.activationPolicy() each time. That call is a synchronous LaunchServices XPC round trip, and it showed up at 1–7% of main-thread samples while Settings was open. It's now skipped when the controller has already promoted the app to .regular.

Testing

  • Added long ledger ranges start collapsed to the newest days to SpendDashboardDailyLedgerTests.
  • swift test --filter SpendDashboardDailyLedgerTests: 17/17 passed.
  • make check: 0 files need formatting, 0 SwiftLint violations.
  • make test: all 128 groups (1407 selections) passed on the first run, with no retries.

Co-authored-by: Cursor <cursoragent@cursor.com>
@clawsweeper

clawsweeper Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

🦞👀
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 P2 Normal priority bug or improvement with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 25, 2026
@clawsweeper

clawsweeper Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Codex review: needs real behavior proof before merge. Reviewed September 25, 2026, 1:53 PM ET / 17:53 UTC (Revision 2).

ClawSweeper review

What this changes

The PR initially shows 30 recent daily spend rows with an option to expand them, combines provider tooltips per row, and avoids repeated Dock activation-policy queries during window updates.

Merge readiness

⛔ Blocked before merge - 2 items remain

The long-range ledger still renders every day on current main, and this focused PR addresses that path. No definite introduced bug emerged, but the reported scrolling improvement has no after-change observation from a built macOS app, so merge readiness remains blocked on real behavior proof.

Priority: P2
Reviewed head: 604318defcf70937e3294351c486282554cf8cd6

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The patch is focused and source-consistent, while its claimed native performance improvement still lacks after-change proof.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: The changed production owners are the macOS Settings ledger and Dock policy controller. The PR supplies before-change v0.66.0 samples and a focused test, but no after-change observation from a freshly built app showing smoother All-range scrolling, expansion, and normal Dock behavior. A redacted recording, terminal profile, or runtime log would address the gap; updating the PR body should trigger re-review, or a maintainer can comment @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The changed production owners are the macOS Settings ledger and Dock policy controller. The PR supplies before-change v0.66.0 samples and a focused test, but no after-change observation from a freshly built app showing smoother All-range scrolling, expansion, and normal Dock behavior. A redacted recording, terminal profile, or runtime log would address the gap; updating the PR body should trigger re-review, or a maintainer can comment @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 8 items Introduced ledger change: The PR limits initial rendering to the newest 30 summaries and offers the existing expansion control.
Current main: Current main still renders the full reversed daily-summary sequence in the ledger.
Daily-summary construction: The model constructs a row for each covered day, explaining why an All range can produce a long ledger.
Findings None None.
Security None None.

How this fits together

CodexBar turns provider usage into daily spend summaries in its Settings window. The ledger renders those summaries, while Settings window updates also drive Dock icon policy.

flowchart LR
A[Provider usage] --> B[Daily spend summaries]
B --> C[Selected history range]
C --> D[Ledger row limit]
D --> E[Settings window]
E --> F[Window updates]
F --> G[Dock policy]
Loading

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The changed production owners are the macOS Settings ledger and Dock policy controller. The PR supplies before-change v0.66.0 samples and a focused test, but no after-change observation from a freshly built app showing smoother All-range scrolling, expansion, and normal Dock behavior. A redacted recording, terminal profile, or runtime log would address the gap; updating the PR body should trigger re-review, or a maintainer can comment @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Complete next step (P2) - Provide redacted after-change proof from a freshly built macOS app showing the long-range scrolling improvement, Show all expansion, and normal Dock behavior.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Code and test delta production +33/−7 lines; tests +18 lines The production growth is bounded and supports the stated rendering change.

Technical review

Best possible solution:

Keep the short initial ledger and full-history control, then validate smoother All-range scrolling, expansion, and normal Dock behavior in a freshly built macOS app.

Do we have a high-confidence way to reproduce the issue?

No independent current-main runtime reproduction was run. Current source renders a row for every covered day, and the contributor supplies a specific v0.66.0 sampling scenario.

Is this the best way to solve the issue?

Yes, provisionally: the 30-row initial limit follows the existing Projects-list control and targets the reported rendering cost. A native after-change observation is needed to verify the improvement.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against d8c2af958176.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Long-range Settings scrolling is a user-facing performance problem with a limited affected surface.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The changed production owners are the macOS Settings ledger and Dock policy controller. The PR supplies before-change v0.66.0 samples and a focused test, but no after-change observation from a freshly built app showing smoother All-range scrolling, expansion, and normal Dock behavior. A redacted recording, terminal profile, or runtime log would address the gap; updating the PR body should trigger re-review, or a maintainer can comment @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

Likely related people:

  • Sahil Imtiaz: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • KGBos: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Add redacted after-change evidence from a freshly built macOS app showing All-range scrolling, the Show all control, and normal Dock behavior.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-09-25T17:00:35.065Z sha ca482d8 :: needs real behavior proof before merge. :: none

Co-authored-by: Cursor <cursoragent@cursor.com>
steipete added a commit that referenced this pull request Sep 25, 2026
Show the newest 30 daily rows initially and retain the complete ledger behind
Show all. Consolidate daily/hourly chart styling and per-row provider help
without changing source history, totals, chart scope, or exports.

Adopt the bounded-ledger portion of #3998 with expanded fixture coverage.
Retain the v0.65.0 default status-item width contract while investigating #3993.

Co-authored-by: Yuxin Qiao <104957188+Yuxin-Qiao@users.noreply.github.com>
@steipete

Copy link
Copy Markdown
Owner

Thanks @Yuxin-Qiao. The ledger portion landed on main via #4001 with your co-author credit and changelog thanks, and ships in the next release. On a synthetic 365-day fixture the warm initial layout went from 248.7 ms to 41.1 ms with totals unchanged ($365, 365,000 tokens, 365 requests): the ledger now shows the newest 30 rows first and Show all restores every row, and the daily and hourly charts share their presentation types. Your three-day regression fixture was replaced with explicit long-range coverage. The Dock-policy change was left out because nothing here measures LaunchServices or live scrolling; if you have a reproducible measurement for it, a separate PR is welcome.

pull Bot pushed a commit to ben-vargas/CodexBar that referenced this pull request Sep 25, 2026
Show the newest 30 daily ledger rows first with Show all/Show less, and let the daily and hourly charts share their presentation types, colors, legend, and currency axis, so a 365-day range lays out about six times faster with totals, models, export, and chart range unchanged. Adopts the ledger portion of steipete#3998.

Closes steipete#3998

Co-authored-by: Yuxin Qiao <104957188+Yuxin-Qiao@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants