feat: Autocomplete for slash commands (#216)

This commit is contained in:
Devansh Jain
2025-12-15 12:54:52 -08:00
committed by GitHub
parent 3c0b60f82d
commit 7ce41e52f4
9 changed files with 416 additions and 326 deletions

View File

@@ -1,10 +1,13 @@
import { CommandPreview } from "./CommandPreview";
import { Box } from "ink";
import { AgentInfoBar } from "./AgentInfoBar";
import { FileAutocomplete } from "./FileAutocomplete";
import { SlashCommandAutocomplete } from "./SlashCommandAutocomplete";
interface InputAssistProps {
currentInput: string;
cursorPosition: number;
onFileSelect: (path: string) => void;
onCommandSelect: (command: string) => void;
onAutocompleteActiveChange: (isActive: boolean) => void;
agentId?: string;
agentName?: string | null;
@@ -14,13 +17,14 @@ interface InputAssistProps {
/**
* Shows contextual assistance below the input:
* - File autocomplete when "@" is detected
* - Command preview when "/" is detected
* - Slash command autocomplete when "/" is detected
* - Nothing otherwise
*/
export function InputAssist({
currentInput,
cursorPosition,
onFileSelect,
onCommandSelect,
onAutocompleteActiveChange,
agentId,
agentName,
@@ -38,15 +42,22 @@ export function InputAssist({
);
}
// Show command preview when input starts with /
// Show slash command autocomplete when input starts with /
if (currentInput.startsWith("/")) {
return (
<CommandPreview
currentInput={currentInput}
agentId={agentId}
agentName={agentName}
serverUrl={serverUrl}
/>
<Box flexDirection="column">
<SlashCommandAutocomplete
currentInput={currentInput}
cursorPosition={cursorPosition}
onSelect={onCommandSelect}
onActiveChange={onAutocompleteActiveChange}
/>
<AgentInfoBar
agentId={agentId}
agentName={agentName}
serverUrl={serverUrl}
/>
</Box>
);
}