From d2b614e2823c7d9166fa40c4a06ffba46c49691f Mon Sep 17 00:00:00 2001 From: Roo Code Date: Sat, 9 May 2026 12:18:48 +0000 Subject: [PATCH] fix: guard inputValue.trim() against undefined to prevent TypeError (#12304) --- webview-ui/src/components/chat/ChatTextArea.tsx | 4 ++-- webview-ui/src/components/chat/ChatView.tsx | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/webview-ui/src/components/chat/ChatTextArea.tsx b/webview-ui/src/components/chat/ChatTextArea.tsx index e72c1726f35..652e50bc5d4 100644 --- a/webview-ui/src/components/chat/ChatTextArea.tsx +++ b/webview-ui/src/components/chat/ChatTextArea.tsx @@ -245,7 +245,7 @@ export const ChatTextArea = forwardRef( }, [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( // 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 diff --git a/webview-ui/src/components/chat/ChatView.tsx b/webview-ui/src/components/chat/ChatView.tsx index 7008dbe590d..04e511c9352 100644 --- a/webview-ui/src/components/chat/ChatView.tsx +++ b/webview-ui/src/components/chat/ChatView.tsx @@ -203,7 +203,7 @@ const ChatViewComponent: React.ForwardRefRenderFunction { - 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 { - 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 ({ 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