From 64e543f463fb957fa5d61033924af93dd7ed22e7 Mon Sep 17 00:00:00 2001 From: camy-x <209573702+camy-x@users.noreply.github.com> Date: Mon, 28 Sep 2026 18:52:28 +0800 Subject: [PATCH 01/16] fix(config): read client API keys from CPA v8 layout --- .../config/ConfigPage.persistence.test.tsx | 124 ++++++++++++++--- apps/web/src/hooks/useVisualConfig.test.ts | 126 ++++++++++++++++++ apps/web/src/hooks/useVisualConfig.ts | 14 +- 3 files changed, 247 insertions(+), 17 deletions(-) diff --git a/apps/web/src/features/config/ConfigPage.persistence.test.tsx b/apps/web/src/features/config/ConfigPage.persistence.test.tsx index 54963c756..92e6f2e19 100644 --- a/apps/web/src/features/config/ConfigPage.persistence.test.tsx +++ b/apps/web/src/features/config/ConfigPage.persistence.test.tsx @@ -3,6 +3,8 @@ import type { ReactNode } from 'react'; import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; import type { ApiKeyMutation } from '@/components/config/ApiKeysCardEditor'; import type { ManagerConfigResponse } from '@/services/api/usageService'; +import type { VisualConfigValues } from '@/types/visualConfig'; +import { parse as parseYaml, stringify as stringifyYaml } from 'yaml'; vi.mock('react-dom', () => ({ createPortal: (children: ReactNode) => children, @@ -32,6 +34,7 @@ const mocks = vi.hoisted(() => ({ capturedApiKeyOperationStart: null as (() => void) | null, capturedApiKeyOperationEnd: null as (() => void) | null, translate: (key: string) => key, + useRealVisualConfig: false, visualState: { apiKeysText: 'sk-old', dirty: false, @@ -54,10 +57,14 @@ vi.mock('@/hooks/useMediaQuery', () => ({ vi.mock('@/components/config/VisualConfigEditor', () => ({ VisualConfigEditor: ({ + values, + onChange, onPersistApiKeyMutation, onApiKeyOperationStart, onApiKeyOperationEnd, }: { + values: VisualConfigValues; + onChange: (values: Partial) => void; onPersistApiKeyMutation: (mutation: ApiKeyMutation) => Promise; onApiKeyOperationStart: () => void; onApiKeyOperationEnd: () => void; @@ -78,6 +85,8 @@ vi.mock('@/components/config/VisualConfigEditor', () => ({ return (
+ {values.apiKeysText} +