fix: add type check for lastMessage.text in TTS useEffect (#10431)

fix: add type check for lastMessage.text before calling startsWith

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"

Co-authored-by: Roo Code <roomote@roocode.com>
This commit is contained in:
roomote[bot] 2026-01-01 15:11:15 -08:00 committed by GitHub
parent 3074ccc278
commit 586cf47fb2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1016,7 +1016,7 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
// labeled as `user_feedback`.
if (lastMessage && messages.length > 1) {
if (
lastMessage.text && // has text
typeof lastMessage.text === "string" && // has text (must be string for startsWith)
(lastMessage.say === "text" || lastMessage.say === "completion_result") && // is a text message
!lastMessage.partial && // not a partial message
!lastMessage.text.startsWith("{") // not a json object