Skip to content

fix(desktop): keep live foreign agents in mention and add-member autocomplete - #4129

Open
neptun787 wants to merge 1 commit into
block:mainfrom
neptun787:fix/mention-foreign-live-agents
Open

fix(desktop): keep live foreign agents in mention and add-member autocomplete#4129
neptun787 wants to merge 1 commit into
block:mainfrom
neptun787:fix/mention-foreign-live-agents

Conversation

@neptun787

Copy link
Copy Markdown

Problem

Since #2149, the composer's @-mention autocomplete and the members-sidebar add-member search drop every concrete agent identity that is not in the current user's local managed Agents list — including live, invocable agents owned by another desktop that are members of the current channel.

useMentions.addCandidate returns early via isAgentIdentityInManagedList(...) before shouldHideAgentFromMentions(...) (#1611) ever runs, so the whole "member / invocable / directory-exclusion" decision table from #1611 is unreachable for foreign agents. The same gate sits in MembersSidebar.tsx.

Concrete repro (two desktops, one relay):

  1. Desktop B manages agent GADS MacMini and adds it to a shared channel.
  2. On desktop A (different owner), open that channel and type @gads.
  3. No suggestion appears — in the channel or in a 1:1 DM with the agent — even though the agent is a channel member, online, and listed in the relay agent directory (kind:10100). Send-time mention extraction (extractMentionPubkeys) scans the same candidate list, so typing the full name doesn't p-tag it either: the agent is effectively unmentionable from any other device.

Meanwhile #2149's goal is real: stale p-tag/member identities (superseded agent keys) should not resurface.

Fix

Rename the gate to isKnownLiveAgentIdentity and let a relay agent directory entry (kind:10100) count as live evidence alongside the local managed list. Everything else is unchanged — surviving foreign agents still flow through shouldHideAgentFromMentions, so explicitly non-invocable ones stay hidden.

candidate before after
person show show
locally managed agent show show
foreign agent, in directory, invocable (shared channel / allowlist) dropped show
foreign agent, in directory, not invocable ("Fizz", #1611) dropped hidden by shouldHideAgentFromMentions (as designed)
stale identity — no directory entry, not managed (#2149's Bumble) dropped dropped

Applied to both call sites (useMentions.ts, MembersSidebar.tsx); MembersSidebar already had relayAgentsQuery in scope and in the memo deps.

Tests

  • agentAutocompleteEligibility.test.mjs: reworked the gate's test to cover person / managed / directory-listed-foreign / stale branches
  • pnpm test → 3906/3906 pass
  • tsc --noEmit → 0 errors
  • biome check on the 4 changed files → clean

🤖 Generated with Claude Code

…complete

block#2149 made the local managed Agents list the sole authority for concrete
agent identities in autocomplete. That drops every agent owned by another
desktop before shouldHideAgentFromMentions (block#1611) can run — a live,
invocable agent that is a channel member can neither be @-mentioned nor
found in the add-member search from any other device. Send-time mention
extraction fails too, since it scans the same candidate list.

Keep block#2149's stale-identity cleanup, but treat a relay agent directory
entry (kind:10100) as live evidence alongside the managed list: agents
present in either survive candidate building; explicitly non-invocable
ones are still hidden by shouldHideAgentFromMentions.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: neptun787 <neptun787@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant