Skip to content

fix(chat): make a search hit actually scroll into view - #13

Merged
jsfraz merged 1 commit into
developmentfrom
fix/jump-to-search-hit
Nov 17, 2026
Merged

jsfraz merged 1 commit into
developmentfrom
fix/jump-to-search-hit

Conversation

@jsfraz

@jsfraz jsfraz commented Nov 17, 2026

Copy link
Copy Markdown
Owner

Picking a search result did nothing visible.

Root cause: _jumpToMessage widened the rendered window and then called Scrollable.ensureVisible, but a list only builds widgets near the viewport. Growing the tail adds messages above the scroll position, so they are never built, _messageKeys[sentAt] stayed null and the retry silently gave up. The same path backs tapping a reply quote and the date jump, so all three were affected for anything older than the rendered window.

Fix:

  • The window is now cut down to the target rather than only grown: with the target five messages below the top of the rendered slice, jumpTo(0) lands on it and ensureVisible only adjusts the alignment.
  • A target that is already inside a large window but far below the screen is reached by walking up one viewport at a time until its bubble exists.
  • _jumping stops _onScroll's window growth from moving the offset during the walk.
  • The window/offset arithmetic moved to lib/utils/chat_scroll.dart with unit tests.

Verification: flutter analyze --no-fatal-infos clean, flutter test 147/147. The scroll behaviour itself is not verified on a device — no display in this session.

Picking a result did nothing visible. `_jumpToMessage` widened the
rendered window and then called `ensureVisible`, but a list only builds
what is near the viewport: growing the tail added messages *above* the
scroll position, which are never built, so there was no context to
scroll to and the retry silently gave up. The same path backs the reply
quote and the date jump.

The window is now cut down to the target instead of only grown: with the
target five messages below the top of the rendered slice, `jumpTo(0)`
lands on it and `ensureVisible` only fine-tunes the alignment. A target
that is already inside a large window but far below the screen is
reached by walking up one viewport at a time until its bubble exists. A
`_jumping` flag keeps the window growth in `_onScroll` from moving the
offset during the walk.

The two window/offset calculations live in `chat_scroll.dart` and are
covered by unit tests.
@jsfraz
jsfraz merged commit 029c065 into development Nov 17, 2026
1 check passed
@jsfraz
jsfraz deleted the fix/jump-to-search-hit branch November 17, 2026 22:49
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