The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 23, 08:00 UTC
perf(web): virtualize a thread's linked pull requests (#20107)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 15, 2026 at 19:26 UTC
d5139979d427d94d71714e9e59bca1b47832c9a7
1 file changed
+42
-24
apps/web/src/components/pullRequest/ThreadPullRequestsPanel.tsx
+42
-24
@@ -15,7 +15,8 @@ import {
15
MoreHorizontalIcon,
16
PlusIcon,
17
} from "lucide-react";
18
-import { useCallback, useMemo, useState } from "react";
18
+import { LegendList } from "@legendapp/list/react";
19
+import { memo, useCallback, useMemo, useState } from "react";
20
21
import { writeTextToClipboard } from "~/hooks/useCopyToClipboard";
22
import { findProjectForChangeRequest, useOpenPrLink } from "~/lib/openPullRequestLink";
@@ -29,7 +30,6 @@ import { formatRelativeTimeLabel } from "~/timestampFormat";
30
import { Button } from "../ui/button";
31
import { Menu, MenuItem, MenuPopup, MenuTrigger } from "../ui/menu";
32
import { MiddleTruncate } from "../ui/middle-truncate";
32
-import { ScrollArea } from "../ui/scroll-area";
33
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
34
import { openLinkPullRequestDialog } from "./LinkPullRequestDialog";
35
import { pullRequestListLines, type PullRequestListLine } from "./pullRequestListLines";
@@ -78,7 +78,7 @@ function ChecksGlyph({
78
);
79
}
80
81
-function LinkRow({
81
+function LinkRowImpl({
82
line,
83
threadRef,
84
projectId,
@@ -326,6 +326,12 @@ function LinkRow({
326
);
327
}
328
329
+/** Memoized so a modifier key or a sync of one link re-renders only the rows that changed. */
330
+const LinkRow = memo(LinkRowImpl);
331
+
332
+const lineKey = (line: PullRequestListLine) =>
333
+ `${line.link.host}/${line.link.repository}#${line.link.number}`;
334
+
335
export function ThreadPullRequestsPanel({ threadRef }: { threadRef: ScopedThreadRef }) {
336
const configs = useServerConfigs();
337
if (configs.get(threadRef.environmentId)?.environment.capabilities.threadPullRequests !== true) {
@@ -403,6 +409,13 @@ function EnabledThreadPullRequestsPanel({ threadRef }: { threadRef: ScopedThread
409
return latest;
410
}, [links]);
411
412
+ // Legend re-renders visible rows only when data or extraData changes, so everything the rows
413
+ // read from outside their line goes in here.
414
+ const rowInputs = useMemo(
415
+ () => ({ speedMode, environmentProjects, capabilities, supportsWatch, thread }),
416
+ [speedMode, environmentProjects, capabilities, supportsWatch, thread],
417
+ );
418
+
419
if (links.length === 0) {
420
return (
421
<div className="flex h-full flex-col items-center justify-center gap-2 p-6 text-center">
@@ -422,27 +435,32 @@ function EnabledThreadPullRequestsPanel({ threadRef }: { threadRef: ScopedThread
435
436
return (
437
<div className="flex h-full min-h-0 flex-col">
425
- <ScrollArea className="min-h-0 flex-1">
426
- <div className="flex flex-col p-1.5">
427
- {lines.map((line) => (
428
- <LinkRow
429
- key={`${line.link.host}/${line.link.repository}#${line.link.number}`}
430
- line={line}
431
- threadRef={threadRef}
432
- projectId={
433
- capabilities?.pullRequests === true
434
- ? (findProjectForChangeRequest(environmentProjects, line.link)?.id ??
435
- thread?.projectId ??
436
- null)
437
- : null
438
- }
439
- speedMode={speedMode}
440
- onUnlink={handleUnlink}
441
- onSetWatching={supportsWatch ? handleSetWatching : null}
442
- />
443
- ))}
444
- </div>
445
- </ScrollArea>
438
+ {/* Threads that run a stack or a sweep link hundreds of pull requests; only the rows in
439
+ view are mounted. */}
440
+ <LegendList<PullRequestListLine>
441
+ data={lines}
442
+ keyExtractor={lineKey}
443
+ extraData={rowInputs}
444
+ renderItem={({ item: line }) => (
445
+ <LinkRow
446
+ line={line}
447
+ threadRef={threadRef}
448
+ projectId={
449
+ capabilities?.pullRequests === true
450
+ ? (findProjectForChangeRequest(environmentProjects, line.link)?.id ??
451
+ thread?.projectId ??
452
+ null)
453
+ : null
454
+ }
455
+ speedMode={speedMode}
456
+ onUnlink={handleUnlink}
457
+ onSetWatching={supportsWatch ? handleSetWatching : null}
458
+ />
459
+ )}
460
+ estimatedItemSize={44}
461
+ drawDistance={440}
462
+ className="min-h-0 flex-1 overscroll-contain p-1.5"
463
+ />
464
<footer className="flex items-center justify-between border-t border-border/60 px-2 py-1.5 text-2xs text-muted-foreground">
465
<span>
466
{openCount} open · {links.length} linked