@@ -351,8 +351,6 @@ export async function importWorkflowFromYaml(
351351 } ,
352352 targetWorkflowId ?: string
353353) : Promise < { success : boolean ; errors : string [ ] ; warnings : string [ ] ; summary ?: string } > {
354-
355-
356354 try {
357355 // Parse YAML
358356 const { data : yamlWorkflow , errors : parseErrors } = parseWorkflowYaml ( yamlContent )
@@ -368,8 +366,6 @@ export async function importWorkflowFromYaml(
368366 return { success : false , errors, warnings }
369367 }
370368
371-
372-
373369 // Get the existing workflow state (to preserve starter blocks if they exist)
374370 let existingBlocks : Record < string , any > = { }
375371
@@ -380,19 +376,18 @@ export async function importWorkflowFromYaml(
380376 if ( response . ok ) {
381377 const workflowData = await response . json ( )
382378 existingBlocks = workflowData . data ?. state ?. blocks || { }
383-
384- }
385- } catch ( error ) {
386- logger . warn ( `Failed to fetch existing blocks for workflow ${ targetWorkflowId } :` , error )
387379 }
388- } else {
389- // For active workflow, use from store
390- existingBlocks = workflowActions . getExistingBlocks ( )
380+ } catch ( error ) {
381+ logger . warn ( `Failed to fetch existing blocks for workflow ${ targetWorkflowId } :` , error )
391382 }
392-
393- const existingStarterBlocks = Object . values ( existingBlocks ) . filter (
394- ( block : any ) => block . type === 'starter'
395- )
383+ } else {
384+ // For active workflow, use from store
385+ existingBlocks = workflowActions . getExistingBlocks ( )
386+ }
387+
388+ const existingStarterBlocks = Object . values ( existingBlocks ) . filter (
389+ ( block : any ) => block . type === 'starter'
390+ )
396391
397392 // Get stores and current workflow info
398393 const { useWorkflowStore } = require ( '@/stores/workflows/workflow/store' )
@@ -407,8 +402,6 @@ export async function importWorkflowFromYaml(
407402 return { success : false , errors : [ 'No active workflow' ] , warnings : [ ] }
408403 }
409404
410-
411-
412405 // Build complete blocks object
413406 const completeBlocks : Record < string , any > = { }
414407 const completeSubBlockValues : Record < string , Record < string , any > > = { }
@@ -443,8 +436,6 @@ export async function importWorkflowFromYaml(
443436 : { } ) ,
444437 ...starterBlock . inputs , // Override with YAML values
445438 }
446-
447-
448439 } else {
449440 // Create new starter block
450441 starterBlockId = crypto . randomUUID ( )
@@ -478,8 +469,6 @@ export async function importWorkflowFromYaml(
478469
479470 // Set starter block values
480471 completeSubBlockValues [ starterBlockId ] = { ...starterBlock . inputs }
481-
482-
483472 }
484473 }
485474 }
@@ -488,7 +477,6 @@ export async function importWorkflowFromYaml(
488477 let blocksProcessed = 0
489478 for ( const block of blocks ) {
490479 if ( block . type === 'starter' ) {
491-
492480 continue // Already handled above
493481 }
494482
@@ -549,8 +537,6 @@ export async function importWorkflowFromYaml(
549537 }
550538 }
551539
552-
553-
554540 // Create complete edges using the ID mapping
555541 const completeEdges : any [ ] = [ ]
556542 for ( const edge of edges ) {
@@ -563,7 +549,6 @@ export async function importWorkflowFromYaml(
563549 source : sourceId ,
564550 target : targetId ,
565551 } )
566-
567552 } else {
568553 logger . warn ( `Skipping edge - missing blocks: ${ edge . source } -> ${ edge . target } ` )
569554 }
@@ -597,7 +582,7 @@ export async function importWorkflowFromYaml(
597582 hasActiveWebhook : false ,
598583 }
599584
600- // Save directly to database via API
585+ // Save directly to database via API
601586 const response = await fetch ( `/api/workflows/${ activeWorkflowId } /state` , {
602587 method : 'PUT' ,
603588 headers : {
@@ -622,14 +607,14 @@ export async function importWorkflowFromYaml(
622607 if ( ! targetWorkflowId ) {
623608 useWorkflowStore . setState ( completeWorkflowState )
624609
625- // Set subblock values in local store
610+ // Set subblock values in local store
626611 useSubBlockStore . setState ( ( state : any ) => ( {
627612 workflowValues : {
628613 ...state . workflowValues ,
629614 [ activeWorkflowId ] : completeSubBlockValues ,
630615 } ,
631616 } ) )
632- }
617+ }
633618
634619 // Brief delay for UI to update
635620 await new Promise ( ( resolve ) => setTimeout ( resolve , 100 ) )
@@ -640,8 +625,6 @@ export async function importWorkflowFromYaml(
640625 const totalBlocksCreated =
641626 Object . keys ( completeBlocks ) . length - ( existingStarterBlocks . length > 0 ? 1 : 0 )
642627
643-
644-
645628 return {
646629 success : true ,
647630 errors : [ ] ,
0 commit comments