Files
meeting-assistant/MeetingAssistant/Summary/MeetingSummaryRetryRunner.cs
T
codex 7777b349a5
PR and Push Build/Test / build-and-test (push) Successful in 6m37s
Archive summary refinements and profile switching
2026-05-27 23:11:21 +02:00

98 lines
3.2 KiB
C#

using MeetingAssistant.MeetingNotes;
namespace MeetingAssistant.Summary;
public interface IMeetingSummaryRetryRunner
{
Task<MeetingSummaryRetryTriggerResult?> TriggerAsync(
string summaryPath,
MeetingAssistantOptions options,
CancellationToken cancellationToken);
}
public sealed record MeetingSummaryRetryTriggerResult(
string SummaryPath,
string AssistantContextPath);
public sealed class MeetingSummaryRetryRunner : IMeetingSummaryRetryRunner
{
private readonly IMeetingSummaryArtifactResolver artifactResolver;
private readonly IMeetingSummaryPipeline summaryPipeline;
private readonly IMeetingArtifactStore artifactStore;
private readonly ILogger<MeetingSummaryRetryRunner> logger;
public MeetingSummaryRetryRunner(
IMeetingSummaryArtifactResolver artifactResolver,
IMeetingSummaryPipeline summaryPipeline,
IMeetingArtifactStore artifactStore,
ILogger<MeetingSummaryRetryRunner> logger)
{
this.artifactResolver = artifactResolver;
this.summaryPipeline = summaryPipeline;
this.artifactStore = artifactStore;
this.logger = logger;
}
public async Task<MeetingSummaryRetryTriggerResult?> TriggerAsync(
string summaryPath,
MeetingAssistantOptions options,
CancellationToken cancellationToken)
{
var artifacts = await artifactResolver.ResolveBySummaryPathAsync(
summaryPath,
options,
cancellationToken);
if (artifacts is null)
{
return null;
}
_ = Task.Run(() => RunRetryAsync(artifacts, options), CancellationToken.None);
return new MeetingSummaryRetryTriggerResult(
artifacts.SummaryPath,
artifacts.AssistantContextPath);
}
private async Task RunRetryAsync(
MeetingSessionArtifacts artifacts,
MeetingAssistantOptions options)
{
try
{
await artifactStore.UpdateAssistantContextStateAsync(
artifacts,
AssistantContextState.Summarizing,
CancellationToken.None);
var result = await summaryPipeline.RunAsync(
artifacts,
options,
CancellationToken.None);
await artifactStore.UpdateAssistantContextStateAsync(
artifacts,
result.Succeeded ? AssistantContextState.Finished : AssistantContextState.Error,
CancellationToken.None);
}
catch (Exception exception)
{
logger.LogError(
exception,
"Summary retry failed unexpectedly for {SummaryPath}",
artifacts.SummaryPath);
try
{
await artifactStore.UpdateAssistantContextStateAsync(
artifacts,
AssistantContextState.Error,
CancellationToken.None);
}
catch (Exception stateException)
{
logger.LogWarning(
stateException,
"Could not mark assistant context error after summary retry failed for {SummaryPath}",
artifacts.SummaryPath);
}
}
}
}