Skip to content

Stabilize the thread quote jump test and stop dropping focused-message jumps - #6594

Merged
andremion merged 6 commits into
developfrom
andrerego/and-1332-scroll-until-the-quoted-message-is-visible
Jul 29, 2026
Merged

Stabilize the thread quote jump test and stop dropping focused-message jumps#6594
andremion merged 6 commits into
developfrom
andrerego/and-1332-scroll-until-the-quoted-message-is-visible

Conversation

@andremion

@andremion andremion commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Goal

test_quotedReplyNotInList_whenUserAddsQuotedReply_InThread (AllureId 5892) was ignored in #6592 after failing the e2e batch on unrelated PRs. Local soak runs (30 to 40 repetitions per iteration) surfaced four distinct causes, three in the test flow and one in the SDK. This stabilizes the test and re-enables it.

Resolves AND-1332

Implementation

  • Scroll setup: the fixed count of eight scroll-ups could leave the target message clipped at the viewport edge, where its text is not laid out and a long press does nothing (confirmed by the CI failure screenshot: the target was 30px into the viewport). New scrollMessageListUpToMessage scrolls one page at a time until the message is fully inside the list viewport after the fling settles.
  • Tap on the quote: a tap that lands while the list is still moving is cancelled by the touch slop and never reaches the click handler (confirmed by per-failure logcat: no focusMessage call in the failing attempts). tapOnQuotedMessage now verifies the jump moved the quote out of the viewport and taps again when it did not.
  • Channel click: the openChannel click picks an object by index from findObjects, a path the stale-safe helpers did not cover, and threw StaleObjectException when the channel list refreshed between the find and the click. Added waitToAppearAndClick(withIndex) to the toolkit, mirroring the existing selector-based contract, and used it in openChannel.
  • compose: the focused-message scroll effect skipped the jump when the list was still scrolling, and since the focused state is consumed either way, a jump requested while the list settles was silently dropped and never retried; a user tapping a quote during the settle got nothing. The effect now waits for the scroll to end instead of skipping. This one is verified by code tracing rather than an isolated reproduction; the eaten-tap mode above produced the same visible outcome in the soaks.
  • The dead MessageListPage.messageList selector (Stream_MessageList, which exists nowhere) now points at the real Stream_Messages tag.

Testing

Local soak evidence, same emulator and mock server for all iterations:

  • Before: the test failed roughly 2 of 5 runs locally and 4 of 5 CI batch runs.
  • After each fix the corresponding failure mode disappeared from the soaks; with all fixes, 30 of 30 soak runs pass, plus final sanity runs of the participant jump variant, the root-message jump test, and a channel quote test (all of which share the changed openChannel path).

For reviewers: run QuotedReplyTests#test_quotedReplyNotInList_whenUserAddsQuotedReply_InThread repeatedly against the mock server; before this change it fails within a handful of attempts, after it it stays green.

Summary by CodeRabbit

  • Bug Fixes

    • Improved reliability when navigating channels and selecting messages during active scrolling.
    • Fixed quoted-message navigation so taps are retried when the message list is still settling.
    • Improved automatic scrolling to bring referenced messages fully into view.
    • Ensured jumps to focused messages complete after scrolling finishes.
  • Tests

    • Re-enabled coverage for quoted replies that are not visible in the current message list.

@andremion andremion added the pr:bug Bug fix label Jul 28, 2026
@andremion

Copy link
Copy Markdown
Contributor Author

@CodeRabbit review

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@github-actions

Copy link
Copy Markdown
Contributor

PR checklist ✅

All required conditions are satisfied:

  • Title length is OK (or ignored by label).
  • At least one pr: label exists.
  • Sections ### Goal, ### Implementation, and ### Testing are filled, or the PR is bot-authored.
  • An issue is linked (Linear ticket or GitHub issue), or the PR is bot-authored.

🎉 Great job! This PR is ready for review.

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

The changes improve Android UI test interaction reliability, synchronize focused-message scrolling with list settling, update the message-list selector, and re-enable a quoted-reply end-to-end test using target-based scrolling.

Changes

Quoted reply reliability

Layer / File(s) Summary
Indexed UI selection
stream-chat-android-e2e-test/.../Wait.kt, stream-chat-android-compose-sample/.../UserRobot.kt
Adds stale-safe indexed clicking and uses it when opening a channel.
Message navigation synchronization
stream-chat-android-compose/.../Messages.kt, stream-chat-android-compose-sample/.../UserRobot.kt, stream-chat-android-compose-sample/.../MessageListPage.kt
Waits for list scrolling to finish, retries quoted-message taps, scrolls to fully visible target messages, and updates the message-list selector.
Quoted reply test validation
stream-chat-android-compose-sample/.../QuotedReplyTests.kt
Re-enables the quoted-reply test and replaces fixed scrolling with target-based scrolling.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested labels: pr:test, pr:improvement

Suggested reviewers: velikovpetar, testableapple, gpunto

Poem

I’m a bunny with a scrolling plan,
Tapping quotes as fast as I can.
Stale clicks hop away,
Messages settle and stay,
Tests bloom bright across the land.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main fix: stabilizing the quote-jump test and focused-message jump behavior.
Description check ✅ Passed The description includes Goal, Implementation, and Testing with concrete details; optional UI/GIF/checklist sections are missing but the core template is covered.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch andrerego/and-1332-scroll-until-the-quoted-message-is-visible

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@stream-chat-android-compose-sample/src/androidTestE2eDebug/kotlin/io/getstream/chat/android/compose/robots/UserRobot.kt`:
- Around line 335-347: The message visibility logic in the surrounding scroll
method must validate both the target’s top and bottom against
MessageList.messageList.visibleBounds, not just listTop, and perform that
validation after every settled swipe, including the final scrollMessageListUp
call. Reorder the loop so each swipe settles before checking the target, while
preserving the existing success return and retry behavior.

In
`@stream-chat-android-e2e-test/src/main/kotlin/io/getstream/chat/android/e2e/test/uiautomator/Wait.kt`:
- Around line 80-87: Update the retry loop in the timeout-aware wait method
around waitToAppear and StaleObjectException so it stops when the remaining time
is non-positive, rather than granting POLL_INTERVAL_MILLIS beyond endTime.
Preserve the last StaleObjectException and rethrow it when the requested timeout
expires, avoiding another waitToAppear call after the deadline.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d50acb6c-d743-45a1-bac4-6200b7977acf

📥 Commits

Reviewing files that changed from the base of the PR and between 0650aef and 4993f49.

📒 Files selected for processing (5)
  • stream-chat-android-compose-sample/src/androidTestE2eDebug/kotlin/io/getstream/chat/android/compose/pages/MessageListPage.kt
  • stream-chat-android-compose-sample/src/androidTestE2eDebug/kotlin/io/getstream/chat/android/compose/robots/UserRobot.kt
  • stream-chat-android-compose-sample/src/androidTestE2eDebug/kotlin/io/getstream/chat/android/compose/tests/QuotedReplyTests.kt
  • stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/messages/list/Messages.kt
  • stream-chat-android-e2e-test/src/main/kotlin/io/getstream/chat/android/e2e/test/uiautomator/Wait.kt

@github-actions

Copy link
Copy Markdown
Contributor

SDK Size Comparison 📏

SDK Before After Difference Status
stream-chat-android-client 5.95 MB 5.95 MB 0.00 MB 🟢
stream-chat-android-ui-components 11.22 MB 11.22 MB 0.00 MB 🟢
stream-chat-android-compose 12.70 MB 12.70 MB 0.00 MB 🟢

@andremion
andremion force-pushed the andrerego/and-1332-scroll-until-the-quoted-message-is-visible branch 2 times, most recently from f2e0468 to 9f54290 Compare July 28, 2026 14:59
@andremion
andremion marked this pull request as ready for review July 28, 2026 15:36
@andremion
andremion requested a review from a team as a code owner July 28, 2026 15:36
…essage

The focused-message scroll effect skipped the jump when the list was
still scrolling, and the focused state is consumed either way, so a
jump requested while the list settles was silently dropped and never
retried. Wait for the scroll to end instead of skipping.
waitToAppearAndClick only covered single-object selectors; clicks on
an object picked by index from findObjects still threw
StaleObjectException when the containing list refreshed between the
find and the click. Mirror the same re-find and retry contract for the
indexed lookup.
Three failure modes made the test flaky. The fixed count of eight
scroll-ups could leave the target message clipped at the viewport
edge, where its text is not laid out and a long press does nothing:
scroll until the message is fully inside the viewport instead. A tap
on the quoted message that lands while the list is still moving is
cancelled by the touch slop and never reaches the click handler: verify
the jump moved the quote out of the viewport and tap again when it did
not. The channel click at the start of the test could hit a stale node:
open the channel through the stale-safe indexed click.

Also fixes the MessageListPage list selector, which pointed at a
resource id that does not exist.
Moves the body of the focused-message scroll effect into an internal
LazyListState extension so the guard, the idle jump, and the
wait-out-an-ongoing-scroll behavior can be exercised in unit tests.
States why scrollMessageListUpToMessage only checks the top edge of the
list viewport, and documents the final grace poll of the indexed
waitToAppearAndClick the same way its selector-based sibling does.
With the clock auto-advancing, runOnIdle finished the scroll animation
before scrollToFocusedItem started, so the test passed even with the
wait reverted to the old skip behavior. Pause the main clock, launch
the jump in the middle of the animation, and assert it stays parked
until the scroll ends.
@andremion
andremion force-pushed the andrerego/and-1332-scroll-until-the-quoted-message-is-visible branch from 9f54290 to 4826025 Compare July 29, 2026 10:15
@andremion
andremion enabled auto-merge July 29, 2026 10:15
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
58.3% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@andremion
andremion added this pull request to the merge queue Jul 29, 2026
Merged via the queue into develop with commit b90de74 Jul 29, 2026
18 of 19 checks passed
@andremion
andremion deleted the andrerego/and-1332-scroll-until-the-quoted-message-is-visible branch July 29, 2026 11:36
@stream-public-bot stream-public-bot added the released Included in a release label Jul 30, 2026
@stream-public-bot

Copy link
Copy Markdown
Contributor

🚀 Available in v7.7.0

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

Labels

pr:bug Bug fix released Included in a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants