fix(editor): Do not run the workflow when the save before execute fails (#39763)

This commit is contained in:
Theodore Nastos 2026-09-29 14:50:29 +00:00 committed by GitHub
parent f9dbd2c8d6
commit 7204df600d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 34 additions and 2 deletions

View File

@ -466,6 +466,22 @@ describe('useRunWorkflow({ router })', () => {
await runWorkflow({});
expect(workflowSaving.saveCurrentWorkflow).toHaveBeenCalledTimes(1);
expect(workflowsStore.runWorkflow).toHaveBeenCalledTimes(1);
});
it('should not run when the save before execute fails with autosave enabled', async () => {
vi.spyOn(settingsStore, 'isAutosaveEnabled', 'get').mockReturnValue(true);
vi.mocked(uiStore).stateIsDirty = true;
vi.mocked(workflowsStore).isWorkflowSaved = { '123': true };
const workflowSaving = useWorkflowSaving({ router });
vi.mocked(workflowSaving.saveCurrentWorkflow).mockResolvedValueOnce(false);
const { runWorkflow } = useRunWorkflow({ router });
const result = await runWorkflow({});
expect(workflowSaving.saveCurrentWorkflow).toHaveBeenCalledTimes(1);
expect(workflowsStore.runWorkflow).not.toHaveBeenCalled();
expect(result).toBeUndefined();
});
it('should prompt the user and save when they confirm if autosave is disabled and state is dirty (ADO-5328)', async () => {
@ -515,6 +531,21 @@ describe('useRunWorkflow({ router })', () => {
expect(workflowSaving.saveCurrentWorkflow).toHaveBeenCalledTimes(1);
});
it('should not run a new workflow when its first save fails', async () => {
vi.spyOn(settingsStore, 'isAutosaveEnabled', 'get').mockReturnValue(false);
vi.mocked(uiStore).stateIsDirty = false;
vi.mocked(workflowsStore).isWorkflowSaved = {};
const workflowSaving = useWorkflowSaving({ router });
vi.mocked(workflowSaving.saveCurrentWorkflow).mockResolvedValueOnce(false);
const { runWorkflow } = useRunWorkflow({ router });
const result = await runWorkflow({});
expect(workflowSaving.saveCurrentWorkflow).toHaveBeenCalledTimes(1);
expect(workflowsStore.runWorkflow).not.toHaveBeenCalled();
expect(result).toBeUndefined();
});
});
describe('scoped workflow document store (eval-loop reruns)', () => {

View File

@ -175,15 +175,15 @@ export function useRunWorkflow(useRunWorkflowOpts: {
if (response !== MODAL_CONFIRM) {
return undefined;
}
}
if (isNewWorkflow || uiStore.stateIsDirty) {
const saved = await workflowSaving.saveCurrentWorkflow({
id: workflowDocumentStore.value.workflowId,
});
if (!saved) {
return undefined;
}
} else if (isNewWorkflow || (uiStore.stateIsDirty && settingsStore.isAutosaveEnabled)) {
await workflowSaving.saveCurrentWorkflow({ id: workflowDocumentStore.value.workflowId });
}
const workflowData = workflowDocumentStore.value.serialize();

View File

@ -319,6 +319,7 @@ describe('LogsOverviewPanel', () => {
it('should trigger partial execution if the button is clicked', async () => {
const spyRun = vi.spyOn(workflowsStore, 'runWorkflow');
workflowsStore.isWorkflowSaved = { 'test-workflow-id': true };
const logs = createLogTree(
createTestWorkflowObject(aiManualWorkflow),