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:
William Valentin
2026-02-26 09:44:59 -08:00
parent 7004a1a805
commit c34b387ffe
2 changed files with 26 additions and 0 deletions
+12
View File
@@ -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', () => {
+14
View File
@@ -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();