fix: handle undefined inputValue in ChatTextArea to prevent crash #10632
+14
−11
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related GitHub Issue
Closes: #10631
Description
This PR attempts to address Issue #10631 where Roo Code crashes when the Gemini gemini-flash-latest model returns blank/empty responses.
Root Cause: The error
TypeError: Cannot read properties of undefined (reading 'trim')occurs atChatTextArea.tsx:259wheninputValueisundefined. This happens when the Gemini model returns an empty/blank response, causing the parent component to passundefinedinstead of an empty string to theinputValueprop.Solution: Added defensive null/undefined checks using the nullish coalescing operator (
??) to defaultinputValueto an empty string in the following locations:hasInputContentmemo (line 259) - the crashing linehandleEnhancePromptcallback (line 245)handleKeyDownbackspace handler (lines 509-523)handlePastecallback (line 678)handleDropcallback (lines 823-842)This ensures the component gracefully handles
undefinedornullvalues by defaulting to an empty string, preventing the crash.Feedback and guidance are welcome.
Test Procedure
Pre-Submission Checklist
Documentation Updates
Additional Notes
This is a defensive fix that prevents the UI from crashing when receiving unexpected
undefinedvalues. The underlying issue of blank responses from the Gemini model may be a separate server-side or API configuration issue.Important
Fix crash in
ChatTextArea.tsxby handlingundefinedinputValuewith nullish coalescing to prevent errors.ChatTextArea.tsxby handlingundefinedinputValueusing nullish coalescing (??) to default to an empty string.hasInputContentmemo (line 259),handleEnhancePrompt(line 245),handleKeyDownbackspace handler (lines 509-523),handlePaste(line 678), andhandleDrop(lines 823-842).This description was created by
for 1918d9c. You can customize this summary. It will automatically update as commits are pushed.