perf(web): panel toggles no longer re-render the timeline and composer (#18077)

This commit is contained in:
oliver authored and GitHub committed 2026-10-11 20:21:19 -03:00
1 parent c9181d81a8
commit f6fa4776e7
2 files changed
+60 -36

No files matched your search

+54 -30
View File
@@ -10913,6 +10913,45 @@ export default function ChatView(props: ChatViewProps) {
}, [cancelWorktreeSetup, draftId, setupTarget.environmentId, worktreeSetup]);
const onSendRef = useRef(onSend);
onSendRef.current = onSend;
const onResumeRef = useRef(onResume);
onResumeRef.current = onResume;
const onCompactContextRef = useRef(onCompactContext);
onCompactContextRef.current = onCompactContext;
const onComposerSend = useCallback(
(...args: Parameters<typeof onSend>) => onSendRef.current(...args),
[],
);
const onComposerResume = useCallback(() => onResumeRef.current(), []);
const onComposerCompactContext = useCallback(() => onCompactContextRef.current(), []);
const queuedRunsControl = useMemo(
() =>
isServerThread && activeThread ? (
<QueuedRunsControl
ref={queuedRunsControlRef}
steerShortcutLabel={shortcutLabelForCommand(keybindings, "thread.steerQueuedMessage", {
context: { terminalFocus: false },
})}
editShortcutLabel={shortcutLabelForCommand(keybindings, "thread.editQueuedMessage", {
context: { composerFocus: true },
})}
environmentId={activeThread.environmentId}
threadId={activeThread.id}
optimisticMessages={optimisticUserMessages}
editingRunId={editingQueuedRun?.runId ?? null}
onEditQueuedRun={beginEditingQueuedRun}
onCancelEdit={cancelEditingQueuedRun}
/>
) : null,
[
activeThread,
beginEditingQueuedRun,
cancelEditingQueuedRun,
editingQueuedRun?.runId,
isServerThread,
keybindings,
optimisticUserMessages,
],
);
// Resend once the cancelled dispatch has settled and the composer is free.
// Every state that makes `onSend` bail and wait is part of the readiness
// check, so the flag survives a reconnect, a reverting checkpoint, or a
@@ -10977,12 +11016,21 @@ export default function ChatView(props: ChatViewProps) {
const onOpenTurnDiff = useCallback(
(runId: RunId, filePath?: string) => {
if (!isServerThread || !activeThreadRef) return;
const diffOpen =
selectActiveRightPanel(useRightPanelStore.getState().byThreadKey, activeThreadRef) ===
"diff";
explicitDiffOpenRef.current = diffOpen ? null : activeThreadRef;
useDiffPanelStore.getState().selectTurn(activeThreadRef, runId, filePath);
useRightPanelStore.getState().open(activeThreadRef, "diff");
onDiffPanelOpen?.();
},
[activeThreadRef, diffOpen, isServerThread, onDiffPanelOpen],
[activeThreadRef, isServerThread, onDiffPanelOpen],
);
const onTimelineRollbackCheckpoint = useCallback(
(input: { readonly checkpointId: string; readonly scopeId: string }) => {
if (!paintOnlyDisplayedTimeline) void onRollbackCheckpoint(input);
},
[onRollbackCheckpoint, paintOnlyDisplayedTimeline],
);
// The revert handler is read from a ref at call-time so the callback
// reference is fully stable and never busts TimelineRowCtx identity.
@@ -11504,9 +11552,7 @@ export default function ChatView(props: ChatViewProps) {
onOpenThread={onOpenRelatedThread}
parentThreadLink={paintOnlyDisplayedTimeline ? null : parentThreadLink}
onForkFromRun={paintOnlyDisplayedTimeline ? async () => {} : onForkFromRun}
onRollbackCheckpoint={(input) => {
if (!paintOnlyDisplayedTimeline) void onRollbackCheckpoint(input);
}}
onRollbackCheckpoint={onTimelineRollbackCheckpoint}
supportsConversationRollback={
!paintOnlyDisplayedTimeline && supportsConversationRollback
}
@@ -11711,29 +11757,7 @@ export default function ChatView(props: ChatViewProps) {
: projectCloneSendBlockReason
}
isPreparingWorktree={isPreparingWorktree && !sendQueuesBehindSetup}
queuedRunsControl={
isServerThread && activeThread ? (
<QueuedRunsControl
ref={queuedRunsControlRef}
steerShortcutLabel={shortcutLabelForCommand(
keybindings,
"thread.steerQueuedMessage",
{ context: { terminalFocus: false } },
)}
editShortcutLabel={shortcutLabelForCommand(
keybindings,
"thread.editQueuedMessage",
{ context: { composerFocus: true } },
)}
environmentId={activeThread.environmentId}
threadId={activeThread.id}
optimisticMessages={optimisticUserMessages}
editingRunId={editingQueuedRun?.runId ?? null}
onEditQueuedRun={beginEditingQueuedRun}
onCancelEdit={cancelEditingQueuedRun}
/>
) : null
}
queuedRunsControl={queuedRunsControl}
bannerItems={composerBannerItems}
resumeCompactionTokens={resumeCompactionTokens}
keepFullHistory={keepFullHistory}
@@ -11807,9 +11831,9 @@ export default function ChatView(props: ChatViewProps) {
onPageScrollKeyDown={onComposerPageScrollKeyDown}
onPageScrollKeyUp={onComposerPageScrollKeyUp}
onPageScrollRelease={onComposerPageScrollRelease}
onCompactContext={onCompactContext}
onSend={onSend}
onResume={onResume}
onCompactContext={onComposerCompactContext}
onSend={onComposerSend}
onResume={onComposerResume}
onInterrupt={onInterrupt}
onImplementPlanInNewThread={onImplementPlanInNewThread}
onRespondToApproval={onRespondToApproval}
@@ -10,18 +10,20 @@ import type { DraftId } from "../../composerDraftStore";
import { useT3ProjectFileScripts } from "../../hooks/useT3ProjectFileScripts";
import { type EnvMode, type EnvironmentOption } from "../BranchToolbar.logic";
import { BranchToolbar } from "../BranchToolbar";
import GitActionsControl from "../GitActionsControl";
import BaseGitActionsControl from "../GitActionsControl";
import ProjectScriptsControl, {
type NewProjectScriptInput,
type ProjectScriptActionResult,
} from "../ProjectScriptsControl";
import type { ComponentProps } from "react";
import { memo, type ComponentProps } from "react";
import { ThreadDetailsCard } from "./ThreadDetailsCard";
import { OpenInPicker } from "./OpenInPicker";
import { ThreadDetailsSection } from "./ThreadDetailsSection";
import { ThreadAutomationsPanel } from "./ThreadAutomationsPanel";
import { ThreadRelationshipsPanel } from "./ThreadRelationshipsControl";
const GitActionsControl = memo(BaseGitActionsControl);
export interface ThreadDetailsPanelProps extends Pick<
ComponentProps<typeof ThreadDetailsCard>,
"anchor" | "handle" | "onPresentationChange"
@@ -67,6 +69,7 @@ export function ThreadDetailsPanel(props: ThreadDetailsPanelProps) {
props.environmentId,
props.activeProjectScripts ? props.gitCwd : null,
);
const activeThreadRef = { environmentId: props.environmentId, threadId: props.threadId };
const branchToolbarProps = {
showGitControls: props.isGitRepo,
environmentId: props.environmentId,
@@ -160,10 +163,7 @@ export function ThreadDetailsPanel(props: ThreadDetailsPanelProps) {
displayMode="panel"
compact={density !== "full"}
gitCwd={props.gitCwd}
activeThreadRef={{
environmentId: props.environmentId,
threadId: props.threadId,
}}
activeThreadRef={activeThreadRef}
{...(props.draftId ? { draftId: props.draftId } : {})}
{...(props.onOpenChanges ? { onOpenChanges: props.onOpenChanges } : {})}
/>