fix(common-config): reset initialization flag when preset changes

The common config checkbox was only auto-enabled for the first preset
(custom) because hasInitializedNewMode ref was permanently locked to
true after first initialization.

Add selectedPresetId parameter to all three common config hooks and
reset the initialization flag when preset changes, allowing the
initialization logic to re-run for each preset switch.
This commit is contained in:
Jason
2026-01-04 10:46:35 +08:00
parent 2c35372ca0
commit 37396b9c70
4 changed files with 24 additions and 0 deletions

View File

@@ -358,6 +358,7 @@ export function ProviderForm({
settingsConfig: form.watch("settingsConfig"),
onConfigChange: (config) => form.setValue("settingsConfig", config),
initialData: appId === "claude" ? initialData : undefined,
selectedPresetId: selectedPresetId ?? undefined,
});
// 使用 Codex 通用配置片段 hook (仅 Codex 模式)
@@ -373,6 +374,7 @@ export function ProviderForm({
codexConfig,
onConfigChange: handleCodexConfigChange,
initialData: appId === "codex" ? initialData : undefined,
selectedPresetId: selectedPresetId ?? undefined,
});
// 使用 Gemini 配置 hook (仅 Gemini 模式)
@@ -460,6 +462,7 @@ export function ProviderForm({
envStringToObj,
envObjToString,
initialData: appId === "gemini" ? initialData : undefined,
selectedPresetId: selectedPresetId ?? undefined,
});
const [isCommonConfigModalOpen, setIsCommonConfigModalOpen] = useState(false);