Skip to content

Conversation

@icecrasher321
Copy link
Collaborator

@icecrasher321 icecrasher321 commented Oct 2, 2025

Summary

Type issue with deployedStatus and deployedAt fields -- if workflow was deployed. This fixes that.

Removed dead workflow state fields

Type of Change

  • Bug fix

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 Oct 2, 2025

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

Project Deployment Preview Comments Updated (UTC)
sim Ready Ready Preview Comment Oct 2, 2025 3:25am
1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
docs Skipped Skipped Oct 2, 2025 3:25am

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 addresses a type validation error that occurred when auto-layout operations were performed on deployed workflows. The core issue was that UI-only fields like `deploymentStatuses`, `needsRedeployment`, and `dragStartPosition` were being sent to the API along with the persistent workflow state, causing schema validation to fail.

The fix involves two complementary changes:

  1. Client-side cleanup: In the auto-layout utility (auto-layout.ts), the code now destructures out UI-only fields before sending the workflow state to the API. This ensures only database-appropriate fields are persisted while maintaining existing data transformation logic for dates and optional fields.

  2. API schema adjustment: The workflow state API schema (route.ts) was updated to remove the DeploymentStatusSchema and deploymentStatuses field entirely, acknowledging these as UI-only concerns. The deployedAt field now uses z.coerce.date() to handle string-to-Date conversion gracefully.

This change maintains the architectural separation between transient UI state and persistent database state. The auto-layout feature can now handle deployed workflows without triggering type validation errors, while preserving all existing functionality for date handling and optional field management.

Important Files Changed

Changed Files
Filename Score Overview
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/utils/auto-layout.ts 4/5 Destructures UI-only fields before API persistence to prevent type validation errors
apps/sim/app/api/workflows/[id]/state/route.ts 4/5 Removes deployment status schema and updates deployedAt field to use date coercion

Confidence score: 4/5

  • This PR is safe to merge with minimal risk as it addresses a specific type validation bug without changing core functionality
  • Score reflects focused changes that properly separate UI state from persistent state with clear architectural reasoning
  • Pay close attention to the API schema changes to ensure downstream compatibility with existing deployed workflows

Sequence Diagram

sequenceDiagram
    participant User
    participant Client as "Auto Layout Client"
    participant AutoLayoutAPI as "/api/workflows/[id]/autolayout"
    participant StateAPI as "/api/workflows/[id]/state"
    participant DB as "Database"
    participant Store as "Workflow Store"
    
    User->>Client: "Trigger auto layout"
    Client->>Store: "Get current workflow state"
    Store-->>Client: "blocks, edges, loops, parallels"
    
    Client->>AutoLayoutAPI: "POST layout request with workflow data"
    AutoLayoutAPI-->>Client: "layouted blocks with new positions"
    
    Client->>Store: "Update store with new positions"
    Store-->>Client: "State updated"
    
    Note over Client: Clean workflow state for persistence
    Client->>Client: "Remove UI-only fields (deploymentStatuses, etc.)"
    Client->>Client: "Convert null dates to undefined"
    Client->>Client: "Sanitize edges handles"
    
    Client->>StateAPI: "PUT cleaned workflow state"
    StateAPI->>DB: "Save to normalized tables"
    DB-->>StateAPI: "Save confirmation"
    StateAPI-->>Client: "Success response"
    
    alt Save fails
        Client->>Store: "Revert to original positions"
        Store-->>Client: "State reverted"
        Client-->>User: "Error: Failed to save positions"
    else Save succeeds
        Client-->>User: "Auto layout applied successfully"
    end
Loading

2 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@vercel vercel bot temporarily deployed to Preview – docs October 2, 2025 03:15 Inactive
@icecrasher321 icecrasher321 changed the title fix(autolayout): type issue if workflow deployed fix(autolayout): type issue if workflow deployed + remove dead state code Oct 2, 2025
@icecrasher321 icecrasher321 merged commit 3509ce8 into staging Oct 2, 2025
9 of 10 checks passed
waleedlatif1 pushed a commit that referenced this pull request Oct 2, 2025
…code (#1524)

* fix(autolayout): type issue if workflow deployed

* remove dead code hasActiveWebhook field
@waleedlatif1 waleedlatif1 deleted the fix/autolayout-type-error branch October 13, 2025 17:38
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