@devries-cameron20 / t3code-1 / commits / 22f006c8d7
Fork 0

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

fix(web): zoom shortcuts zoom the app from the PR, Diff and Files panes (#39207)

Co-authored-by: Julius Marminge <julius0216@outlook.com>

jbearak committed Nov 19, 2026 at 12:37 UTC 22f006c8d79c7dcbf855721e66e225da271ca7b2
4 files changed +55 -3
apps/web/src/components/preview/PreviewView.tsx
+1
@@ -988,6 +988,7 @@ export function PreviewView({
988 <div
989 className="flex min-h-0 flex-1 flex-col bg-background"
990 data-thread-key={scopedThreadKey(threadRef)}
991 + data-preview-view
992 >
993 {pickActive && runtimeTabId && annotationVoice ? (
994 <PreviewAnnotationSpeech
apps/web/src/lib/previewFocus.ts
+9
@@ -5,3 +5,12 @@ export function isPreviewFocused(): boolean {
5 if (activeElement.tagName.toLowerCase() === "webview") return true;
6 return activeElement.closest("[data-preview-panel-mode]") !== null;
7 }
8 +
9 +/** Narrower than isPreviewFocused, whose panel also hosts PR, diff, files and other surfaces. */
10 +export function isBrowserSurfaceFocused(): boolean {
11 + const activeElement = document.activeElement;
12 + if (!(activeElement instanceof HTMLElement) || !activeElement.isConnected) return false;
13 + if (activeElement.tagName.toLowerCase() === "webview") return true;
14 + const panel = activeElement.closest("[data-preview-panel-mode]");
15 + return panel?.querySelector("[data-preview-view]") != null;
16 +}
apps/web/src/shortcuts/chatRouteCommands.browser.test.ts
+34
@@ -1,6 +1,7 @@
1 import type { AnyRouter } from "@tanstack/react-router";
2 import { describe, expect, it } from "vite-plus/test";
3
4 +import { isMacPlatform } from "../lib/utils";
5 import { useThreadSelectionStore } from "../threadSelectionStore";
6 import { installChatRouteCommands } from "./chatRouteCommands";
7
@@ -27,6 +28,19 @@ function pressEscape(): KeyboardEvent {
28 return event;
29 }
30
31 +function pressMod(key: string): KeyboardEvent {
32 + const mac = isMacPlatform(navigator.platform);
33 + const event = new KeyboardEvent("keydown", {
34 + key,
35 + metaKey: mac,
36 + ctrlKey: !mac,
37 + cancelable: true,
38 + bubbles: true,
39 + });
40 + document.activeElement?.dispatchEvent(event);
41 + return event;
42 +}
43 +
44 function selectThread(threadKey: string) {
45 useThreadSelectionStore.getState().clearSelection();
46 useThreadSelectionStore.getState().toggleThread(threadKey);
@@ -64,4 +78,24 @@ describe("chat route commands", () => {
78 navigate(CHAT);
79 expect(pressEscape().defaultPrevented).toBe(true);
80 });
81 +
82 + it("leaves zoom keys to the app unless the focused right panel shows a browser", () => {
83 + const { router } = routerAt(CHAT);
84 + using stack = new DisposableStack();
85 + stack.defer(installChatRouteCommands(router));
86 + const panel = document.createElement("div");
87 + panel.setAttribute("data-preview-panel-mode", "inline");
88 + const pullRequestTab = document.createElement("button");
89 + panel.append(pullRequestTab);
90 + document.body.append(panel);
91 + stack.defer(() => panel.remove());
92 + pullRequestTab.focus();
93 +
94 + for (const key of ["=", "+", "-", "0"]) expect(pressMod(key).defaultPrevented).toBe(false);
95 +
96 + const browser = document.createElement("div");
97 + browser.setAttribute("data-preview-view", "");
98 + panel.append(browser);
99 + for (const key of ["=", "+", "-", "0"]) expect(pressMod(key).defaultPrevented).toBe(true);
100 + });
101 });
apps/web/src/shortcuts/chatRouteCommands.ts
+11 -3
@@ -9,6 +9,7 @@ import { isCommandPaletteOpen, openCommandPalette } from "../commandPaletteBus";
9 import { useComposerDraftStore } from "../composerDraftStore";
10 import { dispatchPreviewAction, type PreviewAction } from "../components/preview/previewActionBus";
11 import { isAppModalPage } from "../components/sidebar/mainAppLocation";
12 +import { isBrowserSurfaceFocused } from "../lib/previewFocus";
13 import { shouldCreateNewThreadInCurrentProject } from "../components/Sidebar.logic";
14 import {
15 createNewThreadHandler,
@@ -126,6 +127,13 @@ export function installChatRouteCommands(router: AnyRouter): () => void {
127 const environmentId = readRouteEnvironmentId();
128 if (environmentId && canOperatePreview(environmentId)) dispatchPreviewAction(action);
129 };
130 + // Unclaimed, zoom keys reach the desktop menu accelerators or the browser's own zoom.
131 + const zoomCommand =
132 + (action: PreviewAction): CommandHandler =>
133 + (event) => {
134 + if (!isBrowserSurfaceFocused()) return false;
135 + previewCommand(action)(event);
136 + };
137
138 return registerCommands(
139 {
@@ -174,9 +182,9 @@ export function installChatRouteCommands(router: AnyRouter): () => void {
182 },
183 "preview.refresh": previewCommand("refresh"),
184 "preview.focusUrl": previewCommand("focus-url"),
177 - "preview.zoomIn": previewCommand("zoom-in"),
178 - "preview.zoomOut": previewCommand("zoom-out"),
179 - "preview.resetZoom": previewCommand("reset-zoom"),
185 + "preview.zoomIn": zoomCommand("zoom-in"),
186 + "preview.zoomOut": zoomCommand("zoom-out"),
187 + "preview.resetZoom": zoomCommand("reset-zoom"),
188 "preview.find": previewCommand("find"),
189 },
190 {