add clear queue button on execute page
All checks were successful
Build and Push Docker Image / build (push) Successful in 20s

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 <noreply@anthropic.com>
This commit is contained in:
2026-03-04 17:11:18 +01:00
parent ef785de955
commit 37fae33bbc
2 changed files with 16 additions and 0 deletions

View File

@@ -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) => {

View File

@@ -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() {
<div className="flex gap-3 mb-6">
{pending > 0 && <Button onClick={startAll}> Run all pending</Button>}
{pending > 0 && <Button variant="secondary" onClick={clearQueue}> Clear queue</Button>}
{jobs.length === 0 && (
<p className="text-gray-500 m-0">
No jobs yet. Go to <Link to="/review">Review</Link> and approve items first.