diff --git a/canvas/src/components/tabs/chat/types.ts b/canvas/src/components/tabs/chat/types.ts index a03cb4599..f5629c311 100644 --- a/canvas/src/components/tabs/chat/types.ts +++ b/canvas/src/components/tabs/chat/types.ts @@ -26,13 +26,16 @@ export function createMessage( content: string, attachments?: ChatAttachment[], ): ChatMessage { - return { + const base = { id: crypto.randomUUID(), role, content, - attachments: attachments && attachments.length > 0 ? attachments : undefined, timestamp: new Date().toISOString(), }; + if (attachments && attachments.length > 0) { + return Object.freeze({ ...base, attachments }); + } + return Object.freeze(base); } // appendMessageDeduped adds a ChatMessage to `prev` unless the tail