Skip to content

Commit 0eea69b

Browse files
waleedlatif1claude
andcommitted
fix(lock): prevent duplicates inside locked containers via regenerateBlockIds
1. regenerateBlockIds now checks if existing parent is locked before keeping the block inside it. If parent is locked, the duplicate is placed outside (parentId cleared) instead of creating an inconsistent state. 2. Remove unnecessary effectivePermissions.canAdmin and potentialParentId from onNodeDragStart dependency array. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 802884f commit 0eea69b

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2889,14 +2889,7 @@ const WorkflowContent = React.memo(() => {
28892889
}
28902890
})
28912891
},
2892-
[
2893-
blocks,
2894-
setDragStartPosition,
2895-
getNodes,
2896-
potentialParentId,
2897-
setPotentialParentId,
2898-
effectivePermissions.canAdmin,
2899-
]
2892+
[blocks, setDragStartPosition, getNodes, setPotentialParentId]
29002893
)
29012894

29022895
/** Handles node drag stop to establish parent-child relationships. */

apps/sim/stores/workflows/utils.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -511,14 +511,15 @@ export function regenerateBlockIds(
511511
parentId: newParentId,
512512
extent: 'parent',
513513
}
514-
} else if (existingBlockNames[oldParentId]) {
515-
// Parent exists in existing workflow - keep original parentId (block stays in same subflow)
514+
} else if (existingBlockNames[oldParentId] && !existingBlockNames[oldParentId].locked) {
515+
// Parent exists in existing workflow and is not locked - keep original parentId
516516
block.data = {
517517
...block.data,
518518
parentId: oldParentId,
519519
extent: 'parent',
520520
}
521521
} else {
522+
// Parent doesn't exist anywhere OR parent is locked - clear the relationship
522523
// Parent doesn't exist anywhere - clear the relationship
523524
block.data = { ...block.data, parentId: undefined, extent: undefined }
524525
}

0 commit comments

Comments
 (0)