From 799ebef587ae0d2be8185193282588e956571081 Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Sun, 21 Jun 2026 15:59:02 +0200 Subject: [PATCH] Fixed chat provider, profile, & templates not updating live --- .../Components/ChatComponent.razor.cs | 37 ++++++++++++++++--- .../Components/ChatTemplateSelection.razor.cs | 22 +++++++++++ .../Components/ProfileSelection.razor.cs | 22 +++++++++++ .../Components/ProviderSelection.razor.cs | 22 +++++++++++ .../Dialogs/Settings/SettingsDialogBase.cs | 3 ++ .../wwwroot/changelog/v26.6.2.md | 1 + 6 files changed, 102 insertions(+), 5 deletions(-) diff --git a/app/MindWork AI Studio/Components/ChatComponent.razor.cs b/app/MindWork AI Studio/Components/ChatComponent.razor.cs index 07be6277..8b3c6251 100644 --- a/app/MindWork AI Studio/Components/ChatComponent.razor.cs +++ b/app/MindWork AI Studio/Components/ChatComponent.razor.cs @@ -503,6 +503,36 @@ public partial class ChatComponent : MSGComponentBase, IAsyncDisposable this.currentChatTemplate = this.SettingsManager.GetChatTemplateById(this.currentChatTemplate.Id); } + private async Task RefreshChatSelectionsAfterConfigurationChange() + { + var previousProvider = this.Provider; + var previousChatTemplate = this.currentChatTemplate; + var chatProviderId = this.ChatThread?.SelectedProvider; + + this.Provider = this.SettingsManager.GetChatProviderForLoadedChat(chatProviderId); + if (this.Provider != previousProvider) + await this.ProviderChanged.InvokeAsync(this.Provider); + + if (this.ChatThread is null) + { + this.currentProfile = this.SettingsManager.GetPreselectedProfile(Tools.Components.CHAT); + this.currentChatTemplate = this.SettingsManager.GetPreselectedChatTemplate(Tools.Components.CHAT); + } + else + { + this.currentProfile = string.IsNullOrWhiteSpace(this.ChatThread.SelectedProfile) + ? this.SettingsManager.GetProfileById(this.currentProfile.Id) + : this.SettingsManager.GetProfileById(this.ChatThread.SelectedProfile); + + this.currentChatTemplate = string.IsNullOrWhiteSpace(this.ChatThread.SelectedChatTemplate) + ? this.SettingsManager.GetChatTemplateById(this.currentChatTemplate.Id) + : this.SettingsManager.GetChatTemplateById(this.ChatThread.SelectedChatTemplate); + } + + if (!this.ComposerState.HasUserDraft && previousChatTemplate != this.currentChatTemplate) + this.ComposerState.ApplyTemplate(this.currentChatTemplate); + } + private IReadOnlyList GetAgentSelectedDataSources() { if (this.ChatThread is null) @@ -1082,11 +1112,8 @@ public partial class ChatComponent : MSGComponentBase, IAsyncDisposable break; case Event.CONFIGURATION_CHANGED: - var previousChatTemplate = this.currentChatTemplate; - this.RefreshCurrentProfileAndChatTemplate(); - if (!this.ComposerState.HasUserDraft && previousChatTemplate != this.currentChatTemplate) - this.ComposerState.ApplyTemplate(this.currentChatTemplate); - + case Event.PLUGINS_RELOADED: + await this.RefreshChatSelectionsAfterConfigurationChange(); this.StateHasChanged(); break; diff --git a/app/MindWork AI Studio/Components/ChatTemplateSelection.razor.cs b/app/MindWork AI Studio/Components/ChatTemplateSelection.razor.cs index bf3eaa99..25bbdd1c 100644 --- a/app/MindWork AI Studio/Components/ChatTemplateSelection.razor.cs +++ b/app/MindWork AI Studio/Components/ChatTemplateSelection.razor.cs @@ -32,6 +32,16 @@ public partial class ChatTemplateSelection : MSGComponentBase private string MarginClass => $"{this.MarginLeft} {this.MarginRight}"; + #region Overrides of ComponentBase + + protected override async Task OnInitializedAsync() + { + this.ApplyFilters([], [ Event.CONFIGURATION_CHANGED ]); + await base.OnInitializedAsync(); + } + + #endregion + private string ChatTemplateIcon(ChatTemplate chatTemplate) { if (chatTemplate.IsEnterpriseConfiguration) @@ -61,4 +71,16 @@ public partial class ChatTemplateSelection : MSGComponentBase }; await this.DialogService.ShowAsync(T("Open Chat Template Options"), dialogParameters, DialogOptions.FULLSCREEN); } + + #region Overrides of MSGComponentBase + + protected override Task ProcessIncomingMessage(ComponentBase? sendingComponent, Event triggeredEvent, T? data) where T : default + { + if (triggeredEvent is Event.CONFIGURATION_CHANGED or Event.PLUGINS_RELOADED) + this.StateHasChanged(); + + return Task.CompletedTask; + } + + #endregion } \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/ProfileSelection.razor.cs b/app/MindWork AI Studio/Components/ProfileSelection.razor.cs index 70747707..6c92aecc 100644 --- a/app/MindWork AI Studio/Components/ProfileSelection.razor.cs +++ b/app/MindWork AI Studio/Components/ProfileSelection.razor.cs @@ -37,6 +37,16 @@ public partial class ProfileSelection : MSGComponentBase private string ToolTipText => this.Disabled ? this.DisabledText : this.defaultToolTipText; private string MarginClass => $"{this.MarginLeft} {this.MarginRight}"; + + #region Overrides of ComponentBase + + protected override async Task OnInitializedAsync() + { + this.ApplyFilters([], [ Event.CONFIGURATION_CHANGED ]); + await base.OnInitializedAsync(); + } + + #endregion private string ProfileIcon(Profile profile) { @@ -57,4 +67,16 @@ public partial class ProfileSelection : MSGComponentBase var dialogParameters = new DialogParameters(); await this.DialogService.ShowAsync(T("Open Profile Options"), dialogParameters, DialogOptions.FULLSCREEN); } + + #region Overrides of MSGComponentBase + + protected override Task ProcessIncomingMessage(ComponentBase? sendingComponent, Event triggeredEvent, T? data) where T : default + { + if (triggeredEvent is Event.CONFIGURATION_CHANGED or Event.PLUGINS_RELOADED) + this.StateHasChanged(); + + return Task.CompletedTask; + } + + #endregion } \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/ProviderSelection.razor.cs b/app/MindWork AI Studio/Components/ProviderSelection.razor.cs index 809ed089..74bd75c9 100644 --- a/app/MindWork AI Studio/Components/ProviderSelection.razor.cs +++ b/app/MindWork AI Studio/Components/ProviderSelection.razor.cs @@ -25,6 +25,16 @@ public partial class ProviderSelection : MSGComponentBase [Inject] private ILogger Logger { get; init; } = null!; + + #region Overrides of ComponentBase + + protected override async Task OnInitializedAsync() + { + this.ApplyFilters([], [ Event.CONFIGURATION_CHANGED ]); + await base.OnInitializedAsync(); + } + + #endregion private async Task SelectionChanged(AIStudio.Settings.Provider provider) { @@ -62,4 +72,16 @@ public partial class ProviderSelection : MSGComponentBase break; } } + + #region Overrides of MSGComponentBase + + protected override Task ProcessIncomingMessage(ComponentBase? sendingComponent, Event triggeredEvent, T? data) where T : default + { + if (triggeredEvent is Event.CONFIGURATION_CHANGED or Event.PLUGINS_RELOADED) + this.StateHasChanged(); + + return Task.CompletedTask; + } + + #endregion } \ No newline at end of file diff --git a/app/MindWork AI Studio/Dialogs/Settings/SettingsDialogBase.cs b/app/MindWork AI Studio/Dialogs/Settings/SettingsDialogBase.cs index 3fc5f45e..0b235fd2 100644 --- a/app/MindWork AI Studio/Dialogs/Settings/SettingsDialogBase.cs +++ b/app/MindWork AI Studio/Dialogs/Settings/SettingsDialogBase.cs @@ -65,6 +65,9 @@ public abstract class SettingsDialogBase : MSGComponentBase switch (triggeredEvent) { case Event.CONFIGURATION_CHANGED: + case Event.PLUGINS_RELOADED: + this.UpdateProviders(); + this.UpdateEmbeddingProviders(); this.StateHasChanged(); break; } diff --git a/app/MindWork AI Studio/wwwroot/changelog/v26.6.2.md b/app/MindWork AI Studio/wwwroot/changelog/v26.6.2.md index d60f3390..8dde7dcc 100644 --- a/app/MindWork AI Studio/wwwroot/changelog/v26.6.2.md +++ b/app/MindWork AI Studio/wwwroot/changelog/v26.6.2.md @@ -5,5 +5,6 @@ - Added support for organization-managed provider confidence settings. Configuration plugins can now set confidence presets, custom confidence schemes, and an app-wide minimum confidence level. - Added support for organization-trusted providers in data source security checks. Configuration plugins can now mark specific provider instances as trusted for data source usage and local embedding warnings. - Changed provider confidence settings to appear in their own settings panel, because they apply to LLM, embedding, and transcription providers. +- Fixed chat provider, profile, and template selections not updating live after configuration plugins were changed. - Fixed organization-managed chat templates not showing the correct icon in the chat template selection menu. - Fixed self-hosted provider API keys sometimes being stored under a localized name. AI Studio now uses a stable key name, keeps correct entries working, and automatically migrates known localized entries for LLM, transcription, and embedding providers. Organizations using configuration plugins do not need to change their plugins; affected users who still see an invalid API key warning should open the provider, transcription, or embedding settings and update the API key once. \ No newline at end of file