Skip to content

Conversation

@icecrasher321
Copy link
Collaborator

Summary

  • Canonical Modes being stripped on copilot edits
  • Update Parent had same issue
  • Must queue edge deletion on remove from subflow correctly

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 Jan 20, 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 20, 2026 5:39pm

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 20, 2026

Greptile Summary

This PR fixes issues where block data properties (specifically canonicalModes) were being stripped during copilot edits and parent updates.

Key Changes:

  • Added canonicalModes field to the Zod schema in the state API route to prevent validation from stripping this property
  • Modified parent update logic in database operations to preserve all data properties except parentId and extent when removing from parent (previously cleared all data)
  • Added proper operation queueing for edge deletion when updating parent to ensure collaborative sync

Technical Details:
The root cause was that when removing a block from a subflow parent, the code was setting data: {} which cleared ALL properties including canonicalModes. The fix uses object destructuring to only remove parentId and extent while preserving other properties like canonicalModes, width, height, etc.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The changes are well-targeted bug fixes with clear intent. The destructuring pattern preserves existing data properties correctly, and the edge deletion queueing follows established patterns in the codebase. All changes maintain backward compatibility.
  • No files require special attention

Important Files Changed

Filename Overview
apps/sim/app/api/workflows/[id]/state/route.ts Added canonicalModes to BlockDataSchema to prevent stripping during state validation
apps/sim/hooks/use-collaborative-workflow.ts Added edge deletion queueing when updating parent to properly sync edge removal operations
apps/sim/socket/database/operations.ts Fixed data preservation by using destructuring to only remove parentId and extent when removing from parent, preserving other properties like canonicalModes

Sequence Diagram

sequenceDiagram
    participant Client
    participant API as State API
    participant Hook as useCollaborativeWorkflow
    participant Store as WorkflowStore
    participant Socket as Socket Operations
    participant DB as Database Operations

    Note over Client,DB: Copilot Edit Flow (preserving canonicalModes)
    Client->>API: PUT /api/workflows/[id]/state
    API->>API: Validate with BlockDataSchema<br/>(includes canonicalModes)
    API->>DB: Save workflow state
    DB->>DB: Preserve canonicalModes in block.data
    API-->>Client: Success

    Note over Client,DB: Update Parent Flow (edge cleanup)
    Client->>Hook: collaborativeBatchUpdateParent
    Hook->>Hook: Collect affected edges
    Hook->>Socket: Queue BATCH_REMOVE_EDGES operation
    Hook->>Store: batchRemoveEdges(edgeIds)
    Hook->>Socket: Queue BATCH_UPDATE_PARENT operation
    Hook->>Store: batchUpdateBlocksWithParent
    Socket->>DB: Persist edge removal
    Socket->>DB: Persist parent update
    DB->>DB: Destructure to remove only<br/>parentId & extent
    DB->>DB: Preserve canonicalModes & other data
    DB-->>Socket: Success
    Socket-->>Client: Sync to other clients
Loading

@icecrasher321 icecrasher321 merged commit 689037a into staging Jan 20, 2026
11 checks passed
@icecrasher321 icecrasher321 deleted the fix/canonical-modes-save branch January 20, 2026 17:43
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