From 4a72f6ffdb34de376288eb19aee44ae228933075 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Fri, 20 Nov 2026 14:16:20 +0000 Subject: [PATCH 1/2] test(web): Cmd+T is forwarded from a focused desktop browser page (#39744) Co-Authored-By: Claude Opus 5.5 --- .../src/components/ReopenClosedViewShortcut.browser.test.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/web/src/components/ReopenClosedViewShortcut.browser.test.tsx b/apps/web/src/components/ReopenClosedViewShortcut.browser.test.tsx index 0830d218945ab..406e3d79bd57d 100644 --- a/apps/web/src/components/ReopenClosedViewShortcut.browser.test.tsx +++ b/apps/web/src/components/ReopenClosedViewShortcut.browser.test.tsx @@ -265,7 +265,7 @@ describe("root reopen shortcut", () => { expect(useClosedViewStore.getState().entries).toEqual([]); }, ); - it("forwards address-bar focus, zoom, and panel close from a focused desktop page", async () => { + it("forwards address-bar focus, zoom, and panel new and close from a focused desktop page", async () => { setup(); await using _shortcut = await renderShortcut(); expect(state.setShortcuts).toHaveBeenLastCalledWith( @@ -275,6 +275,7 @@ describe("root reopen shortcut", () => { "preview.zoomIn", "preview.zoomOut", "preview.resetZoom", + "rightPanel.new", "rightPanel.close", ].map((command) => expect.objectContaining({ command })), ), From 180aaf5c3905f7635364de015830116fbbb80f27 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Fri, 20 Nov 2026 14:38:34 +0000 Subject: [PATCH 2/2] fix(desktop): Cmd+T opens the new-tab menu from a focused browser page A focused page in the Browser panel swallows app keydowns, and the desktop app only forwards chords the web app registers. rightPanel.new was not registered, and its when-clause needs rightPanelOpen, so Cmd+T did nothing. Forward rightPanel.new and handle its menu action in RightPanelTabs. The forwarded path opens the menu without focusing the trigger first, so the window-focus composer refocus cannot close it before the popup takes focus. Co-Authored-By: Claude Opus 5.5 --- .../src/components/ReopenClosedViewShortcut.tsx | 2 ++ .../components/RightPanelTabs.browser.test.tsx | 6 +++++- apps/web/src/components/RightPanelTabs.tsx | 17 ++++++++++++++--- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/apps/web/src/components/ReopenClosedViewShortcut.tsx b/apps/web/src/components/ReopenClosedViewShortcut.tsx index 8c4e7d7c5a80c..83e0d3deaf990 100644 --- a/apps/web/src/components/ReopenClosedViewShortcut.tsx +++ b/apps/web/src/components/ReopenClosedViewShortcut.tsx @@ -54,6 +54,7 @@ const PREVIEW_FORWARDED_COMMANDS = [ "sidebar.toggle", "rightPanel.toggle", "rightPanel.toggleMaximized", + "rightPanel.new", "rightPanel.close", "preview.focusUrl", "preview.zoomIn", @@ -211,6 +212,7 @@ export function ReopenClosedViewShortcut() { context: { previewFocus: true, previewOpen: true, + rightPanelOpen: true, terminalFocus: false, terminalOpen, editableFocus: false, diff --git a/apps/web/src/components/RightPanelTabs.browser.test.tsx b/apps/web/src/components/RightPanelTabs.browser.test.tsx index f803cb41520bc..515d5cdbfb32b 100644 --- a/apps/web/src/components/RightPanelTabs.browser.test.tsx +++ b/apps/web/src/components/RightPanelTabs.browser.test.tsx @@ -25,7 +25,11 @@ function trackpad() { }; let scrolling = false; return { - bridge: { onTrackpadScrollBegin: subscribe(begin), onTrackpadScrollEnd: subscribe(end) }, + bridge: { + onTrackpadScrollBegin: subscribe(begin), + onTrackpadScrollEnd: subscribe(end), + onMenuAction: () => () => {}, + }, scroll(target: Element, deltas: readonly number[]) { let scroller: Element | null = target; while ( diff --git a/apps/web/src/components/RightPanelTabs.tsx b/apps/web/src/components/RightPanelTabs.tsx index 2ce8f22f63f5e..0592a588a872d 100644 --- a/apps/web/src/components/RightPanelTabs.tsx +++ b/apps/web/src/components/RightPanelTabs.tsx @@ -1117,6 +1117,8 @@ export function RightPanelTabs(props: RightPanelTabsProps) { if (props.open === false && addSurfaceMenuOpen) setAddSurfaceMenuOpen(false); + const addSurfaceMenuBlocked = () => + !addSurfaceMenuOpen && document.querySelector(LAUNCHER_SHORTCUT_BLOCKING_LAYERS) !== null; const onNewSurfaceKeyDown = useEffectEvent((event: KeyboardEvent) => { if (event.defaultPrevented || event.isComposing) return; if ( @@ -1125,7 +1127,7 @@ export function RightPanelTabs(props: RightPanelTabsProps) { }) !== "rightPanel.new" ) return; - if (!addSurfaceMenuOpen && document.querySelector(LAUNCHER_SHORTCUT_BLOCKING_LAYERS)) return; + if (addSurfaceMenuBlocked()) return; event.preventDefault(); event.stopPropagation(); if (!event.repeat) { @@ -1133,11 +1135,20 @@ export function RightPanelTabs(props: RightPanelTabsProps) { setAddSurfaceMenuOpen(true); } }); - // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- subscribes a document keydown listener for the new surface shortcut while the panel is open + // Forwarded from a focused browser page. Focusing the trigger here would let ChatView's + // window-focus handler see a plain button and refocus the composer, closing the menu. + const onMenuAction = useEffectEvent((action: string) => { + if (action === "rightPanel.new" && !addSurfaceMenuBlocked()) setAddSurfaceMenuOpen(true); + }); + // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- subscribes document keydown and the desktop menu action (forwarded from a focused browser page) for the new surface shortcut while the panel is open useEffect(() => { if (props.open === false) return; document.addEventListener("keydown", onNewSurfaceKeyDown, true); - return () => document.removeEventListener("keydown", onNewSurfaceKeyDown, true); + const unsubscribe = window.desktopBridge?.onMenuAction(onMenuAction); + return () => { + document.removeEventListener("keydown", onNewSurfaceKeyDown, true); + unsubscribe?.(); + }; }, [props.open]); const updateTabScrollState = (viewport: HTMLDivElement) => {