fix(webui): conflate queued chat renders — chat body no longer lags behind finished agents - #1804
Open
Zenetusken wants to merge 1 commit into
Open
fix(webui): conflate queued chat renders — chat body no longer lags behind finished agents#1804Zenetusken wants to merge 1 commit into
Zenetusken wants to merge 1 commit into
Conversation
setMessages chained one full render per incoming snapshot. Server pushes are debounced at 25ms, so during reasoning streaming snapshots arrive far faster than renders complete; the render queue grew unboundedly and the chat body fell behind in real time. A finished workflow then looked like it was still running until the backlog drained (CLI vs Web UI split-brain; a refresh 'fixed' it by discarding the backlog). Snapshot logs are deltas but merging is cumulative-safe (message-window dedups by id+type, last write wins), so accumulate pending deltas and drain them in as few renders as possible. Awaiting callers still resolve only after a render that includes their messages; stale generations are dropped on render-state reset. Regression coverage runs the real setMessages in Node with a slow renderer: pre-fix code renders 60/60 pushes (demonstrated), fixed code conflates heavily while rendering every message exactly once, in order.
Zenetusken
added a commit
to Zenetusken/agent-zero
that referenced
this pull request
Aug 2, 2026
b2a30ab, overlay 25db83d0c2cb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
During an active turn the Web UI chat body progressively falls behind the backend, and after the agent finishes it keeps "catching up" for many minutes — a completed workflow looks like it is still running. Other clients (CLI, fresh tabs) show the true state immediately; a page refresh "fixes" the Web UI by discarding the backlog. Reported recurring across sessions; #1803 fixed the stale status indicator (sequencing), this PR fixes the chat body backlog itself.
Root cause (measured)
helpers/state_monitor.py), so during reasoning streaming, snapshots arrive at up to ~40/s.setMessageschained one full render per snapshot onto_messageRenderQueue. Every queued render executed even when superseded — no conflation. With renders slower than pushes, the queue grows unboundedly (O(pushes)renders for one turn).Behavioral proof (shipped as a test): the real
setMessagesextracted from source, run in Node with a slow renderer — pre-fix code renders 60/60 pushes; fixed code conflates to a handful of renders with zero messages lost.Fix
Snapshot logs are deltas, but merging is cumulative-safe (
message-window.mergededups byid+type, last write wins). SosetMessagesnow accumulates pending deltas and drains them in as few renders as possible:Validation
tests/test_webui_render_conflation.py: behavioral Node harness (2 tests) + structural guard (1 test). Discriminating: conflation test fails on pre-fix v2.8 ("got 60 renders for 60 pushes"), all pass with the fix. Completeness test passes on both (old code was complete, just unboundedly slow).node --check webui/js/messages.jsclean.Note
Related but separate: the browser-panel screencast (
ws_browser._stream_frames) streams every frame unconditionally while the panel is open (~30% CPU, shares the WS worker with chat pushes). Backpressure for that is a candidate follow-up arc.