diff --git a/packages/cli/src/ui/auth/AuthDialog.tsx b/packages/cli/src/ui/auth/AuthDialog.tsx index 2d4794d72..17d464eed 100644 --- a/packages/cli/src/ui/auth/AuthDialog.tsx +++ b/packages/cli/src/ui/auth/AuthDialog.tsx @@ -10,7 +10,6 @@ import { AuthType } from '@qwen-code/qwen-code-core'; import { Box, Text } from 'ink'; import Link from 'ink-link'; import { theme } from '../semantic-colors.js'; -import { Colors } from '../colors.js'; import { useKeypress } from '../hooks/useKeypress.js'; import { RadioButtonSelect } from '../components/shared/RadioButtonSelect.js'; import { ApiKeyInput } from '../components/ApiKeyInput.js'; @@ -160,6 +159,8 @@ export function AuthDialog(): React.JSX.Element { if (viewLevel === 'api-key-sub') { setViewLevel('main'); + // Reset selectedIndex to ensure UI syncs with initialAuthIndex + setSelectedIndex(null); } else if (viewLevel === 'api-key-input' || viewLevel === 'custom-info') { setViewLevel('api-key-sub'); } @@ -215,7 +216,7 @@ export function AuthDialog(): React.JSX.Element { /> - + {currentSelectedAuthType === AuthType.QWEN_OAUTH ? t('Login with QwenChat account to use daily free quota.') : t('Use coding plan credentials or your own api-keys/providers.')} @@ -244,7 +245,7 @@ export function AuthDialog(): React.JSX.Element { /> - + {apiKeySubItems[apiKeySubModeIndex]?.value === 'coding-plan' ? t("Paste your api key of Bailian Coding Plan and you're all set!") : t( @@ -282,12 +283,12 @@ export function AuthDialog(): React.JSX.Element { {t('Please configure your models in settings.json:')} - + 1. {t('Set API key via environment variable (e.g., OPENAI_API_KEY)')} - + 2.{' '} {t( "Add model configuration to modelProviders['openai'] (or other auth types)", @@ -295,7 +296,7 @@ export function AuthDialog(): React.JSX.Element { - + 3.{' '} {t( 'Each provider needs: id, envKey (required), plus optional baseUrl, generationConfig', @@ -303,7 +304,7 @@ export function AuthDialog(): React.JSX.Element { - + 4.{' '} {t( 'Use /model command to select your preferred model from the configured list', @@ -324,7 +325,7 @@ export function AuthDialog(): React.JSX.Element { - + {MODEL_PROVIDERS_DOCUMENTATION_URL} @@ -369,14 +370,14 @@ export function AuthDialog(): React.JSX.Element { {(authError || errorMessage) && ( - {authError || errorMessage} + {authError || errorMessage} )} {viewLevel === 'main' && ( <> - + {t('(Use Enter to Set Auth)')} @@ -395,7 +396,7 @@ export function AuthDialog(): React.JSX.Element { - + { 'https://qwenlm.github.io/qwen-code-docs/en/users/support/tos-privacy/' } diff --git a/packages/cli/src/ui/components/ApiKeyInput.tsx b/packages/cli/src/ui/components/ApiKeyInput.tsx index f741e3fab..e4082be3a 100644 --- a/packages/cli/src/ui/components/ApiKeyInput.tsx +++ b/packages/cli/src/ui/components/ApiKeyInput.tsx @@ -8,7 +8,7 @@ import type React from 'react'; import { useState } from 'react'; import { Box, Text } from 'ink'; import { TextInput } from './shared/TextInput.js'; -import { Colors } from '../colors.js'; +import { theme } from '../semantic-colors.js'; import { useKeypress } from '../hooks/useKeypress.js'; import { t } from '../../i18n/index.js'; import Link from 'ink-link'; @@ -52,7 +52,7 @@ export function ApiKeyInput({ {error && ( - {error} + {error} )} @@ -60,13 +60,13 @@ export function ApiKeyInput({ - + {CODING_PLAN_API_KEY_URL} - + {t('(Press Enter to submit, Escape to cancel)')}