MCPcopy Create free account
hub / github.com/block/buzz / useRetainedPersona

Function useRetainedPersona

desktop/src/features/profile/ui/UserProfilePanelUtils.ts:337–357  ·  view source on GitHub ↗
(
  sourcePersona: AgentPersona | undefined,
  profileIdentityKey: string,
)

Source from the content-addressed store, hash-verified

335}
336
337export function useRetainedPersona(
338 sourcePersona: AgentPersona | undefined,
339 profileIdentityKey: string,
340) {
341 const [retainedPersona, setRetainedPersona] = React.useState<{
342 key: string;
343 persona: AgentPersona;
344 } | null>(null);
345
346 React.useEffect(() => {
347 if (!sourcePersona) return;
348 setRetainedPersona({ key: profileIdentityKey, persona: sourcePersona });
349 }, [profileIdentityKey, sourcePersona]);
350
351 return (
352 sourcePersona ??
353 (retainedPersona?.key === profileIdentityKey
354 ? retainedPersona.persona
355 : undefined)
356 );
357}

Callers 1

UserProfilePanelFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected