From 586cf47fb2d5bafd62906ba19b9448a744be89c6 Mon Sep 17 00:00:00 2001 From: "roomote[bot]" <219738659+roomote[bot]@users.noreply.github.com> Date: Thu, 1 Jan 2026 15:11:15 -0800 Subject: [PATCH] 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 --- webview-ui/src/components/chat/ChatView.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webview-ui/src/components/chat/ChatView.tsx b/webview-ui/src/components/chat/ChatView.tsx index b358abaaa8..6f3ee16ec1 100644 --- a/webview-ui/src/components/chat/ChatView.tsx +++ b/webview-ui/src/components/chat/ChatView.tsx @@ -1016,7 +1016,7 @@ const ChatViewComponent: React.ForwardRefRenderFunction 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