From 020745c4edbd52cd3f3cccd8c350b381df08c8cf Mon Sep 17 00:00:00 2001 From: charles wu Date: Tue, 26 May 2026 00:36:57 +0800 Subject: [PATCH] fix(cli): align command picker columns --- src/cli/tui/components/command-list.tsx | 40 ++++++++++++++----------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/src/cli/tui/components/command-list.tsx b/src/cli/tui/components/command-list.tsx index fd49313..e1ab55e 100644 --- a/src/cli/tui/components/command-list.tsx +++ b/src/cli/tui/components/command-list.tsx @@ -21,9 +21,11 @@ export function CommandList({ commands, selectedIndex }: CommandListProps) { const { endIndex, startIndex } = getVisibleWindow(commands.length, selectedIndex, MAX_VISIBLE_COMMANDS); const visibleCommands = commands.slice(startIndex, endIndex); + const commandColumnWidth = getCommandColumnWidth(commands); return ( { const index = startIndex + visibleIndex; return ( - - - {index === selectedIndex ? "❯ " : " "} - - - /{cmd.name} - - - {" "} - [{cmd.type}] {summarizeDescription(cmd.description)} - - + + + + {index === selectedIndex ? "❯ " : " "}/{cmd.name} + + + + + [{cmd.type}] {summarizeDescription(cmd.description)} + + + ); })} ); } +function getCommandColumnWidth(commands: SlashCommand[]): number { + const longestCommand = commands.reduce((max, command) => Math.max(max, command.name.length), 0); + return longestCommand + 4; +} + function summarizeDescription(description: string, maxLength = 72): string { const normalized = description.replace(/\s+/g, " ").trim(); if (normalized.length <= maxLength) return normalized;