Added a way to switch off tools you never need (#1115)

This commit is contained in:
Thorsten Sommer authored and GitHub committed 2026-10-27 08:48:52 +01:00
1 parent dcba62b45c
commit 04546c25ac
31 files changed
+638 -37

No files matched your search

@@ -2,11 +2,12 @@
<ExpansionPanel HeaderIcon="@Icons.Material.Filled.Build" HeaderText="@T("Tool Settings")">
<MudText Typo="Typo.body1" Class="mb-4">
@T("Configure global settings for each tool.")
@T("Configure global settings for each tool.") @T("Switch off the tools you never need: they then appear in no tool selection, and the AI cannot use them.")
</MudText>
<MudTable Items="@this.items" Hover="@true" Dense="@true">
<HeaderContent>
<MudTh>@T("Enabled")</MudTh>
<MudTh>@T("Icon")</MudTh>
<MudTh>@T("Name")</MudTh>
<MudTh>@T("Description")</MudTh>
@@ -15,6 +16,11 @@
<MudTh>@T("Settings")</MudTh>
</HeaderContent>
<RowTemplate>
<MudTd>
<MudTooltip Text="@this.GetSwitchTooltip(context)">
<MudSwitch T="bool" Value="@context.IsActive" ValueChanged="@(isOn => this.SwitchToolOnOrOff(context, isOn))" Disabled="@IsSwitchLocked(context)" Color="Color.Primary" />
</MudTooltip>
</MudTd>
<MudTd>
<MudIcon Icon="@context.Icon" Color="Color.Info" />
</MudTd>
@@ -35,7 +41,14 @@
</MudMenu>
</MudTd>
<MudTd>
@if (!context.IsActive)
@if (IsSwitchedOffByUser(context))
{
@* Whether its settings are complete does not matter while nobody can use the tool: *@
<MudTooltip Text="@T("You switched off this tool. It appears in no tool selection, and the AI cannot use it.")">
<MudIcon Icon="@Icons.Material.Filled.VisibilityOff" Color="Color.Default" />
</MudTooltip>
}
else if (!context.IsActive)
{
<MudTooltip Text="@T("This tool has been disabled by your organization.")">
<MudIcon Icon="@Icons.Material.Filled.Lock" Color="Color.Error" />
@@ -47,6 +47,36 @@ public partial class SettingsPanelTools : SettingsPanelBase
await this.DialogService.ShowAsync<ToolSettingsExportDialog>(null, parameters, Dialogs.DialogOptions.FULLSCREEN);
}
private static bool IsSwitchedOffByUser(ToolCatalogItem item) => item.SwitchOffReason is ToolOfferBlockReason.TOOL_SWITCHED_OFF_BY_USER;
/// <summary>
/// Whether the user cannot switch this tool on or off, because their organization switched it or all tools off.
/// </summary>
private static bool IsSwitchLocked(ToolCatalogItem item) => item.SwitchOffReason is ToolOfferBlockReason.TOOLS_SWITCHED_OFF or ToolOfferBlockReason.TOOL_SWITCHED_OFF;
private string GetSwitchTooltip(ToolCatalogItem item)
{
if (IsSwitchLocked(item))
return this.T("This tool has been disabled by your organization.");
return IsSwitchedOffByUser(item)
? this.T("Switch this tool on to use it again.")
: this.T("Switch this tool off if you never need it. It then appears in no tool selection, and the AI cannot use it.");
}
private async Task SwitchToolOnOrOff(ToolCatalogItem item, bool isOn)
{
if (IsSwitchLocked(item))
return;
this.ToolRegistry.SetSwitchedOffByUser(item.Id, !isOn);
await this.SettingsManager.StoreSettings();
this.items = await this.ToolRegistry.GetCatalogAsync(this.ToolRegistry.GetAllDefinitions());
// Tool selections which are open right now load their list anew:
await this.MessageBus.SendMessage<bool>(this, Event.CONFIGURATION_CHANGED);
}
private string GetConfigurationTooltip(ToolCatalogItem item) => item.ConfigurationState.MissingRequiredFields.Count switch
{
_ when !string.IsNullOrWhiteSpace(item.ConfigurationState.Message) => item.ConfigurationState.Message,