mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-05 08:10:14 +00:00
fix: preserve user input when selecting follow-up choices (#7394)
This commit is contained in:
parent
c75f184022
commit
91f3dd90fb
1 changed files with 11 additions and 0 deletions
|
|
@ -166,6 +166,7 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
|
|||
const apiMetrics = useMemo(() => getApiMetrics(modifiedMessages), [modifiedMessages])
|
||||
|
||||
const [inputValue, setInputValue] = useState("")
|
||||
const inputValueRef = useRef(inputValue)
|
||||
const textAreaRef = useRef<HTMLTextAreaElement>(null)
|
||||
const [sendingDisabled, setSendingDisabled] = useState(false)
|
||||
const [selectedImages, setSelectedImages] = useState<string[]>([])
|
||||
|
|
@ -207,6 +208,11 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
|
|||
clineAskRef.current = clineAsk
|
||||
}, [clineAsk])
|
||||
|
||||
// Keep inputValueRef in sync with inputValue state
|
||||
useEffect(() => {
|
||||
inputValueRef.current = inputValue
|
||||
}, [inputValue])
|
||||
|
||||
useEffect(() => {
|
||||
isMountedRef.current = true
|
||||
return () => {
|
||||
|
|
@ -1493,7 +1499,12 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
|
|||
return currentValue !== "" ? `${currentValue} \n${suggestion.answer}` : suggestion.answer
|
||||
})
|
||||
} else {
|
||||
// Don't clear the input value when sending a follow-up choice
|
||||
// The message should be sent but the text area should preserve what the user typed
|
||||
const preservedInput = inputValueRef.current
|
||||
handleSendMessage(suggestion.answer, [])
|
||||
// Restore the input value after sending
|
||||
setInputValue(preservedInput)
|
||||
}
|
||||
},
|
||||
[handleSendMessage, setInputValue, switchToMode, alwaysAllowModeSwitch, clineAsk, markFollowUpAsAnswered],
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue