Skip to content

Add composer autocomplete for enhanced mentions in XML SDK#6510

Merged
gpunto merged 1 commit into
developfrom
pr5-enhanced-mentions-xml-composer
Jun 22, 2026
Merged

Add composer autocomplete for enhanced mentions in XML SDK#6510
gpunto merged 1 commit into
developfrom
pr5-enhanced-mentions-xml-composer

Conversation

@gpunto

@gpunto gpunto commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Goal

Bring @channel, @here, role, and user-group composer suggestions to the XML SDK, matching the Compose composer from PR 4.

PR 5 in the enhanced-mentions series. Part of AND-1175.

Implementation

  • Composer suggestions now render List<Mention> instead of List<User>. Non-user mentions use a new stream_ui_item_mention_special row (icon + @name + subtitle).
  • New selectMention(Mention) overload, onSuggestedMentionSelection binder method, and suggestedMentionSelectionListener.
  • The old user-only mentionSelectionListener / setItems(List<User>) are deprecated but still work for user mentions.

UI Changes

Before After
Screenshot_20260622_100900 Screenshot_20260622_100810

Testing

  • MessageComposerViewModelTest: new cases assert each non-user mention type surfaces correctly.
  • Manual: type @ in the sample composer, confirm channel/here/role/group/user suggestions appear and the picked token survives Send.

Summary by CodeRabbit

Release Notes

  • New Features

    • Added support for mentioning special groups (roles, channel members, online members) alongside individual users.
    • Enhanced mention suggestions with icons and context-specific subtitles for improved clarity.
    • Multi-language support added for mention suggestions across Spanish, French, Hindi, Indonesian, Italian, Japanese, and Korean.
  • Documentation

    • Updated examples for mention suggestion handling.

@gpunto gpunto added the pr:new-feature New feature label Jun 22, 2026
@github-actions

github-actions Bot commented Jun 22, 2026

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.

@gpunto

gpunto commented Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 22, 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

github-actions Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

SDK Size Comparison 📏

SDK Before After Difference Status
stream-chat-android-client 5.90 MB 5.90 MB 0.00 MB 🟢
stream-chat-android-ui-components 11.14 MB 11.15 MB 0.01 MB 🟢
stream-chat-android-compose 12.61 MB 12.61 MB 0.00 MB 🟢

@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

The PR extends MessageComposerView mention suggestions from user-only (User) to a heterogeneous Mention model (channel, here, role, group). It adds suggestedMentionSelectionListener, deprecates mentionSelectionListener, refactors MentionSuggestionsAdapter with two view holders, introduces new layouts/drawables/localized strings, adds a selectMention(Mention) ViewModel overload, wires it through binder/binding, and adds parameterized tests.

Changes

Heterogeneous Mention Suggestions

Layer / File(s) Summary
Public API contracts: suggestedMentionSelectionListener
...api/stream-chat-android-ui-components.api, ...composer/MessageComposerView.kt, ...content/DefaultMessageComposerMentionSuggestionsContent.kt
Declares suggestedMentionSelectionListener on MessageComposerMentionSuggestionsContent and MessageComposerView, marks mentionSelectionListener as deprecated, adds setMentions(List<Mention>) to MentionSuggestionsAdapter, and updates the .api surface file for all new members.
Adapter refactor, view holders, and UI resources
...content/DefaultMessageComposerMentionSuggestionsContent.kt, ...res/layout/stream_ui_item_mention_special.xml, ...res/drawable/stream_ui_shape_mention_icon_avatar.xml, ...res/drawable/stream_design_ic_users.xml, ...res/values*/strings.xml
Replaces the single user-only adapter with a RecyclerView.Adapter using view types; adds UserMentionsViewHolder and SpecialMentionsViewHolder; introduces a special mention row layout, oval avatar drawable, users icon, and onMentionSelected dispatching. Adds three localized subtitle strings across all supported locales (en, es, fr, hi, in, it, ja, ko).
MessageComposerView render wiring
...composer/MessageComposerView.kt, ...content/DefaultMessageComposerLeadingContent.kt
Switches the backing mentionSuggestions list to List<Mention>, routes state.suggestedMentions to the popup renderer, wires both listeners into default and custom content, and updates hasMentionSuggestions to use suggestedMentions.
ViewModel overload and binder/binding wiring
...viewmodel/messages/MessageComposerViewModel.kt, ...MessageComposerViewModelBinder.kt, ...MessageComposerViewModelBinding.kt
Adds selectMention(Mention) overload, adds onSuggestedMentionSelection fluent binder method, extends bindView/bindViewDefaults signatures with the new listener parameter, and adds the default suggestedMentionSelectionListener implementation in MessageComposerViewModelDefaults.
Tests and doc examples
...ui/viewmodels/messages/MessageComposerViewModelTest.kt, ...docs/kotlin/ui/messages/MessageComposer.kt
Adds a parameterized test covering non-user Mention suggestions (channel, here, role, group) with fixture stubs for searchRoles/searchUserGroups; updates all four MessageComposer.kt doc examples to use suggestedMentionSelectionListener and selectMention(mention).

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant MessageComposerView
    participant DefaultMessageComposerMentionSuggestionsContent
    participant MentionSuggestionsAdapter
    participant MessageComposerViewModel

    User->>MessageComposerView: types `@mention` query
    MessageComposerView->>MessageComposerViewModel: state.suggestedMentions updated
    MessageComposerViewModel-->>MessageComposerView: emits MessageComposerState
    MessageComposerView->>DefaultMessageComposerMentionSuggestionsContent: renderState(state)
    DefaultMessageComposerMentionSuggestionsContent->>MentionSuggestionsAdapter: setMentions(state.suggestedMentions)
    MentionSuggestionsAdapter-->>DefaultMessageComposerMentionSuggestionsContent: renders UserMentionsViewHolder or SpecialMentionsViewHolder
    User->>DefaultMessageComposerMentionSuggestionsContent: taps mention row
    DefaultMessageComposerMentionSuggestionsContent->>DefaultMessageComposerMentionSuggestionsContent: onMentionSelected(mention)
    DefaultMessageComposerMentionSuggestionsContent->>MessageComposerView: suggestedMentionSelectionListener(mention)
    MessageComposerView->>MessageComposerViewModel: selectMention(mention)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

  • GetStream/stream-chat-android#6503: Implements the same mention-autocomplete upgrade by switching composer selection callbacks from user-only to Mention-based (selectMention(Mention)/onMentionSelected wiring).

Suggested reviewers

  • andremion
  • aleksandar-apostolov

Poem

🐰 Hop, hop! A mention blooms,
No longer just a user's name in rooms.
Channel, here, role, or group —
All fall into the mention loop!
The adapter now renders each in turn,
As the rabbit watches strings return. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 35.90% 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
Title check ✅ Passed The title directly and clearly describes the main change: adding composer autocomplete for enhanced mentions in the XML SDK.
Description check ✅ Passed The description includes Goal, Implementation, UI Changes with before/after screenshots, and Testing sections, matching the required template structure with substantive details.
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.

✏️ 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 pr5-enhanced-mentions-xml-composer

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.

@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: 1

🤖 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-ui-components/src/main/kotlin/io/getstream/chat/android/ui/viewmodel/messages/MessageComposerViewModelBinding.kt`:
- Around line 114-123: The issue is that both mentionSelectionListener and
suggestedMentionSelectionListener are being bound in the bindMessageComposerView
function (lines 121-122), and this causes Mention.User selections to be
processed twice because the default mention selection handler at line 263 also
calls selectMention. Remove the binding of one of these listeners or refactor
the default handler logic to avoid duplicating the mention selection processing
that is already handled by the bound listeners. The same duplication pattern
also occurs in other similar binding locations referenced in the comment (lines
201-202 and 231-233).
🪄 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

Run ID: 466c1a77-708d-452a-8245-4d69d9b7d995

📥 Commits

Reviewing files that changed from the base of the PR and between ab96b71 and 21b40b6.

📒 Files selected for processing (20)
  • stream-chat-android-docs/src/main/kotlin/io/getstream/chat/docs/kotlin/ui/messages/MessageComposer.kt
  • stream-chat-android-ui-common/src/main/res/drawable/stream_design_ic_users.xml
  • stream-chat-android-ui-components/api/stream-chat-android-ui-components.api
  • stream-chat-android-ui-components/src/main/kotlin/io/getstream/chat/android/ui/feature/messages/composer/MessageComposerView.kt
  • stream-chat-android-ui-components/src/main/kotlin/io/getstream/chat/android/ui/feature/messages/composer/content/DefaultMessageComposerLeadingContent.kt
  • stream-chat-android-ui-components/src/main/kotlin/io/getstream/chat/android/ui/feature/messages/composer/content/DefaultMessageComposerMentionSuggestionsContent.kt
  • stream-chat-android-ui-components/src/main/kotlin/io/getstream/chat/android/ui/viewmodel/messages/MessageComposerViewModel.kt
  • stream-chat-android-ui-components/src/main/kotlin/io/getstream/chat/android/ui/viewmodel/messages/MessageComposerViewModelBinder.kt
  • stream-chat-android-ui-components/src/main/kotlin/io/getstream/chat/android/ui/viewmodel/messages/MessageComposerViewModelBinding.kt
  • stream-chat-android-ui-components/src/main/res/drawable/stream_ui_shape_mention_icon_avatar.xml
  • stream-chat-android-ui-components/src/main/res/layout/stream_ui_item_mention_special.xml
  • stream-chat-android-ui-components/src/main/res/values-es/strings.xml
  • stream-chat-android-ui-components/src/main/res/values-fr/strings.xml
  • stream-chat-android-ui-components/src/main/res/values-hi/strings.xml
  • stream-chat-android-ui-components/src/main/res/values-in/strings.xml
  • stream-chat-android-ui-components/src/main/res/values-it/strings.xml
  • stream-chat-android-ui-components/src/main/res/values-ja/strings.xml
  • stream-chat-android-ui-components/src/main/res/values-ko/strings.xml
  • stream-chat-android-ui-components/src/main/res/values/strings.xml
  • stream-chat-android-ui-components/src/test/kotlin/io/getstream/chat/android/ui/viewmodels/messages/MessageComposerViewModelTest.kt

@gpunto gpunto force-pushed the pr5-enhanced-mentions-xml-composer branch from 21b40b6 to dcb3e99 Compare June 22, 2026 08:31
@sonarqubecloud

Copy link
Copy Markdown

@gpunto gpunto marked this pull request as ready for review June 22, 2026 10:30
@gpunto gpunto requested a review from a team as a code owner June 22, 2026 10:30
@gpunto gpunto merged commit 2cad4de into develop Jun 22, 2026
23 of 24 checks passed
@gpunto gpunto deleted the pr5-enhanced-mentions-xml-composer branch June 22, 2026 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:new-feature New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants