-
Notifications
You must be signed in to change notification settings - Fork 3k
feat(web-shell): improve slash command discovery (taller menu, group counts, fuzzy search) #6267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -178,6 +178,97 @@ describe('getSlashCommandCompletionResult', () => { | |
| ]); | ||
| }); | ||
|
|
||
| it('fuzzy-ranks top-level commands for an abbreviated query', () => { | ||
| const commands: CommandInfo[] = [ | ||
| { name: 'model', description: 'Switch model', source: 'builtin-command' }, | ||
| { | ||
| name: 'memory', | ||
| description: 'Manage memory', | ||
| source: 'builtin-command', | ||
| }, | ||
| { | ||
| name: 'agent-reproduce-feature', | ||
| description: 'Reproduce a feature', | ||
| source: 'skill-dir-command', | ||
| }, | ||
| ]; | ||
|
|
||
| const mdl = getSlashCommandCompletionResult( | ||
| '/mdl', | ||
| 4, | ||
| commands, | ||
| [], | ||
| 'en', | ||
| getTranslator('en'), | ||
| ); | ||
| expect(mdl?.items[0]?.label).toBe('/model'); | ||
|
|
||
| const arf = getSlashCommandCompletionResult( | ||
| '/arf', | ||
| 4, | ||
| commands, | ||
| [], | ||
| 'en', | ||
| getTranslator('en'), | ||
| ); | ||
| expect(arf?.items.map((item) => item.label)).toContain( | ||
| '/agent-reproduce-feature', | ||
| ); | ||
| }); | ||
|
|
||
| it('drops section headers while searching but keeps them while browsing', () => { | ||
| const commands: CommandInfo[] = [ | ||
| { | ||
| name: 'clear', | ||
| description: 'Clear the screen', | ||
| source: 'builtin-command', | ||
| }, | ||
| { | ||
| name: 'demo:ping', | ||
| description: 'Project command', | ||
| source: 'skill-dir-command', | ||
| }, | ||
| ]; | ||
|
|
||
| const browsing = getSlashCommandCompletionResult( | ||
| '/', | ||
| 1, | ||
| commands, | ||
| [], | ||
| 'en', | ||
| getTranslator('en'), | ||
| ); | ||
| expect(browsing?.items.every((item) => Boolean(item.section))).toBe(true); | ||
|
|
||
| const searching = getSlashCommandCompletionResult( | ||
| '/c', | ||
| 2, | ||
| commands, | ||
| [], | ||
| 'en', | ||
| getTranslator('en'), | ||
| ); | ||
| expect(searching?.items.map((item) => item.label)).toEqual(['/clear']); | ||
| expect(searching?.items.every((item) => item.section === undefined)).toBe( | ||
| true, | ||
| ); | ||
| }); | ||
|
|
||
| it('returns null when fuzzy search matches nothing', () => { | ||
| const commands: CommandInfo[] = [ | ||
| { name: 'clear', description: 'Clear', source: 'builtin-command' }, | ||
| ]; | ||
| const result = getSlashCommandCompletionResult( | ||
| '/zzzzzzz', | ||
| 8, | ||
| commands, | ||
| [], | ||
| 'en', | ||
| getTranslator('en'), | ||
| ); | ||
| expect(result).toBeNull(); | ||
| }); | ||
|
|
||
| it('honors panel category order and filtered commands', () => { | ||
| const commands: CommandInfo[] = [ | ||
| { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Suggestion] it('deduplicates commands with the same name for fuzzy search', () => {
const commands: CommandInfo[] = [
{ name: 'model', description: 'First', source: 'builtin-command' },
{ name: 'model', description: 'Duplicate', source: 'skill-dir-command' },
{ name: 'memory', description: 'Manage memory', source: 'builtin-command' },
];
const result = getSlashCommandCompletionResult(
'/model', 6, commands, [], 'en', getTranslator('en'),
);
expect(result?.items).toHaveLength(1);
expect(result?.items[0]?.detail).toBe('First');
});— qwen3.7-max via Qwen Code /review |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| /** | ||
| * @license | ||
| * Copyright 2025 Qwen Team | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import { describe, expect, it } from 'vitest'; | ||
| import { planSlashSectionRows } from './slashSectionPlan'; | ||
|
|
||
| describe('planSlashSectionRows', () => { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Suggestion] All existing tests use either all-section-defined or all-section-undefined items. A mixed test — e.g. it('handles mixed section and undefined items correctly', () => {
const plans = planSlashSectionRows(
[
{ section: 'Custom commands' },
{ section: undefined },
{ section: 'System commands' },
],
'command',
);
expect(plans[0]).toMatchObject({ showHeader: true, showDivider: false, count: 1 });
expect(plans[1]).toMatchObject({ showHeader: false, showDivider: false, count: 0 });
expect(plans[2]).toMatchObject({ showHeader: true, showDivider: true, count: 1 });
});— qwen3.7-max via Qwen Code /review |
||
| it('shows a header at each group boundary', () => { | ||
| const plans = planSlashSectionRows( | ||
| [ | ||
| { section: 'Custom commands' }, | ||
| { section: 'Custom commands' }, | ||
| { section: 'Skill commands' }, | ||
| { section: 'System commands' }, | ||
| ], | ||
| 'command', | ||
| ); | ||
| expect(plans.map((p) => p.showHeader)).toEqual([true, false, true, true]); | ||
| }); | ||
|
|
||
| it('shows a header but no divider on the first row', () => { | ||
| const plans = planSlashSectionRows( | ||
| [{ section: 'Skill commands' }, { section: 'System commands' }], | ||
| 'command', | ||
| ); | ||
| expect(plans[0]).toMatchObject({ showHeader: true, showDivider: false }); | ||
| expect(plans[1]).toMatchObject({ showHeader: true, showDivider: true }); | ||
| }); | ||
|
|
||
| it('does not repeat headers for adjacent duplicate sections', () => { | ||
| const plans = planSlashSectionRows( | ||
| [ | ||
| { section: 'System commands' }, | ||
| { section: 'System commands' }, | ||
| { section: 'System commands' }, | ||
| ], | ||
| 'command', | ||
| ); | ||
| expect(plans.filter((p) => p.showHeader)).toHaveLength(1); | ||
| }); | ||
|
|
||
| it('reports the number of rows in each section on the header row', () => { | ||
| const plans = planSlashSectionRows( | ||
| [ | ||
| { section: 'Skill commands' }, | ||
| { section: 'Skill commands' }, | ||
| { section: 'System commands' }, | ||
| ], | ||
| 'command', | ||
| ); | ||
| expect(plans[0].count).toBe(2); | ||
| expect(plans[1].count).toBe(0); | ||
| expect(plans[2].count).toBe(1); | ||
| }); | ||
|
|
||
| it('never groups subcommand menus', () => { | ||
| const plans = planSlashSectionRows( | ||
| [{ section: 'Skill commands' }, { section: 'System commands' }], | ||
| 'subcommand', | ||
| ); | ||
| expect(plans.every((p) => !p.showHeader && p.count === 0)).toBe(true); | ||
| }); | ||
|
|
||
| it('shows no headers when items carry no section (search results)', () => { | ||
| const plans = planSlashSectionRows( | ||
| [{ section: undefined }, { section: undefined }], | ||
| 'command', | ||
| ); | ||
| expect(plans.every((p) => !p.showHeader)).toBe(true); | ||
| }); | ||
| }); | ||
Uh oh!
There was an error while loading. Please reload this page.