Migrate update step changes to diff (#14663)

This PR should fix optimistic rendering issues on step updates:
- compute a diff for trigger and steps on mutations
- build an util that applies that diff (built a more robust version from
https://github.com/AsyncBanana/micropatch)
- apply diff in cache
This commit is contained in:
Thomas Trompette
2025-09-23 18:41:26 +02:00
committed by GitHub
parent a5c47a60d0
commit 6ea7aea92b
31 changed files with 1545 additions and 518 deletions
@@ -873,6 +873,8 @@ export type CreateWorkflowVersionEdgeInput = {
};
export type CreateWorkflowVersionStepInput = {
/** Step ID */
id?: InputMaybe<Scalars['String']>;
/** Next step ID */
nextStepId?: InputMaybe<Scalars['UUID']>;
/** Parent step connection options */
@@ -4033,10 +4035,8 @@ export type WorkflowVersion = {
export type WorkflowVersionStepChanges = {
__typename?: 'WorkflowVersionStepChanges';
createdStep?: Maybe<WorkflowAction>;
deletedStepIds?: Maybe<Array<Scalars['String']>>;
stepsNextStepIds?: Maybe<Scalars['JSON']>;
triggerNextStepIds?: Maybe<Array<Scalars['String']>>;
stepsDiff?: Maybe<Scalars['JSON']>;
triggerDiff?: Maybe<Scalars['JSON']>;
};
export type Workspace = {
@@ -5411,6 +5411,8 @@ export type FindOneCoreViewSortQueryVariables = Exact<{
export type FindOneCoreViewSortQuery = { __typename?: 'Query', getCoreViewSort?: { __typename?: 'CoreViewSort', id: string, fieldMetadataId: string, direction: ViewSortDirection, viewId: string } | null };
export type WorkflowDiffFragmentFragment = { __typename?: 'WorkflowVersionStepChanges', triggerDiff?: any | null, stepsDiff?: any | null };
export type ActivateWorkflowVersionMutationVariables = Exact<{
workflowVersionId: Scalars['UUID'];
}>;
@@ -5437,14 +5439,14 @@ export type CreateWorkflowVersionEdgeMutationVariables = Exact<{
}>;
export type CreateWorkflowVersionEdgeMutation = { __typename?: 'Mutation', createWorkflowVersionEdge: { __typename?: 'WorkflowVersionStepChanges', triggerNextStepIds?: Array<string> | null, stepsNextStepIds?: any | null } };
export type CreateWorkflowVersionEdgeMutation = { __typename?: 'Mutation', createWorkflowVersionEdge: { __typename?: 'WorkflowVersionStepChanges', triggerDiff?: any | null, stepsDiff?: any | null } };
export type CreateWorkflowVersionStepMutationVariables = Exact<{
input: CreateWorkflowVersionStepInput;
}>;
export type CreateWorkflowVersionStepMutation = { __typename?: 'Mutation', createWorkflowVersionStep: { __typename?: 'WorkflowVersionStepChanges', triggerNextStepIds?: Array<string> | null, stepsNextStepIds?: any | null, createdStep?: { __typename?: 'WorkflowAction', id: string, name: string, type: string, settings: any, valid: boolean, nextStepIds?: Array<string> | null, position?: { __typename?: 'WorkflowStepPosition', x: number, y: number } | null } | null } };
export type CreateWorkflowVersionStepMutation = { __typename?: 'Mutation', createWorkflowVersionStep: { __typename?: 'WorkflowVersionStepChanges', triggerDiff?: any | null, stepsDiff?: any | null } };
export type DeactivateWorkflowVersionMutationVariables = Exact<{
workflowVersionId: Scalars['UUID'];
@@ -5458,21 +5460,21 @@ export type DeleteWorkflowVersionEdgeMutationVariables = Exact<{
}>;
export type DeleteWorkflowVersionEdgeMutation = { __typename?: 'Mutation', deleteWorkflowVersionEdge: { __typename?: 'WorkflowVersionStepChanges', triggerNextStepIds?: Array<string> | null, stepsNextStepIds?: any | null } };
export type DeleteWorkflowVersionEdgeMutation = { __typename?: 'Mutation', deleteWorkflowVersionEdge: { __typename?: 'WorkflowVersionStepChanges', triggerDiff?: any | null, stepsDiff?: any | null } };
export type DeleteWorkflowVersionStepMutationVariables = Exact<{
input: DeleteWorkflowVersionStepInput;
}>;
export type DeleteWorkflowVersionStepMutation = { __typename?: 'Mutation', deleteWorkflowVersionStep: { __typename?: 'WorkflowVersionStepChanges', triggerNextStepIds?: Array<string> | null, stepsNextStepIds?: any | null, deletedStepIds?: Array<string> | null } };
export type DeleteWorkflowVersionStepMutation = { __typename?: 'Mutation', deleteWorkflowVersionStep: { __typename?: 'WorkflowVersionStepChanges', triggerDiff?: any | null, stepsDiff?: any | null } };
export type DuplicateWorkflowVersionStepMutationVariables = Exact<{
input: DuplicateWorkflowVersionStepInput;
}>;
export type DuplicateWorkflowVersionStepMutation = { __typename?: 'Mutation', duplicateWorkflowVersionStep: { __typename?: 'WorkflowVersionStepChanges', triggerNextStepIds?: Array<string> | null, stepsNextStepIds?: any | null, createdStep?: { __typename?: 'WorkflowAction', id: string, name: string, type: string, settings: any, valid: boolean, nextStepIds?: Array<string> | null, position?: { __typename?: 'WorkflowStepPosition', x: number, y: number } | null } | null } };
export type DuplicateWorkflowVersionStepMutation = { __typename?: 'Mutation', duplicateWorkflowVersionStep: { __typename?: 'WorkflowVersionStepChanges', triggerDiff?: any | null, stepsDiff?: any | null } };
export type RunWorkflowVersionMutationVariables = Exact<{
input: RunWorkflowVersionInput;
@@ -6062,6 +6064,12 @@ ${BillingSubscriptionFragmentFragmentDoc}
${RoleFragmentFragmentDoc}
${ViewFragmentFragmentDoc}
${AvailableWorkspacesFragmentFragmentDoc}`;
export const WorkflowDiffFragmentFragmentDoc = gql`
fragment WorkflowDiffFragment on WorkflowVersionStepChanges {
triggerDiff
stepsDiff
}
`;
export const AssignRoleToAgentDocument = gql`
mutation AssignRoleToAgent($agentId: UUID!, $roleId: UUID!) {
assignRoleToAgent(agentId: $agentId, roleId: $roleId)
@@ -12394,11 +12402,10 @@ export type CreateDraftFromWorkflowVersionMutationOptions = Apollo.BaseMutationO
export const CreateWorkflowVersionEdgeDocument = gql`
mutation CreateWorkflowVersionEdge($input: CreateWorkflowVersionEdgeInput!) {
createWorkflowVersionEdge(input: $input) {
triggerNextStepIds
stepsNextStepIds
...WorkflowDiffFragment
}
}
`;
${WorkflowDiffFragmentFragmentDoc}`;
export type CreateWorkflowVersionEdgeMutationFn = Apollo.MutationFunction<CreateWorkflowVersionEdgeMutation, CreateWorkflowVersionEdgeMutationVariables>;
/**
@@ -12428,23 +12435,10 @@ export type CreateWorkflowVersionEdgeMutationOptions = Apollo.BaseMutationOption
export const CreateWorkflowVersionStepDocument = gql`
mutation CreateWorkflowVersionStep($input: CreateWorkflowVersionStepInput!) {
createWorkflowVersionStep(input: $input) {
triggerNextStepIds
stepsNextStepIds
createdStep {
id
name
type
settings
valid
nextStepIds
position {
x
y
}
}
...WorkflowDiffFragment
}
}
`;
${WorkflowDiffFragmentFragmentDoc}`;
export type CreateWorkflowVersionStepMutationFn = Apollo.MutationFunction<CreateWorkflowVersionStepMutation, CreateWorkflowVersionStepMutationVariables>;
/**
@@ -12505,11 +12499,10 @@ export type DeactivateWorkflowVersionMutationOptions = Apollo.BaseMutationOption
export const DeleteWorkflowVersionEdgeDocument = gql`
mutation DeleteWorkflowVersionEdge($input: CreateWorkflowVersionEdgeInput!) {
deleteWorkflowVersionEdge(input: $input) {
triggerNextStepIds
stepsNextStepIds
...WorkflowDiffFragment
}
}
`;
${WorkflowDiffFragmentFragmentDoc}`;
export type DeleteWorkflowVersionEdgeMutationFn = Apollo.MutationFunction<DeleteWorkflowVersionEdgeMutation, DeleteWorkflowVersionEdgeMutationVariables>;
/**
@@ -12539,12 +12532,10 @@ export type DeleteWorkflowVersionEdgeMutationOptions = Apollo.BaseMutationOption
export const DeleteWorkflowVersionStepDocument = gql`
mutation DeleteWorkflowVersionStep($input: DeleteWorkflowVersionStepInput!) {
deleteWorkflowVersionStep(input: $input) {
triggerNextStepIds
stepsNextStepIds
deletedStepIds
...WorkflowDiffFragment
}
}
`;
${WorkflowDiffFragmentFragmentDoc}`;
export type DeleteWorkflowVersionStepMutationFn = Apollo.MutationFunction<DeleteWorkflowVersionStepMutation, DeleteWorkflowVersionStepMutationVariables>;
/**
@@ -12574,23 +12565,10 @@ export type DeleteWorkflowVersionStepMutationOptions = Apollo.BaseMutationOption
export const DuplicateWorkflowVersionStepDocument = gql`
mutation DuplicateWorkflowVersionStep($input: DuplicateWorkflowVersionStepInput!) {
duplicateWorkflowVersionStep(input: $input) {
triggerNextStepIds
stepsNextStepIds
createdStep {
id
name
type
settings
valid
nextStepIds
position {
x
y
}
}
...WorkflowDiffFragment
}
}
`;
${WorkflowDiffFragmentFragmentDoc}`;
export type DuplicateWorkflowVersionStepMutationFn = Apollo.MutationFunction<DuplicateWorkflowVersionStepMutation, DuplicateWorkflowVersionStepMutationVariables>;
/**