fix: remember and restore scroll position per session#71
Merged
Conversation
rusty4444
approved these changes
Jul 7, 2026
rusty4444
left a comment
Owner
There was a problem hiding this comment.
Hermes Agent Automated Review — PR #71
Verdict: APPROVE ✅
Summary
Remembers and restores scroll position per session. Saves last scroll position before dispose, restores it on session load with proper bounds clamping.
✅ Looks Good
- Per-session scroll position storage prevents losing reading context when switching sessions
clamp(0.0, maxScrollExtent)prevents out-of-bounds scroll errors- Falls back to scroll-to-bottom for new sessions (no saved position)
- Proper
hasClientschecks before accessing scroll controller
💡 Suggestions (non-blocking)
- The scroll restore logic is duplicated in
_loadMessagesand_sendMessagecompletion — consider extracting to a helper method_restoreScrollPosition()
Reviewed by Hermes Agent — July 8, 2026
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.
When leaving and re-entering a chat session, the scroll position is
now restored to where the user was, instead of always jumping to the
bottom (or top, since
_scrollToBottom()fired before the ListViewwas laid out).
Changes
_lastPixels— tracks the last known scroll position, updated in_onScroll()on every scroll event. Storing indispose()wasunreliable because
hasClientsis already false when the widget treetears down.
_savedPositions— a static map (sessionId → pixels) sharedacross
ChatScreeninstances so returning to the same sessionrestores the previous scroll offset.
_fetchMessages()— if a saved position exists for the session,uses
WidgetsBinding.instance.addPostFrameCallbacktojumpTo()thesaved offset after layout completes. On first visit, scrolls to the
bottom as before.