Fresh history cut from cynarAI/evoo antigravity-handoff/project-timeline (Voice First + project timeline). Brand docs/titles as evOo; keep @rakazo/* packages as tech debt. Excludes node_modules, caches, secrets, voice blobs.
29 lines
905 B
TypeScript
29 lines
905 B
TypeScript
import type { Prisma } from "./client.js";
|
|
|
|
/** The caller selects authorized runs and owns the surrounding transaction and cleanup. */
|
|
export async function cancelRunsInTransaction(
|
|
tx: Pick<Prisma.TransactionClient, "run" | "attempt" | "task">,
|
|
runs: ReadonlyArray<{ id: string; taskId: string }>,
|
|
cancelledAt: Date,
|
|
): Promise<void> {
|
|
if (runs.length === 0) return;
|
|
const runIds = runs.map((run) => run.id);
|
|
await tx.run.updateMany({
|
|
where: { id: { in: runIds } },
|
|
data: {
|
|
status: "cancelled",
|
|
completedAt: cancelledAt,
|
|
leaseOwner: null,
|
|
leaseExpiresAt: null,
|
|
},
|
|
});
|
|
await tx.attempt.updateMany({
|
|
where: { runId: { in: runIds }, status: "running" },
|
|
data: { status: "cancelled", finishedAt: cancelledAt },
|
|
});
|
|
await tx.task.updateMany({
|
|
where: { id: { in: runs.map((run) => run.taskId) } },
|
|
data: { status: "cancelled" },
|
|
});
|
|
}
|