diff --git a/app/MindWork AI Studio/Settings/SettingsManager.cs b/app/MindWork AI Studio/Settings/SettingsManager.cs index 9f32c76d..336d4f95 100644 --- a/app/MindWork AI Studio/Settings/SettingsManager.cs +++ b/app/MindWork AI Studio/Settings/SettingsManager.cs @@ -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 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 TryDeserializeCurrentSettings(string settingsPath, string sourceDescription) { try diff --git a/app/MindWork AI Studio/wwwroot/changelog/v26.6.2.md b/app/MindWork AI Studio/wwwroot/changelog/v26.6.2.md index 6eea89f2..8e26f706 100644 --- a/app/MindWork AI Studio/wwwroot/changelog/v26.6.2.md +++ b/app/MindWork AI Studio/wwwroot/changelog/v26.6.2.md @@ -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. \ No newline at end of file