Repository navigation
fix(chat): keep a finished reply on screen until its saved copy replaces it - #259
Merged
Merged
Conversation
…ces it At message_end the streamed bubble was cleared at once, while the saved copy arrived only when the catch-up read of the session file returned. In between the reply's space was empty: the chat shrank (1924 -> 672px in a real run), the view jumped up to where the reply started, and the follow-scroll then slid back down once the saved copy arrived. A finished assistant reply without tool calls is now held (hold action) and rendered until a history publish contains it (release, matched by timestamp), so the saved row replaces it in the same render. agent_end keeps a held reply; a new stream or reset still clears it.
…sage ends Review of the hold: - A catch-up page read mid-run carries a live snapshot with no message (omp cleared it at message_end), which dispatched start and dropped the held reply before its saved copy existed. Live snapshots and non-reply message ends now dispatch idle, which keeps a held reply. - surfaceQuotaOnStream skips a held reply, so a quota notice no longer restarts it as a stream beside its saved copy. - A past-branch view never holds: it never receives the saved copy. - Autoplay waits for the saved row, so its speaker button shows playback; the held bubble no longer shows the live tokens/s gauge. - The test now covers a read without the saved reply, a live snapshot and agent_end before the save, and fails on the previous commit.
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
When the agent finished a reply, the chat jumped up to the start of the reply for a moment and then slid back down.
At
message_endthe streamed bubble was cleared at once, but the saved copy only appears when the catch-up read of the session file returns. In between, the reply's space was empty. In a real run, the chat's scroll height fell from 1924px to 672px, the view was clamped up by 831px, and the follow-scroll then smooth-scrolled back down once the saved copy arrived.Changes
hooks/useAgentSession-stream.ts: a finished reply can be held.holdkeeps it on screen while not streaming.releaseclears it only when committed history contains it (matched bytimestamp; a reply without one is dropped as before).endand the newidlekeep a held reply.start,updateandresetclear it as before.message_end: a finished assistant reply with visible content and no tool calls is held. Other message ends dispatchidle. A past-branch view never holds, since it never receives the saved copy.historycallback dispatchesreleasewith the new messages, in the same batch assetMessages. The saved row replaces the held bubble in one render.idle, so a catch-up page read before omp's write does not drop the held reply.surfaceQuotaOnStreamskips a held reply.ChatWindowrenders a held reply. Autoplay waits for the saved row, so its speaker button shows playback. The held bubble no longer shows the live tokens/s gauge.Verification
useAgentSession.rpc.test.mjs: a read without the saved reply, a live snapshot without a message, andagent_endall keep the reply; the save then replaces it with exactly one copy. It fails on the first commit of this PR and onupstream/main. Mutations ofend(always clear) andrelease(ignore the timestamp) both fail it.npm test: 1409 pass, 1 fail. The failure, "message Markdown copy preserves source…" inMessageView.test.mjs, also fails on unmodifiedupstream/mainon this machine (heavily loaded at the time), so it is unrelated.tsc --noEmitand eslint are clean.