diff --git a/desktop/src/features/channels/ui/useChannelActivityTyping.test.mjs b/desktop/src/features/channels/ui/useChannelActivityTyping.test.mjs index 3e3943f43e..fb520ef861 100644 --- a/desktop/src/features/channels/ui/useChannelActivityTyping.test.mjs +++ b/desktop/src/features/channels/ui/useChannelActivityTyping.test.mjs @@ -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([ diff --git a/desktop/src/features/channels/ui/useChannelAgentSessions.ts b/desktop/src/features/channels/ui/useChannelAgentSessions.ts index 8420c37327..e0cf93e269 100644 --- a/desktop/src/features/channels/ui/useChannelAgentSessions.ts +++ b/desktop/src/features/channels/ui/useChannelAgentSessions.ts @@ -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; }