From b67806ae9a99e5a3c449c60457933b47d14ba66c Mon Sep 17 00:00:00 2001 From: Billy Biggs Date: Sun, 15 Jun 2025 11:40:39 -0700 Subject: Support completion of checkpoint names in /resume (#1063) --- packages/cli/src/ui/components/InputPrompt.tsx | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'packages/cli/src/ui/components/InputPrompt.tsx') diff --git a/packages/cli/src/ui/components/InputPrompt.tsx b/packages/cli/src/ui/components/InputPrompt.tsx index c4177c00..d31b7106 100644 --- a/packages/cli/src/ui/components/InputPrompt.tsx +++ b/packages/cli/src/ui/components/InputPrompt.tsx @@ -109,11 +109,20 @@ export const InputPrompt: React.FC = ({ const selectedSuggestion = completionSuggestions[indexToUse]; if (query.trimStart().startsWith('/')) { + const parts = query.trimStart().substring(1).split(' '); + const commandName = parts[0]; const slashIndex = query.indexOf('/'); const base = query.substring(0, slashIndex + 1); - const newValue = base + selectedSuggestion.value; - buffer.setText(newValue); - handleSubmitAndClear(newValue); + + const command = slashCommands.find((cmd) => cmd.name === commandName); + if (command && command.completion) { + const newValue = `${base}${commandName} ${selectedSuggestion.value}`; + buffer.setText(newValue); + } else { + const newValue = base + selectedSuggestion.value; + buffer.setText(newValue); + handleSubmitAndClear(newValue); + } } else { const atIndex = query.lastIndexOf('@'); if (atIndex === -1) return; @@ -131,7 +140,13 @@ export const InputPrompt: React.FC = ({ } resetCompletionState(); }, - [resetCompletionState, handleSubmitAndClear, buffer, completionSuggestions], + [ + resetCompletionState, + handleSubmitAndClear, + buffer, + completionSuggestions, + slashCommands, + ], ); useInput( -- cgit v1.2.3