Skip to content

feat(duplicate): duplicate variables when duplicating a workflow#1254

Merged
waleedlatif1 merged 2 commits intostagingfrom
sim-67
Sep 5, 2025
Merged

feat(duplicate): duplicate variables when duplicating a workflow#1254
waleedlatif1 merged 2 commits intostagingfrom
sim-67

Conversation

@waleedlatif1
Copy link
Collaborator

Summary

duplicate variables when duplicating a workflow, previously we did not duplicate the variables along with the workflow itself but now we do. makes for a more cohesive and consistent UX, where the entire workflow state is picked up and copied over, including any variable references.

Type of Change

  • New feature

Testing

Tested manually, see below.

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-04.at.8.46.18.PM.mov

@vercel
Copy link

vercel bot commented Sep 5, 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 5, 2025 4:25am
1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
docs Skipped Skipped Sep 5, 2025 4: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 implements variable duplication when duplicating workflows, addressing a UX inconsistency where previously only the workflow structure was copied without its associated variables. The changes span three key layers:

Backend API Enhancement: The workflow duplication endpoint (/api/workflows/[id]/duplicate/route.ts) now properly creates new Variable objects with remapped UUIDs and correct workflow references during the duplication process. This ensures each duplicated workflow gets its own independent set of variables rather than sharing references with the source workflow.

Store Interface Extension: A new loadForWorkflow method is added to the VariablesStore interface (stores/panel/variables/types.ts) to support API-based variable loading for specific workflows.

Store Implementation: The variables store (stores/panel/variables/store.ts) implements the loadForWorkflow method, which fetches variables from the API and hydrates the store while preserving variables from other workflows. The method includes proper error handling and loading states.

Client-side Integration: The workflow registry store (stores/workflows/registry/store.ts) now calls the new loadForWorkflow method after successful workflow duplication to ensure the client-side store is immediately synchronized with the duplicated variables.

This creates a seamless experience where duplicated workflows appear with all their variables intact, maintaining referential integrity and providing immediate access to the copied variable state without requiring page refreshes or navigation.

Confidence score: 4/5

  • This PR is safe to merge with low risk as it adds new functionality without modifying existing workflows
  • Score reflects well-structured implementation with proper error handling and clear separation of concerns across API, store interface, and client integration
  • Pay close attention to the API route duplication logic to ensure variable ID remapping works correctly in all edge cases

4 files reviewed, 2 comments

Edit Code Review Bot Settings | Greptile

@vercel vercel bot temporarily deployed to Preview – docs September 5, 2025 04:20 Inactive
@waleedlatif1 waleedlatif1 merged commit 8668622 into staging Sep 5, 2025
3 of 4 checks passed
@waleedlatif1 waleedlatif1 deleted the sim-67 branch September 5, 2025 04:20
arenadeveloper02 pushed a commit to arenadeveloper02/p2-sim that referenced this pull request Sep 19, 2025
…studioai#1254)

* feat(duplicate): duplicate variables when duplicating a workflow

* better typing
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