fix: clear lyrics-review cache on job status change

renderLyricsReview was caching its job ID only in the done path, allowing
stale data to persist when switching between done/running/failed jobs.
Now clears the cache in the failed and not-done branches so a previously-
viewed done job always re-fetches when re-selected.

Regression test: test_lyrics_review_cache_clears_on_job_status_change
verifies both branches clear the cache key before rendering placeholders.
This commit is contained in:
2026-07-27 23:36:56 -07:00
parent 903e83dbcc
commit 6a98ea0f21
2 changed files with 19 additions and 0 deletions
+2
View File
@@ -872,10 +872,12 @@ function buildLyricsReview(data) {
async function renderLyricsReview(job) { async function renderLyricsReview(job) {
const box = document.getElementById("lyrics-review"); const box = document.getElementById("lyrics-review");
if (job.status === "failed") { if (job.status === "failed") {
delete box.dataset.jobId;
box.replaceChildren(emptyNote("job failed — nothing to review")); box.replaceChildren(emptyNote("job failed — nothing to review"));
return; return;
} }
if (job.status !== "done") { if (job.status !== "done") {
delete box.dataset.jobId;
box.replaceChildren(emptyNote("waiting for this song to finish…")); box.replaceChildren(emptyNote("waiting for this song to finish…"));
return; return;
} }
+17
View File
@@ -433,6 +433,23 @@ def test_index_lyrics_review_uses_endash_for_time_ranges():
assert "–" in body assert "–" in body
def test_lyrics_review_cache_clears_on_job_status_change():
"""Regression: switching between done/failed/running jobs must clear the
cache so a previously-viewed done job re-fetches when re-selected."""
html = _index_html()
body = _fn_body(html, "renderLyricsReview")
# The "failed" branch must clear the cache before rendering the placeholder
assert re.search(
r'if\s*\(\s*job\.status\s*===\s*"failed"\s*\)\s*\{[^}]*'
r'delete\s+box\.dataset\.jobId',
body, re.S), "failed branch must delete cache key"
# The "not done" (queued/running) branch must clear the cache before rendering
assert re.search(
r'if\s*\(\s*job\.status\s*!==\s*"done"\s*\)\s*\{[^}]*'
r'delete\s+box\.dataset\.jobId',
body, re.S), "not done branch must delete cache key"
def test_index_has_copy_path_control(): def test_index_has_copy_path_control():
assert "copy-path" in _index_html() assert "copy-path" in _index_html()