diff --git a/.changeset/swift-views-scream.md b/.changeset/swift-views-scream.md new file mode 100644 index 000000000..701fd39ab --- /dev/null +++ b/.changeset/swift-views-scream.md @@ -0,0 +1,5 @@ +--- +"kimi-code": patch +--- + +multi-select question jumps to next after only one answer selected diff --git a/apps/vscode/webview-ui/src/components/QuestionDialog.tsx b/apps/vscode/webview-ui/src/components/QuestionDialog.tsx index c4919269a..c5f2e46fd 100644 --- a/apps/vscode/webview-ui/src/components/QuestionDialog.tsx +++ b/apps/vscode/webview-ui/src/components/QuestionDialog.tsx @@ -9,9 +9,12 @@ export function QuestionDialog() { const [selectedIndex, setSelectedIndex] = useState(1); const [questionIndex, setQuestionIndex] = useState(0); const [answers, setAnswers] = useState>({}); + const [multiSelected, setMultiSelected] = useState([]); const questions = pendingQuestion?.questions ?? []; const question = questions[questionIndex]; + const isMultiSelect = question?.multi_select === true; + const isLastQuestion = questionIndex + 1 >= questions.length; useEffect(() => { if (pendingQuestion) { @@ -20,6 +23,7 @@ export function QuestionDialog() { setSelectedIndex(1); setQuestionIndex(0); setAnswers({}); + setMultiSelected([]); } }, [pendingQuestion?.id]); @@ -28,28 +32,43 @@ export function QuestionDialog() { // 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) { + if (!isLastQuestion) { setAnswers(nextAnswers); setQuestionIndex(questionIndex + 1); setShowCustom(false); setCustomInput(""); setSelectedIndex(1); + setMultiSelected([]); } else { await respondQuestion(nextAnswers); } }; const handleSelect = async (optionLabel: string) => { + if (isMultiSelect) { + setMultiSelected((prev) => + prev.includes(optionLabel) ? prev.filter((value) => value !== optionLabel) : [...prev, optionLabel], + ); + return; + } await handleAnswer(optionLabel); }; const handleCustomSubmit = async () => { - if (!customInput.trim()) return; - await handleAnswer(customInput.trim()); + const value = customInput.trim(); + if (!value) return; + if (isMultiSelect) { + setMultiSelected((prev) => (prev.includes(value) ? prev : [...prev, value])); + setCustomInput(""); + setShowCustom(false); + return; + } + await handleAnswer(value); }; const options = question.options || []; const customIndex = options.length + 1; + const customValues = multiSelected.filter((value) => !options.some((option) => option.label === value)); return (
@@ -61,25 +80,51 @@ export function QuestionDialog() { )} {question.header &&
{question.header}
}
{question.question}
+ {isMultiSelect &&
Select all that apply
}
- {options.map((option, idx) => ( + {options.map((option, idx) => { + const isChecked = isMultiSelect && multiSelected.includes(option.label); + const isHighlighted = selectedIndex === idx + 1; + return ( + + ); + })} + {customValues.map((value) => ( ))} {showCustom ? ( @@ -119,6 +164,17 @@ export function QuestionDialog() { Custom response... )} + {isMultiSelect && ( + + )}