@@ -166,6 +166,7 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
166166 const apiMetrics = useMemo ( ( ) => getApiMetrics ( modifiedMessages ) , [ modifiedMessages ] )
167167
168168 const [ inputValue , setInputValue ] = useState ( "" )
169+ const inputValueRef = useRef ( inputValue )
169170 const textAreaRef = useRef < HTMLTextAreaElement > ( null )
170171 const [ sendingDisabled , setSendingDisabled ] = useState ( false )
171172 const [ selectedImages , setSelectedImages ] = useState < string [ ] > ( [ ] )
@@ -207,6 +208,11 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
207208 clineAskRef . current = clineAsk
208209 } , [ clineAsk ] )
209210
211+ // Keep inputValueRef in sync with inputValue state
212+ useEffect ( ( ) => {
213+ inputValueRef . current = inputValue
214+ } , [ inputValue ] )
215+
210216 useEffect ( ( ) => {
211217 isMountedRef . current = true
212218 return ( ) => {
@@ -1493,7 +1499,12 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
14931499 return currentValue !== "" ? `${ currentValue } \n${ suggestion . answer } ` : suggestion . answer
14941500 } )
14951501 } else {
1502+ // Don't clear the input value when sending a follow-up choice
1503+ // The message should be sent but the text area should preserve what the user typed
1504+ const preservedInput = inputValueRef . current
14961505 handleSendMessage ( suggestion . answer , [ ] )
1506+ // Restore the input value after sending
1507+ setInputValue ( preservedInput )
14971508 }
14981509 } ,
14991510 [ handleSendMessage , setInputValue , switchToMode , alwaysAllowModeSwitch , clineAsk , markFollowUpAsAnswered ] ,
0 commit comments