import { Box, Text } from "ink"; import type { CommandConfig, UnifiedRepo } from "../types/index.ts"; export interface CommandPaletteProps { commands: CommandConfig[]; selectedRepos: UnifiedRepo[]; onClose: () => void; } export function CommandPalette({ commands, selectedRepos, onClose: _onClose, }: CommandPaletteProps) { // onClose is handled by parent through keybindings void _onClose; const repoCount = selectedRepos.length; const repoNames = selectedRepos.slice(0, 3).map((r) => r.name); const moreCount = repoCount > 3 ? repoCount - 3 : 0; // Get the first local path for context const targetPath = selectedRepos[0]?.localPath || selectedRepos[0]?.local?.path; if (commands.length === 0) { return ( Command Palette No custom commands configured. Add commands to your config file: commands: - name: "Open in Editor" key: "e" command: "code ." [Esc] Close ); } return ( {/* Header */} Command Palette {/* Target info */} Target: {repoNames.join(", ")} {moreCount > 0 && +{moreCount} more} {targetPath && ( Path: {targetPath} )} {/* Commands list */} Available Commands {commands.map((cmd) => ( [{cmd.key}] {cmd.name} {cmd.command} {cmd.confirm && (confirm)} {cmd.background && (bg)} ))} {/* Footer */} [key] Execute [Esc] Close ); }