mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-08-11 17:32:11 +00:00
Added a user value snapshot when a configuration plugin takes over a setting
This commit is contained in:
parent
c4471213fa
commit
4bdf64b262
@ -159,11 +159,14 @@ public abstract record ConfigMetaBase(string SettingName) : IConfig
|
|||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// Only an unmanaged setting holds a value which belongs to the user. When one configuration
|
/// Only an unmanaged setting holds a value which belongs to the user. When one configuration
|
||||||
/// plugin takes a setting over from another, the current value belongs to the previous plugin,
|
/// plugin takes a setting over from another, the current value belongs to the previous plugin,
|
||||||
/// so the snapshot of the user's value must survive that handover untouched.
|
/// so the snapshot of the user's value must survive that handover untouched.<br/><br/>
|
||||||
|
/// The persisted editable default counts as managed as well: unlike a locked setting, it is not
|
||||||
|
/// restored into the in-memory state when the settings are loaded, so right after a start it is
|
||||||
|
/// the only evidence that a configuration plugin is already in charge.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public void CaptureUserValueSnapshot()
|
public void CaptureUserValueSnapshot()
|
||||||
{
|
{
|
||||||
if (this.ManagedMode is not null)
|
if (this.ManagedMode is not null || SettingsManagerAccess.ConfigurationData.ManagedEditableDefaults.ContainsKey(this.SettingName))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var snapshots = SettingsManagerAccess.ConfigurationData.ManagedUserValueSnapshots;
|
var snapshots = SettingsManagerAccess.ConfigurationData.ManagedUserValueSnapshots;
|
||||||
|
|||||||
@ -913,6 +913,13 @@ public static partial class ManagedConfiguration
|
|||||||
if (!MayManageSetting(configPluginId, configMeta))
|
if (!MayManageSetting(configPluginId, configMeta))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Remember the value the user had chosen before any configuration plugin took this setting
|
||||||
|
// over. Once no plugin manages it anymore, we hand that value back to the user:
|
||||||
|
//
|
||||||
|
if (successful)
|
||||||
|
configMeta.CaptureUserValueSnapshot();
|
||||||
|
|
||||||
switch (successful)
|
switch (successful)
|
||||||
{
|
{
|
||||||
case true:
|
case true:
|
||||||
@ -967,6 +974,15 @@ public static partial class ManagedConfiguration
|
|||||||
if (!MayManageSetting(configPluginId, configMeta))
|
if (!MayManageSetting(configPluginId, configMeta))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Remember the value the user had chosen before any configuration plugin took this setting
|
||||||
|
// over. Once no plugin manages it anymore, we hand that value back to the user. This has to
|
||||||
|
// happen before the managed state below changes, because only an unmanaged setting holds a
|
||||||
|
// value which belongs to the user:
|
||||||
|
//
|
||||||
|
if (successful)
|
||||||
|
configMeta.CaptureUserValueSnapshot();
|
||||||
|
|
||||||
switch (successful)
|
switch (successful)
|
||||||
{
|
{
|
||||||
case true when managedMode is ManagedConfigurationMode.LOCKED:
|
case true when managedMode is ManagedConfigurationMode.LOCKED:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user