Kaynağa Gözat

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 <[email protected]>
roomote[bot] 1 gün önce
ebeveyn
işleme
586cf47fb2
1 değiştirilmiş dosya ile 1 ekleme ve 1 silme
  1. 1 1
      webview-ui/src/components/chat/ChatView.tsx

+ 1 - 1
webview-ui/src/components/chat/ChatView.tsx

@@ -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