mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-07-22 07:41:23 -07:00
Improve altName completion behavior in slash commands (#4227)
Co-authored-by: Jacob Richman <jacob314@gmail.com>
This commit is contained in:
@@ -54,6 +54,12 @@ describe('useCompletion git-aware filtering integration', () => {
|
||||
description: 'Show help',
|
||||
action: vi.fn(),
|
||||
},
|
||||
{
|
||||
name: 'stats',
|
||||
altName: 'usage',
|
||||
description: 'check session stats. Usage: /stats [model|tools]',
|
||||
action: vi.fn(),
|
||||
},
|
||||
{
|
||||
name: 'clear',
|
||||
description: 'Clear the screen',
|
||||
@@ -511,10 +517,27 @@ describe('useCompletion git-aware filtering integration', () => {
|
||||
expect(result.current.showSuggestions).toBe(true);
|
||||
});
|
||||
|
||||
it('should suggest commands based on altName', async () => {
|
||||
it.each([['/?'], ['/usage']])(
|
||||
'should not suggest commands when altName is fully typed',
|
||||
async (altName) => {
|
||||
const { result } = renderHook(() =>
|
||||
useCompletion(
|
||||
altName,
|
||||
'/test/cwd',
|
||||
true,
|
||||
mockSlashCommands,
|
||||
mockCommandContext,
|
||||
),
|
||||
);
|
||||
|
||||
expect(result.current.suggestions).toHaveLength(0);
|
||||
},
|
||||
);
|
||||
|
||||
it('should suggest commands based on partial altName matches', async () => {
|
||||
const { result } = renderHook(() =>
|
||||
useCompletion(
|
||||
'/?',
|
||||
'/usag', // part of the word "usage"
|
||||
'/test/cwd',
|
||||
true,
|
||||
mockSlashCommands,
|
||||
@@ -523,7 +546,11 @@ describe('useCompletion git-aware filtering integration', () => {
|
||||
);
|
||||
|
||||
expect(result.current.suggestions).toEqual([
|
||||
{ label: 'help', value: 'help', description: 'Show help' },
|
||||
{
|
||||
label: 'stats',
|
||||
value: 'stats',
|
||||
description: 'check session stats. Usage: /stats [model|tools]',
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -734,7 +761,7 @@ describe('useCompletion git-aware filtering integration', () => {
|
||||
|
||||
expect(result.current.suggestions.length).toBe(mockSlashCommands.length);
|
||||
expect(result.current.suggestions.map((s) => s.label)).toEqual(
|
||||
expect.arrayContaining(['help', 'clear', 'memory', 'chat']),
|
||||
expect.arrayContaining(['help', 'clear', 'memory', 'chat', 'stats']),
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user