Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions apps/desktop/e2e/local-files.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,55 @@ createRoot(document.getElementById('settings')).render(
await expect(prompt.getByRole('button', { name: "Don't allow", exact: true })).toBeVisible()
return { prompt, result }
}
await test.step('File → Folder Access opens over a focused utility window', async () => {
if (!app) throw new Error('Desktop app is not running')
const serverShown = app.waitForEvent('window', { timeout: 10_000 })
await app.evaluate(({ Menu }) => {
const item = Menu.getApplicationMenu()
?.items.flatMap((entry) => entry.submenu?.items ?? [])
.find((entry) => entry.label === 'Server…')
if (!item) throw new Error('Server menu item missing')
item.click()
})
await expect(await serverShown).toHaveTitle('Sim - Server')
await expect
.poll(() =>
app?.evaluate(({ BrowserWindow }) =>
BrowserWindow.getAllWindows().some(
(win) => win.webContents.getURL().endsWith('server.html') && win.isVisible()
)
)
)
.toBe(true)
const accessMenu = await app.evaluate(({ BrowserWindow, Menu }) => {
const utility = BrowserWindow.getAllWindows().find((win) =>
win.webContents.getURL().endsWith('server.html')
)
if (!utility) throw new Error('Server window missing')
const item = Menu.getApplicationMenu()
?.items.flatMap((entry) => entry.submenu?.items ?? [])
.find((entry) => entry.label === 'Folder Access…')
if (!item) throw new Error('Folder Access menu item missing')
const popup = Menu.prototype.popup
let shown: { anchoredToUtility: boolean; items: string[] } | undefined
Menu.prototype.popup = function (this: Electron.Menu, options) {
shown = {
anchoredToUtility: options?.window === utility,
items: this.items.map((entry) => entry.label),
}
}
try {
item.click(undefined, utility)
} finally {
Menu.prototype.popup = popup
}
utility.close()
return shown
})
expect(accessMenu?.anchoredToUtility).toBe(true)
expect(accessMenu?.items).toContain('Add Folder…')
})

await test.step('Stop cancels only its own request while chats share a folder prompt', async () => {
const sharedFolder = join(root, 'Shared')
mkdirSync(sharedFolder)
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src/main/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ export function buildMenuTemplate(deps: MenuDeps): MenuItemConstructorOptions[]
{
label: 'Folder Access…',
click: (_item, focusedWindow) => {
const win = focusedMainOrFallback(focusedWindow)
const win = focusedWindowOrMain(focusedWindow)
if (win) deps.openFolderAccess(win)
},
},
Expand Down
Loading