"use client"; import { useState, useRef, useCallback } from "react"; import { ArrowUp, Loader2 } from "lucide-react"; import { useApp } from "@/lib/store"; export default function ChatInput() { const [text, setText] = useState(""); const { sendMessage, isStreaming, isCompressing } = useApp(); const textareaRef = useRef(null); const disabled = isStreaming || isCompressing; const handleSubmit = useCallback(() => { if (!text.trim() || disabled) return; sendMessage(text.trim()); setText(""); if (textareaRef.current) textareaRef.current.style.height = "auto"; }, [text, disabled, sendMessage]); const handleKeyDown = (e: React.KeyboardEvent) => { if (e.key === "Enter" && !e.shiftKey) { e.preventDefault(); handleSubmit(); } }; const handleInput = () => { const el = textareaRef.current; if (el) { el.style.height = "auto"; el.style.height = Math.min(el.scrollHeight, 160) + "px"; } }; return (