Skip to content

Commit ffa325d

Browse files
committed
fix: preserve user input when selecting follow-up choices
When users typed a message at a choice prompt and selected a follow-up suggestion, their typed message was being cleared and lost. This fix preserves the user's input value after sending the follow-up choice message, ensuring the text area retains what the user typed. Fixes #7316
1 parent 2e99d5b commit ffa325d

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

webview-ui/src/components/chat/ChatView.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1493,10 +1493,23 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
14931493
return currentValue !== "" ? `${currentValue} \n${suggestion.answer}` : suggestion.answer
14941494
})
14951495
} else {
1496+
// Don't clear the input value when sending a follow-up choice
1497+
// The message should be sent but the text area should preserve what the user typed
1498+
const preservedInput = inputValue
14961499
handleSendMessage(suggestion.answer, [])
1500+
// Restore the input value after sending
1501+
setInputValue(preservedInput)
14971502
}
14981503
},
1499-
[handleSendMessage, setInputValue, switchToMode, alwaysAllowModeSwitch, clineAsk, markFollowUpAsAnswered],
1504+
[
1505+
handleSendMessage,
1506+
setInputValue,
1507+
switchToMode,
1508+
alwaysAllowModeSwitch,
1509+
clineAsk,
1510+
markFollowUpAsAnswered,
1511+
inputValue,
1512+
],
15001513
)
15011514

15021515
const handleBatchFileResponse = useCallback((response: { [key: string]: boolean }) => {

0 commit comments

Comments
 (0)