Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Jan 12, 2026

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 at ChatTextArea.tsx:259 when inputValue is undefined. This happens when the Gemini model returns an empty/blank response, causing the parent component to pass undefined instead of an empty string to the inputValue prop.

Solution: Added defensive null/undefined checks using the nullish coalescing operator (??) to default inputValue to an empty string in the following locations:

  • hasInputContent memo (line 259) - the crashing line
  • handleEnhancePrompt callback (line 245)
  • handleKeyDown backspace handler (lines 509-523)
  • handlePaste callback (line 678)
  • handleDrop callback (lines 823-842)

This ensures the component gracefully handles undefined or null values by defaulting to an empty string, preventing the crash.

Feedback and guidance are welcome.

Test Procedure

  1. Configure Google Gemini with gemini-flash-latest model
  2. Send a simple "Hi" message
  3. Verify that Roo Code no longer crashes when receiving blank responses
  4. The follow-up responses may still be blank (server-side issue), but the UI should not crash

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Documentation Updates

  • No documentation updates are required.

Additional Notes

This is a defensive fix that prevents the UI from crashing when receiving unexpected undefined values. 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.tsx by handling undefined inputValue with nullish coalescing to prevent errors.

  • Behavior:
    • Fix crash in ChatTextArea.tsx by handling undefined inputValue using nullish coalescing (??) to default to an empty string.
    • Affects hasInputContent memo (line 259), handleEnhancePrompt (line 245), handleKeyDown backspace handler (lines 509-523), handlePaste (line 678), and handleDrop (lines 823-842).
  • Testing:
    • Verify no crash when receiving blank responses from Gemini model.
    • UI should remain stable even if responses are blank.

This description was created by Ellipsis for 1918d9c. You can customize this summary. It will automatically update as commits are pushed.

Add defensive null/undefined checks using nullish coalescing operator
to handle cases where inputValue is undefined, such as when Gemini
model returns blank responses.

Fixes #10631
@roomote
Copy link
Contributor Author

roomote bot commented Jan 12, 2026

Rooviewer Clock   See task on Roo Cloud

Review complete. No issues found.

The defensive null/undefined checks using nullish coalescing (??) are correctly applied to all locations where inputValue is used with string methods. The fix appropriately addresses the crash reported in #10631.

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Jan 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels.

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

[bug] Selecting blank ask followup question causes crash

3 participants