Skip to content

Allow long messages to scroll in message menu and tweak animation#6314

Open
gpunto wants to merge 5 commits intov7from
message-menu-tweaks
Open

Allow long messages to scroll in message menu and tweak animation#6314
gpunto wants to merge 5 commits intov7from
message-menu-tweaks

Conversation

@gpunto
Copy link
Copy Markdown
Contributor

@gpunto gpunto commented Mar 30, 2026

Goal

Three issues in the selected message menu:

  1. Long messages should be scrollable
  2. When a long-ish message is off screen at the top in the chat, the initial position in the menu's animation is wrong
  3. The initial position in the animation is slightly wrong depending on the position of the message in a group

Implementation

  1. Add a custom modifier to allow scrolling without clipping (since we want to scroll below the reactions picker & context menu)
  2. Move from boundsInWindow to positionInWindow
  3. Use the same MessagePosition that the original message had

🎨 UI Changes

Screenshot_20260330_153653

Testing

You can open the message menu in these scenario and verify they work as expected

  • Open for a long message and try scrolling it
  • Open for a message that is almost completely cut off of the top of the screen

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Fixed selected message menu animations to properly account for scroll offset, ensuring smooth vertical alignment when scrolling through message lists.
    • Improved message group position tracking for more accurate selection rendering and display consistency.
  • Refactor

    • Restructured message selection mechanism for enhanced scroll-aware behavior.

@gpunto gpunto added the pr:bug Bug fix label Mar 30, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 30, 2026

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.

🎉 Great job! This PR is ready for review.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 30, 2026

SDK Size Comparison 📏

SDK Before After Difference Status
stream-chat-android-client 5.25 MB 5.86 MB 0.61 MB 🔴
stream-chat-android-ui-components 10.60 MB 11.17 MB 0.57 MB 🔴
stream-chat-android-compose 12.81 MB 12.41 MB -0.40 MB 🚀

@gpunto gpunto marked this pull request as ready for review March 30, 2026 16:02
@gpunto gpunto requested a review from a team as a code owner March 30, 2026 16:02
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 30, 2026

Walkthrough

This PR refactors the selected message state mechanism by replacing a bounds-only LocalSelectedMessageBounds composition local with a richer SelectedMessageSnapshot data class that captures both message bounds and group position. The menu animation is updated to couple scroll offset into the vertical pop-out calculation.

Changes

Cohort / File(s) Summary
Composition Local & Data Class Definition
stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/messages/list/SelectedMessageSnapshot.kt
Replaces LocalSelectedMessageBounds with new SelectedMessageSnapshot data class and LocalSelectedMessageSnapshot composition local, capturing both bounds and group position.
Message Selection State Updates
stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/messages/list/MessageItem.kt, stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/messages/MessagesScreen.kt
Updates selection handling to create SelectedMessageSnapshot from position and size; switches composition local provider from bounds-only to snapshot-based approach.
Menu Animation & Rendering
stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/selectedmessage/SelectedMessageMenu.kt
Introduces UnclippedScrollState, couples animation translation to scroll offset, replaces messageModifier property with function, adds unclipped scroll modifier to message area with negative z-index.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A snapshot springs where bounds once were,
With group position in the blur,
The menu now dances with the scroll,
Each animation plays its role,
State flows richer through the tree,
A refactor crafted carefully! 🌸

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main changes: enabling scrolling for long messages in the menu and animation adjustments.
Description check ✅ Passed The description covers Goal, Implementation, and includes UI changes with a screenshot, but lacks Testing details, videos, and incomplete Checklist sections per the template.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 message-menu-tweaks

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 and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/selectedmessage/SelectedMessageMenu.kt (1)

235-355: Please add regression coverage for the new scroll/animation path.

This behavior now depends on custom layout code plus window-space positioning math, so a Paparazzi case for a tall message and one clipped at the top would make regressions much easier to catch.

Based on learnings, Applies to /stream-chat-android-compose//*Test.kt : Add Paparazzi snapshots for Compose UI regressions and run verifyPaparazziDebug.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/selectedmessage/SelectedMessageMenu.kt`
around lines 235 - 355, Add Paparazzi snapshot tests to cover the new unclipped
scroll + window-space animation path by creating Compose test cases that render
SelectedMessageMenu (or a minimal composable that uses UnclippedScrollState,
unclippedVerticalScroll, MenuAnimationState, and rememberMenuAnimation) with two
scenarios: a very tall message and a message positioned/clipped at the top of
the window; capture snapshots of the composed UI and assert they match the
golden images. Put tests under stream-chat-android-compose/**/*Test.kt, use
Paparazzi to set a fixed device size, supply appropriate sourceBounds and
MessageAlignment to exercise the translation math, and run verifyPaparazziDebug
to record/verify snapshots.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In
`@stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/selectedmessage/SelectedMessageMenu.kt`:
- Around line 235-355: Add Paparazzi snapshot tests to cover the new unclipped
scroll + window-space animation path by creating Compose test cases that render
SelectedMessageMenu (or a minimal composable that uses UnclippedScrollState,
unclippedVerticalScroll, MenuAnimationState, and rememberMenuAnimation) with two
scenarios: a very tall message and a message positioned/clipped at the top of
the window; capture snapshots of the composed UI and assert they match the
golden images. Put tests under stream-chat-android-compose/**/*Test.kt, use
Paparazzi to set a fixed device size, supply appropriate sourceBounds and
MessageAlignment to exercise the translation math, and run verifyPaparazziDebug
to record/verify snapshots.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: eda7d0c0-3f57-4e88-a040-475947ec266d

📥 Commits

Reviewing files that changed from the base of the PR and between e4994a4 and c1036f4.

📒 Files selected for processing (4)
  • stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/selectedmessage/SelectedMessageMenu.kt
  • stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/messages/MessagesScreen.kt
  • stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/messages/list/MessageItem.kt
  • stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/messages/list/SelectedMessageSnapshot.kt

@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

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

See analysis details on SonarQube Cloud

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

Labels

pr:bug Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant