mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-18 05:18:00 +00:00
Fix document analysis provider selection freezes
This commit is contained in:
1 parent
6e735523c6
commit
894c509f4d
7 files changed
+80
-34
No files matched your search
@@ -104,13 +104,13 @@ else
|
||||
@T("Note: This setting only takes effect when this policy is exported and distributed via a configuration plugin to other users. When enabled, users will only see the document selection interface and cannot view or modify the policy details. This setting does NOT affect your local view - you will always see the full policy definition for policies you create.")
|
||||
</MudJustifiedText>
|
||||
|
||||
<ConfigurationMinConfidenceSelection Disabled="@(() => this.IsNoPolicySelectedOrProtected)" RestrictToGlobalMinimumConfidence="true" SelectedValue="@(() => this.policyMinimumProviderConfidence)" SelectionUpdateAsync="@(async level => await this.PolicyMinimumConfidenceWasChangedAsync(level))" />
|
||||
<ConfigurationMinConfidenceSelection Disabled="@(() => this.IsNoPolicySelectedOrProtected)" RestrictToGlobalMinimumConfidence="true" SelectedValue="@(() => this.policyMinimumProviderConfidence)" SelectionUpdate="@this.PolicyMinimumConfidenceWasChanged" />
|
||||
|
||||
<ToolSelectionField Component="@this.Component" SelectedToolIds="@this.policyAllowedToolIds" SelectedToolIdsChanged="@this.PolicyAllowedToolsWasChangedAsync" Disabled="@this.IsNoPolicySelectedOrProtected" Label="@T("Tools this policy permits")" Help="@T("Only the tools selected here can be used by the AI for an analysis with this policy. Every tool still has to meet the confidence requirements of the selected provider, so a tool may remain unavailable even when this policy permits it.")"/>
|
||||
<ToolSelectionField Component="@this.Component" SelectedToolIds="@this.policyAllowedToolIds" SelectedToolIdsChanged="@this.PolicyAllowedToolsWasChanged" Disabled="@this.IsNoPolicySelectedOrProtected" Label="@T("Tools this policy permits")" Help="@T("Only the tools selected here can be used by the AI for an analysis with this policy. Every tool still has to meet the confidence requirements of the selected provider, so a tool may remain unavailable even when this policy permits it.")"/>
|
||||
|
||||
<ConfigurationProviderSelection Component="Components.DOCUMENT_ANALYSIS_ASSISTANT" Data="@this.availableLLMProviders" Disabled="@(() => this.IsNoPolicySelectedOrProtected)" SelectedValue="@(() => this.policyPreselectedProviderId)" SelectionUpdate="@this.PolicyPreselectedProviderWasChanged" ExplicitMinimumConfidence="@this.GetPolicyMinimumConfidenceLevel()"/>
|
||||
|
||||
<ConfigurationSelect OptionDescription="@T("Preselect a profile")" Disabled="@(() => this.IsNoPolicySelected)" SelectedValue="@(() => this.policyPreselectedProfile)" Data="@ConfigurationSelectDataFactory.GetComponentProfilesData(this.SettingsManager.ConfigurationData.Profiles)" SelectionUpdateAsync="@(async selection => await this.PolicyPreselectedProfileWasChangedAsync(selection))" OptionHelp="@T("Choose whether the policy should use the app default profile, no profile, or a specific profile.")"/>
|
||||
<ConfigurationSelect OptionDescription="@T("Preselect a profile")" Disabled="@(() => this.IsNoPolicySelected)" SelectedValue="@(() => this.policyPreselectedProfile)" Data="@ConfigurationSelectDataFactory.GetComponentProfilesData(this.SettingsManager.ConfigurationData.Profiles)" SelectionUpdate="@this.PolicyPreselectedProfileWasChanged" OptionHelp="@T("Choose whether the policy should use the app default profile, no profile, or a specific profile.")"/>
|
||||
|
||||
<MudTextSwitch Disabled="@(this.IsNoPolicySelected || (this.selectedPolicy?.IsEnterpriseConfiguration ?? true))" Label="@T("Would you like to protect this policy so that you cannot accidentally edit or delete it?")" Value="@this.policyIsProtected" ValueChanged="async state => await this.PolicyProtectionWasChanged(state)" LabelOn="@T("Yes, protect this policy")" LabelOff="@T("No, the policy can be edited")" />
|
||||
|
||||
|
||||
+28
-9
@@ -180,6 +180,7 @@ public partial class DocumentAnalysisAssistant : AssistantBaseCore<NoSettingsPan
|
||||
protected override void ResetForm()
|
||||
{
|
||||
this.loadedDocumentPaths.Clear();
|
||||
this.policyNameWasEdited = false;
|
||||
if (!this.MightPreselectValues())
|
||||
{
|
||||
this.policyName = string.Empty;
|
||||
@@ -220,6 +221,7 @@ public partial class DocumentAnalysisAssistant : AssistantBaseCore<NoSettingsPan
|
||||
this.policyAllowedToolIds = [..this.selectedPolicy.AllowedToolIds];
|
||||
this.policyPreselectedProviderId = this.selectedPolicy.PreselectedProvider;
|
||||
this.policyPreselectedProfile = ProfilePreselection.FromStoredValue(this.selectedPolicy.PreselectedProfile);
|
||||
this.policyNameWasEdited = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -259,6 +261,7 @@ public partial class DocumentAnalysisAssistant : AssistantBaseCore<NoSettingsPan
|
||||
return;
|
||||
|
||||
// The preselected profile is always user-adjustable, even for protected policies and enterprise configurations:
|
||||
var hasChanges = this.selectedPolicy.PreselectedProfile != this.policyPreselectedProfile;
|
||||
this.selectedPolicy.PreselectedProfile = this.policyPreselectedProfile;
|
||||
|
||||
// Enterprise configurations cannot be modified at all:
|
||||
@@ -268,6 +271,17 @@ public partial class DocumentAnalysisAssistant : AssistantBaseCore<NoSettingsPan
|
||||
var canEditProtectedFields = force || (!this.selectedPolicy.IsProtected && !this.policyIsProtected);
|
||||
if (canEditProtectedFields)
|
||||
{
|
||||
hasChanges = hasChanges
|
||||
|| this.policyNameWasEdited
|
||||
|| this.selectedPolicy.PreselectedProvider != this.policyPreselectedProviderId
|
||||
|| this.selectedPolicy.PolicyDescription != this.policyDescription
|
||||
|| this.selectedPolicy.IsProtected != this.policyIsProtected
|
||||
|| this.selectedPolicy.HidePolicyDefinition != this.policyHidePolicyDefinition
|
||||
|| this.selectedPolicy.AnalysisRules != this.policyAnalysisRules
|
||||
|| this.selectedPolicy.OutputRules != this.policyOutputRules
|
||||
|| this.selectedPolicy.MinimumProviderConfidence != this.policyMinimumProviderConfidence
|
||||
|| !this.selectedPolicy.AllowedToolIds.SetEquals(this.policyAllowedToolIds);
|
||||
|
||||
this.selectedPolicy.PreselectedProvider = this.policyPreselectedProviderId;
|
||||
this.selectedPolicy.PolicyName = this.policyName;
|
||||
this.selectedPolicy.PolicyDescription = this.policyDescription;
|
||||
@@ -279,7 +293,11 @@ public partial class DocumentAnalysisAssistant : AssistantBaseCore<NoSettingsPan
|
||||
this.selectedPolicy.AllowedToolIds = [..this.policyAllowedToolIds];
|
||||
}
|
||||
|
||||
if (!hasChanges)
|
||||
return;
|
||||
|
||||
await this.SettingsManager.StoreSettings();
|
||||
this.policyNameWasEdited = false;
|
||||
}
|
||||
|
||||
private DataDocumentAnalysisPolicy? selectedPolicy;
|
||||
@@ -298,6 +316,7 @@ public partial class DocumentAnalysisAssistant : AssistantBaseCore<NoSettingsPan
|
||||
/// </remarks>
|
||||
private bool documentSelectionExpanded;
|
||||
private string policyName = string.Empty;
|
||||
private bool policyNameWasEdited;
|
||||
private string policyDescription = string.Empty;
|
||||
private string policyAnalysisRules = string.Empty;
|
||||
private string policyOutputRules = string.Empty;
|
||||
@@ -477,6 +496,7 @@ public partial class DocumentAnalysisAssistant : AssistantBaseCore<NoSettingsPan
|
||||
return;
|
||||
|
||||
this.selectedPolicy.PolicyName = this.policyName;
|
||||
this.policyNameWasEdited = true;
|
||||
}
|
||||
|
||||
private async Task PolicyProtectionWasChanged(bool state)
|
||||
@@ -488,7 +508,6 @@ public partial class DocumentAnalysisAssistant : AssistantBaseCore<NoSettingsPan
|
||||
return;
|
||||
|
||||
this.policyIsProtected = state;
|
||||
this.selectedPolicy.IsProtected = state;
|
||||
this.policyDefinitionExpanded = !state;
|
||||
this.documentSelectionExpanded = state;
|
||||
await this.AutoSave(true);
|
||||
@@ -503,7 +522,6 @@ public partial class DocumentAnalysisAssistant : AssistantBaseCore<NoSettingsPan
|
||||
return;
|
||||
|
||||
this.policyHidePolicyDefinition = state;
|
||||
this.selectedPolicy.HidePolicyDefinition = state;
|
||||
await this.AutoSave(true);
|
||||
}
|
||||
|
||||
@@ -580,17 +598,19 @@ public partial class DocumentAnalysisAssistant : AssistantBaseCore<NoSettingsPan
|
||||
/// <summary>
|
||||
/// Takes over the tools this policy permits.
|
||||
/// </summary>
|
||||
private async Task PolicyAllowedToolsWasChangedAsync(HashSet<string> allowedToolIds)
|
||||
private void PolicyAllowedToolsWasChanged(HashSet<string> allowedToolIds)
|
||||
{
|
||||
this.policyAllowedToolIds = allowedToolIds;
|
||||
await this.AutoSave();
|
||||
if (this.selectedPolicy is not null)
|
||||
this.selectedPolicy.AllowedToolIds = [..allowedToolIds];
|
||||
}
|
||||
|
||||
private async Task PolicyMinimumConfidenceWasChangedAsync(ConfidenceLevel level)
|
||||
private void PolicyMinimumConfidenceWasChanged(ConfidenceLevel level)
|
||||
{
|
||||
this.policyMinimumProviderConfidence = level;
|
||||
await this.AutoSave();
|
||||
|
||||
if (this.selectedPolicy is not null)
|
||||
this.selectedPolicy.MinimumProviderConfidence = level;
|
||||
|
||||
this.ApplyPolicyPreselection();
|
||||
}
|
||||
|
||||
@@ -605,14 +625,13 @@ public partial class DocumentAnalysisAssistant : AssistantBaseCore<NoSettingsPan
|
||||
this.ApplyPolicyPreselection();
|
||||
}
|
||||
|
||||
private async Task PolicyPreselectedProfileWasChangedAsync(ProfilePreselection selection)
|
||||
private void PolicyPreselectedProfileWasChanged(ProfilePreselection selection)
|
||||
{
|
||||
this.policyPreselectedProfile = selection;
|
||||
if (this.selectedPolicy is not null)
|
||||
this.selectedPolicy.PreselectedProfile = this.policyPreselectedProfile;
|
||||
|
||||
this.CurrentProfile = this.ResolveProfileSelection();
|
||||
await this.AutoSave();
|
||||
}
|
||||
|
||||
#region Overrides of MSGComponentBase
|
||||
|
||||
Reference in new issue
Block a user