mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
Infer agents from task source mentions
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user