Skip to content

fix(chat): keep scroll position steady and make the prompt rail responsive - #587

Merged
ArgaFairuz merged 1 commit into
mainfrom
fix/chat-nav-and-virtual-scroll
Nov 18, 2026
Merged

ArgaFairuz merged 1 commit into
mainfrom
fix/chat-nav-and-virtual-scroll

Conversation

@ArgaFairuz

Copy link
Copy Markdown
Collaborator

Summary

Makes the chat's prompt navigation rail fast, accurate, visibly loading and usable on touch, and keeps the reading position steady while the virtual list reveals, trims and loads history.

Why

Jumping to an old prompt paged back one request at a time with no feedback and often landed off-target. The dot window snapped the moment a dot was clicked, and the active dot lagged behind the prompt on screen — or never moved at all after "scroll to bottom", because a long agent turn pushed its prompt out of the rendered window. Rail tooltips lingered half-faded and blocked taps on mobile. Scrolling stalled at the top/bottom until nudged and jumped when items were revealed or trimmed — worst on Safari, which has no scroll anchoring.

Changes

  • messages:list-page accepts until_id; getMessagePage reaches back to it in one page (test added)
  • Nav jumps: one-request load, cancellation token, spinner on the pressed dot/chevron, position held until layout settles
  • Rail dots: one column sliding behind a clipped viewport (animated), window frozen while a jump loads, ellipsis rows always reserved
  • Active dot: scrollspy on a reading line (30% of the viewport, max 240px) over each rendered message's global index (data-msg-index), so prompts outside the rendered window still resolve; rechecked on layout changes and on reaching the bottom; "scroll to bottom" highlights the last prompt immediately
  • Rail input: mouse-only hover, keyboard-only focus tooltips, stale hover cleared; touch tap-to-jump, press-and-hold preview, accelerated scrub with hysteresis and direction re-basing, slide-left to cancel
  • Anchor keeper (ResizeObserver) replaces native scroll anchoring (overflow-anchor: none); content-visibility removed
  • Edges re-checked after every load/reveal; older pages prefetched; trims limited to off-screen items
  • vs.sync no longer moves an older window to the end during streaming; isUserAtBottom requires the window to reach the end
  • Tool-result change detection no longer serialises every result
  • Classic window 20/5 → 30/10

Test plan

  • bun run check, bun run lint
  • bun run test — new until_id test passes; remaining failures exist on main or come from the temporary data dir
  • Manual: in a chat whose last turn has many tool calls, scroll up and press "scroll to bottom" — the last dot becomes active
  • Manual: click the topmost dot of a long rail while the active dot is at the bottom (spinner stays put, dots slide after landing); scroll past prompts and confirm the active dot switches as each crosses the upper third, including inside long agent turns
  • Manual: jump to a far prompt, fast scroll both directions on Chrome + Safari/iOS, touch tap/hold/scrub, read history during streaming

Notes

On iOS, a scroll correction mid-momentum can still stop the fling; prefetching and the larger window make that rare. The rail now renders every prompt's dot (clipped), which is cheap even for hundreds of prompts.

…nsive

Jumping to an old prompt from the navigation rail could take seconds
with no feedback, then land in the wrong place. The rail's dots
snapped to a new window the instant one was clicked, the active dot
lagged behind what was on screen and stayed put after scrolling to
the bottom, tooltips lingered half-faded, and on touch devices the
rail could not be tapped at all. Scrolling through history stalled at
the top or bottom until the user scrolled again, and the view jumped
when items were revealed or trimmed.

The jump paged back one 80-message request at a time, measured its
target once while neighbours still rendered at a 200px
content-visibility estimate, and could be overtaken by a later click.
The dot window re-sliced around the new active dot in a single frame.
The active dot was the rendered prompt nearest the viewport centre,
so one already scrolled past could stay active, and when a long agent
turn filled the rendered window with tool calls no prompt was found
at all. Tooltips relied on leave events that never fire for removed
or disabled elements, and iOS treats a tap that reveals hover content
as hover only. Loading was driven solely by scroll events, so a load
finishing while the reader sat at an edge triggered nothing; position
was restored from scrollHeight deltas, trims had no compensation
(Safari has no scroll anchoring), and streaming moved the virtual
window to the end even while the reader was on older messages.

The page API now takes until_id so a jump loads in one request; jumps
carry a token, show a spinner on the control pressed, keep the dots
still until they land and then slide them, and hold their target
while layout settles. The active dot follows a reading line over
every message's position in the whole list, so a prompt outside the
rendered window still counts, and it is rechecked on layout changes.
Hover is mouse-only and cleared when its element goes away; touch
gets tap to jump, press-and-hold to preview and an accelerated,
hysteresis-damped scrub. A ResizeObserver anchor keeper replaces
native scroll anchoring, edges are re-checked after every load, older
pages are prefetched, trims only drop off-screen items, sync leaves
older windows in place, and tool results are fingerprinted cheaply.
@ArgaFairuz
ArgaFairuz merged commit 68fad41 into main Nov 18, 2026
1 check failed
@ArgaFairuz
ArgaFairuz deleted the fix/chat-nav-and-virtual-scroll branch November 18, 2026 11:12
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