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:
@@ -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). */
|
||||
|
||||
Reference in New Issue
Block a user