feat(slint): Plex quality hydration on album-open + consistent quality badges (port slice 6)

Hydration:
- qbz-plex: additive plex_hydrate_album_quality(base, token, rating_keys) — per
  key plex_get_track_metadata (batch 5, 5s/call timeout, skip failures) then the
  COALESCE write-back plex_cache_update_track_quality; awaited before re-read.
- qbz-player/qbz-core: patch_plex_quality / patch_plex_queue_quality patch the
  in-memory queue in place by rating_key (for the now-playing stamp).
- qbz-slint: album-open trigger (gated on DB-NULL, not a value heuristic) then
  refresh of all badge surfaces — album-card grid (re-read aggregate + patch
  every model + the raw filter source), album-detail header + rows, now-playing
  stamp. Re-sync stays routed through plex_cache_save_tracks (carry-over).

Quality badge consistency (the four surfaces must agree — and pre-hydration
show the filetype, not nothing):
- One shared classifier crate::quality::badge(format, bit_depth, sample_rate) ->
  (tier, detail, tooltip); the album card, album-detail header and track rows
  all route through it (kills the per-surface duplication that produced
  "96 kHz" vs "96000 kHz"). sample_rate normalized to kHz via a >=1000 guard so
  Qobuz's already-kHz values are never re-divided (no "0.041 kHz").
- New "lossless" tier: an un-hydrated lossless file (FLAC/WAV/ALAC… with unknown
  bit depth) shows a generic filetype badge ("FLAC") instead of an empty badge,
  rendered in QualityBadge (compact chip) + QualityBadgeFull; upgrades to
  "24-bit / 96 kHz" after hydration. Local/Qobuz/mp3 unchanged.

cc
This commit is contained in:
vicrodh committed 2026-06-08 10:27:28 -06:00
1 parent a680da5ad8
commit 5939c090ca
10 files changed
+599 -38

No files matched your search

+21
View File
@@ -625,6 +625,27 @@ impl<A: FrontendAdapter + Send + Sync + 'static> QbzCore<A> {
result
}
/// Patch the cached quality of any queued Plex track whose `rating_key`
/// matches one of `updates` (`(rating_key, bit_depth, sample_rate_khz)`).
/// Frontend-agnostic hook for the Plex quality-hydration path: a track
/// hydrated while it is already enqueued/playing carries a frozen quality
/// snapshot, so this upgrades it in place. Returns true if the CURRENT
/// track was patched — the caller then re-pushes the now-playing stamp.
pub async fn patch_plex_queue_quality(
&self,
updates: &[(String, Option<u32>, Option<f64>)],
) -> bool {
let queue = self.queue.write().await;
let current_patched = queue.patch_plex_quality(updates);
if current_patched {
self.emit(CoreEvent::QueueUpdated {
state: queue.get_state(),
})
.await;
}
current_patched
}
// ==================== Search & Catalog ====================
/// Search for albums