diff --git a/app/MindWork AI Studio/Assistants/DocumentAnalysis/DocumentAnalysisAssistant.razor.cs b/app/MindWork AI Studio/Assistants/DocumentAnalysis/DocumentAnalysisAssistant.razor.cs index f2a7ad96..c87d6800 100644 --- a/app/MindWork AI Studio/Assistants/DocumentAnalysis/DocumentAnalysisAssistant.razor.cs +++ b/app/MindWork AI Studio/Assistants/DocumentAnalysis/DocumentAnalysisAssistant.razor.cs @@ -256,12 +256,12 @@ public partial class DocumentAnalysisAssistant : AssistantBaseCore @@ -333,15 +333,19 @@ public partial class DocumentAnalysisAssistant : AssistantBaseCore - /// Whether a typed policy name still waits to be written to the settings file. + /// Whether an edit already applied to a policy still waits to be written to the settings file. /// /// - /// Typing a name applies it to its policy at once, so that the policy list shows the new name - /// right away -- which leaves nothing for the auto-save to compare the form against. This flag - /// is what tells it that a store is nevertheless due. It belongs to no particular policy: the - /// name has long arrived where it belongs, only the file has not caught up yet. + /// Some handlers apply their value to the selected policy at once, because the rest of the + /// assistant reads it back from there right away: the policy list has to show a new name while + /// it is being typed, and the provider preselection is recomputed from the policy, not from the + /// form. Doing so leaves the auto-save nothing to compare the form against -- form and policy + /// already agree -- so every such handler has to announce the store itself. That is what this + /// flag is for. It belongs to no particular policy: the value has long arrived where it + /// belongs, only the file has not caught up yet, which is why a form reset or a switch to + /// another policy does not clear it. Only a completed store does. /// - private bool policyNameStorePending; + private bool policyStorePending; private string policyDescription = string.Empty; private string policyAnalysisRules = string.Empty; private string policyOutputRules = string.Empty; @@ -521,7 +525,7 @@ public partial class DocumentAnalysisAssistant : AssistantBaseCore allowedToolIds) { this.policyAllowedToolIds = allowedToolIds; - if (this.selectedPolicy is not null) - this.selectedPolicy.AllowedToolIds = [..allowedToolIds]; + if (this.selectedPolicy is null) + return; + + this.selectedPolicy.AllowedToolIds = [..allowedToolIds]; + this.policyStorePending = true; } private void PolicyMinimumConfidenceWasChanged(ConfidenceLevel level) { this.policyMinimumProviderConfidence = level; if (this.selectedPolicy is not null) + { this.selectedPolicy.MinimumProviderConfidence = level; + this.policyStorePending = true; + } this.ApplyPolicyPreselection(); } @@ -646,6 +656,7 @@ public partial class DocumentAnalysisAssistant : AssistantBaseCore