diff options
Diffstat (limited to 'packages/cli/src/ui/components')
| -rw-r--r-- | packages/cli/src/ui/components/Help.tsx | 2 | ||||
| -rw-r--r-- | packages/cli/src/ui/components/InputPrompt.test.tsx | 8 | ||||
| -rw-r--r-- | packages/cli/src/ui/components/InputPrompt.tsx | 10 |
3 files changed, 11 insertions, 9 deletions
diff --git a/packages/cli/src/ui/components/Help.tsx b/packages/cli/src/ui/components/Help.tsx index c51867af..ecad9b5e 100644 --- a/packages/cli/src/ui/components/Help.tsx +++ b/packages/cli/src/ui/components/Help.tsx @@ -10,7 +10,7 @@ import { Colors } from '../colors.js'; import { SlashCommand } from '../commands/types.js'; interface Help { - commands: SlashCommand[]; + commands: readonly SlashCommand[]; } export const Help: React.FC<Help> = ({ commands }) => ( diff --git a/packages/cli/src/ui/components/InputPrompt.test.tsx b/packages/cli/src/ui/components/InputPrompt.test.tsx index 6b201901..886a6235 100644 --- a/packages/cli/src/ui/components/InputPrompt.test.tsx +++ b/packages/cli/src/ui/components/InputPrompt.test.tsx @@ -451,13 +451,13 @@ describe('InputPrompt', () => { unmount(); }); - it('should complete a command based on its altName', async () => { - // Add a command with an altName to our mock for this test + it('should complete a command based on its altNames', async () => { + // Add a command with an altNames to our mock for this test props.slashCommands.push({ name: 'help', - altName: '?', + altNames: ['?'], description: '...', - }); + } as SlashCommand); mockedUseCompletion.mockReturnValue({ ...mockCompletion, diff --git a/packages/cli/src/ui/components/InputPrompt.tsx b/packages/cli/src/ui/components/InputPrompt.tsx index 46326431..b7c53196 100644 --- a/packages/cli/src/ui/components/InputPrompt.tsx +++ b/packages/cli/src/ui/components/InputPrompt.tsx @@ -32,7 +32,7 @@ export interface InputPromptProps { userMessages: readonly string[]; onClearScreen: () => void; config: Config; - slashCommands: SlashCommand[]; + slashCommands: readonly SlashCommand[]; commandContext: CommandContext; placeholder?: string; focus?: boolean; @@ -180,18 +180,20 @@ export const InputPrompt: React.FC<InputPromptProps> = ({ // If there's no trailing space, we need to check if the current query // is already a complete path to a parent command. if (!hasTrailingSpace) { - let currentLevel: SlashCommand[] | undefined = slashCommands; + let currentLevel: readonly SlashCommand[] | undefined = slashCommands; for (let i = 0; i < parts.length; i++) { const part = parts[i]; const found: SlashCommand | undefined = currentLevel?.find( - (cmd) => cmd.name === part || cmd.altName === part, + (cmd) => cmd.name === part || cmd.altNames?.includes(part), ); if (found) { if (i === parts.length - 1 && found.subCommands) { isParentPath = true; } - currentLevel = found.subCommands; + currentLevel = found.subCommands as + | readonly SlashCommand[] + | undefined; } else { // Path is invalid, so it can't be a parent path. currentLevel = undefined; |
