Skip to content

ui-common: Ignore mention suggestions that start with whitespace#6526

Open
gpunto wants to merge 1 commit into
developfrom
fix/mention-lookup-trim-whitespace-query
Open

ui-common: Ignore mention suggestions that start with whitespace#6526
gpunto wants to merge 1 commit into
developfrom
fix/mention-lookup-trim-whitespace-query

Conversation

@gpunto

@gpunto gpunto commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Goal

In the message composer, typing @ followed by spaces keeps the mention suggestion active with a whitespace-only query, which makes the group/role lookup return everything.

TypingSuggester.typingSuggestion lets a suggestion token start with whitespace, so @ produces a " " query that is forwarded to the lookup. The fix rejects suggestions that start with whitespace, while still allowing internal spaces so multi-word names (e.g. @John Doe) remain searchable.

Closes AND-1268

Implementation

  • TypingSuggester now returns no suggestion when the token starts with whitespace. Internal and trailing spaces are still part of the token, so multi-word names keep working.

Testing

  • New TypingSuggesterTest: empty token, single-word and mid-text tokens, multi-word and trailing-space tokens, and the leading-whitespace cases that now produce no suggestion.

Summary by CodeRabbit

  • Bug Fixes
    • Improved mention suggestions so matches are no longer shown when the suggested text starts with whitespace, while still allowing valid internal spacing.
  • Tests
    • Added coverage for mention suggestion behavior across common typing cases and invalid whitespace patterns.

@gpunto gpunto added the pr:bug Bug fix label Jun 26, 2026
@github-actions

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.

@github-actions

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.15 MB 11.15 MB 0.00 MB 🟢
stream-chat-android-compose 12.63 MB 12.63 MB 0.00 MB 🟢

@sonarqubecloud

Copy link
Copy Markdown

@gpunto gpunto marked this pull request as ready for review June 26, 2026 11:41
@gpunto gpunto requested a review from a team as a code owner June 26, 2026 11:41
@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 8779fbb6-a1be-4b2a-9ff2-a6c2edd7e508

📥 Commits

Reviewing files that changed from the base of the PR and between 636018c and d7bf8c9.

📒 Files selected for processing (2)
  • stream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/feature/messages/composer/typing/TypingSuggester.kt
  • stream-chat-android-ui-common/src/test/kotlin/io/getstream/chat/android/ui/common/feature/messages/composer/typing/TypingSuggesterTest.kt

Walkthrough

typingSuggestion now rejects suggestion text that starts with whitespace, and a new parameterized test suite covers valid mention tokens and invalid whitespace and formatting cases.

Changes

Typing suggester whitespace handling

Layer / File(s) Summary
Whitespace guard and test coverage
stream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/feature/messages/composer/typing/TypingSuggester.kt, stream-chat-android-ui-common/src/test/kotlin/io/getstream/chat/android/ui/common/feature/messages/composer/typing/TypingSuggesterTest.kt
typingSuggestion returns null when the derived suggestion text begins with whitespace, and a parameterized test class checks matching and non-matching mention inputs.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

A tiny hop, a rabbit's grin 🐰
No leading space may sneak back in
@john may bloom, but @ must flee
Hop-hop! The suggester now agrees

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% 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 clearly matches the main bugfix: ignoring mention suggestions that begin with whitespace.
Description check ✅ Passed The description includes Goal, Implementation, and Testing with enough detail for this bugfix, and the missing visual sections are not critical.
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.
✨ 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 fix/mention-lookup-trim-whitespace-query

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.

@andremion andremion left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

One thing on cross-SDK parity: No iOS SDK has this leading-whitespace guard. Looks like the same bug exists on iOS. Should we file equivalent fixes on iOS so the behavior stays aligned?

Minor, not blocking: the Android check uses isWhitespace() (covers tabs and other Unicode whitespace), while iOS only treats " " and "\n" as separators. That difference is pre-existing, just noting it in case we want the platforms to classify edge inputs the same way.

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