The best way to control Claude Code, Codex and more from any computer or phone
fix(desktop): Cmd/Ctrl+W closes sidebar tabs, never the window (#25860)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Theo Browne committed
Oct 27, 2026 at 03:01 UTC
a86c05f977ef0e86b064c452d2c8b583a8ea73c1
4 files changed
+52
-4
apps/desktop/src/window/DesktopApplicationMenu.test.ts
+35
@@ -199,6 +199,41 @@ describe("DesktopApplicationMenu", () => {
199
}),
200
);
201
202
+ it.effect("never binds Cmd/Ctrl+W to closing the window", () =>
203
+ Effect.gen(function* () {
204
+ for (const platform of ["darwin", "linux", "win32"] as const) {
205
+ const applicationMenuTemplate =
206
+ yield* Deferred.make<readonly Electron.MenuItemConstructorOptions[]>();
207
+ yield* configureMenu(yield* Deferred.make<string>(), applicationMenuTemplate, {
208
+ platform,
209
+ });
210
+
211
+ const items: Electron.MenuItemConstructorOptions[] = [];
212
+ const collect = (template: readonly Electron.MenuItemConstructorOptions[]) => {
213
+ for (const item of template) {
214
+ items.push(item);
215
+ if (Array.isArray(item.submenu)) collect(item.submenu);
216
+ }
217
+ };
218
+ collect(yield* Deferred.await(applicationMenuTemplate));
219
+
220
+ assert.isUndefined(
221
+ items.find((item) => item.role === "close"),
222
+ platform,
223
+ );
224
+ // Electron's default windowMenu submenu includes a close role.
225
+ assert.isUndefined(
226
+ items.find((item) => item.role === "windowMenu" && item.submenu === undefined),
227
+ platform,
228
+ );
229
+ assert.isUndefined(
230
+ items.find((item) => item.accelerator?.toLowerCase().endsWith("+w")),
231
+ platform,
232
+ );
233
+ }
234
+ }),
235
+ );
236
+
237
it.effect("reloads the main window even while a browser page has focus", () =>
238
Effect.gen(function* () {
239
const selectedAction = yield* Deferred.make<string>();
apps/desktop/src/window/DesktopApplicationMenu.ts
+15
-2
@@ -200,7 +200,10 @@ export const make = Effect.gen(function* () {
200
},
201
{ type: "separator" as const },
202
]),
203
- { role: environment.platform === "darwin" ? "close" : "quit" },
203
+ // Cmd/Ctrl+W belongs to the renderer's tab close; it must never close the window.
204
+ environment.platform === "darwin"
205
+ ? { label: "Close Window", click: (_item, window) => window?.close() }
206
+ : { role: "quit" },
207
],
208
},
209
{
@@ -289,7 +292,17 @@ export const make = Effect.gen(function* () {
292
{ role: "togglefullscreen" },
293
],
294
},
292
- { role: "windowMenu" },
295
+ {
296
+ // Electron's default Window submenu adds a Ctrl+W close role off macOS.
297
+ role: "windowMenu",
298
+ submenu: [
299
+ { role: "minimize" },
300
+ { role: "zoom" },
301
+ ...(environment.platform === "darwin"
302
+ ? [{ type: "separator" as const }, { role: "front" as const }]
303
+ : []),
304
+ ],
305
+ },
306
{
307
role: "help",
308
submenu: [
apps/desktop/src/window/DesktopWindow.ts
+1
-1
@@ -619,7 +619,6 @@ export const make = Effect.gen(function* () {
619
}
620
});
621
622
- // Terminal-close repeats can outlive the terminal; reject them before the native close-window accelerator.
622
const quitShortcutHandler = makeQuitShortcutHandler({
623
platform: environment.platform,
624
getMode: () =>
@@ -645,6 +644,7 @@ export const make = Effect.gen(function* () {
644
});
645
window.webContents.on("before-input-event", (event, input) => {
646
quitShortcutHandler(event, input);
647
+ // A held Cmd/Ctrl+W closes one tab or terminal, not each one behind it.
648
if (input.type !== "keyDown" || !input.isAutoRepeat) return;
649
const modifier = environment.platform === "darwin" ? input.meta : input.control;
650
if (modifier && !input.alt && !input.shift && input.key.toLowerCase() === "w") {
docs/user/keybindings.md
+1
-1
@@ -165,7 +165,7 @@ through the pages you have visited, like a browser's back and forward buttons.
165
## Reserved shortcuts
166
167
In the desktop app, `mod+w` closes the focused terminal or the active right-panel
168
-tab. When nothing remains to close, it closes the window. In a browser, `mod+w`
168
+tab. When nothing remains to close, it does nothing; it never closes the window. In a browser, `mod+w`
169
closes the browser tab; rebind `rightPanel.close` and `terminal.close` to an available
170
shortcut such as `alt+w`.
171