Skip to content

Coalesce streamed chat updates to keep the UI responsive - #48

Merged
Lazarus-931 merged 1 commit into
mainfrom
fix-ui-stall-during-generation
Jul 22, 2026
Merged

Coalesce streamed chat updates to keep the UI responsive#48
Lazarus-931 merged 1 commit into
mainfrom
fix-ui-stall-during-generation

Conversation

@Lazarus-931

Copy link
Copy Markdown
Collaborator

When each streamed token is applied to the messages component on the main actor, the constant updates saturate the run loop, so live UI like the transcript, the thinking bubble, and the "Working" animation stops repainting until some input event nudges it (issue #11). Buffering the content, reasoning, and metric deltas and flushing them to the view at ~30 Hz moves those writes off the per-token path, so the main thread is no longer starved during generation. A trailing flush guarantees the last partial chunk still lands, and a final flush on completion or cancellation applies whatever remains in the buffer. The result is a transcript and thinking bubble that update smoothly the whole way through a response instead of freezing mid generation.

Applying every streamed token to the published message on the main actor
saturates the run loop, so the transcript, thinking bubble, and "Working"
animation stop repainting until an input event (#11). Buffer content,
reasoning, and metrics deltas and flush them at ~30 Hz — with a trailing flush
and a final flush on completion/cancel — so decode no longer starves the main
thread.
@Lazarus-931
Lazarus-931 requested a review from lucasnewman July 22, 2026 16:26

@lucasnewman lucasnewman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Lazarus-931
Lazarus-931 merged commit 010f68e into main Jul 22, 2026
2 checks passed
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.

2 participants