diff --git a/packages/app/src/composer/draft/create-flow.ts b/packages/app/src/composer/draft/create-flow.ts index 69895358f..ea3638da6 100644 --- a/packages/app/src/composer/draft/create-flow.ts +++ b/packages/app/src/composer/draft/create-flow.ts @@ -214,14 +214,6 @@ export function useDraftAgentCreateFlow({ }), ); markPendingCreateLifecycle({ draftId, lifecycle: "sent" }); - if ( - useSessionStore.getState().sessions[pendingServerId]?.agents.get(createResult.agentId) - ?.status === "running" - ) { - useCreateFlowStore - .getState() - .clearByAgent({ serverId: pendingServerId, agentId: createResult.agentId }); - } } await onCreateSuccess({ result: createResult.result, attempt }); diff --git a/packages/app/src/contexts/session-context.tsx b/packages/app/src/contexts/session-context.tsx index dece8f2ec..8a627d614 100644 --- a/packages/app/src/contexts/session-context.tsx +++ b/packages/app/src/contexts/session-context.tsx @@ -327,12 +327,10 @@ function finalizeTimelineApplication(input: { } if (shouldMarkAuthoritativeHistoryApplied) { setAgentAuthoritativeHistoryApplied(serverId, agentId, true); + useCreateFlowStore.getState().clearByAgent({ serverId, agentId }); markAgentHistorySynchronized(serverId, agentId); const session = useSessionStore.getState().sessions[serverId]; const agent = session?.agents.get(agentId) ?? session?.agentDetails.get(agentId); - if (agent?.status === "running") { - useCreateFlowStore.getState().clearByAgent({ serverId, agentId }); - } if (agent && agent.status !== "running") { getHostRuntimeStore().drainQueuedAgentMessage(serverId, agentId); } @@ -815,14 +813,6 @@ function SessionProviderInternal({ children, serverId, client }: SessionProvider ) { voiceRuntime?.onTurnEvent(serverId, agentId, event.type); } - if ( - event.type === "turn_completed" || - event.type === "turn_failed" || - event.type === "turn_canceled" - ) { - useCreateFlowStore.getState().clearByAgent({ serverId, agentId }); - } - agentStreamReducerQueue.enqueue(agentId, { event: streamEvent, seq, diff --git a/packages/app/src/utils/agent-directory-sync.ts b/packages/app/src/utils/agent-directory-sync.ts index 532a50478..24e14c420 100644 --- a/packages/app/src/utils/agent-directory-sync.ts +++ b/packages/app/src/utils/agent-directory-sync.ts @@ -9,7 +9,6 @@ import { acceptAgentDirectoryUpdate } from "@/utils/agent-directory-update-polic import { buildDraftStoreKey } from "@/stores/draft-keys"; import { useDraftStore } from "@/stores/draft-store"; import { getInitDeferred, getInitKey, rejectInitDeferred } from "@/utils/agent-initialization"; -import { useCreateFlowStore } from "@/stores/create-flow-store"; type AgentDirectoryFetchEntry = FetchAgentsEntry; export type AgentDirectoryDelta = Extract< @@ -53,9 +52,6 @@ function upsertAgentDirectoryReplica( previousAgent?.projectPlacement, }; const acceptedAgent = upsertAgentReplica(serverId, agent); - if (acceptedAgent.status === "running") { - useCreateFlowStore.getState().clearByAgent({ serverId, agentId: acceptedAgent.id }); - } if (acceptedAgent.archivedAt) { clearArchiveAgentPending({ queryClient, serverId, agentId: acceptedAgent.id }); } @@ -178,12 +174,6 @@ export function replaceFetchedAgentDirectory(input: { const store = useSessionStore.getState(); for (const agent of fetchedAgents.values()) { - if (agent.status === "running") { - useCreateFlowStore.getState().clearByAgent({ - serverId: input.serverId, - agentId: agent.id, - }); - } if (agent.archivedAt) { clearArchiveAgentPending({ queryClient, serverId: input.serverId, agentId: agent.id }); }