File tree Expand file tree Collapse file tree
app/workspace/[workspaceId]/w/[workflowId]/utils
lib/copilot/tools/server/workflow
stores/workflows/workflow Expand file tree Collapse file tree Original file line number Diff line number Diff 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.
Original file line number Diff line number Diff 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 ) ) {
Original file line number Diff line number Diff 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' ) {
You can’t perform that action at this time.
0 commit comments