Skip to content

perf(web): defer pull request line stats until visible - #6471

Open
Adamulek123 wants to merge 4 commits into
pingdotgg:mainfrom
Adamulek123:t3code/pr-visible-line-stats
Open

perf(web): defer pull request line stats until visible#6471
Adamulek123 wants to merge 4 commits into
pingdotgg:mainfrom
Adamulek123:t3code/pr-visible-line-stats

Conversation

@Adamulek123

@Adamulek123 Adamulek123 commented Aug 13, 2026

Copy link
Copy Markdown

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 typecheck
  • git diff --check origin/main...t3code/pr-visible-line-stats

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • No visual UI change requires before/after screenshots
  • No animation or interaction change requires a video

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.

PullRequestRow accepts optional statsKey and statsRef; the row button carries data-pull-request-stats-key and registers with the observer. On first intersection, the row is unobserved and deduplicated per filterKey, then appended as an immutable per-environment batch to statsTargetState instead of rebuilding targets from all groups on 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

  • Previously, diff stats were fetched eagerly for all displayed pull request rows at once.
  • Now, a shared IntersectionObserver (with rootMargin: 480px) in _chat.pull-requests.tsx triggers stats fetches only as rows approach the viewport, batching requests per environment.
  • PullRequestRow accepts new statsKey and statsRef props to expose the button element for observation and key-based lookup.
  • Duplicate requests within the same filter key are suppressed via a requestedStatsKeys ref; rows are unobserved after first intersection.
  • Behavioral Change: stats queries now fire incrementally as the user scrolls rather than all at once on render.

Macroscope summarized 1d318ee.

@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 37fa9dd7-a3da-4642-a1ac-621d0e6b64d5

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

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.

❤️ Share

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

@github-actions github-actions Bot added the size:M 30-99 changed lines (additions + deletions). label Aug 13, 2026
Comment thread apps/web/src/routes/_chat.pull-requests.tsx Outdated
Comment thread apps/web/src/routes/_chat.pull-requests.tsx Outdated
Comment thread apps/web/src/routes/_chat.pull-requests.tsx Outdated
@macroscopeapp

macroscopeapp Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: 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.

@github-actions github-actions Bot added the vouch:unvouched PR author is not yet trusted in the VOUCHED list. label Aug 13, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ 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.

Comment thread apps/web/src/routes/_chat.pull-requests.tsx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant