mirror of
https://github.com/simstudioai/sim.git
synced 2026-02-01 02:05:18 -05:00
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:
@@ -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.
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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') {
|
||||
|
||||
Reference in New Issue
Block a user