Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Jan 1, 2026

This PR attempts to address Issue #10430.

Problem

The TTS (text-to-speech) useEffect in ChatView.tsx was crashing with TypeError: Q.text.startsWith is not a function because it only checked if lastMessage.text was truthy before calling .startsWith(). If text was a non-string truthy value (array, object, or number), this would throw an error.

Solution

Changed line 1019 from a truthy check to an explicit type check:

- lastMessage.text && // has text
+ typeof lastMessage.text === "string" && // has text (must be string for startsWith)

This ensures .startsWith() will only be called on actual string values.

Testing

  • All 23 existing ChatView tests pass
  • TypeScript compilation passes

Feedback and guidance are welcome.


Important

Fixes TypeError in ChatView.tsx by ensuring lastMessage.text is a string before calling .startsWith().

  • Behavior:
    • Fixes TypeError in useEffect in ChatView.tsx by changing lastMessage.text check from truthy to typeof lastMessage.text === "string".
    • Ensures .startsWith() is only called on strings, preventing crashes when text is non-string.
  • Testing:
    • All 23 existing ChatView tests pass.
    • TypeScript compilation passes.

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

Fixes #10430

The TTS useEffect was calling .startsWith() on lastMessage.text after only
checking if it was truthy. If text was a non-string truthy value (array,
object, or number), this would crash with "Q.text.startsWith is not a function".

Changed the truthy check to an explicit type check: typeof lastMessage.text === "string"
@roomote
Copy link
Contributor Author

roomote bot commented Jan 1, 2026

Rooviewer Clock   See task on Roo Cloud

Review complete. No issues found.

The change from a truthy check to an explicit typeof lastMessage.text === "string" check is a valid defensive programming fix that protects against runtime type violations when calling .startsWith() on the TTS message text.

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

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jan 1, 2026
@mrubens mrubens marked this pull request as ready for review January 1, 2026 23:05
@mrubens mrubens requested review from cte and jr as code owners January 1, 2026 23:05
@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. bug Something isn't working labels Jan 1, 2026
@roomote
Copy link
Contributor Author

roomote bot commented Jan 1, 2026

Rooviewer Clock   See task on Roo Cloud

Review complete. No issues found.

The change from a truthy check to an explicit typeof lastMessage.text === "string" check is a valid defensive programming fix that protects against runtime type violations when calling .startsWith() on the TTS message text.

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

@mrubens mrubens merged commit 586cf47 into main Jan 1, 2026
28 checks passed
@mrubens mrubens deleted the fix/10430-tts-type-check branch January 1, 2026 23:11
@github-project-automation github-project-automation bot moved this from Triage to Done in Roo Code Roadmap Jan 1, 2026
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Jan 1, 2026
@roomote roomote bot mentioned this pull request Jan 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working lgtm This PR has been approved by a maintainer size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants