The best way to control Claude Code, Codex and more from any computer or phone
perf(web): Shift re-renders only each row's quick-action group (#22726)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 21, 2026 at 01:28 UTC
57d784404ed1814816d135484f9820e6824dc7c2
4 files changed
+136
-106
apps/web/src/components/pullRequest/PullRequestListGroups.tsx
+44
-47
@@ -3,7 +3,6 @@ import { EyeIcon, LayersIcon, PenLineIcon, UsersIcon, type LucideIcon } from "lu
3
import type { RefCallback } from "react";
4
5
import { cn } from "~/lib/utils";
6
-import { useShortcutModifierState } from "~/shortcutModifierState";
6
import { Separator } from "../ui/separator";
7
import {
8
pullRequestEntryKey,
@@ -12,7 +11,10 @@ import {
11
type PullRequestGroup,
12
} from "./pullRequestList.logic";
13
import { PullRequestRow, type PullRequestRowTarget } from "./PullRequestRow";
15
-import type { PullRequestSpeedActionResult } from "./PullRequestSpeedActions";
14
+import {
15
+ PullRequestSpeedModeProvider,
16
+ type PullRequestSpeedActionResult,
17
+} from "./PullRequestSpeedActions";
18
19
const GROUP_ICONS: Record<string, LucideIcon> = {
20
authored: PenLineIcon,
@@ -38,10 +40,6 @@ function PullRequestGroupHeader({
40
);
41
}
42
41
-/**
42
- * The grouped rows. Holding Shift turns rows into speed actions, so the modifier subscription lives
43
- * here: a key press re-renders the rows, not the page and its open pull request.
44
- */
43
export function PullRequestListGroups({
44
groups,
45
environmentLabels,
@@ -75,47 +73,46 @@ export function PullRequestListGroups({
73
sweepingKeys: ReadonlySet<string>;
74
onCloseSweepStart: (entry: EnvironmentPullRequestEntry, event: PointerEvent) => void;
75
}) {
78
- const modifiers = useShortcutModifierState(true);
79
- const speedMode =
80
- modifiers.shiftKey && !modifiers.metaKey && !modifiers.ctrlKey && !modifiers.altKey;
76
return (
82
- <div className={cn("space-y-3", sweepingKeys.size > 0 && "**:pointer-events-none")}>
83
- {groups.map((group) => (
84
- <div key={group.key} className="space-y-0.5">
85
- {group.label ? <PullRequestGroupHeader group={group} /> : null}
86
- {group.entries.map((entry) => {
87
- const entryKey = pullRequestEntryKey(entry);
88
- const environmentLabel = environmentLabels?.get(entry.environmentId);
89
- return (
90
- <PullRequestRow
91
- key={entryKey}
92
- statsKey={entryKey}
93
- statsRef={statsRef}
94
- entry={entry}
95
- showProjectTitle
96
- showProvider={showProvider}
97
- {...(environmentLabel !== undefined ? { environmentLabel } : {})}
98
- matchedElsewhere={
99
- query.length > 0 && scorePullRequestMatch(entry, query) <= MATCHED_ELSEWHERE_SCORE
100
- }
101
- selected={
102
- selected?.environmentId === entry.environmentId &&
103
- selected.repository === entry.repository &&
104
- selected.host?.toLowerCase() === entry.host.toLowerCase() &&
105
- selected.number === entry.number
106
- }
107
- onSelect={onSelect}
108
- speedMode={speedMode}
109
- hostActions={hostActionsOf(entry)}
110
- onActed={onActed}
111
- closing={closingKeys.has(entryKey)}
112
- sweeping={sweepingKeys.has(entryKey)}
113
- onCloseSweepStart={onCloseSweepStart}
114
- />
115
- );
116
- })}
117
- </div>
118
- ))}
119
- </div>
77
+ <PullRequestSpeedModeProvider>
78
+ <div className={cn("space-y-3", sweepingKeys.size > 0 && "**:pointer-events-none")}>
79
+ {groups.map((group) => (
80
+ <div key={group.key} className="space-y-0.5">
81
+ {group.label ? <PullRequestGroupHeader group={group} /> : null}
82
+ {group.entries.map((entry) => {
83
+ const entryKey = pullRequestEntryKey(entry);
84
+ const environmentLabel = environmentLabels?.get(entry.environmentId);
85
+ return (
86
+ <PullRequestRow
87
+ key={entryKey}
88
+ statsKey={entryKey}
89
+ statsRef={statsRef}
90
+ entry={entry}
91
+ showProjectTitle
92
+ showProvider={showProvider}
93
+ {...(environmentLabel !== undefined ? { environmentLabel } : {})}
94
+ matchedElsewhere={
95
+ query.length > 0 &&
96
+ scorePullRequestMatch(entry, query) <= MATCHED_ELSEWHERE_SCORE
97
+ }
98
+ selected={
99
+ selected?.environmentId === entry.environmentId &&
100
+ selected.repository === entry.repository &&
101
+ selected.host?.toLowerCase() === entry.host.toLowerCase() &&
102
+ selected.number === entry.number
103
+ }
104
+ onSelect={onSelect}
105
+ hostActions={hostActionsOf(entry)}
106
+ onActed={onActed}
107
+ closing={closingKeys.has(entryKey)}
108
+ sweeping={sweepingKeys.has(entryKey)}
109
+ onCloseSweepStart={onCloseSweepStart}
110
+ />
111
+ );
112
+ })}
113
+ </div>
114
+ ))}
115
+ </div>
116
+ </PullRequestSpeedModeProvider>
117
);
118
}
apps/web/src/components/pullRequest/PullRequestRow.tsx
-3
@@ -78,7 +78,6 @@ function PullRequestRowImpl({
78
statsKey,
79
statsRef,
80
onSelect,
81
- speedMode,
81
hostActions,
82
onActed,
83
closing = false,
@@ -95,7 +94,6 @@ function PullRequestRowImpl({
94
statsKey?: string;
95
statsRef?: RefCallback<HTMLDivElement>;
96
onSelect: (entry: PullRequestRowTarget) => void;
98
- speedMode: boolean;
97
hostActions: ReadonlySet<PullRequestAction>;
98
onActed: (result: PullRequestSpeedActionResult) => void;
99
closing?: boolean;
@@ -243,7 +241,6 @@ function PullRequestRowImpl({
241
<PullRequestSpeedActions
242
entry={entry}
243
hostActions={hostActions}
246
- visible={speedMode}
244
onActed={onActed}
245
closing={closing}
246
sweeping={sweeping}
apps/web/src/components/pullRequest/PullRequestSpeedActions.tsx
+46
-8
@@ -1,5 +1,8 @@
1
import { useAtomValue } from "@effect/atom-react";
2
import type { PullRequestAction } from "@t3tools/contracts";
3
+import { createContext, use, type ReactNode } from "react";
4
+
5
+import { useShortcutModifierState } from "~/shortcutModifierState";
6
import { pullRequestEnvironment } from "~/state/pullRequests";
7
import { useUiStateStore } from "~/uiStateStore";
8
import { Button } from "../ui/button";
@@ -26,7 +29,6 @@ export interface PullRequestSpeedActionResult<Entry = EnvironmentPullRequestEntr
29
export function PullRequestSpeedActions<Entry extends PullRequestSpeedActionEntry>({
30
entry,
31
hostActions,
29
- visible,
32
onActed,
33
closing = false,
34
sweeping = false,
@@ -34,7 +36,6 @@ export function PullRequestSpeedActions<Entry extends PullRequestSpeedActionEntr
36
}: {
37
entry: Entry;
38
hostActions: ReadonlySet<PullRequestAction>;
37
- visible: boolean;
39
onActed?: (result: PullRequestSpeedActionResult<Entry>) => void;
40
closing?: boolean;
41
sweeping?: boolean;
@@ -75,12 +76,10 @@ export function PullRequestSpeedActions<Entry extends PullRequestSpeedActionEntr
76
const busy = actionPending || closing || sweeping;
77
if (actions.length === 0) return null;
78
return (
78
- <div
79
- className="shrink-0 items-center gap-1 pr-3"
80
- style={{ display: visible || busy ? "flex" : "none" }}
81
- role="group"
82
- aria-label={`Quick actions for pull request #${entry.number}`}
83
- data-pull-request-action-pending={actionPending || closing}
79
+ <SpeedModeGroup
80
+ busy={busy}
81
+ pending={actionPending || closing}
82
+ label={`Quick actions for pull request #${entry.number}`}
83
>
84
{actions.map((action) => {
85
const label = ACTIONS[action].label;
@@ -116,6 +115,45 @@ export function PullRequestSpeedActions<Entry extends PullRequestSpeedActionEntr
115
</Tooltip>
116
);
117
})}
118
+ </SpeedModeGroup>
119
+ );
120
+}
121
+
122
+/**
123
+ * Whether Shift is held, as context rather than a row prop: a Shift press then re-renders each
124
+ * row's action group, not the rows or their buttons, in one commit.
125
+ */
126
+export const PullRequestSpeedModeContext = createContext(false);
127
+
128
+/** Tracks Shift for the quick actions below it. */
129
+export function PullRequestSpeedModeProvider({ children }: { children: ReactNode }) {
130
+ const modifiers = useShortcutModifierState(true);
131
+ const speedMode =
132
+ modifiers.shiftKey && !modifiers.metaKey && !modifiers.ctrlKey && !modifiers.altKey;
133
+ return <PullRequestSpeedModeContext value={speedMode}>{children}</PullRequestSpeedModeContext>;
134
+}
135
+
136
+function SpeedModeGroup({
137
+ busy,
138
+ pending,
139
+ label,
140
+ children,
141
+}: {
142
+ busy: boolean;
143
+ pending: boolean;
144
+ label: string;
145
+ children: ReactNode;
146
+}) {
147
+ const speedMode = use(PullRequestSpeedModeContext);
148
+ return (
149
+ <div
150
+ className="shrink-0 items-center gap-1 pr-3"
151
+ style={{ display: speedMode || busy ? "flex" : "none" }}
152
+ role="group"
153
+ aria-label={label}
154
+ data-pull-request-action-pending={pending}
155
+ >
156
+ {children}
157
</div>
158
);
159
}
apps/web/src/components/pullRequest/ThreadPullRequestsPanel.tsx
+46
-48
@@ -54,7 +54,7 @@ import {
54
} from "./pullRequestPresentation";
55
import { PullRequestGlyph } from "./pullRequestIcons";
56
import { pullRequestQuickActions } from "./pullRequestList.logic";
57
-import { PullRequestSpeedActions } from "./PullRequestSpeedActions";
57
+import { PullRequestSpeedActions, PullRequestSpeedModeContext } from "./PullRequestSpeedActions";
58
59
const SOURCE_LABELS: Record<ThreadPullRequestLink["source"], string> = {
60
manual: "Linked by you",
@@ -278,11 +278,7 @@ function LinkRowImpl({
278
/>
279
</a>
280
{actionEntry !== null ? (
281
- <PullRequestSpeedActions
282
- entry={actionEntry}
283
- hostActions={linkHostActions}
284
- visible={speedMode}
285
- />
281
+ <PullRequestSpeedActions entry={actionEntry} hostActions={linkHostActions} />
282
) : null}
283
<span
284
className={cn(
@@ -448,48 +444,50 @@ function EnabledThreadPullRequestsPanel({ threadRef }: { threadRef: ScopedThread
444
}
445
446
return (
451
- <div className="flex h-full min-h-0 flex-col">
452
- {/* Threads that run a stack or a sweep link hundreds of pull requests; only the rows in
447
+ <PullRequestSpeedModeContext value={speedMode}>
448
+ <div className="flex h-full min-h-0 flex-col">
449
+ {/* Threads that run a stack or a sweep link hundreds of pull requests; only the rows in
450
view are mounted. */}
454
- <LegendList<PullRequestListLine>
455
- data={lines}
456
- keyExtractor={lineKey}
457
- extraData={rowInputs}
458
- renderItem={({ item: line }) => (
459
- <LinkRow
460
- line={line}
461
- threadRef={threadRef}
462
- projectId={
463
- capabilities?.pullRequests === true
464
- ? (findProjectForChangeRequest(environmentProjects, line.link)?.id ??
465
- thread?.projectId ??
466
- null)
467
- : null
468
- }
469
- speedMode={speedMode}
470
- onUnlink={handleUnlink}
471
- onSetWatching={supportsWatch ? handleSetWatching : null}
472
- />
473
- )}
474
- estimatedItemSize={44}
475
- drawDistance={440}
476
- className="min-h-0 flex-1 overscroll-contain p-1.5"
477
- />
478
- <footer className="flex items-center justify-between border-t border-border/60 px-2 py-1.5 text-2xs text-muted-foreground">
479
- <span>
480
- {openCount} open · {linkCount} linked
481
- {lastSynced ? (
482
- <>
483
- {" · synced "}
484
- <RelativeTime timestamp={lastSynced} />
485
- </>
486
- ) : null}
487
- </span>
488
- <Button size="xs" variant="ghost" onClick={openLinkDialog}>
489
- <PlusIcon className="size-3.5" />
490
- Link
491
- </Button>
492
- </footer>
493
- </div>
451
+ <LegendList<PullRequestListLine>
452
+ data={lines}
453
+ keyExtractor={lineKey}
454
+ extraData={rowInputs}
455
+ renderItem={({ item: line }) => (
456
+ <LinkRow
457
+ line={line}
458
+ threadRef={threadRef}
459
+ projectId={
460
+ capabilities?.pullRequests === true
461
+ ? (findProjectForChangeRequest(environmentProjects, line.link)?.id ??
462
+ thread?.projectId ??
463
+ null)
464
+ : null
465
+ }
466
+ speedMode={speedMode}
467
+ onUnlink={handleUnlink}
468
+ onSetWatching={supportsWatch ? handleSetWatching : null}
469
+ />
470
+ )}
471
+ estimatedItemSize={44}
472
+ drawDistance={440}
473
+ className="min-h-0 flex-1 overscroll-contain p-1.5"
474
+ />
475
+ <footer className="flex items-center justify-between border-t border-border/60 px-2 py-1.5 text-2xs text-muted-foreground">
476
+ <span>
477
+ {openCount} open · {linkCount} linked
478
+ {lastSynced ? (
479
+ <>
480
+ {" · synced "}
481
+ <RelativeTime timestamp={lastSynced} />
482
+ </>
483
+ ) : null}
484
+ </span>
485
+ <Button size="xs" variant="ghost" onClick={openLinkDialog}>
486
+ <PlusIcon className="size-3.5" />
487
+ Link
488
+ </Button>
489
+ </footer>
490
+ </div>
491
+ </PullRequestSpeedModeContext>
492
);
493
}