import { useState, useRef, useEffect, useCallback } from "react"; import { Send, Square, Plus } from "lucide-react"; import { useLLM } from "../hooks/useLLM"; import { MessageBubble } from "./MessageBubble"; import { StatusBar } from "./StatusBar"; const EXAMPLE_PROMPTS = [ { label: "Solve x² + x - 12 = 0", prompt: "Solve x^2 + x - 12 = 0", }, { label: "Explain quantum computing", prompt: "Explain quantum computing in simple terms. What makes it different from classical computing, and what are some real-world applications?", }, { label: "Write a Python quicksort", prompt: "Write a clean, well-commented Python implementation of the quicksort algorithm. Include an example of how to use it.", }, { label: "Solve a logic puzzle", prompt: "Five people were eating apples, A finished before B, but behind C. D finished before E, but behind B. What was the finishing order?", }, ] as const; interface ChatInputProps { showDisclaimer: boolean; animated?: boolean; } function ChatInput({ showDisclaimer, animated }: ChatInputProps) { const { send, stop, status, isGenerating } = useLLM(); const isReady = status.state === "ready"; const [input, setInput] = useState(""); const textareaRef = useRef(null); const handleSubmit = useCallback( (e?: React.FormEvent) => { e?.preventDefault(); const text = input.trim(); if (!text || !isReady || isGenerating) return; setInput(""); if (textareaRef.current) { textareaRef.current.style.height = "7.5rem"; } send(text); }, [input, isReady, isGenerating, send], ); const handleKeyDown = useCallback( (e: React.KeyboardEvent) => { if (e.key === "Enter" && !e.shiftKey) { e.preventDefault(); handleSubmit(); } }, [handleSubmit], ); return (