fix(frontend): address Codex config review feedback

This commit is contained in:
haruka
2026-07-14 18:31:06 +08:00
parent e2028a814e
commit f09d63f54e
6 changed files with 44 additions and 75 deletions
+20 -19
View File
@@ -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
}
]
}
@@ -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: '<div><slot /><slot name="footer" /></div>'
},
Icon: {
template: '<span />'
}
}
}
})
const windowsTab = wrapper.findAll('button').find(
(button) => button.text().trim() === 'Windows'
)
expect(windowsTab).toBeDefined()
await windowsTab!.trigger('click')
await nextTick()
const codeBlocks = wrapper.findAll('pre code').map((code) => code.text())
expect(codeBlocks).toContain('$env:SUB2API_API_KEY="sk-test"')
expect(wrapper.text()).not.toContain('auth.json')
expect(configToml).toContain('[features]\nresponses_websockets_v2 = true\ngoals = true')
expect(codeBlocks).toContain('{\n "OPENAI_API_KEY": "sk-test"\n}')
expect(wrapper.text()).toContain('auth.json')
})
it('renders GPT-5.4 mini entry in OpenCode config', async () => {