fix: Tab completion for slash commands (#224)

This commit is contained in:
Devansh Jain
2025-12-15 18:02:50 -08:00
committed by GitHub
parent 6809d04576
commit cbfc7d4eee

View File

@@ -1,4 +1,5 @@
import { Box } from "ink";
import { useEffect } from "react";
import { AgentInfoBar } from "./AgentInfoBar";
import { FileAutocomplete } from "./FileAutocomplete";
import { SlashCommandAutocomplete } from "./SlashCommandAutocomplete";
@@ -30,8 +31,23 @@ export function InputAssist({
agentName,
serverUrl,
}: InputAssistProps) {
const showFileAutocomplete = currentInput.includes("@");
const showCommandAutocomplete =
!showFileAutocomplete && currentInput.startsWith("/");
// Reset active state when no autocomplete is being shown
useEffect(() => {
if (!showFileAutocomplete && !showCommandAutocomplete) {
onAutocompleteActiveChange(false);
}
}, [
showFileAutocomplete,
showCommandAutocomplete,
onAutocompleteActiveChange,
]);
// Show file autocomplete when @ is present
if (currentInput.includes("@")) {
if (showFileAutocomplete) {
return (
<FileAutocomplete
currentInput={currentInput}
@@ -43,7 +59,7 @@ export function InputAssist({
}
// Show slash command autocomplete when input starts with /
if (currentInput.startsWith("/")) {
if (showCommandAutocomplete) {
return (
<Box flexDirection="column">
<SlashCommandAutocomplete