Skip to content

Coalesce chat stream rendering - #324

Closed
plux wants to merge 1 commit into
editor-code-assistant:masterfrom
plux:hn/chat-render-coalescing
Closed

plux wants to merge 1 commit into
editor-code-assistant:masterfrom
plux:hn/chat-render-coalescing

Conversation

@plux

@plux plux commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Context

  • Follow-up to #320: Coalesce assistant stream rendering

Description

Chat stream buffering previously focused on top-level assistant text, but chat
history can also receive subagent text and toolCallPrepare UI updates while a
response is still streaming. Immediate lifecycle events can arrive between those
buffered updates, which can reorder history or allow stale prepare UI to
overwrite newer tool state.

This PR extends stream coalescing to the other chat render paths. It preserves
receive order across top-level assistant text, nested subagent output, and
prepare UI updates.

Changes

  • Queue top-level assistant text, parent-scoped subagent text, and toolCallPrepare UI updates through the stream buffer.
  • Flush queued content before immediate lifecycle boundaries so history renders in receive order.
  • Keep running progress events from flushing pending text prematurely.
  • Finalize pending prepare state on tool lifecycle events so stale prepare UI cannot overwrite completed tool state.
  • Preserve existing subagent child output when parent lifecycle updates change the parent label or status.
  • Capture parent text before nested child blocks so collapsed expandable blocks reopen in receive order.
  • Add regression coverage for render ordering, prepare finalization, running progress events, and nested subagent streams.
  • Add a benchmark fixture for chat render coalescing workloads.
  • Update the README description for eca-chat-stream-flush-interval.

Benchmarks

Measured with Emacs 30.1. Baseline was origin/master at 3f2567b.
The PR branch was 12ef152.

Lower wall time is better.

op baseline ms PR ms change baseline updates PR updates
top-level-assistant 86.74 42.83 -50.6% 0 0
subagent-one-parent 1434.59 31.10 -97.8% 1500 1
subagent-split-parents 333.28 42.12 -87.4% 1500 4
tool-prepare-all 630.13 29.52 -95.3% 600 1
tool-prepare-smart 122.30 29.60 -75.8% 120 1
mixed-stream 942.73 206.83 -78.1% 602 3
history-replay 6318.62 4782.97 -24.3% 240 240

@plux
plux force-pushed the hn/chat-render-coalescing branch 3 times, most recently from 84be39b to 812f086 Compare September 16, 2026 18:47
Buffer assistant text, subagent text, and toolCallPrepare UI updates
behind a shared stream queue. Flush queued content before immediate
lifecycle boundaries so chat history preserves receive order.

Preserve subagent child output when parent lifecycle updates arrive, and
capture expandable parent text before nested child blocks. This keeps
collapsed subagent history stable when users reopen parent blocks.

Add regression coverage for render ordering, prepare finalization,
running progress events, and nested subagent streams. Add a benchmark
fixture for chat render coalescing workloads.
@plux
plux force-pushed the hn/chat-render-coalescing branch from 812f086 to 02a900b Compare September 17, 2026 06:42
@plux plux closed this Sep 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant