Show Giphy preview in channel list message previews#6310
Conversation
Co-Authored-By: Claude <noreply@anthropic.com>
PR checklist ✅All required conditions are satisfied:
🎉 Great job! This PR is ready for review. |
stream-chat-android-compose/src/main/res/drawable/stream_compose_ic_giphy.xml
Show resolved
Hide resolved
WalkthroughThese changes add GIPHY attachment support to the message preview system. A new GIPHY icon drawable and localized string resource are introduced, along with logic to detect GIPHY attachments and render them with the corresponding icon and label in message previews. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
SDK Size Comparison 📏
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/util/MessagePreviewFormatter.kt (1)
294-298: Add a regression test for GIPHY-vs-link precedence.The new branch ordering is correct, but this is easy to regress later. Please add coverage ensuring GIPHY attachments render the Giphy preview (icon + label) even when link fields are also present.
🤖 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/util/MessagePreviewFormatter.kt` around lines 294 - 298, Add a regression unit test that verifies GIPHY attachments take precedence over link previews: in the MessagePreviewFormatter tests (e.g., MessagePreviewFormatterTest) create a message/Attachment with giphy fields set (so giphy.isNotEmpty() triggers) and also include link metadata fields, invoke the formatter method that builds the preview (the code path containing appendInlineContent(DefaultMessagePreviewIconFactory.GIPHY) / append(context.getString(R.string.stream_compose_giphy_preview))) and assert the resulting preview contains the GIPHY icon/label and does not render the link preview text; if there’s no existing test helper, mock or build the Attachment/Message models used by formatPreview to reproduce this branch.
🤖 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/util/MessagePreviewFormatter.kt`:
- Around line 294-298: Add a regression unit test that verifies GIPHY
attachments take precedence over link previews: in the MessagePreviewFormatter
tests (e.g., MessagePreviewFormatterTest) create a message/Attachment with giphy
fields set (so giphy.isNotEmpty() triggers) and also include link metadata
fields, invoke the formatter method that builds the preview (the code path
containing appendInlineContent(DefaultMessagePreviewIconFactory.GIPHY) /
append(context.getString(R.string.stream_compose_giphy_preview))) and assert the
resulting preview contains the GIPHY icon/label and does not render the link
preview text; if there’s no existing test helper, mock or build the
Attachment/Message models used by formatPreview to reproduce this branch.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: fe9d841e-e91d-4c0c-81e2-0c60e4fcb820
📒 Files selected for processing (4)
stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/util/MessagePreviewFormatter.ktstream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/util/MessagePreviewIconFactory.ktstream-chat-android-compose/src/main/res/drawable/stream_compose_ic_giphy.xmlstream-chat-android-compose/src/main/res/values/strings.xml
|


Goal
Giphy messages in the channel list were considered as links. This brings Giphy in line with how photos, videos, files, and other attachment types are displayed.
Implementation
AttachmentType.GIPHYclassification inDefaultMessagePreviewFormatter.appendTypedAttachmentPreview()with icon + "Giphy" labelGIPHYconstant and inline icon entry inDefaultMessagePreviewIconFactoryusing a newstream_compose_ic_giphydrawablestream_compose_ic_giphy.xmlvector drawable (12dp document-style icon)stream_compose_giphy_previewstring resourceUI Changes
giphy_preview_before.mp4
giphy_preview_after.mp4
Testing
Summary by CodeRabbit
Release Notes