From 555d937921106df33853ada8c6350f9fb0e83ca2 Mon Sep 17 00:00:00 2001 From: Connor Yoh Date: Thu, 21 Aug 2025 12:27:03 +0100 Subject: [PATCH] Fix infinite loops --- frontend/src/components/tools/automate/AutomationRun.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/tools/automate/AutomationRun.tsx b/frontend/src/components/tools/automate/AutomationRun.tsx index 0034e0001..c400bae22 100644 --- a/frontend/src/components/tools/automate/AutomationRun.tsx +++ b/frontend/src/components/tools/automate/AutomationRun.tsx @@ -57,11 +57,14 @@ export default function AutomationRun({ automation, onBack, onComplete, automate }); setExecutionSteps(steps); } - // Initialize current files with active files - if (activeFiles) { + }, [automation]); // Remove toolRegistry from dependencies to prevent infinite loops + + // Initialize current files with active files (separate effect) + React.useEffect(() => { + if (activeFiles && activeFiles.length > 0) { setCurrentFiles([...activeFiles]); } - }, [automation, toolRegistry, activeFiles]); + }, [activeFiles?.length]); // Only depend on length to avoid infinite loops const executeAutomation = async () => { if (!activeFiles || activeFiles.length === 0) {