Skip to content

Commit ad057ec

Browse files
authored
Merge pull request #8928 from uinstinct/cli-single-submit
feat: submit slash command in one enter
2 parents 88ec4d2 + 4cf3374 commit ad057ec

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

extensions/cli/spec/shell-mode.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ Interaction with other input helpers
2727
- "/" slash command UI is disabled.
2828
- When in slash command mode (input starts with /):
2929
- "@" file search suggestions are disabled.
30+
- Enter submits the highlighted slash command directly (except /title, which requires Tab to select first).
31+
- Tab selects the highlighted command without submitting.
3032

3133
Submission behavior
3234

extensions/cli/src/ui/UserInput.tsx

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,28 @@ const UserInput: React.FC<UserInputProps> = ({
463463

464464
if ((key.return && !key.shift) || key.tab) {
465465
if (filteredCommands.length > 0) {
466-
selectSlashCommand(filteredCommands[selectedCommandIndex].name);
466+
const commandName = filteredCommands[selectedCommandIndex].name;
467+
if (key.return && commandName !== "title") {
468+
// select and submit the command
469+
const commandText = "/" + commandName;
470+
inputHistory.addEntry(commandText);
471+
472+
// queue up when responding/generating
473+
if (!isRemoteMode && (isWaitingForResponse || isCompacting)) {
474+
void messageQueue.enqueueMessage(commandText);
475+
} else {
476+
onSubmit(commandText);
477+
}
478+
479+
// reset after submitting command
480+
textBuffer.clear();
481+
setInputText("");
482+
setCursorPosition(0);
483+
setShowSlashCommands(false);
484+
setShowBashMode(false);
485+
} else {
486+
selectSlashCommand(commandName);
487+
}
467488
}
468489
return true;
469490
}

0 commit comments

Comments
 (0)