fix: pass context to single-add mutation so reuse guard fires

The single-agent create path was calling createChannelManagedAgent
without context, so the reuse guard (findReusablePersonaAgent) never
fired — always spawning a new keypair + process. Now fetches
managedAgents + channelMemberPubkeys before calling create, matching
the batch path's behavior.
This commit is contained in:
Taylor Ho
2026-05-21 23:06:58 -07:00
parent 4bb06b8aed
commit 0b72f1a72f

View File

@@ -13,6 +13,7 @@ import {
discoverAcpProviders,
discoverBackendProviders,
discoverManagedAgentPrereqs,
getChannelMembers,
getManagedAgentLog,
listManagedAgents,
listRelayAgents,
@@ -417,7 +418,18 @@ export function useCreateChannelManagedAgentMutation(channelId: string | null) {
throw new Error("No channel selected.");
}
return createChannelManagedAgent(channelId, input);
const [managedAgents, members] = await Promise.all([
listManagedAgents(),
getChannelMembers(channelId),
]);
const channelMemberPubkeys = new Set(
members.map((m) => normalizePubkey(m.pubkey)),
);
return createChannelManagedAgent(channelId, input, {
managedAgents,
channelMemberPubkeys,
});
},
onSuccess: (result) => {
if (!channelId) return;