diff --git a/src/ui/SlashCommandUI.tsx b/src/ui/SlashCommandUI.tsx index c940c9133..a62ccd8c3 100644 --- a/src/ui/SlashCommandUI.tsx +++ b/src/ui/SlashCommandUI.tsx @@ -10,14 +10,12 @@ interface SlashCommandUIProps { assistant: AssistantConfig; filter: string; selectedIndex: number; - onSelect: (command: string) => void; } const SlashCommandUI: React.FC = ({ assistant, filter, selectedIndex, - onSelect, }) => { const [allCommands, setAllCommands] = useState([]); diff --git a/src/ui/UserInput.tsx b/src/ui/UserInput.tsx index ae965edaa..8f6b39622 100644 --- a/src/ui/UserInput.tsx +++ b/src/ui/UserInput.tsx @@ -91,12 +91,15 @@ const UserInput: React.FC = ({ // Only show slash commands if slash is the very first character if (text.trimStart().startsWith("/")) { const trimmedText = text.trimStart(); - const beforeCursor = trimmedText.slice(0, cursor - (text.length - trimmedText.length)); - + const beforeCursor = trimmedText.slice( + 0, + cursor - (text.length - trimmedText.length) + ); + // Only show if cursor is after the slash and before any whitespace if (beforeCursor.length > 0 && beforeCursor.startsWith("/")) { const afterSlash = beforeCursor.slice(1); - + if (!afterSlash.includes(" ") && !afterSlash.includes("\n")) { // We're in a slash command context setShowSlashCommands(true); @@ -488,7 +491,6 @@ const UserInput: React.FC = ({ assistant={assistant} filter={slashCommandFilter} selectedIndex={selectedCommandIndex} - onSelect={selectSlashCommand} /> )}