Skip to content

Commit 937507c

Browse files
fix(web): the branch toolbar and thread details panel stay cached while a reply streams
onStartFromOriginChange closed over the whole thread shell, which changes on every streamed event, so both consumers re-rendered with it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 54349ea commit 937507c

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

‎apps/web/src/components/chat/useComposerSelection.ts‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,12 +237,15 @@ export function useComposerSelection(input: ComposerSelectionInput) {
237237
};
238238
const onEnvModeChangeStable = useStableCallback(onEnvModeChange);
239239

240+
// Reads only the id: the shell changes on every streamed event, and a new handler
241+
// re-renders the branch toolbar and thread details panel with it.
242+
const activeThreadId = activeThread?.id;
240243
const onStartFromOriginChange = (nextStartFromOrigin: boolean) => {
241-
if (canOverrideServerThreadEnvMode && activeThread) {
244+
if (canOverrideServerThreadEnvMode && activeThreadId !== undefined) {
242245
setPendingServerThreadStartFromOriginByThreadId((current) =>
243-
current[activeThread.id] === nextStartFromOrigin
246+
current[activeThreadId] === nextStartFromOrigin
244247
? current
245-
: { ...current, [activeThread.id]: nextStartFromOrigin },
248+
: { ...current, [activeThreadId]: nextStartFromOrigin },
246249
);
247250
return;
248251
}

0 commit comments

Comments
 (0)