From 1bdf13cc2c78bed329548ef886c5b5656dbb7951 Mon Sep 17 00:00:00 2001 From: klopez4212 Date: Thu, 25 Jun 2026 15:10:53 +0100 Subject: [PATCH] Fix profile sidebar review feedback --- .../UserProfileCreatedAgentSecretDialog.tsx | 22 ++++++++++++ .../features/profile/ui/UserProfilePanel.tsx | 8 ++++- .../profile/ui/UserProfilePanelUtils.test.mjs | 34 +++++++++++++++++++ .../profile/ui/UserProfilePanelUtils.ts | 11 +++++- 4 files changed, 73 insertions(+), 2 deletions(-) create mode 100644 desktop/src/features/profile/ui/UserProfileCreatedAgentSecretDialog.tsx diff --git a/desktop/src/features/profile/ui/UserProfileCreatedAgentSecretDialog.tsx b/desktop/src/features/profile/ui/UserProfileCreatedAgentSecretDialog.tsx new file mode 100644 index 000000000..05c66ab12 --- /dev/null +++ b/desktop/src/features/profile/ui/UserProfileCreatedAgentSecretDialog.tsx @@ -0,0 +1,22 @@ +import { SecretRevealDialog } from "@/features/agents/ui/SecretRevealDialog"; +import type { CreateManagedAgentResponse } from "@/shared/api/types"; +import React from "react"; + +export function useCreatedAgentSecretReveal() { + const [createdAgent, setCreatedAgent] = + React.useState(null); + + return { + createdAgentSecretDialog: createdAgent ? ( + { + if (!open) { + setCreatedAgent(null); + } + }} + /> + ) : null, + setCreatedAgent, + }; +} diff --git a/desktop/src/features/profile/ui/UserProfilePanel.tsx b/desktop/src/features/profile/ui/UserProfilePanel.tsx index 04762a2bc..1a90da5ff 100644 --- a/desktop/src/features/profile/ui/UserProfilePanel.tsx +++ b/desktop/src/features/profile/ui/UserProfilePanel.tsx @@ -103,6 +103,7 @@ import { UserProfilePanelHeaderActions, UserProfilePanelHeaderLeft, } from "./UserProfilePanelHeaderControls"; +import { useCreatedAgentSecretReveal } from "./UserProfileCreatedAgentSecretDialog"; export type { ProfilePanelView }; @@ -130,6 +131,8 @@ export function UserProfilePanel({ const [internalView, setInternalView] = React.useState("summary"); + const { createdAgentSecretDialog, setCreatedAgent } = + useCreatedAgentSecretReveal(); const view = controlledView ?? internalView; const setView = React.useCallback( (nextView: ProfilePanelView, options?: { replace?: boolean }) => { @@ -449,6 +452,7 @@ export function UserProfilePanel({ try { const created = await createManagedAgentForPersona(resolvedPersona); + setCreatedAgent(created); if (created.spawnError) { toast.error(created.spawnError); } else { @@ -462,7 +466,7 @@ export function UserProfilePanel({ error instanceof Error ? error.message : "Failed to start agent.", ); } - }, [createManagedAgentForPersona, resolvedPersona]); + }, [createManagedAgentForPersona, resolvedPersona, setCreatedAgent]); const handleToggleAgentAutoStart = React.useCallback(async () => { if (managedAgent?.backend.type !== "local") return; @@ -918,6 +922,7 @@ export function UserProfilePanel({ {editAgentDialog} {addAgentToChannelDialog} + {createdAgentSecretDialog} {personaDialogs} ); @@ -985,6 +990,7 @@ export function UserProfilePanel({ {editAgentDialog} {addAgentToChannelDialog} + {createdAgentSecretDialog} {personaDialogs} ); diff --git a/desktop/src/features/profile/ui/UserProfilePanelUtils.test.mjs b/desktop/src/features/profile/ui/UserProfilePanelUtils.test.mjs index 9af5fe3bc..1830741f4 100644 --- a/desktop/src/features/profile/ui/UserProfilePanelUtils.test.mjs +++ b/desktop/src/features/profile/ui/UserProfilePanelUtils.test.mjs @@ -179,6 +179,40 @@ test("personaManagedAgentUpdate leaves runtime fields alone when runtime is unch ); }); +test("personaManagedAgentUpdate resets runtime fields when persona runtime is cleared", () => { + assert.deepEqual( + personaManagedAgentUpdate( + agent({ + agentCommand: "claude", + agentArgs: ["mcp", "serve"], + mcpCommand: "claude-mcp", + }), + persona({ runtime: null }), + { + previousPersona: persona({ runtime: "claude" }), + runtimes: [ + runtime({ + id: "goose", + command: "goose", + defaultArgs: [], + mcpCommand: "", + }), + runtime({ id: "claude" }), + ], + }, + ), + { + pubkey: "deadbeef".repeat(8), + name: "Fizz Prime", + systemPrompt: "New prompt", + model: "new-model", + agentCommand: "goose", + agentArgs: [], + mcpCommand: "", + }, + ); +}); + test("parseProfilePanelView accepts all profile panel subviews", () => { for (const view of [ "summary", diff --git a/desktop/src/features/profile/ui/UserProfilePanelUtils.ts b/desktop/src/features/profile/ui/UserProfilePanelUtils.ts index d5bd0506b..d2b71a048 100644 --- a/desktop/src/features/profile/ui/UserProfilePanelUtils.ts +++ b/desktop/src/features/profile/ui/UserProfilePanelUtils.ts @@ -268,7 +268,7 @@ export function personaManagedAgentUpdate( options.previousPersona !== undefined && options.previousPersona.runtime !== persona.runtime; const runtime = runtimeChanged - ? options.runtimes?.find((candidate) => candidate.id === persona.runtime) + ? resolvePersonaManagedAgentRuntime(persona.runtime, options.runtimes) : undefined; if (runtime?.command) { if (runtime.command !== agent.agentCommand) { @@ -291,6 +291,15 @@ export function personaManagedAgentUpdate( return hasChanges ? input : null; } +function resolvePersonaManagedAgentRuntime( + runtimeId: string | null | undefined, + runtimes: readonly AcpRuntimeCatalogEntry[] | undefined, +) { + if (!runtimes?.length) return undefined; + if (!runtimeId) return runtimes[0]; + return runtimes.find((candidate) => candidate.id === runtimeId); +} + function mergedPersonaEnvVarsForAgent( agent: ManagedAgent, persona: AgentPersona,