From 79a22c8a0315e1b419f280fe06e2f4c55c684c47 Mon Sep 17 00:00:00 2001 From: xintaofei Date: Wed, 11 Mar 2026 19:43:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E6=AD=A5=E6=94=AF=E6=8C=81AskUserQues?= =?UTF-8?q?tion=E4=BA=A4=E4=BA=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/chat/conversation-shell.tsx | 12 ++- src/components/chat/question-dialog.tsx | 86 +++++++++++++++++++ .../conversation-detail-panel.tsx | 32 +++++++ src/contexts/acp-connections-context.tsx | 85 +++++++++++++++++- src/hooks/use-connection.ts | 5 ++ src/i18n/messages/ar.json | 5 ++ src/i18n/messages/de.json | 5 ++ src/i18n/messages/en.json | 5 ++ src/i18n/messages/es.json | 5 ++ src/i18n/messages/fr.json | 5 ++ src/i18n/messages/ja.json | 5 ++ src/i18n/messages/ko.json | 5 ++ src/i18n/messages/pt.json | 5 ++ src/i18n/messages/zh-CN.json | 5 ++ src/i18n/messages/zh-TW.json | 5 ++ src/lib/tool-call-normalization.ts | 5 ++ 16 files changed, 273 insertions(+), 2 deletions(-) create mode 100644 src/components/chat/question-dialog.tsx 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} +

+ +
+