@@ -267,6 +267,55 @@ createRoot(document.getElementById('settings')).render(
267267 await expect ( prompt . getByRole ( 'button' , { name : "Don't allow" , exact : true } ) ) . toBeVisible ( )
268268 return { prompt, result }
269269 }
270+ await test . step ( 'File → Folder Access opens over a focused utility window' , async ( ) => {
271+ if ( ! app ) throw new Error ( 'Desktop app is not running' )
272+ const serverShown = app . waitForEvent ( 'window' , { timeout : 10_000 } )
273+ await app . evaluate ( ( { Menu } ) => {
274+ const item = Menu . getApplicationMenu ( )
275+ ?. items . flatMap ( ( entry ) => entry . submenu ?. items ?? [ ] )
276+ . find ( ( entry ) => entry . label === 'Server…' )
277+ if ( ! item ) throw new Error ( 'Server menu item missing' )
278+ item . click ( )
279+ } )
280+ await expect ( await serverShown ) . toHaveTitle ( 'Sim - Server' )
281+ await expect
282+ . poll ( ( ) =>
283+ app ?. evaluate ( ( { BrowserWindow } ) =>
284+ BrowserWindow . getAllWindows ( ) . some (
285+ ( win ) => win . webContents . getURL ( ) . endsWith ( 'server.html' ) && win . isVisible ( )
286+ )
287+ )
288+ )
289+ . toBe ( true )
290+ const accessMenu = await app . evaluate ( ( { BrowserWindow, Menu } ) => {
291+ const utility = BrowserWindow . getAllWindows ( ) . find ( ( win ) =>
292+ win . webContents . getURL ( ) . endsWith ( 'server.html' )
293+ )
294+ if ( ! utility ) throw new Error ( 'Server window missing' )
295+ const item = Menu . getApplicationMenu ( )
296+ ?. items . flatMap ( ( entry ) => entry . submenu ?. items ?? [ ] )
297+ . find ( ( entry ) => entry . label === 'Folder Access…' )
298+ if ( ! item ) throw new Error ( 'Folder Access menu item missing' )
299+ const popup = Menu . prototype . popup
300+ let shown : { anchoredToUtility : boolean ; items : string [ ] } | undefined
301+ Menu . prototype . popup = function ( this : Electron . Menu , options ) {
302+ shown = {
303+ anchoredToUtility : options ?. window === utility ,
304+ items : this . items . map ( ( entry ) => entry . label ) ,
305+ }
306+ }
307+ try {
308+ item . click ( undefined , utility )
309+ } finally {
310+ Menu . prototype . popup = popup
311+ }
312+ utility . close ( )
313+ return shown
314+ } )
315+ expect ( accessMenu ?. anchoredToUtility ) . toBe ( true )
316+ expect ( accessMenu ?. items ) . toContain ( 'Add Folder…' )
317+ } )
318+
270319 await test . step ( 'Stop cancels only its own request while chats share a folder prompt' , async ( ) => {
271320 const sharedFolder = join ( root , 'Shared' )
272321 mkdirSync ( sharedFolder )
0 commit comments