From 3c73fa7ce02b7ee6b2904ec58e47c06262aebf5d Mon Sep 17 00:00:00 2001 From: Adamulek123 Date: Tue, 1 Sep 2026 13:07:27 +0200 Subject: [PATCH] perf(web): defer pull request line stats until visible (#6471) Co-authored-by: Theo Browne --- .../components/pullRequest/PullRequestRow.tsx | 9 +- .../pullRequest/pullRequestList.logic.test.ts | 196 ++++++++++++++ .../pullRequest/pullRequestList.logic.ts | 150 +++++++++++ apps/web/src/routes/_chat.pull-requests.tsx | 243 ++++++++++++++---- apps/web/src/state/pullRequests.ts | 24 +- 5 files changed, 561 insertions(+), 61 deletions(-) diff --git a/apps/web/src/components/pullRequest/PullRequestRow.tsx b/apps/web/src/components/pullRequest/PullRequestRow.tsx index b6b96ab7f55edf8c410b764b04456ed764478253..2284144d7fd191b75fc389c18da5af6e8d73a9ac 100644 --- a/apps/web/src/components/pullRequest/PullRequestRow.tsx +++ b/apps/web/src/components/pullRequest/PullRequestRow.tsx @@ -1,5 +1,5 @@ import { SearchIcon } from "lucide-react"; -import { memo } from "react"; +import { memo, type RefCallback } from "react"; import { cn } from "~/lib/utils"; import { getSourceControlPresentationForKind } from "~/sourceControlPresentation"; @@ -40,6 +40,8 @@ function PullRequestRowImpl({ showProvider, environmentLabel, matchedElsewhere, + statsKey, + statsRef, onSelect, }: { entry: EnvironmentPullRequestEntry; @@ -54,11 +56,16 @@ function PullRequestRowImpl({ * commit message. Saying so is the difference between a result and an apparently random row. */ matchedElsewhere?: boolean; + /** Used by the list's shared visibility observer to defer optional line-count reads. */ + statsKey?: string; + statsRef?: RefCallback; onSelect: (entry: EnvironmentPullRequestEntry) => void; }) { const { Icon, providerName } = getSourceControlPresentationForKind(entry.provider); return (