@@ -3,6 +3,7 @@ import { getCurrentWindow } from '@tauri-apps/api/window';
33import { useWorkspaceContext } from '../../infrastructure/contexts/WorkspaceContext' ;
44import { notificationService } from '@/shared/notification-system' ;
55import { createLogger } from '@/shared/utils/logger' ;
6+ import { sendDebugProbe } from '@/shared/utils/debugProbe' ;
67import { useI18n } from '@/infrastructure/i18n' ;
78
89const log = createLogger ( 'useWindowControls' ) ;
@@ -90,15 +91,54 @@ export const useWindowControls = (options?: { isToolbarMode?: boolean }) => {
9091 }
9192
9293 if ( document . visibilityState === 'visible' ) {
94+ sendDebugProbe (
95+ 'useWindowControls.ts:handleVisibilityChange' ,
96+ 'Window became visible' ,
97+ {
98+ isToolbarMode,
99+ }
100+ ) ;
93101 try {
94102 const appWindow = getCurrentWindow ( ) ;
95103 // Delay update until window fully restores
96104 setTimeout ( async ( ) => {
97- await updateWindowState ( appWindow ) ;
98- await restoreMacOSOverlayTitlebar ( appWindow ) ;
105+ const startedAt = typeof performance !== 'undefined' ? performance . now ( ) : Date . now ( ) ;
106+ try {
107+ await updateWindowState ( appWindow ) ;
108+ await restoreMacOSOverlayTitlebar ( appWindow ) ;
109+ sendDebugProbe (
110+ 'useWindowControls.ts:handleVisibilityChange' ,
111+ 'Window restore sync completed' ,
112+ {
113+ durationMs :
114+ Math . round (
115+ ( ( typeof performance !== 'undefined' ? performance . now ( ) : Date . now ( ) ) -
116+ startedAt ) *
117+ 10
118+ ) / 10 ,
119+ isToolbarMode,
120+ }
121+ ) ;
122+ } catch ( error ) {
123+ sendDebugProbe (
124+ 'useWindowControls.ts:handleVisibilityChange' ,
125+ 'Window restore sync failed' ,
126+ {
127+ error : formatErrorMessage ( error ) ,
128+ isToolbarMode,
129+ }
130+ ) ;
131+ }
99132 } , 300 ) ;
100133 } catch ( error ) {
101- // Ignore errors
134+ sendDebugProbe (
135+ 'useWindowControls.ts:handleVisibilityChange' ,
136+ 'Window restore setup failed' ,
137+ {
138+ error : formatErrorMessage ( error ) ,
139+ isToolbarMode,
140+ }
141+ ) ;
102142 }
103143 }
104144 } ;
0 commit comments