mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-20 02:17:05 +00:00
refactor(cliproxy): resolve remaining review parity and cleanup nits
- export buildProviderMap from provider capabilities and reuse in auth-types - add provider descriptions to backend capabilities and sync display names - remove ui CLIPROXY_PORT alias and use CLIPROXY_DEFAULT_PORT directly - return stable string from getProviderDescription - extend backend/ui parity tests for display name and description values
This commit is contained in:
1 parent
39593c161b
commit
7e527af777
7 files changed
+53
-26
No files matched your search
@@ -16,7 +16,7 @@ import {
|
||||
useCreatePreset,
|
||||
useDeletePreset,
|
||||
} from '@/hooks/use-cliproxy';
|
||||
import { CLIPROXY_PORT } from '@/lib/preset-utils';
|
||||
import { CLIPROXY_DEFAULT_PORT } from '@/lib/preset-utils';
|
||||
import { usePrivacy } from '@/contexts/privacy-context';
|
||||
import { useProviderEditor } from './use-provider-editor';
|
||||
import { CustomPresetDialog } from './custom-preset-dialog';
|
||||
@@ -117,7 +117,7 @@ export function ProviderEditor({
|
||||
const effectiveApiKey = authTokens?.apiKey?.value ?? 'ccs-internal-managed';
|
||||
|
||||
const handleApplyPreset = (updates: Record<string, string>) => {
|
||||
const effectivePort = port ?? CLIPROXY_PORT;
|
||||
const effectivePort = port ?? CLIPROXY_DEFAULT_PORT;
|
||||
updateEnvValues({
|
||||
ANTHROPIC_BASE_URL: `http://127.0.0.1:${effectivePort}/api/provider/${provider}`,
|
||||
ANTHROPIC_AUTH_TOKEN: effectiveApiKey,
|
||||
@@ -127,7 +127,7 @@ export function ProviderEditor({
|
||||
};
|
||||
|
||||
const handleCustomPresetApply = (values: ModelMappingValues, presetName?: string) => {
|
||||
const effectivePort = port ?? CLIPROXY_PORT;
|
||||
const effectivePort = port ?? CLIPROXY_DEFAULT_PORT;
|
||||
updateEnvValues({
|
||||
ANTHROPIC_BASE_URL: `http://127.0.0.1:${effectivePort}/api/provider/${provider}`,
|
||||
ANTHROPIC_AUTH_TOKEN: effectiveApiKey,
|
||||
|
||||
@@ -27,7 +27,7 @@ const WIZARD_PROVIDER_ORDER: CLIProxyProvider[] = [
|
||||
export const PROVIDERS: ProviderOption[] = WIZARD_PROVIDER_ORDER.map((id) => ({
|
||||
id,
|
||||
name: getProviderDisplayName(id),
|
||||
description: getProviderDescription(id) || '',
|
||||
description: getProviderDescription(id),
|
||||
}));
|
||||
|
||||
export const ALL_STEPS = ['provider', 'auth', 'variant', 'success'];
|
||||
|
||||
@@ -7,9 +7,6 @@ import { MODEL_CATALOGS } from './model-catalogs';
|
||||
import { CLIPROXY_DEFAULT_PORT } from './default-ports';
|
||||
export { CLIPROXY_DEFAULT_PORT } from './default-ports';
|
||||
|
||||
/** CLIProxy port - should match the backend configuration */
|
||||
export const CLIPROXY_PORT = CLIPROXY_DEFAULT_PORT;
|
||||
|
||||
/** Default fallback API key if fetch fails */
|
||||
const DEFAULT_API_KEY = 'ccs-internal-managed';
|
||||
|
||||
@@ -33,7 +30,7 @@ async function fetchEffectiveApiKey(): Promise<string> {
|
||||
* Uses the first model's presetMapping or falls back to using defaultModel for all tiers
|
||||
*
|
||||
* @param provider - The provider ID (e.g., 'gemini', 'codex', 'agy')
|
||||
* @param port - Optional custom port (defaults to CLIPROXY_PORT)
|
||||
* @param port - Optional custom port (defaults to CLIPROXY_DEFAULT_PORT)
|
||||
* @returns Object with success status and applied preset name
|
||||
*/
|
||||
export async function applyDefaultPreset(
|
||||
|
||||
@@ -115,9 +115,9 @@ export function getProviderDisplayName(provider: string): string {
|
||||
}
|
||||
|
||||
/** Map provider to user-facing short description */
|
||||
export function getProviderDescription(provider: string): string | undefined {
|
||||
export function getProviderDescription(provider: string): string {
|
||||
const normalized = provider.toLowerCase();
|
||||
if (!isValidProvider(normalized)) return undefined;
|
||||
if (!isValidProvider(normalized)) return '';
|
||||
return PROVIDER_METADATA[normalized].description;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user