diff --git a/apps/x/apps/renderer/src/components/sidebar-content.tsx b/apps/x/apps/renderer/src/components/sidebar-content.tsx index 2207a856..5bccd41e 100644 --- a/apps/x/apps/renderer/src/components/sidebar-content.tsx +++ b/apps/x/apps/renderer/src/components/sidebar-content.tsx @@ -1056,21 +1056,23 @@ function TasksSection({ ) : null} {run.title || '(Untitled chat)'} {run.createdAt ? ( - + {formatRunTime(run.createdAt)} ) : null} - + {!processingRunIds?.has(run.id) && ( + + )} diff --git a/apps/x/packages/core/src/runs/runs.ts b/apps/x/packages/core/src/runs/runs.ts index d15144c4..490e935f 100644 --- a/apps/x/packages/core/src/runs/runs.ts +++ b/apps/x/packages/core/src/runs/runs.ts @@ -6,6 +6,7 @@ import { IRunsRepo } from "./repo.js"; import { IAgentRuntime } from "../agents/runtime.js"; import { IBus } from "../application/lib/bus.js"; import { IAbortRegistry } from "./abort-registry.js"; +import { IRunsLock } from "./lock.js"; import { forceCloseAllMcpClients } from "../mcp/mcp.js"; export async function createRun(opts: z.infer): Promise> { @@ -66,8 +67,16 @@ export async function stop(runId: string, force: boolean = false): Promise } export async function deleteRun(runId: string): Promise { - const repo = container.resolve('runsRepo'); - await repo.delete(runId); + const runsLock = container.resolve('runsLock'); + if (!await runsLock.lock(runId)) { + throw new Error(`Cannot delete run ${runId}: run is currently active`); + } + try { + const repo = container.resolve('runsRepo'); + await repo.delete(runId); + } finally { + await runsLock.release(runId); + } } export async function fetchRun(runId: string): Promise> {