mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-06-27 13:16:26 +00:00
Improved settings recovery with backup-based fallbacks
This commit is contained in:
parent
b064eab9cb
commit
26172ce43a
@ -120,13 +120,13 @@ public sealed class SettingsManager
|
||||
if(settingsVersion.FailureReason is not SettingsWriteBlockReason.NONE)
|
||||
{
|
||||
this.BlockSettingsWrites(settingsVersion.FailureReason, "The settings file version could not be identified. Settings writes are blocked to avoid overwriting newer or unreadable settings.");
|
||||
return null;
|
||||
return await this.TryReadCurrentVersionBackupSnapshotForBlockedSettings();
|
||||
}
|
||||
|
||||
if(settingsVersion.Version > CURRENT_SETTINGS_VERSION)
|
||||
{
|
||||
this.BlockSettingsWrites(SettingsWriteBlockReason.VERSION_NEWER_THAN_APP, $"The settings file uses the newer version '{settingsVersion.Version}'. Settings writes are blocked to avoid overwriting newer settings.");
|
||||
return null;
|
||||
return await this.TryReadCurrentVersionBackupSnapshotForBlockedSettings();
|
||||
}
|
||||
|
||||
Data? settingsData;
|
||||
@ -154,7 +154,7 @@ public sealed class SettingsManager
|
||||
if(currentSettings.FailureReason is not SettingsWriteBlockReason.NONE)
|
||||
{
|
||||
this.BlockSettingsWrites(currentSettings.FailureReason, "The current settings file could not be safely loaded. Settings writes are blocked to avoid overwriting recoverable settings.");
|
||||
return null;
|
||||
return await this.TryReadCurrentVersionBackupSnapshotForBlockedSettings();
|
||||
}
|
||||
|
||||
settingsData = currentSettings.SettingsData!;
|
||||
@ -231,6 +231,20 @@ public sealed class SettingsManager
|
||||
return backupSettings.SettingsData;
|
||||
}
|
||||
|
||||
private async Task<Data?> TryReadCurrentVersionBackupSnapshotForBlockedSettings()
|
||||
{
|
||||
var settingsData = await this.TryReadCurrentVersionBackupSnapshot();
|
||||
if(settingsData is null)
|
||||
{
|
||||
this.logger.LogWarning($"No valid current-version settings backup was found while settings writes are blocked. Reason: '{this.SettingsWriteBlockReason}'.");
|
||||
return null;
|
||||
}
|
||||
|
||||
this.PrepareLoadedSettings(settingsData);
|
||||
this.logger.LogWarning($"Loaded settings from the '{GetBackupSettingsFilename(CURRENT_SETTINGS_VERSION)}' backup file while settings writes remain blocked. Reason: '{this.SettingsWriteBlockReason}'.");
|
||||
return settingsData;
|
||||
}
|
||||
|
||||
private async Task<CurrentSettingsReadResult> TryDeserializeCurrentSettings(string settingsPath, string sourceDescription)
|
||||
{
|
||||
try
|
||||
|
||||
@ -7,5 +7,5 @@
|
||||
- Changed provider confidence settings to appear in their own settings panel, because they apply to LLM, embedding, and transcription providers.
|
||||
- Fixed chat provider, profile, and template selections not updating live after configuration plugins were changed.
|
||||
- Fixed organization-managed chat templates not showing the correct icon in the chat template selection menu.
|
||||
- Fixed personal settings sometimes being lost after a settings-format upgrade when an older app version was started again. AI Studio now keeps versioned settings backups, restores them automatically when needed, and warns users when settings cannot be saved safely.
|
||||
- Fixed personal settings sometimes being lost after a settings-format upgrade when an older app version was started again. AI Studio now keeps versioned settings backups, restores the latest compatible backup when needed, and warns users when settings cannot be saved safely.
|
||||
- Fixed self-hosted provider API keys sometimes being stored under a localized name. AI Studio now uses a stable key name, keeps correct entries working, and automatically migrates known localized entries for LLM, transcription, and embedding providers. Organizations using configuration plugins do not need to change their plugins; affected users who still see an invalid API key warning should open the provider, transcription, or embedding settings and update the API key once. Thanks, Tim & Eric, for the detailed bug report and testing help.
|
||||
Loading…
Reference in New Issue
Block a user