diff --git a/app/history/new/page.tsx b/app/history/new/page.tsx index 8098186..a6a2c8d 100644 --- a/app/history/new/page.tsx +++ b/app/history/new/page.tsx @@ -4,9 +4,11 @@ import { useState } from "react"; import { useRouter } from "next/navigation"; import { ArrowLeft, Send, Loader2 } from "lucide-react"; import Link from "next/link"; +import { useToast } from "@/components/Toast"; export default function NewSessionPage() { const router = useRouter(); + const { toast } = useToast(); const [message, setMessage] = useState(""); const [sending, setSending] = useState(false); @@ -14,7 +16,6 @@ export default function NewSessionPage() { if (!message.trim() || sending) return; setSending(true); try { - // Create session const res = await fetch("/api/sessions", { method: "POST", headers: { "Content-Type": "application/json" }, @@ -24,7 +25,6 @@ export default function NewSessionPage() { const sessionId = data.session?.id; if (!sessionId) throw new Error("No session ID"); - // Send first message await fetch("/api/sessions/" + sessionId + "/chat", { method: "POST", headers: { "Content-Type": "application/json" }, @@ -32,7 +32,8 @@ export default function NewSessionPage() { }); router.push("/history/" + sessionId); - } catch { + } catch (e) { + toast("Failed to create session", "error"); setSending(false); } }; @@ -46,11 +47,15 @@ export default function NewSessionPage() {
+ Creates a new web session and sends your first message. +
+