Skip to content

Conversation

harshit078
Copy link
Contributor

@harshit078 harshit078 commented Oct 6, 2025

Description

Visual Appearance

Screenshot 2025-10-09 at 5 46 18 PM Screenshot 2025-10-09 at 5 46 35 PM

@FelixMalfait
Copy link
Member

I feel like the scheduledDateTime use case might be harder to achieve based on your implementation (and you could argue it could be a trigger). Let's focus on duration for v1. We can always add 2 types later

@FelixMalfait
Copy link
Member

Sorry I'll close to keep the backlog clean because we have way to many PRs open but let me know when you need more feedback we can re-open any time!

@FelixMalfait FelixMalfait reopened this Oct 8, 2025
Copy link
Contributor

github-actions bot commented Oct 8, 2025

🚀 Preview Environment Ready!

Your preview environment is available at: http://bore.pub:38712

This environment will automatically shut down when the PR is closed or after 5 hours.

/>

<WorkflowStepBody>
<Select
Copy link
Member

Choose a reason for hiding this comment

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

Let's drop this? Also it's not at a specific date it's the opposite!

Copy link
Member

Choose a reason for hiding this comment

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

I told you to do duration only and I think you did fixed data only 😅. Since we have the wrong one let's go with both then!

case 'FILTER':
case 'EMPTY':
case 'DELAY':
return theme.color.green60;
Copy link
Member

Choose a reason for hiding this comment

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

Image This looks odd? Please refer to Figma or check with @Bonapara

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I couldnt find a color for filter on Figma. Maybe I might have missed it looking there. I'll push to make sure it uses the same green color.

Copy link
Member

Choose a reason for hiding this comment

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

let's use the green tag color like other nodes from the Flow section

Copy link
Member

Choose a reason for hiding this comment

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

Should the filter also become green @Bonapara? (also in the flow section)

const delayInMs = scheduledDate.getTime() - now.getTime();

await this.messageQueueService.add<DelayedResumeJobData>(
'DelayedResumeJob',
Copy link
Member

Choose a reason for hiding this comment

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

If the queue is full then the delay might not be respected so we might want to do a higher priority queue for those jobs (MessageQueue enum: add workflowDelayedJobsQueue). We don't use priorities right now but a good opportunity to start introducing them. Let's also put the emailQueue in priority / do something clean. lower numbers = higher priority in BullMQ.

@harshit078 harshit078 marked this pull request as ready for review October 9, 2025 13:44
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.

Greptile Overview

Summary

This PR implements a comprehensive workflow delay action feature that allows workflows to pause execution either for a specified duration (days, hours, minutes, seconds) or until a specific scheduled date/time. The implementation spans both frontend and backend systems, creating a complete end-to-end solution.

On the backend, the change introduces a new DELAY workflow action type with dedicated schemas, types, and execution logic. The DelayWorkflowAction calculates delay timing and schedules resume jobs through a message queue system, while ResumeDelayedJob handles resuming workflow execution after delays expire. A new priority-based message queue system ensures delayed jobs receive highest priority (priority 1) for timely execution.

The frontend provides a dual-mode configuration interface through WorkflowEditActionDelay component, allowing users to choose between scheduled datetime delays or duration-based delays. The component includes proper form validation, debounced saving, and readonly support for completed workflows. Visual integration includes appropriate icons (pause symbol), color theming (green), and localization support.

The architecture follows established patterns in the codebase with proper type safety, error handling, and integration with existing workflow systems. The delay action is properly registered in the workflow factory, integrated into workflow execution modules, and added to all relevant UI components for comprehensive support across the workflow system.

Important Files Changed

Changed Files
Filename Score Overview
packages/twenty-server/src/engine/core-modules/message-queue/message-queue.constants.ts 2/5 Added workflowDelayedJobsQueue constant but with queue mismatch issue
packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/delay/jobs/resume-delayed.job.ts 4/5 New job handler for resuming delayed workflows with proper error handling
packages/twenty-server/src/engine/core-modules/message-queue/message-queue-priority.constant.ts 4/5 New priority system with workflow delays getting highest priority
packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/delay-actions/components/WorkflowEditActionDelay.tsx 4/5 Main delay action configuration component with dual delay modes
packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/delay/delay.workflow-action.ts 4/5 Core delay action implementation with message queue scheduling
packages/twenty-shared/src/workflow/schemas/workflow-delay-action-settings-schema.ts 4/5 Zod schema for delay action settings validation
packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/delay/types/workflow-delay-action-input.type.ts 4/5 TypeScript types for delay action input configuration
packages/twenty-front/src/modules/workflow/workflow-steps/components/WorkflowRunStepNodeDetail.tsx 4/5 Added readonly delay action support in workflow run view
packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/delay/guards/is-workflow-delay-action.guard.ts 4/5 Type guard for delay actions with consistent patterns
packages/twenty-server/src/engine/core-modules/message-queue/drivers/bullmq.driver.ts 4/5 Added delay and priority support to message queue driver
packages/twenty-shared/src/workflow/index.ts 5/5 Export statements for delay action schemas
packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/utils/getActionIcon.ts 5/5 Added pause icon for delay actions
packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/delay/types/workflow-delay-action-settings.type.ts 5/5 Type definition following established patterns
packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/utils/getActionHeaderTypeOrThrow.ts 5/5 Added internationalized delay action header
packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/types/workflow-action.type.ts 5/5 Core delay action type integration with workflow system
packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/utils/getActionIconColorOrThrow.ts 5/5 Green color assignment for delay actions
packages/twenty-shared/src/workflow/schemas/workflow-delay-action-schema.ts 5/5 Base delay action schema following established patterns
packages/twenty-server/src/engine/core-modules/message-queue/drivers/interfaces/job-options.interface.ts 5/5 Added delay property to job options interface
packages/twenty-server/src/modules/workflow/workflow-builder/workflow-version-step/workflow-version-step-operations.workspace-service.ts 5/5 Default delay step configuration with consistent patterns
packages/twenty-front/src/modules/workflow/types/Workflow.ts 5/5 Frontend type integration following Zod schema patterns
packages/twenty-front/src/modules/workflow/workflow-steps/components/WorkflowStepDetail.tsx 5/5 Added delay action case to workflow step detail component
packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/delay/delay-action.module.ts 5/5 Module definition following established action module patterns
packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/constants/FlowActions.ts 5/5 Added delay to flow actions with proper icon and label
packages/twenty-front/src/modules/workflow/workflow-diagram/workflow-nodes/components/WorkflowDiagramStepNodeIcon.tsx 5/5 Visual integration with green color theming
packages/twenty-server/src/modules/workflow/workflow-executor/factories/workflow-action.factory.ts 5/5 Factory registration for delay actions
packages/twenty-shared/src/workflow/schemas/workflow-action-schema.ts 5/5 Integration into main workflow action discriminated union
packages/twenty-server/src/modules/workflow/workflow-executor/workflow-executor.module.ts 5/5 Module registration in workflow executor
packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/types/workflow-action-settings.type.ts 5/5 Union type extension for delay action settings

Confidence score: 3/5

  • This PR introduces a complex delay action system with proper backend job scheduling and frontend UI, but has a critical queue mismatch issue that could prevent delayed jobs from being processed
  • Score lowered due to the inconsistency between DelayWorkflowAction using workflowDelayedJobsQueue while ResumeDelayedJob processor listens to workflowQueue, which could result in jobs being queued but never processed
  • Pay close attention to message queue configuration files to ensure DelayWorkflowAction and ResumeDelayedJob use the same queue for proper job processing

Sequence Diagram

sequenceDiagram
    participant User
    participant Frontend
    participant WorkflowExecutor
    participant DelayWorkflowAction
    participant MessageQueue
    participant ResumeDelayedJob
    participant WorkflowRunner

    User->>Frontend: "Configure delay action"
    Frontend->>Frontend: "Set delay type (schedule_date/duration)"
    Frontend->>Frontend: "Configure delay parameters"
    
    Note over User,WorkflowRunner: Workflow Execution starts
    
    WorkflowExecutor->>DelayWorkflowAction: "execute(stepId, settings, runInfo)"
    DelayWorkflowAction->>DelayWorkflowAction: "Validate delay action type"
    
    alt Scheduled Date
        DelayWorkflowAction->>DelayWorkflowAction: "Calculate delay from scheduledDateTime"
        DelayWorkflowAction->>DelayWorkflowAction: "delayInMs = scheduledDate - now"
    else Duration
        DelayWorkflowAction->>DelayWorkflowAction: "Calculate delay from duration"
        DelayWorkflowAction->>DelayWorkflowAction: "delayInMs = days*24*60*60*1000 + hours*60*60*1000 + minutes*60*1000 + seconds*1000"
    end
    
    DelayWorkflowAction->>MessageQueue: "add('ResumeDelayedJob', jobData, { delay: delayInMs })"
    DelayWorkflowAction-->>WorkflowExecutor: "{ pendingEvent: true }"
    
    Note over MessageQueue: Delay period passes
    
    MessageQueue->>ResumeDelayedJob: "handle({ workspaceId, workflowRunId, stepId })"
    ResumeDelayedJob->>ResumeDelayedJob: "Get workflow run status"
    
    alt Workflow still running
        ResumeDelayedJob->>MessageQueue: "add('RunWorkflowJob', runData)"
        ResumeDelayedJob->>WorkflowRunner: "increaseWorkflowRunQueuedCount()"
        MessageQueue->>WorkflowRunner: "Continue workflow execution"
    else Workflow not running
        ResumeDelayedJob->>ResumeDelayedJob: "Skip execution"
    end
Loading

Additional Comments (3)

  1. packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/delay/types/workflow-delay-action-input.type.ts, line 3 (link)

    style: Consider using a more specific type than string for scheduledDateTime, such as ISO 8601 datetime string or a branded type for better type safety

  2. packages/twenty-server/src/modules/workflow/workflow-executor/workflow-actions/delay/types/workflow-delay-action-input.type.ts, line 1-10 (link)

    logic: The type structure should enforce mutual exclusivity - when delayType is 'schedule_date', only scheduledDateTime should be required, and when 'duration', only duration should be required

  3. packages/twenty-shared/src/workflow/schemas/workflow-delay-action-settings-schema.ts, line 8 (link)

    style: Consider using ISO 8601 datetime format validation instead of just string() for scheduledDateTime

Context used:

Rule from dashboard - Use lingui for all user-facing strings to make them translatable, including field type labels and UI... (source)

28 files reviewed, 8 comments

Edit Code Review Agent Settings | Greptile

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.

3 participants