diff --git a/app/MindWork AI Studio/Settings/ManagedConfiguration.Parsing.cs b/app/MindWork AI Studio/Settings/ManagedConfiguration.Parsing.cs index cbe3b968..d96fee51 100644 --- a/app/MindWork AI Studio/Settings/ManagedConfiguration.Parsing.cs +++ b/app/MindWork AI Studio/Settings/ManagedConfiguration.Parsing.cs @@ -1,3 +1,4 @@ +using System; using System.Globalization; using System.Linq.Expressions; @@ -178,6 +179,63 @@ public static partial class ManagedConfiguration return HandleParsedValue(configPluginId, dryRun, successful, configMeta, configuredValue); } + + /// + /// Attempts to process the configuration settings from a Lua table for string values. + /// + /// + /// When the configuration is successfully processed, it updates the configuration metadata with the configured value. + /// Furthermore, it locks the managed state of the configuration metadata to the provided configuration plugin ID. + /// The setting's value is set to the configured value. + /// + /// The ID of the related configuration plugin. + /// The Lua table containing the settings to process. + /// The expression to select the configuration class. + /// The expression to select the property within the configuration class. + /// When true, the method will not apply any changes, but only check if the configuration can be read. + /// The type of the configuration class. + /// True when the configuration was successfully processed, otherwise false. + public static bool TryProcessConfiguration( + Expression> configSelection, + Expression> propertyExpression, + TDataType type, + Guid configPluginId, + LuaTable settings, + bool dryRun) + { + // + // Handle configured string values + // + + // Check if that configuration was registered: + if(!TryGet(configSelection, propertyExpression, out var configMeta)) + return false; + + var successful = false; + var configuredValue = configMeta.Default; + + // Step 1 -- try to read the Lua value out of the Lua table: + if(settings.TryGetValue(SettingsManager.ToSettingName(propertyExpression), out var configuredTextValue)) + { + // Step 2 -- try to read the Lua value as a string: + if(configuredTextValue.TryRead(out var configuredText)) + { + switch (type) + { + case Guid: + successful = Guid.TryParse(configuredText, out var id); + configuredValue = successful ? id.ToString().ToLowerInvariant(): configuredText; + break; + case string: + configuredValue = configuredText; + successful = true; + break; + } + } + } + + return HandleParsedValue(configPluginId, dryRun, successful, configMeta, configuredValue); + } /// /// Attempts to process the configuration settings from a Lua table for ISpanParsable list types. diff --git a/app/MindWork AI Studio/Tools/PluginSystem/PluginConfiguration.cs b/app/MindWork AI Studio/Tools/PluginSystem/PluginConfiguration.cs index 979a626a..afa97c14 100644 --- a/app/MindWork AI Studio/Tools/PluginSystem/PluginConfiguration.cs +++ b/app/MindWork AI Studio/Tools/PluginSystem/PluginConfiguration.cs @@ -77,7 +77,7 @@ public sealed class PluginConfiguration(bool isInternal, LuaState state, PluginT PluginConfigurationObject.TryParse(PluginConfigurationObjectType.PROFILE, x => x.Profiles, x => x.NextProfileNum, mainTable, this.Id, ref this.configObjects, dryRun); // Config: preselected profile? - ManagedConfiguration.TryProcessConfiguration(x => x.App, x => x.PreselectedProfile, this.Id, settingsTable, dryRun); + ManagedConfiguration.TryProcessConfiguration(x => x.App, x => x.PreselectedProfile, Guid.Empty, this.Id, settingsTable, dryRun); message = string.Empty; return true; diff --git a/app/MindWork AI Studio/wwwroot/changelog/v0.9.55.md b/app/MindWork AI Studio/wwwroot/changelog/v0.9.55.md index 5455675f..2f221d88 100644 --- a/app/MindWork AI Studio/wwwroot/changelog/v0.9.55.md +++ b/app/MindWork AI Studio/wwwroot/changelog/v0.9.55.md @@ -1,2 +1,2 @@ # v0.9.55, build 230 (2025-12-xx xx:xx UTC) -- Fixed a bug in the comparison of GUIDs in the enterprise plugin. \ No newline at end of file +- Improved the ID handling in the enterprise plugin. \ No newline at end of file