From 295c7a07aa42bfd72547c96d60ec9442fe224e5f Mon Sep 17 00:00:00 2001 From: klopez4212 Date: Sat, 27 Jun 2026 10:54:05 +0100 Subject: [PATCH] Infer agents from task source mentions --- .../channels/ui/useAgentConversationRouteTarget.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/desktop/src/features/channels/ui/useAgentConversationRouteTarget.ts b/desktop/src/features/channels/ui/useAgentConversationRouteTarget.ts index 05d0409e7..31e641539 100644 --- a/desktop/src/features/channels/ui/useAgentConversationRouteTarget.ts +++ b/desktop/src/features/channels/ui/useAgentConversationRouteTarget.ts @@ -4,6 +4,7 @@ import type { AgentConversationMarker, OpenAgentConversationInput, } from "@/features/agents/agentConversations"; +import { collectMessageMentionPubkeys } from "@/features/messages/lib/formatTimelineMessages"; import type { TimelineMessage } from "@/features/messages/types"; import type { Channel } from "@/shared/api/types"; import { normalizePubkey } from "@/shared/lib/pubkey"; @@ -80,11 +81,18 @@ export function useAgentConversationRouteTarget({ const sourceAuthorIsAgent = sourceMessage.pubkey ? agentPubkeys.has(normalizePubkey(sourceMessage.pubkey)) : false; + const mentionedAgentPubkey = + collectMessageMentionPubkeys([sourceMessage]).find((pubkey) => + agentPubkeys.has(normalizePubkey(pubkey)), + ) ?? ""; const taskAgentPubkey = marker?.agentPubkey || - (sourceAuthorIsAgent ? (sourceMessage.pubkey ?? "") : ""); + (sourceAuthorIsAgent ? (sourceMessage.pubkey ?? "") : "") || + mentionedAgentPubkey; const taskAgentName = - marker?.agentName || (taskAgentPubkey ? sourceMessage.author : ""); + marker?.agentName || + (sourceAuthorIsAgent && taskAgentPubkey ? sourceMessage.author : "") || + taskAgentPubkey; const rootId = sourceMessage.rootId ?? sourceMessage.parentId ?? sourceMessage.id; const contextMessages = timelineMessages.filter(