fix(tui): preserved autocomplete for no-arg slash prompts

- Propagated builtin allowArgs metadata into TUI autocomplete entries.

- Let no-arg slash-looking prompts fall through to prompt-composer completions while keeping argument-capable commands scoped.

- Added regressions for /settings @ and /settings #copy.
This commit is contained in:
roboomp
2026-07-05 09:05:45 +00:00
parent ed63b62889
commit 1fcdc4f882
6 changed files with 74 additions and 19 deletions
@@ -95,11 +95,13 @@ function getPromptActionPrefix(textBeforeCursor: string): string | null {
}
export class PromptActionAutocompleteProvider implements AutocompleteProvider {
#commands: SlashCommand[];
#baseProvider: CombinedAutocompleteProvider;
#actions: PromptActionDefinition[];
#basePath: string;
constructor(commands: SlashCommand[], basePath: string, actions: PromptActionDefinition[]) {
this.#commands = commands;
this.#baseProvider = new CombinedAutocompleteProvider(commands, basePath);
this.#basePath = basePath;
this.#actions = actions;
@@ -118,8 +120,13 @@ export class PromptActionAutocompleteProvider implements AutocompleteProvider {
leadingSlashStart !== null && !hasPromptTextBeforeCursorLine
? textBeforeCursor.slice(leadingSlashStart)
: null;
if (commandText?.includes(" ")) {
return this.#baseProvider.getSuggestions(lines, cursorLine, cursorCol);
const spaceIndex = commandText?.indexOf(" ") ?? -1;
if (commandText !== null && spaceIndex !== -1) {
const commandName = commandText.slice(1, spaceIndex);
const command = this.#commands.find(cmd => cmd.name === commandName || cmd.aliases?.includes(commandName));
if (command && (!("allowArgs" in command) || command.allowArgs !== false)) {
return this.#baseProvider.getSuggestions(lines, cursorLine, cursorCol);
}
}
const promptActionPrefix = getPromptActionPrefix(textBeforeCursor);
@@ -2437,6 +2437,7 @@ export const BUILTIN_SLASH_COMMAND_DEFS: ReadonlyArray<BuiltinSlashCommand> = BU
command => ({
name: command.name,
aliases: command.aliases,
allowArgs: command.allowArgs === true,
description: command.description,
subcommands: command.subcommands,
inlineHint: command.inlineHint,
@@ -16,6 +16,8 @@ export interface BuiltinSlashCommand {
name: string;
aliases?: string[];
description: string;
/** Whether the command consumes text after the command name. */
allowArgs?: boolean;
/** Subcommands for dropdown completion (e.g. /mcp add, /mcp list). */
subcommands?: SubcommandDef[];
/** Static inline hint when command takes a simple argument (no subcommands). */