Open-source AI coworkers that each get a computer of their own: a browser, files and tools, with every action decided before it happens and recorded after. Bring any AG-UI agent.
fix(chat): drop malformed user content instead of throwing (#359)
Felix-Ayush54f937f463a8
diff --git a/app/src/components/channels/chat-messages.ts b/app/src/components/channels/chat-messages.tsindex 7dce9acf..c12273bb 100644--- a/app/src/components/channels/chat-messages.ts+++ b/app/src/components/channels/chat-messages.ts@@ -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.contentdiff --git a/app/tests/chat-messages.test.ts b/app/tests/chat-messages.test.tsindex b637c3ec..028c18a7 100644--- a/app/tests/chat-messages.test.ts+++ b/app/tests/chat-messages.test.ts@@ -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([]);+ }+ });});