Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions app/src/components/channels/chat-messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ export function toVisibleChatItems(

if (message.role !== "user") return [];

if (
typeof message.content !== "string" &&
!Array.isArray(message.content)
) {
return [];
}
const text =
typeof message.content === "string"
? message.content
Expand Down
12 changes: 12 additions & 0 deletions app/tests/chat-messages.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,16 @@ describe("toVisibleChatItems", () => {

expect(toVisibleChatItems([thinking])).toEqual([]);
});

test("drops a malformed live user turn instead of throwing", () => {
// Live turns bypass schema validation; one bad turn must not unmount the transcript.
for (const content of [undefined, null, 42] as unknown[]) {
const bad = {
id: "user-bad",
role: "user",
content,
} as unknown as Message;
expect(toVisibleChatItems([bad])).toEqual([]);
}
});
});