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);