mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-04-14 13:01:37 +00:00
Added an option for mandatory terms of use dialogs (#725)
Some checks failed
Build and Release / Determine run mode (push) Has been cancelled
Build and Release / Read metadata (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg,updater, dmg) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis,updater, nsis) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage,deb,updater, appimage,deb) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg,updater, dmg) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis,updater, nsis) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage,deb,updater, appimage,deb) (push) Has been cancelled
Build and Release / Prepare & create release (push) Has been cancelled
Build and Release / Publish release (push) Has been cancelled
Some checks failed
Build and Release / Determine run mode (push) Has been cancelled
Build and Release / Read metadata (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg,updater, dmg) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis,updater, nsis) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage,deb,updater, appimage,deb) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg,updater, dmg) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis,updater, nsis) (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage,deb,updater, appimage,deb) (push) Has been cancelled
Build and Release / Prepare & create release (push) Has been cancelled
Build and Release / Publish release (push) Has been cancelled
This commit is contained in:
parent
09258c7548
commit
8b11e2317b
@ -2098,6 +2098,27 @@ UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::MANAGEPANDOCDEPENDENCY::T527187983"] = "C
|
||||
-- Install Pandoc
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::MANAGEPANDOCDEPENDENCY::T986578435"] = "Install Pandoc"
|
||||
|
||||
-- Version
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::MANDATORYINFODISPLAY::T1573770551"] = "Version"
|
||||
|
||||
-- A new version of the terms is available. Please review it again.
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::MANDATORYINFODISPLAY::T1711766303"] = "A new version of the terms is available. Please review it again."
|
||||
|
||||
-- This mandatory info has not been accepted yet.
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::MANDATORYINFODISPLAY::T1870532312"] = "This mandatory info has not been accepted yet."
|
||||
|
||||
-- Accepted version
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::MANDATORYINFODISPLAY::T203086476"] = "Accepted version"
|
||||
|
||||
-- Last accepted version
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::MANDATORYINFODISPLAY::T3407978086"] = "Last accepted version"
|
||||
|
||||
-- Accepted at (UTC)
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::MANDATORYINFODISPLAY::T3511160492"] = "Accepted at (UTC)"
|
||||
|
||||
-- Please review this text again. The content was changed.
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::MANDATORYINFODISPLAY::T941885055"] = "Please review this text again. The content was changed."
|
||||
|
||||
-- Given that my employer's workplace uses both Windows and Linux, I wanted a cross-platform solution that would work seamlessly across all major operating systems, including macOS. Additionally, I wanted to demonstrate that it is possible to create modern, efficient, cross-platform applications without resorting to Electron bloatware. The combination of .NET and Rust with Tauri proved to be an excellent technology stack for building such robust applications.
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::MOTIVATION::T1057189794"] = "Given that my employer's workplace uses both Windows and Linux, I wanted a cross-platform solution that would work seamlessly across all major operating systems, including macOS. Additionally, I wanted to demonstrate that it is possible to create modern, efficient, cross-platform applications without resorting to Electron bloatware. The combination of .NET and Rust with Tauri proved to be an excellent technology stack for building such robust applications."
|
||||
|
||||
@ -5695,6 +5716,9 @@ UI_TEXT_CONTENT["AISTUDIO::PAGES::INFORMATION::T1137744461"] = "ID mismatch: the
|
||||
-- This is a private AI Studio installation. It runs without an enterprise configuration.
|
||||
UI_TEXT_CONTENT["AISTUDIO::PAGES::INFORMATION::T1209549230"] = "This is a private AI Studio installation. It runs without an enterprise configuration."
|
||||
|
||||
-- Unknown configuration plugin
|
||||
UI_TEXT_CONTENT["AISTUDIO::PAGES::INFORMATION::T1290340974"] = "Unknown configuration plugin"
|
||||
|
||||
-- This library is used to read PDF files. This is necessary, e.g., for using PDFs as a data source for a chat.
|
||||
UI_TEXT_CONTENT["AISTUDIO::PAGES::INFORMATION::T1388816916"] = "This library is used to read PDF files. This is necessary, e.g., for using PDFs as a data source for a chat."
|
||||
|
||||
@ -5725,6 +5749,9 @@ UI_TEXT_CONTENT["AISTUDIO::PAGES::INFORMATION::T1629800076"] = "Building on .NET
|
||||
-- AI Studio creates a log file at startup, in which events during startup are recorded. After startup, another log file is created that records all events that occur during the use of the app. This includes any errors that may occur. Depending on when an error occurs (at startup or during use), the contents of these log files can be helpful for troubleshooting. Sensitive information such as passwords is not included in the log files.
|
||||
UI_TEXT_CONTENT["AISTUDIO::PAGES::INFORMATION::T1630237140"] = "AI Studio creates a log file at startup, in which events during startup are recorded. After startup, another log file is created that records all events that occur during the use of the app. This includes any errors that may occur. Depending on when an error occurs (at startup or during use), the contents of these log files can be helpful for troubleshooting. Sensitive information such as passwords is not included in the log files."
|
||||
|
||||
-- Consent:
|
||||
UI_TEXT_CONTENT["AISTUDIO::PAGES::INFORMATION::T171952677"] = "Consent:"
|
||||
|
||||
-- This library is used to display the differences between two texts. This is necessary, e.g., for the grammar and spelling assistant.
|
||||
UI_TEXT_CONTENT["AISTUDIO::PAGES::INFORMATION::T1772678682"] = "This library is used to display the differences between two texts. This is necessary, e.g., for the grammar and spelling assistant."
|
||||
|
||||
@ -5944,6 +5971,9 @@ UI_TEXT_CONTENT["AISTUDIO::PAGES::INFORMATION::T788846912"] = "Copies the config
|
||||
-- installed by AI Studio
|
||||
UI_TEXT_CONTENT["AISTUDIO::PAGES::INFORMATION::T833849470"] = "installed by AI Studio"
|
||||
|
||||
-- Provided by configuration plugin: {0}
|
||||
UI_TEXT_CONTENT["AISTUDIO::PAGES::INFORMATION::T836298648"] = "Provided by configuration plugin: {0}"
|
||||
|
||||
-- We use this library to be able to read PowerPoint files. This allows us to insert content from slides into prompts and take PowerPoint files into account in RAG processes. We thank Nils Kruthoff for his work on this Rust crate.
|
||||
UI_TEXT_CONTENT["AISTUDIO::PAGES::INFORMATION::T855925638"] = "We use this library to be able to read PowerPoint files. This allows us to insert content from slides into prompts and take PowerPoint files into account in RAG processes. We thank Nils Kruthoff for his work on this Rust crate."
|
||||
|
||||
|
||||
47
app/MindWork AI Studio/Components/MandatoryInfoDisplay.razor
Normal file
47
app/MindWork AI Studio/Components/MandatoryInfoDisplay.razor
Normal file
@ -0,0 +1,47 @@
|
||||
@inherits MSGComponentBase
|
||||
|
||||
<MudStack Spacing="2">
|
||||
<MudText Typo="Typo.body2">
|
||||
@T("Version"): @this.Info.VersionText
|
||||
</MudText>
|
||||
|
||||
@if (this.ShowAcceptanceMetadata)
|
||||
{
|
||||
@if (this.AcceptanceStatus is MandatoryInfoAcceptanceStatus.MISSING)
|
||||
{
|
||||
<MudAlert Severity="Severity.Warning" Variant="Variant.Outlined" Dense="@true">
|
||||
@T("This mandatory info has not been accepted yet.")
|
||||
</MudAlert>
|
||||
}
|
||||
else if (this.AcceptanceStatus is MandatoryInfoAcceptanceStatus.VERSION_CHANGED)
|
||||
{
|
||||
<MudAlert Severity="Severity.Warning" Variant="Variant.Outlined" Dense="@true">
|
||||
@T("A new version of the terms is available. Please review it again.")
|
||||
<br />
|
||||
@T("Last accepted version"): @this.Acceptance!.AcceptedVersion
|
||||
<br />
|
||||
@T("Accepted at (UTC)"): @this.Acceptance.AcceptedAtUtc.UtcDateTime.ToString("u")
|
||||
</MudAlert>
|
||||
}
|
||||
else if (this.AcceptanceStatus is MandatoryInfoAcceptanceStatus.CONTENT_CHANGED)
|
||||
{
|
||||
<MudAlert Severity="Severity.Warning" Variant="Variant.Outlined" Dense="@true">
|
||||
@T("Please review this text again. The content was changed.")
|
||||
<br />
|
||||
@T("Last accepted version"): @this.Acceptance!.AcceptedVersion
|
||||
<br />
|
||||
@T("Accepted at (UTC)"): @this.Acceptance.AcceptedAtUtc.UtcDateTime.ToString("u")
|
||||
</MudAlert>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudAlert Severity="Severity.Success" Variant="Variant.Outlined" Dense="@true">
|
||||
@T("Accepted version"): @this.Acceptance!.AcceptedVersion
|
||||
<br />
|
||||
@T("Accepted at (UTC)"): @this.Acceptance.AcceptedAtUtc.UtcDateTime.ToString("u")
|
||||
</MudAlert>
|
||||
}
|
||||
}
|
||||
|
||||
<MudJustifiedMarkdown Value="@this.Info.Markdown" />
|
||||
</MudStack>
|
||||
@ -0,0 +1,42 @@
|
||||
using AIStudio.Settings.DataModel;
|
||||
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace AIStudio.Components;
|
||||
|
||||
public partial class MandatoryInfoDisplay
|
||||
{
|
||||
private enum MandatoryInfoAcceptanceStatus
|
||||
{
|
||||
MISSING,
|
||||
VERSION_CHANGED,
|
||||
CONTENT_CHANGED,
|
||||
ACCEPTED,
|
||||
}
|
||||
|
||||
[Parameter]
|
||||
public DataMandatoryInfo Info { get; set; } = new();
|
||||
|
||||
[Parameter]
|
||||
public DataMandatoryInfoAcceptance? Acceptance { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public bool ShowAcceptanceMetadata { get; set; }
|
||||
|
||||
private MandatoryInfoAcceptanceStatus AcceptanceStatus
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.Acceptance is null)
|
||||
return MandatoryInfoAcceptanceStatus.MISSING;
|
||||
|
||||
if (!string.Equals(this.Acceptance.AcceptedVersion, this.Info.VersionText, StringComparison.Ordinal))
|
||||
return MandatoryInfoAcceptanceStatus.VERSION_CHANGED;
|
||||
|
||||
if (!string.Equals(this.Acceptance.AcceptedHash, this.Info.AcceptanceHash, StringComparison.Ordinal))
|
||||
return MandatoryInfoAcceptanceStatus.CONTENT_CHANGED;
|
||||
|
||||
return MandatoryInfoAcceptanceStatus.ACCEPTED;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
<div class="justified-markdown">
|
||||
<MudMarkdown Value="@this.Value" Props="Markdown.DefaultConfig" MarkdownPipeline="Markdown.SAFE_MARKDOWN_PIPELINE" />
|
||||
</div>
|
||||
@ -0,0 +1,9 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace AIStudio.Components;
|
||||
|
||||
public partial class MudJustifiedMarkdown
|
||||
{
|
||||
[Parameter]
|
||||
public string Value { get; set; } = string.Empty;
|
||||
}
|
||||
@ -14,4 +14,11 @@ public static class DialogOptions
|
||||
CloseOnEscapeKey = true,
|
||||
FullWidth = true, MaxWidth = MaxWidth.Medium,
|
||||
};
|
||||
|
||||
public static readonly MudBlazor.DialogOptions BLOCKING_FULLSCREEN = new()
|
||||
{
|
||||
BackdropClick = false,
|
||||
CloseOnEscapeKey = false,
|
||||
FullWidth = true, MaxWidth = MaxWidth.Medium,
|
||||
};
|
||||
}
|
||||
25
app/MindWork AI Studio/Dialogs/MandatoryInfoDialog.razor
Normal file
25
app/MindWork AI Studio/Dialogs/MandatoryInfoDialog.razor
Normal file
@ -0,0 +1,25 @@
|
||||
@inherits MSGComponentBase
|
||||
|
||||
<MudDialog>
|
||||
<DialogContent>
|
||||
<div class="pt-6" style="max-height: calc(100vh - 11rem); overflow-y: auto; overflow-x: hidden; padding-right: 0.5rem;">
|
||||
<MandatoryInfoDisplay Info="@this.Info" Acceptance="@this.Acceptance" ShowAcceptanceMetadata="@true" />
|
||||
</div>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudStack Row="true" Justify="Justify.SpaceBetween" Class="pa-4" Style="width: 100%;">
|
||||
<MudButton OnClick="@this.Reject"
|
||||
Variant="Variant.Filled"
|
||||
Color="Color.Error"
|
||||
Size="Size.Large">
|
||||
@this.Info.RejectButtonText
|
||||
</MudButton>
|
||||
<MudButton OnClick="@this.Accept"
|
||||
Variant="Variant.Filled"
|
||||
Color="Color.Success"
|
||||
Size="Size.Large">
|
||||
@this.Info.AcceptButtonText
|
||||
</MudButton>
|
||||
</MudStack>
|
||||
</DialogActions>
|
||||
</MudDialog>
|
||||
22
app/MindWork AI Studio/Dialogs/MandatoryInfoDialog.razor.cs
Normal file
22
app/MindWork AI Studio/Dialogs/MandatoryInfoDialog.razor.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using AIStudio.Components;
|
||||
using AIStudio.Settings.DataModel;
|
||||
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace AIStudio.Dialogs;
|
||||
|
||||
public partial class MandatoryInfoDialog : MSGComponentBase
|
||||
{
|
||||
[CascadingParameter]
|
||||
private IMudDialogInstance MudDialog { get; set; } = null!;
|
||||
|
||||
[Parameter]
|
||||
public DataMandatoryInfo Info { get; set; } = new();
|
||||
|
||||
[Parameter]
|
||||
public DataMandatoryInfoAcceptance? Acceptance { get; set; }
|
||||
|
||||
private void Accept() => this.MudDialog.Close(DialogResult.Ok(true));
|
||||
|
||||
private void Reject() => this.MudDialog.Close(DialogResult.Ok(false));
|
||||
}
|
||||
@ -53,6 +53,8 @@ public partial class MainLayout : LayoutComponentBase, IMessageBusReceiver, ILan
|
||||
private UpdateResponse? currentUpdateResponse;
|
||||
private MudThemeProvider themeProvider = null!;
|
||||
private bool useDarkMode;
|
||||
private bool startupCompleted;
|
||||
private readonly SemaphoreSlim mandatoryInfoDialogSemaphore = new(1, 1);
|
||||
|
||||
private IReadOnlyCollection<NavBarItem> navItems = [];
|
||||
|
||||
@ -91,8 +93,8 @@ public partial class MainLayout : LayoutComponentBase, IMessageBusReceiver, ILan
|
||||
this.MessageBus.ApplyFilters(this, [],
|
||||
[
|
||||
Event.UPDATE_AVAILABLE, Event.CONFIGURATION_CHANGED, Event.COLOR_THEME_CHANGED, Event.SHOW_ERROR,
|
||||
Event.SHOW_ERROR, Event.SHOW_WARNING, Event.SHOW_SUCCESS, Event.STARTUP_PLUGIN_SYSTEM,
|
||||
Event.PLUGINS_RELOADED, Event.INSTALL_UPDATE,
|
||||
Event.SHOW_WARNING, Event.SHOW_SUCCESS, Event.STARTUP_PLUGIN_SYSTEM, Event.PLUGINS_RELOADED,
|
||||
Event.INSTALL_UPDATE, Event.STARTUP_COMPLETED,
|
||||
]);
|
||||
|
||||
// Set the snackbar for the update service:
|
||||
@ -174,6 +176,8 @@ public partial class MainLayout : LayoutComponentBase, IMessageBusReceiver, ILan
|
||||
await this.UpdateThemeConfiguration();
|
||||
this.LoadNavItems();
|
||||
this.StateHasChanged();
|
||||
if (this.startupCompleted)
|
||||
_ = this.EnsureMandatoryInfosAcceptedAsync();
|
||||
break;
|
||||
|
||||
case Event.COLOR_THEME_CHANGED:
|
||||
@ -261,6 +265,13 @@ public partial class MainLayout : LayoutComponentBase, IMessageBusReceiver, ILan
|
||||
this.LoadNavItems();
|
||||
|
||||
await this.InvokeAsync(this.StateHasChanged);
|
||||
if (this.startupCompleted)
|
||||
_ = this.EnsureMandatoryInfosAcceptedAsync();
|
||||
break;
|
||||
|
||||
case Event.STARTUP_COMPLETED:
|
||||
this.startupCompleted = true;
|
||||
_ = this.EnsureMandatoryInfosAcceptedAsync();
|
||||
break;
|
||||
}
|
||||
});
|
||||
@ -368,12 +379,90 @@ public partial class MainLayout : LayoutComponentBase, IMessageBusReceiver, ILan
|
||||
await this.MessageBus.SendMessage<bool>(this, Event.COLOR_THEME_CHANGED);
|
||||
this.StateHasChanged();
|
||||
}
|
||||
|
||||
private async Task EnsureMandatoryInfosAcceptedAsync()
|
||||
{
|
||||
if (!await this.mandatoryInfoDialogSemaphore.WaitAsync(0))
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
var pendingInfos = this.GetPendingMandatoryInfos().ToList();
|
||||
if (pendingInfos.Count == 0)
|
||||
return;
|
||||
|
||||
foreach (var info in pendingInfos)
|
||||
{
|
||||
var wasAccepted = await this.ShowMandatoryInfoDialog(info);
|
||||
if (!wasAccepted)
|
||||
{
|
||||
await this.RustService.ExitApplication();
|
||||
return;
|
||||
}
|
||||
|
||||
await this.StoreMandatoryInfoAcceptance(info);
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
this.mandatoryInfoDialogSemaphore.Release();
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerable<DataMandatoryInfo> GetPendingMandatoryInfos()
|
||||
{
|
||||
return PluginFactory.GetMandatoryInfos()
|
||||
.Where(info =>
|
||||
{
|
||||
var acceptance = this.SettingsManager.ConfigurationData.MandatoryInformation.FindAcceptance(info.Id);
|
||||
return acceptance is null || !string.Equals(acceptance.AcceptedHash, info.AcceptanceHash, StringComparison.Ordinal);
|
||||
});
|
||||
}
|
||||
|
||||
private async Task<bool> ShowMandatoryInfoDialog(DataMandatoryInfo info)
|
||||
{
|
||||
var acceptance = this.SettingsManager.ConfigurationData.MandatoryInformation.FindAcceptance(info.Id);
|
||||
var dialogParameters = new DialogParameters<MandatoryInfoDialog>
|
||||
{
|
||||
{ x => x.Info, info },
|
||||
{ x => x.Acceptance, acceptance },
|
||||
};
|
||||
|
||||
var dialogReference = await this.DialogService.ShowAsync<MandatoryInfoDialog>(info.Title, dialogParameters, DialogOptions.BLOCKING_FULLSCREEN);
|
||||
var dialogResult = await dialogReference.Result;
|
||||
return dialogResult is { Canceled: false, Data: true };
|
||||
}
|
||||
|
||||
private async Task StoreMandatoryInfoAcceptance(DataMandatoryInfo info)
|
||||
{
|
||||
var acceptances = this.SettingsManager.ConfigurationData.MandatoryInformation.Acceptances;
|
||||
var acceptance = new DataMandatoryInfoAcceptance
|
||||
{
|
||||
InfoId = info.Id,
|
||||
AcceptedVersion = info.VersionText,
|
||||
AcceptedHash = info.AcceptanceHash,
|
||||
AcceptedAtUtc = DateTimeOffset.UtcNow,
|
||||
EnterpriseConfigurationPluginId = info.EnterpriseConfigurationPluginId,
|
||||
};
|
||||
|
||||
var existingIndex = acceptances.FindIndex(item => item.InfoId == info.Id);
|
||||
if (existingIndex >= 0)
|
||||
acceptances[existingIndex] = acceptance;
|
||||
else
|
||||
acceptances.Add(acceptance);
|
||||
|
||||
await this.SettingsManager.StoreSettings();
|
||||
}
|
||||
|
||||
#region Implementation of IDisposable
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
this.MessageBus.Unregister(this);
|
||||
this.mandatoryInfoDialogSemaphore.Dispose();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -222,6 +222,18 @@
|
||||
<ExpansionPanel HeaderIcon="@Icons.Material.Filled.EventNote" HeaderText="@T("Changelog")">
|
||||
<Changelog/>
|
||||
</ExpansionPanel>
|
||||
|
||||
@foreach (var mandatoryInfoPanel in this.mandatoryInfoPanels)
|
||||
{
|
||||
<ExpansionPanel HeaderIcon="@Icons.Material.Filled.Gavel" HeaderText="@mandatoryInfoPanel.HeaderText">
|
||||
<MudText Typo="Typo.body2" Class="mb-3">
|
||||
@string.Format(T("Provided by configuration plugin: {0}"), mandatoryInfoPanel.PluginName)
|
||||
</MudText>
|
||||
<MandatoryInfoDisplay Info="@mandatoryInfoPanel.Info"
|
||||
Acceptance="@mandatoryInfoPanel.Acceptance"
|
||||
ShowAcceptanceMetadata="@true"/>
|
||||
</ExpansionPanel>
|
||||
}
|
||||
|
||||
<ExpansionPanel HeaderIcon="@Icons.Material.Filled.Book" HeaderText="@T("Logbook")">
|
||||
<MudText Typo="Typo.h4">
|
||||
|
||||
@ -2,6 +2,7 @@ using System.Reflection;
|
||||
|
||||
using AIStudio.Components;
|
||||
using AIStudio.Dialogs;
|
||||
using AIStudio.Settings.DataModel;
|
||||
using AIStudio.Tools.Databases;
|
||||
using AIStudio.Tools.Metadata;
|
||||
using AIStudio.Tools.PluginSystem;
|
||||
@ -77,9 +78,13 @@ public partial class Information : MSGComponentBase
|
||||
.ToList();
|
||||
|
||||
private List<EnterpriseEnvironment> enterpriseEnvironments = EnterpriseEnvironmentService.CURRENT_ENVIRONMENTS.ToList();
|
||||
|
||||
private List<MandatoryInfoPanelData> mandatoryInfoPanels = [];
|
||||
|
||||
private sealed record DatabaseDisplayInfo(string Label, string Value);
|
||||
|
||||
private sealed record MandatoryInfoPanelData(string HeaderText, string PluginName, DataMandatoryInfo Info, DataMandatoryInfoAcceptance? Acceptance);
|
||||
|
||||
private readonly List<DatabaseDisplayInfo> databaseDisplayInfo = new();
|
||||
|
||||
private bool HasAnyActiveEnvironment => this.enterpriseEnvironments.Any(e => e.IsActive);
|
||||
@ -117,7 +122,7 @@ public partial class Information : MSGComponentBase
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
this.ApplyFilters([], [ Event.ENTERPRISE_ENVIRONMENTS_CHANGED ]);
|
||||
this.ApplyFilters([], [ Event.ENTERPRISE_ENVIRONMENTS_CHANGED, Event.CONFIGURATION_CHANGED ]);
|
||||
await base.OnInitializedAsync();
|
||||
|
||||
this.RefreshEnterpriseConfigurationState();
|
||||
@ -145,6 +150,7 @@ public partial class Information : MSGComponentBase
|
||||
{
|
||||
case Event.PLUGINS_RELOADED:
|
||||
case Event.ENTERPRISE_ENVIRONMENTS_CHANGED:
|
||||
case Event.CONFIGURATION_CHANGED:
|
||||
this.RefreshEnterpriseConfigurationState();
|
||||
await this.InvokeAsync(this.StateHasChanged);
|
||||
break;
|
||||
@ -163,6 +169,16 @@ public partial class Information : MSGComponentBase
|
||||
.ToList();
|
||||
|
||||
this.enterpriseEnvironments = EnterpriseEnvironmentService.CURRENT_ENVIRONMENTS.ToList();
|
||||
this.mandatoryInfoPanels = PluginFactory.GetMandatoryInfos()
|
||||
.Select(info =>
|
||||
{
|
||||
var plugin = this.configPlugins.FirstOrDefault(item => item.Id == info.EnterpriseConfigurationPluginId);
|
||||
var pluginName = plugin?.Name ?? T("Unknown configuration plugin");
|
||||
var acceptance = this.SettingsManager.ConfigurationData.MandatoryInformation.FindAcceptance(info.Id);
|
||||
var headerText = $"{T("Consent:")} {info.Title}";
|
||||
return new MandatoryInfoPanelData(headerText, pluginName, info, acceptance);
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
|
||||
private async Task DeterminePandocVersion()
|
||||
|
||||
@ -266,6 +266,32 @@ CONFIG["CHAT_TEMPLATES"] = {}
|
||||
-- Document analysis policies for this configuration:
|
||||
CONFIG["DOCUMENT_ANALYSIS_POLICIES"] = {}
|
||||
|
||||
-- Mandatory infos that users must explicitly accept before using AI Studio:
|
||||
-- AI Studio asks users again when Version, Title, or Markdown change.
|
||||
-- Changing Version additionally allows the UI to communicate that a new version is available.
|
||||
CONFIG["MANDATORY_INFOS"] = {}
|
||||
|
||||
-- An example mandatory info:
|
||||
-- CONFIG["MANDATORY_INFOS"][#CONFIG["MANDATORY_INFOS"]+1] = {
|
||||
-- ["Id"] = "00000000-0000-0000-0000-000000000000",
|
||||
-- ["Title"] = "AI Usage Requirements",
|
||||
-- ["Version"] = "1",
|
||||
-- ["Markdown"] = [===[
|
||||
-- ## Usage Requirements
|
||||
--
|
||||
-- Before using this AI offering, please ensure that:
|
||||
--
|
||||
-- - you have completed the required internal training,
|
||||
-- - generated output is clearly labeled where necessary,
|
||||
-- - results are reviewed by a human before reuse,
|
||||
-- - all internal policies and applicable law are followed.
|
||||
--
|
||||
-- Further information is available in the [internal wiki](https://example.org/wiki).
|
||||
-- ]===],
|
||||
-- ["AcceptButtonText"] = "Yes, I comply with these requirements",
|
||||
-- ["RejectButtonText"] = "Stop. I do not agree to these requirements"
|
||||
-- }
|
||||
|
||||
-- An example document analysis policy:
|
||||
-- CONFIG["DOCUMENT_ANALYSIS_POLICIES"][#CONFIG["DOCUMENT_ANALYSIS_POLICIES"]+1] = {
|
||||
-- ["Id"] = "00000000-0000-0000-0000-000000000000",
|
||||
|
||||
@ -1524,7 +1524,7 @@ UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::SLIDEBUILDER::SLIDEASSISTANT::T2823798965
|
||||
-- This assistant helps you create clear, structured slides from long texts or documents. Enter a presentation title and provide the content either as text or with one or more documents. Important aspects allow you to add instructions to the LLM regarding output or formatting. Set the number of slides either directly or based on your desired presentation duration. You can also specify the number of bullet points. If the default value of 0 is not changed, the LLM will independently determine how many slides or bullet points to generate. The output can be flexibly generated in various languages and tailored to a specific audience.
|
||||
UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::SLIDEBUILDER::SLIDEASSISTANT::T2910177051"] = "Dieser Assistent hilft Ihnen, aus langen Texten oder Dokumenten klare, strukturierte Folien zu erstellen. Geben Sie einen Titel für die Präsentation ein und stellen Sie den Inhalt entweder als Text oder über ein oder mehrere Dokumente bereit. Unter „Wichtige Aspekte“ können Sie dem LLM Anweisungen zur Ausgabe oder Formatierung geben. Legen Sie die Anzahl der Folien entweder direkt oder anhand der gewünschten Präsentationsdauer fest. Sie können auch die Anzahl der Aufzählungspunkte angeben. Wenn der Standardwert 0 nicht geändert wird, bestimmt das LLM selbstständig, wie viele Folien oder Aufzählungspunkte erstellt werden. Die Ausgabe kann flexibel in verschiedenen Sprachen erzeugt und auf eine bestimmte Zielgruppe zugeschnitten werden."
|
||||
|
||||
-- Folienplaner-Assistent
|
||||
-- Slide Planner Assistant
|
||||
UI_TEXT_CONTENT["AISTUDIO::ASSISTANTS::SLIDEBUILDER::SLIDEASSISTANT::T2924755246"] = "Folienplaner-Assistent"
|
||||
|
||||
-- The result of your previous slide builder session.
|
||||
@ -2100,6 +2100,27 @@ UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::MANAGEPANDOCDEPENDENCY::T527187983"] = "
|
||||
-- Install Pandoc
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::MANAGEPANDOCDEPENDENCY::T986578435"] = "Pandoc installieren"
|
||||
|
||||
-- Version
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::MANDATORYINFODISPLAY::T1573770551"] = "Version"
|
||||
|
||||
-- A new version of the terms is available. Please review it again.
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::MANDATORYINFODISPLAY::T1711766303"] = "Eine neue Version der Bedingungen ist verfügbar. Bitte lesen Sie die Bedingungen erneut durch."
|
||||
|
||||
-- This mandatory info has not been accepted yet.
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::MANDATORYINFODISPLAY::T1870532312"] = "Diese Pflichtangabe wurde noch nicht akzeptiert."
|
||||
|
||||
-- Accepted version
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::MANDATORYINFODISPLAY::T203086476"] = "Akzeptierte Version"
|
||||
|
||||
-- Last accepted version
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::MANDATORYINFODISPLAY::T3407978086"] = "Zuletzt akzeptierte Version"
|
||||
|
||||
-- Accepted at (UTC)
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::MANDATORYINFODISPLAY::T3511160492"] = "Akzeptiert am (UTC)"
|
||||
|
||||
-- Please review this text again. The content was changed.
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::MANDATORYINFODISPLAY::T941885055"] = "Bitte lesen Sie diesen Text erneut durch. Der Inhalt wurde geändert."
|
||||
|
||||
-- Given that my employer's workplace uses both Windows and Linux, I wanted a cross-platform solution that would work seamlessly across all major operating systems, including macOS. Additionally, I wanted to demonstrate that it is possible to create modern, efficient, cross-platform applications without resorting to Electron bloatware. The combination of .NET and Rust with Tauri proved to be an excellent technology stack for building such robust applications.
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::MOTIVATION::T1057189794"] = "Da mein Arbeitgeber sowohl Windows als auch Linux am Arbeitsplatz nutzt, wollte ich eine plattformübergreifende Lösung, die nahtlos auf allen wichtigen Betriebssystemen, einschließlich macOS, funktioniert. Außerdem wollte ich zeigen, dass es möglich ist, moderne, effiziente und plattformübergreifende Anwendungen zu erstellen, ohne auf Software-Ballast, wie z.B. das Electron-Framework, zurückzugreifen. Die Kombination aus .NET und Rust mit Tauri hat sich dabei als hervorragender Technologie-Stack für den Bau solch robuster Anwendungen erwiesen."
|
||||
|
||||
@ -5508,7 +5529,7 @@ UI_TEXT_CONTENT["AISTUDIO::PAGES::ASSISTANTS::T2830810750"] = "AI Studio Entwick
|
||||
-- Generate a job posting for a given job description.
|
||||
UI_TEXT_CONTENT["AISTUDIO::PAGES::ASSISTANTS::T2831103254"] = "Erstellen Sie eine Stellenanzeige anhand einer vorgegebenen Stellenbeschreibung."
|
||||
|
||||
-- Folienplaner-Assistent
|
||||
-- Slide Planner Assistant
|
||||
UI_TEXT_CONTENT["AISTUDIO::PAGES::ASSISTANTS::T2924755246"] = "Folienplaner-Assistent"
|
||||
|
||||
-- Installed Assistants
|
||||
@ -5697,6 +5718,9 @@ UI_TEXT_CONTENT["AISTUDIO::PAGES::INFORMATION::T1137744461"] = "ID-Konflikt: Die
|
||||
-- This is a private AI Studio installation. It runs without an enterprise configuration.
|
||||
UI_TEXT_CONTENT["AISTUDIO::PAGES::INFORMATION::T1209549230"] = "Dies ist eine private AI Studio-Installation. Sie läuft ohne Unternehmenskonfiguration."
|
||||
|
||||
-- Unknown configuration plugin
|
||||
UI_TEXT_CONTENT["AISTUDIO::PAGES::INFORMATION::T1290340974"] = "Unbekanntes Konfigurations-Plugin"
|
||||
|
||||
-- This library is used to read PDF files. This is necessary, e.g., for using PDFs as a data source for a chat.
|
||||
UI_TEXT_CONTENT["AISTUDIO::PAGES::INFORMATION::T1388816916"] = "Diese Bibliothek wird verwendet, um PDF-Dateien zu lesen. Das ist zum Beispiel notwendig, um PDFs als Datenquelle für einen Chat zu nutzen."
|
||||
|
||||
@ -5727,6 +5751,9 @@ UI_TEXT_CONTENT["AISTUDIO::PAGES::INFORMATION::T1629800076"] = "Basierend auf .N
|
||||
-- AI Studio creates a log file at startup, in which events during startup are recorded. After startup, another log file is created that records all events that occur during the use of the app. This includes any errors that may occur. Depending on when an error occurs (at startup or during use), the contents of these log files can be helpful for troubleshooting. Sensitive information such as passwords is not included in the log files.
|
||||
UI_TEXT_CONTENT["AISTUDIO::PAGES::INFORMATION::T1630237140"] = "AI Studio erstellt beim Start eine Protokolldatei, in der Ereignisse während des Starts aufgezeichnet werden. Nach dem Start wird eine weitere Protokolldatei erstellt, die alle Ereignisse während der Nutzung der App dokumentiert. Dazu gehören auch eventuell auftretende Fehler. Je nachdem, wann ein Fehler auftritt (beim Start oder während der Nutzung), können die Inhalte dieser Protokolldateien bei der Fehlerbehebung hilfreich sein. Sensible Informationen wie Passwörter werden nicht in den Protokolldateien gespeichert."
|
||||
|
||||
-- Consent:
|
||||
UI_TEXT_CONTENT["AISTUDIO::PAGES::INFORMATION::T171952677"] = "Zustimmung:"
|
||||
|
||||
-- This library is used to display the differences between two texts. This is necessary, e.g., for the grammar and spelling assistant.
|
||||
UI_TEXT_CONTENT["AISTUDIO::PAGES::INFORMATION::T1772678682"] = "Diese Bibliothek wird verwendet, um die Unterschiede zwischen zwei Texten anzuzeigen. Das ist zum Beispiel für den Grammatik- und Rechtschreibassistenten notwendig."
|
||||
|
||||
@ -5946,6 +5973,9 @@ UI_TEXT_CONTENT["AISTUDIO::PAGES::INFORMATION::T788846912"] = "Kopiert die Konfi
|
||||
-- installed by AI Studio
|
||||
UI_TEXT_CONTENT["AISTUDIO::PAGES::INFORMATION::T833849470"] = "installiert von AI Studio"
|
||||
|
||||
-- Provided by configuration plugin: {0}
|
||||
UI_TEXT_CONTENT["AISTUDIO::PAGES::INFORMATION::T836298648"] = "Bereitgestellt vom Konfigurations-Plugin: {0}"
|
||||
|
||||
-- We use this library to be able to read PowerPoint files. This allows us to insert content from slides into prompts and take PowerPoint files into account in RAG processes. We thank Nils Kruthoff for his work on this Rust crate.
|
||||
UI_TEXT_CONTENT["AISTUDIO::PAGES::INFORMATION::T855925638"] = "Wir verwenden diese Bibliothek, um PowerPoint-Dateien lesen zu können. So ist es möglich, Inhalte aus Folien in Prompts einzufügen und PowerPoint-Dateien in RAG-Prozessen zu berücksichtigen. Wir danken Nils Kruthoff für seine Arbeit an diesem Rust-Crate."
|
||||
|
||||
@ -6492,7 +6522,7 @@ UI_TEXT_CONTENT["AISTUDIO::TOOLS::COMPONENTSEXTENSIONS::T2684676843"] = "Texte z
|
||||
-- Synonym Assistant
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::COMPONENTSEXTENSIONS::T2921123194"] = "Synonym-Assistent"
|
||||
|
||||
-- Folienplaner-Assistent
|
||||
-- Slide Planner Assistant
|
||||
UI_TEXT_CONTENT["AISTUDIO::TOOLS::COMPONENTSEXTENSIONS::T2924755246"] = "Folienplaner-Assistent"
|
||||
|
||||
-- Document Analysis Assistant
|
||||
|
||||
@ -2100,6 +2100,27 @@ UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::MANAGEPANDOCDEPENDENCY::T527187983"] = "C
|
||||
-- Install Pandoc
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::MANAGEPANDOCDEPENDENCY::T986578435"] = "Install Pandoc"
|
||||
|
||||
-- Version
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::MANDATORYINFODISPLAY::T1573770551"] = "Version"
|
||||
|
||||
-- A new version of the terms is available. Please review it again.
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::MANDATORYINFODISPLAY::T1711766303"] = "A new version of the terms is available. Please review it again."
|
||||
|
||||
-- This mandatory info has not been accepted yet.
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::MANDATORYINFODISPLAY::T1870532312"] = "This mandatory info has not been accepted yet."
|
||||
|
||||
-- Accepted version
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::MANDATORYINFODISPLAY::T203086476"] = "Accepted version"
|
||||
|
||||
-- Last accepted version
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::MANDATORYINFODISPLAY::T3407978086"] = "Last accepted version"
|
||||
|
||||
-- Accepted at (UTC)
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::MANDATORYINFODISPLAY::T3511160492"] = "Accepted at (UTC)"
|
||||
|
||||
-- Please review this text again. The content was changed.
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::MANDATORYINFODISPLAY::T941885055"] = "Please review this text again. The content was changed."
|
||||
|
||||
-- Given that my employer's workplace uses both Windows and Linux, I wanted a cross-platform solution that would work seamlessly across all major operating systems, including macOS. Additionally, I wanted to demonstrate that it is possible to create modern, efficient, cross-platform applications without resorting to Electron bloatware. The combination of .NET and Rust with Tauri proved to be an excellent technology stack for building such robust applications.
|
||||
UI_TEXT_CONTENT["AISTUDIO::COMPONENTS::MOTIVATION::T1057189794"] = "Given that my employer's workplace uses both Windows and Linux, I wanted a cross-platform solution that would work seamlessly across all major operating systems, including macOS. Additionally, I wanted to demonstrate that it is possible to create modern, efficient, cross-platform applications without resorting to Electron bloatware. The combination of .NET and Rust with Tauri proved to be an excellent technology stack for building such robust applications."
|
||||
|
||||
@ -5697,6 +5718,9 @@ UI_TEXT_CONTENT["AISTUDIO::PAGES::INFORMATION::T1137744461"] = "ID mismatch: the
|
||||
-- This is a private AI Studio installation. It runs without an enterprise configuration.
|
||||
UI_TEXT_CONTENT["AISTUDIO::PAGES::INFORMATION::T1209549230"] = "This is a private AI Studio installation. It runs without an enterprise configuration."
|
||||
|
||||
-- Unknown configuration plugin
|
||||
UI_TEXT_CONTENT["AISTUDIO::PAGES::INFORMATION::T1290340974"] = "Unknown configuration plugin"
|
||||
|
||||
-- This library is used to read PDF files. This is necessary, e.g., for using PDFs as a data source for a chat.
|
||||
UI_TEXT_CONTENT["AISTUDIO::PAGES::INFORMATION::T1388816916"] = "This library is used to read PDF files. This is necessary, e.g., for using PDFs as a data source for a chat."
|
||||
|
||||
@ -5727,6 +5751,9 @@ UI_TEXT_CONTENT["AISTUDIO::PAGES::INFORMATION::T1629800076"] = "Building on .NET
|
||||
-- AI Studio creates a log file at startup, in which events during startup are recorded. After startup, another log file is created that records all events that occur during the use of the app. This includes any errors that may occur. Depending on when an error occurs (at startup or during use), the contents of these log files can be helpful for troubleshooting. Sensitive information such as passwords is not included in the log files.
|
||||
UI_TEXT_CONTENT["AISTUDIO::PAGES::INFORMATION::T1630237140"] = "AI Studio creates a log file at startup, in which events during startup are recorded. After startup, another log file is created that records all events that occur during the use of the app. This includes any errors that may occur. Depending on when an error occurs (at startup or during use), the contents of these log files can be helpful for troubleshooting. Sensitive information such as passwords is not included in the log files."
|
||||
|
||||
-- Consent:
|
||||
UI_TEXT_CONTENT["AISTUDIO::PAGES::INFORMATION::T171952677"] = "Consent:"
|
||||
|
||||
-- This library is used to display the differences between two texts. This is necessary, e.g., for the grammar and spelling assistant.
|
||||
UI_TEXT_CONTENT["AISTUDIO::PAGES::INFORMATION::T1772678682"] = "This library is used to display the differences between two texts. This is necessary, e.g., for the grammar and spelling assistant."
|
||||
|
||||
@ -5946,6 +5973,9 @@ UI_TEXT_CONTENT["AISTUDIO::PAGES::INFORMATION::T788846912"] = "Copies the config
|
||||
-- installed by AI Studio
|
||||
UI_TEXT_CONTENT["AISTUDIO::PAGES::INFORMATION::T833849470"] = "installed by AI Studio"
|
||||
|
||||
-- Provided by configuration plugin: {0}
|
||||
UI_TEXT_CONTENT["AISTUDIO::PAGES::INFORMATION::T836298648"] = "Provided by configuration plugin: {0}"
|
||||
|
||||
-- We use this library to be able to read PowerPoint files. This allows us to insert content from slides into prompts and take PowerPoint files into account in RAG processes. We thank Nils Kruthoff for his work on this Rust crate.
|
||||
UI_TEXT_CONTENT["AISTUDIO::PAGES::INFORMATION::T855925638"] = "We use this library to be able to read PowerPoint files. This allows us to insert content from slides into prompts and take PowerPoint files into account in RAG processes. We thank Nils Kruthoff for his work on this Rust crate."
|
||||
|
||||
|
||||
@ -114,6 +114,8 @@ public sealed class Data
|
||||
|
||||
public DataDocumentAnalysis DocumentAnalysis { get; init; } = new();
|
||||
|
||||
public DataMandatoryInformation MandatoryInformation { get; init; } = new();
|
||||
|
||||
public DataTextSummarizer TextSummarizer { get; init; } = new();
|
||||
|
||||
public DataTextContentCleaner TextContentCleaner { get; init; } = new();
|
||||
|
||||
117
app/MindWork AI Studio/Settings/DataModel/DataMandatoryInfo.cs
Normal file
117
app/MindWork AI Studio/Settings/DataModel/DataMandatoryInfo.cs
Normal file
@ -0,0 +1,117 @@
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
using Lua;
|
||||
|
||||
namespace AIStudio.Settings.DataModel;
|
||||
|
||||
public sealed record DataMandatoryInfo
|
||||
{
|
||||
private static readonly ILogger LOG = Program.LOGGER_FACTORY.CreateLogger<DataMandatoryInfo>();
|
||||
|
||||
/// <summary>
|
||||
/// The stable ID of the mandatory info.
|
||||
/// </summary>
|
||||
public string Id { get; private init; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// The ID of the enterprise configuration plugin that provides this info.
|
||||
/// </summary>
|
||||
public Guid EnterpriseConfigurationPluginId { get; private init; } = Guid.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// The title shown to the user.
|
||||
/// </summary>
|
||||
public string Title { get; private init; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// The configured version string shown to the user. A changed version triggers re-acceptance
|
||||
/// and allows the UI to distinguish a new version from a content-only change.
|
||||
/// </summary>
|
||||
public string VersionText { get; private init; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// The Markdown content shown to the user.
|
||||
/// </summary>
|
||||
public string Markdown { get; private init; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// The label of the acceptance button.
|
||||
/// </summary>
|
||||
public string AcceptButtonText { get; private init; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// The label of the reject button.
|
||||
/// </summary>
|
||||
public string RejectButtonText { get; private init; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// The current hash used to determine whether the user needs to re-accept the info.
|
||||
/// </summary>
|
||||
public string AcceptanceHash { get; private init; } = string.Empty;
|
||||
|
||||
private static string CreateAcceptanceHash(string versionText, string title, string markdown)
|
||||
{
|
||||
var content = $"Version:{versionText}\nTitle:{title}\nMarkdown:{markdown}";
|
||||
var bytes = Encoding.UTF8.GetBytes(content);
|
||||
var hash = SHA256.HashData(bytes);
|
||||
|
||||
return Convert.ToHexString(hash);
|
||||
}
|
||||
|
||||
public static bool TryParseConfiguration(int idx, LuaTable table, Guid configPluginId, out DataMandatoryInfo mandatoryInfo)
|
||||
{
|
||||
mandatoryInfo = new DataMandatoryInfo();
|
||||
if (!table.TryGetValue("Id", out var idValue) || !idValue.TryRead<string>(out var idText) || !Guid.TryParse(idText, out var id))
|
||||
{
|
||||
LOG.LogWarning("The configured mandatory info {InfoIndex} does not contain a valid ID. The ID must be a valid GUID.", idx);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!table.TryGetValue("Title", out var titleValue) || !titleValue.TryRead<string>(out var title) || string.IsNullOrWhiteSpace(title))
|
||||
{
|
||||
LOG.LogWarning("The configured mandatory info {InfoIndex} does not contain a valid Title field.", idx);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!table.TryGetValue("Version", out var versionValue) || !versionValue.TryRead<string>(out var versionText) || string.IsNullOrWhiteSpace(versionText))
|
||||
{
|
||||
LOG.LogWarning("The configured mandatory info {InfoIndex} does not contain a valid Version field.", idx);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!table.TryGetValue("Markdown", out var markdownValue) || !markdownValue.TryRead<string>(out var markdown) || string.IsNullOrWhiteSpace(markdown))
|
||||
{
|
||||
LOG.LogWarning("The configured mandatory info {InfoIndex} does not contain a valid Markdown field.", idx);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!table.TryGetValue("AcceptButtonText", out var acceptButtonValue) || !acceptButtonValue.TryRead<string>(out var acceptButtonText) || string.IsNullOrWhiteSpace(acceptButtonText))
|
||||
{
|
||||
LOG.LogWarning("The configured mandatory info {InfoIndex} does not contain a valid AcceptButtonText field.", idx);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!table.TryGetValue("RejectButtonText", out var rejectButtonValue) || !rejectButtonValue.TryRead<string>(out var rejectButtonText) || string.IsNullOrWhiteSpace(rejectButtonText))
|
||||
{
|
||||
LOG.LogWarning("The configured mandatory info {InfoIndex} does not contain a valid RejectButtonText field.", idx);
|
||||
return false;
|
||||
}
|
||||
|
||||
var normalizedMarkdown = AIStudio.Tools.Markdown.RemoveSharedIndentation(markdown);
|
||||
var acceptanceHash = CreateAcceptanceHash(versionText, title, normalizedMarkdown);
|
||||
mandatoryInfo = new DataMandatoryInfo
|
||||
{
|
||||
Id = id.ToString(),
|
||||
Title = title,
|
||||
VersionText = versionText,
|
||||
Markdown = normalizedMarkdown,
|
||||
AcceptButtonText = acceptButtonText,
|
||||
RejectButtonText = rejectButtonText,
|
||||
EnterpriseConfigurationPluginId = configPluginId,
|
||||
AcceptanceHash = acceptanceHash,
|
||||
};
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
namespace AIStudio.Settings.DataModel;
|
||||
|
||||
public sealed record DataMandatoryInfoAcceptance
|
||||
{
|
||||
/// <summary>
|
||||
/// The ID of the mandatory info that was accepted.
|
||||
/// </summary>
|
||||
public string InfoId { get; init; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// The accepted version string.
|
||||
/// </summary>
|
||||
public string AcceptedVersion { get; init; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// The accepted hash of the mandatory info content.
|
||||
/// </summary>
|
||||
public string AcceptedHash { get; init; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// The UTC time of the acceptance.
|
||||
/// </summary>
|
||||
public DateTimeOffset AcceptedAtUtc { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// The plugin that provided the accepted info at the time of acceptance.
|
||||
/// </summary>
|
||||
public Guid EnterpriseConfigurationPluginId { get; init; } = Guid.Empty;
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
namespace AIStudio.Settings.DataModel;
|
||||
|
||||
public sealed class DataMandatoryInformation
|
||||
{
|
||||
/// <summary>
|
||||
/// Persisted user acceptances for configured mandatory infos.
|
||||
/// </summary>
|
||||
public List<DataMandatoryInfoAcceptance> Acceptances { get; set; } = [];
|
||||
|
||||
public DataMandatoryInfoAcceptance? FindAcceptance(string infoId)
|
||||
{
|
||||
return this.Acceptances.LastOrDefault(acceptance => string.Equals(acceptance.InfoId, infoId, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
public bool RemoveLeftOverAcceptances(IEnumerable<DataMandatoryInfo> mandatoryInfos)
|
||||
{
|
||||
var validInfoIds = mandatoryInfos
|
||||
.Select(info => info.Id)
|
||||
.ToHashSet(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
var removedCount = this.Acceptances.RemoveAll(acceptance => !validInfoIds.Contains(acceptance.InfoId));
|
||||
return removedCount > 0;
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,5 @@
|
||||
using Markdig;
|
||||
using System.Text;
|
||||
|
||||
namespace AIStudio.Tools;
|
||||
|
||||
@ -26,4 +27,123 @@ public static class Markdown
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
public static string RemoveSharedIndentation(string value)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(value))
|
||||
return string.Empty;
|
||||
|
||||
return RemoveSharedIndentation(value.AsSpan());
|
||||
}
|
||||
|
||||
private static string RemoveSharedIndentation(ReadOnlySpan<char> value)
|
||||
{
|
||||
var firstContentLineStart = -1;
|
||||
var lastContentLineStart = -1;
|
||||
var lastContentLineEnd = -1;
|
||||
var commonIndentation = int.MaxValue;
|
||||
var position = 0;
|
||||
|
||||
while (TryGetNextLine(value, position, out var lineStart, out var currentLineEnd, out var nextPosition))
|
||||
{
|
||||
var lineContent = value[lineStart..currentLineEnd];
|
||||
if (IsWhiteSpace(lineContent))
|
||||
{
|
||||
position = nextPosition;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (firstContentLineStart < 0)
|
||||
firstContentLineStart = lineStart;
|
||||
|
||||
lastContentLineStart = lineStart;
|
||||
lastContentLineEnd = currentLineEnd;
|
||||
commonIndentation = Math.Min(commonIndentation, CountIndentation(lineContent));
|
||||
position = nextPosition;
|
||||
}
|
||||
|
||||
if (firstContentLineStart < 0)
|
||||
return string.Empty;
|
||||
|
||||
if (commonIndentation == int.MaxValue)
|
||||
commonIndentation = 0;
|
||||
|
||||
var builder = new StringBuilder(lastContentLineEnd - firstContentLineStart);
|
||||
var shouldAppendLineBreak = false;
|
||||
position = firstContentLineStart;
|
||||
|
||||
while (TryGetNextLine(value, position, out var lineStart, out var lineEnd, out var nextPosition))
|
||||
{
|
||||
var lineContent = value[lineStart..lineEnd];
|
||||
|
||||
if (shouldAppendLineBreak)
|
||||
builder.Append('\n');
|
||||
|
||||
if (IsWhiteSpace(lineContent))
|
||||
shouldAppendLineBreak = true;
|
||||
else if (lineContent.Length > commonIndentation)
|
||||
{
|
||||
builder.Append(lineContent[commonIndentation..]);
|
||||
shouldAppendLineBreak = true;
|
||||
}
|
||||
else
|
||||
shouldAppendLineBreak = true;
|
||||
|
||||
if (lineStart == lastContentLineStart)
|
||||
break;
|
||||
|
||||
position = nextPosition;
|
||||
}
|
||||
|
||||
return builder.ToString();
|
||||
}
|
||||
|
||||
private static bool IsWhiteSpace(ReadOnlySpan<char> value)
|
||||
{
|
||||
foreach (var character in value)
|
||||
{
|
||||
if (!char.IsWhiteSpace(character))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static int CountIndentation(ReadOnlySpan<char> value)
|
||||
{
|
||||
var indentation = 0;
|
||||
while (indentation < value.Length && char.IsWhiteSpace(value[indentation]))
|
||||
indentation++;
|
||||
|
||||
return indentation;
|
||||
}
|
||||
|
||||
private static bool TryGetNextLine(ReadOnlySpan<char> value, int position, out int lineStart, out int lineEnd, out int nextPosition)
|
||||
{
|
||||
if (position > value.Length)
|
||||
{
|
||||
lineStart = 0;
|
||||
lineEnd = 0;
|
||||
nextPosition = position;
|
||||
return false;
|
||||
}
|
||||
|
||||
lineStart = position;
|
||||
for (var i = position; i < value.Length; i++)
|
||||
{
|
||||
if (value[i] != '\n')
|
||||
continue;
|
||||
|
||||
lineEnd = i > lineStart && value[i - 1] == '\r'
|
||||
? i - 1
|
||||
: i;
|
||||
|
||||
nextPosition = i + 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
lineEnd = value.Length;
|
||||
nextPosition = value.Length + 1;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -34,6 +34,8 @@ public static partial class Pandoc
|
||||
/// </summary>
|
||||
private static bool HAS_LOGGED_AVAILABILITY_CHECK_ONCE;
|
||||
|
||||
private static readonly HttpClient WEB_CLIENT = new();
|
||||
|
||||
/// <summary>
|
||||
/// Prepares a Pandoc process by using the Pandoc process builder.
|
||||
/// </summary>
|
||||
@ -181,21 +183,18 @@ public static partial class Pandoc
|
||||
// Download the latest Pandoc archive from GitHub:
|
||||
//
|
||||
var uri = await GenerateArchiveUriAsync();
|
||||
using (var client = new HttpClient())
|
||||
var response = await WEB_CLIENT.GetAsync(uri);
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
var response = await client.GetAsync(uri);
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
await MessageBus.INSTANCE.SendError(new(Icons.Material.Filled.Error, TB("Pandoc was not installed successfully, because the archive was not found.")));
|
||||
LOG.LogError("Pandoc was not installed successfully, because the archive was not found (status code {0}): url='{1}', message='{2}'", response.StatusCode, uri, response.RequestMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
// Download the archive to the temporary file:
|
||||
await using var tempFileStream = File.Create(pandocTempDownloadFile);
|
||||
await response.Content.CopyToAsync(tempFileStream);
|
||||
await MessageBus.INSTANCE.SendError(new(Icons.Material.Filled.Error, TB("Pandoc was not installed successfully, because the archive was not found.")));
|
||||
LOG.LogError("Pandoc was not installed successfully, because the archive was not found (status code {0}): url='{1}', message='{2}'", response.StatusCode, uri, response.RequestMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
// Download the archive to the temporary file:
|
||||
await using var tempFileStream = File.Create(pandocTempDownloadFile);
|
||||
await response.Content.CopyToAsync(tempFileStream);
|
||||
|
||||
if (uri.EndsWith(".zip", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
ZipFile.ExtractToDirectory(pandocTempDownloadFile, installDir);
|
||||
@ -245,9 +244,7 @@ public static partial class Pandoc
|
||||
/// <remarks>Version numbers can have the following formats: x.x, x.x.x or x.x.x.x</remarks>
|
||||
/// <returns>Latest Pandoc version number</returns>
|
||||
public static async Task<string> FetchLatestVersionAsync() {
|
||||
using var client = new HttpClient();
|
||||
var response = await client.GetAsync(LATEST_URL);
|
||||
|
||||
var response = await WEB_CLIENT.GetAsync(LATEST_URL);
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
LOG.LogError("Code {StatusCode}: Could not fetch Pandoc's latest page: {Response}", response.StatusCode, response.RequestMessage);
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using AIStudio.Settings;
|
||||
using AIStudio.Settings.DataModel;
|
||||
using AIStudio.Tools.Services;
|
||||
|
||||
using Lua;
|
||||
@ -12,12 +13,18 @@ public sealed class PluginConfiguration(bool isInternal, LuaState state, PluginT
|
||||
private static readonly ILogger LOG = Program.LOGGER_FACTORY.CreateLogger(nameof(PluginConfiguration));
|
||||
|
||||
private List<PluginConfigurationObject> configObjects = [];
|
||||
private List<DataMandatoryInfo> mandatoryInfos = [];
|
||||
|
||||
/// <summary>
|
||||
/// The list of configuration objects. Configuration objects are, e.g., providers or chat templates.
|
||||
/// </summary>
|
||||
public IEnumerable<PluginConfigurationObject> ConfigObjects => this.configObjects;
|
||||
|
||||
/// <summary>
|
||||
/// The list of mandatory infos provided by this configuration plugin.
|
||||
/// </summary>
|
||||
public IReadOnlyList<DataMandatoryInfo> MandatoryInfos => this.mandatoryInfos;
|
||||
|
||||
/// <summary>
|
||||
/// True/false when explicitly configured in the plugin, otherwise null.
|
||||
/// </summary>
|
||||
@ -91,6 +98,7 @@ public sealed class PluginConfiguration(bool isInternal, LuaState state, PluginT
|
||||
private bool TryProcessConfiguration(bool dryRun, out string message)
|
||||
{
|
||||
this.configObjects.Clear();
|
||||
this.mandatoryInfos.Clear();
|
||||
|
||||
// Ensure that the main CONFIG table exists and is a valid Lua table:
|
||||
if (!this.State.Environment["CONFIG"].TryRead<LuaTable>(out var mainTable))
|
||||
@ -150,6 +158,9 @@ public sealed class PluginConfiguration(bool isInternal, LuaState state, PluginT
|
||||
|
||||
// Handle configured document analysis policies:
|
||||
PluginConfigurationObject.TryParse(PluginConfigurationObjectType.DOCUMENT_ANALYSIS_POLICY, x => x.DocumentAnalysis.Policies, x => x.NextDocumentAnalysisPolicyNum, mainTable, this.Id, ref this.configObjects, dryRun);
|
||||
|
||||
// Handle configured mandatory infos:
|
||||
this.TryReadMandatoryInfos(mainTable);
|
||||
|
||||
// Config: preselected provider?
|
||||
ManagedConfiguration.TryProcessConfiguration(x => x.App, x => x.PreselectedProvider, Guid.Empty, this.Id, settingsTable, dryRun);
|
||||
@ -163,4 +174,25 @@ public sealed class PluginConfiguration(bool isInternal, LuaState state, PluginT
|
||||
message = string.Empty;
|
||||
return true;
|
||||
}
|
||||
|
||||
private void TryReadMandatoryInfos(LuaTable mainTable)
|
||||
{
|
||||
if (!mainTable.TryGetValue("MANDATORY_INFOS", out var mandatoryInfosValue) || !mandatoryInfosValue.TryRead<LuaTable>(out var mandatoryInfosTable))
|
||||
return;
|
||||
|
||||
for (var i = 1; i <= mandatoryInfosTable.ArrayLength; i++)
|
||||
{
|
||||
var luaMandatoryInfoValue = mandatoryInfosTable[i];
|
||||
if (!luaMandatoryInfoValue.TryRead<LuaTable>(out var luaMandatoryInfoTable))
|
||||
{
|
||||
LOG.LogWarning("The table 'MANDATORY_INFOS' entry at index {Index} is not a valid table (config plugin id: {ConfigPluginId}).", i, this.Id);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (DataMandatoryInfo.TryParseConfiguration(i, luaMandatoryInfoTable, this.Id, out var mandatoryInfo))
|
||||
this.mandatoryInfos.Add(mandatoryInfo);
|
||||
else
|
||||
LOG.LogWarning("The table 'MANDATORY_INFOS' entry at index {Index} does not contain a valid mandatory info (config plugin id: {ConfigPluginId}).", i, this.Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -185,6 +185,10 @@ public static partial class PluginFactory
|
||||
// Check document analysis policies:
|
||||
if(await PluginConfigurationObject.CleanLeftOverConfigurationObjects(PluginConfigurationObjectType.DOCUMENT_ANALYSIS_POLICY, x => x.DocumentAnalysis.Policies, AVAILABLE_PLUGINS, configObjectList))
|
||||
wasConfigurationChanged = true;
|
||||
|
||||
// Check left-over mandatory info acceptances:
|
||||
if (SETTINGS_MANAGER.ConfigurationData.MandatoryInformation.RemoveLeftOverAcceptances(GetMandatoryInfos()))
|
||||
wasConfigurationChanged = true;
|
||||
|
||||
// Check for a preselected provider:
|
||||
if(ManagedConfiguration.IsConfigurationLeftOver(x => x.App, x => x.PreselectedProvider, AVAILABLE_PLUGINS))
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using AIStudio.Settings;
|
||||
using AIStudio.Settings.DataModel;
|
||||
|
||||
namespace AIStudio.Tools.PluginSystem;
|
||||
|
||||
@ -127,4 +128,12 @@ public static partial class PluginFactory
|
||||
|
||||
HOT_RELOAD_WATCHER.Dispose();
|
||||
}
|
||||
|
||||
public static IReadOnlyList<DataMandatoryInfo> GetMandatoryInfos()
|
||||
{
|
||||
return RUNNING_PLUGINS
|
||||
.OfType<PluginConfiguration>()
|
||||
.SelectMany(plugin => plugin.MandatoryInfos)
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
3
app/MindWork AI Studio/Tools/Rust/AppExitResponse.cs
Normal file
3
app/MindWork AI Studio/Tools/Rust/AppExitResponse.cs
Normal file
@ -0,0 +1,3 @@
|
||||
namespace AIStudio.Tools.Rust;
|
||||
|
||||
public sealed record AppExitResponse(bool Success, string ErrorMessage);
|
||||
@ -1,5 +1,7 @@
|
||||
using System.Security.Cryptography;
|
||||
|
||||
using AIStudio.Tools.Rust;
|
||||
|
||||
namespace AIStudio.Tools.Services;
|
||||
|
||||
public sealed partial class RustService
|
||||
@ -117,4 +119,35 @@ public sealed partial class RustService
|
||||
|
||||
return await response.Content.ReadAsStringAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Requests the Rust runtime to exit the entire desktop application.
|
||||
/// </summary>
|
||||
public async Task<bool> ExitApplication()
|
||||
{
|
||||
try
|
||||
{
|
||||
var response = await this.http.PostAsync("/app/exit", null);
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
this.logger?.LogError("Failed to exit the app due to network error: {StatusCode}.", response.StatusCode);
|
||||
return false;
|
||||
}
|
||||
|
||||
var result = await response.Content.ReadFromJsonAsync<AppExitResponse>(this.jsonRustSerializerOptions);
|
||||
if (result is null || !result.Success)
|
||||
{
|
||||
this.logger?.LogError("Failed to exit the app: {Error}", result?.ErrorMessage ?? "Unknown error");
|
||||
return false;
|
||||
}
|
||||
|
||||
this.logger?.LogInformation("Exit request sent to Rust runtime.");
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this.logger?.LogError(ex, "Exception while requesting application exit.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -116,6 +116,25 @@
|
||||
margin-bottom:2em;
|
||||
}
|
||||
|
||||
.justified-markdown .mud-markdown-body p,
|
||||
.justified-markdown .mud-markdown-body li,
|
||||
.justified-markdown .mud-markdown-body blockquote p {
|
||||
text-align: justify;
|
||||
hyphens: auto;
|
||||
}
|
||||
|
||||
.justified-markdown .mud-markdown-body pre,
|
||||
.justified-markdown .mud-markdown-body code,
|
||||
.justified-markdown .mud-markdown-body h1,
|
||||
.justified-markdown .mud-markdown-body h2,
|
||||
.justified-markdown .mud-markdown-body h3,
|
||||
.justified-markdown .mud-markdown-body h4,
|
||||
.justified-markdown .mud-markdown-body h5,
|
||||
.justified-markdown .mud-markdown-body h6,
|
||||
.justified-markdown .mud-markdown-body table {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.code-block {
|
||||
background-color: #2d2d2d;
|
||||
color: #f8f8f2;
|
||||
|
||||
@ -9,8 +9,10 @@
|
||||
- Added pre-call validation to check if the selected model exists for the provider before making the request.
|
||||
- Added math rendering in chats for LaTeX display formulas, including block formats such as `$$ ... $$` and `\[ ... \]`.
|
||||
- Added the latest OpenAI models.
|
||||
- Added support for mandatory information notices in configuration plugins. Organizations can now require users to read and confirm important information before continuing in AI Studio.
|
||||
- Released the document analysis assistant after an intense testing phase.
|
||||
- Improved enterprise deployment for organizations: administrators can now provide up to 10 centrally managed enterprise configuration slots, use policy files on Linux and macOS, and continue using older configuration formats as a fallback during migration.
|
||||
- Improved transparency on the information page by showing configured mandatory notices together with their source and confirmation status.
|
||||
- Improved the profile selection for assistants and the chat. You can now explicitly choose between the app default profile, no profile, or a specific profile.
|
||||
- Improved the performance by caching the OS language detection and requesting the user language only once per app start.
|
||||
- Improved the chat performance by reducing unnecessary UI updates, making chats smoother and more responsive, especially in longer conversations.
|
||||
|
||||
@ -727,6 +727,13 @@ pub struct ShortcutResponse {
|
||||
error_message: String,
|
||||
}
|
||||
|
||||
/// Response for application exit requests.
|
||||
#[derive(Serialize)]
|
||||
pub struct AppExitResponse {
|
||||
success: bool,
|
||||
error_message: String,
|
||||
}
|
||||
|
||||
/// Internal helper function to register a shortcut with its callback.
|
||||
/// This is used by both `register_shortcut` and `resume_shortcuts` to
|
||||
/// avoid code duplication.
|
||||
@ -755,6 +762,34 @@ fn register_shortcut_with_callback(
|
||||
}
|
||||
}
|
||||
|
||||
/// Requests a controlled shutdown of the entire desktop application.
|
||||
#[post("/app/exit")]
|
||||
pub fn exit_app(_token: APIToken) -> Json<AppExitResponse> {
|
||||
let main_window_lock = MAIN_WINDOW.lock().unwrap();
|
||||
let main_window = match main_window_lock.as_ref() {
|
||||
Some(window) => window,
|
||||
None => {
|
||||
error!(Source = "Tauri"; "Cannot exit app: main window not available.");
|
||||
return Json(AppExitResponse {
|
||||
success: false,
|
||||
error_message: "Main window not available".to_string(),
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
let app_handle = main_window.app_handle();
|
||||
info!(Source = "Tauri"; "Controlled app exit was requested by the UI.");
|
||||
tauri::async_runtime::spawn(async move {
|
||||
time::sleep(Duration::from_millis(50)).await;
|
||||
app_handle.exit(0);
|
||||
});
|
||||
|
||||
Json(AppExitResponse {
|
||||
success: true,
|
||||
error_message: String::new(),
|
||||
})
|
||||
}
|
||||
|
||||
/// Registers or updates a global shortcut. If the shortcut string is empty,
|
||||
/// the existing shortcut for that name will be unregistered.
|
||||
#[post("/shortcuts/register", data = "<payload>")]
|
||||
|
||||
@ -76,6 +76,7 @@ pub fn start_runtime_api() {
|
||||
crate::app_window::select_file,
|
||||
crate::app_window::select_files,
|
||||
crate::app_window::save_file,
|
||||
crate::app_window::exit_app,
|
||||
crate::secret::get_secret,
|
||||
crate::secret::store_secret,
|
||||
crate::secret::delete_secret,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user