Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/vscode-question-dialog-multi-answers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"kimi-code": patch
---

Fix only the first question being answerable when the agent asked multiple questions at once; each question is now answered one by one and submitted together.
37 changes: 27 additions & 10 deletions apps/vscode/webview-ui/src/components/QuestionDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,45 @@ export function QuestionDialog() {
const [customInput, setCustomInput] = useState("");
const [showCustom, setShowCustom] = useState(false);
const [selectedIndex, setSelectedIndex] = useState(1);
const [questionIndex, setQuestionIndex] = useState(0);
const [answers, setAnswers] = useState<Record<string, string>>({});

// For now, only handle the first question
const question = pendingQuestion?.questions?.[0];
const questions = pendingQuestion?.questions ?? [];
const question = questions[questionIndex];

useEffect(() => {
if (pendingQuestion) {
setShowCustom(false);
setCustomInput("");
setSelectedIndex(1);
setQuestionIndex(0);
setAnswers({});
}
}, [pendingQuestion?.id]);

if (!pendingQuestion || !question) return null;

// Step through the questions one by one; submit all answers after the last.
const handleAnswer = async (answer: string) => {
const nextAnswers = { ...answers, [question.question]: answer };
if (questionIndex + 1 < questions.length) {
setAnswers(nextAnswers);
setQuestionIndex(questionIndex + 1);
setShowCustom(false);
setCustomInput("");
setSelectedIndex(1);
} else {
await respondQuestion(nextAnswers);
}
};

const handleSelect = async (optionLabel: string) => {
const answers: Record<string, string> = {
[question.question]: optionLabel,
};
await respondQuestion(answers);
await handleAnswer(optionLabel);
};

const handleCustomSubmit = async () => {
if (!customInput.trim()) return;
const answers: Record<string, string> = {
[question.question]: customInput.trim(),
};
await respondQuestion(answers);
await handleAnswer(customInput.trim());
};

const options = question.options || [];
Expand All @@ -42,6 +54,11 @@ export function QuestionDialog() {
return (
<div className={cn("mb-0.5 border border-blue-200 dark:border-blue-800 rounded-lg overflow-hidden bg-background flex flex-col shrink")}>
<div className="p-2 space-y-2">
{questions.length > 1 && (
<div className="text-[10px] text-muted-foreground">
Question {questionIndex + 1} of {questions.length}
</div>
)}
{question.header && <div className="text-[10px] text-muted-foreground uppercase tracking-wide">{question.header}</div>}
<div className="text-xs font-semibold text-foreground">{question.question}</div>
<div className="space-y-1.5">
Expand Down