fix: propagate queue cancel to run state

This commit is contained in:
Codex
2026-06-09 02:12:12 +08:00
parent 0227babce6
commit 70f2a6e22a
3 changed files with 9 additions and 5 deletions
+2 -2
View File
@@ -985,8 +985,8 @@ CREATE TABLE IF NOT EXISTS agentrun_schema_migrations (
async cancelQueueTask(taskId: string, reason = "cancel requested"): Promise<QueueTaskRecord> {
const task = await this.getQueueTask(taskId);
if (isTerminalQueueTaskState(task.state)) return task;
if (task.latestAttempt?.commandId) await this.cancelCommand(task.latestAttempt.commandId, reason);
else if (task.latestAttempt?.runId) await this.cancelRun(task.latestAttempt.runId, reason);
if (task.latestAttempt?.runId) await this.cancelRun(task.latestAttempt.runId, reason);
else if (task.latestAttempt?.commandId) await this.cancelCommand(task.latestAttempt.commandId, reason);
return this.withTransaction(async (client) => {
const existing = await client.query("SELECT * FROM agentrun_queue_tasks WHERE id = $1 FOR UPDATE", [taskId]);
const row = existing.rows[0];