Skip to content

fix(chat): keep a finished reply on screen until its saved copy replaces it - #259

Merged
andrebrait merged 2 commits into
ompweb-dev:mainfrom
andrebrait:fix/turn-end-scroll-jump
Oct 13, 2026
Merged

andrebrait merged 2 commits into
ompweb-dev:mainfrom
andrebrait:fix/turn-end-scroll-jump

Conversation

@andrebrait

Copy link
Copy Markdown
Collaborator

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_end the 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. hold keeps it on screen while not streaming. release clears it only when committed history contains it (matched by timestamp; a reply without one is dropped as before). end and the new idle keep a held reply. start, update and reset clear it as before.
  • message_end: a finished assistant reply with visible content and no tool calls is held. Other message ends dispatch idle. A past-branch view never holds, since it never receives the saved copy.
  • The catch-up history callback dispatches release with the new messages, in the same batch as setMessages. The saved row replaces the held bubble in one render.
  • Live snapshots without a message dispatch idle, so a catch-up page read before omp's write does not drop the held reply.
  • surfaceQuotaOnStream skips a held reply.
  • ChatWindow renders 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.
  • CHANGELOG entry under Unreleased / Fixed.

Verification

  • Real browser (headless Chromium, 390x844 mobile emulation, real omp run with a short model): across the end of the turn, the largest scroll-height drop was 0 and the largest upward scroll was 0. Before the fix, they were 1252px and 831px.
  • New test in useAgentSession.rpc.test.mjs: a read without the saved reply, a live snapshot without a message, and agent_end all keep the reply; the save then replaces it with exactly one copy. It fails on the first commit of this PR and on upstream/main. Mutations of end (always clear) and release (ignore the timestamp) both fail it.
  • npm test: 1409 pass, 1 fail. The failure, "message Markdown copy preserves source…" in MessageView.test.mjs, also fails on unmodified upstream/main on this machine (heavily loaded at the time), so it is unrelated. tsc --noEmit and eslint are clean.
  • Not yet checked on a physical phone.

…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.
@andrebrait
andrebrait merged commit fd28309 into ompweb-dev:main Oct 13, 2026
3 checks passed
@andrebrait
andrebrait deleted the fix/turn-end-scroll-jump branch October 13, 2026 21:11
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