diff --git a/frontend/src/components/tools/automate/AutomationRun.tsx b/frontend/src/components/tools/automate/AutomationRun.tsx index b204d6931..640f802f6 100644 --- a/frontend/src/components/tools/automate/AutomationRun.tsx +++ b/frontend/src/components/tools/automate/AutomationRun.tsx @@ -38,7 +38,7 @@ export default function AutomationRun({ automation, onComplete, automateOperatio id: `${op.operation}-${index}`, operation: op.operation, name: tool?.name || op.operation, - status: EXECUTION_STATUS.PENDING as const + status: EXECUTION_STATUS.PENDING }; }); setExecutionSteps(steps); @@ -69,7 +69,7 @@ export default function AutomationRun({ automation, onComplete, automateOperatio // Reset progress tracking setCurrentStepIndex(0); - setExecutionSteps(prev => prev.map(step => ({ ...step, status: EXECUTION_STATUS.PENDING as const, error: undefined }))); + setExecutionSteps(prev => prev.map(step => ({ ...step, status: EXECUTION_STATUS.PENDING, error: undefined }))); try { // Use the automateOperation.executeOperation to handle file consumption properly @@ -79,17 +79,17 @@ export default function AutomationRun({ automation, onComplete, automateOperatio onStepStart: (stepIndex: number, operationName: string) => { setCurrentStepIndex(stepIndex); setExecutionSteps(prev => prev.map((step, idx) => - idx === stepIndex ? { ...step, status: EXECUTION_STATUS.RUNNING as const } : step + idx === stepIndex ? { ...step, status: EXECUTION_STATUS.RUNNING } : step )); }, onStepComplete: (stepIndex: number, resultFiles: File[]) => { setExecutionSteps(prev => prev.map((step, idx) => - idx === stepIndex ? { ...step, status: EXECUTION_STATUS.COMPLETED as const } : step + idx === stepIndex ? { ...step, status: EXECUTION_STATUS.COMPLETED } : step )); }, onStepError: (stepIndex: number, error: string) => { setExecutionSteps(prev => prev.map((step, idx) => - idx === stepIndex ? { ...step, status: EXECUTION_STATUS.ERROR as const, error } : step + idx === stepIndex ? { ...step, status: EXECUTION_STATUS.ERROR, error } : step )); } }, diff --git a/frontend/src/components/tools/automate/AutomationSelection.tsx b/frontend/src/components/tools/automate/AutomationSelection.tsx index e751ea401..f55cf4c5d 100644 --- a/frontend/src/components/tools/automate/AutomationSelection.tsx +++ b/frontend/src/components/tools/automate/AutomationSelection.tsx @@ -64,7 +64,7 @@ export default function AutomationSelection({ op.operation)} onClick={() => onRun(automation)} /> ))} diff --git a/frontend/src/hooks/tools/automate/useAutomationForm.ts b/frontend/src/hooks/tools/automate/useAutomationForm.ts index b9444f871..11464a329 100644 --- a/frontend/src/hooks/tools/automate/useAutomationForm.ts +++ b/frontend/src/hooks/tools/automate/useAutomationForm.ts @@ -41,7 +41,7 @@ export function useAutomationForm({ mode, existingAutomation, toolRegistry }: Us id: `${operation}-${Date.now()}-${index}`, operation: operation, name: getToolName(operation), - configured: mode === AutomationMode.EDIT ? true : (typeof op === 'object' ? op.configured || false : false), + configured: mode === AutomationMode.EDIT ? true : false, parameters: typeof op === 'object' ? op.parameters || {} : {} }; }); diff --git a/frontend/src/hooks/tools/automate/useSuggestedAutomations.ts b/frontend/src/hooks/tools/automate/useSuggestedAutomations.ts index aa4a4cef8..bb1ed5916 100644 --- a/frontend/src/hooks/tools/automate/useSuggestedAutomations.ts +++ b/frontend/src/hooks/tools/automate/useSuggestedAutomations.ts @@ -1,33 +1,53 @@ import { useMemo } from 'react'; import { useTranslation } from 'react-i18next'; import StarIcon from '@mui/icons-material/Star'; - -export interface SuggestedAutomation { - id: string; - operations: string[]; - icon: React.ComponentType; -} +import { SuggestedAutomation } from '../../../types/automation'; export function useSuggestedAutomations(): SuggestedAutomation[] { const { t } = useTranslation(); - const suggestedAutomations = useMemo(() => [ - { - id: "compress-and-merge", - operations: ["compress", "merge"], - icon: StarIcon, - }, - { - id: "ocr-and-convert", - operations: ["ocr", "convert"], - icon: StarIcon, - }, - { - id: "secure-workflow", - operations: ["sanitize", "addPassword", "changePermissions"], - icon: StarIcon, - }, - ], [t]); + const suggestedAutomations = useMemo(() => { + const now = new Date().toISOString(); + return [ + { + id: "compress-and-merge", + name: t("automation.suggested.compressAndMerge", "Compress & Merge"), + description: t("automation.suggested.compressAndMergeDesc", "Compress PDFs and merge them into one file"), + operations: [ + { operation: "compress", parameters: {} }, + { operation: "merge", parameters: {} } + ], + createdAt: now, + updatedAt: now, + icon: StarIcon, + }, + { + id: "ocr-and-convert", + name: t("automation.suggested.ocrAndConvert", "OCR & Convert"), + description: t("automation.suggested.ocrAndConvertDesc", "Extract text via OCR and convert to different format"), + operations: [ + { operation: "ocr", parameters: {} }, + { operation: "convert", parameters: {} } + ], + createdAt: now, + updatedAt: now, + icon: StarIcon, + }, + { + id: "secure-workflow", + name: t("automation.suggested.secureWorkflow", "Secure Workflow"), + description: t("automation.suggested.secureWorkflowDesc", "Sanitize, add password, and set permissions"), + operations: [ + { operation: "sanitize", parameters: {} }, + { operation: "addPassword", parameters: {} }, + { operation: "changePermissions", parameters: {} } + ], + createdAt: now, + updatedAt: now, + icon: StarIcon, + }, + ]; + }, [t]); return suggestedAutomations; } diff --git a/frontend/src/tools/Automate.tsx b/frontend/src/tools/Automate.tsx index 9e7a7b864..54538781b 100644 --- a/frontend/src/tools/Automate.tsx +++ b/frontend/src/tools/Automate.tsx @@ -75,6 +75,10 @@ const Automate = ({ onPreviewFile, onComplete, onError }: BaseToolProps) => { ); case 'creation': + if (!stepData.mode) { + console.error('Creation mode is undefined'); + return null; + } return ( { ); case 'run': + if (!stepData.automation) { + console.error('Automation config is undefined'); + return null; + } return (