From 82a16a216817f818554f453304a5515d6f196a0a Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Fri, 14 Nov 2025 11:53:05 +0100 Subject: [PATCH] Added the possibility to set a default profile using a configuration plugin --- .../Components/Settings/SettingsPanelApp.razor | 2 +- app/MindWork AI Studio/Plugins/configuration/plugin.lua | 7 +++++++ app/MindWork AI Studio/Settings/DataModel/DataApp.cs | 2 +- .../Tools/PluginSystem/PluginConfiguration.cs | 3 +++ .../Tools/PluginSystem/PluginFactory.Loading.cs | 4 ++++ 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/app/MindWork AI Studio/Components/Settings/SettingsPanelApp.razor b/app/MindWork AI Studio/Components/Settings/SettingsPanelApp.razor index cbc6e281..58e9e828 100644 --- a/app/MindWork AI Studio/Components/Settings/SettingsPanelApp.razor +++ b/app/MindWork AI Studio/Components/Settings/SettingsPanelApp.razor @@ -28,5 +28,5 @@ } - + \ No newline at end of file diff --git a/app/MindWork AI Studio/Plugins/configuration/plugin.lua b/app/MindWork AI Studio/Plugins/configuration/plugin.lua index 61cd572c..77797c51 100644 --- a/app/MindWork AI Studio/Plugins/configuration/plugin.lua +++ b/app/MindWork AI Studio/Plugins/configuration/plugin.lua @@ -95,6 +95,13 @@ CONFIG["SETTINGS"] = {} -- Examples are PRE_WRITER_MODE_2024, PRE_RAG_2024, PRE_DOCUMENT_ANALYSIS_2025. -- CONFIG["SETTINGS"]["DataApp.EnabledPreviewFeatures"] = { "PRE_RAG_2024", "PRE_DOCUMENT_ANALYSIS_2025" } +-- Configure the preselected profile. +-- It must be one of the profile IDs defined in CONFIG["PROFILES"]. +-- Be aware that the ID must be using the same casing as defined in the profile. +-- When the ID is using upper case letters, but using lower case letters in this +-- setting, the preselection will not work. +-- CONFIG["SETTINGS"]["DataApp.PreselectedProfile"] = "00000000-0000-0000-0000-000000000000" + -- Example chat templates for this configuration: CONFIG["CHAT_TEMPLATES"] = {} diff --git a/app/MindWork AI Studio/Settings/DataModel/DataApp.cs b/app/MindWork AI Studio/Settings/DataModel/DataApp.cs index a09f8324..a6029cda 100644 --- a/app/MindWork AI Studio/Settings/DataModel/DataApp.cs +++ b/app/MindWork AI Studio/Settings/DataModel/DataApp.cs @@ -70,7 +70,7 @@ public sealed class DataApp(Expression>? configSelection = n /// /// Should we preselect a profile for the entire app? /// - public string PreselectedProfile { get; set; } = string.Empty; + public string PreselectedProfile { get; set; } = ManagedConfiguration.Register(configSelection, n => n.PreselectedProfile, string.Empty); /// /// Should we preselect a chat template for the entire app? diff --git a/app/MindWork AI Studio/Tools/PluginSystem/PluginConfiguration.cs b/app/MindWork AI Studio/Tools/PluginSystem/PluginConfiguration.cs index 05da10fe..979a626a 100644 --- a/app/MindWork AI Studio/Tools/PluginSystem/PluginConfiguration.cs +++ b/app/MindWork AI Studio/Tools/PluginSystem/PluginConfiguration.cs @@ -76,6 +76,9 @@ public sealed class PluginConfiguration(bool isInternal, LuaState state, PluginT // Handle configured profiles: 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); + message = string.Empty; return true; } diff --git a/app/MindWork AI Studio/Tools/PluginSystem/PluginFactory.Loading.cs b/app/MindWork AI Studio/Tools/PluginSystem/PluginFactory.Loading.cs index 9df176cd..8990d499 100644 --- a/app/MindWork AI Studio/Tools/PluginSystem/PluginFactory.Loading.cs +++ b/app/MindWork AI Studio/Tools/PluginSystem/PluginFactory.Loading.cs @@ -141,6 +141,10 @@ public static partial class PluginFactory if(PluginConfigurationObject.CleanLeftOverConfigurationObjects(PluginConfigurationObjectType.PROFILE, x => x.Profiles, AVAILABLE_PLUGINS, configObjectList)) wasConfigurationChanged = true; + // Check for a preselected profile: + if(ManagedConfiguration.IsConfigurationLeftOver(x => x.App, x => x.PreselectedProfile, AVAILABLE_PLUGINS)) + wasConfigurationChanged = true; + // Check for the update interval: if(ManagedConfiguration.IsConfigurationLeftOver(x => x.App, x => x.UpdateInterval, AVAILABLE_PLUGINS)) wasConfigurationChanged = true;