diff --git a/src/ui/SlashCommandUI.tsx b/src/ui/SlashCommandUI.tsx index a18914ac1..dfef5ce06 100644 --- a/src/ui/SlashCommandUI.tsx +++ b/src/ui/SlashCommandUI.tsx @@ -1,6 +1,6 @@ +import { type AssistantConfig } from "@continuedev/sdk"; import { Box, Text } from "ink"; import React from "react"; -import { type AssistantConfig } from "@continuedev/sdk"; interface SlashCommandUIProps { assistant: AssistantConfig; @@ -26,28 +26,43 @@ const SlashCommandUI: React.FC = ({ const systemCommands: SlashCommand[] = [ { name: "help", description: "Show help message", category: "system" }, { name: "exit", description: "Exit the chat", category: "system" }, - { name: "login", description: "Authenticate with your account", category: "system" }, - { name: "logout", description: "Sign out of your current session", category: "system" }, - { name: "whoami", description: "Check who you're currently logged in as", category: "system" }, - { name: "models", description: "List available AI models", category: "system" }, + { + name: "login", + description: "Authenticate with your account", + category: "system", + }, + { + name: "logout", + description: "Sign out of your current session", + category: "system", + }, + { + name: "whoami", + description: "Check who you're currently logged in as", + category: "system", + }, + { + name: "models", + description: "List available AI models", + category: "system", + }, ]; - const assistantCommands: SlashCommand[] = assistant.prompts?.map( - (prompt) => ({ + const assistantCommands: SlashCommand[] = + assistant.prompts?.map((prompt) => ({ name: prompt?.name || "", description: prompt?.description || "", category: "assistant" as const, - }) - ) || []; + })) || []; return [...systemCommands, ...assistantCommands]; }; const allCommands = getSlashCommands(); - + // Filter commands based on the current filter - const filteredCommands = allCommands.filter( - (cmd) => cmd.name.toLowerCase().includes(filter.toLowerCase()) + const filteredCommands = allCommands.filter((cmd) => + cmd.name.toLowerCase().includes(filter.toLowerCase()) ); if (filteredCommands.length === 0) { @@ -65,39 +80,21 @@ const SlashCommandUI: React.FC = ({ } return ( - - - - Slash Commands - - - + {filteredCommands.map((command, index) => { const isSelected = index === selectedIndex; - const categoryColor = command.category === "system" ? "cyan" : "yellow"; - + return ( - - - {isSelected ? "▶ " : " "} - /{command.name} + + + {" "} + /{command.name} - {command.description} ); })} - + Use ↑/↓ to navigate, Enter to select, Tab to complete @@ -107,4 +104,4 @@ const SlashCommandUI: React.FC = ({ ); }; -export default SlashCommandUI; \ No newline at end of file +export default SlashCommandUI;