@devries-cameron20 / t3code-1 / commits / 3bd7b04544
Fork 0

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

fix(web): Escape and tool keys work as soon as preview annotation starts (#34796)

Julius Marminge committed Nov 11, 2026 at 23:38 UTC 3bd7b0454452c883fd42a1bb900e64eb617b1edb
1 file changed +10 -3
apps/web/src/components/preview/PreviewView.tsx
+10 -3
@@ -146,14 +146,18 @@ function ServerTabFileNotShown(props: {
146 );
147 }
148
149 -function focusPreviewPage(runtimeTabId: string) {
150 - const active = document.activeElement;
151 - if (active && active !== document.body && !active.closest("[data-preview-panel-mode]")) return;
149 +function focusPreviewWebview(runtimeTabId: string) {
150 document
151 .querySelector<HTMLElement>(`[data-preview-viewport="${CSS.escape(runtimeTabId)}"] webview`)
152 ?.focus();
153 }
154
155 +function focusPreviewPage(runtimeTabId: string) {
156 + const active = document.activeElement;
157 + if (active && active !== document.body && !active.closest("[data-preview-panel-mode]")) return;
158 + focusPreviewWebview(runtimeTabId);
159 +}
160 +
161 export function PreviewView({
162 threadRef,
163 tabId: requestedTabId,
@@ -816,6 +820,9 @@ export function PreviewView({
820 readEnvironmentScope(threadRef.environmentId, AuthOrchestrationOperateScope),
821 );
822 if (pickRequest.cancelled) return;
823 + // Main's WebContents.focus() cannot move the embedder's DOM focus into a guest, so key
824 + // presses would stay in the app; only focusing the <webview> element hands them to the page.
825 + focusPreviewWebview(runtimeTabId);
826 const result = await bridge.pickElement(runtimeTabId, voice);
827 if (!result || pickRequest.cancelled) return;
828 // The accepted pick must survive further clicks, tab changes, and unmount; stop cancellation here.