From 1a89d185269df6b492f9960c7efb140890bf75b1 Mon Sep 17 00:00:00 2001 From: Neha Prasad Date: Sat, 23 Aug 2025 05:21:49 +0530 Subject: [PATCH] fix: slash command completion menu column width and spacing issues (#5797) Co-authored-by: matt korwel Co-authored-by: Arya Gummadi --- .../src/ui/components/SuggestionsDisplay.tsx | 51 ++++++++++++++----- 1 file changed, 38 insertions(+), 13 deletions(-) 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} );