Uh oh!
There was an error while loading. Please reload this page.
fix(web): <mod>-w closes focused right panel tabs instead of entire window - #6351
fix(web): <mod>-w closes focused right panel tabs instead of entire window#6351davidhu2000 wants to merge 6 commits into
<mod>-w closes focused right panel tabs instead of entire window#6351Conversation
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| modKey && | ||
| !event.altKey && | ||
| !event.shiftKey && | ||
| isPreviewFocused(activeBrowserTabId) |
There was a problem hiding this comment.
🟠 Highcomponents/ChatView.tsx:4677
The Mod+W handler closes the active right-panel surface only when isPreviewFocused(activeBrowserTabId) returns true, but that function only recognizes <webview> elements or DOM under [data-preview-panel-mode]. When a terminal, diff, files, pull-request, or agents surface is focused, isPreviewFocused returns false, so Mod+W falls through to Electron's default handler and closes the entire application window instead of the panel tab. Consecutive closes also break: after closing a preview tab, focus is moved to [data-right-panel-surface-content], but isPreviewFocused does not recognize that container either, so the next Mod+W falls through again. Consider gating the branch on a broader right-panel focus check rather than isPreviewFocused.
🤖 Copy this AI Prompt to have your agent fix this:
In file @apps/web/src/components/ChatView.tsx around line 4677:
The `Mod+W` handler closes the active right-panel surface only when `isPreviewFocused(activeBrowserTabId)` returns true, but that function only recognizes `<webview>` elements or DOM under `[data-preview-panel-mode]`. When a terminal, diff, files, pull-request, or agents surface is focused, `isPreviewFocused` returns false, so `Mod+W` falls through to Electron's default handler and closes the entire application window instead of the panel tab. Consecutive closes also break: after closing a preview tab, focus is moved to `[data-right-panel-surface-content]`, but `isPreviewFocused` does not recognize that container either, so the next `Mod+W` falls through again. Consider gating the branch on a broader right-panel focus check rather than `isPreviewFocused`.
There was a problem hiding this comment.
Verified this is already covered. RightPanelTabs renders its tab bar, every non-browser surface, and [data-right-panel-surface-content] as children of PreviewPanelShell (RightPanelTabs.tsx:587-736). That shell sets [data-preview-panel-mode] on its root (PreviewPanelShell.tsx:51-68), so activeElement.closest("[data-preview-panel-mode]") returns the shell for terminal, diff, files, pull-request, agents, and the post-close focus container.
The detached Electron <webview> is the only special case, and that path is scoped to the active browser tab ID to exclude the mini-player. I also exercised isPreviewFocused(null) with a focused non-webview descendant of the shell; it returns true. No code change is needed here.
There was a problem hiding this comment.
Sorry, I'm unable to act on this request because you do not have permissions within this repository.
ApprovabilityVerdict: Needs human review 1 blocking correctness issue found. This PR modifies keyboard shortcut behavior by intercepting Mod+W to close right panel tabs. A High-severity finding identifies that the focus check is incomplete - the shortcut may fall through to close the entire app window for non-preview surfaces like terminals or diffs, warranting careful review of the implementation scope. You can customize Macroscope's approvability policy. Learn more. |
<mod>-w closes focused right panel tabs instead of entire windowThere was a problem hiding this comment.
One finding: the new <mod>+W interception also fires while a right-panel terminal is focused, which replaces the existing terminal.close behavior with a destructive whole-tab close.
Posted via Macroscope — UI Consistency
| if ( | ||
| activeRightPanelSurface && | ||
| event.key.toLowerCase() === "w" && | ||
| modKey && | ||
| !event.altKey && | ||
| !event.shiftKey && | ||
| isPreviewFocused(activeBrowserTabId) | ||
| ) { |
There was a problem hiding this comment.
isPreviewFocused(activeBrowserTabId) returns true for any focus inside the panel shell (the non-webview branch matches closest("[data-preview-panel-mode]")), and the panel terminal renders inside that shell. Because this window handler is capture-phase and runs before resolveShortcutCommand, pressing <mod>+W with a right-panel terminal focused now calls closeRightPanelSurface, which tears down the whole terminal tab and every session in it, instead of the configured terminal.close (closePanelTerminal) that closes only the focused pane — while the panel still advertises that shortcut via closeShortcutLabel. It also bypasses user-remapped keybindings for mod+w.
Suggest gating the block on the terminal not owning focus (terminalFocusOwner is already computed just above), so terminal tabs keep pane-level close and preview/diff/files tabs get the new tab close:
| if( | |
| activeRightPanelSurface&& | |
| event.key.toLowerCase()==="w"&& | |
| modKey&& | |
| !event.altKey&& | |
| !event.shiftKey&& | |
| isPreviewFocused(activeBrowserTabId) | |
| ){ | |
| if( | |
| activeRightPanelSurface&& | |
| terminalFocusOwner===null&& | |
| event.key.toLowerCase()==="w"&& | |
| modKey&& | |
| !event.altKey&& | |
| !event.shiftKey&& | |
| isPreviewFocused(activeBrowserTabId) | |
| ){ |
Posted via Macroscope — UI Consistency
t3dotgg
commented
Sep 4, 2026
Note 🤖 GPT-6 Astra (preview) responding on behalf of Theo This was closed as part of an automated cleanup pass. If you believe it was closed in error, reply here and we will get it reopened. Closing as superseded by #9363, which is on main. The shared |
When keyboard focus was inside the right panel, Mod+W fell through to Electron and closed the T3 Code window instead of the active panel tab. After the first tab closed, focus also left the panel, so a second press still closed the window.
Screen.Recording.2026-08-12.at.10.15.38.AM.mov
Model: GPT-5.6-sol via the Codex harness in T3 Code.
Note
[!NOTE]
Close focused right panel preview tabs with Cmd/Ctrl+W
ChatViewContentwhen a preview webview for the active right panel tab has focus, closing that surface viacloseRightPanelSurface.isPreviewFocusedto accept an optional tab ID, returning false when the focused webview belongs to a different tab.RightPanelTabsprogrammatically focusable (tabIndex={-1}) so focus can shift back to the panel after closing.📊 Macroscope summarized ece0328. 3 files reviewed, 0 issues evaluated, 0 issues filtered, 0 comments posted
> ### 🗂️ Filtered Issues No issues evaluated. > >