Skip to content

fix(ux): Filter existing members from channel user autocomplete#38956

Open
Copilot wants to merge 7 commits intodevelopfrom
copilot/fix-add-user-duplicate-channel
Open

fix(ux): Filter existing members from channel user autocomplete#38956
Copilot wants to merge 7 commits intodevelopfrom
copilot/fix-add-user-duplicate-channel

Conversation

Copy link
Contributor

Copilot AI commented Feb 23, 2026

The "Add Users" dialog showed existing channel members in autocomplete results, allowing duplicate selections. Backend handled duplicates gracefully but provided poor UX.

Changes

UserAutoCompleteMultiple component

  • Added exceptions: string[] prop to exclude usernames from API query
  • Updated query key to include exceptions for cache consistency

AddUsers component

  • Fetches current room members (channels/private groups only, limit 100)
  • Extracts and sorts usernames via single reduce operation
  • Passes as exceptions to UserAutoCompleteMultiple

Query optimization

  • Pre-sorts exceptions in AddUsers for memoization
  • Query key expects pre-sorted array to avoid repeated allocations

API test

  • Verifies backend handles duplicate invitations without creating duplicate system messages
// Before: all users shown
<UserAutoCompleteMultiple {...field} />

// After: existing members filtered
<UserAutoCompleteMultiple 
  exceptions={existingMemberUsernames}
  {...field} 
/>

Behavior

  • Query disabled for unsupported room types (e.g., DMs)
  • Graceful degradation: on fetch error, shows all users (backend still prevents duplicates)
  • Channels >100 members may show some existing members in autocomplete (API pagination limit)
Original prompt

This section details on the original issue you should resolve

<issue_title>Added user can be added again in channel</issue_title>
<issue_description>

Description:

When we try adding a user to channel, we just can simply add his name in search bar and add to him in the channel,
Now if we again search his name in add user we can add him again.

Steps to reproduce:

  1. Go to add user in channel
  2. Add a user to channel
  3. Again search his name in the list.

Expected behavior:

If user is already in channel he/she should not be in list to get added

Actual behavior:

We can add the user again !

Screenshot from 2019-03-22 01-03-28

You can see doodle1 is already in channel and yet we can add him again.

</issue_description>

<agent_instructions>Check if we already have an API test for this; if not, create one and make the fix.</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@geekgonecrazy from the screenshot it looks like doodle1 was actually removed from the channel when you are about to insert 🤔

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Feb 23, 2026

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link

changeset-bot bot commented Feb 23, 2026

⚠️ No Changeset found

Latest commit: 8c8c9f6

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copilot AI and others added 5 commits February 23, 2026 23:17
Co-authored-by: ggazzo <5263975+ggazzo@users.noreply.github.com>
…ut member limit

Co-authored-by: ggazzo <5263975+ggazzo@users.noreply.github.com>
Co-authored-by: ggazzo <5263975+ggazzo@users.noreply.github.com>
Co-authored-by: ggazzo <5263975+ggazzo@users.noreply.github.com>
Co-authored-by: ggazzo <5263975+ggazzo@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix duplicate user addition in channel Fix: Filter existing members from channel user autocomplete Feb 23, 2026
Copilot AI requested a review from ggazzo February 23, 2026 23:24
@ggazzo ggazzo changed the title Fix: Filter existing members from channel user autocomplete fix(ux): Filter existing members from channel user autocomplete Feb 24, 2026
@ggazzo ggazzo added this to the 8.3.0 milestone Feb 24, 2026
@ggazzo ggazzo requested a review from dougfabris February 24, 2026 14:12
@ggazzo ggazzo marked this pull request as ready for review February 24, 2026 14:12
@ggazzo ggazzo requested review from a team as code owners February 24, 2026 14:12
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 4 files

@codecov
Copy link

codecov bot commented Feb 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.63%. Comparing base (3048477) to head (8c8c9f6).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #38956      +/-   ##
===========================================
- Coverage    70.64%   70.63%   -0.01%     
===========================================
  Files         3189     3189              
  Lines       112715   112718       +3     
  Branches     20363    20392      +29     
===========================================
- Hits         79627    79619       -8     
- Misses       31044    31055      +11     
  Partials      2044     2044              
Flag Coverage Δ
unit 71.16% <100.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Added user can be added again in channel

3 participants