Skip to content

Rework scroll position handling#40

Open
torarnv wants to merge 2 commits intolangwatch:mainfrom
torarnv:rework-scroll-position-handling
Open

Rework scroll position handling#40
torarnv wants to merge 2 commits intolangwatch:mainfrom
torarnv:rework-scroll-position-handling

Conversation

@torarnv
Copy link
Contributor

@torarnv torarnv commented Mar 9, 2026

No description provided.

torarnv added 2 commits March 9, 2026 15:41
The previous overscroll-based gesture (rubber-banding past the top)
was essentially invisible — there was no UI hint and users saw a
truncated conversation with no indication that more history existed.

We now detect when the scroll position is within 300px of the top
and automatically load the next 80 turns. A ScrollState observer
tracks document view frame changes and incrementally adjusts the
scroll offset so the visible content stays pixel-perfect in place,
even while the user is still scrolling with momentum. Chained loads
continue until all history is loaded or the viewport moves away
from the top.

To prevent false triggers during the initial scroll-to-bottom
animation, auto-loading is armed after a 500ms delay that resets
on session switches.
We were using the sequential turn index as the ForEach identity,
but this index shifts whenever new turns are appended to the JSONL
file, causing SwiftUI to see all-new IDs and re-render the entire
list. The viewport would jump even when the user had scrolled away
from the bottom.

We now use the file line number, which is stable — appending new
lines never changes existing line numbers. This keeps the viewport
in place when new turns arrive, while still following new content
when the user is already at the bottom.

Amends 0d66aa7.
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