"use client"; import { Button } from "@/components/ui/button"; import { Textarea } from "@/components/ui/textarea"; import { cn } from "@/lib/utils"; import { useSpeechRecognition } from "@/lib/useSpeechRecognition"; import { useCallback } from "react"; export function QueryComposer({ question, isLoading, disabled = false, onChange, onSubmit, }: { question: string; isLoading: boolean; disabled?: boolean; onChange: (value: string) => void; onSubmit: () => void; }) { const submitDisabled = isLoading || disabled; // Append speech to whatever is already typed, so voice and keyboard compose. const handleTranscript = useCallback( (text: string) => { if (!text) return; const base = question.trim(); onChange(base ? `${base} ${text}` : text); }, [onChange, question] ); const { supported, listening, interim, error, toggle } = useSpeechRecognition({ onTranscript: handleTranscript, }); return (