From 9f213ffa7908da8501a05d0e6fe1cac435d3915d Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Thu, 21 Aug 2025 12:41:03 -0500 Subject: [PATCH] Clear messages when navigating between projects --- src/components/Shakespeare/ChatPane.tsx | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/components/Shakespeare/ChatPane.tsx b/src/components/Shakespeare/ChatPane.tsx index 3974fc49..2c4a1cc9 100644 --- a/src/components/Shakespeare/ChatPane.tsx +++ b/src/components/Shakespeare/ChatPane.tsx @@ -153,14 +153,21 @@ BASE_DOMAIN=nostrdeploy.com`); } }; + // Clear messages when navigating between projects + useEffect(() => { + setMessages([]); + }, [projectId]) + useEffect(() => { // Add welcome message - addMessage({ - id: generateId(), - role: 'assistant', - content: `Hello! I'm here to help you build "${projectName}". I can help you edit files, add new features, and build your Nostr website. What would you like to work on?`, - }); - }, [projectName, projectId]); + if (!messages.length) { + addMessage({ + id: generateId(), + role: 'assistant', + content: `Hello! I'm here to help you build "${projectName}". I can help you edit files, add new features, and build your Nostr website. What would you like to work on?`, + }); + } + }, [projectName, messages]); useEffect(() => { if (scrollAreaRef.current && messages) {