gate conversation auto-scroll on the bottom pin (T-368)

New items arrive on every streamed token, and _onChanged jumped to
maxScrollExtent unconditionally — so a reader who scrolled up was
dragged back to the tail continuously for the whole reply. The
_atBottom pin already existed for viewport resizes (T-297); apply it
to the new-item path too, re-checking after layout since the user can
scroll during the frame. Twin tests added beside the T-297 pair:
pinned view keeps following, scrolled-up view stays put.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-06-12 00:26:32 +02:00
co-authored by Claude Fable 5
parent 75fc2719a0
commit 390ab2b64e
5 changed files with 63 additions and 4 deletions
@@ -268,9 +268,13 @@ class _ConversationViewState extends State<ConversationView> {
void _onChanged() {
if (!mounted) return;
setState(() {});
// Follow the tail — jump to the bottom after the new item lays out.
// Follow the tail — but only when already pinned to it. New items arrive
// on every streamed token; jumping unconditionally yanks a reader who
// scrolled up back to the bottom for the whole reply (T-368, twin of the
// T-297 resize gate).
if (!_atBottom) return;
WidgetsBinding.instance.addPostFrameCallback((_) {
if (_scroll.hasClients) {
if (_scroll.hasClients && _atBottom) {
_scroll.jumpTo(_scroll.position.maxScrollExtent);
}
});