diff --git a/client/src/components/Prompts/Groups/CreatePromptForm.tsx b/client/src/components/Prompts/Groups/CreatePromptForm.tsx index 2a618923fd..1fbbe7ab26 100644 --- a/client/src/components/Prompts/Groups/CreatePromptForm.tsx +++ b/client/src/components/Prompts/Groups/CreatePromptForm.tsx @@ -184,6 +184,7 @@ const CreatePromptForm = ({ onFilesChange={setFiles} handleFileChange={handleFileChange} disabled={isSubmitting} + onFileChange={() => {}} /> methods.setValue('oneliner', value)} diff --git a/client/src/components/Prompts/PromptFile.tsx b/client/src/components/Prompts/PromptFile.tsx index f750e77ce1..37937a2507 100644 --- a/client/src/components/Prompts/PromptFile.tsx +++ b/client/src/components/Prompts/PromptFile.tsx @@ -13,6 +13,7 @@ export default function PromptFile({ fileFilter, isRTL = false, Wrapper, + onFileChange, }: { files: Map | undefined; abortUpload?: () => void; @@ -21,6 +22,7 @@ export default function PromptFile({ fileFilter?: (file: ExtendedFile) => boolean; isRTL?: boolean; Wrapper?: React.FC<{ children: React.ReactNode }>; + onFileChange?: (files: ExtendedFile[]) => void; }) { const localize = useLocalize(); const { showToast } = useToastContext(); @@ -101,6 +103,11 @@ export default function PromptFile({ if (file.temp_file_id) { updatedFiles.delete(file.temp_file_id); } + + // Call onFileChange with the updated files array + const updatedFilesArray = Array.from(updatedFiles.values()); + onFileChange?.(updatedFilesArray); + return updatedFiles; }); }; diff --git a/client/src/components/Prompts/PromptFiles.tsx b/client/src/components/Prompts/PromptFiles.tsx index 75ade75756..520717e6f1 100644 --- a/client/src/components/Prompts/PromptFiles.tsx +++ b/client/src/components/Prompts/PromptFiles.tsx @@ -12,11 +12,13 @@ const PromptFiles = ({ onFilesChange, handleFileChange, disabled, + onFileChange, }: { files: ExtendedFile[]; onFilesChange?: (files: ExtendedFile[]) => void; handleFileChange?: (event: React.ChangeEvent, toolResource?: string) => void; disabled?: boolean; + onFileChange?: (files: ExtendedFile[]) => void; }) => { const localize = useLocalize(); @@ -63,6 +65,7 @@ const PromptFiles = ({ onFilesChange?.(newFiles); }} setFilesLoading={() => {}} + onFileChange={onFileChange} Wrapper={({ children }) =>
{children}
} /> diff --git a/client/src/components/Prompts/PromptForm.tsx b/client/src/components/Prompts/PromptForm.tsx index f84439737a..91e770abe3 100644 --- a/client/src/components/Prompts/PromptForm.tsx +++ b/client/src/components/Prompts/PromptForm.tsx @@ -544,6 +544,12 @@ const PromptForm = () => { onFilesChange={setFiles} handleFileChange={handleFileChange} disabled={!canEdit} + onFileChange={(updatedFiles) => { + if (canEdit && selectedPrompt) { + const currentPromptText = getValues('prompt'); + onSave(currentPromptText, updatedFiles); + } + }} /> , toolResource?: string) => void; disabled?: boolean; showVariablesInfo?: boolean; + onFileChange?: (files: ExtendedFile[]) => void; } const PromptVariablesAndFiles: React.FC = ({ @@ -19,6 +20,7 @@ const PromptVariablesAndFiles: React.FC = ({ handleFileChange, disabled, showVariablesInfo = true, + onFileChange, }) => { return (
@@ -34,6 +36,7 @@ const PromptVariablesAndFiles: React.FC = ({ onFilesChange={onFilesChange} handleFileChange={handleFileChange} disabled={disabled} + onFileChange={onFileChange} />