Skip to content

Fix chat scroll UI#231

Merged
kirklandsign merged 3 commits into
mainfrom
android/fix-chat-scroll-ui
Apr 10, 2026
Merged

Fix chat scroll UI#231
kirklandsign merged 3 commits into
mainfrom
android/fix-chat-scroll-ui

Conversation

@kirklandsign
Copy link
Copy Markdown
Contributor

@kirklandsign kirklandsign commented Apr 9, 2026

The conversation scroll had several issues: auto-scroll fired on every token during generation (forcing users back to bottom even when reading history), LazyColumn keys included list index (defeating item reuse), and the clickable modifier for keyboard dismiss interfered with scroll gestures.

  • Add unique id field to Message for stable LazyColumn keys
  • Replace per-token scrollTrigger with throttled polling (300ms) that only scrolls when user is near bottom (derivedStateOf detection)
  • Use instant scrollToItem during generation, animateScrollToItem on completion
  • Add SmallFloatingActionButton to jump back to bottom when scrolled up
  • Replace clickable with pointerInput/detectTapGestures for keyboard dismiss to avoid scroll gesture interference
Screenshot_1775780979

…tom FAB

The conversation scroll had several issues: auto-scroll fired on every
token during generation (forcing users back to bottom even when reading
history), LazyColumn keys included list index (defeating item reuse),
and the clickable modifier for keyboard dismiss interfered with scroll
gestures.

- Add unique id field to Message for stable LazyColumn keys
- Replace per-token scrollTrigger with throttled polling (300ms) that
  only scrolls when user is near bottom (derivedStateOf detection)
- Use instant scrollToItem during generation, animateScrollToItem on
  completion
- Add SmallFloatingActionButton to jump back to bottom when scrolled up
- Replace clickable with pointerInput/detectTapGestures for keyboard
  dismiss to avoid scroll gesture interference
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Apr 9, 2026
Use GsonBuilder with InstanceCreator for Message deserialization so
that default field values (notably the new `id` field) are properly
initialized when loading saved messages from older JSON that lacks
the field. Without this, Gson's Unsafe.allocateInstance() leaves `id`
as null, crashing LazyColumn's stable-key lookup.

Also remove the now-unused `scrollTrigger` state — ChatScreen no longer
observes it after the scroll rework, so each-token increments were just
wasted snapshot notifications.
Copy link
Copy Markdown
Contributor

@lucylq lucylq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good!

@kirklandsign kirklandsign merged commit 43eda77 into main Apr 10, 2026
15 checks passed
@kirklandsign kirklandsign deleted the android/fix-chat-scroll-ui branch April 10, 2026 01:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants