feat(tui): add tab completions for /login mode subcommand
Implement tab completion for /login <provider> mode <value> syntax, allowing users to easily switch auth modes (api_key, oauth, auto) with keyboard navigation. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -245,6 +245,18 @@ describe('getCommandCompletions', () => {
|
|||||||
const completions = getCommandCompletions('/ru');
|
const completions = getCommandCompletions('/ru');
|
||||||
expect(completions).toContain('/runtime');
|
expect(completions).toContain('/runtime');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('completes /login <provider> mode values', () => {
|
||||||
|
const completions = getCommandCompletions('/login anthropic mode ');
|
||||||
|
expect(completions).toContain('/login anthropic mode api_key');
|
||||||
|
expect(completions).toContain('/login anthropic mode oauth');
|
||||||
|
expect(completions).toContain('/login anthropic mode auto');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('filters mode completions by partial input', () => {
|
||||||
|
const completions = getCommandCompletions('/login anthropic mode o');
|
||||||
|
expect(completions).toEqual(['/login anthropic mode oauth']);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('isToolInventoryQuery', () => {
|
describe('isToolInventoryQuery', () => {
|
||||||
|
|||||||
@@ -368,6 +368,20 @@ export function getCommandCompletions(partial: string): string[] {
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Complete /login <provider> mode <value>
|
||||||
|
if (trimmed.startsWith('/login ')) {
|
||||||
|
const rest = trimmed.slice('/login '.length).trim();
|
||||||
|
const parts = rest.split(/\s+/);
|
||||||
|
// /login <provider> mode <partial>
|
||||||
|
if (parts.length >= 2 && parts[1] === 'mode') {
|
||||||
|
const partial = (parts[2] ?? '').toLowerCase();
|
||||||
|
const modes = ['api_key', 'oauth', 'auto'];
|
||||||
|
return modes
|
||||||
|
.filter(m => m.startsWith(partial))
|
||||||
|
.map(m => `/login ${parts[0]} mode ${m}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Complete /model <tier> <provider/model>
|
// Complete /model <tier> <provider/model>
|
||||||
if (trimmed.startsWith('/model ')) {
|
if (trimmed.startsWith('/model ')) {
|
||||||
const args = trimmed.slice('/model '.length).trim();
|
const args = trimmed.slice('/model '.length).trim();
|
||||||
|
|||||||
Reference in New Issue
Block a user