The best way to control Claude Code, Codex and more from any computer or phone
| 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 | } |