Skip to content

The agent that grows with you

fix(desktop): type window-menu against Electron's MenuItemConstructorOptions

Brooklyn Nicholsonffc74885c5f6
diff --git a/apps/desktop/electron/window-menu.test.ts b/apps/desktop/electron/window-menu.test.ts
index 4b5494009ac..e060eaa0f62 100644
--- a/apps/desktop/electron/window-menu.test.ts
+++ b/apps/desktop/electron/window-menu.test.ts
@@ -15,8 +15,12 @@ test('macOS registers the native Window menu so AppKit window commands remain av
})
test('non-macOS keeps the explicit cross-platform Window menu', () => {
- assert.deepEqual(windowMenuTemplate(false), {
- label: 'Window',
- submenu: [{ role: 'minimize' }, { role: 'close' }]
- })
+ const menu = windowMenuTemplate(false)
+
+ assert.equal(menu.label, 'Window')
+ assert.deepEqual(
+ menu.submenu.map(item => item.role),
+ ['minimize', undefined]
+ )
+ assert.equal(menu.submenu[1].label, 'Close')
})
diff --git a/apps/desktop/electron/window-menu.ts b/apps/desktop/electron/window-menu.ts
index 0d5c68ca08d..a3981850c13 100644
--- a/apps/desktop/electron/window-menu.ts
+++ b/apps/desktop/electron/window-menu.ts
@@ -1,7 +1,7 @@
-interface WindowMenuItem {
- label?: string
- role?: string
- submenu: Array<{ role: string }>
+import type { MenuItemConstructorOptions } from 'electron'
+
+interface WindowMenuItem extends MenuItemConstructorOptions {
+ submenu: MenuItemConstructorOptions[]
}
function windowMenuTemplate(isMac: boolean): WindowMenuItem {
@@ -13,7 +13,19 @@ function windowMenuTemplate(isMac: boolean): WindowMenuItem {
...(isMac ? { role: 'windowMenu' } : {}),
submenu: isMac
? [{ role: 'minimize' }, { role: 'zoom' }, { role: 'front' }]
- : [{ role: 'minimize' }, { role: 'close' }]
+ : // Click-only Close: the `close` role would register its default
+ // CommandOrControl+W accelerator, claiming the chord before the
+ // before-input-event run that routes a terminal-focused Ctrl+W to the
+ // shell's word erase (#65457). The menu item still closes the focused
+ // window when clicked.
+ [
+ { role: 'minimize' },
+ {
+ click: (_menuItem, window) => window?.close(),
+ label: 'Close',
+ registerAccelerator: false
+ }
+ ]
}
}