Skip to content

fix(desktop): stop Ctrl+W from closing the window on Windows/Linux - #53600

Closed
limexp wants to merge 1 commit into
anomalyco:devfrom
limexp:fix-ctrl-w
Closed

limexp wants to merge 1 commit into
anomalyco:devfrom
limexp:fix-ctrl-w

Conversation

@limexp

@limexp limexp commented Oct 6, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #52683

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

On Windows and Linux the desktop app never installs its own application menu:
createMenu() returns immediately unless the platform is darwin. With no menu
set, Electron keeps its default application menu, whose window menu binds the
close role to CommandOrControl+W. That accelerator runs in the main process
and closes the whole window before the renderer's tab.close keybind
(mod+w, packages/app/src/pages/session/use-session-commands.tsx:529) can run,
so Ctrl+W closed the app instead of the active tab.

The window menu bar is hidden anyway (autoHideMenuBar: true in
packages/desktop/src/main/windows.ts), so on Windows/Linux this menu is only
used for its accelerators. This PR installs an equivalent menu on non-macOS
(fileMenu/editMenu/viewMenu plus a Window menu with only minimize),
omitting the window-close accelerator. Ctrl+W then reaches the renderer and
closes the tab/terminal as intended, while reload, zoom, fullscreen, minimize
and quit keep working.

macOS is unchanged — it already builds its own menu. Same class as #34937 and
#37610 (which was fixed on the renderer side for macOS), but this is the
Windows/Linux code path.

How did you verify your code works?

  • bun run --cwd packages/desktop typecheck
  • oxlint packages/desktop/src/main/menu.ts
  • Dev build on Linux/Fedora (bun run dev:desktop): with two or more session
    tabs, Ctrl+W closes the active tab and the window stays open; Ctrl+R,
    Ctrl+0/+/-, F11, Ctrl+M and Ctrl+Q still work.

Screenshots / recordings

N/A — no visual change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

@thdxr

thdxr commented Oct 10, 2026

Copy link
Copy Markdown
Member

This branch has been upgraded to V2. We're no longer taking PRs for V1. If you think this is still relevant, please port it over and open it for V2.

— from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

desktop: Ctrl+W closes the whole window instead of the current tab

2 participants