From c34b387ffe0adb9c615c8dbf608ab0b46440baea Mon Sep 17 00:00:00 2001 From: William Valentin Date: Thu, 26 Feb 2026 09:44:59 -0800 Subject: [PATCH] feat(tui): add tab completions for /login mode subcommand Implement tab completion for /login mode syntax, allowing users to easily switch auth modes (api_key, oauth, auto) with keyboard navigation. Co-Authored-By: Claude Sonnet 4.6 --- src/frontends/tui/commands.test.ts | 12 ++++++++++++ src/frontends/tui/commands.ts | 14 ++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/frontends/tui/commands.test.ts b/src/frontends/tui/commands.test.ts index eca95e8..d2b0996 100644 --- a/src/frontends/tui/commands.test.ts +++ b/src/frontends/tui/commands.test.ts @@ -245,6 +245,18 @@ describe('getCommandCompletions', () => { const completions = getCommandCompletions('/ru'); expect(completions).toContain('/runtime'); }); + + it('completes /login 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', () => { diff --git a/src/frontends/tui/commands.ts b/src/frontends/tui/commands.ts index b675a0f..c67f0f3 100644 --- a/src/frontends/tui/commands.ts +++ b/src/frontends/tui/commands.ts @@ -368,6 +368,20 @@ export function getCommandCompletions(partial: string): string[] { return []; } + // Complete /login mode + if (trimmed.startsWith('/login ')) { + const rest = trimmed.slice('/login '.length).trim(); + const parts = rest.split(/\s+/); + // /login mode + 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 if (trimmed.startsWith('/model ')) { const args = trimmed.slice('/model '.length).trim();