mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-17 19:18:00 +00:00
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
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:
1 parent
902a01a4d0
commit
7d9a4f5ab1
51 files changed
+531
-85
No files matched your search
@@ -270,7 +270,7 @@ public partial class AssistantAgenda : AssistantBaseCore<SettingsDialogAgenda>
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
var deferredContent = MessageBus.INSTANCE.CheckDeferredMessages<string>(Event.SEND_TO_AGENDA_ASSISTANT).FirstOrDefault();
|
||||
var deferredContent = MessageBus.INSTANCE.TakeDeferredMessages<string>(Event.SEND_TO_AGENDA_ASSISTANT).LastOrDefault();
|
||||
if (deferredContent is not null)
|
||||
this.inputContent = deferredContent;
|
||||
|
||||
|
||||
@@ -478,6 +478,12 @@ public abstract partial class AssistantBase<TSettings> : AssistantLowerBase wher
|
||||
this.CancellationTokenSource?.Dispose();
|
||||
this.CancellationTokenSource = null;
|
||||
}
|
||||
|
||||
//
|
||||
// The handlers above close over this assistant, and the content stays in the chat
|
||||
// thread. The stream is over by now, so nothing has to listen to it anymore:
|
||||
//
|
||||
aiText.ResetStreamingHandlers();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+13
-3
@@ -15,15 +15,15 @@ public partial class AssistantBatchProcessing
|
||||
{
|
||||
return IsTranscribableMedia(fileResult.FilePath)
|
||||
? this.LoadMediaTranscriptAsync(fileResult, token)
|
||||
: this.LoadDocumentContentAsync(fileResult);
|
||||
: this.LoadDocumentContentAsync(fileResult, token);
|
||||
}
|
||||
|
||||
private async Task<string?> LoadDocumentContentAsync(BatchProcessingFileResult fileResult)
|
||||
private async Task<string?> LoadDocumentContentAsync(BatchProcessingFileResult fileResult, CancellationToken token)
|
||||
{
|
||||
FileExtractionResult extraction;
|
||||
try
|
||||
{
|
||||
extraction = await this.RustService.ReadArbitraryFileData(fileResult.FilePath, int.MaxValue);
|
||||
extraction = await this.RustService.ReadArbitraryFileData(fileResult.FilePath, int.MaxValue, token: token);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -31,6 +31,16 @@ public partial class AssistantBatchProcessing
|
||||
return null;
|
||||
}
|
||||
|
||||
//
|
||||
// The user stopped the batch run while we were reading this file. That says nothing about
|
||||
// the file, so it gets the same status as a cancelled AI request instead of a failure:
|
||||
//
|
||||
if (extraction.ErrorCode is FileExtractionErrorCode.CANCELLED)
|
||||
{
|
||||
this.FinishFileResult(fileResult, BatchProcessingFileStatus.CANCELED, T("The batch run was canceled."));
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!extraction.HasUsableContent)
|
||||
{
|
||||
this.Logger.LogError("Reading the batch file '{FilePath}' failed: code={ErrorCode}, message='{ErrorMessage}'.", fileResult.FilePath, extraction.ErrorCode, extraction.ErrorMessage);
|
||||
|
||||
@@ -143,7 +143,7 @@ public partial class AssistantCoding : AssistantBaseCore<SettingsDialogCoding>
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
var deferredContent = MessageBus.INSTANCE.CheckDeferredMessages<string>(Event.SEND_TO_CODING_ASSISTANT).FirstOrDefault();
|
||||
var deferredContent = MessageBus.INSTANCE.TakeDeferredMessages<string>(Event.SEND_TO_CODING_ASSISTANT).LastOrDefault();
|
||||
if (deferredContent is not null)
|
||||
this.questions = deferredContent;
|
||||
|
||||
|
||||
@@ -124,7 +124,7 @@ public partial class AssistantEMail : AssistantBaseCore<SettingsDialogWritingEMa
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
var deferredContent = MessageBus.INSTANCE.CheckDeferredMessages<string>(Event.SEND_TO_EMAIL_ASSISTANT).FirstOrDefault();
|
||||
var deferredContent = MessageBus.INSTANCE.TakeDeferredMessages<string>(Event.SEND_TO_EMAIL_ASSISTANT).LastOrDefault();
|
||||
if (deferredContent is not null)
|
||||
this.inputBulletPoints = deferredContent;
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ public partial class AssistantGrammarSpelling : AssistantBaseCore<SettingsDialog
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
var deferredContent = MessageBus.INSTANCE.CheckDeferredMessages<string>(Event.SEND_TO_GRAMMAR_SPELLING_ASSISTANT).FirstOrDefault();
|
||||
var deferredContent = MessageBus.INSTANCE.TakeDeferredMessages<string>(Event.SEND_TO_GRAMMAR_SPELLING_ASSISTANT).LastOrDefault();
|
||||
if (deferredContent is not null)
|
||||
this.inputText = deferredContent;
|
||||
|
||||
|
||||
@@ -5698,6 +5698,9 @@ UI_TEXT_CONTENT["AISTUDIO::DIALOGS::DOCUMENTCHECKDIALOG::T2129302565"] = "Load f
|
||||
-- Image View
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::DOCUMENTCHECKDIALOG::T2199753423"] = "Image View"
|
||||
|
||||
-- Your document is large, so we show you only its beginning. We hide the remaining {0:N0} characters here. Rest assured: the AI still receives your entire document.
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::DOCUMENTCHECKDIALOG::T2468296835"] = "Your document is large, so we show you only its beginning. We hide the remaining {0:N0} characters here. Rest assured: the AI still receives your entire document."
|
||||
|
||||
-- See how we load your file. Review the content before we process it further.
|
||||
UI_TEXT_CONTENT["AISTUDIO::DIALOGS::DOCUMENTCHECKDIALOG::T3271853346"] = "See how we load your file. Review the content before we process it further."
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ public partial class AssistantIconFinder : AssistantBaseCore<SettingsDialogIconF
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
var deferredContent = MessageBus.INSTANCE.CheckDeferredMessages<string>(Event.SEND_TO_ICON_FINDER_ASSISTANT).FirstOrDefault();
|
||||
var deferredContent = MessageBus.INSTANCE.TakeDeferredMessages<string>(Event.SEND_TO_ICON_FINDER_ASSISTANT).LastOrDefault();
|
||||
if (deferredContent is not null)
|
||||
this.inputContext = deferredContent;
|
||||
|
||||
|
||||
@@ -177,7 +177,7 @@ public partial class AssistantJobPostings : AssistantBaseCore<SettingsDialogJobP
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
var deferredContent = MessageBus.INSTANCE.CheckDeferredMessages<string>(Event.SEND_TO_JOB_POSTING_ASSISTANT).FirstOrDefault();
|
||||
var deferredContent = MessageBus.INSTANCE.TakeDeferredMessages<string>(Event.SEND_TO_JOB_POSTING_ASSISTANT).LastOrDefault();
|
||||
if (deferredContent is not null)
|
||||
this.inputJobDescription = deferredContent;
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ public partial class AssistantLegalCheck : AssistantBaseCore<SettingsDialogLegal
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
var deferredContent = MessageBus.INSTANCE.CheckDeferredMessages<string>(Event.SEND_TO_LEGAL_CHECK_ASSISTANT).FirstOrDefault();
|
||||
var deferredContent = MessageBus.INSTANCE.TakeDeferredMessages<string>(Event.SEND_TO_LEGAL_CHECK_ASSISTANT).LastOrDefault();
|
||||
if (deferredContent is not null)
|
||||
this.inputQuestions = deferredContent;
|
||||
|
||||
|
||||
@@ -139,7 +139,7 @@ public partial class AssistantMyTasks : AssistantBaseCore<SettingsDialogMyTasks>
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
var deferredContent = MessageBus.INSTANCE.CheckDeferredMessages<string>(Event.SEND_TO_MY_TASKS_ASSISTANT).FirstOrDefault();
|
||||
var deferredContent = MessageBus.INSTANCE.TakeDeferredMessages<string>(Event.SEND_TO_MY_TASKS_ASSISTANT).LastOrDefault();
|
||||
if (deferredContent is not null)
|
||||
this.inputText = deferredContent;
|
||||
|
||||
|
||||
@@ -152,7 +152,7 @@ public partial class AssistantPromptOptimizer : AssistantBaseCore<SettingsDialog
|
||||
this.ResetGuidelineSummaryToDefault();
|
||||
this.hasUpdatedDefaultRecommendations = false;
|
||||
|
||||
var deferredContent = MessageBus.INSTANCE.CheckDeferredMessages<string>(Event.SEND_TO_PROMPT_OPTIMIZER_ASSISTANT).FirstOrDefault();
|
||||
var deferredContent = MessageBus.INSTANCE.TakeDeferredMessages<string>(Event.SEND_TO_PROMPT_OPTIMIZER_ASSISTANT).LastOrDefault();
|
||||
if (deferredContent is not null)
|
||||
this.inputPrompt = deferredContent;
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ public partial class AssistantRewriteImprove : AssistantBaseCore<SettingsDialogR
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
var deferredContent = MessageBus.INSTANCE.CheckDeferredMessages<string>(Event.SEND_TO_REWRITE_ASSISTANT).FirstOrDefault();
|
||||
var deferredContent = MessageBus.INSTANCE.TakeDeferredMessages<string>(Event.SEND_TO_REWRITE_ASSISTANT).LastOrDefault();
|
||||
if (deferredContent is not null)
|
||||
this.inputText = deferredContent;
|
||||
|
||||
|
||||
@@ -256,7 +256,7 @@ public partial class SlideAssistant : AssistantBaseCore<SettingsDialogSlideBuild
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
var deferredContent = MessageBus.INSTANCE.CheckDeferredMessages<string>(Event.SEND_TO_SLIDE_BUILDER_ASSISTANT).FirstOrDefault();
|
||||
var deferredContent = MessageBus.INSTANCE.TakeDeferredMessages<string>(Event.SEND_TO_SLIDE_BUILDER_ASSISTANT).LastOrDefault();
|
||||
if (deferredContent is not null)
|
||||
this.inputContent = deferredContent;
|
||||
|
||||
|
||||
@@ -131,7 +131,7 @@ public partial class AssistantSynonyms : AssistantBaseCore<SettingsDialogSynonym
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
var deferredContent = MessageBus.INSTANCE.CheckDeferredMessages<string>(Event.SEND_TO_SYNONYMS_ASSISTANT).FirstOrDefault();
|
||||
var deferredContent = MessageBus.INSTANCE.TakeDeferredMessages<string>(Event.SEND_TO_SYNONYMS_ASSISTANT).LastOrDefault();
|
||||
if (deferredContent is not null)
|
||||
this.inputContext = deferredContent;
|
||||
|
||||
|
||||
@@ -115,7 +115,7 @@ public partial class AssistantTextSummarizer : AssistantBaseCore<SettingsDialogT
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
var deferredContent = MessageBus.INSTANCE.CheckDeferredMessages<string>(Event.SEND_TO_TEXT_SUMMARIZER_ASSISTANT).FirstOrDefault();
|
||||
var deferredContent = MessageBus.INSTANCE.TakeDeferredMessages<string>(Event.SEND_TO_TEXT_SUMMARIZER_ASSISTANT).LastOrDefault();
|
||||
if (deferredContent is not null)
|
||||
this.inputText = deferredContent;
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ public partial class AssistantTranslation : AssistantBaseCore<SettingsDialogTran
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
var deferredContent = MessageBus.INSTANCE.CheckDeferredMessages<string>(Event.SEND_TO_TRANSLATION_ASSISTANT).FirstOrDefault();
|
||||
var deferredContent = MessageBus.INSTANCE.TakeDeferredMessages<string>(Event.SEND_TO_TRANSLATION_ASSISTANT).LastOrDefault();
|
||||
if (deferredContent is not null)
|
||||
this.inputText = deferredContent;
|
||||
|
||||
|
||||
+5
@@ -138,6 +138,11 @@ public partial class VisualBriefingAssistant
|
||||
this.MediaTranscriptionService.ClearOwnerState(MediaImportOwner.ForVisualBriefing(id));
|
||||
await this.Store.DeleteAsync(id);
|
||||
await this.Store.ForgetSelectionAsync(id);
|
||||
|
||||
// The briefing is gone, so neither its build state nor its progress snapshot is of use:
|
||||
this.BuildOrchestrator.ForgetBriefing(id);
|
||||
this.BuildProgressService.Forget(id);
|
||||
|
||||
this.ClearSelectedProject();
|
||||
|
||||
await this.ReloadListAsync();
|
||||
|
||||
@@ -158,7 +158,7 @@ public partial class VisualBriefingAssistant : MSGComponentBase
|
||||
await this.ReloadListAsync();
|
||||
await this.ConsumePendingMediaOutcomesAsync();
|
||||
_ = this.MonitorSourceStatusAsync(this.sourceMonitorCancellation.Token);
|
||||
var deferredInstruction = this.MessageBus.CheckDeferredMessages<string>(Event.SEND_TO_VISUAL_BRIEFING_ASSISTANT).FirstOrDefault();
|
||||
var deferredInstruction = this.MessageBus.TakeDeferredMessages<string>(Event.SEND_TO_VISUAL_BRIEFING_ASSISTANT).LastOrDefault();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(deferredInstruction))
|
||||
{
|
||||
|
||||
@@ -63,6 +63,21 @@ internal sealed partial class VisualBriefingBuildOrchestrator
|
||||
public VisualBriefingOperationDiagnostics? GetDiagnostics(Guid briefingId) =>
|
||||
this.liveDiagnostics.GetValueOrDefault(briefingId);
|
||||
|
||||
/// <summary>
|
||||
/// Drops what we kept for a briefing which does not exist anymore.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Both dictionaries only ever grew: every briefing which was built once stayed in them for as
|
||||
/// long as the app was running. The build lock is not disposed, because another build might
|
||||
/// still wait on it.
|
||||
/// </remarks>
|
||||
/// <param name="briefingId">The identifier of the deleted briefing.</param>
|
||||
public void ForgetBriefing(Guid briefingId)
|
||||
{
|
||||
this.buildLocks.TryRemove(briefingId, out _);
|
||||
this.liveDiagnostics.TryRemove(briefingId, out _);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Builds or resumes a visual briefing operation.
|
||||
/// </summary>
|
||||
|
||||
+10
@@ -33,4 +33,14 @@ public sealed class VisualBriefingBuildProgressService
|
||||
/// </summary>
|
||||
public VisualBriefingBuildRecord? GetLatest(Guid briefingId) =>
|
||||
this.latest.GetValueOrDefault(briefingId);
|
||||
|
||||
/// <summary>
|
||||
/// Drops the snapshot of a briefing which does not exist anymore.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// A snapshot is a complete build record. Without this, every briefing which was ever built
|
||||
/// kept one for as long as the app was running.
|
||||
/// </remarks>
|
||||
/// <param name="briefingId">The identifier of the deleted briefing.</param>
|
||||
public void Forget(Guid briefingId) => this.latest.TryRemove(briefingId, out _);
|
||||
}
|
||||
@@ -398,6 +398,7 @@ public sealed partial class VisualBriefingStore
|
||||
finally
|
||||
{
|
||||
gate.Release();
|
||||
this.ForgetLock(briefingId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -167,6 +167,16 @@ public sealed partial class VisualBriefingStore(
|
||||
/// </summary>
|
||||
private SemaphoreSlim GetLock(Guid briefingId) => this.briefingLocks.GetOrAdd(briefingId, _ => new(1, 1));
|
||||
|
||||
/// <summary>
|
||||
/// Drops the lock of a briefing which does not exist anymore.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Otherwise, this dictionary keeps one entry per briefing the app ever touched. We do not
|
||||
/// dispose the semaphore: another operation might still wait on it, and disposing it under
|
||||
/// their feet would turn a deleted briefing into an exception somewhere else.
|
||||
/// </remarks>
|
||||
private void ForgetLock(Guid briefingId) => this.briefingLocks.TryRemove(briefingId, out _);
|
||||
|
||||
/// <summary>
|
||||
/// Defines <c>BriefingDirectory</c> for the visual briefing feature.
|
||||
/// </summary>
|
||||
|
||||
Reference in new issue
Block a user