mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-04-29 18:36:23 +02:00
refactor: enhance delete run logic with locking mechanism and update sidebar button visibility
This commit is contained in:
parent
5f3b0a3174
commit
6b0f31c369
2 changed files with 25 additions and 14 deletions
|
|
@ -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<typeof CreateRunOptions>): Promise<z.infer<typeof Run>> {
|
||||
|
|
@ -66,8 +67,16 @@ export async function stop(runId: string, force: boolean = false): Promise<void>
|
|||
}
|
||||
|
||||
export async function deleteRun(runId: string): Promise<void> {
|
||||
const repo = container.resolve<IRunsRepo>('runsRepo');
|
||||
await repo.delete(runId);
|
||||
const runsLock = container.resolve<IRunsLock>('runsLock');
|
||||
if (!await runsLock.lock(runId)) {
|
||||
throw new Error(`Cannot delete run ${runId}: run is currently active`);
|
||||
}
|
||||
try {
|
||||
const repo = container.resolve<IRunsRepo>('runsRepo');
|
||||
await repo.delete(runId);
|
||||
} finally {
|
||||
await runsLock.release(runId);
|
||||
}
|
||||
}
|
||||
|
||||
export async function fetchRun(runId: string): Promise<z.infer<typeof Run>> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue