@@ -1178,13 +1178,21 @@ export class CodeWindow extends BaseWindow implements ICodeWindow {
11781178 // 2. Immediate check after loadURL - fallback if ready-to-show doesn't fire
11791179 // 3. Page load events - ensure visibility after content loads
11801180 // 4. Timeout fallback - last resort
1181+ // 5. Error handling - detect if workbench.html failed to load
11811182 if ( isMacintosh && this . _win ) {
1183+ // Track if window was successfully shown
1184+ let windowShown = false ;
1185+
11821186 // Immediate check: Show window if it's not visible (fallback if ready-to-show hasn't fired)
11831187 const ensureWindowVisible = ( ) => {
11841188 if ( this . _win && ! this . _win . isDestroyed ( ) ) {
1185- if ( ! this . _win . isVisible ( ) ) {
1189+ const wasVisible = this . _win . isVisible ( ) ;
1190+ if ( ! wasVisible ) {
11861191 this . logService . trace ( 'window#load: forcing window to show on macOS' ) ;
11871192 this . _win . showInactive ( ) ;
1193+ windowShown = true ;
1194+ } else {
1195+ windowShown = true ;
11881196 }
11891197 if ( this . _win . isMinimized ( ) ) {
11901198 this . _win . restore ( ) ;
@@ -1203,6 +1211,14 @@ export class CodeWindow extends BaseWindow implements ICodeWindow {
12031211 }
12041212 } ;
12051213
1214+ // Listen for load failures - this could indicate workbench.html is missing
1215+ this . _win . webContents . once ( 'did-fail-load' , ( event , errorCode , errorDescription , validatedURL ) => {
1216+ this . logService . error ( `window#load: Failed to load workbench on macOS - Code: ${ errorCode } , Description: ${ errorDescription } , URL: ${ validatedURL } ` ) ;
1217+ this . logService . error ( 'window#load: This may indicate workbench.html is missing or the file path is incorrect' ) ;
1218+ // Still try to show the window even if load failed
1219+ ensureWindowVisible ( ) ;
1220+ } ) ;
1221+
12061222 // Immediate check (in case ready-to-show already fired or won't fire)
12071223 ensureWindowVisible ( ) ;
12081224
@@ -1219,9 +1235,15 @@ export class CodeWindow extends BaseWindow implements ICodeWindow {
12191235
12201236 // Fallback: Ensure visibility after a delay (handles edge cases)
12211237 setTimeout ( ( ) => {
1222- if ( this . _win && ! this . _win . isDestroyed ( ) && ! this . _win . isVisible ( ) ) {
1223- this . logService . warn ( 'window#load: window still not visible after delay, forcing show' ) ;
1224- ensureWindowVisible ( ) ;
1238+ if ( this . _win && ! this . _win . isDestroyed ( ) ) {
1239+ if ( ! this . _win . isVisible ( ) ) {
1240+ this . logService . warn ( 'window#load: window still not visible after delay, forcing show' ) ;
1241+ ensureWindowVisible ( ) ;
1242+ }
1243+ // Final diagnostic check
1244+ if ( ! windowShown ) {
1245+ this . logService . error ( 'window#load: CRITICAL - Window was never shown on macOS. This indicates a serious issue.' ) ;
1246+ }
12251247 }
12261248 } , 500 ) ;
12271249 }
0 commit comments