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
This commit is contained in:
Reinier van der Leer
2025-11-18 13:49:37 +01:00
committed by GitHub
parent 3b34c04a7a
commit 2569576d78

View File

@@ -762,6 +762,22 @@ const FlowEditor: React.FC<{
[],
);
// Track when we should run or schedule after save completes
const [shouldRunAfterSave, setShouldRunAfterSave] = useState(false);
const [shouldScheduleAfterSave, setShouldScheduleAfterSave] = useState(false);
// Effect to trigger runOrOpenInput or openRunInputDialog after saving completes
useEffect(() => {
if (!isSaving && shouldRunAfterSave) {
runnerUIRef.current?.runOrOpenInput();
setShouldRunAfterSave(false);
}
if (!isSaving && shouldScheduleAfterSave) {
runnerUIRef.current?.openRunInputDialog();
setShouldScheduleAfterSave(false);
}
}, [isSaving, shouldRunAfterSave, shouldScheduleAfterSave]);
const handleRunButton = useCallback(async () => {
if (isRunning) return;
if (!savedAgent) {
@@ -771,7 +787,7 @@ const FlowEditor: React.FC<{
return;
}
await saveAgent();
runnerUIRef.current?.runOrOpenInput();
setShouldRunAfterSave(true);
}, [isRunning, savedAgent, toast, saveAgent]);
const handleScheduleButton = useCallback(async () => {
@@ -783,7 +799,7 @@ const FlowEditor: React.FC<{
return;
}
await saveAgent();
runnerUIRef.current?.openRunInputDialog();
setShouldScheduleAfterSave(true);
}, [isScheduling, savedAgent, toast, saveAgent]);
const isNewBlockEnabled = useGetFlag(Flag.NEW_BLOCK_MENU);