Skip to content
TypeScript

perf(web): main thread updates no longer re-render an open side chat (#28264)

Yuruzuu2f777bdd497a
diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx
index 99fe420431c..ea477b91447 100644
--- a/apps/web/src/components/ChatView.tsx
+++ b/apps/web/src/components/ChatView.tsx
@@ -3177,6 +3177,11 @@ export default function ChatView(props: ChatViewProps) {
(folders: Parameters<ChatComposerHandle["addDroppedFolders"]>[0]) =>
composerRef.current?.addDroppedFolders(folders),
);
+ // Above the early return, where React Compiler can cache it for the side chat pane.
+ const sideChatParentPanel = {
+ openToolDiff: onOpenToolDiffStable,
+ runShellCommand: runSideChatShellCommandStable,
+ };
if (!activeThread) {
return embedded ? null : <NoActiveThreadState />;
@@ -3196,10 +3201,7 @@ export default function ChatView(props: ChatViewProps) {
getShortcutContext={getShortcutContextStable}
onSendAnnotation={sendPreviewAnnotationStable}
onCloseSurface={closeRightPanelSurface}
- sideChatParentPanel={{
- openToolDiff: onOpenToolDiffStable,
- runShellCommand: runSideChatShellCommandStable,
- }}
+ sideChatParentPanel={sideChatParentPanel}
terminal={{
launchContext: activeTerminalLaunchContext ?? null,
keybindings,
diff --git a/apps/web/src/components/chat/RightPanelSurfaceContent.tsx b/apps/web/src/components/chat/RightPanelSurfaceContent.tsx
index 6ca50c824cb..b703e5d05da 100644
--- a/apps/web/src/components/chat/RightPanelSurfaceContent.tsx
+++ b/apps/web/src/components/chat/RightPanelSurfaceContent.tsx
@@ -79,7 +79,7 @@ export function RightPanelSurfaceContent(props: {
readonly files: RightPanelFileProps;
readonly sideChatParentPanel: SideChatParentPanel;
}) {
- const { surface, threadRef, visible } = props;
+ const { surface, threadRef, visible, onCloseSurface } = props;
if (surface === null) return null;
switch (surface.kind) {
case "preview":
@@ -176,7 +176,7 @@ export function RightPanelSurfaceContent(props: {
parentRef={threadRef}
threadId={surface.threadId}
parentPanel={props.sideChatParentPanel}
- onClose={() => props.onCloseSurface(surface)}
+ onClose={() => onCloseSurface(surface)}
/>
);
case "device":