fix(ui): restore slash command autocomplete space and fix enter execution

This restores the original autocomplete behavior where hitting Tab on a slash command suggestion correctly inserts a trailing space, allowing the user to naturally type the next argument or subcommand.

It also changes the Enter key execution logic to correctly execute a command if it has an action and no completion function, ignoring the autoExecute flag. This matches the expected user behavior where selecting a command like `/stats` and pressing Enter immediately executes it, instead of simply autocompleting it without execution.
This commit is contained in:
Sehoon Shon
2026-03-28 02:31:58 -04:00
parent 07ab16dbbe
commit 616608ef23
5 changed files with 48 additions and 47 deletions
@@ -481,7 +481,7 @@ describe('useCommandCompletion', () => {
});
describe('handleAutocomplete', () => {
it('should complete a partial command and NOT add a space if it has an action', async () => {
it('should complete a partial command and ADD a space even if it has an action', async () => {
setupMocks({
slashSuggestions: [{ label: 'memory', value: 'memory' }],
slashCompletionRange: {
@@ -502,7 +502,7 @@ describe('useCommandCompletion', () => {
result.current.handleAutocomplete(0);
});
expect(result.current.textBuffer.text).toBe('/memory');
expect(result.current.textBuffer.text).toBe('/memory ');
});
it('should complete a partial command and ADD a space if it has NO action (e.g. just a parent)', async () => {