| @@ -206,14 +206,18 @@ |
| 206 | 206 | const run = db |
| 207 | 207 | .prepare(`${RUN_SELECT} WHERE pr.id = ?`) |
| 208 | 208 | .get(parseInt(id)) as any; |
| 209 | | if (!run || run.status !== "running") { |
| 210 | | return reply.code(400).send({ error: "Run is not running" }); |
| 209 | if (!run || (run.status !== "running" && run.status !== "pending")) { |
| 210 | return reply.code(400).send({ error: "Run is not running or pending" }); |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | runner.cancelRun(parseInt(id)); |
| 214 | 214 | db.prepare( |
| 215 | 215 | `UPDATE pipeline_runs SET status = 'cancelled', finished_at = datetime('now') WHERE id = ?` |
| 216 | 216 | ).run(parseInt(id)); |
| 217 | // Also cancel any pending/running steps |
| 218 | db.prepare( |
| 219 | `UPDATE pipeline_steps SET status = 'cancelled' WHERE run_id = ? AND status IN ('pending', 'running')` |
| 220 | ).run(parseInt(id)); |
| 217 | 221 | |
| 218 | 222 | const updated = db |
| 219 | 223 | .prepare(`${RUN_SELECT} WHERE pr.id = ?`) |
| 220 | 224 | |