diff --git a/server.py b/server.py index 9e670f89..ed88eb8c 100644 --- a/server.py +++ b/server.py @@ -3038,6 +3038,22 @@ def enrichment_states_for(self, filenames: list[str]) -> dict: out[fn] = st return out + def _unmatched_set(self, filenames) -> set: + """The subset of `filenames` whose enrichment landed in the 'failed' + (no-match) state — feeds the grid's persistent per-card "no match" badge, + so the misses stay visible at rest (the batch tile only shows while a + refresh runs). Chunked set membership, like favorite_set.""" + fns = list(filenames) + out: set = set() + for i in range(0, len(fns), 400): + chunk = fns[i:i + 400] + if not chunk: + break + q = ("SELECT filename FROM song_enrichment WHERE match_state = 'failed' " + "AND filename IN (%s)" % ",".join("?" * len(chunk))) + out.update(r[0] for r in self.conn.execute(q, chunk).fetchall()) + return out + def enrichment_song_row(self, filename: str) -> dict | None: """The identity fields the matcher/scorer keys on, for one song.""" row = self.conn.execute( @@ -4042,6 +4058,11 @@ def query_page(self, q: str = "", page: int = 0, size: int = 24, fns = [s["filename"] for s in songs] udm = self.user_meta_map(fns) tgm = self.tags_map(fns) + # Enrichment "no match" (failed) set for the page, so a card can show a + # persistent "no match" badge — the Refresh-Metadata batch's transient + # per-tile state only paints while a pass runs. Cheap set membership like + # favs/estd, so the misses stay visible at rest. + um = self._unmatched_set(fns) # Canonical artist at display (P4): re-label the card's artist through the # alias override so "ACDC" reads as "AC/DC". Display-only — the row's sort # position (raw artist) is untouched, so a card can show a canonical name @@ -4051,6 +4072,7 @@ def query_page(self, q: str = "", page: int = 0, size: int = 24, for s in songs: s["user_difficulty"] = udm.get(s["filename"]) s["tags"] = tgm.get(s["filename"], []) + s["unmatched"] = s["filename"] in um if amap: s["artist"] = amap.get((s.get("artist") or "").lower(), s.get("artist")) # Grouped rows carry the ⚑ N (chart_count) + the work_key from the diff --git a/static/v3/songs.js b/static/v3/songs.js index 9d6fe9d2..188053fa 100644 --- a/static/v3/songs.js +++ b/static/v3/songs.js @@ -498,21 +498,32 @@ // to before (keeps the windowed grid's height math untouched). Honest state // transitions, NOT a fake per-song %: a match is binary (design §11). const _metaTile = {}; // fn -> 'queued' | 'working' | 'done' | 'nochange' - function enrichBadge(fn) { - const st = _metaTile[fn]; + // Cards whose enrichment landed 'failed' (from the grid payload) — tracked so + // the PERSISTENT "no match" badge survives a batch tile clearing (a + // _patchCardEnrich with no flag falls back to this instead of wiping it). + // Populated as cards render (enrichBadge is called per card with the flag). + const _unmatched = new Set(); + function enrichBadge(fn, unmatched) { + if (unmatched !== undefined) { if (unmatched) _unmatched.add(fn); else _unmatched.delete(fn); } + // A live batch tile wins over the resting no-match marker (they never + // coexist — the batch clears its tiles when it finishes). + const st = _metaTile[fn] || (_unmatched.has(fn) ? 'nomatch' : null); if (!st) return ''; const M = { - queued: ['bg-black/60 text-fb-textDim', '• Queued'], - working: ['bg-fb-primary text-white', '⟳ Matching…'], - done: ['bg-fb-good/90 text-black', '✓ Updated'], - nochange: ['bg-black/60 text-fb-textDim', '— No match'], + queued: ['bg-black/60 text-fb-textDim', '• Queued', ''], + working: ['bg-fb-primary text-white', '⟳ Matching…', ''], + done: ['bg-fb-good/90 text-black', '✓ Updated', ''], + nochange: ['bg-black/60 text-fb-textDim', '— No match', ''], + // Resting indicator: subtle, so a mostly-unmatched library isn't a + // wall of loud badges; points at the manual fix. + nomatch: ['bg-black/60 text-fb-textDim', 'No match', 'No metadata match found — right-click to fix it by hand'], }; const conf = M[st] || M.queued; // top-10 clears the tuning chip (top-2) in both normal and select mode; // z-20 sits it above the art. Non-interactive so it never eats a click. return ''; + ' text-[0.5625rem] font-bold px-1.5 py-0.5 rounded-sm leading-tight pointer-events-none"' + + (conf[2] ? ' title="' + conf[2] + '"' : '') + '>' + conf[1] + ''; } // After a song is scored, the badge for that card is stale until the next @@ -870,7 +881,7 @@ return '