Skip artifact clear when re-selecting the same thread

Only clear artifact store when navigating to a different thread,
not when clicking the already-active thread in the sidebar.
This commit is contained in:
Daniel Han 2026-03-31 12:15:01 +00:00
commit 1bfcfc9745

View file

@ -596,8 +596,14 @@ export function ChatPage(): ReactElement {
const handleThreadSelect = useCallback(
(nextView: ChatView) => {
useArtifactStore.getState().clearArtifacts();
setView(nextView);
setView((prev) => {
const prevId = prev.mode === "single" ? prev.threadId : prev.pairId;
const nextId = nextView.mode === "single" ? nextView.threadId : nextView.pairId;
if (prevId !== nextId) {
useArtifactStore.getState().clearArtifacts();
}
return nextView;
});
},
[],
);