Fixed message bus issues (#268)

This commit is contained in:
Thorsten Sommer 2025-01-21 15:36:22 +01:00 committed by GitHub
parent cf975f2a6c
commit be408a6aee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with 47 additions and 4 deletions

View File

@ -147,6 +147,8 @@ public abstract partial class AssistantBase : ComponentBase, IMessageBusReceiver
#region Implementation of IMessageBusReceiver
public string ComponentName => nameof(AssistantBase);
public Task ProcessMessage<T>(ComponentBase? sendingComponent, Event triggeredEvent, T? data)
{
switch (triggeredEvent)

View File

@ -44,6 +44,8 @@ public partial class AssistantBlock : ComponentBase, IMessageBusReceiver, IDispo
#region Implementation of IMessageBusReceiver
public string ComponentName => nameof(AssistantBlock);
public Task ProcessMessage<T>(ComponentBase? sendingComponent, Event triggeredEvent, T? data)
{
switch (triggeredEvent)

View File

@ -525,9 +525,19 @@ public partial class ChatComponent : MSGComponentBase, IAsyncDisposable
this.isStreaming = false;
this.hasUnsavedChanges = false;
this.userInput = string.Empty;
this.currentWorkspaceId = this.ChatThread?.WorkspaceId ?? Guid.Empty;
this.currentWorkspaceName = this.ChatThread is null ? string.Empty : await WorkspaceBehaviour.LoadWorkspaceName(this.ChatThread.WorkspaceId);
this.WorkspaceName(this.currentWorkspaceName);
if (this.ChatThread is not null)
{
this.currentWorkspaceId = this.ChatThread.WorkspaceId;
this.currentWorkspaceName = await WorkspaceBehaviour.LoadWorkspaceName(this.ChatThread.WorkspaceId);
this.WorkspaceName(this.currentWorkspaceName);
}
else
{
this.currentWorkspaceId = Guid.Empty;
this.currentWorkspaceName = string.Empty;
this.WorkspaceName(this.currentWorkspaceName);
}
await this.SelectProviderWhenLoadingChat();
if (this.SettingsManager.ConfigurationData.Chat.ShowLatestMessageAfterLoading)
@ -653,6 +663,8 @@ public partial class ChatComponent : MSGComponentBase, IAsyncDisposable
#region Overrides of MSGComponentBase
public override string ComponentName => nameof(ChatComponent);
public override async Task ProcessIncomingMessage<T>(ComponentBase? sendingComponent, Event triggeredEvent, T? data) where T : default
{
switch (triggeredEvent)
@ -692,6 +704,7 @@ public partial class ChatComponent : MSGComponentBase, IAsyncDisposable
public async ValueTask DisposeAsync()
{
this.MessageBus.Unregister(this);
if(this.SettingsManager.ConfigurationData.Workspace.StorageBehavior is WorkspaceStorageBehavior.STORE_CHATS_AUTOMATICALLY)
{
await this.SaveThread();

View File

@ -63,6 +63,8 @@ public partial class ConfidenceInfo : ComponentBase, IMessageBusReceiver, IDispo
#region Implementation of IMessageBusReceiver
public string ComponentName => nameof(ConfidenceInfo);
public Task ProcessMessage<T>(ComponentBase? sendingComponent, Event triggeredEvent, T? data)
{
switch (triggeredEvent)

View File

@ -57,6 +57,8 @@ public partial class ConfigurationBase : ComponentBase, IMessageBusReceiver, IDi
#region Implementation of IMessageBusReceiver
public string ComponentName => nameof(ConfigurationBase);
public Task ProcessMessage<TMsg>(ComponentBase? sendingComponent, Event triggeredEvent, TMsg? data)
{
switch (triggeredEvent)

View File

@ -60,6 +60,8 @@ public partial class ConfigurationProviderSelection : ComponentBase, IMessageBus
#region Implementation of IMessageBusReceiver
public string ComponentName => nameof(ConfigurationProviderSelection);
public async Task ProcessMessage<T>(ComponentBase? sendingComponent, Event triggeredEvent, T? data)
{
switch (triggeredEvent)

View File

@ -50,6 +50,8 @@ public partial class InnerScrolling : MSGComponentBase
#region Overrides of MSGComponentBase
public override string ComponentName => nameof(InnerScrolling);
public override Task ProcessIncomingMessage<T>(ComponentBase? sendingComponent, Event triggeredEvent, T? data) where T : default
{
switch (triggeredEvent)

View File

@ -24,6 +24,8 @@ public abstract class MSGComponentBase : ComponentBase, IDisposable, IMessageBus
#region Implementation of IMessageBusReceiver
public abstract string ComponentName { get; }
public Task ProcessMessage<T>(ComponentBase? sendingComponent, Event triggeredEvent, T? data)
{
switch (triggeredEvent)

View File

@ -136,6 +136,8 @@ public partial class MainLayout : LayoutComponentBase, IMessageBusReceiver, IDis
#region Implementation of IMessageBusReceiver
public string ComponentName => nameof(MainLayout);
public async Task ProcessMessage<T>(ComponentBase? sendingComponent, Event triggeredEvent, T? data)
{
switch (triggeredEvent)

View File

@ -28,6 +28,8 @@ public partial class Chat : MSGComponentBase
protected override async Task OnInitializedAsync()
{
this.ApplyFilters([], [ Event.WORKSPACE_TOGGLE_OVERLAY ]);
this.splitterPosition = this.SettingsManager.ConfigurationData.Workspace.SplitterPosition;
this.splitterSaveTimer.AutoReset = false;
this.splitterSaveTimer.Elapsed += async (_, _) =>
@ -74,6 +76,8 @@ public partial class Chat : MSGComponentBase
#region Overrides of MSGComponentBase
public override string ComponentName => nameof(Chat);
public override Task ProcessIncomingMessage<T>(ComponentBase? sendingComponent, Event triggeredEvent, T? data) where T : default
{
switch (triggeredEvent)

View File

@ -28,6 +28,8 @@ public partial class Settings : ComponentBase, IMessageBusReceiver, IDisposable
#region Implementation of IMessageBusReceiver
public string ComponentName => nameof(Settings);
public Task ProcessMessage<TMsg>(ComponentBase? sendingComponent, Event triggeredEvent, TMsg? data)
{
switch (triggeredEvent)

View File

@ -41,6 +41,8 @@ public partial class Writer : MSGComponentBase, IAsyncDisposable
#region Overrides of MSGComponentBase
public override string ComponentName => nameof(Writer);
public override Task ProcessIncomingMessage<T>(ComponentBase? sendingComponent, Event triggeredEvent, T? data) where T : default
{
return Task.CompletedTask;

View File

@ -4,6 +4,8 @@ namespace AIStudio.Tools;
public interface IMessageBusReceiver
{
public string ComponentName { get; }
public Task ProcessMessage<T>(ComponentBase? sendingComponent, Event triggeredEvent, T? data);
public Task<TResult?> ProcessMessageWithResult<TPayload, TResult>(ComponentBase? sendingComponent, Event triggeredEvent, TPayload? data);

View File

@ -60,6 +60,8 @@ public sealed class UpdateService : BackgroundService, IMessageBusReceiver
#region Implementation of IMessageBusReceiver
public string ComponentName => nameof(UpdateService);
public async Task ProcessMessage<T>(ComponentBase? sendingComponent, Event triggeredEvent, T? data)
{
switch (triggeredEvent)

View File

@ -1,4 +1,6 @@
# v0.9.27, build 202 (2025-01-xx xx:xx UTC)
- Improved the inner content scrolling to use the entire space available.
- Improved message process debugging. This helps to identify issues related to the message handling.
- Fixed the hostname validation message for ERI v1 data sources.
- Fixed a memory leak in the chat component.
- Removed the "send to" button from the ERI server assistant, since it is not supported.