mirror of
https://github.com/aaif-goose/goose.git
synced 2026-07-03 14:10:03 +02:00
fix: preserve pathless browser-uploaded file attachments on retry/edit
This commit is contained in:
@@ -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");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user