fix(desktop): keep owned in-channel agents mentionable across machines
Problem
An agent whose process runs on another machine is unmentionable from every machine except the one hosting it, even while it sits in the channel answering mentions. Reported in #2508, #3739 and #2349.
Two gates in useMentions drop it, and fixing either one alone leaves the default configuration broken:
isAgentIdentityInManagedListrejects any agent absent from this machine's managed list. A remote agent always fails here.shouldHideAgentFromMentionsthen reads the agent's kind:10100 entry as an explicit not-invocable signal.getMentionableAgentPubkeysonly admits relay agents whoserespond_toisanyoneor an allowlist naming the current user, so an agent left on the defaultowner-only(RespondTo::default(),crates/buzz-acp/src/config.rs) never lands there.
Replaying both gates against an owner-only in-channel agent owned by the viewer and present in the directory:
gate 1 (isAgentIdentityInManagedList) passes : true
gate 2 (shouldHideAgentFromMentions) hides : true
=> visible in autocomplete: false
What changed
#1243 set out to "scope mention/add autocomplete to reachable identities" and described an eligible agent as "my managed/owned agent", but only the managed list was ever consulted. This restores the missing half, scoped to what actually proves reachability:
channel membership (it is here and answering) + ownership (
owner-onlyaccepts its owner by definition)
Membership is the evidence, ownership the permission, and neither depends on which machine hosts the process.
Ownership is not self-declared. Profile.ownerPubkey is derived from a NIP-OA attestation verified against the agent's own pubkey (profile_valid_oa_owner_pubkey, desktop/src-tauri/src/nostr_convert.rs), and MembersSidebar already gates member-card actions on exactly this comparison (viewerIsOwner). An agent cannot claim an owner it does not have.
isAgentMentionEligible consolidates the two predicates in one place. They encode a single policy but are order-dependent: the managed-list gate can reject a candidate before the invocability gate applies its "invocable => show" rule, so composing them at the call site invites applying only half the policy. This also addresses the gate-ordering inconsistency raised in the review of #4047.
Deliberately unchanged
- Owned agents that are not channel members stay hidden. A profile-only agent we own has no evidence of running anywhere. #1243 hides it on purpose and the
mirafixture pins that; this PR keeps it passing. - Online presence is not a criterion. It would also surface other people's agents, which #1611 set out to prevent.
MembersSidebaris untouched. Its add-member autocomplete excludes existing members by construction, so a membership-scoped rule would be dead code there.
Tests
e2e regression (desktop/tests/e2e/mentions.spec.ts) drives the rendered autocomplete rather than the predicate, so it stays honest if useMentions ever stops routing candidates through the policy. nadia is an in-channel, viewer-owned, owner-only relay agent absent from managedAgents.
Reproduced on both revisions:
- base
3d7712c: fails — the dropdown never appears for@nadia - this branch: passes
Unit (agentAutocompleteEligibility.test.mjs): 11 added cases covering both gates and the consolidated policy — owned member accepted, owned non-member still hidden, other-owner member still hidden, pubkey normalization, ownership branch inert without currentPubkey, and both gates applied rather than just the managed-list one.
Full suite: pnpm test 3919/3919, pnpm typecheck clean, pnpm lint no new findings.
e2e: mentions, team-mentions and channels are green (124), reproduced across two runs. The rest of --project=smoke shows a handful of failures on this machine (composer-selection-formatting, messaging avatar, onboarding-agent-defaults concurrency, thread-focus-mode, relay-reconnect, and a hover tooltip in mentions.spec.ts). They reproduce on unmodified 3d7712c and the set changes between runs, so they look like local environment flakiness rather than anything this branch introduces. Worth a second opinion from CI.