Skip to content

Add flow to run output #10220

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 14, 2025
Merged

Add flow to run output #10220

merged 2 commits into from
Feb 14, 2025

Conversation

thomtrp
Copy link
Contributor

@thomtrp thomtrp commented Feb 14, 2025

We need the version trigger and steps to be stored in the output. We should not rely on the version itself because some run are made on draft versions. Which means versions could be edited afterwards.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This PR enhances workflow run history by storing workflow version triggers and steps directly in the run output, ensuring runs remain accurate even if draft versions are modified later.

  • Added flow field in WorkflowRunOutput to store version trigger and steps in /packages/twenty-server/src/modules/workflow/common/standard-objects/workflow-run.workspace-entity.ts
  • Renamed steps to stepsOutput in output structures for clarity and separation of concerns
  • Added WORKFLOW_RUN_INVALID exception code in /packages/twenty-server/src/modules/workflow/workflow-runner/exceptions/workflow-run.exception.ts
  • Modified startWorkflowRun to include initial flow data in /packages/twenty-server/src/modules/workflow/workflow-runner/workflow-run/workflow-run.workspace-service.ts
  • Removed Logger dependency from workflow execution services for simplified error handling

5 file(s) reviewed, 4 comment(s)
Edit PR Review Bot Settings | Greptile

Comment on lines 20 to 24
export type WorkflowExecutorState = {
flow: WorkflowRunOutput['flow'];
stepsOutput: WorkflowRunOutput['stepsOutput'];
status: WorkflowRunStatus;
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: flow field is defined but never populated in the executor state

Comment on lines 112 to 118
await this.workflowRunWorkspaceService.saveWorkflowRunState({
workflowRunId,
output: {
steps: updatedOutputSteps,
stepsOutput: updatedStepsOutput,
},
context: updatedContext,
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: flow field is missing in saveWorkflowRunState calls, which could lead to incomplete state persistence

Copy link
Contributor

@Devessier Devessier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we discussed, this change will make the front-end's life way easier to compute a diagram for workflow runs. We can merge.

Please note that this change will break the frontend. We must fix it early next week.

trigger: WorkflowTrigger;
steps: WorkflowAction[];
};
stepsOutput: Record<string, StepRunOutput>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines 76 to 80
flow: {
trigger: workflowVersion.trigger,
steps: workflowVersion.steps,
},
stepsOutput: {},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌

Comment on lines +159 to +163
output: {
flow: workflowRunToUpdate.output?.flow ?? {
trigger: undefined,
steps: [],
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like the workflowRunToUpdate.output?.flow should never be undefined. What do you think?

Copy link
Contributor Author

@thomtrp thomtrp Feb 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it can actually. When the run is not started yet. We should only store the flow once started because this is the version we'll execute

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense 👌

@thomtrp thomtrp merged commit 0172803 into main Feb 14, 2025
32 checks passed
@thomtrp thomtrp deleted the tt-store-flow-to-run-output branch February 14, 2025 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants