Repository navigation
fix(browser): stop Ctrl+W in the browser panel from quitting wmux - #431
Merged
amirlehmam merged 2 commits intoNov 4, 2026
Merged
Conversation
wmux never sets an application menu, so Electron's default one is live behind the hidden menu bar. A key the browser panel's page leaves unhandled is passed to the embedder and on to that menu, so Ctrl+W ran Window > Close on the whole window and the app quit. Ctrl+R reloaded the entire wmux UI and Ctrl+M minimized it the same way. Ignore menu shortcuts on every <webview> guest. The page still receives every key, and the desktop renderer's menu behaviour is unchanged.
Slice the 'webview' blocks of hardenWebContents out of src/main/index.ts by brace counting (comments blanked, strings skipped) and assert one of them calls ignoreMenuShortcutsInGuest(contents), so the Ctrl+W guard cannot be dropped or moved out of the guest branch without a failing test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
amirlehmam
force-pushed
the
fix/browser-ctrl-w-quits
branch
from
November 4, 2026 10:56
375bb12 to
dc90256
Compare
Owner
|
Thank you, this is a real data-loss fix and the analysis is right: wmux never sets an application menu, so a key a page leaves unhandled reached Electron's default Window → Close. I rebased it onto 2.55.2 and added one test on top. The existing test covered |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With the browser panel focused,
Ctrl+Wcloses the entire wmux window instead of a tab. With one window open, that quits the app and every terminal in it.Cause
wmux never calls
Menu.setApplicationMenu, so Electron installs its default menu. The menu bar is hidden (titleBarStyle: 'hidden'), but its accelerators are still active:Ctrl+WCtrl+R/Ctrl+Shift+RCtrl+Shift+ICtrl+MCtrl+0/Ctrl+Plus/Ctrl+-In the desktop renderer these never fire for a wmux binding, because
useKeyboardShortcutscallspreventDefaulton every key it claims, and a prevented key never reaches the menu. A<webview>guest has no such handler. A key its page leaves unhandled goes to the embedder and from there to the window's menu. SoCtrl+Win a page runs Window → Close. For the same reason,Ctrl+Rin a page reloads the whole wmux UI, not the page, andCtrl+Mminimizes wmux.Fix
ignoreMenuShortcutsInGuest(src/main/webview-menu-shortcuts.ts) callscontents.setIgnoreMenuShortcuts(true)on everywebviewguest, from the existingweb-contents-createdhardening hook. It only affects keys pressed while a page has focus:setMenu(null)Verification
I ran a dev build side by side with the installed wmux under
WMUX_INSTANCE, opened a browser tab on example.com, focused the guest, and sent real input events from the main process (webContents.sendInputEvent):Ctrl+Win the pageCtrl+Rin the pageCtrl+Min the pagekeydownlistenerCtrl+w,Ctrl+r,Ctrl+mCtrl+Wwith the desktop renderer focused (control)Menu.getApplicationMenu()from main to confirm the default menu, and that Close is bound toCommandOrControl+W.tests/unit/webview-menu-shortcuts.test.ts.tsc -p tsconfig.node.jsonpasses.Not in scope
wmux's own shortcuts still don't fire while a page has focus:
Ctrl+Wthere now does nothing, where a user might expect it to close the browser tab. Fixing that means forwarding guest keys to the desktop's shortcut dispatcher, which deserves its own PR. This one stops the data loss.