mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
fix: guard inputValue.trim() against undefined to prevent TypeError (#12304)
This commit is contained in:
parent
ad25634905
commit
d2b614e282
2 changed files with 6 additions and 6 deletions
|
|
@ -245,7 +245,7 @@ export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
|
|||
}, [selectedType, searchQuery])
|
||||
|
||||
const handleEnhancePrompt = useCallback(() => {
|
||||
const trimmedInput = inputValue.trim()
|
||||
const trimmedInput = (inputValue ?? "").trim()
|
||||
|
||||
if (trimmedInput) {
|
||||
setIsEnhancingPrompt(true)
|
||||
|
|
@ -259,7 +259,7 @@ export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
|
|||
|
||||
// Memoized check for whether the input has content (text or images)
|
||||
const hasInputContent = useMemo(() => {
|
||||
return inputValue.trim().length > 0 || selectedImages.length > 0
|
||||
return (inputValue ?? "").trim().length > 0 || selectedImages.length > 0
|
||||
}, [inputValue, selectedImages])
|
||||
|
||||
// Compute the key combination text for the send button tooltip based on enterBehavior
|
||||
|
|
|
|||
|
|
@ -203,7 +203,7 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
|
|||
|
||||
// Compute whether auto-approval is paused (user is typing in a followup)
|
||||
const isFollowUpAutoApprovalPaused = useMemo(() => {
|
||||
return !!(inputValue && inputValue.trim().length > 0 && clineAsk === "followup")
|
||||
return !!(inputValue && (inputValue ?? "").trim().length > 0 && clineAsk === "followup")
|
||||
}, [inputValue, clineAsk])
|
||||
|
||||
// Cancel auto-approval timeout when user starts typing
|
||||
|
|
@ -710,7 +710,7 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
|
|||
|
||||
// Handle enqueue button click from textarea
|
||||
const handleEnqueueCurrentMessage = useCallback(() => {
|
||||
const text = inputValue.trim()
|
||||
const text = (inputValue ?? "").trim()
|
||||
if (text || selectedImages.length > 0) {
|
||||
vscode.postMessage({
|
||||
type: "queueMessage",
|
||||
|
|
@ -1536,12 +1536,12 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
|
|||
|
||||
useImperativeHandle(ref, () => ({
|
||||
acceptInput: () => {
|
||||
const hasInput = inputValue.trim() || selectedImages.length > 0
|
||||
const hasInput = (inputValue ?? "").trim() || selectedImages.length > 0
|
||||
|
||||
// Special case: during command_output, queue the message instead of
|
||||
// triggering the primary button action (which would lose the message)
|
||||
if (clineAskRef.current === "command_output" && hasInput) {
|
||||
vscode.postMessage({ type: "queueMessage", text: inputValue.trim(), images: selectedImages })
|
||||
vscode.postMessage({ type: "queueMessage", text: (inputValue ?? "").trim(), images: selectedImages })
|
||||
setInputValue("")
|
||||
setSelectedImages([])
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue