@devries-cameron20 / t3code-1 / commits / 966e422c9f
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(desktop): Cmd+T opens the new-tab menu from a focused browser page (#39769)

Julius Marminge committed Nov 20, 2026 at 07:06 UTC 966e422c9f1800187cb1599d0f5b096638d74ccb
4 files changed +23 -5
apps/web/src/components/ReopenClosedViewShortcut.browser.test.tsx
+2 -1
@@ -265,7 +265,7 @@ describe("root reopen shortcut", () => {
265 expect(useClosedViewStore.getState().entries).toEqual([]);
266 },
267 );
268 - it("forwards address-bar focus, zoom, and panel close from a focused desktop page", async () => {
268 + it("forwards address-bar focus, zoom, and panel new and close from a focused desktop page", async () => {
269 setup();
270 await using _shortcut = await renderShortcut();
271 expect(state.setShortcuts).toHaveBeenLastCalledWith(
@@ -275,6 +275,7 @@ describe("root reopen shortcut", () => {
275 "preview.zoomIn",
276 "preview.zoomOut",
277 "preview.resetZoom",
278 + "rightPanel.new",
279 "rightPanel.close",
280 ].map((command) => expect.objectContaining({ command })),
281 ),
apps/web/src/components/ReopenClosedViewShortcut.tsx
+2
@@ -54,6 +54,7 @@ const PREVIEW_FORWARDED_COMMANDS = [
54 "sidebar.toggle",
55 "rightPanel.toggle",
56 "rightPanel.toggleMaximized",
57 + "rightPanel.new",
58 "rightPanel.close",
59 "preview.focusUrl",
60 "preview.zoomIn",
@@ -211,6 +212,7 @@ export function ReopenClosedViewShortcut() {
212 context: {
213 previewFocus: true,
214 previewOpen: true,
215 + rightPanelOpen: true,
216 terminalFocus: false,
217 terminalOpen,
218 editableFocus: false,
apps/web/src/components/RightPanelTabs.browser.test.tsx
+5 -1
@@ -25,7 +25,11 @@ function trackpad() {
25 };
26 let scrolling = false;
27 return {
28 - bridge: { onTrackpadScrollBegin: subscribe(begin), onTrackpadScrollEnd: subscribe(end) },
28 + bridge: {
29 + onTrackpadScrollBegin: subscribe(begin),
30 + onTrackpadScrollEnd: subscribe(end),
31 + onMenuAction: () => () => {},
32 + },
33 scroll(target: Element, deltas: readonly number[]) {
34 let scroller: Element | null = target;
35 while (
apps/web/src/components/RightPanelTabs.tsx
+14 -3
@@ -1117,6 +1117,8 @@ export function RightPanelTabs(props: RightPanelTabsProps) {
1117
1118 if (props.open === false && addSurfaceMenuOpen) setAddSurfaceMenuOpen(false);
1119
1120 + const addSurfaceMenuBlocked = () =>
1121 + !addSurfaceMenuOpen && document.querySelector(LAUNCHER_SHORTCUT_BLOCKING_LAYERS) !== null;
1122 const onNewSurfaceKeyDown = useEffectEvent((event: KeyboardEvent) => {
1123 if (event.defaultPrevented || event.isComposing) return;
1124 if (
@@ -1125,7 +1127,7 @@ export function RightPanelTabs(props: RightPanelTabsProps) {
1127 }) !== "rightPanel.new"
1128 )
1129 return;
1128 - if (!addSurfaceMenuOpen && document.querySelector(LAUNCHER_SHORTCUT_BLOCKING_LAYERS)) return;
1130 + if (addSurfaceMenuBlocked()) return;
1131 event.preventDefault();
1132 event.stopPropagation();
1133 if (!event.repeat) {
@@ -1133,11 +1135,20 @@ export function RightPanelTabs(props: RightPanelTabsProps) {
1135 setAddSurfaceMenuOpen(true);
1136 }
1137 });
1136 - // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- subscribes a document keydown listener for the new surface shortcut while the panel is open
1138 + // Forwarded from a focused browser page. Focusing the trigger here would let ChatView's
1139 + // window-focus handler see a plain button and refocus the composer, closing the menu.
1140 + const onMenuAction = useEffectEvent((action: string) => {
1141 + if (action === "rightPanel.new" && !addSurfaceMenuBlocked()) setAddSurfaceMenuOpen(true);
1142 + });
1143 + // 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
1144 useEffect(() => {
1145 if (props.open === false) return;
1146 document.addEventListener("keydown", onNewSurfaceKeyDown, true);
1140 - return () => document.removeEventListener("keydown", onNewSurfaceKeyDown, true);
1147 + const unsubscribe = window.desktopBridge?.onMenuAction(onMenuAction);
1148 + return () => {
1149 + document.removeEventListener("keydown", onNewSurfaceKeyDown, true);
1150 + unsubscribe?.();
1151 + };
1152 }, [props.open]);
1153
1154 const updateTabScrollState = (viewport: HTMLDivElement) => {