Skip to content

Conversation

@icecrasher321
Copy link
Collaborator

@icecrasher321 icecrasher321 commented Jan 16, 2026

Summary

  • Can switch to advanced at the subblock level. Also have a box to show advanced fields instead of gear icon in the top.
  • Hide Form Deploy from Docs
  • Serializer cleanup
  • Preprocessing Checks for different async trigger paths consolidated, removed redundant checks

Type of Change

  • Other: UX Improvement + Code refactor

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)

@vercel
Copy link

vercel bot commented Jan 16, 2026

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

Project Deployment Review Updated (UTC)
docs Ready Ready Preview, Comment Jan 16, 2026 7:59am

Review with Vercel Agent

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 16, 2026

Greptile Summary

This PR consolidates preprocessing checks and refactors the serializer/validation logic across async execution paths. The main improvements are:

  • Consolidated Preprocessing: Env var validation (ensureEnvVarsDecryptable, ensureBlockVariablesResolvable) has been moved from schedule-execution.ts into the centralized preprocessExecution function with a new preflightEnvVars flag, eliminating duplicate checks across schedule, webhook, and workflow execution paths.

  • Serializer Refactor: The serializer now properly delegates visibility logic to the established visibility module (buildCanonicalIndex, evaluateSubBlockCondition, getCanonicalValues), removing inline condition evaluation. Response format parsing and tool selection are extracted into reusable helpers.

  • Centralized Reference Validation: Env var resolution logic is consolidated into a single resolveEnvVarReferences function in reference-validation.ts with configurable options (exact match, embedded resolution, trimming, missing handling). This replaces duplicated resolution logic across copilot/execute-tool and removed code from schedule-execution.ts.

  • Smart Preflight Strategy: Env var preflight is conditionally enabled: only for async Trigger.dev executions (to catch issues early), skipped for synchronous execution and resume contexts (avoiding redundant checks).

  • Code Cleanup: Removed redundant imports (decryptSecret, REFERENCE), unused utility functions, and simplified error handling in the serializer.

All changes maintain backward compatibility and improve code maintainability by centralizing cross-cutting concerns.

Confidence Score: 5/5

  • This PR is safe to merge. It is a well-executed refactoring that consolidates validation logic, centralizes repeated code, and improves code organization without introducing breaking changes.
  • The PR merits a high confidence score because: (1) All changes are refactoring/consolidation with no new feature logic, reducing risk. (2) The preprocessing consolidation properly threads flags through execution paths without changing behavior. (3) Visibility and validation logic is moved to established modules rather than new implementations. (4) The previous comment about the schedule route handling env var preflight failures was resolved by moving validation into preprocessing with proper error handling. (5) Tests are included and passing. (6) Changes follow existing code patterns and architectural principles. (7) No changes to critical execution paths or security boundaries.
  • No files require special attention. All changes are well-contained, properly integrated, and follow established patterns.

Important Files Changed

Filename Overview
apps/sim/serializer/index.ts Comprehensive serializer refactor: Replaced inline condition logic with visibility module functions (buildCanonicalIndex, evaluateSubBlockCondition, getCanonicalValues). Extracted parseResponseFormatSafely call to shared utility. Removed duplicate tool selection logic by introducing selectToolId helper. Improved canonical pair handling with dedicated functions. All changes are well-structured and reduce code duplication.
apps/sim/lib/execution/preprocessing.ts Added new preflightEnvVars and envUserId parameters to preprocessing flow. When enabled, calls preflightWorkflowEnvVars before returning success. Properly logs errors and returns appropriate error responses. Implementation follows existing error handling patterns. Well-integrated into preprocessing pipeline.
apps/sim/executor/utils/reference-validation.ts Refactored env var resolution into configurable resolveEnvVarReferences function with EnvVarResolveOptions. Supports exact match and embedded resolution, key trimming, and configurable missing value handling. Well-documented and consolidates env var resolution logic that was previously duplicated across multiple files.
apps/sim/background/schedule-execution.ts Removed redundant env var validation functions (ensureBlockVariablesResolvable, ensureEnvVarsDecryptable). Added preflighted flag to payload and passed it to preprocessing. Conditional env var preflight based on payload flag. Consolidates preprocessing checks into a single call, avoiding duplicate validation logic.
apps/sim/app/api/workflows/[id]/execute/route.ts Added preflighted flag to async execution flow. Env var preflight enabled only for async Trigger.dev executions. Properly threaded shouldPreflightEnvVars flag through preprocessing and async handler. Logic is sound: avoids redundant preflight for sync execution and allows resume scenarios to skip preflight.
apps/sim/app/api/copilot/execute-tool/route.ts Removed duplicate resolveEnvVarReferences function and imported centralized version from reference-validation. Updated call to include options config for exact match and embedded resolution. Properly passes onMissing: 'keep' to maintain original behavior.

Sequence Diagram

sequenceDiagram
    participant Client
    participant API as API Route
    participant Preprocess as Preprocessing
    participant Preflight as Env Preflight
    participant Execution as Schedule Execution
    participant Logger as Logger

    Client->>API: Trigger Workflow Execution
    API->>Preprocess: preprocessExecution({preflightEnvVars: true})
    
    Preprocess->>Logger: Validate Workflow Exists
    Preprocess->>Logger: Check Deployment Status
    Preprocess->>Logger: Resolve Billing Actor
    Preprocess->>Logger: Get User Subscription
    Preprocess->>Logger: Check Rate Limits
    Preprocess->>Logger: Check Usage Limits
    
    Preprocess->>Preflight: await preflightWorkflowEnvVars()
    alt Preflight Success
        Preflight-->>Preprocess: Return Success
        Preprocess-->>API: Return {success: true}
    else Preflight Fails
        Preflight-->>Logger: Log Error
        Preprocess-->>API: Return {success: false, error}
    end
    
    API->>Execution: handleAsyncExecution({preflighted: true})
    Execution->>Logger: Execute Workflow Core (skip preflight)
    Execution-->>Client: Return Execution Result
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.

44 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@icecrasher321
Copy link
Collaborator Author

@greptile

@icecrasher321
Copy link
Collaborator Author

@greptile

…block

# Conflicts:
#	apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/sub-block.tsx
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