mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-13 00:53:48 +00:00
Fixed settings keeping their plugin value after a configuration was withdrawn (#903)
Build and Release / Determine run mode (push) Has been cancelled
Build and Release / Read metadata (push) Has been cancelled
Build and Release / Sync Flatpak repo (push) Has been cancelled
Build and Release / Collect Flatpak artifacts (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg,app,updater, dmg) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis,updater, nsis) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage,updater, appimage) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg,app,updater, dmg) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis,updater, nsis) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage,updater, appimage) (push) Has been cancelled
Build and Release / Prepare & create release (push) Has been cancelled
Build and Release / Publish release (push) Has been cancelled
Build and Release / Determine run mode (push) Has been cancelled
Build and Release / Read metadata (push) Has been cancelled
Build and Release / Sync Flatpak repo (push) Has been cancelled
Build and Release / Collect Flatpak artifacts (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg,app,updater, dmg) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis,updater, nsis) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage,updater, appimage) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg,app,updater, dmg) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis,updater, nsis) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage,updater, appimage) (push) Has been cancelled
Build and Release / Prepare & create release (push) Has been cancelled
Build and Release / Publish release (push) Has been cancelled
This commit is contained in:
1 parent
a3cccb7c7d
commit
b9ec13edcf
10 files changed
+239
-11
No files matched your search
@@ -361,6 +361,19 @@ public static partial class ManagedConfiguration
|
||||
configMeta.RemovePluginContribution(contributingConfigPluginId);
|
||||
wasChanged = true;
|
||||
}
|
||||
|
||||
//
|
||||
// Finally, drop any snapshot of the user's value which nobody claims anymore. Without
|
||||
// this, a setting which stopped being managed outside of the paths above would keep its
|
||||
// snapshot in the settings file forever. The persisted editable default counts as a
|
||||
// claim as well: it survives a configuration plugin which is deployed but could not be
|
||||
// loaded, and that plugin is still in charge:
|
||||
//
|
||||
if (configMeta.ManagedMode is null && !TryGetEditableDefaultState(configMeta.SettingName, out _) && configMeta.ClearUserValueSnapshot())
|
||||
{
|
||||
Log.LogInformation($"Dropping the snapshot of the user's value for the setting '{configMeta.SettingName}': no configuration plugin manages it anymore.");
|
||||
wasChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Remove persisted states which belong to settings that do not exist anymore:
|
||||
@@ -405,6 +418,13 @@ public static partial class ManagedConfiguration
|
||||
wasChanged = true;
|
||||
}
|
||||
|
||||
foreach (var settingName in configurationData.ManagedUserValueSnapshots.Keys.Where(x => !registeredSettingNames.Contains(x)).ToList())
|
||||
{
|
||||
Log.LogInformation($"Removing the snapshot of the user's value for the setting '{settingName}': this setting does not exist anymore.");
|
||||
configurationData.ManagedUserValueSnapshots.Remove(settingName);
|
||||
wasChanged = true;
|
||||
}
|
||||
|
||||
return wasChanged;
|
||||
}
|
||||
|
||||
@@ -447,7 +467,7 @@ public static partial class ManagedConfiguration
|
||||
if (configMeta.ManagedMode is not ManagedConfigurationMode.EDITABLE_DEFAULT)
|
||||
return false;
|
||||
|
||||
configMeta.ClearEditableDefaultConfiguration();
|
||||
configMeta.ResetEditableDefaultConfiguration(keepCurrentValue: false);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -455,7 +475,17 @@ public static partial class ManagedConfiguration
|
||||
return false;
|
||||
|
||||
Log.LogInformation($"Clearing the editable default of the setting '{configMeta.SettingName}': the configuration plugin '{editableDefaultState.ConfigPluginId}' is not available anymore.");
|
||||
configMeta.ClearEditableDefaultConfiguration();
|
||||
configMeta.ResetEditableDefaultConfiguration(HasUserChangedEditableDefault(configMeta, editableDefaultState));
|
||||
return ClearEditableDefaultState(configMeta.SettingName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether the user has changed an editable default themselves.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The user may change an editable default at any time. When the current value is not the one
|
||||
/// the configuration plugin applied last, the user decided against that value, and their
|
||||
/// decision outlives the plugin.
|
||||
/// </remarks>
|
||||
private static bool HasUserChangedEditableDefault(ConfigMetaBase configMeta, ManagedEditableDefaultState editableDefaultState) => !string.Equals(configMeta.SerializeCurrentValue(), editableDefaultState.LastAppliedValue, StringComparison.Ordinal);
|
||||
}
|
||||
Reference in new issue
Block a user