"use client"; import { useState } from "react"; import { useTheme } from "next-themes"; import { MessageCircle } from "lucide-react"; import { ChatMessageList, ChatComposer, type ChatBubbleMessage } from "@/components/ai/chat-thread"; import { useSpeechRecognition } from "@/hooks/use-speech-recognition"; import { sendChatMessage, type ChatMessage } from "@/lib/actions/chat-ai"; export function ChatPageClient({ aiConfigured }: { aiConfigured: boolean }) { const { resolvedTheme } = useTheme(); const colorMode = resolvedTheme === "dark" ? "dark" : "light"; const [messages, setMessages] = useState([]); const [input, setInput] = useState(""); const [sending, setSending] = useState(false); const [error, setError] = useState(null); const { supported: micSupported, listening, start, stop } = useSpeechRecognition({ onFinalResult: (transcript) => setInput((prev) => (prev ? `${prev} ${transcript}` : transcript)), onError: setError, }); async function handleSend() { const text = input.trim(); if (!text || sending) return; if (listening) stop(); const next: ChatMessage[] = [...messages, { role: "user", content: text }]; setMessages(next); setInput(""); setError(null); setSending(true); const result = await sendChatMessage(next); setSending(false); if ("error" in result) { setError(result.error); return; } setMessages([...next, { role: "assistant", content: result.content }]); } return (

Chat

Ask about anything across your boards — notes, open to-dos, and things you've already finished.

{!aiConfigured ? (

AI generation isn't configured yet. Ask an administrator to set it up.

) : (
)}
); }