Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/components/providers/EditProviderDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ export function EditProviderDialog({
}, [liveSettings, provider?.settingsConfig]); // 只依赖 settingsConfig,不依赖整个 provider

// 固定 initialData,防止 provider 对象更新时重置表单
// 注意:不依赖 provider?.meta,避免 providers refetch 时触发重新计算导致闪烁
// meta 的初始化已在 ProviderForm 中通过 useEffect 处理(line 203-225)
const initialData = useMemo(() => {
if (!provider) return null;
return {
Expand All @@ -147,14 +149,13 @@ export function EditProviderDialog({
websiteUrl: provider.websiteUrl,
settingsConfig: initialSettingsConfig,
category: provider.category,
meta: provider.meta,
meta: provider.meta, // 使用当前 meta,但不在依赖中
icon: provider.icon,
iconColor: provider.iconColor,
};
}, [
open, // 修复:编辑保存后再次打开显示旧数据,依赖 open 确保每次打开时重新读取最新 provider 数据
provider?.id, // 只依赖 ID,provider 对象更新不会触发重新计算
provider?.meta, // 需要依赖 meta 以便正确初始化 testConfig 和 proxyConfig
initialSettingsConfig,
]);

Expand Down
8 changes: 7 additions & 1 deletion src/components/providers/forms/ProviderForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -384,9 +384,15 @@ export function ProviderForm({
}
}, [appId, initialData, selectedPresetId, resetCodexConfig]);

// Only reset form when defaultValues changes in NEW mode (not edit mode)
// In edit mode, resetting on every provider data change would cause blinking
// and discard user's ongoing edits when providers refetch periodically
useEffect(() => {
if (isEditMode && initialData) {
return;
}
Comment on lines +391 to +393
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Reset form after async live settings arrive

When editing a provider, EditProviderDialog can fetch liveSettings asynchronously and updates initialData.settingsConfig afterwards, but this new guard makes ProviderForm skip form.reset(...) for all edit sessions. As a result, the form keeps the initial DB snapshot and never applies the later live config, so users may unknowingly edit/save stale JSON for the current active provider. This regression is triggered whenever live settings are loaded after the dialog first renders.

Useful? React with 👍 / 👎.

form.reset(defaultValues);
}, [defaultValues, form]);
}, [defaultValues, form, isEditMode, initialData]);

const presetCategoryLabels: Record<string, string> = useMemo(
() => ({
Expand Down
Loading