mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
Fix profile sidebar review feedback
This commit is contained in:
@@ -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<CreateManagedAgentResponse | null>(null);
|
||||
|
||||
return {
|
||||
createdAgentSecretDialog: createdAgent ? (
|
||||
<SecretRevealDialog
|
||||
created={createdAgent}
|
||||
onOpenChange={(open) => {
|
||||
if (!open) {
|
||||
setCreatedAgent(null);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
) : null,
|
||||
setCreatedAgent,
|
||||
};
|
||||
}
|
||||
@@ -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<ProfilePanelView>("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({
|
||||
</div>
|
||||
{editAgentDialog}
|
||||
{addAgentToChannelDialog}
|
||||
{createdAgentSecretDialog}
|
||||
{personaDialogs}
|
||||
</>
|
||||
);
|
||||
@@ -985,6 +990,7 @@ export function UserProfilePanel({
|
||||
</aside>
|
||||
{editAgentDialog}
|
||||
{addAgentToChannelDialog}
|
||||
{createdAgentSecretDialog}
|
||||
{personaDialogs}
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user