mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-04-30 12:40:44 +00:00
refactor(cli): simplify auth type display in Header
- Add AuthDisplayType enum and helper for Coding Plan detection - Remove formatAuthType/titleizeAuthType functions - Update tests for new auth types Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
parent
00f9c56660
commit
7e4159569e
3 changed files with 77 additions and 85 deletions
|
|
@ -5,16 +5,43 @@
|
|||
*/
|
||||
|
||||
import { Box } from 'ink';
|
||||
import { Header } from './Header.js';
|
||||
import { AuthType } from '@qwen-code/qwen-code-core';
|
||||
import { Header, AuthDisplayType } from './Header.js';
|
||||
import { Tips } from './Tips.js';
|
||||
import { useSettings } from '../contexts/SettingsContext.js';
|
||||
import { useConfig } from '../contexts/ConfigContext.js';
|
||||
import { useUIState } from '../contexts/UIStateContext.js';
|
||||
import { isCodingPlanConfig } from '../../constants/codingPlan.js';
|
||||
|
||||
interface AppHeaderProps {
|
||||
version: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine the auth display type based on auth type and configuration.
|
||||
*/
|
||||
function getAuthDisplayType(
|
||||
authType?: AuthType,
|
||||
baseUrl?: string,
|
||||
apiKeyEnvKey?: string,
|
||||
): AuthDisplayType {
|
||||
if (!authType) {
|
||||
return AuthDisplayType.UNKNOWN;
|
||||
}
|
||||
|
||||
// Check if it's a Coding Plan config
|
||||
if (isCodingPlanConfig(baseUrl, apiKeyEnvKey)) {
|
||||
return AuthDisplayType.CODING_PLAN;
|
||||
}
|
||||
|
||||
switch (authType) {
|
||||
case AuthType.QWEN_OAUTH:
|
||||
return AuthDisplayType.QWEN_OAUTH;
|
||||
default:
|
||||
return AuthDisplayType.API_KEY;
|
||||
}
|
||||
}
|
||||
|
||||
export const AppHeader = ({ version }: AppHeaderProps) => {
|
||||
const settings = useSettings();
|
||||
const config = useConfig();
|
||||
|
|
@ -27,12 +54,18 @@ export const AppHeader = ({ version }: AppHeaderProps) => {
|
|||
const showBanner = !config.getScreenReader();
|
||||
const showTips = !(settings.merged.ui?.hideTips || config.getScreenReader());
|
||||
|
||||
const authDisplayType = getAuthDisplayType(
|
||||
authType,
|
||||
contentGeneratorConfig?.baseUrl,
|
||||
contentGeneratorConfig?.apiKeyEnvKey,
|
||||
);
|
||||
|
||||
return (
|
||||
<Box flexDirection="column">
|
||||
{showBanner && (
|
||||
<Header
|
||||
version={version}
|
||||
authType={authType}
|
||||
authDisplayType={authDisplayType}
|
||||
model={model}
|
||||
workingDirectory={targetDir}
|
||||
/>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue