import React from 'react'; import { Box, Text, Newline } from 'ink'; import { getKeyboardHandler } from '../services/keyboard-handler.js'; interface HelpOverlayProps { visible: boolean; onClose: () => void; } export const HelpOverlay: React.FC = ({ visible, onClose }) => { if (!visible) return null; const keyboardHandler = getKeyboardHandler(); const shortcuts = keyboardHandler.getContextualShortcuts(); const currentContext = keyboardHandler.getCurrentContext(); // Group shortcuts by context const groupedShortcuts = shortcuts.reduce((acc, shortcut) => { const contexts = shortcut.context || ['global']; contexts.forEach(context => { if (!acc[context]) acc[context] = []; acc[context].push(shortcut); }); return acc; }, {} as Record); const formatShortcutKey = (shortcut: any): string => { const parts = []; if (shortcut.ctrl) parts.push('Ctrl'); if (shortcut.shift) parts.push('Shift'); if (shortcut.alt) parts.push('Alt'); const key = shortcut.key.length === 1 ? shortcut.key.toUpperCase() : shortcut.key; parts.push(key); return parts.join('+'); }; return ( {/* Header */} 🎯 Keyboard Shortcuts Help Current Context: {currentContext} Press 'h' or 'Escape' to close this help • Context-sensitive shortcuts shown {/* Shortcuts Content */} {Object.entries(groupedShortcuts).map(([context, contextShortcuts]) => ( 📁 {context.toUpperCase()} {contextShortcuts.map((shortcut, index) => ( {formatShortcutKey(shortcut).padEnd(15)} {shortcut.description} ))} ))} {/* Quick Reference */} 🔥 Quick Reference Navigation: Use number keys (1-6) to switch views Global: 'q' to quit, 'h' for help, 'r' to refresh Selection: Arrow keys to navigate, Enter to select Advanced: Ctrl+A (select all), Ctrl+C (copy), Ctrl+V (paste) {/* Footer */} 💡 Tip: Shortcuts are context-aware and change based on your current view ); }; export default HelpOverlay;