Repository navigation
fix(chat): keep scroll position steady and make the prompt rail responsive - #587
Merged
Merged
Conversation
…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.
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.
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-pageacceptsuntil_id;getMessagePagereaches back to it in one page (test added)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 immediatelyoverflow-anchor: none);content-visibilityremovedvs.syncno longer moves an older window to the end during streaming;isUserAtBottomrequires the window to reach the endTest plan
bun run check,bun run lintbun run test— newuntil_idtest passes; remaining failures exist onmainor come from the temporary data dirNotes
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.