From f09d63f54eed0d724c2c3120f7c4dddbdfc779a5 Mon Sep 17 00:00:00 2001 From: haruka <1628615876@qq.com> Date: Tue, 14 Jul 2026 18:31:06 +0800 Subject: [PATCH] fix(frontend): address Codex config review feedback --- frontend/src/components/keys/UseKeyModal.vue | 39 ++++++------- .../keys/__tests__/UseKeyModal.spec.ts | 56 ++++--------------- .../src/i18n/locales/en/admin/channels.ts | 2 +- frontend/src/i18n/locales/en/dashboard.ts | 10 ++-- .../src/i18n/locales/zh/admin/channels.ts | 2 +- frontend/src/i18n/locales/zh/dashboard.ts | 10 ++-- 6 files changed, 44 insertions(+), 75 deletions(-) diff --git a/frontend/src/components/keys/UseKeyModal.vue b/frontend/src/components/keys/UseKeyModal.vue index 87983f94cc..726b01b60c 100644 --- a/frontend/src/components/keys/UseKeyModal.vue +++ b/frontend/src/components/keys/UseKeyModal.vue @@ -563,35 +563,29 @@ name = "OpenAI" base_url = "${baseUrl}" wire_api = "responses" requires_openai_auth = false -env_key = "SUB2API_API_KEY" http_headers = { "x-openai-actor-authorization" = "local-image-extension" } [features] -image_generation = true goals = true` + // auth.json content + const authContent = `{ + "OPENAI_API_KEY": "${apiKey}" +}` + return [ { path: `${configDir}/config.toml`, content: configContent, hint: t('keys.useKeyModal.openai.configTomlHint') }, - generateCodexAPIKeyEnvironment(apiKey, isWindows) + { + path: `${configDir}/auth.json`, + content: authContent + } ] } -function generateCodexAPIKeyEnvironment(apiKey: string, isWindows: boolean): FileConfig { - return isWindows - ? { - path: 'PowerShell', - content: `$env:SUB2API_API_KEY="${apiKey}"` - } - : { - path: 'Terminal', - content: `export SUB2API_API_KEY="${apiKey}"` - } -} - function generateGrokFiles(baseUrl: string, apiKey: string): FileConfig[] { const isWindows = activeTab.value === 'windows' const configDir = isWindows ? '%userprofile%\\.grok' : '~/.grok' @@ -620,7 +614,7 @@ function generateOpenAIWsFiles(baseUrl: string, apiKey: string): FileConfig[] { const isWindows = activeTab.value === 'windows' const configDir = isWindows ? '%userprofile%\\.codex' : '~/.codex' - // config.toml content with the Responses WebSocket transport enabled + // config.toml content with WebSocket v2 const configContent = `model_provider = "OpenAI" model = "gpt-5.5" review_model = "gpt-5.5" @@ -635,20 +629,27 @@ base_url = "${baseUrl}" wire_api = "responses" supports_websockets = true requires_openai_auth = false -env_key = "SUB2API_API_KEY" http_headers = { "x-openai-actor-authorization" = "local-image-extension" } [features] -image_generation = true +responses_websockets_v2 = true goals = true` + // auth.json content + const authContent = `{ + "OPENAI_API_KEY": "${apiKey}" +}` + return [ { path: `${configDir}/config.toml`, content: configContent, hint: t('keys.useKeyModal.openai.configTomlHint') }, - generateCodexAPIKeyEnvironment(apiKey, isWindows) + { + path: `${configDir}/auth.json`, + content: authContent + } ] } diff --git a/frontend/src/components/keys/__tests__/UseKeyModal.spec.ts b/frontend/src/components/keys/__tests__/UseKeyModal.spec.ts index 4e216de8da..da890f3d0e 100644 --- a/frontend/src/components/keys/__tests__/UseKeyModal.spec.ts +++ b/frontend/src/components/keys/__tests__/UseKeyModal.spec.ts @@ -78,7 +78,7 @@ describe('UseKeyModal', () => { expect(parsed.provider.grok.models['gpt-5.6']).toBeUndefined() }) - it('renders API key mode and local image generation in OpenAI Codex config', () => { + it('renders minimal image executor authorization in OpenAI Codex config', () => { const wrapper = mount(UseKeyModal, { props: { show: true, @@ -108,16 +108,17 @@ describe('UseKeyModal', () => { expect(configToml).not.toContain('model_context_window') expect(configToml).not.toContain('model_auto_compact_token_limit') expect(configToml).toContain('requires_openai_auth = false') - expect(configToml).toContain('env_key = "SUB2API_API_KEY"') expect(configToml).toContain('http_headers = { "x-openai-actor-authorization" = "local-image-extension" }') + expect(configToml).not.toContain('env_key') + expect(configToml).not.toContain('image_generation') expect(configToml).not.toContain('supports_websockets') expect(configToml).not.toContain('responses_websockets_v2') - expect(configToml).toContain('[features]\nimage_generation = true\ngoals = true') - expect(codeBlocks).toContain('export SUB2API_API_KEY="sk-test"') - expect(wrapper.text()).not.toContain('auth.json') + expect(configToml).toContain('[features]\ngoals = true') + expect(codeBlocks).toContain('{\n "OPENAI_API_KEY": "sk-test"\n}') + expect(wrapper.text()).toContain('auth.json') }) - it('renders API key mode and current WebSocket settings in OpenAI Codex config', async () => { + it('renders minimal image executor authorization in OpenAI Codex WebSocket config', async () => { const wrapper = mount(UseKeyModal, { props: { show: true, @@ -155,46 +156,13 @@ describe('UseKeyModal', () => { expect(configToml).not.toContain('model_context_window') expect(configToml).not.toContain('model_auto_compact_token_limit') expect(configToml).toContain('requires_openai_auth = false') - expect(configToml).toContain('env_key = "SUB2API_API_KEY"') expect(configToml).toContain('http_headers = { "x-openai-actor-authorization" = "local-image-extension" }') + expect(configToml).not.toContain('env_key') + expect(configToml).not.toContain('image_generation') expect(configToml).toContain('supports_websockets = true') - expect(configToml).not.toContain('responses_websockets_v2') - expect(configToml).toContain('[features]\nimage_generation = true\ngoals = true') - expect(codeBlocks).toContain('export SUB2API_API_KEY="sk-test"') - expect(wrapper.text()).not.toContain('auth.json') - }) - - it('renders a PowerShell API key command for Codex on Windows', async () => { - const wrapper = mount(UseKeyModal, { - props: { - show: true, - apiKey: 'sk-test', - baseUrl: 'https://example.com/v1', - platform: 'openai' - }, - global: { - stubs: { - BaseDialog: { - template: '