Skip to content

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

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

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

Conversation

@limexp

@limexp limexp commented Oct 11, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #52683

Type of change

  • Bug fix

What does this PR do?

On Windows and Linux the desktop app never installs its own menu (createMenu returns early unless the platform is darwin), so Electron keeps its default application menu. That default menu binds Close to Ctrl+W, which closes the whole window before the app's tab.close shortcut (mod+w) can run, so Ctrl+W quit the app instead of closing the tab.

I install an equivalent menu on non-macOS that leaves out the close accelerator (file/edit/view plus a Window menu with only minimize). The menu bar is hidden there anyway, so it only exists for the other shortcuts, which keep working. macOS is unchanged, and this is the V2 port of #53600 (closed because dev had moved to V2).

How did you verify your code works?

Ran bun run --cwd packages/desktop typecheck and oxlint on the changed file. Both pass; oxlint reports 0 errors (2 warnings also present on dev before this change). Also ran the dev build on Linux with a couple of tabs open: Ctrl+W closes the active tab and the window stays, and Ctrl+R, 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

Added by the opencode bot (AI-generated).

Related: #34937, #37610

@github-actions

Copy link
Copy Markdown
Contributor

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

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change looks correct and I have no blocking concerns. I couldn't run the Electron app here (no display), so I checked by reading the code and type-checking packages/desktop, which passes.

On Windows/Linux, Electron's fileMenu role holds only Quit, and editMenu/viewMenu match the default menu's groups. The only shortcut this drops is the Window menu's Close (Ctrl+W), so no new shortcuts appear. Rebuilds from refreshMenu go through the same branch, so the menu stays installed.

Public API: unchanged.

Two small points, neither blocking:

  • Until createMenu first runs (when windows are restored or translations arrive), Electron's default menu, still with Ctrl+W, is briefly active.
  • Keeping minimize keeps Ctrl+M as a minimize shortcut, which #34937 also complained about. That's fine to leave for this fix.

Related: #34937, #37610

@github-actions

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

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

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

1 participant