From 37fae33bbcad0749d2c5607df601b758f39af9b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20F=C3=B6rtsch?= Date: Wed, 4 Mar 2026 17:11:18 +0100 Subject: [PATCH] add clear queue button on execute page deletes all pending jobs, reverts their review plans back to pending so they can be re-reviewed and re-approved. Co-Authored-By: Claude Opus 4.6 --- server/api/execute.ts | 14 ++++++++++++++ src/features/execute/ExecutePage.tsx | 2 ++ 2 files changed, 16 insertions(+) diff --git a/server/api/execute.ts b/server/api/execute.ts index 4e6845c..9724cba 100644 --- a/server/api/execute.ts +++ b/server/api/execute.ts @@ -115,6 +115,20 @@ app.post('/job/:id/cancel', (c) => { return c.json({ ok: true }); }); +// ─── Clear queue ────────────────────────────────────────────────────────────── + +app.post('/clear', (c) => { + const db = getDb(); + // Revert review plans for pending jobs back to 'pending' so they can be re-approved + db.prepare(` + UPDATE review_plans SET status = 'pending', reviewed_at = NULL + WHERE item_id IN (SELECT item_id FROM jobs WHERE status = 'pending') + AND status = 'approved' + `).run(); + const result = db.prepare("DELETE FROM jobs WHERE status = 'pending'").run(); + return c.json({ ok: true, cleared: result.changes }); +}); + // ─── SSE ────────────────────────────────────────────────────────────────────── app.get('/events', (c) => { diff --git a/src/features/execute/ExecutePage.tsx b/src/features/execute/ExecutePage.tsx index 709ec0c..4a12eab 100644 --- a/src/features/execute/ExecutePage.tsx +++ b/src/features/execute/ExecutePage.tsx @@ -54,6 +54,7 @@ export function ExecutePage() { }, []); const startAll = async () => { await api.post('/api/execute/start'); load(); }; + const clearQueue = async () => { await api.post('/api/execute/clear'); load(); }; const runJob = async (id: number) => { await api.post(`/api/execute/job/${id}/run`); load(); }; const cancelJob = async (id: number) => { await api.post(`/api/execute/job/${id}/cancel`); load(); }; const assignNode = async (jobId: number, nodeId: number | null) => { @@ -86,6 +87,7 @@ export function ExecutePage() {
{pending > 0 && } + {pending > 0 && } {jobs.length === 0 && (

No jobs yet. Go to Review and approve items first.