fix(cli): prioritize slash command completions (#3104)

This commit is contained in:
易良 2026-04-11 11:04:58 +08:00 committed by GitHub
parent 4c67670ef0
commit 81ccbb976c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 308 additions and 14 deletions

View file

@ -246,6 +246,36 @@ describe('useSlashCompletion', () => {
});
});
it('should prefer higher completionPriority when match quality ties', async () => {
const slashCommands = [
createTestCommand({
name: 'mock',
description: 'Mock command',
}),
createTestCommand({
name: 'model',
description: 'Model command',
completionPriority: 100,
}),
];
const { result } = renderHook(() =>
useTestHarnessForSlashCompletion(
true,
'/mo',
slashCommands,
mockCommandContext,
),
);
await waitFor(() => {
expect(result.current.suggestions.map((s) => s.value)).toEqual([
'model',
'mock',
]);
});
});
it('should suggest commands based on partial altNames', async () => {
const slashCommands = [
createTestCommand({