feat(settings): add Enable Fast toggle for Codex service tier
This commit is contained in:
@@ -121,6 +121,7 @@ interface AgentDraft {
|
||||
codexReasoningEffort: CodexReasoningEffort
|
||||
codexSupportsWebsockets: boolean
|
||||
codexSkills: boolean
|
||||
codexServiceTierFast: boolean
|
||||
claudeMainModel: string
|
||||
claudeReasoningModel: string
|
||||
claudeDefaultHaikuModel: string
|
||||
@@ -1147,6 +1148,7 @@ interface CodexTomlImportantValues {
|
||||
providerSupportsWebsockets: Record<string, boolean>
|
||||
featureResponsesWebsocketsV2: boolean
|
||||
featureSkills: boolean
|
||||
serviceTierFast: boolean
|
||||
}
|
||||
|
||||
interface CodexImportantValues {
|
||||
@@ -1158,6 +1160,7 @@ interface CodexImportantValues {
|
||||
providerOptions: string[]
|
||||
supportsWebsockets: boolean
|
||||
skills: boolean
|
||||
serviceTierFast: boolean
|
||||
}
|
||||
|
||||
const CODEX_DEFAULT_MODEL_PROVIDER = "codeg"
|
||||
@@ -1319,6 +1322,7 @@ function extractCodexTomlImportantValues(
|
||||
CODEX_DEFAULT_REASONING_EFFORT
|
||||
let featureResponsesWebsocketsV2 = false
|
||||
let featureSkills = false
|
||||
let serviceTierFast = false
|
||||
let currentProviderSection: string | null = null
|
||||
let inFeaturesSection = false
|
||||
|
||||
@@ -1364,6 +1368,14 @@ function extractCodexTomlImportantValues(
|
||||
CODEX_DEFAULT_REASONING_EFFORT
|
||||
continue
|
||||
}
|
||||
if (
|
||||
!currentProviderSection &&
|
||||
!inFeaturesSection &&
|
||||
assignment.key === "service_tier"
|
||||
) {
|
||||
serviceTierFast = assignment.value.toLowerCase() === "fast"
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
const boolAssignment = parseTomlBooleanAssignment(rawLine)
|
||||
@@ -1452,6 +1464,7 @@ function extractCodexTomlImportantValues(
|
||||
providerSupportsWebsockets,
|
||||
featureResponsesWebsocketsV2,
|
||||
featureSkills,
|
||||
serviceTierFast,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1547,6 +1560,7 @@ function extractCodexImportantValues(
|
||||
),
|
||||
supportsWebsockets: providerSupportsWebsockets,
|
||||
skills: toml.featureSkills,
|
||||
serviceTierFast: toml.serviceTierFast,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1579,7 +1593,11 @@ function preferredTomlRootInsertionIndex(lines: string[], key: string): number {
|
||||
const modelIndex = findTomlRootAssignmentIndex(lines, "model")
|
||||
return modelIndex >= 0 ? modelIndex + 1 : 0
|
||||
}
|
||||
return findTomlRootEndIndex(lines)
|
||||
let insertAt = findTomlRootEndIndex(lines)
|
||||
while (insertAt > 0 && lines[insertAt - 1].trim() === "") {
|
||||
insertAt -= 1
|
||||
}
|
||||
return insertAt
|
||||
}
|
||||
|
||||
function updateTomlRootStringKey(
|
||||
@@ -1952,6 +1970,7 @@ function patchCodexConfigTomlText(
|
||||
modelReasoningEffort?: string
|
||||
supportsWebsockets?: boolean
|
||||
skills?: boolean
|
||||
serviceTierFast?: boolean
|
||||
}
|
||||
): string {
|
||||
let nextTomlText = configTomlText
|
||||
@@ -2052,6 +2071,13 @@ function patchCodexConfigTomlText(
|
||||
patch.skills ? true : null
|
||||
)
|
||||
}
|
||||
if (typeof patch.serviceTierFast === "boolean") {
|
||||
nextTomlText = updateTomlRootStringKey(
|
||||
nextTomlText,
|
||||
"service_tier",
|
||||
patch.serviceTierFast ? "fast" : ""
|
||||
)
|
||||
}
|
||||
nextTomlText = updateTomlRootBooleanKey(
|
||||
nextTomlText,
|
||||
"disable_response_storage",
|
||||
@@ -2286,6 +2312,7 @@ function buildAgentDraft(agent: AcpAgentInfo): AgentDraft {
|
||||
codexReasoningEffort: codexImportant.reasoningEffort,
|
||||
codexSupportsWebsockets: codexImportant.supportsWebsockets,
|
||||
codexSkills: codexImportant.skills,
|
||||
codexServiceTierFast: codexImportant.serviceTierFast,
|
||||
claudeMainModel: important.claudeMainModel,
|
||||
claudeReasoningModel: important.claudeReasoningModel,
|
||||
claudeDefaultHaikuModel: important.claudeDefaultHaikuModel,
|
||||
@@ -4519,6 +4546,7 @@ export function AcpAgentSettings() {
|
||||
codexReasoningEffort: important.reasoningEffort,
|
||||
codexSupportsWebsockets: important.supportsWebsockets,
|
||||
codexSkills: important.skills,
|
||||
codexServiceTierFast: important.serviceTierFast,
|
||||
}))
|
||||
},
|
||||
[selectedAgent, selectedDraft, updateSelectedDraft]
|
||||
@@ -4542,6 +4570,7 @@ export function AcpAgentSettings() {
|
||||
codexReasoningEffort: important.reasoningEffort,
|
||||
codexSupportsWebsockets: important.supportsWebsockets,
|
||||
codexSkills: important.skills,
|
||||
codexServiceTierFast: important.serviceTierFast,
|
||||
}))
|
||||
},
|
||||
[selectedAgent, selectedDraft, updateSelectedDraft]
|
||||
@@ -4594,6 +4623,7 @@ export function AcpAgentSettings() {
|
||||
codexReasoningEffort: synced.reasoningEffort,
|
||||
codexSupportsWebsockets: synced.supportsWebsockets,
|
||||
codexSkills: synced.skills,
|
||||
codexServiceTierFast: synced.serviceTierFast,
|
||||
}))
|
||||
return
|
||||
}
|
||||
@@ -4627,6 +4657,7 @@ export function AcpAgentSettings() {
|
||||
codexReasoningEffort: synced.reasoningEffort,
|
||||
codexSupportsWebsockets: synced.supportsWebsockets,
|
||||
codexSkills: synced.skills,
|
||||
codexServiceTierFast: synced.serviceTierFast,
|
||||
}))
|
||||
},
|
||||
[selectedAgent, selectedDraft, updateSelectedDraft]
|
||||
@@ -4693,6 +4724,7 @@ export function AcpAgentSettings() {
|
||||
codexReasoningEffort: synced.reasoningEffort,
|
||||
codexSupportsWebsockets: synced.supportsWebsockets,
|
||||
codexSkills: synced.skills,
|
||||
codexServiceTierFast: synced.serviceTierFast,
|
||||
codexAuthJsonText: nextAuth.authJsonText,
|
||||
codexConfigTomlText: nextToml,
|
||||
}))
|
||||
@@ -4729,6 +4761,7 @@ export function AcpAgentSettings() {
|
||||
codexReasoningEffort: synced.reasoningEffort,
|
||||
codexSupportsWebsockets: synced.supportsWebsockets,
|
||||
codexSkills: synced.skills,
|
||||
codexServiceTierFast: synced.serviceTierFast,
|
||||
codexConfigTomlText: nextToml,
|
||||
}))
|
||||
},
|
||||
@@ -4761,6 +4794,40 @@ export function AcpAgentSettings() {
|
||||
codexReasoningEffort: synced.reasoningEffort,
|
||||
codexSupportsWebsockets: synced.supportsWebsockets,
|
||||
codexSkills: synced.skills,
|
||||
codexServiceTierFast: synced.serviceTierFast,
|
||||
codexConfigTomlText: nextToml,
|
||||
}))
|
||||
},
|
||||
[selectedAgent, selectedDraft, updateSelectedDraft]
|
||||
)
|
||||
|
||||
const handleCodexServiceTierFastChange = useCallback(
|
||||
(enabled: boolean) => {
|
||||
if (
|
||||
!selectedAgent ||
|
||||
!selectedDraft ||
|
||||
selectedAgent.agent_type !== "codex"
|
||||
)
|
||||
return
|
||||
const nextToml = patchCodexConfigTomlText(
|
||||
selectedDraft.codexConfigTomlText,
|
||||
{ serviceTierFast: enabled }
|
||||
)
|
||||
const synced = extractCodexImportantValues(
|
||||
selectedDraft.codexAuthJsonText,
|
||||
nextToml
|
||||
)
|
||||
updateSelectedDraft((current) => ({
|
||||
...current,
|
||||
apiBaseUrl: synced.apiBaseUrl,
|
||||
apiKey: synced.apiKey ?? current.apiKey,
|
||||
model: synced.model,
|
||||
codexModelProvider: synced.modelProvider,
|
||||
codexProviderOptions: synced.providerOptions,
|
||||
codexReasoningEffort: synced.reasoningEffort,
|
||||
codexSupportsWebsockets: synced.supportsWebsockets,
|
||||
codexSkills: synced.skills,
|
||||
codexServiceTierFast: synced.serviceTierFast,
|
||||
codexConfigTomlText: nextToml,
|
||||
}))
|
||||
},
|
||||
@@ -5351,6 +5418,19 @@ export function AcpAgentSettings() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="space-y-1.5">
|
||||
<div className="flex items-center justify-between rounded-md border px-3 py-2">
|
||||
<label className="text-[11px] text-muted-foreground">
|
||||
{t("codex.enableFast")}
|
||||
</label>
|
||||
<Switch
|
||||
checked={selectedDraft.codexServiceTierFast}
|
||||
onCheckedChange={handleCodexServiceTierFastChange}
|
||||
aria-label={t("codex.enableFastAria")}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="space-y-1.5">
|
||||
<label className="text-[11px] text-muted-foreground">
|
||||
{t("codex.authJsonNative")}
|
||||
|
||||
Reference in New Issue
Block a user