Allow to stop running workflow (#15270)

https://github.com/user-attachments/assets/599154e4-8743-471b-b05a-721b635bcf4e

On stoppage:
- if no running steps, mark pending as failed and end the workflow
- if running steps, set as stopping and exit. Going to the next step, as
the workflow is not running anymore, it will naturally stop
This commit is contained in:
Thomas Trompette
2025-10-23 15:01:15 +02:00
committed by GitHub
parent 1cf442966d
commit 4effa5351c
23 changed files with 532 additions and 70 deletions
@@ -19,6 +19,7 @@ export enum MetricsKeys {
WorkflowRunStartedManualTrigger = 'workflow-run/started/manual-trigger',
WorkflowRunCompleted = 'workflow-run/completed',
WorkflowRunFailed = 'workflow-run/failed',
WorkflowRunStopped = 'workflow-run/stopped',
WorkflowRunFailedThrottled = 'workflow-run/failed/throttled',
WorkflowRunFailedToEnqueue = 'workflow-run/failed/to-enqueue',
AIToolExecutionFailed = 'ai-tool-execution/failed',
@@ -0,0 +1,9 @@
import { Field, ObjectType } from '@nestjs/graphql';
import { UUIDScalarType } from 'src/engine/api/graphql/workspace-schema-builder/graphql-types/scalars';
@ObjectType('RunWorkflowVersionOutput')
export class RunWorkflowVersionOutput {
@Field(() => UUIDScalarType)
workflowRunId: string;
}
@@ -1,9 +1,13 @@
import { Field, ObjectType } from '@nestjs/graphql';
import { UUIDScalarType } from 'src/engine/api/graphql/workspace-schema-builder/graphql-types/scalars';
import { WorkflowRunStatus } from 'src/modules/workflow/common/standard-objects/workflow-run.workspace-entity';
@ObjectType('WorkflowRun')
export class WorkflowRunDTO {
@Field(() => UUIDScalarType)
workflowRunId: string;
id: string;
@Field(() => WorkflowRunStatus)
status: WorkflowRunStatus;
}
@@ -7,6 +7,7 @@ import { PreventNestToAutoLogGraphqlErrorsFilter } from 'src/engine/core-modules
import { ResolverValidationPipe } from 'src/engine/core-modules/graphql/pipes/resolver-validation.pipe';
import { UserEntity } from 'src/engine/core-modules/user/user.entity';
import { RunWorkflowVersionInput } from 'src/engine/core-modules/workflow/dtos/run-workflow-version-input.dto';
import { RunWorkflowVersionOutput } from 'src/engine/core-modules/workflow/dtos/run-workflow-version-output.dto';
import { WorkflowRunDTO } from 'src/engine/core-modules/workflow/dtos/workflow-run.dto';
import { WorkflowTriggerGraphqlApiExceptionFilter } from 'src/engine/core-modules/workflow/filters/workflow-trigger-graphql-api-exception.filter';
import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
@@ -59,7 +60,7 @@ export class WorkflowTriggerResolver {
);
}
@Mutation(() => WorkflowRunDTO)
@Mutation(() => RunWorkflowVersionOutput)
async runWorkflowVersion(
@AuthUser() user: UserEntity,
@AuthWorkspace() workspace: WorkspaceEntity,
@@ -91,4 +92,12 @@ export class WorkflowTriggerResolver {
}),
});
}
@Mutation(() => WorkflowRunDTO)
async stopWorkflowRun(
@Args('workflowRunId', { type: () => UUIDScalarType })
workflowRunId: string,
) {
return this.workflowTriggerWorkspaceService.stopWorkflowRun(workflowRunId);
}
}