import { useEffect } from 'react'; import { Keyboard } from 'lucide-react'; import { shortcuts, type ShortcutDefinition } from '@renderer/lib/keyboardShortcuts'; interface KeyboardShortcutsPanelProps { onClose: () => void; } const categoryOrder = ['Navigation', 'Sessions', 'Workspace', 'General'] as const; function groupByCategory(defs: ShortcutDefinition[]): Map { const groups = new Map(); for (const def of defs) { const list = groups.get(def.category) ?? []; list.push(def); groups.set(def.category, list); } return groups; } export function KeyboardShortcutsPanel({ onClose }: KeyboardShortcutsPanelProps) { // Escape to close — capture phase so it doesn't propagate useEffect(() => { const handleEscape = (e: KeyboardEvent) => { if (e.key === 'Escape') { e.preventDefault(); e.stopImmediatePropagation(); onClose(); } }; document.addEventListener('keydown', handleEscape, true); return () => document.removeEventListener('keydown', handleEscape, true); }, [onClose]); const grouped = groupByCategory(shortcuts); return (
e.stopPropagation()} > {/* Header */}

Keyboard Shortcuts

Press Esc to close
{/* Body — two-column grid of categories */}
{categoryOrder.map((cat) => { const items = grouped.get(cat); if (!items?.length) return null; return (

{cat}

    {items.map((item) => (
  • {item.label}
  • ))}
); })}
{/* Footer */}
Tip: Use the command palette for even more actions
); } /** Inline keyboard key cap. */ function Kbd({ children }: { children: React.ReactNode }) { return ( {children} ); } /** Renders a compound shortcut like "Ctrl+Shift+Tab" as joined key caps. */ function ShortcutBadge({ keys }: { keys: string }) { const parts = keys.split('+'); return ( {parts.map((part, i) => ( {part} ))} ); }