Repository navigation
fix(browser): let Ctrl+W close the browser tab from inside a page - #432
Merged
amirlehmam merged 2 commits intoNov 4, 2026
Merged
amirlehmam merged 2 commits into
amirlehmam merged 2 commits into
Conversation
A focused <webview> guest gets its keys before the desktop renderer, so none of wmux's shortcuts fired while a page had focus. Ctrl+W did nothing (or, before the previous commit, quit wmux). Main now forwards a guest's shortcut-shaped key-downs (Ctrl/Alt/Meta chords and function keys) to its host window without preventing them. The page keeps every key, so the desktop only answers with the tab-level actions a browser reserves from pages (GLOBAL_IN_PAGE): close, open, reopen and cycle tabs, workspaces and windows. A web app's Ctrl+B or Ctrl+F stays the page's. The key is resolved to the pane hosting that guest. If focus reached the page without moving wmux's pane focus there, the pane is focused first and the key replayed, so Ctrl+W never closes a tab in another pane.
The renderer half of the guest key forwarding (drop auto-repeats, match the user's bindings, answer only GLOBAL_IN_PAGE actions) lived inline in the useKeyboardShortcuts effect, so removing the repeat guard or the GLOBAL_IN_PAGE filter left every test green. Move the decision into an exported pure guestShortcutAction(key, shortcuts) and have the hook call it. Behaviour is unchanged: the hook still drops repeats before focusing the guest's pane, and still focuses before matching and replaying. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
amirlehmam
force-pushed
the
fix/browser-page-tab-shortcuts
branch
from
November 4, 2026 10:57
9303933 to
eff3e5e
Compare
Owner
|
Thanks, this fills the gap #431 left. The approach holds up under review:
#431 is merged, so I rebased this onto master with only your commit. I added one commit on top: the renderer half (drop repeats, match the user's bindings, keep only |
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.
Follow-up to #431. With a browser pane's page focused, none of wmux's shortcuts fire. After #431,
Ctrl+Wthere does nothing at all; this makes it close the browser tab.Builds on #431. This branch contains #431's commit. Without it, the forwarded
Ctrl+Wwould still reach Electron's default menu and close the window. Merge #431 first, or merge this PR, which includes it.Why the shortcuts never fired
A focused
<webview>guest receives its keys before the desktop renderer does. They never reach thedocument-level listeners inuseKeyboardShortcuts.Main is the only place that sees those keys, through the guest's
before-input-event. But that event fires before the page handles the key, so main can't tell whether the page is going to use it.Fix
Main (
webview-guest-keys.ts,shared/guest-key.ts).browser:guest-key.preventDefault. Main doesn't know the user's bindings, and keeping a second copy ofclaimsKeyEventthere is exactly what AGENTS.md rules out.Renderer (
useKeyboardShortcuts).matchesBindingthe DOM path uses.GLOBAL_IN_PAGE(shortcut-target.ts), the counterpart ofGLOBAL_IN_EDITOR.Closing the right tab (
utils/guest-pane.ts).<webview>it is.Ctrl+Wtherefore never closes a tab in another pane.To let another action work from a page, add it to
GLOBAL_IN_PAGE. Only do that if no web app would reasonably use its chord.Verification
I ran a dev build side by side with the installed wmux under
WMUX_INSTANCE, with a terminal pane and a browser pane, and sent real input to the guests withwebContents.sendInputEvent. The table shows the store state:Ctrl+WCtrl+Win a page in a pane with tabst, b*, tt, t*Ctrl+Tin a pageCtrl+Bin a pagekeydownsawCtrl+bwtyped in a pageguest-key.test.tscovers the input filter and the main forwarder.guest-pane.test.tscovers the guest → pane lookup.shortcut-target.test.tscovers theGLOBAL_IN_PAGEcontents.tscpasses for both projects. The only renderer errors arekatex/mermaidbeing missing from my localnode_modules, which is unrelated to this change.eslintis clean on the changed files.