From 40750188349893522dddea74c9bdaee4bc6409f6 Mon Sep 17 00:00:00 2001 From: Thomas Trompette Date: Fri, 19 Jun 2026 12:36:14 +0200 Subject: [PATCH] fix(workflow): label manual trigger record output as Record/Records (#21832) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## What The manual trigger output schema exposed the triggering record(s) under a node labeled **Payload**. Relabels it to match what the node actually contains: - **Single-record** availability → **Record** - **Bulk-records** availability → **Records** ## Why "Payload" was a misnomer — the node holds the record(s) that triggered the workflow. This is a display-label-only change. ## Notes for reviewers - **No migration.** The persisted output schema key stays `payload`, so existing variable references (`{{trigger.payload.x}}`) are unaffected. - The front recomputes the output schema on the fly (`computeStepOutputSchema`), so the variable picker shows the new labels immediately, including for existing triggers. - The backend (`workflow-schema.workspace-service`) is updated to match for newly persisted/re-saved schemas. Previously persisted schemas keep "Payload" until re-saved. - Added `WORKFLOW_TRIGGER_RECORD_LABEL` / `WORKFLOW_TRIGGER_RECORDS_LABEL` and removed the now-unused `WORKFLOW_TRIGGER_PAYLOAD_LABEL`. - Unit tests updated for both single and bulk cases (55/55 passing). Review in cubic --- .../generate/__tests__/computeStepOutputSchema.test.ts | 6 +++++- .../utils/generate/computeStepOutputSchema.ts | 7 ++++--- .../workflow-schema/workflow-schema.workspace-service.ts | 7 ++++--- .../src/workflow/constants/WorkflowTriggerPayloadLabel.ts | 1 - .../src/workflow/constants/WorkflowTriggerRecordLabel.ts | 1 + .../src/workflow/constants/WorkflowTriggerRecordsLabel.ts | 1 + packages/twenty-shared/src/workflow/index.ts | 3 ++- 7 files changed, 17 insertions(+), 9 deletions(-) delete mode 100644 packages/twenty-shared/src/workflow/constants/WorkflowTriggerPayloadLabel.ts create mode 100644 packages/twenty-shared/src/workflow/constants/WorkflowTriggerRecordLabel.ts create mode 100644 packages/twenty-shared/src/workflow/constants/WorkflowTriggerRecordsLabel.ts diff --git a/packages/twenty-front/src/modules/workflow/workflow-variables/utils/generate/__tests__/computeStepOutputSchema.test.ts b/packages/twenty-front/src/modules/workflow/workflow-variables/utils/generate/__tests__/computeStepOutputSchema.test.ts index a1ae7641b6..bfd28581a4 100644 --- a/packages/twenty-front/src/modules/workflow/workflow-variables/utils/generate/__tests__/computeStepOutputSchema.test.ts +++ b/packages/twenty-front/src/modules/workflow/workflow-variables/utils/generate/__tests__/computeStepOutputSchema.test.ts @@ -199,7 +199,7 @@ describe('computeStepOutputSchema', () => { expect((result as any).payload).toMatchObject({ isLeaf: false, - label: 'Payload', + label: 'Record', }); expect((result as any).payload.value).toHaveProperty( '_outputSchemaType', @@ -223,6 +223,10 @@ describe('computeStepOutputSchema', () => { objectMetadataItems: [mockCompanyObjectMetadataItem], }); + expect((result as any).payload).toMatchObject({ + isLeaf: false, + label: 'Records', + }); expect((result as any).payload.value).toHaveProperty('companies'); expect((result as any).payload.value.companies).toMatchObject({ isLeaf: true, diff --git a/packages/twenty-front/src/modules/workflow/workflow-variables/utils/generate/computeStepOutputSchema.ts b/packages/twenty-front/src/modules/workflow/workflow-variables/utils/generate/computeStepOutputSchema.ts index e127830175..89d8f2532e 100644 --- a/packages/twenty-front/src/modules/workflow/workflow-variables/utils/generate/computeStepOutputSchema.ts +++ b/packages/twenty-front/src/modules/workflow/workflow-variables/utils/generate/computeStepOutputSchema.ts @@ -15,7 +15,8 @@ import { buildManualTriggerMetadataNode, WORKFLOW_TRIGGER_METADATA_KEY, WORKFLOW_TRIGGER_PAYLOAD_KEY, - WORKFLOW_TRIGGER_PAYLOAD_LABEL, + WORKFLOW_TRIGGER_RECORD_LABEL, + WORKFLOW_TRIGGER_RECORDS_LABEL, } from 'twenty-shared/workflow'; import { DatabaseEventAction } from '~/generated-metadata/graphql'; @@ -130,7 +131,7 @@ export const computeStepOutputSchema = ({ [WORKFLOW_TRIGGER_PAYLOAD_KEY]: { isLeaf: false, icon: objectMetadataItem.icon ?? undefined, - label: WORKFLOW_TRIGGER_PAYLOAD_LABEL, + label: WORKFLOW_TRIGGER_RECORD_LABEL, value: generateRecordOutputSchema(objectMetadataItem), }, [WORKFLOW_TRIGGER_METADATA_KEY]: buildManualTriggerMetadataNode(), @@ -142,7 +143,7 @@ export const computeStepOutputSchema = ({ [WORKFLOW_TRIGGER_PAYLOAD_KEY]: { isLeaf: false, type: 'object', - label: WORKFLOW_TRIGGER_PAYLOAD_LABEL, + label: WORKFLOW_TRIGGER_RECORDS_LABEL, value: { [objectMetadataItem.namePlural]: { isLeaf: true, diff --git a/packages/twenty-server/src/modules/workflow/workflow-builder/workflow-schema/workflow-schema.workspace-service.ts b/packages/twenty-server/src/modules/workflow/workflow-builder/workflow-schema/workflow-schema.workspace-service.ts index e2174e58a6..27134b74bd 100644 --- a/packages/twenty-server/src/modules/workflow/workflow-builder/workflow-schema/workflow-schema.workspace-service.ts +++ b/packages/twenty-server/src/modules/workflow/workflow-builder/workflow-schema/workflow-schema.workspace-service.ts @@ -18,7 +18,8 @@ import { TRIGGER_STEP_ID, WORKFLOW_TRIGGER_METADATA_KEY, WORKFLOW_TRIGGER_PAYLOAD_KEY, - WORKFLOW_TRIGGER_PAYLOAD_LABEL, + WORKFLOW_TRIGGER_RECORD_LABEL, + WORKFLOW_TRIGGER_RECORDS_LABEL, WorkflowActionType, } from 'twenty-shared/workflow'; @@ -480,7 +481,7 @@ export class WorkflowSchemaWorkspaceService { const payload: Node = { isLeaf: false, type: 'object', - label: WORKFLOW_TRIGGER_PAYLOAD_LABEL, + label: WORKFLOW_TRIGGER_RECORD_LABEL, value: recordOutputSchema, }; @@ -500,7 +501,7 @@ export class WorkflowSchemaWorkspaceService { const payload: Node = { isLeaf: false, type: 'object', - label: WORKFLOW_TRIGGER_PAYLOAD_LABEL, + label: WORKFLOW_TRIGGER_RECORDS_LABEL, value: { [objectMetadataInfo.flatObjectMetadata.namePlural]: { label: objectMetadataInfo.flatObjectMetadata.labelPlural, diff --git a/packages/twenty-shared/src/workflow/constants/WorkflowTriggerPayloadLabel.ts b/packages/twenty-shared/src/workflow/constants/WorkflowTriggerPayloadLabel.ts deleted file mode 100644 index 7a3b30e040..0000000000 --- a/packages/twenty-shared/src/workflow/constants/WorkflowTriggerPayloadLabel.ts +++ /dev/null @@ -1 +0,0 @@ -export const WORKFLOW_TRIGGER_PAYLOAD_LABEL = 'Payload'; diff --git a/packages/twenty-shared/src/workflow/constants/WorkflowTriggerRecordLabel.ts b/packages/twenty-shared/src/workflow/constants/WorkflowTriggerRecordLabel.ts new file mode 100644 index 0000000000..cba335ea2c --- /dev/null +++ b/packages/twenty-shared/src/workflow/constants/WorkflowTriggerRecordLabel.ts @@ -0,0 +1 @@ +export const WORKFLOW_TRIGGER_RECORD_LABEL = 'Record'; diff --git a/packages/twenty-shared/src/workflow/constants/WorkflowTriggerRecordsLabel.ts b/packages/twenty-shared/src/workflow/constants/WorkflowTriggerRecordsLabel.ts new file mode 100644 index 0000000000..0019511acd --- /dev/null +++ b/packages/twenty-shared/src/workflow/constants/WorkflowTriggerRecordsLabel.ts @@ -0,0 +1 @@ +export const WORKFLOW_TRIGGER_RECORDS_LABEL = 'Records'; diff --git a/packages/twenty-shared/src/workflow/index.ts b/packages/twenty-shared/src/workflow/index.ts index c905a25379..a61d70d8e9 100644 --- a/packages/twenty-shared/src/workflow/index.ts +++ b/packages/twenty-shared/src/workflow/index.ts @@ -17,7 +17,8 @@ export { WORKFLOW_TRIGGER_METADATA_LABEL } from './constants/WorkflowTriggerMeta export { WORKFLOW_TRIGGER_METADATA_WORKSPACE_MEMBER_ID_KEY } from './constants/WorkflowTriggerMetadataWorkspaceMemberIdKey'; export { WORKFLOW_TRIGGER_METADATA_WORKSPACE_MEMBER_ID_LABEL } from './constants/WorkflowTriggerMetadataWorkspaceMemberIdLabel'; export { WORKFLOW_TRIGGER_PAYLOAD_KEY } from './constants/WorkflowTriggerPayloadKey'; -export { WORKFLOW_TRIGGER_PAYLOAD_LABEL } from './constants/WorkflowTriggerPayloadLabel'; +export { WORKFLOW_TRIGGER_RECORD_LABEL } from './constants/WorkflowTriggerRecordLabel'; +export { WORKFLOW_TRIGGER_RECORDS_LABEL } from './constants/WorkflowTriggerRecordsLabel'; export { WORKFLOW_DIAGRAM_DEFAULT_NODE_DIMENSIONS } from './layout/constants/WorkflowDiagramDefaultNodeDimensions'; export { WORKFLOW_LAYOUT_DEFAULT_OPTIONS } from './layout/constants/WorkflowLayoutDefaultOptions'; export type {