-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
8723 workflow add editor in serverless function code step #8805
8723 workflow add editor in serverless function code step #8805
Conversation
There was a problem hiding this 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 implements serverless function code editing in workflow steps and moves workflow version step management from frontend to backend, with significant changes to both the UI and backend architecture.
- Added new
WorkflowVersionResolver
and DTOs in backend to handle workflow step CRUD operations through dedicated endpoints - Implemented code editor integration in
WorkflowEditActionFormServerlessFunction
with Monaco editor and auto-completion support - Added serverless function lifecycle management (create/delete) tied to workflow code steps
- Created
DeleteServerlessFunctionJob
for batch deletion through message queue system - Refactored workflow action types to simplify CRUD operations by consolidating subtypes into single
RECORD_CRUD
type
56 file(s) reviewed, 52 comment(s)
Edit PR Review Bot Settings | Greptile
@@ -35,7 +35,7 @@ export const WorkflowRunActionEffect = () => { | |||
type: ActionMenuEntryType.WorkflowRun, | |||
key: `workflow-run-${activeWorkflowVersion.id}`, | |||
scope: ActionMenuEntryScope.Global, | |||
label: capitalize(activeWorkflowVersion.workflow.name), | |||
label: capitalize(activeWorkflowVersion.workflow?.name || ''), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: Optional chaining added for workflow?.name but not used consistently - line 48 still accesses workflow.name directly which could cause runtime errors
findOneRecord: async ({ | ||
objectRecordId, | ||
onCompleted, | ||
}: FindOneRecordParams<T>) => { | ||
await findOneRecord({ | ||
variables: { objectRecordId }, | ||
fetchPolicy, | ||
onCompleted: (data) => { | ||
const record = getRecordFromRecordNode<T>({ | ||
recordNode: data[objectNameSingular], | ||
}); | ||
onCompleted?.(record); | ||
}, | ||
}), | ||
}); | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: Making findOneRecord async but not handling potential rejection could cause unhandled promise rejections. Consider adding try/catch.
const { serverlessFunctionId = '' } = useParams(); | ||
const { availablePackages } = useGetAvailablePackages({ | ||
id: serverlessFunctionId, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: serverlessFunctionId defaults to empty string which could cause issues if ID is required by useGetAvailablePackages
} from '~/generated-metadata/graphql'; | ||
|
||
export const useGetAvailablePackages = () => { | ||
export const useGetAvailablePackages = (input: ServerlessFunctionIdInput) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Consider making input parameter optional with a default value to maintain backward compatibility with existing usage
...ages/twenty-front/src/modules/settings/serverless-functions/hooks/useGetAvailablePackages.ts
Show resolved
Hide resolved
...ty-server/src/modules/workflow/workflow-status/listeners/workflow-version-status.listener.ts
Outdated
Show resolved
Hide resolved
...ty-server/src/modules/workflow/workflow-status/listeners/workflow-version-status.listener.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huge work @martmull 💪
packages/twenty-front/src/modules/workflow/components/WorkflowDiagramStepNodeEditable.tsx
Outdated
Show resolved
Hide resolved
...wenty-server/src/engine/core-modules/workflow/dtos/create-workflow-version-step-input.dto.ts
Show resolved
Hide resolved
packages/twenty-server/src/engine/core-modules/workflow/resolvers/workflow-version.resolver.ts
Outdated
Show resolved
Hide resolved
...-server/src/modules/workflow/common/workspace-services/workflow-version.workspace-service.ts
Outdated
Show resolved
Hide resolved
...-server/src/modules/workflow/common/workspace-services/workflow-version.workspace-service.ts
Outdated
Show resolved
Hide resolved
...-server/src/modules/workflow/common/workspace-services/workflow-version.workspace-service.ts
Outdated
Show resolved
Hide resolved
...-server/src/modules/workflow/common/workspace-services/workflow-version.workspace-service.ts
Outdated
Show resolved
Hide resolved
...-server/src/modules/workflow/common/workspace-services/workflow-version.workspace-service.ts
Outdated
Show resolved
Hide resolved
99f8f19
to
5d36f1c
Compare
packages/twenty-front/src/modules/object-record/hooks/useLazyFindOneRecord.ts
Outdated
Show resolved
Hide resolved
...er/src/modules/workflow/common/workspace-services/workflow-version-step.workspace-service.ts
Outdated
Show resolved
Hide resolved
...er/src/modules/workflow/common/workspace-services/workflow-version-step.workspace-service.ts
Show resolved
Hide resolved
5f598a0
to
42673fc
Compare
42673fc
to
ecf5e2d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you a lot for your pull request, @martmull. It's really nice to edit a serverless function directly from the workflow visualizer.
I spotted a few things that we could discuss.
...on-menu/actions/record-agnostic-actions/workflow-run-actions/hooks/useWorkflowRunActions.tsx
Outdated
Show resolved
Hide resolved
packages/twenty-front/src/modules/workflow/hooks/useCreateNewWorkflowVersion.ts
Show resolved
Hide resolved
packages/twenty-front/src/modules/workflow/hooks/useUpdateWorkflowVersionStep.ts
Outdated
Show resolved
Hide resolved
packages/twenty-front/src/modules/workflow/hooks/useUpdateWorkflowVersionStep.ts
Outdated
Show resolved
Hide resolved
packages/twenty-front/src/modules/workflow/hooks/useWorkflowWithCurrentVersion.ts
Outdated
Show resolved
Hide resolved
packages/twenty-front/src/modules/workflow/utils/getFunctionInputSchema.ts
Show resolved
Hide resolved
...wenty-server/src/engine/core-modules/serverless/drivers/utils/get-last-layer-dependencies.ts
Show resolved
Hide resolved
...er/src/modules/workflow/common/workspace-services/workflow-version-step.workspace-service.ts
Show resolved
Hide resolved
...rc/modules/workflow/workflow-actions/components/WorkflowEditActionFormServerlessFunction.tsx
Show resolved
Hide resolved
07703e8
to
11b0ea1
Compare
11b0ea1
to
3382033
Compare
) - create a serverless function when creating a new workflow code step - add code editor in workflow code step - move workflowVersion steps management from frontend to backend - add a custom resolver for workflow-version management - fix optimistic rendering on frontend - fix css - delete serverless function when deleting workflow code step TODO - Don't update serverlessFunction if no code change - Factorize what can be between crud trigger and crud step - Publish serverless version when activating workflow - delete serverless functions when deleting workflow or workflowVersion - fix optimistic rendering for code updates - Unify CRUD types <img width="1279" alt="image" src="https://github.com/user-attachments/assets/3d97ee9f-4b96-4abc-9d36-5c0280058be4">
TODO