Skip to content

Commit 4c05ae1

Browse files
waleedlatif1claude
andcommitted
fix(lock): address review comments for lock feature
1. Store batchToggleEnabled now uses continue to skip locked blocks entirely, matching database operation behavior 2. Copilot add operation now checks if parent container is locked before adding nested nodes (defensive check for consistency) 3. Remove unused filterUnprotectedEdges function Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 8dad4d4 commit 4c05ae1

3 files changed

Lines changed: 18 additions & 19 deletions

File tree

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/utils/block-protection-utils.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -71,20 +71,6 @@ export function filterProtectedBlocks(
7171
}
7272
}
7373

74-
/**
75-
* Filters edges to only include those that are not protected.
76-
*
77-
* @param edges - Array of edges to filter
78-
* @param blocks - Record of all blocks in the workflow
79-
* @returns Array of edges that can be modified (not protected)
80-
*/
81-
export function filterUnprotectedEdges<T extends { source: string; target: string }>(
82-
edges: T[],
83-
blocks: Record<string, BlockState>
84-
): T[] {
85-
return edges.filter((edge) => !isEdgeProtected(edge, blocks))
86-
}
87-
8874
/**
8975
* Checks if any blocks in the selection are protected.
9076
* Useful for determining if edit actions should be disabled.

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2146,6 +2146,19 @@ function applyOperationsToWorkflowState(
21462146

21472147
// Handle nested nodes (for loops/parallels created from scratch)
21482148
if (params.nestedNodes) {
2149+
// Defensive check: verify parent is not locked before adding children
2150+
// (Parent was just created with locked: false, but check for consistency)
2151+
const parentBlock = modifiedState.blocks[block_id]
2152+
if (parentBlock?.locked) {
2153+
logSkippedItem(skippedItems, {
2154+
type: 'block_locked',
2155+
operationType: 'add_nested_nodes',
2156+
blockId: block_id,
2157+
reason: `Container "${block_id}" is locked - cannot add nested nodes`,
2158+
})
2159+
break
2160+
}
2161+
21492162
Object.entries(params.nestedNodes).forEach(([childId, childBlock]: [string, any]) => {
21502163
// Validate childId is a valid string
21512164
if (!isValidKey(childId)) {

apps/sim/stores/workflows/workflow/store.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -373,16 +373,16 @@ export const useWorkflowStore = create<WorkflowStore>()(
373373
const newBlocks = { ...currentBlocks }
374374
const blocksToToggle = new Set<string>()
375375

376-
// For each ID, collect blocks to toggle (skip locked blocks)
376+
// For each ID, collect blocks to toggle (skip locked blocks entirely)
377377
// If it's a container, also include non-locked children
378378
for (const id of ids) {
379379
const block = currentBlocks[id]
380380
if (!block) continue
381381

382-
// Skip locked blocks
383-
if (!block.locked) {
384-
blocksToToggle.add(id)
385-
}
382+
// Skip locked blocks entirely (including their children)
383+
if (block.locked) continue
384+
385+
blocksToToggle.add(id)
386386

387387
// If it's a loop or parallel, also include non-locked children
388388
if (block.type === 'loop' || block.type === 'parallel') {

0 commit comments

Comments
 (0)