diff --git a/components/chat.tsx b/components/chat.tsx index b3a8394..54f6865 100644 --- a/components/chat.tsx +++ b/components/chat.tsx @@ -19,6 +19,7 @@ import { import { useState } from 'react' import { Button } from './ui/button' import { Input } from './ui/input' +import { useRouter } from 'next/navigation' const IS_PREVIEW = process.env.VERCEL_ENV === 'preview' export interface ChatProps extends React.ComponentProps<'div'> { @@ -27,6 +28,7 @@ export interface ChatProps extends React.ComponentProps<'div'> { } export function Chat({ id, initialMessages, className }: ChatProps) { + const router = useRouter() const [previewToken, setPreviewToken] = useLocalStorage( 'ai-token', null @@ -40,6 +42,9 @@ export function Chat({ id, initialMessages, className }: ChatProps) { body: { id, previewToken + }, + onFinish: () => { + router.refresh() } }) return ( diff --git a/components/sidebar-actions.tsx b/components/sidebar-actions.tsx index 4c6a34b..7273180 100644 --- a/components/sidebar-actions.tsx +++ b/components/sidebar-actions.tsx @@ -200,7 +200,9 @@ export function SidebarActions({ } setDeleteDialogOpen(false) + router.refresh() router.push('/') + toast.success('Chat deleted') }) }} >