From 1bfcfc9745c31e25db0259ca23848a2afa923516 Mon Sep 17 00:00:00 2001 From: Daniel Han Date: Tue, 31 Mar 2026 12:15:01 +0000 Subject: [PATCH] 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. --- studio/frontend/src/features/chat/chat-page.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/studio/frontend/src/features/chat/chat-page.tsx b/studio/frontend/src/features/chat/chat-page.tsx index 3adbb157ad..e844e97da8 100644 --- a/studio/frontend/src/features/chat/chat-page.tsx +++ b/studio/frontend/src/features/chat/chat-page.tsx @@ -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; + }); }, [], );