import { useCallback, useEffect, useRef, useState } from "react"; import { MessageSquareText } from "lucide-react"; import { Button } from "@/components/ui/button"; import { cn } from "@/lib/utils"; interface AskUserPromptProps { question: string; buttons: string[][]; onAnswer: (answer: string) => void; } export function AskUserPrompt({ question, buttons, onAnswer, }: AskUserPromptProps) { const [customOpen, setCustomOpen] = useState(false); const [custom, setCustom] = useState(""); const inputRef = useRef(null); const options = buttons.flat().filter(Boolean); useEffect(() => { if (customOpen) { inputRef.current?.focus(); } }, [customOpen]); const submitCustom = useCallback(() => { const answer = custom.trim(); if (!answer) return; onAnswer(answer); setCustom(""); setCustomOpen(false); }, [custom, onAnswer]); if (options.length === 0) return null; return (

{question}

{options.map((option) => ( ))}
{customOpen ? (