Skip to content

Conversation

aadamgough
Copy link
Collaborator

Summary

Added in the ability to duplicate a subflow with the children and sub block values.

Type of Change

  • Other: improvement

Testing

See video

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)

Screenshots/Videos

Screen.Recording.2025-09-14.at.11.55.14.PM.mov

Copy link

vercel bot commented Sep 15, 2025

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

Project Deployment Preview Comments Updated (UTC)
sim Ready Ready Preview Comment Sep 15, 2025 7:25am
1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
docs Skipped Skipped Sep 15, 2025 7: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 Summary

This PR adds comprehensive functionality for duplicating subflows (loop and parallel blocks) along with all their child blocks and internal connections in Sim's collaborative workflow editor. The feature enables users to quickly replicate complex workflow structures while preserving all nested content, configurations, and block references.

The implementation spans multiple architectural layers:

Backend Infrastructure: New database operations handle atomic creation of parent subflow blocks, child blocks with proper parent-child relationships, and internal edges. The socket server middleware adds duplicate-with-children permissions for admin and write users, with comprehensive validation schemas for the complex operation payload.

Real-time Collaboration: The collaborative workflow system is extended with collaborativeDuplicateSubflow functionality that performs optimistic local updates followed by server synchronization. This ensures all collaborators immediately see duplicated structures with proper ID mapping and reference updates.

Reference Integrity: A new utility (updateBlockReferences) handles updating block ID references within subblock values during duplication, replacing patterns like <oldId. and %oldId. with new mapped IDs to maintain referential integrity in the duplicated structure.

User Interface: The subflow node component adds a duplicate button in the hover toolbar alongside the existing delete button, providing intuitive access to the duplication feature.

The feature integrates seamlessly with Sim's existing collaborative architecture, following established patterns for real-time synchronization, permission management, and atomic database operations. This enhancement significantly improves workflow productivity by allowing users to duplicate complex subflow structures without manual recreation.

Confidence score: 3/5

  • This PR introduces complex functionality with potential edge cases around reference mapping and collaborative synchronization
  • Score reflects concerns about pattern specificity in reference updates and the complexity of multi-table database operations
  • Pay close attention to lib/workflows/reference-utils.ts and the collaborative workflow hooks for potential reference mapping issues

7 files reviewed, 1 comment

Edit Code Review Bot Settings | Greptile

if (typeof value === 'string') {
let result = value
for (const [oldId, newId] of blockIdMapping.entries()) {
if (result.includes(oldId)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Using includes() check before replacement is inefficient and could cause false positives. A block ID 'abc' would match strings containing 'abc' even when not in reference format.

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.

1 participant