Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -306,3 +306,39 @@ test("coalesceAgentAutocompleteCandidates: leaves non-agents alone", () => {

assert.deepEqual(coalesce([first, second]), [first, second]);
});


test("shared relay agent not in local managed list is admitted (#3971)", () => {
// #3971: an agent hosted on another machine is a channel member and appears
// in the relay directory with respond_to=anyone, but is NOT in the local
// managed-agent list. The old addCandidate gate dropped it before
// shouldHideAgentFromMentions could consult mentionableAgentPubkeys, making
// remote shared agents unreachable. The fixed admit condition is:
// admit iff isAgentIdentityInManagedList(...) || mentionableAgentPubkeys.has(pubkey)
const managedAgentPubkeys = new Set(); // agent is remote-only, not local
const mentionableAgentPubkeys = new Set([PUB_B]); // relay-shared
const pubkey = PUB_B;

const admitCondition =
isAgentIdentityInManagedList(
{ isAgent: true, pubkey },
managedAgentPubkeys,
) || mentionableAgentPubkeys.has(pubkey);

assert.equal(admitCondition, true);
});

test("non-shared non-local agent is still rejected (#3971)", () => {
// A remote agent NOT in the relay mentionable set must still be dropped.
const managedAgentPubkeys = new Set();
const mentionableAgentPubkeys = new Set();
const pubkey = PUB_C;

const admitCondition =
isAgentIdentityInManagedList(
{ isAgent: true, pubkey },
managedAgentPubkeys,
) || mentionableAgentPubkeys.has(pubkey);

assert.equal(admitCondition, false);
});
5 changes: 4 additions & 1 deletion desktop/src/features/messages/lib/useMentions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,10 @@ export function useMentions(
if (isArchivedDiscovery(pubkey)) {
return;
}
if (!isAgentIdentityInManagedList(candidate, managedAgentPubkeys)) {
if (
!isAgentIdentityInManagedList(candidate, managedAgentPubkeys) &&
!mentionableAgentPubkeys.has(pubkey)
) {
return;
}
if (
Expand Down