diff --git a/backend/src/routes/adminItemDrafts.ts b/backend/src/routes/adminItemDrafts.ts index 833c4a2..4954413 100644 --- a/backend/src/routes/adminItemDrafts.ts +++ b/backend/src/routes/adminItemDrafts.ts @@ -1,6 +1,7 @@ import { Router, Request, Response } from 'express'; import { pool } from '../db'; import { asyncRoute } from '../asyncRoute'; +import { draftQueued } from '../intake/draftingWorker'; import { nextPriceSource, PriceSource } from '../intake/priceSource'; const router = Router(); @@ -148,6 +149,15 @@ router.post( [req.params.itemId] ); if (rowCount === 0) return res.status(404).json({ error: 'no draft for this item' }); + + // Wake the worker rather than leaving the row for the five-minute sweeper. + // Both this and the submission path put a row into 'queued'; only that one + // asked for it to be drafted, which made this button indistinguishable from + // a dead one (#272). Fire and forget with a logged catch, exactly as there: + // a slow or failing model call must not become a failed request for the + // admin, and the sweeper is still the backstop if this misses. + void draftQueued(1).catch((err) => console.error('[drafting] after regenerate:', err)); + res.json({ state: 'queued' }); }) ); diff --git a/backend/src/routes/intakeActions.ts b/backend/src/routes/intakeActions.ts index 7e60867..b6e5be8 100644 --- a/backend/src/routes/intakeActions.ts +++ b/backend/src/routes/intakeActions.ts @@ -1,6 +1,7 @@ import { Router, Request, Response } from 'express'; import { pool } from '../db'; import { asyncRoute } from '../asyncRoute'; +import { draftQueued } from '../intake/draftingWorker'; import { IntakeAction, verifyAction } from '../intake/actionLinks'; const router = Router(); @@ -96,6 +97,15 @@ router.post( [checked.itemId] ); if (rowCount === 0) return res.status(404).json({ error: 'no draft for this item' }); + + // Wake the worker rather than leaving the row for the five-minute sweeper. + // Both this and the submission path put a row into 'queued'; only that one + // asked for it to be drafted, which made this button indistinguishable from + // a dead one (#272). Fire and forget with a logged catch, exactly as there: + // a slow or failing model call must not become a failed request for the + // admin, and the sweeper is still the backstop if this misses. + void draftQueued(1).catch((err) => console.error('[drafting] after regenerate:', err)); + return res.json({ state: 'queued' }); }