Description
In app/src/components/channels/chat-messages.ts, the toVisibleChatItems function assumes that any non-string message.content is an array of InputContent objects and calls .filter() directly:
const text =
typeof message.content === "string"
? message.content
: message.content
.filter((part) => part.type === "text")
.map((part) => part.text)
.join("\n");
If message.content is undefined, null, or an unexpected object format (e.g. from partial streaming events, custom assistant/system payloads, or deserialized messages), calling .filter() throws an unhandled TypeError: Cannot read
properties of undefined (reading 'filter').
This crashes the React component tree and blanks the chat transcript for the user.
Steps to Reproduce
- Receive or restore a user message where content is undefined, null, or non-array.
- Render ChatTranscript or call toVisibleChatItems([message]).
- The component throws an unhandled TypeError during render.
Expected Behavior
toVisibleChatItems should safely handle non-array and malformed message.content values without throwing, falling back to an empty string.
Proposed Solution
- Add an Array.isArray(message.content) check before attempting to filter content parts.
- Ensure array elements are validated as { type: "text", text: string } objects before accessing .text.
- Add unit test coverage in app/tests/chat-messages.test.ts.
Description
In app/src/components/channels/chat-messages.ts, the toVisibleChatItems function assumes that any non-string message.content is an array of InputContent objects and calls .filter() directly:
If message.content is undefined, null, or an unexpected object format (e.g. from partial streaming events, custom assistant/system payloads, or deserialized messages), calling .filter() throws an unhandled TypeError: Cannot read
properties of undefined (reading 'filter').
This crashes the React component tree and blanks the chat transcript for the user.
Steps to Reproduce
Expected Behavior
toVisibleChatItems should safely handle non-array and malformed message.content values without throwing, falling back to an empty string.
Proposed Solution