Repository navigation
fix(mobile): tag all candidates when an @mention is ambiguous - #4371
Closed
CryptoJones wants to merge 1 commit into
Closed
CryptoJones wants to merge 1 commit into
CryptoJones wants to merge 1 commit into
Conversation
_resolveMentions took the first profile whose display name matched and broke out of the loop. When two members share a display name — a stale identity left behind by a re-key is the common case — "first match" means whichever entry the user-cache Map happened to yield first, so the `p` tag landed on an arbitrary one of them. In practice this made mention delivery depend on map ordering: some names resolved to the live identity and worked, others resolved to a dead one and silently notified nobody. The agent never saw a `p` tag for itself, and nothing surfaced to the sender to indicate the mention had gone nowhere. buzz-cli rejects an ambiguous mention outright and directs the user to retry with an explicit --mention <pubkey>, but mobile has no way to supply one, so failing would leave a duplicated display name permanently unmentionable. Tag every candidate instead: the intended recipient stays reachable, at the cost of a redundant `p` tag on the identities sharing that name. Adds a regression test that fails against the previous behaviour. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SZQxkSFrkD6MHCLz6wbYkr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the mobile half of #4303.
The bug
_resolveMentionsinmobile/lib/features/channels/send_message_provider.darttook the first profile whose display name matched and stopped:There is no ambiguity detection. When two channel members share a display name,
cacheis aMap, so "the first match" is really "whichever entry the map happened to yield first" — and that decides which pubkey lands in theptag.Why it matters
Agents match mentions purely on
ptags (event_mentions_agentincrates/buzz-acp/src/lib.rs). If the tag names the wrong identity, the intended agent never sees the mention — and nothing surfaces to the sender.This was found in a community where five bot display names each resolved to two pubkeys: a live identity and a stale one left behind by a re-key. The observed behaviour was that some agents answered
@Nameand others silently never did, consistently, for hours. It read as "the agents are ignoring me". Mentioning the same agent in the same channel with an explicit pubkey got a reply in seconds.The split was purely map ordering: names whose live profile happened to be enumerated first worked; the rest tagged a dead identity.
buzz-clialready handles this correctly —resolve_names_to_pubkeysreturns aCliError::Usagelisting the candidates, with the comment:Mobile silently did the thing that comment warns against.
The change
Collect every matching candidate instead of breaking at the first, and tag them all.
Erroring the way the CLI does would be more consistent, but the CLI's remedy is "retry with
--mention <pubkey>" and mobile has no way to supply one — so failing would leave a duplicated display name permanently unmentionable from the phone. Tagging all candidates keeps the intended recipient reachable; the cost is a redundantptag on the other identities sharing that name.Channel-member scoping is unchanged, so candidates are still restricted to members of the channel being posted to.
Tests
Adds
tags every candidate when a display name is ambiguous, which builds two members sharing a display name with the stale one deliberately ordered first — the production condition. Verified it fails against the previous behaviour (+1 -1 … [E]) and passes with the change.dart analyze lib test— no issuesflutter test test/features/channels/send_message_provider_test.dart— 3/3 passflutter test— 1022 pass, 1 pre-existing failure inchannel_detail_page_test.dartthat reproduces identically on unmodifiedupstream/mainNote
This fixes mention resolution in the presence of duplicate display names. It does not prevent duplicate display names from existing — #4303 also covers
agents archivereportingok:truewithout applying, and archived identities still appearing inusers get --name, both of which are relay-side and unaddressed here.🤖 Generated with Claude Code
https://claude.ai/code/session_01SZQxkSFrkD6MHCLz6wbYkr
Proudly Made in Nebraska. Go Big Red! 🌽 https://xkcd.com/2347/