Skip to content

Commit ef4acfd

Browse files
waleedlatif1claude
andcommitted
fix(copilot): check parent lock in edit and delete operations
Both edit and delete operations now check if the block's parent container is locked, not just if the block itself is locked. This ensures consistent behavior with the UI which uses isBlockProtected utility that checks both direct lock and parent lock. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 395e6ed commit ef4acfd

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

apps/sim/lib/copilot/tools/server/workflow/edit-workflow.ts

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,13 +1522,20 @@ function applyOperationsToWorkflowState(
15221522
break
15231523
}
15241524

1525-
// Check if block is locked
1526-
if (modifiedState.blocks[block_id].locked) {
1525+
// Check if block is locked or inside a locked container
1526+
const deleteBlock = modifiedState.blocks[block_id]
1527+
const deleteParentId = deleteBlock.data?.parentId as string | undefined
1528+
const deleteParentLocked = deleteParentId
1529+
? modifiedState.blocks[deleteParentId]?.locked
1530+
: false
1531+
if (deleteBlock.locked || deleteParentLocked) {
15271532
logSkippedItem(skippedItems, {
15281533
type: 'block_locked',
15291534
operationType: 'delete',
15301535
blockId: block_id,
1531-
reason: `Block "${block_id}" is locked and cannot be deleted`,
1536+
reason: deleteParentLocked
1537+
? `Block "${block_id}" is inside locked container "${deleteParentId}" and cannot be deleted`
1538+
: `Block "${block_id}" is locked and cannot be deleted`,
15321539
})
15331540
break
15341541
}
@@ -1568,13 +1575,17 @@ function applyOperationsToWorkflowState(
15681575

15691576
const block = modifiedState.blocks[block_id]
15701577

1571-
// Check if block is locked
1572-
if (block.locked) {
1578+
// Check if block is locked or inside a locked container
1579+
const editParentId = block.data?.parentId as string | undefined
1580+
const editParentLocked = editParentId ? modifiedState.blocks[editParentId]?.locked : false
1581+
if (block.locked || editParentLocked) {
15731582
logSkippedItem(skippedItems, {
15741583
type: 'block_locked',
15751584
operationType: 'edit',
15761585
blockId: block_id,
1577-
reason: `Block "${block_id}" is locked and cannot be edited`,
1586+
reason: editParentLocked
1587+
? `Block "${block_id}" is inside locked container "${editParentId}" and cannot be edited`
1588+
: `Block "${block_id}" is locked and cannot be edited`,
15781589
})
15791590
break
15801591
}

0 commit comments

Comments
 (0)