diff --git a/src/features/authFiles/components/AuthFilesPrefixProxyEditorModal.tsx b/src/features/authFiles/components/AuthFilesPrefixProxyEditorModal.tsx index 4e7b25a..3e68254 100644 --- a/src/features/authFiles/components/AuthFilesPrefixProxyEditorModal.tsx +++ b/src/features/authFiles/components/AuthFilesPrefixProxyEditorModal.tsx @@ -126,10 +126,10 @@ export function AuthFilesPrefixProxyEditorModal(props: AuthFilesPrefixProxyEdito
onChange('websocket', value)} + onChange={(value) => onChange('websockets', value)} />
{t('ai_providers.codex_websockets_hint')}
diff --git a/src/features/authFiles/constants.ts b/src/features/authFiles/constants.ts index 8c02825..2fb30cf 100644 --- a/src/features/authFiles/constants.ts +++ b/src/features/authFiles/constants.ts @@ -160,6 +160,19 @@ export const parseDisableCoolingValue = (value: unknown): boolean | undefined => return undefined; }; +export const readCodexAuthFileWebsockets = (value: Record): boolean => + parseDisableCoolingValue(value.websockets) ?? false; + +export const applyCodexAuthFileWebsockets = ( + value: Record, + websockets: boolean +): Record => { + const next = { ...value }; + delete next.websocket; + next.websockets = websockets; + return next; +}; + export function isRuntimeOnlyAuthFile(file: AuthFileItem): boolean { const raw = file['runtime_only'] ?? file.runtimeOnly; if (typeof raw === 'boolean') return raw; diff --git a/src/features/authFiles/hooks/useAuthFilesPrefixProxyEditor.ts b/src/features/authFiles/hooks/useAuthFilesPrefixProxyEditor.ts index eee1df0..cf8a169 100644 --- a/src/features/authFiles/hooks/useAuthFilesPrefixProxyEditor.ts +++ b/src/features/authFiles/hooks/useAuthFilesPrefixProxyEditor.ts @@ -6,10 +6,12 @@ import { useNotificationStore } from '@/stores'; import { formatFileSize } from '@/utils/format'; import { MAX_AUTH_FILE_SIZE } from '@/utils/constants'; import { + applyCodexAuthFileWebsockets, normalizeExcludedModels, parseDisableCoolingValue, parseExcludedModelsText, parsePriorityValue, + readCodexAuthFileWebsockets, } from '@/features/authFiles/constants'; export type PrefixProxyEditorField = @@ -18,7 +20,7 @@ export type PrefixProxyEditorField = | 'priority' | 'excludedModelsText' | 'disableCooling' - | 'websocket' + | 'websockets' | 'note'; export type PrefixProxyEditorFieldValue = string | boolean; @@ -37,7 +39,7 @@ export type PrefixProxyEditorState = { priority: string; excludedModelsText: string; disableCooling: string; - websocket: boolean; + websockets: boolean; note: string; noteTouched: boolean; }; @@ -92,10 +94,6 @@ const buildPrefixProxyUpdatedText = (editor: PrefixProxyEditorState | null): str delete next.disable_cooling; } - if (editor.isCodexFile) { - next.websocket = editor.websocket; - } - if (editor.noteTouched) { const noteValue = editor.note.trim(); if (noteValue) { @@ -105,7 +103,9 @@ const buildPrefixProxyUpdatedText = (editor: PrefixProxyEditorState | null): str } } - return JSON.stringify(next); + return JSON.stringify( + editor.isCodexFile ? applyCodexAuthFileWebsockets(next, editor.websockets) : next + ); }; export function useAuthFilesPrefixProxyEditor( @@ -157,7 +157,7 @@ export function useAuthFilesPrefixProxyEditor( priority: '', excludedModelsText: '', disableCooling: '', - websocket: false, + websockets: false, note: '', noteTouched: false, }); @@ -199,8 +199,9 @@ export function useAuthFilesPrefixProxyEditor( const json = { ...(parsed as Record) }; if (isCodexFile) { - const websocketValue = parseDisableCoolingValue(json.websocket); - json.websocket = websocketValue ?? false; + const normalizedWebsockets = readCodexAuthFileWebsockets(json); + delete json.websocket; + json.websockets = normalizedWebsockets; } const originalText = JSON.stringify(json); const prefix = typeof json.prefix === 'string' ? json.prefix : ''; @@ -208,7 +209,7 @@ export function useAuthFilesPrefixProxyEditor( const priority = parsePriorityValue(json.priority); const excludedModels = normalizeExcludedModels(json.excluded_models); const disableCoolingValue = parseDisableCoolingValue(json.disable_cooling); - const websocketValue = parseDisableCoolingValue(json.websocket); + const websocketsValue = readCodexAuthFileWebsockets(json); const note = typeof json.note === 'string' ? json.note : ''; setPrefixProxyEditor((prev) => { @@ -225,7 +226,7 @@ export function useAuthFilesPrefixProxyEditor( excludedModelsText: excludedModels.join('\n'), disableCooling: disableCoolingValue === undefined ? '' : disableCoolingValue ? 'true' : 'false', - websocket: websocketValue ?? false, + websockets: websocketsValue, note, noteTouched: false, error: null, @@ -253,7 +254,7 @@ export function useAuthFilesPrefixProxyEditor( if (field === 'excludedModelsText') return { ...prev, excludedModelsText: String(value) }; if (field === 'disableCooling') return { ...prev, disableCooling: String(value) }; if (field === 'note') return { ...prev, note: String(value), noteTouched: true }; - return { ...prev, websocket: Boolean(value) }; + return { ...prev, websockets: Boolean(value) }; }); };