mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
Fix profile sidebar edit and secret reveal
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
@@ -18,6 +18,7 @@ type SubmitProfilePersonaDialogOptions = {
|
||||
createPersona: (input: CreatePersonaInput) => Promise<AgentPersona>;
|
||||
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}`,
|
||||
|
||||
Reference in New Issue
Block a user