diff --git a/src/components/chat/conversation-shell.tsx b/src/components/chat/conversation-shell.tsx index ce0761a..622e9c9 100644 --- a/src/components/chat/conversation-shell.tsx +++ b/src/components/chat/conversation-shell.tsx @@ -7,9 +7,13 @@ import type { SessionModeInfo, AvailableCommandInfo, } from "@/lib/types" -import type { PendingPermission } from "@/contexts/acp-connections-context" +import type { + PendingPermission, + PendingQuestion, +} from "@/contexts/acp-connections-context" import { ChatInput } from "@/components/chat/chat-input" import { PermissionDialog } from "@/components/chat/permission-dialog" +import { QuestionDialog } from "@/components/chat/question-dialog" interface ConversationShellProps { status: ConnectionStatus | null @@ -17,10 +21,12 @@ interface ConversationShellProps { defaultPath?: string error: string | null pendingPermission: PendingPermission | null + pendingQuestion: PendingQuestion | null onFocus: () => void onSend: (draft: PromptDraft, modeId?: string | null) => void onCancel: () => void onRespondPermission: (requestId: string, optionId: string) => void + onAnswerQuestion: (answer: string) => void children: ReactNode modes?: SessionModeInfo[] configOptions?: SessionConfigOptionInfo[] @@ -42,10 +48,12 @@ export function ConversationShell({ defaultPath, error, pendingPermission, + pendingQuestion, onFocus, onSend, onCancel, onRespondPermission, + onAnswerQuestion, children, modes, configOptions, @@ -69,6 +77,8 @@ export function ConversationShell({ onRespond={onRespondPermission} /> + + {!hideInput && ( void +} + +export function QuestionDialog({ question, onAnswer }: QuestionDialogProps) { + const t = useTranslations("Folder.chat.questionDialog") + const [answer, setAnswer] = useState("") + const textareaRef = useRef(null) + const prevQuestionIdRef = useRef(null) + + const questionId = question?.tool_call_id ?? null + if (questionId !== prevQuestionIdRef.current) { + prevQuestionIdRef.current = questionId + if (questionId && answer !== "") { + setAnswer("") + } + } + + useEffect(() => { + if (question) { + textareaRef.current?.focus() + } + }, [question]) + + const handleSubmit = useCallback(() => { + const trimmed = answer.trim() + if (!trimmed) return + onAnswer(trimmed) + setAnswer("") + }, [answer, onAnswer]) + + const handleKeyDown = useCallback( + (e: React.KeyboardEvent) => { + if (e.key === "Enter" && !e.shiftKey) { + e.preventDefault() + handleSubmit() + } + }, + [handleSubmit] + ) + + if (!question) return null + + return ( +
+
+ + {t("title")} +
+ +

+ {question.question} +

+ +
+