@devries-cameron20 / t3code Mirror · read-only
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, 04:45 UTC

main
ts 16 lines 838 Bytes
Raw
1 export function isPreviewFocused(): boolean {
2 const activeElement = document.activeElement;
3 if (!(activeElement instanceof HTMLElement)) return false;
4 if (!activeElement.isConnected) return false;
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 }