Reduced memory usage and fixed several memory leaks (#933)
Build and Release / Determine run mode (push) Has been cancelled
Build and Release / Read metadata (push) Has been cancelled
Build and Release / Sync Flatpak repo (push) Has been cancelled
Build and Release / Collect Flatpak artifacts (push) Has been cancelled
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg,app,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,updater, appimage) (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,app,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,updater, appimage) (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:
Thorsten Sommer authored and GitHub committed 2026-08-23 21:15:37 +02:00
1 parent 902a01a4d0
commit 7d9a4f5ab1
51 files changed
+531 -85

No files matched your search

@@ -14,7 +14,7 @@ using DialogOptions = AIStudio.Dialogs.DialogOptions;
namespace AIStudio.Components;
public partial class ChatComponent : MSGComponentBase, IAsyncDisposable
public partial class ChatComponent : MSGComponentBase
{
private readonly Guid draftMediaOwnerId = Guid.NewGuid();
private const string CHAT_INPUT_ID = "chat-user-input";
@@ -131,7 +131,7 @@ public partial class ChatComponent : MSGComponentBase, IAsyncDisposable
this.lastAppliedStandardDataSourceOptions = this.SettingsManager.ConfigurationData.Chat.PreselectedDataSourceOptions.CreateCopy();
var deferredInput = MessageBus.INSTANCE.CheckDeferredMessages<string>(Event.SEND_TO_CHAT_INPUT).FirstOrDefault();
var deferredInput = MessageBus.INSTANCE.TakeDeferredMessages<string>(Event.SEND_TO_CHAT_INPUT).LastOrDefault();
if (!string.IsNullOrWhiteSpace(deferredInput))
this.ComposerState.SetUserInput(deferredInput);
@@ -139,7 +139,7 @@ public partial class ChatComponent : MSGComponentBase, IAsyncDisposable
// Check for deferred messages of the kind 'SEND_TO_CHAT',
// aka the user sends an assistant result to the chat:
//
var deferredContent = MessageBus.INSTANCE.CheckDeferredMessages<ChatThread>(Event.SEND_TO_CHAT).FirstOrDefault();
var deferredContent = MessageBus.INSTANCE.TakeDeferredMessages<ChatThread>(Event.SEND_TO_CHAT).LastOrDefault();
if (deferredContent is not null)
{
//
@@ -234,7 +234,7 @@ public partial class ChatComponent : MSGComponentBase, IAsyncDisposable
// component sends a message to the chat component to load
// the chat with the bias:
//
var deferredLoading = MessageBus.INSTANCE.CheckDeferredMessages<LoadChat>(Event.LOAD_CHAT).FirstOrDefault();
var deferredLoading = MessageBus.INSTANCE.TakeDeferredMessages<LoadChat>(Event.LOAD_CHAT).LastOrDefault();
if (deferredLoading != default)
{
this.loadChat = deferredLoading;
@@ -1288,9 +1288,9 @@ public partial class ChatComponent : MSGComponentBase, IAsyncDisposable
#endregion
#region Implementation of IAsyncDisposable
#region Overrides of MSGComponentBase
public async ValueTask DisposeAsync()
protected override async ValueTask DisposeResourcesAsync()
{
this.MediaTranscriptionService.StateChanged -= this.OnMediaImportStateChanged;
if(this.SettingsManager.ConfigurationData.Workspace.StorageBehavior is WorkspaceStorageBehavior.STORE_CHATS_AUTOMATICALLY)
@@ -1300,7 +1300,6 @@ public partial class ChatComponent : MSGComponentBase, IAsyncDisposable
}
await this.AIJobService.SetForegroundAsync(AIJobKind.CHAT_GENERATION, this.foregroundChatId, false);
this.Dispose();
}
#endregion
@@ -5,7 +5,7 @@ using Microsoft.AspNetCore.Components;
namespace AIStudio.Components;
public abstract class MSGComponentBase : ComponentBase, IDisposable, IMessageBusReceiver, ILang
public abstract class MSGComponentBase : ComponentBase, IDisposable, IAsyncDisposable, IMessageBusReceiver, ILang
{
[Inject]
protected SettingsManager SettingsManager { get; init; } = null!;
@@ -103,10 +103,20 @@ public abstract class MSGComponentBase : ComponentBase, IDisposable, IMessageBus
this.MessageBus.ApplyFilters(this, filterComponents, eventsList.ToHashSet());
}
/// <summary>
/// Releases what this component has acquired. Override this instead of implementing
/// IDisposable again, so the deregistration from the message bus cannot be lost.
/// </summary>
protected virtual void DisposeResources()
{
}
/// <summary>
/// Releases what this component has acquired and needs an await to release. Override this
/// instead of implementing IAsyncDisposable, see the remarks on DisposeAsync below.
/// </summary>
protected virtual ValueTask DisposeResourcesAsync() => ValueTask.CompletedTask;
#region Implementation of IDisposable
public void Dispose()
@@ -116,4 +126,25 @@ public abstract class MSGComponentBase : ComponentBase, IDisposable, IMessageBus
}
#endregion
#region Implementation of IAsyncDisposable
/// <summary>
/// Releases this component asynchronously.
/// </summary>
/// <remarks>
/// This base class implements both ways of disposing on purpose. Blazor calls only DisposeAsync
/// when a component offers both, so a derived component which implements IAsyncDisposable on
/// its own would silently skip everything Dispose does — above all the deregistration from the
/// message bus, which holds a strong reference to every receiver. Deriving components override
/// DisposeResources or DisposeResourcesAsync instead, and this stays the one place which knows
/// about both.
/// </remarks>
public async ValueTask DisposeAsync()
{
await this.DisposeResourcesAsync();
this.Dispose();
}
#endregion
}