Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
30 changes: 17 additions & 13 deletions src/commands/login/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export function Login(props: {
}): React.ReactNode {
const mainLoopModel = useMainLoopModel();
const [showWorkspaceKeyInput, setShowWorkspaceKeyInput] = React.useState(false);
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 +121,7 @@ export function Login(props: {
}
return;
}
if (input === 'w' || input === 'W') {
if ((input === 'w' || input === 'W') && loginMethodSelectionActive) {
setShowWorkspaceKeyInput(true);
return;
}
Expand Down Expand Up @@ -171,21 +172,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
6 changes: 6 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,10 @@ export function ConsoleOAuthFlow({
}
}, [oauthStatus]);

useEffect(() => {
onLoginMethodSelectionActiveChange?.(oauthStatus.state === 'idle');
}, [oauthStatus.state, onLoginMethodSelectionActiveChange]);

// Handle Enter to continue on success state
useKeybinding(
'confirm:yes',
Expand Down
Loading