diff --git a/packages/cli/src/ui/components/SuggestionsDisplay.tsx b/packages/cli/src/ui/components/SuggestionsDisplay.tsx index 1275a911..facdfee3 100644 --- a/packages/cli/src/ui/components/SuggestionsDisplay.tsx +++ b/packages/cli/src/ui/components/SuggestionsDisplay.tsx @@ -52,6 +52,21 @@ export function SuggestionsDisplay({ ); const visibleSuggestions = suggestions.slice(startIndex, endIndex); + const isSlashCommandMode = userInput.startsWith('/'); + let commandNameWidth = 0; + + if (isSlashCommandMode) { + const maxLabelLength = visibleSuggestions.length + ? Math.max(...visibleSuggestions.map((s) => s.label.length)) + : 0; + + const maxAllowedWidth = Math.floor(width * 0.35); + commandNameWidth = Math.max( + 15, + Math.min(maxLabelLength + 2, maxAllowedWidth), + ); + } + return ( {scrollOffset > 0 && } @@ -72,21 +87,31 @@ export function SuggestionsDisplay({ return ( - {userInput.startsWith('/') ? ( - // only use box model for (/) command mode - - {labelElement} - + {isSlashCommandMode ? ( + <> + + {labelElement} + + {suggestion.description ? ( + + + {suggestion.description} + + + ) : null} + ) : ( - labelElement + <> + {labelElement} + {suggestion.description ? ( + + + {suggestion.description} + + + ) : null} + )} - {suggestion.description ? ( - - - {suggestion.description} - - - ) : null} );