Skip to content

Conversation

@waleedlatif1
Copy link
Collaborator

Summary

  • Action bar duplicate now includes children for loop/parallel blocks
  • Uses same copyBlocks + preparePasteData pattern as context menu

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 21, 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 21, 2026 10:47pm

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 21, 2026

Greptile Summary

This PR fixes the action bar duplicate functionality to properly include children when duplicating loop/parallel blocks. The implementation refactors handleDuplicateBlock to use the copyBlocks + preparePasteData pattern from the workflow registry, which automatically handles nested block inclusion and ID regeneration. It also adds trigger validation to prevent invalid duplications and error notifications when conflicts occur.

Changes:

  • Replaced manual block duplication logic with copyBlocks() + preparePasteData() pattern
  • Added validateTriggerPaste() validation to check for trigger constraints
  • Added error notifications for validation failures
  • Properly passes all required parameters to collaborativeBatchAddBlocks() including edges, loops, parallels, and subblock values
  • Updated dependencies in useCallback to reflect the new logic flow

Confidence Score: 5/5

  • This PR is safe to merge with no concerns
  • The refactoring uses well-established patterns already present in the workflow.tsx file's executePasteOperation function. The copyBlocks function automatically includes children via its built-in loop/parallel node detection. The preparePasteData and regenerateBlockIds functions properly handle ID mapping, reference updates, and position offsetting for nested blocks. The addition of validateTriggerPaste validation strengthens the implementation by preventing invalid duplications. The code follows existing patterns, maintains proper state management, and includes appropriate error handling.
  • No files require special attention

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/action-bar/action-bar.tsx Refactored duplicate block handler to use copyBlocks + preparePasteData pattern instead of manual duplication logic. This ensures children of loop/parallel blocks are included when duplicating. Added trigger validation using validateTriggerPaste and error notification handling.

Sequence Diagram

sequenceDiagram
    participant User
    participant ActionBar as ActionBar Component
    participant WorkflowRegistry as WorkflowRegistry Store
    participant WorkflowStore as WorkflowStore
    participant Clipboard as Clipboard State

    User->>ActionBar: Click duplicate button
    ActionBar->>WorkflowRegistry: getState() to access copyBlocks & preparePasteData
    
    ActionBar->>WorkflowRegistry: copyBlocks([blockId])
    activate WorkflowRegistry
    Note over WorkflowRegistry: Auto-includes nested nodes<br/>from loop/parallel blocks
    WorkflowRegistry->>WorkflowStore: getState() to read blocks, loops, parallels
    WorkflowRegistry->>Clipboard: Store copied data (blocks, edges, loops, parallels, subBlockValues)
    deactivate WorkflowRegistry
    
    ActionBar->>WorkflowRegistry: preparePasteData(offset)
    activate WorkflowRegistry
    Note over WorkflowRegistry: Regenerates IDs<br/>Updates references<br/>Handles positioning
    WorkflowRegistry->>Clipboard: Read clipboard data
    WorkflowRegistry->>WorkflowRegistry: regenerateBlockIds()
    deactivate WorkflowRegistry
    
    ActionBar->>ActionBar: validateTriggerPaste(blocks, existingBlocks)
    
    alt Validation succeeds
        ActionBar->>ActionBar: collaborativeBatchAddBlocks(blocks, edges, loops, parallels, subBlockValues)
        ActionBar->>WorkflowStore: Add duplicated blocks with children
        Note over WorkflowStore: New blocks include<br/>children & proper<br/>parentId relationships
    else Validation fails (trigger conflict)
        ActionBar->>User: Show error notification
    end
Loading

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.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

@waleedlatif1
Copy link
Collaborator Author

@greptile

@waleedlatif1 waleedlatif1 merged commit 8bbcf31 into staging Jan 21, 2026
12 checks passed
@waleedlatif1 waleedlatif1 deleted the improvement/duplicate branch January 21, 2026 22:54
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