Compare commits

...

1 Commits

Author SHA1 Message Date
fullstack-engineer 1e93c74456 fix(chat): omit attachments key from createMessage when no files provided
sop-tier-check / tier-check (pull_request) Successful in 13s
sop-checklist-gate / gate (pull_request) Successful in 13s
sop-checklist / all-items-acked (pull_request) [info tier:low] acked: 0/7 — missing: comprehensive-testing, local-postgres-e2e, staging-smoke, +4 — body-unfilled: comprehensive-testing, l
audit-force-merge / audit (pull_request) Has been skipped
Object.keys({ attachments: undefined }) still includes "attachments" as a
key, breaking the "returns a plain object with expected keys" test. Fix by
conditionally spreading attachments only when non-empty, and Object.freeze
the return value to preserve the existing immutability assertion.

Fixes 2 test cases in createMessage.test.ts.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-13 11:20:48 +00:00
+5 -2
View File
@@ -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