Skip to content

Base: Look up display name ambiguity under the name a member is shown with - #7010

Open
SamuraiF0x wants to merge 2 commits into
matrix-org:mainfrom
SamuraiF0x:base/ambiguity-rendered-name
Open

SamuraiF0x wants to merge 2 commits into
matrix-org:mainfrom
SamuraiF0x:base/ambiguity-rendered-name

Conversation

@SamuraiF0x

@SamuraiF0x SamuraiF0x commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

The ambiguity index is keyed by the name a member set themselves, which is also what RoomMember::name renders: own profile, then the latest member event, then the localpart. But the lookup behind RoomMember::name_ambiguous used the latest member event's name. The two differ for a kicked member: the kick event carries no display name, and the profile writer deliberately keeps the member's own profile, so the member is still shown under their old name while the lookup asked about their localpart and always came back unambiguous.

Concretely, with three members sharing a display name and one of them kicked, the kicked member's messages render under the shared name without disambiguation while the two remaining members are disambiguated.

The fix resolves the name once, through a helper that RoomMember::display_name now shares so the two cannot drift, and uses it for the lookup in members, get_member and from_parts. No public API changes. The new test drives the scenario through sync and the real profile writer; it fails on name_ambiguous() without the fix.

This touches the same lines as #7004, whichever merges second rebases trivially.

  • I've documented the public API changes in the appropriate changelog files (see Writing changelog entries).
  • This PR was made with the help of AI.

Signed-off-by: Šimun Kordiš kordis.simun@gmail.com

@SamuraiF0x
SamuraiF0x requested a review from a team as a code owner September 9, 2026 01:20
@SamuraiF0x
SamuraiF0x requested review from poljar and removed request for a team September 9, 2026 01:20
@codecov

codecov Bot commented Sep 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.27%. Comparing base (2e2f867) to head (ed0ae9c).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7010      +/-   ##
==========================================
+ Coverage   90.26%   90.27%   +0.01%     
==========================================
  Files         408      408              
  Lines      117566   117612      +46     
  Branches   117566   117612      +46     
==========================================
+ Hits       106121   106175      +54     
+ Misses       7491     7483       -8     
  Partials     3954     3954              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@codspeed

codspeed Bot commented Sep 9, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 50 untouched benchmarks


Comparing SamuraiF0x:base/ambiguity-rendered-name (ed0ae9c) with main (2e2f867)

Open in CodSpeed

…shown with

The ambiguity index is keyed by the name a member set themselves, and `RoomMember::name` renders that same name: the member's own profile first, then the latest member event, then the localpart. The lookup that sets `RoomMember::name_ambiguous` used the latest member event's name instead. The two differ for a kicked member: the kick event carries no display name, but the profile writer keeps the member's own profile, so they are still shown under their old name while the lookup asked about their localpart and always came back unambiguous. With three members sharing a name and one of them kicked, the kicked member's messages rendered under the shared name with no disambiguation while the other two were disambiguated. Resolve the name once, shared with `RoomMember::display_name` so the two cannot drift, and use it for the lookup in `members`, `get_member` and `from_parts`.

Signed-off-by: Šimun Kordiš <kordis.simun@gmail.com>
Signed-off-by: Šimun Kordiš <kordis.simun@gmail.com>
@SamuraiF0x
SamuraiF0x force-pushed the base/ambiguity-rendered-name branch from 5a1a632 to ed0ae9c Compare September 9, 2026 08:34
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.

1 participant