@@ -271,20 +271,26 @@ export const buildFLUXGraph = async (arg: GraphBuilderArg): Promise<GraphBuilder
271271 . filter ( ( entity ) => getGlobalReferenceImageWarnings ( entity , model ) . length === 0 ) ;
272272
273273 if ( validFlux2RefImageConfigs . length > 0 ) {
274- const flux2KontextCollect = g . addNode ( {
275- type : 'collect' ,
276- id : getPrefixedId ( 'flux2_kontext_collect' ) ,
277- } ) ;
274+ let prevCollect : Invocation < 'collect' > | null = null ;
278275 for ( const { config } of validFlux2RefImageConfigs ) {
279276 // FLUX.2 uses the same flux_kontext node - it just packages the image
280277 const kontextConditioning = g . addNode ( {
281278 type : 'flux_kontext' ,
282279 id : getPrefixedId ( 'flux_kontext' ) ,
283280 image : zImageField . parse ( config . image ?. crop ?. image ?? config . image ?. original . image ) ,
284281 } ) ;
285- g . addEdge ( kontextConditioning , 'kontext_cond' , flux2KontextCollect , 'item' ) ;
282+ const collectNode = g . addNode ( {
283+ type : 'collect' ,
284+ id : getPrefixedId ( 'flux2_kontext_collect' ) ,
285+ } ) ;
286+ g . addEdge ( kontextConditioning , 'kontext_cond' , collectNode , 'item' ) ;
287+ if ( prevCollect !== null ) {
288+ g . addEdge ( prevCollect , 'collection' , collectNode , 'collection' ) ;
289+ }
290+ prevCollect = collectNode ;
286291 }
287- g . addEdge ( flux2KontextCollect , 'collection' , flux2Denoise , 'kontext_conditioning' ) ;
292+ assert ( prevCollect !== null ) ;
293+ g . addEdge ( prevCollect , 'collection' , flux2Denoise , 'kontext_conditioning' ) ;
288294
289295 g . upsertMetadata ( { ref_images : validFlux2RefImageConfigs } , 'merge' ) ;
290296 }
0 commit comments