Skip to content

Conversation

@icecrasher321
Copy link
Collaborator

Summary

Code quality improvement for webhooks

Type of Change

  • Code Quality Improvement

Testing

Tested manually. Webhook/Schedule Lifecycle

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 Jan 24, 2026

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

1 Skipped Deployment
Project Deployment Review Updated (UTC)
docs Skipped Skipped Jan 24, 2026 7:00am

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 24, 2026

Greptile Summary

Removed ~578 lines of dead code from webhook and workflow lifecycle management. The changes consolidate webhook CRUD operations to the deploy flow only, eliminating unused UI-driven webhook management.

Key Changes

  • Webhook management hook: Removed saveConfig, deleteConfig, createWebhook, and updateWebhook functions (~200 lines). Hook now only loads webhook info for display.
  • Store cleanup: Removed unused toggleBlockTriggerMode function (88 lines) that was attempting to manage webhook active state from the UI.
  • API endpoint simplification: Webhook PATCH endpoint no longer accepts path, provider, or providerConfig updates - only isActive and failedCount remain updateable.
  • Dynamic import elimination: Replaced 14+ dynamic imports across webhook files with static imports for better bundling and performance.
  • Deploy flow improvements: Enhanced saveTriggerWebhooksForDeploy with two-phase creation (external subscriptions first, then DB transaction), better version cleanup with previousVersionId tracking, and forceRecreateSubscriptions for version reactivation.
  • Schedule handling: Added disabled block filtering and orphaned schedule cleanup.
  • Version activation: Admin version activation endpoint now includes full deployment lifecycle (triggers, schedules, MCP sync).

Confidence Score: 5/5

  • Safe to merge - removes unused code paths and improves webhook lifecycle management
  • The PR removes genuinely dead code (unused webhook CRUD functions, unused store actions) and improves the deployment flow with better transactional guarantees. The two-phase webhook creation pattern and proper cleanup of previous versions are improvements. Static imports replace dynamic imports for better performance. Test coverage includes the new disabled block filtering. All changes are consistent with the stated goal of code quality improvement.
  • No files require special attention

Important Files Changed

Filename Overview
apps/sim/hooks/use-webhook-management.ts Removed 200+ lines of unused webhook CRUD operations (saveConfig, deleteConfig, createWebhook, updateWebhook) - webhook lifecycle now handled entirely by deploy flow
apps/sim/stores/workflows/workflow/store.ts Removed 88 lines of dead toggleBlockTriggerMode function and related webhook toggle logic
apps/sim/app/api/webhooks/[id]/route.ts Removed 80+ lines from PATCH endpoint - path, provider, and providerConfig updates no longer supported (only isActive and failedCount remain)
apps/sim/lib/webhooks/deploy.ts Major refactoring: added previousVersionId/forceRecreateSubscriptions params, two-phase webhook creation (external subscriptions first, then DB records in transaction), improved cleanup logic
apps/sim/app/api/v1/admin/workflows/[id]/versions/[versionId]/activate/route.ts Added full deployment lifecycle logic (triggers, schedules, cleanup) to version activation endpoint - mirrors deploy route logic

Sequence Diagram

sequenceDiagram
    participant Client
    participant DeployAPI as Deploy API
    participant WebhookDeploy as lib/webhooks/deploy
    participant ExternalProvider as External Webhook Provider
    participant DB as Database
    participant ScheduleDeploy as lib/workflows/schedules/deploy
    
    Note over Client,ScheduleDeploy: Workflow Deployment Flow

    Client->>DeployAPI: POST /api/workflows/{id}/deploy
    DeployAPI->>DB: Get current active version ID
    DeployAPI->>DB: Create new deployment version
    
    DeployAPI->>WebhookDeploy: saveTriggerWebhooksForDeploy(previousVersionId)
    
    Note over WebhookDeploy,DB: Cleanup Phase
    WebhookDeploy->>DB: Get all workflow webhooks
    WebhookDeploy->>ExternalProvider: Delete subscriptions for previous version
    WebhookDeploy->>DB: Identify webhooks to delete/recreate
    
    Note over WebhookDeploy,ExternalProvider: Two-Phase Creation
    loop For each new webhook
        WebhookDeploy->>ExternalProvider: Create external subscription
        ExternalProvider-->>WebhookDeploy: Return subscription details
    end
    
    WebhookDeploy->>DB: Insert all webhooks in transaction
    WebhookDeploy-->>DeployAPI: Success
    
    DeployAPI->>ScheduleDeploy: createSchedulesForDeploy()
    ScheduleDeploy->>DB: Delete orphaned schedules
    ScheduleDeploy->>DB: Create/update schedules
    ScheduleDeploy-->>DeployAPI: Success
    
    DeployAPI->>ScheduleDeploy: cleanupDeploymentVersion(previousVersionId, skipExternalCleanup=true)
    ScheduleDeploy->>DB: Delete previous version webhooks/schedules
    
    DeployAPI-->>Client: Deployment successful
Loading

@icecrasher321
Copy link
Collaborator Author

@cursor review

@icecrasher321
Copy link
Collaborator Author

@cursor review

@icecrasher321
Copy link
Collaborator Author

@cursor review

@icecrasher321
Copy link
Collaborator Author

@cursor review

@icecrasher321
Copy link
Collaborator Author

@cursor review

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

@icecrasher321 icecrasher321 merged commit 12100e6 into staging Jan 24, 2026
11 checks passed
@icecrasher321 icecrasher321 deleted the fix/config-webhook-preserve branch January 24, 2026 07:18
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