fix(desktop): stop hiding relay-directory agents from the mention picker - #4839
fix(desktop): stop hiding relay-directory agents from the mention picker#4839TheSeydiCharyyev wants to merge 2 commits into
Conversation
useMentions fetches the relay agent directory, derives mentionableAgentPubkeys from it, and adds every relay agent as a mention candidate - then dropped them all one line before the check that consumes any of that. The gate was isAgentIdentityInManagedList against managedAgentPubkeys, which only holds agents the desktop spawns itself, so an agent hosted anywhere else never reached shouldHideAgentFromMentions. That policy is written for exactly these candidates: invocable agents are shown, non-member non-invocable ones are hidden, and a channel member is hidden only on an explicit not-invocable directory entry. Dropping the earlier gate lets it decide. Locally managed agents are unaffected - they are in mentionableAgentPubkeys either way, so the policy shows them. Mentioning a directory-only agent does not try to launch anything locally: useMentionSendFlow narrows the launch path to managedAgentsByPubkey.has(pubkey), so such a mention is simply published. The add-members picker uses the same helper and is deliberately left alone here - it has no equivalent policy to fall back on. Refs block#4776 Refs block#4833 Signed-off-by: Seydi Charyyev <seydi.charyev@gmail.com>
|
Related: our server-hosted agent is in the channel and has a directory card, but Desktop still hides it from @ unless we strip ownership. Please stop treating relay-directory agents as non-mentionable for the owner. +1 |
|
Confirmed, and this PR alone does not cover your case. Adding a second commit here: an owner-only relay agent counts as mentionable for its owner, taking ownership from the profile data this hook already reads. |
relayAgentIsSharedWithUser accepted only `anyone` and `allowlist`, so an owner-only agent was never invocable - not even for the one person it answers to. With a directory entry and channel membership, shouldHideAgentFromMentions then hid it as explicitly not-invocable, which is why dropping ownership worked around it. RelayAgent carries no owner field, so getMentionableAgentPubkeys now takes an owner lookup and useMentions supplies it from the profile metadata the hook already reads for candidate labels. Ownership is matched, never assumed: an unknown owner keeps the agent hidden. Raised on block#4839 by a third deployment hitting the same wall. Signed-off-by: Seydi Charyyev <seydi.charyev@gmail.com>
|
I filed #4776 and I run the same shape of setup: self-hosted relay, six communities on it, 23 agents as containers on my own VM, none of them spawned by the desktop. So this hits me directly and I'm glad someone picked it up. I've been running the equivalent of your part 1 as a local patch for about a week. Same conclusion — the candidate loop builds everything Part 2 is the interesting one for me, because I hit the symptom and never found the cause. All my agents run with On #4833's second half: that's what I ran into. I hand-wrote entries into Two things I can't speak to. I haven't built your branch, so this is a code read, not a test report. And I patch |
|
Same setup on my side: server agents, desktop as the client. Glad part 2 landed; that was the gap I was hitting. Thanks both. |
Summary
Two gates kept relay-directory agents out of the
@picker. Both are in this PR.1. A local-managed-list gate ran ahead of the eligibility policy.
useMentionsfetches the relay agent directory, derivesmentionableAgentPubkeysfrom it, and adds every relay agent as a mention candidate — then dropped them all one line before the check that consumes any of that:managedAgentPubkeysonly holds agents the desktop spawns itself, so an agent hosted anywhere else never reachedshouldHideAgentFromMentions— even though the hook had already fetched it (relayAgentsQuery), decided it was invocable (getMentionableAgentPubkeys, same query), and queued it as a candidate. For a deployment where no agent is desktop-spawned, that candidate loop is dead code.shouldHideAgentFromMentionsis written for exactly these candidates, so the gate is removed and the policy decides.2.
owner-onlyagents were invocable by nobody — including their owner.relayAgentIsSharedWithUseraccepted onlyrespondTo: "anyone"and anallowlistcontaining the current user. Anowner-onlyagent fell through tofalse, so it never enteredmentionableAgentPubkeys; with a directory entry and channel membership,shouldHideAgentFromMentionsthen hid it as explicitly not-invocable. That is why dropping ownership works around it.RelayAgentcarries no owner field, sogetMentionableAgentPubkeysnow takes an owner lookup anduseMentionssupplies it from the profile metadata the hook already reads for candidate labels (profiles[pubkey].ownerPubkey). Ownership is matched, never assumed — an unknown owner keeps the agent hidden.Locally managed agents are unaffected throughout:
getMentionableAgentPubkeysseeds its set frommanagedAgentPubkeys, so they stay invocable and stay shown.Mentioning a directory-only agent does not try to launch anything locally.
useMentionSendFlownarrows the launch path withnormalizedMentionPubkeys.filter((pubkey) => managedAgentsByPubkey.has(pubkey))before callingensureManagedAgentMentionsReady, so an agent that is not in the local store is published as an ordinary mention. (That is the difference from the second half of #4833, where the agent had been added tomanaged-agents.jsonand the app then tried to start a local copy.)Out of scope: the add-members picker in
MembersSidebarcalls the same helper and is deliberately untouched here. It has no equivalent policy to fall back on, so opening it up is a separate decision.Related issue
Refs #4776 and #4833, filed independently within a day of each other against the same gate, plus a third deployment reported in this PR's comments — that report is what surfaced the
owner-onlyhalf. No open PR touchesuseMentions.tsoragentAutocompleteEligibility.ts.Testing
desktoppackage on Windows 11, node 22.17.1, pnpm 11.4.0.pnpm test).pnpm checkclean across 1756 files;pnpm typecheckclean;pnpm buildsucceeds.managedAgentPubkeysan unnecessary dependency of thementionCandidatesmemo; biome'suseExhaustiveDependenciesflagged it and it is dropped in the same change.useMentions.tssits exactly on its 1000-line ratchet, so the added comments are terse by necessity; the reasoning lives here instead.New cases in
agentAutocompleteEligibility.test.mjs:relayAgentIsSharedWithUser: an owner-only agent is invocable by its owner— also asserts someone else's owner-only agent stays hidden, and that unknown ownership does not admit it.getMentionableAgentPubkeys: admits an owner-only relay agent for its owner— two owner-only agents, only the owned one is admitted.a relay-directory agent the desktop does not manage stays mentionable— the Desktop drops relay-directory agents from the mention picker when it doesn't manage them locally #4776 shape end to end.The first two fail against the pre-change helper (
# fail 2) and pass after, so theowner-onlyhalf is a genuine regression test. The third pins the policy and documents the ordering trap but exercises the helpers rather than the hook, so it passes either way —desktophas no React hook test harness, and the call-site ordering in commit 1 is argued from the code path above rather than from a failing test. E2E coverage through the mock bridge can be added if that is preferred.