fix(apps/kimi-code): allow deselecting Other option in multi-select question dialog (#2810)

This commit is contained in:
HydrogenE7 2026-08-11 19:55:13 +08:00 committed by GitHub
parent 860354976e
commit 64abebc95a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 47 additions and 0 deletions

View file

@ -0,0 +1,5 @@
---
"@moonshot-ai/kimi-code": patch
---
Fix multi-select "Other" options so they can be deselected after being committed.

View file

@ -299,6 +299,12 @@ export class QuestionDialogComponent extends Container implements Focusable {
this.reviewMessage = undefined;
if (this.isOtherOption(questionIdx, optionIdx)) {
if (question.multi_select && this.multiSelections[questionIdx]?.has(optionIdx)) {
this.multiSelections[questionIdx].delete(optionIdx);
this.lastAnswerMethod = method;
this.updateAnswer(questionIdx);
return;
}
this.enterOtherInput(questionIdx);
return;
}

View file

@ -394,6 +394,42 @@ describe('QuestionDialogComponent', () => {
expect(out).toContain('Mushroom');
});
it('multi-select Other can be toggled off after it is committed', () => {
const pending = makePending([
{
question: 'Pick toppings?',
multi_select: true,
options: [{ label: 'Cheese' }, { label: 'Pepperoni' }],
},
]);
const { dialog, collected } = makeDialog(pending);
// Select Other and commit a custom value.
dialog.handleInput('3');
dialog.handleInput('M');
dialog.handleInput('u');
dialog.handleInput('s');
dialog.handleInput('h');
dialog.handleInput('r');
dialog.handleInput('o');
dialog.handleInput('o');
dialog.handleInput('m');
dialog.handleInput('\r');
// Toggle it off using the same key.
dialog.handleInput('3');
// Select a preset option to confirm the answer still builds correctly.
dialog.handleInput('1');
dialog.handleInput('\t');
const review = strip(dialog.render(80).join('\n'));
expect(review).toContain('Cheese');
expect(review).not.toContain('Mushroom');
dialog.handleInput('1');
expect(collected).toEqual([['Cheese']]);
});
it('escape dismisses with empty answers array', () => {
const pending = makePending([
{