mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-08-04 19:45:34 +08:00
feat(codex): add remote compaction toggle for third-party providers
Write model_providers name as "OpenAI" to let Codex attempt remote compaction through compatible endpoints. Hidden for official providers.
This commit is contained in:
@@ -12,7 +12,9 @@ import { useTranslation } from "react-i18next";
|
||||
import JsonEditor from "@/components/JsonEditor";
|
||||
import {
|
||||
isCodexGoalModeEnabled,
|
||||
isCodexRemoteCompactionEnabled,
|
||||
setCodexGoalMode,
|
||||
setCodexRemoteCompaction,
|
||||
} from "@/utils/providerConfigUtils";
|
||||
/*
|
||||
import {
|
||||
@@ -98,6 +100,8 @@ export const CodexAuthSection: React.FC<CodexAuthSectionProps> = ({
|
||||
interface CodexConfigSectionProps {
|
||||
value: string;
|
||||
onChange: (value: string) => void;
|
||||
providerName?: string;
|
||||
showRemoteCompaction?: boolean;
|
||||
useCommonConfig: boolean;
|
||||
onCommonConfigToggle: (checked: boolean) => void;
|
||||
onEditCommonConfig: () => void;
|
||||
@@ -111,6 +115,8 @@ interface CodexConfigSectionProps {
|
||||
export const CodexConfigSection: React.FC<CodexConfigSectionProps> = ({
|
||||
value,
|
||||
onChange,
|
||||
providerName,
|
||||
showRemoteCompaction = true,
|
||||
useCommonConfig,
|
||||
onCommonConfigToggle,
|
||||
onEditCommonConfig,
|
||||
@@ -157,6 +163,10 @@ export const CodexConfigSection: React.FC<CodexConfigSectionProps> = ({
|
||||
() => isCodexGoalModeEnabled(localValue),
|
||||
[localValue],
|
||||
);
|
||||
const remoteCompactionEnabled = useMemo(
|
||||
() => isCodexRemoteCompactionEnabled(localValue),
|
||||
[localValue],
|
||||
);
|
||||
|
||||
const handleGoalModeToggle = useCallback(
|
||||
(checked: boolean) => {
|
||||
@@ -165,6 +175,19 @@ export const CodexConfigSection: React.FC<CodexConfigSectionProps> = ({
|
||||
[handleLocalChange],
|
||||
);
|
||||
|
||||
const handleRemoteCompactionToggle = useCallback(
|
||||
(checked: boolean) => {
|
||||
handleLocalChange(
|
||||
setCodexRemoteCompaction(
|
||||
localValueRef.current || "",
|
||||
checked,
|
||||
providerName,
|
||||
),
|
||||
);
|
||||
},
|
||||
[handleLocalChange, providerName],
|
||||
);
|
||||
|
||||
// Codex 1M 上下文相关状态/回调暂时禁用——见同文件下方 JSX 注释处的恢复说明。
|
||||
/*
|
||||
// Parse toggle states from TOML text
|
||||
@@ -257,6 +280,21 @@ export const CodexConfigSection: React.FC<CodexConfigSectionProps> = ({
|
||||
{t("codexConfig.enableGoalMode")}
|
||||
</label>
|
||||
|
||||
{showRemoteCompaction && (
|
||||
<label
|
||||
className="inline-flex cursor-pointer items-center gap-2 text-sm text-muted-foreground"
|
||||
title={t("codexConfig.remoteCompactionHint")}
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={remoteCompactionEnabled}
|
||||
onChange={(e) => handleRemoteCompactionToggle(e.target.checked)}
|
||||
className="w-4 h-4 text-blue-500 bg-white dark:bg-gray-800 border-border-default rounded focus:ring-blue-500 dark:focus:ring-blue-400 focus:ring-2"
|
||||
/>
|
||||
{t("codexConfig.enableRemoteCompaction")}
|
||||
</label>
|
||||
)}
|
||||
|
||||
<label className="inline-flex cursor-pointer items-center gap-2 text-sm text-muted-foreground">
|
||||
<input
|
||||
type="checkbox"
|
||||
|
||||
Reference in New Issue
Block a user