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 @@ -12,12 +12,45 @@ import {
channelScopedBotTypingPubkeyKey,
mergeMemberAgentFlagsIntoProfiles,
} from "./useChannelActivityTyping.ts";
import {
buildChannelAgentSessionCandidates,
getChannelAgentSessionAgents,
} from "./useChannelAgentSessions.ts";

const AGENT =
"abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234";
const AGENT_2 =
"dcba4321dcba4321dcba4321dcba4321dcba4321dcba4321dcba4321dcba4321";

it("keeps a directory-known Hermes agent in DM activity when it is a member", () => {
const channelMembers = [{ pubkey: AGENT, role: "bot" }];
const candidates = buildChannelAgentSessionCandidates({
channelMembers,
managedAgents: [],
relayAgents: [
{
pubkey: AGENT,
name: "Hermes",
status: "online",
channelIds: ["ordinary-channel"],
channels: ["Ordinary channel"],
},
],
});

const agents = getChannelAgentSessionAgents({
activeChannel: { channelType: "dm", name: "Hermes DM" },
activeChannelId: "dm-channel",
agents: candidates,
channelMembers,
});

assert.deepEqual(
agents.map((agent) => agent.pubkey),
[AGENT],
);
});

describe("channelScopedBotTypingPubkeyKey", () => {
it("excludes thread-scoped typing entries", () => {
const key = channelScopedBotTypingPubkeyKey([
Expand Down
4 changes: 4 additions & 0 deletions desktop/src/features/channels/ui/useChannelAgentSessions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ export function getChannelAgentSessionAgents({
channelIds.includes(activeChannelId) ||
channels.includes(activeChannel.name);

if (activeChannel.channelType === "dm") {
return memberPubkeys?.has(normalizedPubkey) ?? matchesDeclaredChannel;
}

if (agent.agentSource === "member-bot") {
return botMemberPubkeys?.has(normalizedPubkey) ?? matchesDeclaredChannel;
}
Expand Down