summaryrefslogtreecommitdiff
path: root/packages/cli/src/ui/hooks/useCompletion.ts
diff options
context:
space:
mode:
authorBilly Biggs <[email protected]>2025-06-15 11:40:39 -0700
committerGitHub <[email protected]>2025-06-15 11:40:39 -0700
commitb67806ae9a99e5a3c449c60457933b47d14ba66c (patch)
treef1334ae7d120c3ba39e5725d5e1f56db8ad443ff /packages/cli/src/ui/hooks/useCompletion.ts
parent6d772a30c0540ad83c99a794c820af635961694a (diff)
Support completion of checkpoint names in /resume (#1063)
Diffstat (limited to 'packages/cli/src/ui/hooks/useCompletion.ts')
-rw-r--r--packages/cli/src/ui/hooks/useCompletion.ts28
1 files changed, 28 insertions, 0 deletions
diff --git a/packages/cli/src/ui/hooks/useCompletion.ts b/packages/cli/src/ui/hooks/useCompletion.ts
index b7603720..5217e60c 100644
--- a/packages/cli/src/ui/hooks/useCompletion.ts
+++ b/packages/cli/src/ui/hooks/useCompletion.ts
@@ -127,6 +127,34 @@ export function useCompletion(
// --- Handle Slash Command Completion ---
if (trimmedQuery.startsWith('/')) {
+ const parts = trimmedQuery.substring(1).split(' ');
+ const commandName = parts[0];
+ const subCommand = parts.slice(1).join(' ');
+
+ const command = slashCommands.find(
+ (cmd) => cmd.name === commandName || cmd.altName === commandName,
+ );
+
+ if (command && command.completion) {
+ const fetchAndSetSuggestions = async () => {
+ setIsLoadingSuggestions(true);
+ if (command.completion) {
+ const results = await command.completion();
+ const filtered = results.filter((r) => r.startsWith(subCommand));
+ const newSuggestions = filtered.map((s) => ({
+ label: s,
+ value: s,
+ }));
+ setSuggestions(newSuggestions);
+ setShowSuggestions(newSuggestions.length > 0);
+ setActiveSuggestionIndex(newSuggestions.length > 0 ? 0 : -1);
+ }
+ setIsLoadingSuggestions(false);
+ };
+ fetchAndSetSuggestions();
+ return;
+ }
+
const partialCommand = trimmedQuery.substring(1);
const filteredSuggestions = slashCommands
.filter(