diff --git a/ui/goose2/src/features/chat/lib/__tests__/attachments.test.ts b/ui/goose2/src/features/chat/lib/__tests__/attachments.test.ts index 2e15253035..9e5583eaa4 100644 --- a/ui/goose2/src/features/chat/lib/__tests__/attachments.test.ts +++ b/ui/goose2/src/features/chat/lib/__tests__/attachments.test.ts @@ -121,4 +121,30 @@ describe("rebuildAttachmentDrafts", () => { expect(drafts[0].kind).toBe("file"); expect(drafts[0].name).toBe("photo.jpg"); }); + + it("preserves pathless browser-uploaded file attachments", () => { + const msg: Message = { + id: "m4", + role: "user", + created: Date.now(), + content: [{ type: "text", text: "see attached" }], + metadata: { + userVisible: true, + agentVisible: true, + attachments: [ + { + type: "file", + name: "report.pdf", + mimeType: "application/pdf", + }, + ], + }, + }; + + const drafts = rebuildAttachmentDrafts(msg); + + expect(drafts).toHaveLength(1); + expect(drafts[0].kind).toBe("file"); + expect(drafts[0].name).toBe("report.pdf"); + }); }); diff --git a/ui/goose2/src/features/chat/lib/attachments.ts b/ui/goose2/src/features/chat/lib/attachments.ts index c102a88d02..0358e94800 100644 --- a/ui/goose2/src/features/chat/lib/attachments.ts +++ b/ui/goose2/src/features/chat/lib/attachments.ts @@ -112,14 +112,14 @@ export function rebuildAttachmentDrafts( name: att.name, path: att.path, }); - } else if (att.type === "file" && att.path) { + } else if (att.type === "file") { // Skip image file entries when content blocks already provide the base64 if (hasImageDrafts && att.mimeType?.startsWith("image/")) continue; drafts.push({ id: crypto.randomUUID(), kind: "file", name: att.name, - path: att.path, + ...(att.path ? { path: att.path } : {}), mimeType: att.mimeType, }); }