@@ -378,15 +378,18 @@ export async function importWorkflowFromYaml(
378378
379379 // Get the existing workflow state (to preserve starter blocks if they exist)
380380 let existingBlocks : Record < string , any > = { }
381-
381+
382382 if ( targetWorkflowId ) {
383383 // For target workflow, fetch from API
384384 try {
385385 const response = await fetch ( `/api/workflows/${ targetWorkflowId } ` )
386386 if ( response . ok ) {
387387 const workflowData = await response . json ( )
388388 existingBlocks = workflowData . data ?. state ?. blocks || { }
389- logger . debug ( `Fetched existing blocks for target workflow ${ targetWorkflowId } :` , Object . keys ( existingBlocks ) )
389+ logger . debug (
390+ `Fetched existing blocks for target workflow ${ targetWorkflowId } :` ,
391+ Object . keys ( existingBlocks )
392+ )
390393 }
391394 } catch ( error ) {
392395 logger . warn ( `Failed to fetch existing blocks for workflow ${ targetWorkflowId } :` , error )
@@ -395,7 +398,7 @@ export async function importWorkflowFromYaml(
395398 // For active workflow, use from store
396399 existingBlocks = workflowActions . getExistingBlocks ( )
397400 }
398-
401+
399402 const existingStarterBlocks = Object . values ( existingBlocks ) . filter (
400403 ( block : any ) => block . type === 'starter'
401404 )
@@ -413,8 +416,10 @@ export async function importWorkflowFromYaml(
413416 if ( ! activeWorkflowId ) {
414417 return { success : false , errors : [ 'No active workflow' ] , warnings : [ ] }
415418 }
416-
417- logger . info ( `Importing YAML into workflow: ${ activeWorkflowId } ${ targetWorkflowId ? '(specified target)' : '(active workflow)' } ` )
419+
420+ logger . info (
421+ `Importing YAML into workflow: ${ activeWorkflowId } ${ targetWorkflowId ? '(specified target)' : '(active workflow)' } `
422+ )
418423
419424 // Build complete blocks object
420425 const completeBlocks : Record < string , any > = { }
@@ -615,11 +620,11 @@ export async function importWorkflowFromYaml(
615620 // Save directly to database via API
616621 logger . info ( 'Saving complete workflow state directly to database...' )
617622 logger . debug ( 'Sample block being saved:' , {
618- firstBlockId : Object . keys ( completeBlocks ) [ 0 ] ,
623+ firstBlockId : Object . keys ( completeBlocks ) [ 0 ] ,
619624 firstBlock : Object . values ( completeBlocks ) [ 0 ] ,
620- firstBlockSubBlocks : Object . values ( completeBlocks ) [ 0 ] ?. subBlocks
625+ firstBlockSubBlocks : Object . values ( completeBlocks ) [ 0 ] ?. subBlocks ,
621626 } )
622-
627+
623628 const response = await fetch ( `/api/workflows/${ activeWorkflowId } /state` , {
624629 method : 'PUT' ,
625630 headers : {
@@ -654,7 +659,7 @@ export async function importWorkflowFromYaml(
654659 [ activeWorkflowId ] : completeSubBlockValues ,
655660 } ,
656661 } ) )
657-
662+
658663 // Verify SubBlockStore was updated
659664 const subBlockStoreValues = useSubBlockStore . getState ( ) . workflowValues [ activeWorkflowId ]
660665 logger . debug ( 'SubBlockStore after update:' , subBlockStoreValues )
0 commit comments