diff --git a/frontend/src/hooks/useAssistantSession.ts b/frontend/src/hooks/useAssistantSession.ts index d4ef81a9..25bf03ec 100644 --- a/frontend/src/hooks/useAssistantSession.ts +++ b/frontend/src/hooks/useAssistantSession.ts @@ -169,7 +169,12 @@ export function useAssistantSession() { const selectChat = useCallback(async (chatId: string) => { currentChatRef.current = chatId setActiveChatId(chatId) - // Don't clear task lane yet — wait for server response to decide + // Clear task lane immediately to prevent the persist effect from + // tagging the old session's data with the new chatId (race condition). + // Server-side pending_task_lane will restore it below if it exists. + setActiveQuestions([]) + setActiveActions([]) + setShowTaskLane(false) try { const detail = await aiSessionsApi.getSession(chatId) if (currentChatRef.current !== chatId) return