From 978a50eb3ca75e4d82e272d4321495a21e7b5970 Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Sun, 27 Oct 2024 14:00:20 +0100 Subject: [PATCH] Don't generate a name, when already present --- app/MindWork AI Studio/Pages/Chat.razor.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/app/MindWork AI Studio/Pages/Chat.razor.cs b/app/MindWork AI Studio/Pages/Chat.razor.cs index c5d3180b..e77b285b 100644 --- a/app/MindWork AI Studio/Pages/Chat.razor.cs +++ b/app/MindWork AI Studio/Pages/Chat.razor.cs @@ -68,14 +68,17 @@ public partial class Chat : MSGComponentBase, IAsyncDisposable this.chatThread = deferredContent; if (this.chatThread is not null) { - var firstUserBlock = this.chatThread.Blocks.FirstOrDefault(x => x.Role == ChatRole.USER); - if (firstUserBlock is not null) + if (string.IsNullOrWhiteSpace(this.chatThread.Name)) { - this.chatThread.Name = firstUserBlock.Content switch + var firstUserBlock = this.chatThread.Blocks.FirstOrDefault(x => x.Role == ChatRole.USER); + if (firstUserBlock is not null) { - ContentText textBlock => this.ExtractThreadName(textBlock.Text), - _ => "Thread" - }; + this.chatThread.Name = firstUserBlock.Content switch + { + ContentText textBlock => this.ExtractThreadName(textBlock.Text), + _ => "Thread" + }; + } } }