fix(hub): skip text processing after MessageAggregator reset
Add an `active` flag so that message_update/message_end events are ignored after reset() until the next message_start, preventing stale accumulated text from being re-emitted as a block. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
733798f2a9
commit
1a9e915d49
1 changed files with 8 additions and 1 deletions
|
|
@ -33,6 +33,7 @@ export class MessageAggregator {
|
|||
private buffer = "";
|
||||
private previousText = "";
|
||||
private blockIndex = 0;
|
||||
private active = false;
|
||||
private readonly chunker: BlockChunker;
|
||||
|
||||
constructor(
|
||||
|
|
@ -60,15 +61,20 @@ export class MessageAggregator {
|
|||
|
||||
case "message_start":
|
||||
this.resetState();
|
||||
this.active = true;
|
||||
this.onPassthrough(event);
|
||||
return;
|
||||
|
||||
case "message_update":
|
||||
if (!this.active) return;
|
||||
this.handleMessageUpdate(event as AgentEvent & { type: "message_update" });
|
||||
return;
|
||||
|
||||
case "message_end":
|
||||
this.handleMessageEnd(event as AgentEvent & { type: "message_end" });
|
||||
if (this.active) {
|
||||
this.handleMessageEnd(event as AgentEvent & { type: "message_end" });
|
||||
}
|
||||
this.active = false;
|
||||
this.onPassthrough(event);
|
||||
return;
|
||||
|
||||
|
|
@ -134,5 +140,6 @@ export class MessageAggregator {
|
|||
this.buffer = "";
|
||||
this.previousText = "";
|
||||
this.blockIndex = 0;
|
||||
this.active = false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue