Skip to content

Conversation

@waleedlatif1
Copy link
Collaborator

Summary

  • update workflows to use deployed variables, not local ones to align with the rest of the canvas components
  • fix has changes being triggered when an integration trigger/webhook is saved

Type of Change

  • New feature

Testing

Tested manually

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)

…ot local ones to align with the rest of the canvas components
…data and not actually required to be redeployed
@vercel
Copy link

vercel bot commented Dec 25, 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 25, 2025 1:37am

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 25, 2025

Greptile Summary

This PR aligns workflow execution behavior with other canvas components by using deployed variables instead of local ones, and fixes false-positive change detection for integration triggers.

Key Changes:

  • Workflow executions now use variables from the deployment version snapshot, not the current local workflow variables
  • Variables are now included in change detection comparison (client-side hook and API endpoints)
  • Trigger runtime metadata (webhookId, triggerPath, testUrl, testUrlExpiresAt) is now excluded from change detection to prevent false positives when saving integration triggers
  • Removed manual state management for needsRedeployment flag - now fully computed based on state comparison
  • Added comprehensive test coverage for variables and trigger metadata in change detection

Technical Implementation:

  • The DeployedWorkflowData interface now includes variables field
  • The loadDeployedWorkflowState function returns variables from the deployment version
  • The deployWorkflow function saves variables alongside blocks/edges/loops/parallels in the deployment snapshot
  • The hasWorkflowChanged comparison function now compares variables and filters out trigger runtime subblocks
  • The useChangeDetection hook includes workflow variables in its state comparison

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The implementation is well-structured with proper fallbacks (|| {} for variables), comprehensive test coverage for new functionality, and clean refactoring that removes manual state management. The changes align with established patterns in the codebase and fix legitimate issues with change detection
  • No files require special attention

Important Files Changed

Filename Overview
apps/sim/app/api/workflows/[id]/execute/route.ts Updated execution to use deployed variables from deployment version instead of local workflow variables
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/deploy/hooks/use-change-detection.ts Added variables to change detection state comparison, removed setChangeDetected function
apps/sim/lib/workflows/comparison/compare.ts Added variables comparison and trigger runtime metadata exclusion to change detection
apps/sim/lib/workflows/persistence/utils.ts Updated interfaces and functions to include variables in deployed workflow data

Sequence Diagram

sequenceDiagram
    participant Client as Client (Canvas)
    participant ChangeDetection as useChangeDetection Hook
    participant VariablesStore as Variables Store
    participant DeployAPI as Deploy API
    participant StatusAPI as Status API
    participant ExecuteAPI as Execute API
    participant DB as Database
    participant DeploymentVersion as Deployment Version Table
    
    Note over Client,DB: Change Detection Flow
    Client->>VariablesStore: Get workflow variables
    VariablesStore-->>ChangeDetection: Return variables filtered by workflowId
    Client->>ChangeDetection: Detect changes (blocks, edges, loops, parallels, variables)
    ChangeDetection->>ChangeDetection: Build currentState with variables
    ChangeDetection->>ChangeDetection: Compare with deployedState (hasWorkflowChanged)
    Note over ChangeDetection: Excludes trigger runtime metadata<br/>(webhookId, triggerPath, testUrl, testUrlExpiresAt)
    ChangeDetection-->>Client: Return changeDetected flag
    
    Note over Client,DB: Deployment Flow
    Client->>DeployAPI: POST /api/workflows/{id}/deploy
    DeployAPI->>DB: Load workflow from normalized tables
    DeployAPI->>DB: Fetch workflow.variables
    DeployAPI->>DeployAPI: Build currentState with variables
    DeployAPI->>DeploymentVersion: Create deployment version with state + variables
    DeployAPI-->>Client: Return deployment success
    
    Note over Client,DB: Status Check Flow
    Client->>StatusAPI: GET /api/workflows/{id}/status
    StatusAPI->>DB: Load workflow from normalized tables
    StatusAPI->>DB: Fetch workflow.variables
    StatusAPI->>StatusAPI: Build currentState with variables
    StatusAPI->>StatusAPI: Compare with deployed state
    StatusAPI-->>Client: Return needsRedeployment flag
    
    Note over Client,DB: Execution Flow
    Client->>ExecuteAPI: POST /api/workflows/{id}/execute
    ExecuteAPI->>DeploymentVersion: Load deployed workflow state
    DeploymentVersion-->>ExecuteAPI: Return state with variables
    ExecuteAPI->>ExecuteAPI: Use deployedVariables (not local workflow.variables)
    ExecuteAPI->>ExecuteAPI: Create ExecutionSnapshot with deployedVariables
    ExecuteAPI-->>Client: Stream execution with deployed variables
Loading

@waleedlatif1 waleedlatif1 merged commit 40a6bf5 into staging Dec 25, 2025
7 checks passed
@waleedlatif1 waleedlatif1 deleted the improvement/vars branch December 25, 2025 01:40
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