@@ -726,21 +726,33 @@ async function deleteAllModels(): Promise<void> {
726726
727727async function restartApp ( appName : string ) : Promise < void > {
728728 const aiRunningAppsPage = await aiLabPage . navigationBar . openRunningApps ( ) ;
729- const aiApp = await aiRunningAppsPage . getRowForApp ( appName ) ;
730729 await aiRunningAppsPage . waitForLoad ( ) ;
731730 await playExpect . poll ( async ( ) => await aiRunningAppsPage . appExists ( appName ) , { timeout : 10_000 } ) . toBeTruthy ( ) ;
732731 await playExpect
733732 . poll ( async ( ) => await aiRunningAppsPage . getCurrentStatusForApp ( appName ) , { timeout : 60_000 } )
734733 . toBe ( 'RUNNING' ) ;
735- await aiRunningAppsPage . restartApp ( appName ) ;
736- // handle possible reset project confirmation dialog https://github.com/containers/podman-desktop-extension-ai-lab/issues/3663
737- try {
738- await handleConfirmationDialog ( aiLabPage . page , podmanAILabExtension . extensionName , true , 'Reset' , 'Cancel' , 25_000 ) ;
739- } catch ( error ) {
740- console . warn ( `Warning: Could not reset the app, repository probably clean.\n\t${ error } ` ) ;
741- }
734+ const aiApp = await aiRunningAppsPage . getRowForApp ( appName ) ;
742735 const appProgressBar = aiApp . getByRole ( 'progressbar' , { name : 'Loading' } ) ;
743- await playExpect ( appProgressBar ) . toBeVisible ( { timeout : 60_000 } ) ;
736+ // Trigger restart and watch for dialog/progress bar in parallel to avoid race condition
737+ // See: https://github.com/containers/podman-desktop-extension-ai-lab/issues/3663
738+ const restartPromise = aiRunningAppsPage . restartApp ( appName ) ;
739+ const dialogPromise = handleConfirmationDialog (
740+ aiLabPage . page ,
741+ podmanAILabExtension . extensionName ,
742+ true ,
743+ 'Reset' ,
744+ 'Cancel' ,
745+ 25_000 ,
746+ ) . catch ( ( ) => {
747+ // Dialog didn't appear - this is expected when repo is clean
748+ } ) ;
749+ const progressBarPromise = playExpect ( appProgressBar )
750+ . toBeVisible ( { timeout : 60_000 } )
751+ . catch ( ( ) => {
752+ console . log ( `Warning: Progress bar did not appear for app "${ appName } " during restart` ) ;
753+ } ) ;
754+
755+ await Promise . all ( [ restartPromise , dialogPromise , progressBarPromise ] ) ;
744756 await playExpect
745757 . poll ( async ( ) => await aiRunningAppsPage . getCurrentStatusForApp ( appName ) , { timeout : 60_000 } )
746758 . toBe ( 'RUNNING' ) ;
0 commit comments