You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Desktop] macOS Cmd+W intermittently closes the window instead of the active tab (menu role:"close" races with tab.close) #37610
On OpenCode Desktop (macOS), Cmd+W is registered in two places at once:
Renderer commandtab.close is bound to mod+w (closes the active tab).
Native Electron application menu File → "Close Window" uses role: "close", which on macOS always owns Cmd+W and calls win.close().
When the renderer keybind handler receives the event (focus in the app UI with a current tab), the tab closes as expected. When focus is elsewhere, or tab.close is not registered (no current tab), or the native menu accelerator wins the race, the entire window/app closes.
This makes Cmd+W unreliable as "close tab" and can lose session context.
{id: "tab.close",keybind: "mod+w",onSelect: ()=>tabsStoreActions.closeTab(...)}// and also terminal.close on mod+w when focus is in the terminal panel
Related: #34937 (Windows native menu accelerators for Ctrl+W / Ctrl+M). Same class of bug — native menu roles/accelerators conflict with app keybinds — but this report is specifically about macOS Cmd+W = close tab vs close window.
Expected
Cmd+W always closes the active tab when one exists (browser / VS Code style).
Closing the window should use a different shortcut (e.g. Cmd+Shift+W) or only happen when there are no tabs left, after an explicit decision.
Suggested fix (any of)
Remove role: "close" from File → Close Window and set an explicit accelerator that does not steal Cmd+W (e.g. Cmd+Shift+W), keep action: "window.close".
Intercept before-input-event in the main process for Cmd+W and forward to tab.close / only call win.close() when no tabs remain.
When the last tab closes, optionally leave an empty window instead of quitting, matching multi-tab desktop apps.
Plugins cannot fix this: the official plugin API runs in the agent process and cannot rewrite Electron Menu.setApplicationMenu or role: "close".
Plugins
None related to keyboard/menu (local agent plugins only).
Activity
github-actions commentedon Jul 18, 2026
This issue might be a duplicate of existing issues. Please check:
role: "close"racing withtab.close, but the root cause and fix space overlap significantly.For keybind-related issues, please also check our pinned keybinds documentation: #4997
Brendonovich commentedon Jul 27, 2026
This should be fixed by #39044 which will be out in the next release. Will close in a few days if we don't experience it any more