@devries-cameron20 / t3code Mirror · read-only / commits / e079ad9a85
Fork 0

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

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 18:30 UTC

fix(desktop): clicking inside the in-app browser closes open host menus (#23141)

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

voida6 committed Nov 13, 2026 at 14:30 UTC e079ad9a85946fb1a7ac32df99b1d951fe7777e5
3 files changed +17 -1
apps/desktop/src/preview/GuestProtocol.ts
+3
@@ -6,6 +6,9 @@ export const ANNOTATION_THEME_CHANNEL = "preview:annotation-theme";
6 export const ANNOTATION_SEND_ENABLED_CHANNEL = "preview:annotation-send-enabled";
7 export const HUMAN_INPUT_CHANNEL = "preview:human-input";
8 export const MOUSE_NAVIGATE_CHANNEL = "preview:mouse-navigate";
9 +// Sent to the hosting <webview> element (ipc-message). The web app mirrors this
10 +// literal in HostedBrowserWebview because it cannot import from the desktop app.
11 +export const POINTER_DOWN_HOST_CHANNEL = "preview:pointer-down";
12 export const PAGE_UNHANDLED_SHORTCUT_CHANNEL = "preview:page-unhandled-shortcut";
13 export const RECORDING_CURSOR_CHANNEL = "preview:recording-cursor";
14 export const RECORDING_POINTER_CHANNEL = "preview:recording-pointer";
apps/desktop/src/preview/PickPreload.ts
+4
@@ -40,6 +40,7 @@ import {
40 ELEMENT_PICKED_CHANNEL,
41 HUMAN_INPUT_CHANNEL,
42 MOUSE_NAVIGATE_CHANNEL,
43 + POINTER_DOWN_HOST_CHANNEL,
44 PAGE_UNHANDLED_SHORTCUT_CHANNEL,
45 RECORDING_CURSOR_CHANNEL,
46 RECORDING_POINTER_CHANNEL,
@@ -193,6 +194,9 @@ const applyAnnotationTheme = (
194
195 const reportHumanPointerInput = (event: PointerEvent): void => {
196 if (!event.isTrusted) return;
197 + // The guest does not always take focus on a click, so the host's webview
198 + // `focus` event can't be relied on to dismiss open menus and popovers.
199 + ipcRenderer.sendToHost(POINTER_DOWN_HOST_CHANNEL);
200 ipcRenderer.send(HUMAN_INPUT_CHANNEL, {
201 kind: "pointer",
202 x: event.clientX,
apps/web/src/browser/HostedBrowserWebview.tsx
+10 -1
@@ -184,16 +184,24 @@ export function HostedBrowserWebview(props: {
184 if (!disposed) remountCrashedWebview();
185 }, recovery.delayMs);
186 };
187 - // Guest clicks only emit focus here; replay pointerdown to dismiss host popups.
187 + // Guest clicks never reach this document, so replay a pointerdown to dismiss host popups.
188 + // The guest preload reports each press, since the guest does not always take focus.
189 const dismissHostPopups = () => {
190 webview.dispatchEvent(
191 new PointerEvent("pointerdown", { bubbles: true, pointerType: "mouse" }),
192 );
193 };
194 + const guestPointerDown = (event: Event) => {
195 + // Mirrors POINTER_DOWN_HOST_CHANNEL in apps/desktop/src/preview/GuestProtocol.ts.
196 + if ((event as Event & { channel?: string }).channel === "preview:pointer-down") {
197 + dismissHostPopups();
198 + }
199 + };
200 webview.addEventListener("did-attach", register);
201 webview.addEventListener("dom-ready", register);
202 webview.addEventListener("render-process-gone", recoverGuest);
203 webview.addEventListener("focus", dismissHostPopups);
204 + webview.addEventListener("ipc-message", guestPointerDown);
205 register();
206 return () => {
207 disposed = true;
@@ -202,6 +210,7 @@ export function HostedBrowserWebview(props: {
210 webview.removeEventListener("dom-ready", register);
211 webview.removeEventListener("render-process-gone", recoverGuest);
212 webview.removeEventListener("focus", dismissHostPopups);
213 + webview.removeEventListener("ipc-message", guestPointerDown);
214 };
215 }, [
216 clientSettingsHydrated,