Skip to content

Commit 2f777bd

Browse files
authored
perf(web): main thread updates no longer re-render an open side chat (#28264)
1 parent 9ff0fac commit 2f777bd

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

‎apps/web/src/components/ChatView.tsx‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3177,6 +3177,11 @@ export default function ChatView(props: ChatViewProps) {
31773177
(folders: Parameters<ChatComposerHandle["addDroppedFolders"]>[0]) =>
31783178
composerRef.current?.addDroppedFolders(folders),
31793179
);
3180+
// Above the early return, where React Compiler can cache it for the side chat pane.
3181+
const sideChatParentPanel = {
3182+
openToolDiff: onOpenToolDiffStable,
3183+
runShellCommand: runSideChatShellCommandStable,
3184+
};
31803185

31813186
if (!activeThread) {
31823187
return embedded ? null : <NoActiveThreadState />;
@@ -3196,10 +3201,7 @@ export default function ChatView(props: ChatViewProps) {
31963201
getShortcutContext={getShortcutContextStable}
31973202
onSendAnnotation={sendPreviewAnnotationStable}
31983203
onCloseSurface={closeRightPanelSurface}
3199-
sideChatParentPanel={{
3200-
openToolDiff: onOpenToolDiffStable,
3201-
runShellCommand: runSideChatShellCommandStable,
3202-
}}
3204+
sideChatParentPanel={sideChatParentPanel}
32033205
terminal={{
32043206
launchContext: activeTerminalLaunchContext ?? null,
32053207
keybindings,

‎apps/web/src/components/chat/RightPanelSurfaceContent.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export function RightPanelSurfaceContent(props: {
7979
readonly files: RightPanelFileProps;
8080
readonly sideChatParentPanel: SideChatParentPanel;
8181
}) {
82-
const { surface, threadRef, visible } = props;
82+
const { surface, threadRef, visible, onCloseSurface } = props;
8383
if (surface === null) return null;
8484
switch (surface.kind) {
8585
case "preview":
@@ -176,7 +176,7 @@ export function RightPanelSurfaceContent(props: {
176176
parentRef={threadRef}
177177
threadId={surface.threadId}
178178
parentPanel={props.sideChatParentPanel}
179-
onClose={() => props.onCloseSurface(surface)}
179+
onClose={() => onCloseSurface(surface)}
180180
/>
181181
);
182182
case "device":

0 commit comments

Comments
 (0)