Skip to content

Port v6: Fix reactions modal crash when no reactions can be displayed#6476

Merged
andremion merged 1 commit into
developfrom
port/v6-to-develop/user-reactions-empty-span-count
May 27, 2026
Merged

Port v6: Fix reactions modal crash when no reactions can be displayed#6476
andremion merged 1 commit into
developfrom
port/v6-to-develop/user-reactions-empty-span-count

Conversation

@andremion
Copy link
Copy Markdown
Contributor

@andremion andremion commented May 27, 2026

Port of #6475 to v7 (develop).

Closes AND-1194.

Goal

Fix the IllegalArgumentException: Span count should be at least 1. Provided 0 crash from UserReactionsView.bindReactionList when the reactions modal opens on a message whose filtered latestReactions ends up empty. The same buggy code is present on every v6 release from 6.35.0 through 6.38.0 and on develop.

Implementation

UserReactionsView.bindReactionList set gridLayoutManager.spanCount directly from the size of the filtered reaction list:

gridLayoutManager.spanCount = userReactionItems.size.coerceAtMost(MAX_COLUMNS_COUNT)

When userReactionItems is empty, spanCount = 0 is passed to GridLayoutManager.setSpanCount, which rejects it.

Clamp the value to at least 1:

gridLayoutManager.spanCount = userReactionItems.size
    .coerceAtMost(MAX_COLUMNS_COUNT)
    .coerceAtLeast(1)

./gradlew apiDump produced zero .api diff, confirming no public surface change.

Testing

See #6475 for the manual repro patch and full testing notes. Also verified on this branch:

  • ./gradlew spotlessApply detekt apiDump — clean.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed an issue where the reaction layout could fail to display properly when the reaction list was empty, ensuring consistent grid formatting.

Review Change Stack

…list crash

UserReactionsView.bindReactionList set GridLayoutManager.spanCount directly
from the size of the filtered reaction list. When the filter produces an
empty list (e.g. reactions whose user is null, or whose type has no
registered drawable in ChatUI.supportedReactions), spanCount = 0 was passed
to GridLayoutManager.setSpanCount, which rejects it with
IllegalArgumentException("Span count should be at least 1. Provided 0").

Coerce the value to at least 1. spanCount = 1 on an empty RecyclerView is
harmless; the modal opens with an empty grid instead of crashing.
@andremion andremion added the pr:bug Bug fix label May 27, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 27, 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, 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.

@andremion
Copy link
Copy Markdown
Contributor Author

@CodeRabbit review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 27, 2026

✅ Actions performed

Review triggered.

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.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 27, 2026

Walkthrough

UserReactionsView now clamps the GridLayoutManager's spanCount to a minimum of 1 and maximum of MAX_COLUMNS_COUNT based on reaction count. Previously, empty reaction lists could set spanCount to 0, which is invalid.

Changes

User Reactions Grid Layout Fix

Layer / File(s) Summary
GridLayoutManager spanCount bounds validation
stream-chat-android-ui-components/src/main/kotlin/io/getstream/chat/android/ui/feature/messages/list/reactions/user/internal/UserReactionsView.kt
spanCount is computed by clamping userReactionItems.size to a range between 1 and MAX_COLUMNS_COUNT, preventing zero span count when the reaction list is empty.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A grid that once collapsed to naught,
Now holds its ground with minimum thought,
One span at least, a rabbit's delight,
The reactions dance, arranged just right!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description provides a clear Goal, Implementation with code examples, and comprehensive Testing notes referencing the original issue.
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.
Title check ✅ Passed The title clearly and specifically describes the main change: fixing a crash in the reactions modal when no reactions can be displayed, which aligns perfectly with the code change that clamps spanCount to prevent it from becoming 0.

✏️ 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 port/v6-to-develop/user-reactions-empty-span-count

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.

@github-actions
Copy link
Copy Markdown
Contributor

SDK Size Comparison 📏

SDK Before After Difference Status
stream-chat-android-client 5.82 MB 5.82 MB 0.00 MB 🟢
stream-chat-android-ui-components 11.02 MB 11.02 MB 0.00 MB 🟢
stream-chat-android-compose 12.44 MB 12.44 MB 0.00 MB 🟢

@sonarqubecloud
Copy link
Copy Markdown

@andremion andremion changed the title fix(ui-components): prevent UserReactionsView empty-list crash Port v6: Fix reactions modal crash when no reactions can be displayed May 27, 2026
@andremion andremion marked this pull request as ready for review May 27, 2026 10:20
@andremion andremion requested a review from a team as a code owner May 27, 2026 10:20
@andremion andremion merged commit c9445bb into develop May 27, 2026
18 of 19 checks passed
@andremion andremion deleted the port/v6-to-develop/user-reactions-empty-span-count branch May 27, 2026 10:26
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.

2 participants