diff --git a/client/src/components/Prompts/Groups/CreatePromptForm.tsx b/client/src/components/Prompts/Groups/CreatePromptForm.tsx index acddce7bcf..2a618923fd 100644 --- a/client/src/components/Prompts/Groups/CreatePromptForm.tsx +++ b/client/src/components/Prompts/Groups/CreatePromptForm.tsx @@ -44,7 +44,6 @@ const CreatePromptForm = ({ promptFiles: files, setFiles, handleFileChange, - handleFileRemove, getToolResources, } = usePromptFileHandling(); @@ -184,7 +183,6 @@ const CreatePromptForm = ({ files={files} onFilesChange={setFiles} handleFileChange={handleFileChange} - onFileRemove={handleFileRemove} disabled={isSubmitting} /> void; setFiles: React.Dispatch>>; setFilesLoading: React.Dispatch>; - onFileRemove?: (fileId: string) => void; fileFilter?: (file: ExtendedFile) => boolean; isRTL?: boolean; Wrapper?: React.FC<{ children: React.ReactNode }>; @@ -33,21 +28,6 @@ export default function PromptFile({ fileFilter ? fileFilter(file) : true, ); - const { mutateAsync } = useDeleteFilesMutation({ - onMutate: async () => - logger.log( - 'prompts', - 'Deleting prompt files', - files.map((f) => f.file_id), - ), - onSuccess: () => { - console.log('Prompt files deleted'); - }, - onError: (error) => { - console.log('Error deleting prompt files:', error); - }, - }); - useEffect(() => { if (files.length === 0) { setFilesLoading(false); @@ -111,29 +91,18 @@ export default function PromptFile({ abortUpload(); } - if (onFileRemove) { - onFileRemove(file.file_id); - } else { - mutateAsync({ - files: [ - { - file_id: file.file_id, - filepath: file.filepath || '', - embedded: file.embedded || false, - source: file.source || FileSources.local, - }, - ], - }); - - setFiles((currentFiles) => { - const updatedFiles = new Map(currentFiles); - updatedFiles.delete(file.file_id); - if (file.temp_file_id) { - updatedFiles.delete(file.temp_file_id); - } - return updatedFiles; - }); + if (file.preview && file.preview.startsWith('blob:')) { + URL.revokeObjectURL(file.preview); } + + setFiles((currentFiles) => { + const updatedFiles = new Map(currentFiles); + updatedFiles.delete(file.file_id); + if (file.temp_file_id) { + updatedFiles.delete(file.temp_file_id); + } + return updatedFiles; + }); }; const isImage = file.type?.startsWith('image') ?? false; diff --git a/client/src/components/Prompts/PromptFiles.tsx b/client/src/components/Prompts/PromptFiles.tsx index 27daa28de4..75ade75756 100644 --- a/client/src/components/Prompts/PromptFiles.tsx +++ b/client/src/components/Prompts/PromptFiles.tsx @@ -11,13 +11,11 @@ const PromptFiles = ({ files, onFilesChange, handleFileChange, - onFileRemove, disabled, }: { files: ExtendedFile[]; onFilesChange?: (files: ExtendedFile[]) => void; handleFileChange?: (event: React.ChangeEvent, toolResource?: string) => void; - onFileRemove?: (fileId: string) => void; disabled?: boolean; }) => { const localize = useLocalize(); @@ -65,7 +63,6 @@ const PromptFiles = ({ onFilesChange?.(newFiles); }} setFilesLoading={() => {}} - onFileRemove={onFileRemove} Wrapper={({ children }) =>
{children}
} /> diff --git a/client/src/components/Prompts/PromptForm.tsx b/client/src/components/Prompts/PromptForm.tsx index 737158ada8..f84439737a 100644 --- a/client/src/components/Prompts/PromptForm.tsx +++ b/client/src/components/Prompts/PromptForm.tsx @@ -196,7 +196,6 @@ const PromptForm = () => { getToolResources, promptFiles: hookPromptFiles, handleFileChange, - handleFileRemove, setFiles, } = usePromptFileHandling({ onFileChange: (updatedFiles) => { @@ -544,7 +543,6 @@ const PromptForm = () => { files={hookPromptFiles} onFilesChange={setFiles} handleFileChange={handleFileChange} - onFileRemove={handleFileRemove} disabled={!canEdit} /> void; handleFileChange?: (event: React.ChangeEvent, toolResource?: string) => void; - onFileRemove?: (fileId: string) => void; disabled?: boolean; showVariablesInfo?: boolean; } @@ -18,7 +17,6 @@ const PromptVariablesAndFiles: React.FC = ({ files = [], onFilesChange, handleFileChange, - onFileRemove, disabled, showVariablesInfo = true, }) => { @@ -35,7 +33,6 @@ const PromptVariablesAndFiles: React.FC = ({ files={files} onFilesChange={onFilesChange} handleFileChange={handleFileChange} - onFileRemove={onFileRemove} disabled={disabled} />