mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-18 00:57:59 +00:00
Hardened background work against disconnected circuits (#937)
This commit is contained in:
1 parent
99089f853e
commit
f03c2d1c88
44 files changed
+500
-126
No files matched your search
@@ -170,10 +170,15 @@ public abstract partial class AssistantBase<TSettings> : AssistantLowerBase wher
|
||||
}
|
||||
|
||||
this.formChangeTimer.AutoReset = false;
|
||||
this.formChangeTimer.Elapsed += async (_, _) =>
|
||||
//
|
||||
// Mind the missing async here: a timer hands its elapsed event to a thread pool thread, where an
|
||||
// async handler has nobody to hand its exception to. Such an exception is not merely unobserved,
|
||||
// it is unhandled, and it takes the app down with it. Observing the task keeps it contained.
|
||||
//
|
||||
this.formChangeTimer.Elapsed += (_, _) =>
|
||||
{
|
||||
this.formChangeTimer.Stop();
|
||||
await this.OnFormChange();
|
||||
this.OnFormChange().Observe($"{nameof(AssistantBase<TSettings>)}: handling a form change");
|
||||
};
|
||||
|
||||
this.MightPreselectValues();
|
||||
@@ -327,7 +332,7 @@ public abstract partial class AssistantBase<TSettings> : AssistantLowerBase wher
|
||||
Array.Resize(ref this.InputIssues, this.InputIssues.Length + 1);
|
||||
this.InputIssues[^1] = issue;
|
||||
this.InputIsValid = false;
|
||||
_ = this.RefreshAssistantUIAsync();
|
||||
this.RefreshAssistantUIAsync().Observe($"{nameof(AssistantBase<TSettings>)}: rendering an added input issue");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -337,7 +342,7 @@ public abstract partial class AssistantBase<TSettings> : AssistantLowerBase wher
|
||||
{
|
||||
this.InputIssues = [];
|
||||
this.InputIsValid = true;
|
||||
_ = this.RefreshAssistantUIAsync();
|
||||
this.RefreshAssistantUIAsync().Observe($"{nameof(AssistantBase<TSettings>)}: rendering cleared input issues");
|
||||
}
|
||||
|
||||
protected void CreateChatThread()
|
||||
@@ -733,11 +738,11 @@ public abstract partial class AssistantBase<TSettings> : AssistantLowerBase wher
|
||||
private void OnMediaImportStateChanged(MediaImportOwner owner)
|
||||
{
|
||||
if (owner == this.CurrentMediaImportOwner)
|
||||
_ = this.InvokeAsync(async () =>
|
||||
this.InvokeAsync(async () =>
|
||||
{
|
||||
await this.ConsumeMediaOutcomeAsync();
|
||||
this.StateHasChanged();
|
||||
});
|
||||
}).Observe($"{nameof(AssistantBase<TSettings>)}: consuming a media import outcome");
|
||||
}
|
||||
|
||||
/// <summary>Consumes a terminal media notification when this assistant is visible.</summary>
|
||||
|
||||
@@ -90,7 +90,7 @@ public partial class AssistantI18N : AssistantBaseCore<SettingsDialogI18N>
|
||||
this.customTargetLanguage = string.Empty;
|
||||
}
|
||||
|
||||
_ = this.OnChangedLanguage();
|
||||
this.OnChangedLanguage().Observe($"{nameof(AssistantI18N)}: applying a language change");
|
||||
}
|
||||
|
||||
protected override bool MightPreselectValues()
|
||||
|
||||
@@ -460,7 +460,7 @@ public partial class AssistantLogViewer : MSGComponentBase
|
||||
{
|
||||
this.StopAutoRefresh();
|
||||
this.autoRefreshCancellationTokenSource = new CancellationTokenSource();
|
||||
_ = this.AutoRefreshLoopAsync(this.autoRefreshCancellationTokenSource.Token);
|
||||
this.AutoRefreshLoopAsync(this.autoRefreshCancellationTokenSource.Token).Observe($"{nameof(AssistantLogViewer)}: refreshing the log automatically");
|
||||
}
|
||||
|
||||
private void StopAutoRefresh()
|
||||
|
||||
+2
-2
@@ -246,14 +246,14 @@ public partial class VisualBriefingAssistant
|
||||
if (this.selectedBriefing?.BriefingId != briefingId)
|
||||
return;
|
||||
|
||||
_ = this.InvokeAsync(() =>
|
||||
this.InvokeAsync(() =>
|
||||
{
|
||||
if (this.selectedBriefing?.BriefingId != briefingId)
|
||||
return;
|
||||
|
||||
this.latestBuild = this.BuildProgressService.GetLatest(briefingId);
|
||||
this.StateHasChanged();
|
||||
});
|
||||
}).Observe($"{nameof(VisualBriefingAssistant)}: rendering the build progress");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
+1
-1
@@ -265,7 +265,7 @@ public partial class VisualBriefingAssistant
|
||||
: briefing.Versions.OrderByDescending(version => version.VersionNumber).FirstOrDefault()?.RevisionId ?? Guid.Empty;
|
||||
|
||||
if (revisionId != Guid.Empty)
|
||||
_ = this.SelectRevisionAsync(revisionId);
|
||||
this.SelectRevisionAsync(revisionId).Observe($"{nameof(VisualBriefingAssistant)}: selecting a revision");
|
||||
else
|
||||
{
|
||||
this.selectedRevisionId = Guid.Empty;
|
||||
|
||||
+2
-2
@@ -136,7 +136,7 @@ public partial class VisualBriefingAssistant
|
||||
!Guid.TryParse(owner.Id, out var briefingId))
|
||||
return;
|
||||
|
||||
_ = this.InvokeAsync(async () =>
|
||||
this.InvokeAsync(async () =>
|
||||
{
|
||||
await this.ConsumeMediaOutcomeAsync(owner);
|
||||
if (!this.MediaTranscriptionService.IsBusy(owner))
|
||||
@@ -152,7 +152,7 @@ public partial class VisualBriefingAssistant
|
||||
}
|
||||
|
||||
this.StateHasChanged();
|
||||
});
|
||||
}).Observe($"{nameof(VisualBriefingAssistant)}: consuming a media import outcome");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -157,7 +157,7 @@ public partial class VisualBriefingAssistant : MSGComponentBase
|
||||
this.BuildProgressService.Changed += this.BuildProgressChanged;
|
||||
await this.ReloadListAsync();
|
||||
await this.ConsumePendingMediaOutcomesAsync();
|
||||
_ = this.MonitorSourceStatusAsync(this.sourceMonitorCancellation.Token);
|
||||
this.MonitorSourceStatusAsync(this.sourceMonitorCancellation.Token).Observe($"{nameof(VisualBriefingAssistant)}: monitoring the source status");
|
||||
var deferredInstruction = this.MessageBus.TakeDeferredMessages<string>(Event.SEND_TO_VISUAL_BRIEFING_ASSISTANT).LastOrDefault();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(deferredInstruction))
|
||||
|
||||
+1
-1
@@ -56,7 +56,7 @@ public partial class VisualBriefingBuildProgress : MSGComponentBase
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await base.OnInitializedAsync();
|
||||
_ = this.MonitorBuildDurationAsync(this.durationMonitorCancellation.Token);
|
||||
this.MonitorBuildDurationAsync(this.durationMonitorCancellation.Token).Observe($"{nameof(VisualBriefingBuildProgress)}: monitoring the build duration");
|
||||
}
|
||||
|
||||
protected override void OnParametersSet()
|
||||
|
||||
Reference in new issue
Block a user