An AI-powered search engine with a generative UI
TypeScript generative-aigenerative-uinextjsollamareactsearxngshadcn-uitailwindcsstavilytypescriptupstashvercel-ai-sdk
fix: clear all chat state when starting new conversation
Yoshiki Miuraa4b67a6031d3
diff --git a/components/chat.tsx b/components/chat.tsxindex 05323110..b8528046 100644--- a/components/chat.tsx+++ b/components/chat.tsx@@ -46,10 +46,18 @@ export function Chat({// - Otherwise, generate a new ID (e.g., / homepage for new chats)const [chatId, setChatId] = useState(() => providedId || generateId())- // Callback to reset chatId when user clicks "New" button+ // Callback to reset chat state when user clicks "New" buttonconst handleNewChat = () => {const newId = generateId()setChatId(newId)+ // Clear other chat-related state that persists due to Next.js 16 component caching+ setInput('')+ setUploadedFiles([])+ setErrorModal({+ open: false,+ type: 'general',+ message: ''+ })}const scrollContainerRef = useRef<HTMLDivElement>(null)