From 0bccc41ccc2877c8261450792a7055b7c4a96142 Mon Sep 17 00:00:00 2001 From: sepehr Date: Tue, 28 Apr 2026 21:54:21 +0200 Subject: [PATCH] fix: chat loses conversation context between messages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove revalidatePath('/chat') from createConversation — it caused the server to re-render the /chat page after each new conversation, which reset the useChat hook state and created a new conversation for every message instead of continuing the existing one. Sidebar now refreshes client-side after streaming completes. Co-Authored-By: Claude Opus 4.7 --- memento-note/app/actions/chat-actions.ts | 2 -- memento-note/components/chat/chat-container.tsx | 6 ++++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/memento-note/app/actions/chat-actions.ts b/memento-note/app/actions/chat-actions.ts index b06b05a..d26eb9a 100644 --- a/memento-note/app/actions/chat-actions.ts +++ b/memento-note/app/actions/chat-actions.ts @@ -21,7 +21,6 @@ export async function createConversation(title: string, notebookId?: string) { }, }) - revalidatePath('/chat') return { id: conversation.id, title: conversation.title } } @@ -69,6 +68,5 @@ export async function deleteConversation(id: string) { where: { id, userId: session.user.id } }) - revalidatePath('/chat') return { success: true } } diff --git a/memento-note/components/chat/chat-container.tsx b/memento-note/components/chat/chat-container.tsx index ea29610..9cc98c6 100644 --- a/memento-note/components/chat/chat-container.tsx +++ b/memento-note/components/chat/chat-container.tsx @@ -60,12 +60,14 @@ export function ChatContainer({ initialConversations, notebooks, webSearchAvaila }, [isLoading, t]) // Sync historyMessages after each completed streaming response - // so the display doesn't revert to stale history + // so the display doesn't revert to stale history. + // Also refresh sidebar so new conversation appears. useEffect(() => { if (status === 'ready' && messages.length > 0) { setHistoryMessages([...messages]) + refreshConversations() } - }, [status, messages]) + }, [status, messages, refreshConversations]) // Load conversation details when the user selects a different conversation useEffect(() => {