Handle settings logs agent failures
PR and Push Build/Test / build-and-test (push) Successful in 9m8s

This commit is contained in:
2026-06-09 17:10:06 +02:00
parent 8af89a622d
commit ecdd23bde7
8 changed files with 147 additions and 15 deletions
@@ -17,6 +17,8 @@ public sealed class WorkflowRulesEditorChatViewModel
public bool IsThinking { get; private set; }
public string ActivityMessage { get; private set; } = "Thinking...";
public event EventHandler? Changed;
public async Task SendAsync(CancellationToken cancellationToken = default)
@@ -31,6 +33,7 @@ public sealed class WorkflowRulesEditorChatViewModel
var priorConversation = Messages.ToList();
Messages.Add(new WorkflowRulesEditorChatMessage(WorkflowRulesEditorChatRole.User, prompt));
IsThinking = true;
ActivityMessage = "Thinking...";
OnChanged();
try
@@ -38,26 +41,39 @@ public sealed class WorkflowRulesEditorChatViewModel
var result = await pipeline.SendAsync(
priorConversation,
prompt,
cancellationToken);
cancellationToken,
SetActivityMessage);
Messages.Clear();
foreach (var message in result.Conversation)
{
Messages.Add(message);
}
}
catch (Exception exception) when (exception is not OperationCanceledException)
catch (Exception exception) when (exception is not OperationCanceledException || !cancellationToken.IsCancellationRequested)
{
Messages.Add(new WorkflowRulesEditorChatMessage(
WorkflowRulesEditorChatRole.Agent,
$"Rules editor failed: {exception.Message}"));
$"Settings and logs failed: {exception.Message}"));
}
finally
{
IsThinking = false;
ActivityMessage = "Thinking...";
OnChanged();
}
}
private void SetActivityMessage(string message)
{
if (!IsThinking || string.IsNullOrWhiteSpace(message))
{
return;
}
ActivityMessage = message;
OnChanged();
}
private void OnChanged()
{
Changed?.Invoke(this, EventArgs.Empty);