mirror of
https://github.com/davidkaya/aryx.git
synced 2026-08-04 19:08:40 +02:00
fix: stabilize streamed message rendering
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -167,6 +167,7 @@ public sealed class TurnDeltaEventDto : SidecarEventDto
|
||||
public string MessageId { get; init; } = string.Empty;
|
||||
public string AuthorName { get; init; } = string.Empty;
|
||||
public string ContentDelta { get; init; } = string.Empty;
|
||||
public string? Content { get; init; }
|
||||
}
|
||||
|
||||
public sealed class TurnCompleteEventDto : SidecarEventDto
|
||||
|
||||
@@ -119,6 +119,7 @@ public sealed class CopilotWorkflowRunner : ITurnWorkflowRunner
|
||||
string messageId = update.Update.MessageId ?? $"{command.RequestId}-delta-{fallbackMessageIndex++}";
|
||||
StreamingSegment segment = GetOrCreateSegment(segments, messageId, authorName);
|
||||
segment.SetContent(StreamingTextMerger.Merge(segment.Content.ToString(), update.Update.Text));
|
||||
segment.SetAuthorName(authorName);
|
||||
|
||||
await onDelta(new TurnDeltaEventDto
|
||||
{
|
||||
@@ -128,6 +129,7 @@ public sealed class CopilotWorkflowRunner : ITurnWorkflowRunner
|
||||
MessageId = messageId,
|
||||
AuthorName = authorName,
|
||||
ContentDelta = update.Update.Text,
|
||||
Content = segment.Content.ToString(),
|
||||
}).ConfigureAwait(false);
|
||||
}
|
||||
else if (evt is ExecutorCompletedEvent completed
|
||||
@@ -477,7 +479,7 @@ public sealed class CopilotWorkflowRunner : ITurnWorkflowRunner
|
||||
|
||||
public string MessageId { get; }
|
||||
|
||||
public string AuthorName { get; }
|
||||
public string AuthorName { get; private set; }
|
||||
|
||||
public StringBuilder Content { get; } = new();
|
||||
|
||||
@@ -486,6 +488,11 @@ public sealed class CopilotWorkflowRunner : ITurnWorkflowRunner
|
||||
Content.Clear();
|
||||
Content.Append(value);
|
||||
}
|
||||
|
||||
public void SetAuthorName(string value)
|
||||
{
|
||||
AuthorName = value;
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class AgentBundle : IAsyncDisposable
|
||||
|
||||
@@ -128,6 +128,7 @@ public sealed class SidecarProtocolHostTests
|
||||
MessageId = "assistant-1",
|
||||
AuthorName = "Primary",
|
||||
ContentDelta = "Hello",
|
||||
Content = "Hello",
|
||||
});
|
||||
|
||||
await onActivity(new AgentActivityEventDto
|
||||
@@ -201,6 +202,7 @@ public sealed class SidecarProtocolHostTests
|
||||
{
|
||||
Assert.Equal("turn-delta", deltaEvent.GetProperty("type").GetString());
|
||||
Assert.Equal("Hello", deltaEvent.GetProperty("contentDelta").GetString());
|
||||
Assert.Equal("Hello", deltaEvent.GetProperty("content").GetString());
|
||||
},
|
||||
toolEvent =>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user