Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions desktop/src/features/messages/lib/useMentions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,13 @@ export function useMentions(

const addCandidate = (candidate: MentionCandidate & { pubkey: string }) => {
const pubkey = normalizePubkey(candidate.pubkey);
if (!pubkey) {
// Persona-definition rows in managed-agents.json can carry an empty
// pubkey (their running instance carries the real one). They are not
// mentionable identities — skip so they never render as phantom
// candidates or shadow the real instance (#3947).
return;
}
if (isArchivedDiscovery(pubkey)) {
return;
}
Expand Down Expand Up @@ -347,16 +354,23 @@ export function useMentions(
}

for (const agent of managedAgentsQuery.data ?? []) {
const linkedPersonaName = agent.personaId
? (activePersonaById.get(agent.personaId)?.displayName ?? null)
: null;
addCandidate({
kind: "identity",
pubkey: agent.pubkey,
displayName: agent.name,
// Prefer the linked persona's display name for presentation; the
// instance's own `name` may be null on running instances (#3947).
displayName: agent.name || linkedPersonaName || null,
isMember: false,
isAgent: true,
isManagedAgent: true,
personaId: agent.personaId ?? undefined,
personaName:
personaNameByPubkey.get(normalizePubkey(agent.pubkey)) ?? null,
personaNameByPubkey.get(normalizePubkey(agent.pubkey)) ??
linkedPersonaName ??
null,
ownerPubkey: currentPubkey,
});
}
Expand Down