fix(precedents): allow delete when extraction completed but timestamp stale
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 32s

The local MCP worker is supposed to NULL `*_extraction_requested_at` after
a successful run, but in practice these timestamps linger. The previous
isPrecedentActive logic treated any non-null timestamp as "still active",
which left completed rows permanently undeletable.

Now only "processing" status (or genuinely queued: pending + timestamp)
counts as active. Once a row is "completed"/"failed", stale timestamps
no longer block the delete button.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-03 16:24:16 +00:00
parent 1f17419ee9
commit 789cc273ee

View File

@@ -187,13 +187,37 @@ export function usePrecedents(filters: ListFilters = {}) {
} }
/** A precedent is "active" while text/halacha extraction is in flight or /** A precedent is "active" while text/halacha extraction is in flight or
* queued for the local MCP worker. Used by the auto-refresh poller and * legitimately queued for the local MCP worker. Used by the auto-refresh
* by the row UI to disable destructive actions. */ * poller and by the row UI to disable destructive actions.
*
* Once a status is "completed" or "failed", the row is NEVER active —
* even if the corresponding `*_requested_at` timestamp still has a value.
* The worker is supposed to NULL it on success but in practice doesn't
* always, and treating those rows as active leaves them permanently
* undeletable. */
export function isPrecedentActive(p: Precedent): boolean { export function isPrecedentActive(p: Precedent): boolean {
// Text extraction
if (p.extraction_status === "processing") return true; if (p.extraction_status === "processing") return true;
// Halacha extraction
if (p.halacha_extraction_status === "processing") return true; if (p.halacha_extraction_status === "processing") return true;
if (p.halacha_extraction_requested_at !== null) return true; if (
if (p.metadata_extraction_requested_at !== null) return true; p.halacha_extraction_status === "pending" &&
p.halacha_extraction_requested_at !== null
) {
return true;
}
// Metadata extraction has no status column — only the timestamp.
// Treat as active only when extraction hasn't yet fully completed
// (otherwise stale timestamps linger after success).
if (
p.metadata_extraction_requested_at !== null &&
p.extraction_status !== "completed"
) {
return true;
}
return false; return false;
} }