Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 19 additions & 13 deletions src/commands/login/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -171,21 +174,24 @@ export function Login(props: {
</Box>
) : (
<>
<Box flexDirection="column" marginBottom={1}>
{!workspaceKeySet ? (
<Text dimColor>Press W to enter workspace API key (saves to settings, no restart needed)</Text>
) : workspaceKeyFromSettings ? (
<Text dimColor>Press W to replace workspace API key · Press D to remove it</Text>
) : (
<Text dimColor>
Workspace API key from ANTHROPIC_API_KEY env. Press W to override with a settings-saved key.
</Text>
)}
{removeState.phase === 'error' && <Text color="error">{removeState.message}</Text>}
</Box>
{loginMethodSelectionActive && (
<Box flexDirection="column" marginBottom={1}>
{!workspaceKeySet ? (
<Text dimColor>Press W to enter workspace API key (saves to settings, no restart needed)</Text>
) : workspaceKeyFromSettings ? (
<Text dimColor>Press W to replace workspace API key · Press D to remove it</Text>
) : (
<Text dimColor>
Workspace API key from ANTHROPIC_API_KEY env. Press W to override with a settings-saved key.
</Text>
)}
{removeState.phase === 'error' && <Text color="error">{removeState.message}</Text>}
</Box>
)}
<ConsoleOAuthFlow
onDone={() => props.onDone(true, mainLoopModel)}
startingMessage={props.startingMessage}
onLoginMethodSelectionActiveChange={setLoginMethodSelectionActive}
/>
</>
)}
Expand Down
7 changes: 7 additions & 0 deletions src/components/ConsoleOAuthFlow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type Props = {
startingMessage?: string;
mode?: 'login' | 'setup-token';
forceLoginMethod?: 'claudeai' | 'console';
onLoginMethodSelectionActiveChange?: (active: boolean) => void;
};

type OAuthStatus =
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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',
Expand Down