forked from boos/BoosAPI
[codex] add setting to disable cross-protocol fallback (#332)
* Add toggle to disable cross-protocol fallback * Tighten runtime settings payload typing
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { api } from '../api.js';
|
||||
import { api, type RuntimeSettingsPayload } from '../api.js';
|
||||
import { useToast } from '../components/Toast.js';
|
||||
import { tr } from '../i18n.js';
|
||||
|
||||
@@ -112,7 +112,7 @@ export default function NotificationSettings() {
|
||||
const saveNotify = async () => {
|
||||
setSavingNotify(true);
|
||||
try {
|
||||
const payload: any = {
|
||||
const payload: RuntimeSettingsPayload = {
|
||||
webhookUrl: runtime.webhookUrl,
|
||||
barkUrl: runtime.barkUrl,
|
||||
webhookEnabled: runtime.webhookEnabled,
|
||||
|
||||
@@ -2,6 +2,7 @@ import React, { useDeferredValue, useEffect, useMemo, useRef, useState, useCallb
|
||||
import { useLocation, useNavigate } from 'react-router-dom';
|
||||
import {
|
||||
api,
|
||||
type RuntimeSettingsPayload,
|
||||
type ProxyDebugTraceDetail,
|
||||
type ProxyDebugTraceListItem,
|
||||
type ProxyLogBillingDetails,
|
||||
@@ -490,7 +491,7 @@ function normalizeProxyDebugSettings(value: any): ProxyDebugSettingsState {
|
||||
};
|
||||
}
|
||||
|
||||
function buildProxyDebugSettingsPayload(settings: ProxyDebugSettingsState) {
|
||||
function buildProxyDebugSettingsPayload(settings: ProxyDebugSettingsState): RuntimeSettingsPayload {
|
||||
return {
|
||||
proxyDebugTraceEnabled: settings.proxyDebugTraceEnabled,
|
||||
proxyDebugCaptureHeaders: settings.proxyDebugCaptureHeaders,
|
||||
|
||||
@@ -51,6 +51,7 @@ type RuntimeSettings = {
|
||||
logCleanupProgramLogsEnabled: boolean;
|
||||
logCleanupRetentionDays: number;
|
||||
codexUpstreamWebsocketEnabled: boolean;
|
||||
disableCrossProtocolFallback: boolean;
|
||||
proxySessionChannelConcurrencyLimit: number;
|
||||
proxySessionChannelQueueWaitMs: number;
|
||||
routingFallbackUnitCost: number;
|
||||
@@ -196,6 +197,7 @@ export default function Settings() {
|
||||
logCleanupProgramLogsEnabled: false,
|
||||
logCleanupRetentionDays: 30,
|
||||
codexUpstreamWebsocketEnabled: false,
|
||||
disableCrossProtocolFallback: false,
|
||||
proxySessionChannelConcurrencyLimit: 2,
|
||||
proxySessionChannelQueueWaitMs: 1500,
|
||||
routingFallbackUnitCost: 1,
|
||||
@@ -426,6 +428,7 @@ export default function Settings() {
|
||||
? Math.trunc(Number(runtimeInfo.logCleanupRetentionDays))
|
||||
: 30,
|
||||
codexUpstreamWebsocketEnabled: !!runtimeInfo.codexUpstreamWebsocketEnabled,
|
||||
disableCrossProtocolFallback: !!runtimeInfo.disableCrossProtocolFallback,
|
||||
proxySessionChannelConcurrencyLimit: Number(runtimeInfo.proxySessionChannelConcurrencyLimit) >= 0
|
||||
? Math.trunc(Number(runtimeInfo.proxySessionChannelConcurrencyLimit))
|
||||
: 2,
|
||||
@@ -842,6 +845,7 @@ export default function Settings() {
|
||||
await api.updateRuntimeSettings({
|
||||
routingWeights: runtime.routingWeights,
|
||||
routingFallbackUnitCost: runtime.routingFallbackUnitCost,
|
||||
disableCrossProtocolFallback: runtime.disableCrossProtocolFallback,
|
||||
});
|
||||
toast.success('Routing weights saved');
|
||||
} catch (err: any) {
|
||||
@@ -1534,6 +1538,26 @@ export default function Settings() {
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<label style={{ display: 'flex', alignItems: 'flex-start', gap: 10, marginBottom: 12, cursor: 'pointer' }}>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={runtime.disableCrossProtocolFallback}
|
||||
onChange={(e) => setRuntime((prev) => ({
|
||||
...prev,
|
||||
disableCrossProtocolFallback: e.target.checked,
|
||||
}))}
|
||||
style={{ marginTop: 2 }}
|
||||
/>
|
||||
<span>
|
||||
<span style={{ display: 'block', fontSize: 13, fontWeight: 600, color: 'var(--color-text-primary)' }}>
|
||||
失败时不尝试其他协议
|
||||
</span>
|
||||
<span style={{ display: 'block', fontSize: 12, color: 'var(--color-text-muted)', lineHeight: 1.7 }}>
|
||||
仅影响 chat / messages / responses 之间的协议切换;不会关闭同协议兼容重试、OAuth 刷新或通道级重试。
|
||||
</span>
|
||||
</span>
|
||||
</label>
|
||||
|
||||
<div className={`anim-collapse ${showAdvancedRouting ? 'is-open' : ''}`.trim()}>
|
||||
<div className="anim-collapse-inner" style={{ paddingTop: 2 }}>
|
||||
<div style={{ display: 'grid', gridTemplateColumns: isMobile ? '1fr' : '1fr 1fr', gap: 12 }}>
|
||||
|
||||
Reference in New Issue
Block a user