Infer DM agents for task starts

This commit is contained in:
klopez4212
2026-06-30 13:56:37 +01:00
parent 0d94a359a4
commit 14f5a40b2b
@@ -41,6 +41,7 @@ import {
} from "@/features/channels/ui/WelcomeComposerBanner";
import {
canOpenAgentConversationInChannel,
getDmAutoRouteAgentPubkeys,
getChannelIntroDescription,
getChannelIntroKind,
isWelcomeSetupSystemMessage,
@@ -289,6 +290,15 @@ export const ChannelPane = React.memo(function ChannelPane({
return pubkeys;
}, [activityAgents, agentPubkeys, agentSessionAgents]);
const dmAutoRouteAgentPubkeys = React.useMemo(
() =>
getDmAutoRouteAgentPubkeys({
channel: activeChannel,
currentPubkey,
knownAgentPubkeys,
}),
[activeChannel, currentPubkey, knownAgentPubkeys],
);
const knownAgentByPubkey = React.useMemo(() => {
const agents = new Map<string, { name: string; pubkey: string }>();
const addAgent = (pubkey: string, name?: string | null) => {
@@ -364,9 +374,21 @@ export const ChannelPane = React.memo(function ChannelPane({
}
}
for (const pubkey of dmAutoRouteAgentPubkeys) {
const dmAgent = knownAgentByPubkey.get(normalizePubkey(pubkey));
if (dmAgent) {
return dmAgent;
}
}
return null;
},
[activeAgentConversationMarkers, activeChannelId, knownAgentByPubkey],
[
activeAgentConversationMarkers,
activeChannelId,
dmAutoRouteAgentPubkeys,
knownAgentByPubkey,
],
);
const completeWelcomeComposerBanner = React.useCallback(() => {
if (!activeChannelId || !isActiveWelcomeChannel) {