@@ -55,16 +55,17 @@ export class LoopManager {
5555 const currentIteration = context . loopIterations . get ( loopId ) || 0
5656
5757 // Store the results from this iteration before potentially resetting blocks
58- const iterationResults : Record < string , any > = { }
58+ const iterationResults : any [ ] = [ ]
5959 for ( const nodeId of loop . nodes ) {
6060 const blockState = context . blockStates . get ( nodeId )
6161 if ( blockState ?. output ) {
62- iterationResults [ nodeId ] = blockState . output
62+ // Just push the output directly, not nested under block ID
63+ iterationResults . push ( blockState . output )
6364 }
6465 }
6566
6667 // Store the iteration results
67- if ( Object . keys ( iterationResults ) . length > 0 ) {
68+ if ( iterationResults . length > 0 ) {
6869 this . storeIterationResult (
6970 context ,
7071 loopId ,
@@ -117,8 +118,13 @@ export class LoopManager {
117118 if ( loopState ) {
118119 for ( let i = 0 ; i < maxIterations ; i ++ ) {
119120 const result = loopState . executionResults . get ( `iteration_${ i } ` )
120- if ( result ?. iteration ) {
121- results . push ( result . iteration )
121+ if ( result ) {
122+ // If result is an array (from multiple blocks in the loop), flatten it
123+ if ( Array . isArray ( result ) ) {
124+ results . push ( ...result )
125+ } else {
126+ results . push ( result )
127+ }
122128 }
123129 }
124130 }
@@ -240,7 +246,7 @@ export class LoopManager {
240246 context : ExecutionContext ,
241247 loopId : string ,
242248 iterationIndex : number ,
243- blockId : string ,
249+ _blockId : string , // Not used anymore since we're storing results directly
244250 output : any
245251 ) : void {
246252 if ( ! context . loopExecutions ) {
@@ -266,16 +272,9 @@ export class LoopManager {
266272 context . loopExecutions . set ( loopId , loopState )
267273 }
268274
269- // Get or create the iteration results object
275+ // Store the output directly for this iteration
270276 const iterationKey = `iteration_${ iterationIndex } `
271- let iterationResults = loopState . executionResults . get ( iterationKey )
272- if ( ! iterationResults ) {
273- iterationResults = { }
274- loopState . executionResults . set ( iterationKey , iterationResults )
275- }
276-
277- // Store the block's output for this iteration
278- iterationResults [ blockId ] = output
277+ loopState . executionResults . set ( iterationKey , output )
279278 }
280279
281280 /**
0 commit comments