From ef4acfdf3964cbf08331bb3a74b7fa4f1ed20eba Mon Sep 17 00:00:00 2001 From: waleed Date: Sat, 31 Jan 2026 20:34:00 -0800 Subject: [PATCH] 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 --- .../tools/server/workflow/edit-workflow.ts | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/apps/sim/lib/copilot/tools/server/workflow/edit-workflow.ts b/apps/sim/lib/copilot/tools/server/workflow/edit-workflow.ts index cfc231bbc..51c2669c2 100644 --- a/apps/sim/lib/copilot/tools/server/workflow/edit-workflow.ts +++ b/apps/sim/lib/copilot/tools/server/workflow/edit-workflow.ts @@ -1522,13 +1522,20 @@ function applyOperationsToWorkflowState( break } - // Check if block is locked - if (modifiedState.blocks[block_id].locked) { + // Check if block is locked or inside a locked container + const deleteBlock = modifiedState.blocks[block_id] + const deleteParentId = deleteBlock.data?.parentId as string | undefined + const deleteParentLocked = deleteParentId + ? modifiedState.blocks[deleteParentId]?.locked + : false + if (deleteBlock.locked || deleteParentLocked) { logSkippedItem(skippedItems, { type: 'block_locked', operationType: 'delete', blockId: block_id, - reason: `Block "${block_id}" is locked and cannot be deleted`, + reason: deleteParentLocked + ? `Block "${block_id}" is inside locked container "${deleteParentId}" and cannot be deleted` + : `Block "${block_id}" is locked and cannot be deleted`, }) break } @@ -1568,13 +1575,17 @@ function applyOperationsToWorkflowState( const block = modifiedState.blocks[block_id] - // Check if block is locked - if (block.locked) { + // Check if block is locked or inside a locked container + const editParentId = block.data?.parentId as string | undefined + const editParentLocked = editParentId ? modifiedState.blocks[editParentId]?.locked : false + if (block.locked || editParentLocked) { logSkippedItem(skippedItems, { type: 'block_locked', operationType: 'edit', blockId: block_id, - reason: `Block "${block_id}" is locked and cannot be edited`, + reason: editParentLocked + ? `Block "${block_id}" is inside locked container "${editParentId}" and cannot be edited` + : `Block "${block_id}" is locked and cannot be edited`, }) break }