fix(desktop): offer shared relay agents in @ mention autocomplete (#3971) - #4058
Open
iroiro147 wants to merge 1 commit into
Open
fix(desktop): offer shared relay agents in @ mention autocomplete (#3971)#4058iroiro147 wants to merge 1 commit into
iroiro147 wants to merge 1 commit into
Conversation
…ock#3971) On a multi-device or team setup, an agent hosted on machine A (buzz-acp, NIP-OA attested, channel member, in the relay directory with respond_to=anyone) never appeared in the @ autocomplete on machine B even though the members panel showed it. The composer had no way to send it a p-tag mention. Root cause: addCandidate in useMentions.ts dropped any isAgent candidate not in the LOCAL managed-agent list: if (!isAgentIdentityInManagedList(candidate, managedAgentPubkeys)) return; This ran BEFORE shouldHideAgentFromMentions, whose mentionableAgentPubkeys set (built from relayAgentIsSharedWithUser — directory agents sharing a channel with respond_to=anyone/allowlist) is exactly what is meant to make shared relay agents mentionable. The early local-only filter made that machinery unreachable dead code for any agent hosted on another machine. Fix: admit the candidate when it is either locally managed OR in the relay-mentionable set: if (!isAgentIdentityInManagedList(candidate, managedAgentPubkeys) && !mentionableAgentPubkeys.has(pubkey)) return; shouldHideAgentFromMentions still applies downstream (it independently consults mentionableAgentPubkeys), so noise-gating is preserved: remote agents NOT relay-shared with the user are still dropped. Pinned: 2 tests in agentAutocompleteEligibility.test.mjs — a shared relay agent not in the local managed list is admitted, and a non-shared non-local agent is still rejected. Verified: pnpm typecheck clean, biome clean, 20/20 eligibility tests + mention suite pass. Fixes block#3971 Signed-off-by: iroiro147 <sarthak.singh@juspay.in>
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.
Summary
Fixes #3971 — the
@mention autocomplete never offered remotely-hosted agents, even when they were channel members, appeared in the members panel, and were registered in the relay agent directory withrespond_to=anyone.Root cause
In
desktop/src/features/messages/lib/useMentions.ts,addCandidatedropped anyisAgentcandidate not in the local managed-agent list:This ran before
shouldHideAgentFromMentions, whosementionableAgentPubkeysset (built fromrelayAgentIsSharedWithUser— directory agents that share a channel with the user and advertiserespond_to=anyoneor an allowlist match) is precisely the machinery meant to make shared relay agents mentionable. The early local-only filter made that set unreachable dead code for any agent hosted on another machine.Fix
Admit the candidate when it is either locally managed or in the relay-mentionable set:
shouldHideAgentFromMentionsstill runs downstream and independently consultsmentionableAgentPubkeys, so noise-gating is preserved: a remote agent that is not relay-shared with the user is still dropped.Verification
pnpm typecheck— cleanpnpm exec biome check— clean (both touched files)node --import ./test-loader.mjs --experimental-strip-types --test src/features/agents/lib/agentAutocompleteEligibility.test.mjs— 20/20 pass (18 baseline + 2 new pinning tests)mentionCandidates.test.mjs,mentionRanking.test.mjs) — greenTests added
agentAutocompleteEligibility.test.mjs, pinning the new admit condition:Impact
Multi-device / team setups where an agent runs on one machine and users chat from another now get real
@Nameautocomplete →p-tag delivery. Workarounds (thread replies to p-tag the parent author, agent-side content-matching rules) are no longer needed.