Disable persona start while runtime discovery runs (#1353)

This commit is contained in:
klopez4212
2026-06-29 09:37:08 -07:00
committed by GitHub
parent 1c221eaafd
commit 92a5f1fc66
3 changed files with 29 additions and 13 deletions
@@ -74,7 +74,7 @@ export function AgentsView() {
isActionPending={isActionPending}
isAgentsLoading={agents.managedAgentsQuery.isLoading}
startingAgentPubkey={agents.startingAgentPubkey}
startingPersonaId={agents.startingPersonaId}
startingPersonaIds={agents.startingPersonaIds}
onBulkRemoveStopped={() => {
void agents.handleBulkRemoveStopped();
}}
@@ -37,7 +37,7 @@ type UnifiedAgentsSectionProps = {
isActionPending: boolean;
isAgentsLoading: boolean;
startingAgentPubkey: string | null;
startingPersonaId: string | null;
startingPersonaIds: ReadonlySet<string>;
onBulkRemoveStopped: () => void;
onBulkStopRunning: () => void;
onCreateAgent: () => void;
@@ -72,7 +72,7 @@ export function UnifiedAgentsSection(props: UnifiedAgentsSectionProps) {
isActionPending,
isAgentsLoading,
startingAgentPubkey,
startingPersonaId,
startingPersonaIds,
onBulkRemoveStopped,
onBulkStopRunning,
onCreateAgent,
@@ -174,7 +174,7 @@ export function UnifiedAgentsSection(props: UnifiedAgentsSectionProps) {
key={group.persona.id}
persona={group.persona}
startingAgentPubkey={startingAgentPubkey}
startingPersonaId={startingPersonaId}
startingPersonaIds={startingPersonaIds}
onOpenAgentProfile={onOpenAgentProfile}
onOpenPersonaProfile={onOpenPersonaProfile}
onStartAgent={onStartAgent}
@@ -253,7 +253,7 @@ function AgentPersonaCard({
agent,
persona,
startingAgentPubkey,
startingPersonaId,
startingPersonaIds,
onOpenAgentProfile,
onOpenPersonaProfile,
onStartAgent,
@@ -262,7 +262,7 @@ function AgentPersonaCard({
agent: ManagedAgent | undefined;
persona: AgentPersona;
startingAgentPubkey: string | null;
startingPersonaId: string | null;
startingPersonaIds: ReadonlySet<string>;
onOpenAgentProfile: (
pubkey: string,
options?: ProfilePanelOpenOptions,
@@ -307,7 +307,7 @@ function AgentPersonaCard({
activeTestId={`persona-runtime-active-${persona.id}`}
avatarUrl={avatarUrl}
isActive={false}
isStarting={startingPersonaId === persona.id}
isStarting={startingPersonaIds.has(persona.id)}
label={title}
startTestId={`persona-runtime-start-${persona.id}`}
onStart={() => onStartPersona(persona)}
@@ -51,6 +51,10 @@ export function useManagedAgentActions() {
React.useState<ManagedAgent | null>(null);
const [createdAgent, setCreatedAgent] =
React.useState<CreateManagedAgentResponse | null>(null);
const [startingPersonaIds, setStartingPersonaIds] = React.useState<
ReadonlySet<string>
>(() => new Set());
const startingPersonaIdsRef = React.useRef(new Set<string>());
const [logAgentPubkey, setLogAgentPubkey] = React.useState<string | null>(
null,
);
@@ -177,7 +181,22 @@ export function useManagedAgentActions() {
return filterAvailableRuntimes(result.data);
}
function setPersonaStartPending(personaId: string, pending: boolean) {
const next = new Set(startingPersonaIdsRef.current);
if (pending) {
next.add(personaId);
} else {
next.delete(personaId);
}
startingPersonaIdsRef.current = next;
setStartingPersonaIds(next);
}
async function handleStartPersona(persona: AgentPersona) {
if (startingPersonaIdsRef.current.has(persona.id)) {
return;
}
setPersonaStartPending(persona.id, true);
clearFeedback();
try {
const runtimes = await getAvailableRuntimesForStart();
@@ -238,6 +257,8 @@ export function useManagedAgentActions() {
setActionErrorMessage(
error instanceof Error ? error.message : "Failed to start agent.",
);
} finally {
setPersonaStartPending(persona.id, false);
}
}
@@ -436,11 +457,6 @@ export function useManagedAgentActions() {
startMutation.isPending && typeof startMutation.variables === "string"
? startMutation.variables
: null;
const startingPersonaId =
createAgentMutation.isPending &&
typeof createAgentMutation.variables?.personaId === "string"
? createAgentMutation.variables.personaId
: null;
return {
relayAgentsQuery,
@@ -465,7 +481,7 @@ export function useManagedAgentActions() {
actionErrorMessage,
setActionErrorMessage,
startingAgentPubkey,
startingPersonaId,
startingPersonaIds,
handleStart,
handleStartPersona,
handleStop,