"use client"; import { useEffect } from "react"; // --------------------------------------------------------------------------- // Module-level registry — ChatWindow registers the abort handler here so that // the global Esc listener in AppShell can call it without prop-drilling. // --------------------------------------------------------------------------- let globalAbortHandler: (() => void) | null = null; /** * Register (or clear) the abort handler for the global Esc shortcut. * Call this from ChatWindow whenever agentRunning or handleAbort changes. */ export function registerAbortHandler(handler: (() => void) | null): void { globalAbortHandler = handler; } // --------------------------------------------------------------------------- // Hook: global keyboard shortcuts // --------------------------------------------------------------------------- interface UseGlobalKeyboardShortcutsOptions { /** Called when Ctrl+Alt+N is pressed. Receives current cwd. */ onNewSession?: (cwd: string) => void; /** The currently selected project directory (sidebar cwd). */ activeCwd?: string | null; } /** * Register global keyboard shortcuts for the application. * * Shortcuts handled here: * Esc – stop the running agent (via module-level abort handler) * Ctrl+Alt+N – create a new session in the active project directory * * Note: Esc inside