diff --git a/packages/elements/src/prompt-input.tsx b/packages/elements/src/prompt-input.tsx index ae522f8..f00cbac 100644 --- a/packages/elements/src/prompt-input.tsx +++ b/packages/elements/src/prompt-input.tsx @@ -75,7 +75,7 @@ import { // ============================================================================ export type AttachmentsContext = { - files: (FileUIPart & { id: string })[]; + files: (FileUIPart & { id: string, file: File })[]; add: (files: File[] | FileList) => void; remove: (id: string) => void; clear: () => void; @@ -151,7 +151,7 @@ export function PromptInputProvider({ // ----- attachments state (global when wrapped) const [attachements, setAttachements] = useState< - (FileUIPart & { id: string })[] + (FileUIPart & { id: string, file: File })[] >([]); const fileInputRef = useRef(null); const openRef = useRef<() => void>(() => {}); @@ -170,6 +170,7 @@ export function PromptInputProvider({ url: URL.createObjectURL(file), mediaType: file.type, filename: file.name, + file, })) ) ); @@ -471,7 +472,7 @@ export const PromptInput = ({ }, []); // ----- Local attachments (only used when no provider) - const [items, setItems] = useState<(FileUIPart & { id: string })[]>([]); + const [items, setItems] = useState<(FileUIPart & { id: string; file: File })[]>([]); const files = usingProvider ? controller.attachments.files : items; const openFileDialogLocal = useCallback(() => { @@ -527,7 +528,7 @@ export const PromptInput = ({ message: "Too many files. Some were not added.", }); } - const next: (FileUIPart & { id: string })[] = []; + const next: (FileUIPart & { id: string, file: File })[] = []; for (const file of capped) { next.push({ id: nanoid(), @@ -535,6 +536,7 @@ export const PromptInput = ({ url: URL.createObjectURL(file), mediaType: file.type, filename: file.name, + file, }); } return prev.concat(next);