feat: Autocomplete for slash commands (#216)
This commit is contained in:
@@ -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>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user