diff --git a/src/commands/login/login.tsx b/src/commands/login/login.tsx index 0c85753924..b44b0c02a3 100644 --- a/src/commands/login/login.tsx +++ b/src/commands/login/login.tsx @@ -77,6 +77,8 @@ export function Login(props: { }): React.ReactNode { const mainLoopModel = useMainLoopModel(); const [showWorkspaceKeyInput, setShowWorkspaceKeyInput] = React.useState(false); + // Whether the login method selection is active + const [loginMethodSelectionActive, setLoginMethodSelectionActive] = React.useState(true); // 'idle' | 'confirm-remove' | 'removing' | { error: string } const [removeState, setRemoveState] = React.useState< { phase: 'idle' } | { phase: 'confirm-remove' } | { phase: 'removing' } | { phase: 'error'; message: string } @@ -120,7 +122,8 @@ export function Login(props: { } return; } - if (input === 'w' || input === 'W') { + // Only allow workspace key input if login method selection is active + if ((input === 'w' || input === 'W') && loginMethodSelectionActive) { setShowWorkspaceKeyInput(true); return; } @@ -171,21 +174,24 @@ export function Login(props: { ) : ( <> - - {!workspaceKeySet ? ( - Press W to enter workspace API key (saves to settings, no restart needed) - ) : workspaceKeyFromSettings ? ( - Press W to replace workspace API key · Press D to remove it - ) : ( - - Workspace API key from ANTHROPIC_API_KEY env. Press W to override with a settings-saved key. - - )} - {removeState.phase === 'error' && {removeState.message}} - + {loginMethodSelectionActive && ( + + {!workspaceKeySet ? ( + Press W to enter workspace API key (saves to settings, no restart needed) + ) : workspaceKeyFromSettings ? ( + Press W to replace workspace API key · Press D to remove it + ) : ( + + Workspace API key from ANTHROPIC_API_KEY env. Press W to override with a settings-saved key. + + )} + {removeState.phase === 'error' && {removeState.message}} + + )} props.onDone(true, mainLoopModel)} startingMessage={props.startingMessage} + onLoginMethodSelectionActiveChange={setLoginMethodSelectionActive} /> )} diff --git a/src/components/ConsoleOAuthFlow.tsx b/src/components/ConsoleOAuthFlow.tsx index 8f4219ca30..83ae04f9dd 100644 --- a/src/components/ConsoleOAuthFlow.tsx +++ b/src/components/ConsoleOAuthFlow.tsx @@ -31,6 +31,7 @@ type Props = { startingMessage?: string; mode?: 'login' | 'setup-token'; forceLoginMethod?: 'claudeai' | 'console'; + onLoginMethodSelectionActiveChange?: (active: boolean) => void; }; type OAuthStatus = @@ -89,6 +90,7 @@ export function ConsoleOAuthFlow({ startingMessage, mode = 'login', forceLoginMethod: forceLoginMethodProp, + onLoginMethodSelectionActiveChange, }: Props): React.ReactNode { const settings = getSettings_DEPRECATED() || {}; const forceLoginMethod = forceLoginMethodProp ?? settings.forceLoginMethod; @@ -144,6 +146,11 @@ export function ConsoleOAuthFlow({ } }, [oauthStatus]); + // Update login method selection active state + useEffect(() => { + onLoginMethodSelectionActiveChange?.(oauthStatus.state === 'idle'); + }, [oauthStatus.state, onLoginMethodSelectionActiveChange]); + // Handle Enter to continue on success state useKeybinding( 'confirm:yes',