perf(web): defer pull request line stats until visible - #6471
perf(web): defer pull request line stats until visible#6471Adamulek123 wants to merge 4 commits into
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ApprovabilityVerdict: Approved 1d318ee Performance optimization that defers pull request line stats fetching until rows are visible using IntersectionObserver. The change is self-contained with no behavioral changes - same data is fetched and displayed, just more efficiently. You can customize Macroscope's approvability policy. Learn more. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 9cc1a18. Configure here.

What Changed
Pull request line counts are now requested only as rows approach the viewport. A single list-owned observer groups newly visible rows into immutable per-environment batches, and completed batches stay cached without being resent as more rows appear.
Why
The list previously requested line stats for every loaded row, including off-screen priority groups. Those reads use expensive host search APIs and could issue work for hundreds of pull requests on a cold page. The bounded visibility batches preserve row rendering and cached counts while avoiding document-wide observation and ever-growing request keys.
UI Changes
No visual design change. Rows still render immediately and line counts appear when available; off-screen rows no longer trigger speculative host reads.
Validation
vp run --filter @t3tools/web typecheckgit diff --check origin/main...t3code/pr-visible-line-statsChecklist
Generated with GPT-5.6 in the Codex harness.
Note
Low Risk
Client-side performance optimization only; existing stats query and merge behavior are preserved with no auth or data-model changes.
Overview
Pull request diff line counts are no longer requested for every loaded row up front. The list now uses a shared
IntersectionObserver(480px root margin) so stats are fetched only as rows approach the viewport.PullRequestRowaccepts optionalstatsKeyandstatsRef; the row button carriesdata-pull-request-stats-keyand registers with the observer. On first intersection, the row is unobserved and deduplicated perfilterKey, then appended as an immutable per-environment batch tostatsTargetStateinstead of rebuilding targets from allgroupson every change.Cached counts still merge via
statsByRow/usePullRequestListStats; UI behavior is unchanged—rows render immediately and counts fill in when available.Reviewed by Cursor Bugbot for commit 1d318ee. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Defer pull request line stats queries until rows are visible in the viewport
IntersectionObserver(withrootMargin: 480px) in_chat.pull-requests.tsxtriggers stats fetches only as rows approach the viewport, batching requests per environment.PullRequestRowaccepts newstatsKeyandstatsRefprops to expose the button element for observation and key-based lookup.requestedStatsKeysref; rows are unobserved after first intersection.Macroscope summarized 1d318ee.