Skip to content

feat(registry): support multi-workflow delete - #1897

Merged
waleedlatif1 merged 2 commits into
stagingfrom
improvement/folders
Nov 11, 2025
Merged

feat(registry): support multi-workflow delete#1897
waleedlatif1 merged 2 commits into
stagingfrom
improvement/folders

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • support multi-workflow delete, reuse hook but extend it support a string[] of workflow ids
  • delete unused e2b switch

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)

@waleedlatif1
waleedlatif1 marked this pull request as ready for review November 11, 2025 20:48
@greptile-apps

greptile-appsBot commented Nov 11, 2025

Copy link
Copy Markdown
Contributor

Greptile Overview

Greptile Summary

This PR extends the workflow deletion system to support deleting multiple workflows at once. The implementation captures the selection state at right-click time, passes workflow IDs through a getWorkflowIds function, and handles navigation intelligently when the active workflow is among those being deleted. The PR also removes the unused E2BSwitch component and related code.

Key Changes:

  • Modified use-delete-workflow hook to accept getWorkflowIds() function instead of static ID, supporting both single and bulk deletion
  • Added selection capture in workflow-item.tsx using refs to preserve state across renders
  • Updated delete modal to display single or multiple workflow names
  • Conditionally hide rename option in context menu when multiple workflows selected
  • Removed E2BSwitch component and its special handling

Issues Found:

  • Critical bug in use-delete-workflow.ts:83-90 where activeWorkflowId determination incorrectly calls isActive recursively with single-element arrays, causing wrong navigation target selection
  • Minor issue in workflow-item.tsx:126-128 where workflows without names could result in empty modal text

Confidence Score: 2/5

  • This PR has a critical logical error in navigation logic that will cause incorrect behavior when deleting multiple workflows
  • The activeWorkflowId determination logic has a critical bug that will cause navigation to the wrong workflow when the active workflow is being deleted as part of a multi-delete operation. The recursive call to isActive with single-element arrays breaks the logic. Additionally, missing fallbacks for workflow names could cause poor UX.
  • apps/sim/app/workspace/[workspaceId]/w/hooks/use-delete-workflow.ts requires immediate attention to fix the activeWorkflowId logic

Important Files Changed

File Analysis

FilenameScoreOverview
apps/sim/app/workspace/[workspaceId]/w/hooks/use-delete-workflow.ts2/5Extended to support multi-workflow delete with navigation logic, but has critical bug in activeWorkflowId determination
apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components-new/workflow-list/components/workflow-item/workflow-item.tsx3/5Added selection capture at right-click and multi-delete support, minor issue with missing workflow name fallbacks
apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components-new/workflow-list/components/delete-modal/delete-modal.tsx5/5Updated to display single or multiple workflow names in delete confirmation, works correctly

Sequence Diagram

sequenceDiagram
participant User
participant WorkflowItem
participant ContextMenu
participant DeleteModal
participant useDeleteWorkflow
participant FolderStore
participant WorkflowRegistry
participant Router
User->>WorkflowItem: Right-click workflow
WorkflowItem->>FolderStore: Get current selection
alt Workflow not selected
WorkflowItem->>FolderStore: selectOnly(workflow.id)
end
WorkflowItem->>FolderStore: Get final selection
WorkflowItem->>WorkflowItem: Capture workflowIds & names in ref
WorkflowItem->>ContextMenu: Show context menu
User->>ContextMenu: Click Delete
ContextMenu->>WorkflowItem: onDelete()
WorkflowItem->>DeleteModal: Open with captured selection
User->>DeleteModal: Confirm delete
DeleteModal->>useDeleteWorkflow: handleDeleteWorkflow()
useDeleteWorkflow->>useDeleteWorkflow: getWorkflowIds()
useDeleteWorkflow->>WorkflowRegistry: Get sidebarWorkflows
useDeleteWorkflow->>useDeleteWorkflow: Find activeWorkflowId
useDeleteWorkflow->>useDeleteWorkflow: Find nextWorkflowId
alt Active workflow being deleted
alt Next workflow exists
useDeleteWorkflow->>Router: Navigate to next workflow
else No remaining workflows
useDeleteWorkflow->>Router: Navigate to workspace root
end
end
useDeleteWorkflow->>WorkflowRegistry: Promise.all(removeWorkflow())
useDeleteWorkflow->>FolderStore: clearSelection()
useDeleteWorkflow->>DeleteModal: onSuccess()
DeleteModal->>User: Close modal
Loading

@greptile-appsgreptile-appsBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

9 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment on lines +86 to 104
// Find the first workflow that's not being deleted
const remainingWorkflows = sidebarWorkflows.filter(
(w) => !workflowIdsToDelete.includes(w.id)
)

if (remainingWorkflows.length > 0) {
// Try to find the next workflow after the current one
const workflowsAfterCurrent = remainingWorkflows.filter((w) => {
const idx = sidebarWorkflows.findIndex((sw) => sw.id === w.id)
return idx > currentIndex
})

if (workflowsAfterCurrent.length > 0) {
nextWorkflowId = workflowsAfterCurrent[0].id
} else {
// Otherwise, use the first remaining workflow
nextWorkflowId = remainingWorkflows[0].id
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

logic: navigation logic may fail when deleting multiple workflows. The currentIndex is based on the first workflow in workflowIdsToDelete, but if workflows are not sequential in the sidebar, the "after current" logic could skip better navigation candidates.

Example: If deleting workflows at positions [2, 5, 8] and currently viewing position 2, it would look for workflows after position 2, skipping position 1 which might be a better candidate.

Suggested change
// Find the first workflow that's not being deleted
constremainingWorkflows=sidebarWorkflows.filter(
(w)=>!workflowIdsToDelete.includes(w.id)
)
if(remainingWorkflows.length>0){
// Try to find the next workflow after the current one
constworkflowsAfterCurrent=remainingWorkflows.filter((w)=>{
constidx=sidebarWorkflows.findIndex((sw)=>sw.id===w.id)
returnidx>currentIndex
})
if(workflowsAfterCurrent.length>0){
nextWorkflowId=workflowsAfterCurrent[0].id
}else{
// Otherwise, use the first remaining workflow
nextWorkflowId=remainingWorkflows[0].id
}
}
letnextWorkflowId: string|null=null
if(isActiveWorkflowBeingDeleted&&sidebarWorkflows.length>workflowIdsToDelete.length){
// Find the first workflow that's not being deleted
constremainingWorkflows=sidebarWorkflows.filter(
(w)=>!workflowIdsToDelete.includes(w.id)
)
if(remainingWorkflows.length>0){
// Find the active workflow's current index
constactiveWorkflowId=typeofisActive==='function'
? sidebarWorkflows.find(w=>workflowIdsToDelete.includes(w.id))?.id
: workflowIdsToDelete[0]
constactiveIndex=sidebarWorkflows.findIndex((w)=>w.id===activeWorkflowId)
// Try to find the next workflow after the active one
constworkflowsAfterActive=remainingWorkflows.filter((w)=>{
constidx=sidebarWorkflows.findIndex((sw)=>sw.id===w.id)
returnidx>activeIndex
})
if(workflowsAfterActive.length>0){
nextWorkflowId=workflowsAfterActive[0].id
}else{
// Otherwise, use the last remaining workflow (closest before active)
nextWorkflowId=remainingWorkflows[remainingWorkflows.length-1].id
}
}
}
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/sim/app/workspace/[workspaceId]/w/hooks/use-delete-workflow.ts
Line: 86:104
Comment:
**logic:** navigation logic may fail when deleting multiple workflows. The `currentIndex` is based on the first workflow in `workflowIdsToDelete`, but if workflows are not sequential in the sidebar, the "after current" logic could skip better navigation candidates.
Example: If deleting workflows at positions [2, 5, 8] and currently viewing position 2, it would look for workflows after position 2, skipping position 1 which might be a better candidate.
```suggestion let nextWorkflowId: string | null = null if (isActiveWorkflowBeingDeleted && sidebarWorkflows.length > workflowIdsToDelete.length) { // Find the first workflow that's not being deleted const remainingWorkflows = sidebarWorkflows.filter( (w) => !workflowIdsToDelete.includes(w.id) ) if (remainingWorkflows.length > 0) { // Find the active workflow's current index const activeWorkflowId = typeof isActive === 'function'  ? sidebarWorkflows.find(w => workflowIdsToDelete.includes(w.id))?.id  : workflowIdsToDelete[0] const activeIndex = sidebarWorkflows.findIndex((w) => w.id === activeWorkflowId) // Try to find the next workflow after the active one const workflowsAfterActive = remainingWorkflows.filter((w) => { const idx = sidebarWorkflows.findIndex((sw) => sw.id === w.id) return idx > activeIndex }) if (workflowsAfterActive.length > 0) { nextWorkflowId = workflowsAfterActive[0].id } else { // Otherwise, use the last remaining workflow (closest before active) nextWorkflowId = remainingWorkflows[remainingWorkflows.length - 1].id } } }```
How can I resolve this? If you propose a fix, please make it concise.

@vercel

vercelBot commented Nov 11, 2025

Copy link
Copy Markdown

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

1 Skipped Deployment
ProjectDeploymentPreviewCommentsUpdated (UTC)
docsSkippedSkippedNov 11, 2025 8:55pm

@waleedlatif1

Copy link
Copy Markdown
CollaboratorAuthor

@greptile

@waleedlatif1
waleedlatif1 merged commit a6a9962 into stagingNov 11, 2025
4 checks passed
@waleedlatif1
waleedlatif1 deleted the improvement/folders branch November 11, 2025 20:55

@greptile-appsgreptile-appsBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

9 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Comment on lines +83 to +90
let activeWorkflowId: string | null = null
if (isActiveWorkflowBeingDeleted && typeof isActive === 'function') {
// Check each workflow being deleted to find which one is active
activeWorkflowId =
workflowIdsToDelete.find((id) => isActive([id])) || workflowIdsToDelete[0]
} else {
activeWorkflowId = workflowIdsToDelete[0]
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

logic: logic issue: incorrect activeWorkflowId when isActive is a function. Line 87 recursively calls isActive with a single-element array, but isActive expects the full array. This returns the wrong result.

Example: Deleting workflows ['id1', 'id2', 'id3'], active is 'id2'. Line 86 will call isActive(['id1']), which returns false, so defaults to workflowIdsToDelete[0] ('id1'), even though 'id2' is the active one.

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/sim/app/workspace/[workspaceId]/w/hooks/use-delete-workflow.ts
Line: 83:90
Comment:
**logic:** logic issue: incorrect `activeWorkflowId` when `isActive` is a function. Line 87 recursively calls `isActive` with a single-element array, but `isActive` expects the full array. This returns the wrong result.
Example: Deleting workflows ['id1', 'id2', 'id3'], active is 'id2'. Line 86 will call `isActive(['id1'])`, which returns false, so defaults to `workflowIdsToDelete[0]` ('id1'), even though 'id2' is the active one.
How can I resolve this? If you propose a fix, please make it concise.

Comment on lines +126 to +128
const workflowNames = workflowIds
.map((id) => workflows[id]?.name)
.filter((name): name is string => !!name)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

logic: potential issue: if some workflows don't have names (undefined), workflowNames could be empty, causing incorrect modal text. Should include fallback like "Untitled Workflow".

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components-new/workflow-list/components/workflow-item/workflow-item.tsx
Line: 126:128
Comment:
**logic:** potential issue: if some workflows don't have names (undefined), `workflowNames` could be empty, causing incorrect modal text. Should include fallback like "Untitled Workflow".
How can I resolve this? If you propose a fix, please make it concise.

waleedlatif1 added a commit that referenced this pull request Nov 12, 2025
* feat(registry): support multi-workflow delete
* added intelligent next index selection if deleting active workflow
waleedlatif1 added a commit that referenced this pull request Nov 12, 2025
* feat(registry): support multi-workflow delete
* added intelligent next index selection if deleting active workflow
@waleedlatif1waleedlatif1 mentioned this pull request Nov 12, 2025
10 tasks
Sign up for freeto 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

@waleedlatif1