Skip to content

Conversation

@waleedlatif1
Copy link
Collaborator

Summary

  • remove save button for schedules, couple schedule deployment with workflow deployment
  • added tests

Type of Change

  • Bug fix

Testing

Tested manually. Added unit tests

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link

vercel bot commented Dec 24, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Review Updated (UTC)
docs Skipped Skipped Dec 24, 2025 2:33am

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 24, 2025

Greptile Summary

This PR couples schedule deployment with workflow deployment, removing the separate "Save" button for schedules.

Key Changes:

  • Schedules are now automatically created/updated when a workflow is deployed and deleted when undeployed
  • Removed the manual schedule save functionality (ScheduleSave component, use-schedule-management hook, POST /api/schedules)
  • Added client-side pre-deploy validation that checks schedule configuration before allowing deployment
  • New ScheduleInfo component displays read-only schedule status (next run, last run, failure count)
  • Simplified /api/schedules/[id] route to only support reactivation of disabled schedules
  • Added comprehensive validation functions in validation.ts for all schedule types
  • Added extensive test coverage for the new schedule deploy utilities

Architecture:
The change simplifies the schedule lifecycle by eliminating the need for users to manually save schedules. This reduces complexity and ensures schedules are always in sync with deployed workflows.

Confidence Score: 4/5

  • This PR is safe to merge with good test coverage and clean architectural changes.
  • Well-structured refactoring that simplifies the schedule management system. Comprehensive test coverage added. Minor code quality items noted in previous reviews (unused prop) but no critical issues.
  • apps/sim/lib/workflows/schedules/deploy.ts - verify behavior with multiple schedule blocks is as intended

Important Files Changed

Filename Overview
apps/sim/lib/workflows/schedules/deploy.ts New file implementing schedule creation/deletion during workflow deployment. Uses upsert pattern with workflowId+blockId conflict target. Minor consideration: generates new UUID on each upsert but existing ID is preserved on conflict.
apps/sim/lib/workflows/schedules/validation.ts New client-safe validation functions for schedule block configuration. Well-structured with proper validation for all schedule types.
apps/sim/app/api/workflows/[id]/deploy/route.ts Modified to validate schedules before deployment and create schedule records during deploy. Deletes schedules within transaction on undeploy. Schedule creation happens outside transaction but with proper error handling.
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/deploy/hooks/use-deployment.ts Enhanced deployment hook with client-side pre-deploy validation. Shows error notifications on validation failure. Clean implementation.
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/schedule-info/schedule-info.tsx New read-only schedule status component replacing the old schedule-save. Shows cron description, next/last run times, and failure states with redeploy action.
apps/sim/app/api/schedules/route.ts Simplified to GET-only endpoint. POST endpoint removed as schedule creation now happens during deployment.
apps/sim/app/api/schedules/[id]/route.ts Simplified to PUT-only (reactivate action). DELETE removed as schedule deletion now handled during workflow undeploy.

Sequence Diagram

sequenceDiagram
    participant User
    participant DeployHook as useDeployment
    participant PreDeploy as runPreDeployChecks
    participant API as /api/workflows/[id]/deploy
    participant Validation as validateWorkflowSchedules
    participant Deploy as createSchedulesForDeploy
    participant DB as Database

    User->>DeployHook: Click Deploy
    
    alt Already Deployed (Redeploy)
        DeployHook->>PreDeploy: Validate client-side
        PreDeploy->>Validation: Check schedule config
        Validation-->>PreDeploy: Result
        PreDeploy-->>DeployHook: Pass/Fail
        alt Validation Failed
            DeployHook-->>User: Show error notification
        else Validation Passed
            DeployHook-->>User: Open deploy modal
        end
    else First Deploy
        DeployHook->>API: POST /deploy
        API->>Validation: validateWorkflowSchedules
        Validation-->>API: isValid
        alt Invalid Schedule
            API-->>DeployHook: 400 Error
            DeployHook-->>User: Show error
        else Valid
            API->>DB: deployWorkflow
            API->>Deploy: createSchedulesForDeploy
            Deploy->>DB: UPSERT schedule records
            Deploy-->>API: ScheduleDeployResult
            API-->>DeployHook: Success + schedule info
            DeployHook-->>User: Open deploy modal
        end
    end
Loading

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.

31 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@waleedlatif1
Copy link
Collaborator Author

@greptile

@waleedlatif1
Copy link
Collaborator Author

@greptile

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.

36 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

@waleedlatif1
Copy link
Collaborator Author

@greptile

@waleedlatif1 waleedlatif1 merged commit 810d208 into staging Dec 24, 2025
10 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/schedules branch December 24, 2025 02:53
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