Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

fix(hub): include message_end text in aggregator

yushenf6fab68873c2
diff --git a/src/hub/message-aggregator.ts b/src/hub/message-aggregator.ts
index 788dc70659..4f4b37384c 100644
--- a/src/hub/message-aggregator.ts
+++ b/src/hub/message-aggregator.ts
@@ -68,7 +68,7 @@ export class MessageAggregator {
return;
case "message_end":
- this.flushBuffer();
+ this.handleMessageEnd(event as AgentEvent & { type: "message_end" });
this.onPassthrough(event);
return;
@@ -87,13 +87,7 @@ export class MessageAggregator {
private handleMessageUpdate(event: AgentEvent): void {
const message = (event as { message?: unknown }).message;
const currentText = extractText(message as Parameters<typeof extractText>[0]);
-
- // Compute incremental delta (monotonic accumulation)
- if (currentText.length <= this.previousText.length) return;
- const delta = currentText.slice(this.previousText.length);
-
- this.previousText = currentText;
- this.buffer += delta;
+ this.appendDelta(currentText);
// Try to emit chunks from buffer
let result = this.chunker.tryChunk(this.buffer);
@@ -104,6 +98,22 @@ export class MessageAggregator {
}
}
+ private handleMessageEnd(event: AgentEvent): void {
+ const message = (event as { message?: unknown }).message;
+ const currentText = extractText(message as Parameters<typeof extractText>[0]);
+ this.appendDelta(currentText);
+ this.flushBuffer();
+ }
+
+ private appendDelta(currentText: string): void {
+ // Compute incremental delta (monotonic accumulation)
+ if (currentText.length <= this.previousText.length) return;
+ const delta = currentText.slice(this.previousText.length);
+
+ this.previousText = currentText;
+ this.buffer += delta;
+ }
+
private flushBuffer(): void {
const result = this.chunker.flush(this.buffer);
if (result) {