From 4097637169335afed795f27395e1fd96c9bc5525 Mon Sep 17 00:00:00 2001 From: Shantur Rathore Date: Sat, 7 Feb 2026 22:08:38 +0000 Subject: [PATCH] fix(ui): preserve question custom input on refocus --- packages/ui/src/components/tool-call/question-block.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/ui/src/components/tool-call/question-block.tsx b/packages/ui/src/components/tool-call/question-block.tsx index cea79806..75544190 100644 --- a/packages/ui/src/components/tool-call/question-block.tsx +++ b/packages/ui/src/components/tool-call/question-block.tsx @@ -132,9 +132,16 @@ export function QuestionToolBlock(props: QuestionToolBlockProps) { if (!multi) { // When switching a radio to custom, clear existing selection first. updateAnswer(questionIndex, []) + toggleOption(questionIndex, value) + return } - toggleOption(questionIndex, value) + // For multi-select, focusing the input should never toggle an existing custom value off. + // Ensure the current input value is selected; removal is handled by unchecking Custom. + const existing = answers()[questionIndex] ?? [] + if (!existing.includes(value)) { + updateAnswer(questionIndex, [...existing, value]) + } } const clearCustomAnswer = (questionIndex: number, valuesToRemove: string[]) => {