Skip to content

Commit 0742a8e

Browse files
perf(mobile): thread rows no longer re-render when another thread streams
useConfirmDeleteThread called no hooks, so the compiler skipped it and the delete handler was a new closure every render. HomeScreen wrapped props callbacks as `props.onX(...)`, which the compiler caches on the whole props object. Together these gave every memoized ThreadListV2Row new handler props on each parent render. The delete confirmation is now a plain function, and HomeScreen passes the callbacks through. The sidebar's select and pull request handlers read destructured callbacks because they also close the open swipe row. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 087ffb3 commit 0742a8e

2 files changed

Lines changed: 13 additions & 24 deletions

File tree

‎apps/mobile/src/features/home/HomeScreen.tsx‎

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -415,28 +415,14 @@ export function HomeScreen(props: HomeScreenProps) {
415415
),
416416
);
417417
const handleSettleThread = props.onSettleThread;
418-
const handleSnoozeThread = (thread: EnvironmentThreadShell, snoozedUntil: string) => {
419-
void props.onSnoozeThread(thread, snoozedUntil);
420-
};
421-
const handleUnsnoozeThread = (thread: EnvironmentThreadShell) => {
422-
void props.onUnsnoozeThread(thread);
423-
};
424-
const handlePinThread = (thread: EnvironmentThreadShell) => {
425-
void props.onPinThread(thread);
426-
};
427-
const handleMoveThread = (thread: EnvironmentThreadShell, direction: ThreadMoveDestination) => {
428-
void props.onMoveThread(thread, direction);
429-
};
430-
const handleUnpinThread = (thread: EnvironmentThreadShell) => {
431-
void props.onUnpinThread(thread);
432-
};
433-
const handleSetThreadAutoSettle = (thread: EnvironmentThreadShell, enabled: boolean) => {
434-
void props.onSetThreadAutoSettle(thread, enabled);
435-
};
436-
const handleRegenerateThreadTitle = (thread: EnvironmentThreadShell) => {
437-
void props.onRegenerateThreadTitle(thread);
438-
};
439-
const handleRenameThread = (thread: EnvironmentThreadShell) => props.onRenameThread(thread);
418+
const handleSnoozeThread = props.onSnoozeThread;
419+
const handleUnsnoozeThread = props.onUnsnoozeThread;
420+
const handlePinThread = props.onPinThread;
421+
const handleMoveThread = props.onMoveThread;
422+
const handleUnpinThread = props.onUnpinThread;
423+
const handleSetThreadAutoSettle = props.onSetThreadAutoSettle;
424+
const handleRegenerateThreadTitle = props.onRegenerateThreadTitle;
425+
const handleRenameThread = props.onRenameThread;
440426
const handleDeleteThread = props.onDeleteThread;
441427
const handleUnsettleThread = props.onUnsettleThread;
442428
const [settledVisibleCount, setSettledVisibleCount] = useState(

‎apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -484,15 +484,18 @@ function ThreadNavigationSidebarPane(
484484
openSwipeableRef.current = null;
485485
}
486486
};
487+
// These close the open row too, so they cannot be pass-throughs. The compiler would
488+
// recache a closure over `props` whenever any prop changed.
489+
const { onSelectThread, onOpenThreadPullRequests } = props;
487490
const handleSelectThread = (thread: EnvironmentThreadShell) => {
488-
props.onSelectThread(thread);
491+
onSelectThread(thread);
489492
openSwipeableRef.current?.close();
490493
};
491494
const handleOpenThreadPullRequests = (
492495
thread: EnvironmentThreadShell,
493496
pr: ThreadPrPresentation,
494497
) => {
495-
props.onOpenThreadPullRequests(thread, pr);
498+
onOpenThreadPullRequests(thread, pr);
496499
openSwipeableRef.current?.close();
497500
};
498501
const handleScrollBeginDrag = () => {

0 commit comments

Comments
 (0)