Skip to content

The agent that grows with you

fix(desktop): restore native macOS Window menu

victorjmilagres6ce0b7496c89
diff --git a/apps/desktop/electron/main.ts b/apps/desktop/electron/main.ts
index f4209999562..ec7d9f3859e 100644
--- a/apps/desktop/electron/main.ts
+++ b/apps/desktop/electron/main.ts
@@ -634,6 +634,7 @@ import {
import { registerWindowControlIpc, windowControlState } from './window-controls'
import { revealAction, shouldFocusToTakeKeyboard } from './window-focus-policy'
import { createWindowOpenHandler } from './window-open-policy'
+import { windowMenuTemplate } from './window-menu'
import { installWindowRendererLifecycle } from './window-renderer-lifecycle'
import { wireWindowReveal } from './window-reveal'
import {
@@ -6932,24 +6933,7 @@ function buildApplicationMenu() {
{ role: 'togglefullscreen' }
]
})
- template.push({
- label: 'Window',
- submenu: IS_MAC
- ? [{ role: 'minimize' }, { role: 'zoom' }, { role: 'front' }]
- : // 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
- }
- ]
- })
+ template.push(windowMenuTemplate(IS_MAC))
template.push({
label: 'Help',
role: 'help',
diff --git a/apps/desktop/electron/window-menu.test.ts b/apps/desktop/electron/window-menu.test.ts
new file mode 100644
index 00000000000..4b5494009ac
--- /dev/null
+++ b/apps/desktop/electron/window-menu.test.ts
@@ -0,0 +1,22 @@
+import assert from 'node:assert/strict'
+
+import { test } from 'vitest'
+
+import { windowMenuTemplate } from './window-menu'
+
+test('macOS registers the native Window menu so AppKit window commands remain available', () => {
+ const menu = windowMenuTemplate(true)
+
+ assert.equal(menu.role, 'windowMenu')
+ assert.deepEqual(
+ menu.submenu.map(item => item.role),
+ ['minimize', 'zoom', 'front']
+ )
+})
+
+test('non-macOS keeps the explicit cross-platform Window menu', () => {
+ assert.deepEqual(windowMenuTemplate(false), {
+ label: 'Window',
+ submenu: [{ role: 'minimize' }, { role: 'close' }]
+ })
+})
diff --git a/apps/desktop/electron/window-menu.ts b/apps/desktop/electron/window-menu.ts
new file mode 100644
index 00000000000..0d5c68ca08d
--- /dev/null
+++ b/apps/desktop/electron/window-menu.ts
@@ -0,0 +1,20 @@
+interface WindowMenuItem {
+ label?: string
+ role?: string
+ submenu: Array<{ role: string }>
+}
+
+function windowMenuTemplate(isMac: boolean): WindowMenuItem {
+ return {
+ label: 'Window',
+ // Mark the macOS menu as AppKit's standard Window menu. Without this role,
+ // macOS still exposes tiling from the green button but does not attach its
+ // Move & Resize commands (and their keyboard shortcuts) to the app menu.
+ ...(isMac ? { role: 'windowMenu' } : {}),
+ submenu: isMac
+ ? [{ role: 'minimize' }, { role: 'zoom' }, { role: 'front' }]
+ : [{ role: 'minimize' }, { role: 'close' }]
+ }
+}
+
+export { windowMenuTemplate }