buzz icon indicating copy to clipboard operation
buzz copied to clipboard

fix(desktop): show cross-desktop managed agents in @mention autocomplete

Open anindyar opened this issue 3 months ago • 0 comments

Summary

Fixes #4187 — a managed agent created on one Buzz Desktop instance is not discoverable in the @mention autocomplete picker on another member's Desktop, even though it is a channel member (role: "bot"), has a valid kind:0 profile, and responds normally when mentioned via the CLI with --mention.

Root cause

useMentions (desktop/src/features/messages/lib/useMentions.ts) builds mention candidates through addCandidate, which applies two agent-visibility gates in sequence:

  1. isAgentIdentityInManagedList(candidate, managedAgentPubkeys) — keeps an agent only if it is in this client's local managed-agent list.
  2. shouldHideAgentFromMentions({ … }) — the nuanced "Option B" member/directory policy that is explicitly designed to show channel-member agents whose invocability is unknown, and to hide only non-member or explicitly-excluded ones.

Gate #1 runs first and short-circuits. Any agent that isn't locally managed is dropped before gate #2 can run — so a managed agent running on another Desktop instance (present in the channel as a role: "bot" member, but absent from this client's local managed list and, for the native Claude Code runtime, not in the relay kind:10100 directory) is filtered out. That makes shouldHideAgentFromMentions's member-handling dead code for exactly the cross-desktop case it was written for, which is the behavior reported in #4187 (and confirmed independently on 0.5.4 in the issue thread).

Fix

Remove the redundant isAgentIdentityInManagedList pre-filter from the mention path and let shouldHideAgentFromMentions be the sole visibility policy there. Its existing, tested behavior already gives the correct result:

  • member agent, unknown invocability (not in directory) → show ✅ (the #4187 case)
  • agent invocable via managed/shared-relay directory → show ✅
  • non-member, non-invocable agent → hide
  • member agent with an explicit not-invocable directory (kind:10100) entry → hide

isAgentIdentityInManagedList itself is unchanged and still used by MembersSidebar's "add member" search, where restricting agent suggestions to locally-managed agents is correct (you can only add agents you manage). The fix is scoped to the mention path only.

Tests

  • desktop/src/features/agents/lib/agentAutocompleteEligibility.test.mjs — added a named #4187 regression test asserting a channel-member agent managed by another Desktop instance (not in the managed list, not in the relay directory) stays visible.
  • Full desktop unit suite green: pnpm test → 4130 passed, 0 failed.
  • pnpm typecheck and biome check clean on the changed files.

Notes for reviewers

  • This is a Desktop-side fix; the previously-linked #4309 only touched mobile/…/compose_bar* and does not address this issue.
  • MembersSidebar's "add member" search still applies the same local-managed gate. That's intentional and out of scope here, but if you'd prefer relay-discovered agents to be addable there too, that's a natural follow-up.

🤖 Generated with Claude Code

anindyar avatar Aug 04 '26 12:08 anindyar