fix(dashboard): kill chat-tab freeze under long sessions / concurrent jobs#560
Merged
Conversation
… jobs Chrome's "Page not responding" dialog fires on the dashboard chat tab once a session accumulates enough messages. Repro condition: long streaming turn or several concurrent jobs broadcasting at once. Two cooperating bugs on the chat feed's hot path: 1. Every assistant_delta event hit setState synchronously. The model streams ~20 deltas/sec; each one re-rendered ChatPanel, which .map'd over every historical ChatMessage with no memoization, so each one re-ran marked.parse + (for tool messages) hljs syntax highlight on UNCHANGED content. Long sessions = N grows = main thread starves. 2. The `streaming` prop fed to historical ChatMessage flipped between `null` (no streaming) and `false` (streaming-but-not-this-message) across turns, so even with memo, `null !== false` would force every historical message to re-render every time streaming started or stopped. Fix: - Wrap ChatMessage in `memo` from preact/compat so historical messages with stable `msg` refs short-circuit re-renders. - Cast the per-row streaming prop to a boolean so historical messages get a stable `false` and memo's shallow compare actually bails out across streaming-on/off transitions. - Coalesce assistant_delta into a single rAF-batched setStreaming. Multiple deltas in the same frame collapse into one state commit; the streaming bubble's re-render rate is capped at the display refresh rate. assistant_final + SSE reconnect + unmount each cancel the pending flush so the buffer can't leak across turns. Closes #551
This was referenced May 10, 2026
Closed
Merged
esengine
added a commit
that referenced
this pull request
May 13, 2026
) Reported in #721: typing in the dashboard composer feels laggy on long sessions. Root cause is that every keystroke commits to `input` state, which forces ChatPanel to walk its entire vnode tree on each frame. ChatMessage was already wrapped in memo (#560), so historical bubbles short-circuit individually — but Preact still has to map() over every message, evaluate the per-row `Boolean(streaming && streaming.id === m.id)` discriminator, and diff each ChatMessage element. For a session with 100+ messages the per-keystroke work is enough to drop frames. Move the message-list render into a `<ChatFeed>` sub-component and wrap it in memo. With `messages` and `streaming` refs both stable while the user is typing, memo bails the whole feed out — keystrokes no longer touch the feed at all. SideRail and ChatStatusBar get the same treatment so /overview poll churn and input edits don't repaint the right-rail progress bars and statusbar. Closes #721
ChasLui
pushed a commit
to ChasLui/DeepSeek-Reasonix
that referenced
this pull request
May 23, 2026
… jobs (esengine#560) Chrome's "Page not responding" dialog fires on the dashboard chat tab once a session accumulates enough messages. Repro condition: long streaming turn or several concurrent jobs broadcasting at once. Two cooperating bugs on the chat feed's hot path: 1. Every assistant_delta event hit setState synchronously. The model streams ~20 deltas/sec; each one re-rendered ChatPanel, which .map'd over every historical ChatMessage with no memoization, so each one re-ran marked.parse + (for tool messages) hljs syntax highlight on UNCHANGED content. Long sessions = N grows = main thread starves. 2. The `streaming` prop fed to historical ChatMessage flipped between `null` (no streaming) and `false` (streaming-but-not-this-message) across turns, so even with memo, `null !== false` would force every historical message to re-render every time streaming started or stopped. Fix: - Wrap ChatMessage in `memo` from preact/compat so historical messages with stable `msg` refs short-circuit re-renders. - Cast the per-row streaming prop to a boolean so historical messages get a stable `false` and memo's shallow compare actually bails out across streaming-on/off transitions. - Coalesce assistant_delta into a single rAF-batched setStreaming. Multiple deltas in the same frame collapse into one state commit; the streaming bubble's re-render rate is capped at the display refresh rate. assistant_final + SSE reconnect + unmount each cancel the pending flush so the buffer can't leak across turns. Closes esengine#551
ChasLui
pushed a commit
to ChasLui/DeepSeek-Reasonix
that referenced
this pull request
May 23, 2026
…sengine#729) Reported in esengine#721: typing in the dashboard composer feels laggy on long sessions. Root cause is that every keystroke commits to `input` state, which forces ChatPanel to walk its entire vnode tree on each frame. ChatMessage was already wrapped in memo (esengine#560), so historical bubbles short-circuit individually — but Preact still has to map() over every message, evaluate the per-row `Boolean(streaming && streaming.id === m.id)` discriminator, and diff each ChatMessage element. For a session with 100+ messages the per-keystroke work is enough to drop frames. Move the message-list render into a `<ChatFeed>` sub-component and wrap it in memo. With `messages` and `streaming` refs both stable while the user is typing, memo bails the whole feed out — keystrokes no longer touch the feed at all. SideRail and ChatStatusBar get the same treatment so /overview poll churn and input edits don't repaint the right-rail progress bars and statusbar. Closes esengine#721
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.
A user reported the embedded dashboard's chat tab triggering Chrome's
"Page not responding" dialog during long active sessions, especially
with concurrent jobs streaming at the same time. Profiled the chat
feed's hot path on a synthetic long session.
Root cause — two cooperating bugs
Every `assistant_delta` event called `setStreaming` synchronously.
The model streams ~20 deltas/sec; concurrent jobs add more events
on top. Each setState re-rendered `ChatPanel`, which `.map`'d
over every historical `ChatMessage` with no memoization. So
each delta re-ran `marked.parse` per message, plus
`hljs.highlight` on every `ToolCard` — on UNCHANGED content.
Long session = N messages grows monotonically = main thread starves.
The per-row streaming prop was passed as
`streaming && streaming.id === m.id` — that produces `null` when
no turn is streaming and `false` when one is streaming but not
this message. Memo's shallow compare treats `null !== false` as a
change, so even after memoizing, every historical row would
re-render the moment a turn started or stopped.
Fix (`dashboard/src/`, +46 / −11)
messages keep stable `msg` references across deltas → bail out.
see a stable `false` across the streaming-on/off transition.
lives in a ref and we flush at most once per animation frame —
capping the streaming-bubble re-render rate at the display refresh
rate regardless of delta volume. `assistant_final` + SSE reconnect
across turns.
Test plan
char response, verify no "Page not responding" prompt during
streaming
the dashboard tab open for several minutes — confirm no freeze
Closes #551