diff --git a/app/MindWork AI Studio/Settings/SettingsManager.cs b/app/MindWork AI Studio/Settings/SettingsManager.cs index e6166196..cb376479 100644 --- a/app/MindWork AI Studio/Settings/SettingsManager.cs +++ b/app/MindWork AI Studio/Settings/SettingsManager.cs @@ -1,4 +1,5 @@ using System.Diagnostics.CodeAnalysis; +using System.Linq.Expressions; using System.Text.Json; using AIStudio.Provider; @@ -347,4 +348,21 @@ public sealed class SettingsManager return ConfidenceLevel.UNKNOWN; } } + + public static string ToSettingName(Expression> propertyExpression) + { + MemberExpression? memberExpr; + + // Handle the case where the expression is a unary expression (e.g., when using Convert): + if (propertyExpression.Body is UnaryExpression { NodeType: ExpressionType.Convert } unaryExpr) + memberExpr = unaryExpr.Operand as MemberExpression; + else + memberExpr = propertyExpression.Body as MemberExpression; + + if (memberExpr is null) + throw new ArgumentException("Expression must be a property access", nameof(propertyExpression)); + + // Return the full name of the property, including the class name: + return $"{typeof(T).Name}.{memberExpr.Member.Name}"; + } } \ No newline at end of file diff --git a/app/MindWork AI Studio/Tools/PluginSystem/PluginConfiguration.cs b/app/MindWork AI Studio/Tools/PluginSystem/PluginConfiguration.cs index 5ec96eda..6355fad1 100644 --- a/app/MindWork AI Studio/Tools/PluginSystem/PluginConfiguration.cs +++ b/app/MindWork AI Studio/Tools/PluginSystem/PluginConfiguration.cs @@ -48,7 +48,7 @@ public sealed class PluginConfiguration(bool isInternal, LuaState state, PluginT return false; } - if (settingsTable.TryGetValue("DataApp.UpdateBehavior", out var updateBehaviorValue) && updateBehaviorValue.TryRead(out var updateBehaviorText) && Enum.TryParse(updateBehaviorText, true, out var updateBehavior)) + if (settingsTable.TryGetValue(SettingsManager.ToSettingName(x => x.UpdateBehavior), out var updateBehaviorValue) && updateBehaviorValue.TryRead(out var updateBehaviorText) && Enum.TryParse(updateBehaviorText, true, out var updateBehavior)) { SETTINGS_LOCKER.Register(x => x.UpdateBehavior, this.Id); SETTINGS_MANAGER.ConfigurationData.App.UpdateBehavior = updateBehavior; diff --git a/app/MindWork AI Studio/wwwroot/changelog/v0.9.49.md b/app/MindWork AI Studio/wwwroot/changelog/v0.9.49.md index b36b3ea8..49fd58ce 100644 --- a/app/MindWork AI Studio/wwwroot/changelog/v0.9.49.md +++ b/app/MindWork AI Studio/wwwroot/changelog/v0.9.49.md @@ -2,6 +2,7 @@ - Added a library by Nils Kruthoff (`nilskruthoff`) that allows AI Studio to read PowerPoint files. This feature is not yet available in the UI, but it will soon be available. Thanks, Nils, for that great contribution. - Improved the loading of some components that require data fetching, resulting in a more responsive UI. - Improved some awkward phrasings in English and German. +- Improved the implementation of configuration plugins to enhance long-term maintainability. - Changed the timestamp display to use the local datetime format for the chats and assistants. - Fixed a bug when editing data sources that caused the selected retrieval process of an ERI data source to not load correctly. - Upgraded to Rust 1.88.0.