fix(desktop): let anyone mention an agent that is already in the channel - #5
Merged
Merged
Conversation
An agent in a channel is invisible to everyone but its operator. On any other device `mentionableAgentPubkeys` is empty for that agent, and the relay directory (kind:10100) lists it, so the member branch of `shouldHideAgentFromMentions` read directory-presence-without-local- mentionability as an explicit not-invocable signal and hid it. The result is a participant nobody in the room can address: it posts, it is in the member sidebar, and typing `@` does not offer it. Channel membership is the authorisation that already governs every other participant, so make it sufficient here too. Whether an agent is managed on *this* device decides local lifecycle controls — start, stop, attach — not whether a peer may speak to it. DMs are unaffected. `isMember: true` is set in exactly one place, the `members` loop in `useMentions`, from the channel's own member list; every other candidate source hard-codes `isMember: false` and the coalescer only ORs. An agent that is not party to a conversation is still gated by the managed-list branch. Nor is anything newly disclosed: channel members are already listed in the sidebar. `isAgentIdentityInManagedList` is renamed `isAgentIdentityDiscoverable`, since with the membership clause its answer is no longer "is this managed here" but "may this be surfaced at all". The existing tests stopped at the predicate, which is how it stayed possible to relax it without knowing whether a mention actually reaches the agent. `agentMentionComposedPath.test.mjs` walks the whole path a picked mention travels — eligibility, label, suggestion, draft ref, `p` tag — and pins the member, non-member, locally-managed and DM cases at the only stage the agent can observe: the emitted `p` tags. Signed-off-by: mattbalza <mattbalza@users.noreply.github.com>
|
To use Codex here, create a Codex account and connect to github. |
`prefer live agent mentions` (block#2149) flipped this assertion to `toHaveCount(0)` when it started hiding relay-classified agents the local device does not manage. alice is exactly that: an agent by the relay's classification and an owner-member of #general — the fixture stand-in for an agent someone else runs. Restoring her here is the point of the change, so the sibling assertion becomes load-bearing rather than vacuous: `.not.toBeVisible()` passed while the row was absent, and only `toHaveCount(0)` on a row that now exists proves a member agent carries no "not in channel" caveat. Signed-off-by: mattbalza <mattbalza@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
An agent in a channel is addressable only by its operator. On every other
device
mentionableAgentPubkeysis empty for that agent while the relaydirectory (kind:10100) lists it — and
shouldHideAgentFromMentionsreadexactly that combination (member, directory-present, not locally mentionable)
as an explicit not-invocable signal, and hid it.
The result is a participant nobody in the room can talk to: it posts messages,
it shows in the member sidebar, and typing
@does not offer it.This is what our
@erpand@codexagents look like to every user on therelay except the one machine that manages them.
Fix
Channel membership already authorises every other participant; make it
sufficient here too.
Whether an agent is managed on this device governs local lifecycle controls
(start, stop, attach) — not whether a peer may speak to it. With the
membership clause
isAgentIdentityInManagedListno longer answers "is thismanaged here" but "may this be surfaced at all", so it is renamed
isAgentIdentityDiscoverable.The
directoryAgentPubkeysmemo inuseMentionshad no other consumer and isremoved.
Why this is safe
DMs are unaffected.
isMember: trueis set in exactly one place — themembersloop inuseMentions, from the channel's own member list. Everyother candidate source hard-codes
isMember: false, and the coalescer onlyORs. An agent that is not party to a conversation is still gated by the
managed-list branch.
Nothing is newly disclosed. Channel members are already listed in the
sidebar; this only makes one of them typeable.
Tests
The existing tests stopped at the predicate, which is how it stayed possible
to relax it without knowing whether a mention actually reaches the agent.
The new
agentMentionComposedPath.test.mjswalks the whole path a pickedmention travels — eligibility →
mentionCandidateLabel→mapMentionCandidateToSuggestion→snapshotDraftMentionRefs→messageMentionPubkeys— and asserts at the only stage the agent can observe,the emitted
ptags:ptag, and isnot flagged
notInChanneland no
ptag(prior behaviour preserved)
Test plan