@@ -5,6 +5,7 @@ let workflowEditorInitialized = false;
55let i2iUploadedFileNames = [ ] ;
66let i2iloopUploadedFileNames = [ ] ;
77let i2iangleUploadedFileNames = [ ] ;
8+ let upscaleloopUploadedFileNames = [ ] ;
89function showCancelButton ( mode ) {
910const btnId = 'btnCancel' + mode . charAt ( 0 ) . toUpperCase ( ) + mode . slice ( 1 ) ;
1011const btn = $ ( btnId ) ;
@@ -591,3 +592,49 @@ $('generationStatus').textContent = I18nManager.t('status.error');
591592$ ( 'generationStatus' ) . style . color = '#f44336' ;
592593} finally { isGenerating = false ; isCancelled = false ; hideCancelButton ( 'i2IAngle' ) ; setGenerateButtonGenerating ( 'i2IAngle' , false ) ; }
593594}
595+ function generateImageUpscaleLoop ( ) {
596+ if ( upscaleloopUploadedFileNames . length === 0 ) { createToastError ( I18nManager . t ( 'toast.inputError' ) , I18nManager . t ( 'toast.uploadImage' ) ) ; return ; }
597+ generateImageUpscaleLoopExec ( ) ;
598+ }
599+ async function generateImageUpscaleLoopExec ( ) {
600+ if ( isGenerating ) return ;
601+ if ( upscaleloopUploadedFileNames . length === 0 ) { createToastError ( I18nManager . t ( 'toast.inputError' ) , I18nManager . t ( 'toast.uploadImage' ) ) ; return ; }
602+ isGenerating = true ;
603+ isCancelled = false ;
604+ showCancelButton ( 'upscaleLoop' ) ;
605+ setGenerateButtonGenerating ( 'upscaleLoop' , true ) ;
606+ try {
607+ const baseWorkflow = await comfyUIWorkflowRepository . getEnabledWorkflowByType ( "Upscaler" ) ;
608+ if ( ! baseWorkflow ) {
609+ ErrorGuideDialog . show ( ErrorGuideDialog . ERROR_TYPES . WORKFLOW_NOT_FOUND , { workflowType : 'Upscaler' } ) ;
610+ $ ( 'generationStatus' ) . textContent = I18nManager . t ( 'status.workflowNotSet' ) ;
611+ $ ( 'generationStatus' ) . style . color = '#f44336' ;
612+ return ;
613+ }
614+ const imageCount = upscaleloopUploadedFileNames . length ;
615+ $ ( 'generationStatus' ) . textContent = I18nManager . t ( 'status.generatingProgress' ) . replace ( '{current}' , 0 ) . replace ( '{total}' , imageCount ) ;
616+ $ ( 'generationStatus' ) . style . color = '#ff9800' ;
617+ resetGenerationTimeStats ( ) ;
618+ for ( let imgIdx = 0 ; imgIdx < imageCount ; imgIdx ++ ) {
619+ if ( isCancelled ) { $ ( 'generationStatus' ) . textContent = I18nManager . t ( 'status.cancelled' ) ; $ ( 'generationStatus' ) . style . color = '#ff9800' ; break ; }
620+ const uploadFileName = upscaleloopUploadedFileNames [ imgIdx ] ;
621+ $ ( 'generationStatus' ) . textContent = I18nManager . t ( 'status.generatingProgress' ) . replace ( '{current}' , imgIdx + 1 ) . replace ( '{total}' , imageCount ) ;
622+ const requestData = { uploadFileName : uploadFileName } ;
623+ const workflow = comfyuiReplacePlaceholders ( baseWorkflow , requestData , 'Upscaler' ) ;
624+ console . log ( 'Generated Upscale Loop Workflow JSON:' , JSON . stringify ( workflow , null , 2 ) ) ;
625+ const startTime = performance . now ( ) ;
626+ const result = await executeWorkflow ( workflow ) ;
627+ const endTime = performance . now ( ) ;
628+ updateGenerationTimeStats ( Math . round ( endTime - startTime ) ) ;
629+ if ( result && result . image ) {
630+ const historyConfig = [ ] ;
631+ displayGeneratedImage ( result . image , imgIdx + 1 , 'Upscale: ' + uploadFileName , historyConfig ) ;
632+ }
633+ }
634+ if ( ! isCancelled ) { $ ( 'generationStatus' ) . textContent = I18nManager . t ( 'status.completed' ) ; $ ( 'generationStatus' ) . style . color = '#4caf50' ; }
635+ } catch ( error ) {
636+ ErrorGuideDialog . showForError ( error , { errorDetail : error . message } ) ;
637+ $ ( 'generationStatus' ) . textContent = I18nManager . t ( 'status.error' ) ;
638+ $ ( 'generationStatus' ) . style . color = '#f44336' ;
639+ } finally { isGenerating = false ; isCancelled = false ; hideCancelButton ( 'upscaleLoop' ) ; setGenerateButtonGenerating ( 'upscaleLoop' , false ) ; }
640+ }
0 commit comments