Repository navigation
fix(macos): make long chats resize and scroll smoothly - #2135
Merged
Merged
Conversation
Measured offscreen on a 253-item session scrolled to its end, each window resize step cost 173 ms: every row was laid out eagerly, and the Latest button was a pinned section footer, which re-lays out its whole section on every frame. Moving the button to an overlay cuts that to 42 ms; making older rows lazy while the newest 20 stay eager brings it to about 15 ms (about 1 ms when the column width does not change) and halves the cost of each scrolled frame. Following the end of the chat now resumes whenever the chat is at its end, and again when a scroll comes to rest there. It used to resume only while input events were still arriving, so a scroll that settled at the end after its last event left Latest showing.
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.
Problem
After #2132, long chats still scrolled slowly, resizing the window was very laggy, and after Latest → scroll up → scroll back to the end, Latest stayed visible.
Measurements
Offscreen benchmark rendering the real 253-item session (
01a14ffb777a-…) in anNSHostingView, release build, scrolled to the end, average per resize step (700–1300 pt):A pinned section footer re-lays out its whole section every frame, and that section was the entire eagerly laid-out chat.
Changes
LazyVStack. The newest 20 stay eager, along with the working indicator and the bottom anchor, so the area being read near the end never changes height while you scroll. (Fully eager rows were added in fix(macos): steady chat scrolling and list new chats at once #2105 to stop that jump.)onScrollPhaseChange(.idle). Before, it resumed only while input events were still arriving, so a scroll that settled at the end after its last event left Latest up. Letting go still requires the reader's own upward input.Tests
swift build,swift test(85) pass. Built and installed locally (/Applications/RustCode.app). Scrolling far up into the lazy region may still correct its row height estimates; that region was never the reported problem.