Skip to content

Message received while at the bottom of a conversation is not scrolled into view #878

Description

@levinium

Checklist

  • I can reproduce the bug with the latest version.
  • I made sure that there are no existing issues - open or closed - to which I could contribute my information.
  • I made sure that there are no existing discussions - open or closed - to which I could contribute my information.
  • I have read the FAQs inside the app (Menu -> About -> FAQs) and my problem isn't listed.
  • I have taken the time to fill in all the required details.
  • This issue contains only one bug.
  • I have read and understood the contribution guidelines.

Affected app version

1.9.1

Affected Android/Custom ROM version

Android 17 / GrapheneOS (build 2026091001)

Affected device model

Pixel 10 Pro XL

How did you install the app?

F-Droid / IzzyOnDroid

Steps to reproduce the bug

  1. Open a conversation that has enough messages to fill more than one screen.
  2. Scroll all the way to the bottom.
  3. Receive a message in that conversation.

Expected behavior

The list scrolls down so the newly received message is fully visible.

Actual behavior

The list does not scroll. The new message lands below the fold - often with only its top edge visible - and has to be scrolled to by hand to be read.

It happens both with and without the keyboard open. Conversations short enough to fit entirely on screen are not affected, because stackFromEnd keeps them pinned to the bottom regardless.

Additional information

The relevant code is in ThreadActivity.setupAdapter():

val lastPosition = itemCount - 1
val lastVisiblePosition = layoutManager.findLastVisibleItemPosition()
val shouldScrollToBottom =
    currentList.lastOrNull() != latestThreadItems.lastOrNull() &&
            lastPosition - lastVisiblePosition == 1
updateMessages(latestThreadItems, if (shouldScrollToBottom) lastPosition else -1)

Two things look wrong here:

  1. lastPosition - lastVisiblePosition == 1 is the "is the user at the bottom" test, but when the user really is at the bottom that difference is 0, not 1. The condition fails in exactly the case it is meant to catch.

  2. When it does fire, the scroll target is lastPosition, which is itemCount - 1 of the list before the update - that is, the message before the one that just arrived.

I have a working fix for this and would be glad to open a PR if this gets the help wanted label.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions