From bd97c0fb4b166bbf4fe3e72d3beabffab2111477 Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Sat, 2 Nov 2024 11:55:09 +0100 Subject: [PATCH] Fixed the "send to" issue, where you could select the bias-of-the-day (#183) --- app/MindWork AI Studio/Assistants/AssistantBase.razor | 10 ++-------- .../Assistants/AssistantBase.razor.cs | 3 +++ app/MindWork AI Studio/Tools/ComponentsExtensions.cs | 8 ++++++++ app/MindWork AI Studio/wwwroot/changelog/v0.9.16.md | 3 ++- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/app/MindWork AI Studio/Assistants/AssistantBase.razor b/app/MindWork AI Studio/Assistants/AssistantBase.razor index ab8a01f..180c449 100644 --- a/app/MindWork AI Studio/Assistants/AssistantBase.razor +++ b/app/MindWork AI Studio/Assistants/AssistantBase.razor @@ -51,11 +51,8 @@ @if (this.ShowSendTo) { - @foreach (var assistant in Enum.GetValues().OrderBy(n => n.Name().Length)) + @foreach (var assistant in Enum.GetValues().Where(n => n.AllowSendTo()).OrderBy(n => n.Name().Length)) { - if (assistant is Components.NONE || this.Component == assistant) - continue; - @assistant.Name() @@ -84,11 +81,8 @@ case SendToButton sendToButton: - @foreach (var assistant in Enum.GetValues().OrderBy(n => n.Name().Length)) + @foreach (var assistant in Enum.GetValues().Where(n => n.AllowSendTo()).OrderBy(n => n.Name().Length)) { - if(assistant is Components.NONE || sendToButton.Self == assistant) - continue; - @assistant.Name() diff --git a/app/MindWork AI Studio/Assistants/AssistantBase.razor.cs b/app/MindWork AI Studio/Assistants/AssistantBase.razor.cs index 1a7b404..7f92ed0 100644 --- a/app/MindWork AI Studio/Assistants/AssistantBase.razor.cs +++ b/app/MindWork AI Studio/Assistants/AssistantBase.razor.cs @@ -267,6 +267,9 @@ public abstract partial class AssistantBase : ComponentBase, IMessageBusReceiver protected Task SendToAssistant(Tools.Components destination, SendToButton sendToButton) { + if (!destination.AllowSendTo()) + return Task.CompletedTask; + var contentToSend = sendToButton == default ? string.Empty : sendToButton.UseResultingContentBlockData switch { false => sendToButton.GetText(), diff --git a/app/MindWork AI Studio/Tools/ComponentsExtensions.cs b/app/MindWork AI Studio/Tools/ComponentsExtensions.cs index 1aa92a1..cfe1c3d 100644 --- a/app/MindWork AI Studio/Tools/ComponentsExtensions.cs +++ b/app/MindWork AI Studio/Tools/ComponentsExtensions.cs @@ -5,6 +5,14 @@ namespace AIStudio.Tools; public static class ComponentsExtensions { + public static bool AllowSendTo(this Components component) => component switch + { + Components.NONE => false, + Components.BIAS_DAY_ASSISTANT => false, + + _ => true, + }; + public static string Name(this Components component) => component switch { Components.GRAMMAR_SPELLING_ASSISTANT => "Grammar & Spelling Assistant", diff --git a/app/MindWork AI Studio/wwwroot/changelog/v0.9.16.md b/app/MindWork AI Studio/wwwroot/changelog/v0.9.16.md index 4b1933e..f3e8b42 100644 --- a/app/MindWork AI Studio/wwwroot/changelog/v0.9.16.md +++ b/app/MindWork AI Studio/wwwroot/changelog/v0.9.16.md @@ -1,3 +1,4 @@ # v0.9.16, build 191 (2024-11-xx xx:xx UTC) - Added our second financial contributor: Thanks `peerschuett` for supporting AI Studio financially. -- Improved the layout of the app window, for example, in full-screen mode on large or high-resolution monitors. \ No newline at end of file +- Improved the layout of the app window, for example, in full-screen mode on large or high-resolution monitors. +- Fixed the "send to" issue, where you could select the bias-of-the-day assistant as destination. \ No newline at end of file