Skip to content

Commit 491abe4

Browse files
committed
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"
1 parent 3074ccc commit 491abe4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1016,7 +1016,7 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
10161016
// labeled as `user_feedback`.
10171017
if (lastMessage && messages.length > 1) {
10181018
if (
1019-
lastMessage.text && // has text
1019+
typeof lastMessage.text === "string" && // has text (must be string for startsWith)
10201020
(lastMessage.say === "text" || lastMessage.say === "completion_result") && // is a text message
10211021
!lastMessage.partial && // not a partial message
10221022
!lastMessage.text.startsWith("{") // not a json object

0 commit comments

Comments
 (0)