From 1dbb9af41c4db2633bd73175211ecd7ea7a565fc Mon Sep 17 00:00:00 2001 From: jacob314 Date: Wed, 25 Feb 2026 10:00:14 -0800 Subject: [PATCH] fix(cli): prioritize shorter command names in shell autocomplete results --- packages/cli/src/ui/hooks/useShellCompletion.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/cli/src/ui/hooks/useShellCompletion.ts b/packages/cli/src/ui/hooks/useShellCompletion.ts index 19442af280..edcc01eda8 100644 --- a/packages/cli/src/ui/hooks/useShellCompletion.ts +++ b/packages/cli/src/ui/hooks/useShellCompletion.ts @@ -483,6 +483,13 @@ export function useShellCompletion({ const queryLower = query.toLowerCase(); results = pathCacheRef.current .filter((cmd) => cmd.toLowerCase().startsWith(queryLower)) + .sort((a, b) => { + // Prioritize shorter commands as they are likely common built-ins + if (a.length !== b.length) { + return a.length - b.length; + } + return a.localeCompare(b); + }) .slice(0, MAX_SHELL_SUGGESTIONS) .map((cmd) => ({ label: cmd,