fix(cli): flush buffered ACP assistant text after an idle gap (#1898)

* fix(cli): flush buffered ACP assistant text after an idle gap

ACP gives no "text segment finished" signal for a turn's last text segment and AcpMessageHandler only emits buffered text at explicit boundaries or through the prompt-lifecycle drains. When neither arrives - a text-only turn whose prompt() never returns - the answer is held until the next user prompt.

Emit buffered text once the stream has been silent for TEXT_IDLE_FLUSH_INTERVAL_MS (1000ms). The idle flush defers while a reasoning block is open (keeps Reasoning above the answer) and while the buffer may be an unfinished control envelope (keeps the internal-event filter complete). A later boundary emits only the remainder, so no character is emitted twice.

* fix(cli): stream idle ACP text as snapshots under one stream id

An id-less idle emission could render a reordered or duplicated answer when a dedupe agent rewrites its buffer with a prefix, and a pause inside an open Markdown fence split the rendered answer into separate blocks.

Stream idle emissions as full-text snapshots under a stable stream id and finalize with the same id at the boundary, mirroring flushReasoning; the partial-watermark computation is removed. The control-envelope guard no longer assumes type is the first JSON key.

* fix(cli): skip interim idle text snapshots in local launcher displays
This commit is contained in:
Maiz
2026-10-28 12:08:26 +08:00
committed by GitHub
parent 7a29b60353
commit b49c5d1dcb
9 changed files with 612 additions and 15 deletions
@@ -1295,6 +1295,11 @@ class OpencodeRemoteLauncher extends RemoteLauncherBase {
switch (message.type) {
case 'text':
// Interim idle snapshots; the settled text arrives at the
// segment boundary, which is what belongs in the local log.
if (message.live) {
break;
}
this.messageBuffer.addMessage(message.text, 'assistant');
break;
case 'reasoning':