Conversation
PR checklist ✅All required conditions are satisfied:
🎉 Great job! This PR is ready for review. |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
SDK Size Comparison 📏
|
WalkthroughThis PR refactors the message reactions API by introducing a new Changes
Sequence DiagramsequenceDiagram
participant MessageContainer
participant rememberMessageReactions as rememberMessageReactions
participant ReactionResolver
participant AdaptiveMessageReactions
participant SegmentedMessageReactions
participant ClusteredMessageReactions
MessageContainer->>rememberMessageReactions: Compute visible reactions
rememberMessageReactions->>ReactionResolver: Filter by supportedReactions
ReactionResolver-->>rememberMessageReactions: Filtered reactions
rememberMessageReactions->>rememberMessageReactions: Map to MessageReactionItemState
rememberMessageReactions-->>MessageContainer: List<MessageReactionItemState>
MessageContainer->>AdaptiveMessageReactions: Render reactions with list
AdaptiveMessageReactions->>SegmentedMessageReactions: Measure width (first attempt)
alt Width fits constraints
SegmentedMessageReactions-->>AdaptiveMessageReactions: Render per-reaction pills
else Width exceeds constraints
AdaptiveMessageReactions->>ClusteredMessageReactions: Fallback to clustered
ClusteredMessageReactions-->>AdaptiveMessageReactions: Render aggregated pill
end
AdaptiveMessageReactions-->>MessageContainer: Rendered reaction UI
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
⚔️ Resolve merge conflicts (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/theme/ChatComponentFactoryParams.kt (1)
25-37:⚠️ Potential issue | 🟡 MinorUpdate MessageReactionsParams KDoc for the new reaction item type (and add thread/state notes).
The KDoc still says “reaction options” and doesn’t include thread/state notes, which is now more important with
MessageReactionItemState(type/emoji/count).📝 Suggested KDoc update
/** * Parameters for the [ChatComponentFactory.MessageReactions] component. * * `@param` modifier Modifier for styling. * `@param` message The message for which the reactions are displayed. - * `@param` reactions The list of reaction options to display. + * `@param` reactions The list of reaction items (type/emoji/count) to display. * `@param` onClick Handler when the reaction list is clicked. The message is provided as a parameter. + * + * Threading: Compose/main thread only. + * State: Treat [reactions] as immutable snapshot state. */As per coding guidelines: 'Document public APIs with KDoc, including thread expectations and state notes'.
stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/theme/ChatComponentFactory.kt (1)
1136-1197:⚠️ Potential issue | 🟡 MinorAdd thread/state notes to MessageContent and MessageReactions KDoc.
These are public APIs, and the signature change makes it a good moment to add thread expectations/state notes.
📝 Suggested KDoc additions
/** * The default content of the message bubble. * Usually contains attachments and text. + * + * Threading: Compose/main thread only. + * State: Treat [messageItem] as immutable UI state. */ @@ /** * The default reactions displayed overlaying the message bubble border. + * + * Threading: Compose/main thread only. + * State: Treat [params] as immutable UI state. */As per coding guidelines: 'Document public APIs with KDoc, including thread expectations and state notes'.
🤖 Fix all issues with AI agents
In
`@stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/state/messages/MessageReactionItemState.kt`:
- Around line 19-30: Update the public KDoc for the data class
MessageReactionItemState to include a short "Thread / State notes" section
describing its expected usage and thread-safety (for example: that instances are
immutable, safe to read from any thread, and represent UI state derived from
Message objects rather than the source message itself), while keeping the
existing `@param` descriptions for type, emoji and count; ensure the new note is
concise and placed in the class-level KDoc so it appears in the public API docs
alongside MessageReactionItemState.
In
`@stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/messages/MessageReactions.kt`:
- Around line 46-53: Add KDoc thread expectations and state notes to the three
public composables AdaptiveMessageReactions, ClusteredMessageReactions, and
SegmentedMessageReactions: update each KDoc block to include a short "Thread
expectations" line (e.g., whether the composable is intended for message list vs
thread/parent messages) and a "State notes" line describing how it reads/depends
on reaction state (local vs server-driven, whether it expects a stable reactions
list, and recomposition behavior). Locate the three symbols
AdaptiveMessageReactions, ClusteredMessageReactions, and
SegmentedMessageReactions in MessageReactions.kt and add the concise KDoc
entries consistent with existing project style for public APIs.
- Around line 188-217: Replace the Compose `@Preview` annotations with the project
helper `@StreamPreview` for the preview composables; update the annotations on
SingleClusteredMessageReactionsPreview,
MultipleClusteredMessageReactionsPreview,
SingleSegmentedMessageReactionsPreview, and
MultipleSegmentedMessageReactionsPreview so they use `@StreamPreview` while
leaving their bodies (which call ClusteredMessageReactions and
SegmentedMessageReactions with PreviewReactionData) unchanged.
- Around line 55-76: In AdaptiveMessageReactions the decision to use the
clustered fallback is wrong because `segmented` is measured with the same
`constraints.maxWidth` so it can never exceed it; change the measurement
strategy to first measure `segmented` with an effectively unconstrained max
width (e.g., copy constraints to remove maxWidth limit) to get its intrinsic
width, then compare that intrinsic width to the original `constraints.maxWidth`;
if it’s larger, measure `clustered` with the original constraints and layout
that, otherwise measure/place `segmented` with the original constraints—update
references to `segmented`, `clustered`, `SubcomposeLayout` and the constraint
copies in `AdaptiveMessageReactions` accordingly.
🧹 Nitpick comments (1)
stream-chat-android-compose/api/stream-chat-android-compose.api (1)
1849-1851: Consider a deprecatedMessageReactionswrapper for migration.The new clustered/segmented/adaptive APIs replace the previous single entry point; a deprecated wrapper delegating to
AdaptiveMessageReactionswould soften upgrade friction for existing users.
...e/src/main/java/io/getstream/chat/android/compose/state/messages/MessageReactionItemState.kt
Show resolved
Hide resolved
...e/src/main/java/io/getstream/chat/android/compose/ui/components/messages/MessageReactions.kt
Outdated
Show resolved
Hide resolved
...e/src/main/java/io/getstream/chat/android/compose/ui/components/messages/MessageReactions.kt
Outdated
Show resolved
Hide resolved
...e/src/main/java/io/getstream/chat/android/compose/ui/components/messages/MessageReactions.kt
Show resolved
Hide resolved
3b79d47 to
ae66083
Compare
7955bec to
39db86d
Compare
...e/src/main/java/io/getstream/chat/android/compose/ui/components/messages/MessageReactions.kt
Show resolved
Hide resolved
589f85b to
6fb7a89
Compare
6fb7a89 to
2187991
Compare
|


Goal
Update message reactions design, including two styles: clustered and segmented
Implementation
MessageReactionItemStatebecause we need to pass the reactions count🎨 UI Changes
Testing
By default we're using segmented. If you want to see the clustered style in the sample you can:
ChatComponentFactory.MessageReactions(easiest option)Summary by CodeRabbit
New Features
Improvements