fix(desktop): show invocable relay-directory agents in mention/add gate [HIV-13]#1
Merged
jjgarciarovira merged 1 commit intoJul 25, 2026
Conversation
…te [HIV-13] PR block#2149 (a4dfead) added `isAgentIdentityInManagedList`, which drops any candidate flagged `isAgent` whose pubkey is not in the viewer's LOCAL managed-agents list. That gate runs in mention autocomplete (useMentions) and the add-members picker (MembersSidebar). The gate is too narrow for box-run resident agents: NIP-OA-badged agents that run on a shared relay get `isAgent=true` from a valid owner-auth tag in their kind:0, and advertise a proper kind:10100 directory card with respond_to:"anyone" and shared channel_ids. They are legitimately invocable by the viewer, but they never appear in any single viewer's local managed list, so block#2149 made them invisible to both mention and add. Widen the gate to admit an agent candidate when its normalized pubkey is in EITHER the locally-managed set OR the mentionable set (locally-managed union relay-directory agents shared with the viewer, as already computed by getMentionableAgentPubkeys and used by shouldHideAgentFromMentions). A bare agent badge with no directory relationship is still dropped, so block#2149's dedup/ranking intent is preserved -- this only restores agents the viewer can actually invoke. - eligibility: isAgentIdentityInManagedList takes the mentionable set as a third arg and admits via either set. - useMentions: pass the mentionableAgentPubkeys it already computes. - MembersSidebar: build the same set (useChannelsQuery + getMentionableAgentPubkeys/getSharedChannelIds) and pass it. - tests: cover invocable-relay-agent admission and the neither-set drop; update existing call-site tests for the new arity. useMentions memos were tightened (folded the single-use sharedChannelIds memo, compacted personaNameByPubkey) to keep the file within the 1000-line size guard.
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
Relay-directory agents that are invocable and shared with the viewer were being hidden from both mention autocomplete and the add-members picker. This restores them while preserving PR block#2149's dedup/ranking intent.
Linear: HIV-13
Problem
A "box-run resident" agent — a NIP-OA-badged agent that runs on a shared relay — is invisible in the desktop client:
@-mentioned (mention autocomplete never lists it).This happens even when the agent has a valid owner-auth tag in its
kind:0(soisAgent === true) and a properkind:10100relay-directory card withrespond_to: "anyone"and sharedchannel_ids— i.e. it is genuinely invocable by the viewer.Root cause
PR block#2149 (
a4dfead2) introducedisAgentIdentityInManagedListand applied it as an eligibility gate in two places:desktop/src/features/messages/lib/useMentions.ts:249— mention autocomplete candidate builder.desktop/src/features/channels/ui/MembersSidebar.tsx:273— add-members search-result builder.The original gate drops any candidate flagged
isAgentwhose pubkey is not in the viewer's local managed-agents list:Box-run resident agents are
isAgent === true(valid owner-auth badge) but are never in any single viewer's local managed list — they live on the relay, not on the viewer's machine. So the gate rejected them.Note that the sibling gate
shouldHideAgentFromMentions(agentAutocompleteEligibility.ts) already handled invocability correctly viamentionableAgentPubkeys; onlyisAgentIdentityInManagedListwas too narrow, so it short-circuited the candidate before the invocability logic ever ran.The change — two admission paths
isAgentIdentityInManagedList(candidate, managedAgentPubkeys, mentionableAgentPubkeys)now admits a non-agent candidate unconditionally, and admits an agent candidate when its normalized pubkey is in either set:managedAgentPubkeys— agents the viewer manages locally. This is the original fix(desktop): prefer live agent mentions block/buzz#2149 path: a bareisAgentbadge with no relationship is still not enough on its own.mentionableAgentPubkeys— agents the viewer can actually invoke: locally-managed ∪ relay-directory (kind:10100) agents shared with the viewer (respond_to: "anyone"in a shared channel, or an allowlist that includes the viewer). This is the same set already produced bygetMentionableAgentPubkeysand consumed byshouldHideAgentFromMentions.Because a candidate still needs to be reachable through one of these two paths, a bare agent badge with no directory relationship is still dropped — block#2149's dedup/ranking behavior is unchanged; this only restores agents the viewer can legitimately invoke.
Wiring:
useMentions.tspasses thementionableAgentPubkeysmemo it already computes (no new query).MembersSidebar.tsxbuilds the same set locally viauseChannelsQuery+getMentionableAgentPubkeys/getSharedChannelIds, using the component's existingcurrentPubkey,relayAgentsQuery, andmanagedAgentsQuery.Test coverage
desktop/src/features/agents/lib/agentAutocompleteEligibility.test.mjs:admits invocable relay agents via the mentionable set— covers (a) anisAgentcandidate in the mentionable-but-not-managed set is admitted (incl. mixed-case pubkey normalization), (b) anisAgentcandidate in neither set is dropped, and (c) a non-agent is unaffected.keeps people and only current managed agent identitiesfor the new three-arg arity (managed-only behavior verified with an empty mentionable set).Checks run against the desktop TS surface (what CI's
desktop-check/desktop-typecheck/desktop-testrun):pnpm check(biome + file-size + px-text + pubkey-truncation guards) — passpnpm typecheck(tsc --noEmit) — passpnpm test— 3372 pass, 0 fail (19 in the eligibility suite)useMentions.tssat exactly at the 1000-line size guard, so the necessary +6 lines were reclaimed within the same file by folding the single-usesharedChannelIdsmemo intomentionableAgentPubkeysand compacting the adjacentpersonaNameByPubkeymemo (both behavior-preserving; file is now 998 lines).Rollout note
This is a desktop client-side change only — no relay/protocol change. Users must rebuild / update the desktop app to pick it up; already-running installs will keep hiding these agents until updated.
Review
3442labs/buzz(Q's primary repo). Upstreamable toblock/buzzlater.