2026-04-15 09:01:31 +02:00
using AIStudio.Dialogs ;
2026-11-21 19:47:10 +01:00
using AIStudio.Tools.PluginSystem.Assistants ;
using Microsoft.AspNetCore.Components ;
2026-04-15 09:01:31 +02:00
using DialogOptions = AIStudio . Dialogs . DialogOptions ;
2026-04-09 10:01:24 +02:00
namespace AIStudio.Components.Settings ;
2026-04-15 09:01:31 +02:00
public partial class SettingsPanelAgentAssistantAudit : SettingsPanelBase
{
2026-11-21 19:47:10 +01:00
[Inject]
private AssistantPluginAuditService AssistantPluginAuditService { get ; init ; } = null !;
/// <summary>
/// Whether automatic audits are switched on, although no provider is left for them.
/// </summary>
/// <remarks>
/// Without a provider, the automatic audit skips every plugin. The least any audit requires decides here:
/// should no provider meet it, none meets what a particular plugin requires either.
/// </remarks>
private bool IsAutomaticAuditWithoutProvider => this . SettingsManager . ConfigurationData . AssistantPluginAudit . AutomaticallyAuditAssistants && ! this . AssistantPluginAuditService . PreviewProvider (). HasProvider ;
/// <summary>
/// Asks the user before they turn off the audit before activation; turning it on needs no confirmation.
/// </summary>
/// <param name="updatedState">The state the user chose.</param>
/// <returns>True when the option may take the state.</returns>
private async Task < bool > ConfirmRequireAuditBeforeActivationChange ( bool updatedState )
2026-04-15 09:01:31 +02:00
{
2026-11-21 19:47:10 +01:00
if ( updatedState )
return true ;
2026-04-15 09:01:31 +02:00
2026-11-21 19:47:10 +01:00
var dialogParameters = new DialogParameters < ConfirmDialog >
{
2026-04-15 09:01:31 +02:00
{
2026-11-21 19:47:10 +01:00
x => x . Message ,
TA ( "Disabling this setting turns off assistant plugin security audits. External assistants may then be activated and used even without a valid audit or after plugin changes. Do you really want to disable this protection?" )
},
};
2026-04-15 09:01:31 +02:00
2026-11-21 19:47:10 +01:00
var dialogReference = await this . DialogService . ShowAsync < ConfirmDialog >(
T ( "Disable Assistant Audit Protection" ),
dialogParameters ,
DialogOptions . FULLSCREEN );
var dialogResult = await dialogReference . Result ;
return dialogResult is { Canceled : false };
2026-04-15 09:01:31 +02:00
}
2026-11-21 19:47:10 +01:00
}