mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-06-27 15:56:28 +00:00
Fixed an issue with settings manager initialization and the DI system
This commit is contained in:
parent
ebb99df7c5
commit
0b8b918d68
@ -151,7 +151,7 @@ public record ConfigMeta<TClass, TValue> : ConfigMetaBase
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void Reset()
|
private void Reset()
|
||||||
{
|
{
|
||||||
var configInstance = this.ConfigSelection.Compile().Invoke(SETTINGS_MANAGER.ConfigurationData);
|
var configInstance = this.ConfigSelection.Compile().Invoke(SettingsManager.ConfigurationData);
|
||||||
var memberExpression = this.PropertyExpression.GetMemberExpression();
|
var memberExpression = this.PropertyExpression.GetMemberExpression();
|
||||||
if (memberExpression.Member is System.Reflection.PropertyInfo propertyInfo)
|
if (memberExpression.Member is System.Reflection.PropertyInfo propertyInfo)
|
||||||
propertyInfo.SetValue(configInstance, this.Default);
|
propertyInfo.SetValue(configInstance, this.Default);
|
||||||
@ -163,7 +163,7 @@ public record ConfigMeta<TClass, TValue> : ConfigMetaBase
|
|||||||
/// <param name="value">The value to set for the configuration property.</param>
|
/// <param name="value">The value to set for the configuration property.</param>
|
||||||
public void SetValue(TValue value)
|
public void SetValue(TValue value)
|
||||||
{
|
{
|
||||||
var configInstance = this.ConfigSelection.Compile().Invoke(SETTINGS_MANAGER.ConfigurationData);
|
var configInstance = this.ConfigSelection.Compile().Invoke(SettingsManager.ConfigurationData);
|
||||||
var memberExpression = this.PropertyExpression.GetMemberExpression();
|
var memberExpression = this.PropertyExpression.GetMemberExpression();
|
||||||
if (memberExpression.Member is System.Reflection.PropertyInfo propertyInfo)
|
if (memberExpression.Member is System.Reflection.PropertyInfo propertyInfo)
|
||||||
propertyInfo.SetValue(configInstance, value);
|
propertyInfo.SetValue(configInstance, value);
|
||||||
@ -174,7 +174,7 @@ public record ConfigMeta<TClass, TValue> : ConfigMetaBase
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public TValue GetValue()
|
public TValue GetValue()
|
||||||
{
|
{
|
||||||
var configInstance = this.ConfigSelection.Compile().Invoke(SETTINGS_MANAGER.ConfigurationData);
|
var configInstance = this.ConfigSelection.Compile().Invoke(SettingsManager.ConfigurationData);
|
||||||
var memberExpression = this.PropertyExpression.GetMemberExpression();
|
var memberExpression = this.PropertyExpression.GetMemberExpression();
|
||||||
if (memberExpression.Member is System.Reflection.PropertyInfo propertyInfo && propertyInfo.GetValue(configInstance) is TValue value)
|
if (memberExpression.Member is System.Reflection.PropertyInfo propertyInfo && propertyInfo.GetValue(configInstance) is TValue value)
|
||||||
return value;
|
return value;
|
||||||
|
|||||||
@ -2,5 +2,5 @@ namespace AIStudio.Settings;
|
|||||||
|
|
||||||
public abstract record ConfigMetaBase : IConfig
|
public abstract record ConfigMetaBase : IConfig
|
||||||
{
|
{
|
||||||
protected static readonly SettingsManager SETTINGS_MANAGER = Program.SERVICE_PROVIDER.GetRequiredService<SettingsManager>();
|
protected static SettingsManager SettingsManager => Program.SERVICE_PROVIDER.GetRequiredService<SettingsManager>();
|
||||||
}
|
}
|
||||||
@ -654,7 +654,7 @@ public static partial class ManagedConfiguration
|
|||||||
|
|
||||||
if (successful)
|
if (successful)
|
||||||
{
|
{
|
||||||
var configInstance = configSelection.Compile().Invoke(SETTINGS_MANAGER.ConfigurationData);
|
var configInstance = configSelection.Compile().Invoke(SettingsManager.ConfigurationData);
|
||||||
var currentValue = propertyExpression.Compile().Invoke(configInstance);
|
var currentValue = propertyExpression.Compile().Invoke(configInstance);
|
||||||
var merged = new HashSet<TValue>(currentValue);
|
var merged = new HashSet<TValue>(currentValue);
|
||||||
merged.UnionWith(configuredValue);
|
merged.UnionWith(configuredValue);
|
||||||
|
|||||||
@ -9,7 +9,7 @@ namespace AIStudio.Settings;
|
|||||||
public static partial class ManagedConfiguration
|
public static partial class ManagedConfiguration
|
||||||
{
|
{
|
||||||
private static readonly ConcurrentDictionary<string, IConfig> METADATA = new();
|
private static readonly ConcurrentDictionary<string, IConfig> METADATA = new();
|
||||||
private static readonly SettingsManager SETTINGS_MANAGER = Program.SERVICE_PROVIDER.GetRequiredService<SettingsManager>();
|
private static SettingsManager SettingsManager => Program.SERVICE_PROVIDER.GetRequiredService<SettingsManager>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Attempts to retrieve the configuration metadata for a given configuration selection and
|
/// Attempts to retrieve the configuration metadata for a given configuration selection and
|
||||||
@ -418,19 +418,19 @@ public static partial class ManagedConfiguration
|
|||||||
|
|
||||||
private static bool TryGetEditableDefaultState(string settingName, out ManagedEditableDefaultState editableDefaultState)
|
private static bool TryGetEditableDefaultState(string settingName, out ManagedEditableDefaultState editableDefaultState)
|
||||||
{
|
{
|
||||||
return SETTINGS_MANAGER.ConfigurationData.ManagedEditableDefaults.TryGetValue(settingName, out editableDefaultState!);
|
return SettingsManager.ConfigurationData.ManagedEditableDefaults.TryGetValue(settingName, out editableDefaultState!);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void SetEditableDefaultState(string settingName, Guid pluginId, string lastAppliedValue)
|
private static void SetEditableDefaultState(string settingName, Guid pluginId, string lastAppliedValue)
|
||||||
{
|
{
|
||||||
SETTINGS_MANAGER.ConfigurationData.ManagedEditableDefaults[settingName] = new()
|
SettingsManager.ConfigurationData.ManagedEditableDefaults[settingName] = new()
|
||||||
{
|
{
|
||||||
ConfigPluginId = pluginId,
|
ConfigPluginId = pluginId,
|
||||||
LastAppliedValue = lastAppliedValue,
|
LastAppliedValue = lastAppliedValue,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool ClearEditableDefaultState(string settingName) => SETTINGS_MANAGER.ConfigurationData.ManagedEditableDefaults.Remove(settingName);
|
private static bool ClearEditableDefaultState(string settingName) => SettingsManager.ConfigurationData.ManagedEditableDefaults.Remove(settingName);
|
||||||
|
|
||||||
private static bool CleanupEditableDefaultState<TClass, TValue>(
|
private static bool CleanupEditableDefaultState<TClass, TValue>(
|
||||||
ConfigMeta<TClass, TValue> configMeta,
|
ConfigMeta<TClass, TValue> configMeta,
|
||||||
|
|||||||
@ -9,7 +9,7 @@ namespace AIStudio.Tools.PluginSystem;
|
|||||||
public sealed class PluginConfiguration(bool isInternal, LuaState state, PluginType type) : PluginBase(isInternal, state, type)
|
public sealed class PluginConfiguration(bool isInternal, LuaState state, PluginType type) : PluginBase(isInternal, state, type)
|
||||||
{
|
{
|
||||||
private static string TB(string fallbackEN) => I18N.I.T(fallbackEN, typeof(PluginConfiguration).Namespace, nameof(PluginConfiguration));
|
private static string TB(string fallbackEN) => I18N.I.T(fallbackEN, typeof(PluginConfiguration).Namespace, nameof(PluginConfiguration));
|
||||||
private static readonly SettingsManager SETTINGS_MANAGER = Program.SERVICE_PROVIDER.GetRequiredService<SettingsManager>();
|
private static SettingsManager SettingsManager => Program.SERVICE_PROVIDER.GetRequiredService<SettingsManager>();
|
||||||
private static readonly ILogger LOG = Program.LOGGER_FACTORY.CreateLogger(nameof(PluginConfiguration));
|
private static readonly ILogger LOG = Program.LOGGER_FACTORY.CreateLogger(nameof(PluginConfiguration));
|
||||||
|
|
||||||
private List<PluginConfigurationObject> configObjects = [];
|
private List<PluginConfigurationObject> configObjects = [];
|
||||||
@ -41,7 +41,7 @@ public sealed class PluginConfiguration(bool isInternal, LuaState state, PluginT
|
|||||||
await StoreEnterpriseApiKeysAsync();
|
await StoreEnterpriseApiKeysAsync();
|
||||||
await StoreEnterpriseSecretsAsync();
|
await StoreEnterpriseSecretsAsync();
|
||||||
|
|
||||||
await SETTINGS_MANAGER.StoreSettings();
|
await SettingsManager.StoreSettings();
|
||||||
await MessageBus.INSTANCE.SendMessage<bool>(null, Event.CONFIGURATION_CHANGED);
|
await MessageBus.INSTANCE.SendMessage<bool>(null, Event.CONFIGURATION_CHANGED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,7 +15,7 @@ namespace AIStudio.Tools.PluginSystem;
|
|||||||
public sealed record PluginConfigurationObject
|
public sealed record PluginConfigurationObject
|
||||||
{
|
{
|
||||||
private static readonly RustService RUST_SERVICE = Program.SERVICE_PROVIDER.GetRequiredService<RustService>();
|
private static readonly RustService RUST_SERVICE = Program.SERVICE_PROVIDER.GetRequiredService<RustService>();
|
||||||
private static readonly SettingsManager SETTINGS_MANAGER = Program.SERVICE_PROVIDER.GetRequiredService<SettingsManager>();
|
private static SettingsManager SettingsManager => Program.SERVICE_PROVIDER.GetRequiredService<SettingsManager>();
|
||||||
private static readonly ILogger LOG = Program.LOGGER_FACTORY.CreateLogger<PluginConfigurationObject>();
|
private static readonly ILogger LOG = Program.LOGGER_FACTORY.CreateLogger<PluginConfigurationObject>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -91,7 +91,8 @@ public sealed record PluginConfigurationObject
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var storedObjects = configObjectSelection.Compile()(SETTINGS_MANAGER.ConfigurationData);
|
var localSettingsManager = SettingsManager;
|
||||||
|
var storedObjects = configObjectSelection.Compile()(localSettingsManager.ConfigurationData);
|
||||||
var numberObjects = luaTable.ArrayLength;
|
var numberObjects = luaTable.ArrayLength;
|
||||||
ThreadSafeRandom? random = null;
|
ThreadSafeRandom? random = null;
|
||||||
for (var i = 1; i <= numberObjects; i++)
|
for (var i = 1; i <= numberObjects; i++)
|
||||||
@ -141,7 +142,7 @@ public sealed record PluginConfigurationObject
|
|||||||
// Case: The object does not exist, we have to add it
|
// Case: The object does not exist, we have to add it
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (nextConfigObjectNumSelection.TryIncrement(SETTINGS_MANAGER.ConfigurationData, IncrementType.POST) is { Success: true, UpdatedValue: var nextNum })
|
if (nextConfigObjectNumSelection.TryIncrement(localSettingsManager.ConfigurationData, IncrementType.POST) is { Success: true, UpdatedValue: var nextNum })
|
||||||
{
|
{
|
||||||
// Case: Increment the next number was successful
|
// Case: Increment the next number was successful
|
||||||
configObject = configObject with { Num = nextNum };
|
configObject = configObject with { Num = nextNum };
|
||||||
@ -185,7 +186,8 @@ public sealed record PluginConfigurationObject
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var storedObjects = SETTINGS_MANAGER.ConfigurationData.DataSources;
|
var localSettingsManager = SettingsManager;
|
||||||
|
var storedObjects = localSettingsManager.ConfigurationData.DataSources;
|
||||||
var numberObjects = luaTable.ArrayLength;
|
var numberObjects = luaTable.ArrayLength;
|
||||||
ThreadSafeRandom? random = null;
|
ThreadSafeRandom? random = null;
|
||||||
for (var i = 1; i <= numberObjects; i++)
|
for (var i = 1; i <= numberObjects; i++)
|
||||||
@ -222,7 +224,7 @@ public sealed record PluginConfigurationObject
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (IncrementDataSourceNum() is { Success: true, UpdatedValue: var nextNum })
|
if (IncrementDataSourceNum(localSettingsManager.ConfigurationData) is { Success: true, UpdatedValue: var nextNum })
|
||||||
{
|
{
|
||||||
configObject = configObject with { Num = nextNum };
|
configObject = configObject with { Num = nextNum };
|
||||||
storedObjects.Add(configObject);
|
storedObjects.Add(configObject);
|
||||||
@ -239,9 +241,9 @@ public sealed record PluginConfigurationObject
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
static IncrementResult<uint> IncrementDataSourceNum()
|
static IncrementResult<uint> IncrementDataSourceNum(Data data)
|
||||||
{
|
{
|
||||||
return ((Expression<Func<Data, uint>>)(x => x.NextDataSourceNum)).TryIncrement(SETTINGS_MANAGER.ConfigurationData, IncrementType.POST);
|
return ((Expression<Func<Data, uint>>)(x => x.NextDataSourceNum)).TryIncrement(data, IncrementType.POST);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,7 +266,8 @@ public sealed record PluginConfigurationObject
|
|||||||
SecretStoreType? secretStoreType = null,
|
SecretStoreType? secretStoreType = null,
|
||||||
bool deleteSecret = false) where TClass : IConfigurationObject
|
bool deleteSecret = false) where TClass : IConfigurationObject
|
||||||
{
|
{
|
||||||
var configuredObjects = configObjectSelection.Compile()(SETTINGS_MANAGER.ConfigurationData);
|
var localSettingsManager = SettingsManager;
|
||||||
|
var configuredObjects = configObjectSelection.Compile()(localSettingsManager.ConfigurationData);
|
||||||
var leftOverObjects = new List<TClass>();
|
var leftOverObjects = new List<TClass>();
|
||||||
foreach (var configuredObject in configuredObjects)
|
foreach (var configuredObject in configuredObjects)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -191,7 +191,7 @@ public static partial class PluginFactory
|
|||||||
wasConfigurationChanged = true;
|
wasConfigurationChanged = true;
|
||||||
|
|
||||||
// Check left-over mandatory info acceptances:
|
// Check left-over mandatory info acceptances:
|
||||||
if (SETTINGS_MANAGER.ConfigurationData.MandatoryInformation.RemoveLeftOverAcceptances(GetMandatoryInfos()))
|
if (SettingsManager.ConfigurationData.MandatoryInformation.RemoveLeftOverAcceptances(GetMandatoryInfos()))
|
||||||
wasConfigurationChanged = true;
|
wasConfigurationChanged = true;
|
||||||
|
|
||||||
// Check for a preselected provider:
|
// Check for a preselected provider:
|
||||||
@ -285,7 +285,7 @@ public static partial class PluginFactory
|
|||||||
|
|
||||||
if (wasConfigurationChanged)
|
if (wasConfigurationChanged)
|
||||||
{
|
{
|
||||||
await SETTINGS_MANAGER.StoreSettings();
|
await SettingsManager.StoreSettings();
|
||||||
await MessageBus.INSTANCE.SendMessage<bool>(null, Event.CONFIGURATION_CHANGED);
|
await MessageBus.INSTANCE.SendMessage<bool>(null, Event.CONFIGURATION_CHANGED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -64,7 +64,7 @@ public static partial class PluginFactory
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (availablePlugin.IsInternal || SETTINGS_MANAGER.IsPluginEnabled(availablePlugin) || availablePlugin.Type == PluginType.CONFIGURATION || availablePlugin.Type == PluginType.ASSISTANT)
|
if (availablePlugin.IsInternal || SettingsManager.IsPluginEnabled(availablePlugin) || availablePlugin.Type == PluginType.CONFIGURATION || availablePlugin.Type == PluginType.ASSISTANT)
|
||||||
if(await Start(availablePlugin, cancellationToken) is { IsValid: true } plugin)
|
if(await Start(availablePlugin, cancellationToken) is { IsValid: true } plugin)
|
||||||
{
|
{
|
||||||
if (plugin is PluginConfiguration configPlugin)
|
if (plugin is PluginConfiguration configPlugin)
|
||||||
|
|||||||
@ -6,7 +6,7 @@ namespace AIStudio.Tools.PluginSystem;
|
|||||||
public static partial class PluginFactory
|
public static partial class PluginFactory
|
||||||
{
|
{
|
||||||
private static readonly ILogger LOG = Program.LOGGER_FACTORY.CreateLogger(nameof(PluginFactory));
|
private static readonly ILogger LOG = Program.LOGGER_FACTORY.CreateLogger(nameof(PluginFactory));
|
||||||
private static readonly SettingsManager SETTINGS_MANAGER = Program.SERVICE_PROVIDER.GetRequiredService<SettingsManager>();
|
private static SettingsManager SettingsManager => Program.SERVICE_PROVIDER.GetRequiredService<SettingsManager>();
|
||||||
|
|
||||||
private static string DATA_DIR = string.Empty;
|
private static string DATA_DIR = string.Empty;
|
||||||
private static string PLUGINS_ROOT = string.Empty;
|
private static string PLUGINS_ROOT = string.Empty;
|
||||||
|
|||||||
@ -17,7 +17,6 @@ public sealed class TemporaryChatService(ILogger<TemporaryChatService> logger, S
|
|||||||
|
|
||||||
logger.LogInformation("The temporary chat maintenance service was initialized.");
|
logger.LogInformation("The temporary chat maintenance service was initialized.");
|
||||||
|
|
||||||
await settingsManager.LoadSettings();
|
|
||||||
if(settingsManager.ConfigurationData.Workspace.StorageTemporaryMaintenancePolicy is WorkspaceStorageTemporaryMaintenancePolicy.NO_AUTOMATIC_MAINTENANCE)
|
if(settingsManager.ConfigurationData.Workspace.StorageTemporaryMaintenancePolicy is WorkspaceStorageTemporaryMaintenancePolicy.NO_AUTOMATIC_MAINTENANCE)
|
||||||
{
|
{
|
||||||
logger.LogWarning("Automatic maintenance of temporary chat storage is disabled. Exiting maintenance service.");
|
logger.LogWarning("Automatic maintenance of temporary chat storage is disabled. Exiting maintenance service.");
|
||||||
|
|||||||
@ -10,7 +10,8 @@
|
|||||||
- Improved workspaces by allowing new workspaces to be created while moving a chat.
|
- Improved workspaces by allowing new workspaces to be created while moving a chat.
|
||||||
- Improved voice recording shortcut labels so they match the user's keyboard layout after being configured.
|
- Improved voice recording shortcut labels so they match the user's keyboard layout after being configured.
|
||||||
- Improved the enterprise configuration details on the information page by showing where each configuration comes from and which configuration slot was used.
|
- Improved the enterprise configuration details on the information page by showing where each configuration comes from and which configuration slot was used.
|
||||||
- Fixed renamed chat templates and profiles continuing to show their old names in the chat toolbar until restarting the app.
|
- Fixed an issue where newly added profiles and chat templates were not usable until the app was restarted.
|
||||||
|
- Fixed an issue where renamed chat templates and profiles continued to show their old names in the chat toolbar until the app was restarted.
|
||||||
- Fixed workspace creation and renaming to prevent new workspaces from using an existing name.
|
- Fixed workspace creation and renaming to prevent new workspaces from using an existing name.
|
||||||
- Fixed an issue on Microsoft Windows where reading attached documents could briefly open a terminal window while processing files.
|
- Fixed an issue on Microsoft Windows where reading attached documents could briefly open a terminal window while processing files.
|
||||||
- Upgraded dependencies.
|
- Upgraded dependencies.
|
||||||
Loading…
Reference in New Issue
Block a user