chore: Tab for slash command autocomplete (#249)

This commit is contained in:
Devansh Jain
2025-12-16 16:46:13 -08:00
committed by GitHub
parent 0f6ec5e21b
commit e9d6b16e86
7 changed files with 110 additions and 46 deletions

View File

@@ -458,10 +458,10 @@ export function Input({
setCursorPos(newCursorPos);
};
// Handle slash command selection from autocomplete
// Handle slash command selection from autocomplete (Enter key - execute)
const handleCommandSelect = async (selectedCommand: string) => {
// For slash commands, submit immediately when selected from autocomplete
// This provides a better UX - selecting /model should open the model selector
// For slash commands, submit immediately when selected via Enter
// This provides a better UX - pressing Enter on /model should open the model selector
const commandToSubmit = selectedCommand.trim();
// Add to history if not a duplicate of the last entry
@@ -477,6 +477,14 @@ export function Input({
await onSubmit(commandToSubmit);
};
// Handle slash command autocomplete (Tab key - fill text only)
const handleCommandAutocomplete = (selectedCommand: string) => {
// Just fill in the command text without executing
// User can then press Enter to execute or continue typing arguments
setValue(selectedCommand);
setCursorPos(selectedCommand.length);
};
// Get display name and color for permission mode
const getModeInfo = () => {
switch (currentMode) {
@@ -567,6 +575,7 @@ export function Input({
cursorPosition={currentCursorPosition}
onFileSelect={handleFileSelect}
onCommandSelect={handleCommandSelect}
onCommandAutocomplete={handleCommandAutocomplete}
onAutocompleteActiveChange={setIsAutocompleteActive}
agentId={agentId}
agentName={agentName}