feat(frontend): implement comprehensive API Settings Management Interface

Implement a complete API Management Interface for React frontend with split-
panel layout, migrating all features from legacy JS frontend.

New Features:
- API Settings page with 5 tabs: Providers, Endpoints, Cache, Model Pools, CLI Settings
- Provider Management: CRUD operations, multi-key rotation, health checks, test connection
- Endpoint Management: CRUD operations, cache strategy configuration, enable/disable toggle
- Cache Settings: Global configuration, statistics display, clear cache functionality
- Model Pool Management: CRUD operations, auto-discovery feature, provider exclusion
- CLI Settings Management: Provider-based and Direct modes, full CRUD support
- Multi-Key Settings Modal: Manage API keys with rotation strategies and weights
- Manage Models Modal: View and manage models per provider (LLM and Embedding)
- Sync to CodexLens: Integration handler for provider configuration sync

Technical Implementation:
- Created 12 new React components in components/api-settings/
- Extended lib/api.ts with 460+ lines of API client functions
- Created hooks/useApiSettings.ts with 772 lines of TanStack Query hooks
- Added RadioGroup UI component for form selections
- Implemented unified error handling with useNotifications across all operations
- Complete i18n support (500+ keys in English and Chinese)
- Route integration (/api-settings) and sidebar navigation

Code Quality:
- All acceptance criteria from plan.json verified
- Code review passed with Gemini (all 7 IMPL tasks complete)
- Follows existing patterns: Shadcn UI, TanStack Query, react-intl, Lucide icons
This commit is contained in:
catlog22
2026-02-01 23:58:04 +08:00
parent 690597bae8
commit abce912ee5
33 changed files with 5874 additions and 45 deletions

View File

@@ -2828,6 +2828,30 @@ export async function bootstrapCodexLens(): Promise<CodexLensBootstrapResponse>
});
}
/**
* CodexLens semantic install response
*/
export interface CodexLensSemanticInstallResponse {
success: boolean;
message?: string;
gpuMode?: string;
available?: boolean;
backend?: string;
accelerator?: string;
providers?: string[];
error?: string;
}
/**
* Install CodexLens semantic dependencies with GPU mode
*/
export async function installCodexLensSemantic(gpuMode: 'cpu' | 'cuda' | 'directml' = 'cpu'): Promise<CodexLensSemanticInstallResponse> {
return fetchApi<CodexLensSemanticInstallResponse>('/api/codexlens/semantic/install', {
method: 'POST',
body: JSON.stringify({ gpuMode }),
});
}
/**
* Uninstall CodexLens
*/
@@ -3685,3 +3709,116 @@ export async function uninstallCcwLitellm(): Promise<{ success: boolean; message
method: 'POST',
});
}
// ========== CLI Settings Management ==========
/**
* CLI Settings (Claude CLI endpoint configuration)
* Maps to backend EndpointSettings from /api/cli/settings
*/
export interface CliSettingsEndpoint {
id: string;
name: string;
description?: string;
settings: {
env: {
ANTHROPIC_AUTH_TOKEN?: string;
ANTHROPIC_BASE_URL?: string;
DISABLE_AUTOUPDATER?: string;
[key: string]: string | undefined;
};
model?: string;
includeCoAuthoredBy?: boolean;
};
enabled: boolean;
createdAt: string;
updatedAt: string;
}
/**
* CLI Settings list response
*/
export interface CliSettingsListResponse {
endpoints: CliSettingsEndpoint[];
total: number;
}
/**
* Save CLI Settings request
*/
export interface SaveCliSettingsRequest {
id?: string;
name: string;
description?: string;
settings: {
env: {
ANTHROPIC_AUTH_TOKEN?: string;
ANTHROPIC_BASE_URL?: string;
DISABLE_AUTOUPDATER?: string;
[key: string]: string | undefined;
};
model?: string;
includeCoAuthoredBy?: boolean;
};
enabled?: boolean;
}
/**
* Fetch all CLI settings endpoints
*/
export async function fetchCliSettings(): Promise<CliSettingsListResponse> {
return fetchApi('/api/cli/settings');
}
/**
* Fetch single CLI settings endpoint
*/
export async function fetchCliSettingsEndpoint(endpointId: string): Promise<{ endpoint: CliSettingsEndpoint; filePath?: string }> {
return fetchApi(`/api/cli/settings/${encodeURIComponent(endpointId)}`);
}
/**
* Create CLI settings endpoint
*/
export async function createCliSettings(request: SaveCliSettingsRequest): Promise<{ success: boolean; endpoint?: CliSettingsEndpoint; filePath?: string; message?: string }> {
return fetchApi('/api/cli/settings', {
method: 'POST',
body: JSON.stringify(request),
});
}
/**
* Update CLI settings endpoint
*/
export async function updateCliSettings(endpointId: string, request: Partial<SaveCliSettingsRequest>): Promise<{ success: boolean; endpoint?: CliSettingsEndpoint; message?: string }> {
return fetchApi(`/api/cli/settings/${encodeURIComponent(endpointId)}`, {
method: 'PUT',
body: JSON.stringify(request),
});
}
/**
* Delete CLI settings endpoint
*/
export async function deleteCliSettings(endpointId: string): Promise<{ success: boolean; message?: string }> {
return fetchApi(`/api/cli/settings/${encodeURIComponent(endpointId)}`, {
method: 'DELETE',
});
}
/**
* Toggle CLI settings enabled status
*/
export async function toggleCliSettingsEnabled(endpointId: string, enabled: boolean): Promise<{ success: boolean; message?: string }> {
return fetchApi(`/api/cli/settings/${encodeURIComponent(endpointId)}`, {
method: 'PUT',
body: JSON.stringify({ enabled }),
});
}
/**
* Get CLI settings file path
*/
export async function getCliSettingsPath(endpointId: string): Promise<{ endpointId: string; filePath: string; enabled: boolean }> {
return fetchApi(`/api/cli/settings/${encodeURIComponent(endpointId)}/path`);
}