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>
This commit is contained in:
waleed
2026-01-31 19:56:00 -08:00
parent 8dad4d43b2
commit 4c05ae1f34
3 changed files with 18 additions and 19 deletions

View File

@@ -71,20 +71,6 @@ export function filterProtectedBlocks(
}
}
/**
* Filters edges to only include those that are not protected.
*
* @param edges - Array of edges to filter
* @param blocks - Record of all blocks in the workflow
* @returns Array of edges that can be modified (not protected)
*/
export function filterUnprotectedEdges<T extends { source: string; target: string }>(
edges: T[],
blocks: Record<string, BlockState>
): T[] {
return edges.filter((edge) => !isEdgeProtected(edge, blocks))
}
/**
* Checks if any blocks in the selection are protected.
* Useful for determining if edit actions should be disabled.

View File

@@ -2146,6 +2146,19 @@ function applyOperationsToWorkflowState(
// Handle nested nodes (for loops/parallels created from scratch)
if (params.nestedNodes) {
// Defensive check: verify parent is not locked before adding children
// (Parent was just created with locked: false, but check for consistency)
const parentBlock = modifiedState.blocks[block_id]
if (parentBlock?.locked) {
logSkippedItem(skippedItems, {
type: 'block_locked',
operationType: 'add_nested_nodes',
blockId: block_id,
reason: `Container "${block_id}" is locked - cannot add nested nodes`,
})
break
}
Object.entries(params.nestedNodes).forEach(([childId, childBlock]: [string, any]) => {
// Validate childId is a valid string
if (!isValidKey(childId)) {

View File

@@ -373,16 +373,16 @@ export const useWorkflowStore = create<WorkflowStore>()(
const newBlocks = { ...currentBlocks }
const blocksToToggle = new Set<string>()
// For each ID, collect blocks to toggle (skip locked blocks)
// For each ID, collect blocks to toggle (skip locked blocks entirely)
// If it's a container, also include non-locked children
for (const id of ids) {
const block = currentBlocks[id]
if (!block) continue
// Skip locked blocks
if (!block.locked) {
blocksToToggle.add(id)
}
// Skip locked blocks entirely (including their children)
if (block.locked) continue
blocksToToggle.add(id)
// If it's a loop or parallel, also include non-locked children
if (block.type === 'loop' || block.type === 'parallel') {