fix(ui): preserve in-flight touch scrolling during chat updates - #94
Open
jmfederico wants to merge 2 commits into
Open
fix(ui): preserve in-flight touch scrolling during chat updates#94jmfederico wants to merge 2 commits into
jmfederico wants to merge 2 commits into
Conversation
Programmatic scrollTop writes and DOM repaints cancel in-flight touch/momentum scrolling on iOS, causing the chat to freeze mid-gesture. Three mechanisms contribute, all addressed: - The prepend anchor settle loop wrote scrollTop every frame for 30 frames even when the anchor had not drifted. It now only writes when the drift is at least half a pixel. - The conversation position indicator repainted mid-gesture, cancelling touch scrolls because the meter overlaps the top edge of the scrollport. Updates are now deferred while a gesture or momentum scroll is in flight and committed once the scroll settles. - History prepends applied their DOM changes (and scrollTop corrections) as soon as the fetch resolved. The page is still fetched immediately to hide latency, but the merge is held until the chat scroll is idle via a new ScrollIdleTracker, with a max-wait cap so a continuously scrolling user cannot starve it.
TEMPORARY tooling for the touch-scroll stall investigation, gated behind ?scrolldiag=1: instruments the chat scroller (scrollTop writes with stack traces, scroll/touch events, DOM mutations, long tasks) and renders a timeline overlay with an abrupt-stop detector so an on-device reproduction can be screenshotted. Remove once the investigation concludes.
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
Fixes chat scrolling on touch devices (iPad) freezing mid-gesture. Programmatic
scrollTopwrites and DOM repaints cancel in-flight touch/momentum scrolling on iOS; three code paths did this during normal chat use:scrollTopevery frame for 30 frames even when the anchor had not drifted. It now only writes when drift ≥ 0.5px.scrollTopcorrections) the moment the fetch resolved. The page is still fetched immediately to hide latency, but the merge is held until the scroll is idle, via a newScrollIdleTrackerwith a 2.5s max-wait cap so a continuously scrolling user cannot starve it.Commits
fix(ui): preserve in-flight touch scrolling during chat updates— the fix, tests, and changesets.chore(ui): add temporary on-device scroll diagnostics overlay— TEMPORARY debug tooling gated behind?scrolldiag=1for on-device verification of the stall investigation; to be dropped once the investigation concludes (revert of the single top commit).Testing
ScrollIdleTrackerstate machine (fake scheduler), prepend-anchor write suppression,loadEarlierMessagesidle-hold incl. the session-switch race, and Lit touch-event wiring on the chat scroller.