Skip to content
Merged
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) {
Comment on lines +29 to +31

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve multi-select answers before advancing

When a batched AskUserQuestion has a later item with multi_select: true, this new step-through path still routes every click through a single handleAnswer call and immediately advances or responds. Because the VS Code bridge passes multi_select through, valid batches like single-select Q1 plus multi-select Q2 will submit only the first clicked Q2 label and give the user no way to pick the remaining options, so the agent receives an incomplete answer. Keep per-question multi-selection state and advance only after an explicit submit for those items.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Valid symptom, but for the record: the dialog has never supported multi_select — before this PR a multi-select first question behaved exactly the same (first click submitted immediately), so this isn't introduced by the step-through path. Keeping this PR minimal to fix #2299 (later questions not answerable at all). Multi-select support is tracked in #2463, together with a planned single-form redesign.

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
Loading