Skip to content

Commit 2569576

Browse files
authored
fix(frontend/builder): Fix save-and-run with no agent inputs (#11401)
- Resolves #11390 This unbreaks the last step of the Builder tutorial :) ### Changes ๐Ÿ—๏ธ - Give `isSaving` time to propagate before calling dependent callback `saveAndRun` ### Checklist ๐Ÿ“‹ #### For code changes: - [x] I have clearly listed my changes in the PR description - [x] I have made a test plan - [x] I have tested my changes according to the test plan: - [x] Run through Builder tutorial; Run (with implicit save) should work at once
1 parent 3b34c04 commit 2569576

File tree

1 file changed

+18
-2
lines changed
  • autogpt_platform/frontend/src/app/(platform)/build/components/legacy-builder/Flow

1 file changed

+18
-2
lines changed

โ€Žautogpt_platform/frontend/src/app/(platform)/build/components/legacy-builder/Flow/Flow.tsxโ€Ž

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,22 @@ const FlowEditor: React.FC<{
762762
[],
763763
);
764764

765+
// Track when we should run or schedule after save completes
766+
const [shouldRunAfterSave, setShouldRunAfterSave] = useState(false);
767+
const [shouldScheduleAfterSave, setShouldScheduleAfterSave] = useState(false);
768+
769+
// Effect to trigger runOrOpenInput or openRunInputDialog after saving completes
770+
useEffect(() => {
771+
if (!isSaving && shouldRunAfterSave) {
772+
runnerUIRef.current?.runOrOpenInput();
773+
setShouldRunAfterSave(false);
774+
}
775+
if (!isSaving && shouldScheduleAfterSave) {
776+
runnerUIRef.current?.openRunInputDialog();
777+
setShouldScheduleAfterSave(false);
778+
}
779+
}, [isSaving, shouldRunAfterSave, shouldScheduleAfterSave]);
780+
765781
const handleRunButton = useCallback(async () => {
766782
if (isRunning) return;
767783
if (!savedAgent) {
@@ -771,7 +787,7 @@ const FlowEditor: React.FC<{
771787
return;
772788
}
773789
await saveAgent();
774-
runnerUIRef.current?.runOrOpenInput();
790+
setShouldRunAfterSave(true);
775791
}, [isRunning, savedAgent, toast, saveAgent]);
776792

777793
const handleScheduleButton = useCallback(async () => {
@@ -783,7 +799,7 @@ const FlowEditor: React.FC<{
783799
return;
784800
}
785801
await saveAgent();
786-
runnerUIRef.current?.openRunInputDialog();
802+
setShouldScheduleAfterSave(true);
787803
}, [isScheduling, savedAgent, toast, saveAgent]);
788804

789805
const isNewBlockEnabled = useGetFlag(Flag.NEW_BLOCK_MENU);

0 commit comments

Comments
ย (0)