Skip to content

Conversation

@icecrasher321
Copy link
Collaborator

Summary

Canonical Modes should be constructed based on copilot subblock choices.

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 25, 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 25, 2026 6:04am

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 25, 2026

Greptile Overview

Greptile Summary

This PR fixes a bug where canonical modes weren't being properly constructed when copilot edits workflows. The fix adds a new updateCanonicalModesForInputs function that analyzes subblock choices and sets appropriate canonical mode preferences (basic or advanced) based on which subblocks are being used. The function is called in two places:

  • When creating new blocks from copilot parameters
  • When editing existing blocks with new inputs

The implementation correctly handles canonical pairs (basic/advanced mode swaps), prioritizes advanced mode when both modes are present, and properly initializes the data.canonicalModes structure on blocks.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The implementation is straightforward and well-structured. It properly validates inputs, handles edge cases (checks for null/undefined values, validates canonical pairs), and follows existing patterns in the codebase. The logic correctly prioritizes advanced mode and only updates canonical modes when necessary.
  • No files require special attention

Important Files Changed

Filename Overview
apps/sim/lib/copilot/tools/server/workflow/edit-workflow.ts Added updateCanonicalModesForInputs function and integrated it into block creation/editing to properly set canonical mode preferences based on subblock choices

Sequence Diagram

sequenceDiagram
    participant Copilot
    participant EditWorkflow
    participant CreateBlock
    participant UpdateCanonical
    participant BlockRegistry
    participant CanonicalUtils

    Copilot->>EditWorkflow: Edit block with inputs
    EditWorkflow->>EditWorkflow: validateInputsForBlock()
    EditWorkflow->>BlockRegistry: getBlock(blockType)
    BlockRegistry-->>EditWorkflow: blockConfig
    
    alt Creating new block
        EditWorkflow->>CreateBlock: createBlockFromParams()
        CreateBlock->>CreateBlock: Setup subBlocks from config
        CreateBlock->>UpdateCanonical: updateCanonicalModesForInputs()
    else Editing existing block
        EditWorkflow->>EditWorkflow: Apply input changes
        EditWorkflow->>BlockRegistry: getBlock(blockType)
        BlockRegistry-->>EditWorkflow: blockConfig
        EditWorkflow->>UpdateCanonical: updateCanonicalModesForInputs()
    end
    
    UpdateCanonical->>CanonicalUtils: buildCanonicalIndex(subBlocks)
    CanonicalUtils-->>UpdateCanonical: canonicalIndex
    
    loop For each inputKey
        UpdateCanonical->>UpdateCanonical: Get canonicalId from index
        UpdateCanonical->>CanonicalUtils: isCanonicalPair(group)
        CanonicalUtils-->>UpdateCanonical: boolean
        UpdateCanonical->>UpdateCanonical: Determine mode (basic/advanced)
        UpdateCanonical->>UpdateCanonical: Store in canonicalModeUpdates
    end
    
    UpdateCanonical->>UpdateCanonical: Assign to block.data.canonicalModes
    UpdateCanonical-->>EditWorkflow: Block with canonical modes set
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.

No files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@icecrasher321
Copy link
Collaborator Author

@cursor review

@icecrasher321
Copy link
Collaborator Author

@cursor review

@icecrasher321 icecrasher321 changed the title fix(copilot): canonical modes should be constructed fix(copilot): canonical modes should be constructed on edit Jan 25, 2026
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 fa03d4d into staging Jan 25, 2026
11 checks passed
@icecrasher321 icecrasher321 deleted the fix/copilot-edit-canonical branch January 25, 2026 06:14
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