Skip to content

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

Open

Description

@trueocean

Description

In the OpenCode desktop app on Windows, the "Close tab" hotkey is displayed as Ctrl+W, but pressing Ctrl+W closes the entire application window instead of the current session tab. Reproduces consistently.

Likely cause: Ctrl+W is a window/webview-level shortcut (Chromium/Electron "close window/tab") that is handled before the app's own tab-close handler, so the displayed binding never takes effect. Workaround: rebinding "Close tab" to another combination (e.g. Ctrl+Alt+W) avoids the problem.

For comparison:

  • Desktop app: shown binding Ctrl+W → closes the whole window.
  • TUI: close-tab is Ctrl+X then W (session.tab.close); Ctrl+W deletes a word in the prompt.
  • Web UI: Ctrl+W closes the browser tab.

Plugins

None.

OpenCode version

2.0.21 (desktop app / service). Note: a separate opencode binary on PATH reports 1.18.32 (different install).

Steps to reproduce

  1. Open the OpenCode desktop app on Windows.
  2. Go to Settings → Hotkeys and confirm "Close tab" is bound to Ctrl+W (shown as the default).
  3. Open two or more session tabs.
  4. Press Ctrl+W.

Expected: the current session tab closes and the window (with the other tabs) stays open.
Actual: the entire application window closes; no individual tab is closed.

Screenshot and/or share link

Settings → Hotkeys shows "Close tab" = Ctrl+W. (Screenshot available; not attached here.)

Operating System

Windows 10.0.28000 (win32 x64)

Terminal

Desktop app (not a terminal client; no terminal env applies).

Activity

  1. github-actions commented on Oct 2, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    For keybind-related issues, please also check our pinned keybinds documentation: #4997

  2. limexp commented on Oct 6, 2026

    @limexp

    This issue might be a duplicate of existing issues. Please check:

    * [[Desktop] macOS Cmd+W intermittently closes the window instead of the active tab (menu role:"close" races with tab.close) #37610](https://github.com/anomalyco/opencode/issues/37610): macOS Cmd+W intermittently closes the whole window instead of the active tab due to Electron’s native close role conflicting with the tab-close keybind.
    
    * [[FEATURE]:add config option to disable Electron native menu accelerators (Ctrl+M/Ctrl+W) #34937](https://github.com/anomalyco/opencode/issues/34937): Windows Electron native menu accelerators (including Ctrl+W) conflict with app keybinds.
    

    #37610 doesn't cover this. That one is macOS, where the app installs its own native menu, so it's the app's role: "close" racing the renderer's tab.close (fixed renderer-side in #39044).

    On Windows/Linux createMenu() (packages/desktop/src/main/menu.ts) returns early, so no app menu is ever set and Electron's default application menu keeps its close role = CommandOrControl+W. Different menu, different code path — the #39044 fix can't affect it.

    #34937 is the closer match.

  3. opencodejr commented on Oct 28, 2026

    @opencodejr
    Contributor

    Thanks for the detailed report. I couldn't reproduce this here because it needs the desktop app running on Windows, which this environment can't provide, so a maintainer with Windows will need to confirm it.

    The code matches what you describe. In both 2.0.21 and the current dev branch, the desktop app only builds its own application menu on macOS. On Windows and Linux, Electron's default menu stays in place, and its Close item is bound to Ctrl+W, so it closes the whole window before the app's "Close tab" shortcut can run. PR #54557 proposes a fix but hasn't been merged yet.

    Until then, rebinding "Close tab" to another shortcut (as you did with Ctrl+Alt+W) should keep working.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions