diff --git a/frontend/src/pages/AssistantChatPage.tsx b/frontend/src/pages/AssistantChatPage.tsx index 4edc528a..7e4d27b0 100644 --- a/frontend/src/pages/AssistantChatPage.tsx +++ b/frontend/src/pages/AssistantChatPage.tsx @@ -272,12 +272,18 @@ export default function AssistantChatPage() { } } - // Single source of truth for "wipe every per-session task-lane state field" - // before switching to a different chat. Called from selectChat, handleNewChat, - // sendPrefill, and handleResumeNew so adding new lane-scoped state in future + // Single source of truth for "wipe every per-chat UI state field" before + // switching to a different chat. Called from selectChat, handleNewChat, + // sendPrefill, and handleResumeNew so adding new chat-scoped state in future // phases only requires touching this one helper. Forgetting to clear a field - // leaks the previous session's data into the new one (Phase 5 regression). + // leaks the previous chat's data into the new one — first noticed as a task + // lane regression (Phase 5), surfaced again as the conversation pane showing + // the previous chat's messages while the sidebar entry said "0 messages". + // `messages` belongs in here too: selectChat clears it asynchronously when + // getSession returns, but the gap between switching and that response is + // exactly when the previous chat's content stays visible. const resetSessionDerivedState = useCallback(() => { + setMessages([]) setShowTaskLane(false) setActiveQuestions([]) setActiveActions([])