From 54588fc92d8eadc8855186da805473c5a0ad2918 Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Sun, 8 Sep 2024 22:53:34 +0200 Subject: [PATCH] Fixed the bug where the user input was not cleared in the chat (#134) --- app/MindWork AI Studio/Pages/Chat.razor.cs | 16 +++++++++------- .../wwwroot/changelog/v0.9.7.md | 1 + 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app/MindWork AI Studio/Pages/Chat.razor.cs b/app/MindWork AI Studio/Pages/Chat.razor.cs index 5960b5c..96dcc98 100644 --- a/app/MindWork AI Studio/Pages/Chat.razor.cs +++ b/app/MindWork AI Studio/Pages/Chat.razor.cs @@ -47,9 +47,8 @@ public partial class Chat : MSGComponentBase, IAsyncDisposable private bool mustScrollToBottomAfterRender; private byte scrollRenderCountdown; - // Unfortunately, we need the input field reference to clear it after sending a message. - // This is necessary because we have to handle the key events ourselves. Otherwise, - // the clearing would be done automatically. + // Unfortunately, we need the input field reference to blur the focus away. Without + // this, we cannot clear the input field. private MudTextField inputField = null!; #region Overrides of ComponentBase @@ -142,6 +141,10 @@ public partial class Chat : MSGComponentBase, IAsyncDisposable if (!this.IsProviderSelected) return; + // We need to blur the focus away from the input field + // to be able to clear the field: + await this.inputField.BlurAsync(); + // Create a new chat thread if necessary: var threadName = this.ExtractThreadName(this.userInput); @@ -210,7 +213,6 @@ public partial class Chat : MSGComponentBase, IAsyncDisposable }); // Clear the input field: - await this.inputField.Clear(); this.userInput = string.Empty; // Enable the stream state for the chat component: @@ -358,7 +360,7 @@ public partial class Chat : MSGComponentBase, IAsyncDisposable }; } - await this.inputField.Clear(); + this.userInput = string.Empty; } private async Task MoveChatToWorkspace() @@ -427,8 +429,8 @@ public partial class Chat : MSGComponentBase, IAsyncDisposable this.userInput = string.Empty; this.currentWorkspaceId = this.chatThread?.WorkspaceId ?? Guid.Empty; this.currentWorkspaceName = this.chatThread is null ? string.Empty : await this.workspaces.LoadWorkspaceName(this.chatThread.WorkspaceId); - - await this.inputField.Clear(); + + this.userInput = string.Empty; if (this.SettingsManager.ConfigurationData.Chat.ShowLatestMessageAfterLoading) { this.mustScrollToBottomAfterRender = true; diff --git a/app/MindWork AI Studio/wwwroot/changelog/v0.9.7.md b/app/MindWork AI Studio/wwwroot/changelog/v0.9.7.md index 06abf03..90fa66e 100644 --- a/app/MindWork AI Studio/wwwroot/changelog/v0.9.7.md +++ b/app/MindWork AI Studio/wwwroot/changelog/v0.9.7.md @@ -5,6 +5,7 @@ - Added the possibility to preselect any of your profiles as the default profile for the entire app or configure individual profiles for assistants and chats. - Added an introductory description to the provider settings. - Added an indicator for the current and maximal length of the provider instance name. +- Fixed the annoying bug that input made in the chat interface was not cleared when sending the message using hotkeys. - Fixed the bug that the model name for Fireworks was not loaded when editing the provider settings. - Fixed a bug where it was possible that the chat interface was not scrolling to the bottom when new messages were added. - Improved hyphenation for continuous text so that the rules of the respective language are taken into account where possible.