Add image and PDF attachment support with drag-drop and paste

This commit is contained in:
Chris Scott committed 2025-12-28 22:52:16 -05:00
1 parent cc04cb073c
commit d7873241e0
6 files changed
+227 -46

No files matched your search

+25 -8
View File
@@ -144,6 +144,16 @@ const createOptimisticUserMessage = (
messageID: optimisticID,
sessionID,
};
} else if (part.type === "image") {
return {
id: `${optimisticID}_part_${index}`,
type: "file" as const,
filename: part.filename,
url: part.dataUrl,
mime: part.mime,
messageID: optimisticID,
sessionID,
};
} else {
return {
id: `${optimisticID}_part_${index}`,
@@ -205,14 +215,21 @@ export const useSendPrompt = (opcodeUrl: string | null | undefined, directory?:
parts: parts?.map((part) =>
part.type === "text"
? { type: "text", text: part.content }
: {
type: "file",
mime: "text/plain",
filename: part.name,
url: part.path.startsWith("file:")
? part.path
: `file://${part.path}`,
},
: part.type === "image"
? {
type: "file",
mime: part.mime,
filename: part.filename,
url: part.dataUrl,
}
: {
type: "file",
mime: "text/plain",
filename: part.name,
url: part.path.startsWith("file:")
? part.path
: `file://${part.path}`,
},
) || [{ type: "text", text: prompt || "" }],
};