fix(desktop): shared relay agents are un-mentionable/un-addable — let directory eligibility run
Closes #2603
Summary
A shared relay agent (kind:0 + NIP-OA auth tag, kind:10100 directory profile with respond_to: anyone, channel member) responds fine when p-tagged, but nobody except its owning device can @-complete it or add it to channels: addCandidate in useMentions.ts drops every agent-flagged identity that isn't in the local managed-agents list before shouldHideAgentFromMentions runs, making the directory-eligibility path (mentionableAgentPubkeys, and the "Invocable => always show" / member Option-B rules) unreachable for foreign agents. MembersSidebar applies the same managed-list-only gate to add-member search.
Changes
useMentions.ts: remove the pre-emptiveisAgentIdentityInManagedListgate.shouldHideAgentFromMentionsis the single authority — it already shows invocable agents (local managed ∪ relay-directory-eligible), hides non-member non-invocable ones, and applies the member/directory rules. Local managed agents are unaffected (they're seeded intomentionableAgentPubkeys), and other members'owner-onlyagents stay hidden (non-member + non-invocable, or member + directory-excluded).MembersSidebar.tsx: add-member candidates now pass when the agent is locally managed or relay-directory invocable by the current user (newrelayAgentIsInvocableByUser:respond_to: anyone, or an allowlist containing them). Channel overlap is deliberately not required here — adding the agent to the channel is what creates the overlap.agentAutocompleteEligibility.ts: newrelayAgentIsInvocableByUserhelper;relayAgentIsSharedWithUserdelegates its allowlist branch to it (behavior unchanged); doc comment onisAgentIdentityInManagedListclarifying the caller-supplied allow-set contract.
Test plan
node --import ./test-loader.mjs --experimental-strip-types --testonagentAutocompleteEligibility.test.mjs: 22/22 (4 new: invocable-by-user modes, and a regression test that a directory-eligible member agent is shown without a local managed entry).biome checkandtsc --noEmitclean on touched files.- Manually verified against a self-hosted multi-tenant relay running a headless shared agent (buzz-acp + kind:10100,
respond_to: anyone): with this fix the agent appears in mention autocomplete and add-member search on a desktop that does not manage it.
🤖 Generated with Claude Code
Confirming the root cause from another angle in case it's useful for the review.
Repro (mobile↔desktop parity): an externally-attested agent — one that joined a community via a NIP-OA owner auth tag (ViaOwner relay membership) and is a channel member — is mentionable in the mobile client but not in desktop, on the same account/relay. Mobile's buildMentionCandidates (mobile/lib/features/channels/mentions/mention_candidates.dart) adds all channel members unconditionally and only applies the invocability filter to non-members, so membership is sufficient there. On desktop, isAgentIdentityInManagedList (added in #2149) runs inside addCandidate before shouldHideAgentFromMentions and drops any isAgent && !managedAgentPubkeys.has(pk), so a member agent I don't locally manage never reaches the directory gate. Removing that pre-gate (this PR) restores the mobile semantics 👍
One sanity check for the review: #2149's stated intent was narrower than "managed-only" — de-duping owner-less stale p-tag copies of a persona I already manage (e.g. Bumble). Removing the gate entirely also lets owner-less member duplicates back in. If preserving that dedupe matters, a more surgical variant exempts only member + attested agents:
if (candidate.isAgent !== true) return true;
if (managedAgentPubkeys.has(normalizePubkey(candidate.pubkey))) return true;
return candidate.isMember === true && Boolean(candidate.ownerPubkey);
ownerPubkey is only set for a verified auth tag (profile_valid_oa_owner_pubkey in nostr_convert.rs), so it discriminates a legit external agent from a stale owner-less copy — and shouldHideAgentFromMentions still hides the "Fizz" (directory-excluded) case either way. Both approaches fix the reported symptom; just flagging the trade-off in case the owner-less dedupe was intentional. Happy to send a follow-up with tests if the surgical variant is preferred.
Heads up for whoever picks this as the merge vehicle: fixing the picker-eligibility gate alone won't fully close out #2950 for existing agents. Found and verified a second, separate bug while reproducing this end-to-end on my own relay — Edit Agent's "Who can talk to this agent" toggle doesn't reliably persist to the on-disk managed-agents.json respond_to field the harness actually reads (stuck at owner-only despite the UI showing "Anyone," even across an explicit restart). Full repro with timestamped before/after is on #2950's latest comment — once this merges, worth checking that agents whose access was changed post-creation actually respond, not just that they're visible in the picker.
Thanks @bharani-gif for the approve — appreciated.
@Cyberworkshop good catch on the separate track. Agree this PR should stay scoped to picker/directory eligibility (managed-list pre-gate + invocable add-member path). The Edit Agent “Who can talk to this agent” → on-disk managed-agents.json respond_to stuck at owner-only while the UI shows “Anyone” is a distinct persistence/harness bug and won’t be closed by merging #2605 alone.
For whoever drives merge of this vehicle:
- Land #2605 (or the chosen #2987-family carrier) for mention/add visibility.
- Treat the #2950 repro you linked (issue comment) as a follow-up — verify post-create access toggles actually rewrite harness
respond_to, not just the UI label. - After merge, smoke both: shared agent appears in autocomplete and a toggled-to-Anyone agent actually answers non-owners.
Happy to re-test a tip commit after rebase onto current main if useful. Not claiming maintainer merge authority — just collab coordination so #2950 doesn’t get marked done on visibility alone.