Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

terminalFocus.ts

9 lines535 Bytes

1export function isTerminalFocused(): boolean {
2 const activeElement = document.activeElement;
3 if (!(activeElement instanceof HTMLElement)) return false;
4 if (!activeElement.isConnected) return false;
5 if (activeElement.classList.contains("xterm-helper-textarea")) return true;
6 if (activeElement.closest(".thread-terminal-drawer .xterm") !== null) return true;
7 // Sidebar / toolbar / resize affordances: still "terminal UI" for split vs diff.toggle (⌘D).
8 return activeElement.closest(".thread-terminal-drawer") !== null;
9}