fix(downloads): rewire MaintenanceMenu to the downloads pipeline

The maintenance dropdown in Subscriptions → Downloads was wired to the
filesystem-import pipeline (POST /api/import/retry-failed +
POST /api/import/clear-stuck) — the subtitles even said so ("Re-enqueue
every failed import task"), but it was contextually misplaced. From the
Downloads view "Retry failed" queued nothing the operator could see
because the action operated on import_task rows, not download_event
rows. Import-pipeline maintenance is already reachable from Settings →
Imports (ImportTaskList.vue), so removing the import wiring loses
nothing.

Rewired:
- "Retry failed" → bulk-retries the failing-sources list, same loop as
  FailingSourcesCard's RETRY ALL (sourcesStore.checkNow per source).
  Subtitle now matches: "Re-queue every currently failing source".
- "Force recovery sweep" → triggers recover_stalled_download_events on
  demand via a new POST /api/downloads/recover-stalled endpoint. The
  sweep also runs every 5 min on Beat; this is the manual fallback so
  the operator doesn't have to wait for the next tick to clear newly
  stranded events.

MaintenanceMenu is now stateless — emits retry-failed and recover-
stalled. DownloadsTab owns the handlers (reuses the existing
onRetryAll; new onRecoverStalled with a delayed refresh so swept rows
land in the failing rollup).

Operator-flagged 2026-05-29 — "the retry failed button in the
maintenance dropdown doesn't appear to queue anything but manual
requeues works."

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-30 00:59:05 -04:00
parent 36f8ec80fd
commit 77e9859da3
5 changed files with 77 additions and 36 deletions
+20
View File
@@ -134,3 +134,23 @@ async def test_activity_returns_fixed_bucket_array(client, seed):
async def test_activity_rejects_bogus_hours(client):
resp = await client.get("/api/downloads/activity?hours=bogus")
assert resp.status_code == 400
@pytest.mark.asyncio
async def test_recover_stalled_dispatches_task(client, monkeypatch):
"""POST /api/downloads/recover-stalled returns 202 and dispatches the
recover_stalled_download_events task. The task body itself is exercised
in test_maintenance.py — this just covers the API → Celery hand-off."""
from backend.app.tasks import maintenance
called: list[tuple] = []
monkeypatch.setattr(
maintenance.recover_stalled_download_events, "delay",
lambda *a, **kw: called.append((a, kw)),
)
resp = await client.post("/api/downloads/recover-stalled")
assert resp.status_code == 202
body = await resp.get_json()
assert body == {"queued": True}
assert len(called) == 1