@devries-cameron20 / t3code Mirror · read-only / commits / 062b33275d
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 22, 02:00 UTC

fix(desktop): recording cursor stays above modal dialogs and popovers (#27046)

Co-authored-by: maria-rcks <maria@kuuro.net>

Mateus Junges committed Nov 9, 2026 at 11:27 UTC 062b33275da0c0acc91e57cb1577d42807ab3002
1 file changed +30 -1
apps/desktop/src/preview/RecordingCursor.ts
+30 -1
@@ -11,6 +11,11 @@ import {
11 type RecordingKeyPress,
12 } from "./RecordingInput.ts";
13
14 +// Modal dialogs, popovers and fullscreen elements paint above any z-index, so the cursors live in
15 +// the top layer as manual popovers and move back to its front whenever the page adds to it.
16 +const POPOVER_RESET =
17 + "all:initial;margin:0;padding:0;border:0;background:transparent;overflow:visible;inset:auto;animation:none;transition:none;";
18 +
19 /** Draw in guest coordinates; Chromium's native cursor ignores webview CSS placement/scale. Hide it to avoid duplicates. */
20 export function installRecordingCursor(
21 document: Document,
@@ -20,22 +25,43 @@ export function installRecordingCursor(
25 ) {
26 const style = document.createElement("style");
27 style.textContent =
23 - "html, html * { cursor: none !important; } @media (prefers-reduced-motion: reduce) { [data-t3code-recording-agent-cursor] { transition: none !important; } }";
28 + "html, html * { cursor: none !important; } [data-t3code-recording-cursor]::backdrop, [data-t3code-recording-agent-cursor]::backdrop { display: none !important; } @media (prefers-reduced-motion: reduce) { [data-t3code-recording-agent-cursor] { transition: none !important; } }";
29 const cursor = document.createElement("div");
30 cursor.setAttribute("aria-hidden", "true");
31 cursor.setAttribute("data-t3code-recording-cursor", "");
32 + cursor.popover = "manual";
33 cursor.style.cssText =
34 + POPOVER_RESET +
35 "position:fixed;left:0;top:0;width:16px;height:24px;pointer-events:none;z-index:2147483647;display:none;";
36 cursor.innerHTML =
37 '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="24" viewBox="0 0 16 24"><path d="M1 1v18l4-4 4 8 3-1.5-4-8H15Z" fill="black" stroke="white" stroke-width="1.5" stroke-linejoin="round"/></svg>';
38 const agentCursor = document.createElement("div");
39 agentCursor.setAttribute("aria-hidden", "true");
40 agentCursor.setAttribute("data-t3code-recording-agent-cursor", "");
41 + agentCursor.popover = "manual";
42 agentCursor.style.cssText =
43 + POPOVER_RESET +
44 "position:fixed;left:0;top:0;width:20px;height:20px;pointer-events:none;z-index:2147483647;display:none;filter:drop-shadow(0 1px 2px #0003);transition:transform 150ms ease-out,opacity 150ms ease-out;";
45 agentCursor.innerHTML =
46 '<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="var(--recording-cursor-background,white)" stroke="var(--recording-cursor-primary,#2563eb)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="transform:translate(-2px,-2px)"><path d="M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z"/></svg>';
47 document.documentElement.append(style, cursor, agentCursor);
48 + const cursors = [cursor, agentCursor];
49 + const raise = () => {
50 + for (const element of cursors) {
51 + if (!element.isConnected || typeof element.showPopover !== "function") continue;
52 + if (element.matches(":popover-open")) element.hidePopover();
53 + element.showPopover();
54 + }
55 + };
56 + raise();
57 + const dialogObserver = new MutationObserver(raise);
58 + dialogObserver.observe(document, { subtree: true, attributes: true, attributeFilter: ["open"] });
59 + const toggle = (event: Event) => {
60 + if (cursors.some((element) => element === event.target)) return;
61 + if ("newState" in event && event.newState === "open") raise();
62 + };
63 + document.addEventListener("toggle", toggle, true);
64 + document.addEventListener("fullscreenchange", raise);
65 let controller: "human" | "agent" | "none" = "none";
66 let humanPoint: { readonly x: number; readonly y: number } | null = null;
67 const drawHuman = () => {
@@ -182,6 +208,9 @@ export function installRecordingCursor(
208 window.removeEventListener("keyup", keyUp, true);
209 window.removeEventListener("pointerout", leave, true);
210 window.removeEventListener("blur", hide);
211 + dialogObserver.disconnect();
212 + document.removeEventListener("toggle", toggle, true);
213 + document.removeEventListener("fullscreenchange", raise);
214 cancelPendingPointer();
215 window.clearTimeout(agentTimer);
216 cursor.remove();