From 1a3e16420968b0e92919f645e803ce149280a1c7 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 10 Mar 2026 01:21:46 +0000 Subject: [PATCH] fix: add null check for inputValue in ChatTextArea The inputValue prop could be undefined when the component renders, causing a crash when calling .trim() on it. Added defensive null checks using fallback to empty string. --- webview-ui/src/components/chat/ChatTextArea.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webview-ui/src/components/chat/ChatTextArea.tsx b/webview-ui/src/components/chat/ChatTextArea.tsx index e72c1726f35..25a2f239083 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