Skip to content

fix(desktop): show shared relay agents in mention autocomplete - #4137

Open
bossriceshark wants to merge 5 commits into
block:mainfrom
bossriceshark:fix/desktop-remote-agent-mention-autocomplete
Open

fix(desktop): show shared relay agents in mention autocomplete#4137
bossriceshark wants to merge 5 commits into
block:mainfrom
bossriceshark:fix/desktop-remote-agent-mention-autocomplete

Conversation

@bossriceshark

Copy link
Copy Markdown

Summary

Shared/remote relay agents never appear in desktop mention autocomplete, even when their kind:10100 directory records make them mention-eligible — mobile shows them fine. Root cause: addCandidate() in useMentions.ts drops every isAgent candidate that fails isAgentIdentityInManagedList() before shouldHideAgentFromMentions() runs, and a remote agent can never enter the local managed list (apply_inbound_managed_agent() is patch-only by design), so the relay-directory candidate loop is dead code for non-local agents.

Fix: add isAgentIdentityMentionable() — admits non-agents, and agents present in the mentionable set from getMentionableAgentPubkeys() (locally managed ∪ directory-eligible relay agents, the same eligibility useNewMessageRecipients and ProjectsAgentPromptPage already trust) — and switch only the useMentions call site to it. isAgentIdentityInManagedList is unchanged for its remaining consumer (MembersSidebar add-member search, which may deserve the same treatment separately — noted in the issue). An agent in neither set stays hidden, preserving the guard's anti-impersonation posture. Also removes the now-stale managedAgentPubkeys entry from the mentionCandidates memo deps.

Two housekeeping commits are included; happy to split either into its own PR:

  • style(desktop): personaCatalogRelay.test.mjs currently fails biome check . on main (two useTemplate violations); recent main pushes were docs-only, so the path-filtered Desktop Core job hasn't surfaced it. This PR's CI can't go green without the two-line fix.
  • test(desktop): the mentions smoke e2e asserted the buggy behavior — the mock's alice is exactly a directory-eligible shared relay agent (respond_to: "anyone", shared channel) and was expected to be absent from the picker. Updated to expect her visible, with member-tier ordering pinned.

Related issue

Fixes #4128 (searched existing issues/PRs for duplicates — none found)

Testing

  • Unit: extended agentAutocompleteEligibility.test.mjs (node:test) — remote directory-eligible agent admitted; agent in neither set hidden; locally managed unchanged; member-agent-without-directory-record stays hidden (pre-existing behavior, deliberately pinned); case-normalization with a letter-bearing hex fixture.
  • E2E: mentions.spec.ts mention-priority smoke updated to the fixed behavior (see above); full desktop CI green on the fork (Desktop Core, all four Smoke E2E shards, E2E Relay).
  • Live verification on a self-hosted relay: with an unpatched desktop client, a remote buzz-acp agent with a rich directory record gets no pill while Android shows it; with this patch the pill appears, and selecting it delivers the p-tag mention and produces an agent reply. Desktop-vs-mobile discrepancy reproduced and resolved.

Mention candidates were dropped by isAgentIdentityInManagedList before
shouldHideAgentFromMentions ever ran, so remote relay agents — which can
never enter the local managed list (apply_inbound_managed_agent is
patch-only by design) — were unmentionable on desktop even when their
kind:10100 directory records made them eligible. Mobile has no such
filter and shows them.

Admit candidates through the mentionable set (managed agents plus
directory-eligible relay agents) instead — the same eligibility
useNewMessageRecipients already trusts. Agents in neither set stay
hidden, preserving the guard's anti-impersonation posture.
isAgentIdentityInManagedList is unchanged for its remaining consumer
(MembersSidebar add-member search).

Signed-off-by: Matt Rice <bossriceshark@users.noreply.github.com>
Review findings: the case-normalization assertion used a digit-only
fixture (toUpperCase() is identity on digits, so it could never fail) —
replaced with a letter-bearing hex fixture; pinned the member-agent-
without-directory-record path explicitly; converted the new export's
comment to JSDoc per repo convention; noted that the
shouldHideAgentFromMentions member branch is gated upstream.

Signed-off-by: Matt Rice <bossriceshark@users.noreply.github.com>
The mention-priority smoke test asserted alice hidden — alice is the
mock's shared relay agent (directory respond_to "anyone" with a shared
channel, channel member, not locally managed), which is exactly the
candidate class the fix admits. Update expectations to the fixed
behavior and pin her member-tier ordering.

Signed-off-by: Matt Rice <bossriceshark@users.noreply.github.com>
….mjs

main currently fails `biome check .` on these two string concatenations;
recent main pushes were docs-only so the path-filtered desktop CI job
never surfaced it. Included here so this PR's CI can run green — happy
to split into its own PR if preferred.

Signed-off-by: Matt Rice <bossriceshark@users.noreply.github.com>
Signed-off-by: Matt Rice <bossriceshark@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.

Desktop: shared relay agents never appear in mention autocomplete (mobile works)

1 participant