From 5802f4fa110f22a162fb36c84fd40c6b3141f288 Mon Sep 17 00:00:00 2001 From: klopez4212 Date: Thu, 25 Jun 2026 15:22:24 +0100 Subject: [PATCH] Fix profile sidebar edit and secret reveal --- .../features/profile/ui/UserProfilePanel.tsx | 10 ++-- .../ui/UserProfilePanelPersonaSubmit.test.mjs | 51 ++++++++++++++++++- .../ui/UserProfilePanelPersonaSubmit.ts | 3 ++ 3 files changed, 59 insertions(+), 5 deletions(-) diff --git a/desktop/src/features/profile/ui/UserProfilePanel.tsx b/desktop/src/features/profile/ui/UserProfilePanel.tsx index 1a90da5ff..4c26c7c65 100644 --- a/desktop/src/features/profile/ui/UserProfilePanel.tsx +++ b/desktop/src/features/profile/ui/UserProfilePanel.tsx @@ -346,12 +346,12 @@ export function UserProfilePanel({ }, [effectivePubkey, onClose, onOpenDm]); const handleEditAgent = React.useCallback(() => { - if (resolvedPersona && !resolvedPersona.isBuiltIn) { + if (managedAgent) { + setEditAgentOpen(true); + } else if (resolvedPersona && !resolvedPersona.isBuiltIn) { setPersonaDialogState(editPersonaDialogState(resolvedPersona)); - return; } - setEditAgentOpen(true); - }, [resolvedPersona]); + }, [managedAgent, resolvedPersona]); const { deleteManagedAgentRecord, deleteManagedAgentsForPersona } = useProfileAgentDeletion({ @@ -513,6 +513,7 @@ export function UserProfilePanel({ createPersona: createPersonaMutation.mutateAsync, input, managedAgent, + onCreatedAgent: setCreatedAgent, onDone: () => { setPersonaDialogState(null); void personasQuery.refetch(); @@ -527,6 +528,7 @@ export function UserProfilePanel({ createPersonaMutation.mutateAsync, createManagedAgentForPersona, managedAgent, + setCreatedAgent, personasQuery.refetch, resolvedPersona, acpRuntimesQuery.data, diff --git a/desktop/src/features/profile/ui/UserProfilePanelPersonaSubmit.test.mjs b/desktop/src/features/profile/ui/UserProfilePanelPersonaSubmit.test.mjs index 7f264748c..94c04ed13 100644 --- a/desktop/src/features/profile/ui/UserProfilePanelPersonaSubmit.test.mjs +++ b/desktop/src/features/profile/ui/UserProfilePanelPersonaSubmit.test.mjs @@ -1,7 +1,10 @@ import assert from "node:assert/strict"; import test from "node:test"; -import { validateLinkedAgentRuntimeEdit } from "./UserProfilePanelPersonaSubmit.ts"; +import { + submitProfilePersonaDialog, + validateLinkedAgentRuntimeEdit, +} from "./UserProfilePanelPersonaSubmit.ts"; function agent(overrides = {}) { return { @@ -73,6 +76,19 @@ function updateInput(overrides = {}) { }; } +function createInput(overrides = {}) { + return { + displayName: "Fizz", + avatarUrl: undefined, + systemPrompt: "Prompt", + runtime: "goose", + model: undefined, + provider: undefined, + namePool: [], + ...overrides, + }; +} + function runtime(overrides = {}) { return { id: "claude", @@ -148,3 +164,36 @@ test("validateLinkedAgentRuntimeEdit allows clearing linked runtime preference", null, ); }); + +test("submitProfilePersonaDialog reports created agents for secret reveal", async () => { + const createdAgent = { + agent: agent({ name: "Fizz Prime" }), + privateKeyNsec: "nsec1secret", + profileSyncError: null, + spawnError: null, + }; + let revealedAgent = null; + let done = false; + + await submitProfilePersonaDialog({ + createManagedAgentForPersona: async () => createdAgent, + createPersona: async () => persona({ displayName: "Fizz Prime" }), + input: createInput({ displayName: "Fizz Prime" }), + managedAgent: undefined, + onCreatedAgent: (created) => { + revealedAgent = created; + }, + onDone: () => { + done = true; + }, + updateManagedAgent: async () => { + throw new Error("updateManagedAgent should not be called"); + }, + updatePersona: async () => { + throw new Error("updatePersona should not be called"); + }, + }); + + assert.equal(revealedAgent, createdAgent); + assert.equal(done, true); +}); diff --git a/desktop/src/features/profile/ui/UserProfilePanelPersonaSubmit.ts b/desktop/src/features/profile/ui/UserProfilePanelPersonaSubmit.ts index 00e2ee817..a851565b3 100644 --- a/desktop/src/features/profile/ui/UserProfilePanelPersonaSubmit.ts +++ b/desktop/src/features/profile/ui/UserProfilePanelPersonaSubmit.ts @@ -18,6 +18,7 @@ type SubmitProfilePersonaDialogOptions = { createPersona: (input: CreatePersonaInput) => Promise; input: CreatePersonaInput | UpdatePersonaInput; managedAgent: ManagedAgent | undefined; + onCreatedAgent?: (created: CreateManagedAgentResponse) => void; onDone: () => void; previousPersona?: AgentPersona; runtimes?: readonly AcpRuntimeCatalogEntry[]; @@ -71,6 +72,7 @@ export async function submitProfilePersonaDialog({ createPersona, input, managedAgent, + onCreatedAgent, onDone, previousPersona, runtimes, @@ -108,6 +110,7 @@ export async function submitProfilePersonaDialog({ const persona = await createPersona(input); try { const created = await createManagedAgentForPersona(persona); + onCreatedAgent?.(created); if (created.spawnError) { toast.error( `${persona.displayName} was created, but it did not start: ${created.spawnError}`,