fix(sandbox): use deleteConfig when switching to managed mode

Delete user config instead of saving empty config when switching to
managed mode, allowing the system to fall back to system defaults.
This commit is contained in:
yyh
2026-01-19 19:51:47 +08:00
parent 9f444f1f6a
commit 5aa4088051

View File

@ -102,13 +102,10 @@ function ConfigModal({ provider, onClose }: ConfigModalProps) {
}, [provider.config_schema, provider.config, t])
const handleSave = useCallback(async () => {
// For managed mode, save empty config to use system defaults
// For managed mode, delete user config to use system defaults
if (shouldShowModeSelection && configMode === 'managed') {
try {
await saveConfig({
providerType: provider.provider_type,
config: {},
})
await deleteConfig(provider.provider_type)
notify({ type: 'success', message: t('api.saved', { ns: 'common' }) })
onClose()
}
@ -137,7 +134,7 @@ function ConfigModal({ provider, onClose }: ConfigModalProps) {
catch {
// Error toast is handled by fetch layer
}
}, [shouldShowModeSelection, configMode, saveConfig, provider.provider_type, notify, t, onClose])
}, [shouldShowModeSelection, configMode, saveConfig, deleteConfig, provider.provider_type, notify, t, onClose])
const handleRevoke = useCallback(async () => {
try {