Stage 1 of the seam the owner asked for: "son vistas súper híbridas donde se mezcla Qobuz/Local(Folders/Plex) ... hay que hacer una solución agnóstica porque no tardamos en meter a Jellyfin y quizás Navidrome". Nothing is wired yet — this lands the crate, its three source implementations and its tests. `qbz-qt` and `qbz` are untouched, so this commit changes no behaviour. The problem it exists to end, measured rather than assumed: 129 source-branching sites across 30 files in qbz-qt alone, SEVEN distinct item->tracks resolvers none of which can reach the others, FIVE non-interchangeable artwork pipelines over one correct taxonomy, and six incompatible source vocabularies — three of which cannot express Plex at all, including the PERSISTED one (`AlbumSource` is `Qobuz|Local`). Every hybrid view re-wires the per-source handling by hand, which is why something is always missing. One `Source` trait covering the four concerns together — tracks, metadata and origin, artwork, playback — because splitting them is exactly what lets a view forget one. A `SourceRegistry` with claim-priority ordering (Qobuz, Plex, then Local; Plex-before-Local is load-bearing). `RegistryResolver` implements `qbz_mixtape::ItemResolver`, so that crate and the Slint glue stay byte- untouched and keep compiling. The three measured bugs die structurally, not by discipline: - The local DB was reopened PER CALL, so a My QBZ collection logged one "Opening library database" per item (34 measured live). `LocalSource` owns a pooled handle, and it hands out no guard — only `with(|db| ...)` — so a `!Send` `&LibraryDatabase` provably cannot cross an await. `qbz-mixtape`'s sync-resolver constraint becomes an API property instead of a comment. - A `plex:<hash>` album key reached an API that wants a rating key. `MediaRef` has no public constructor: only `registry.claim` mints one, and `PlexSource::claim` rejects that shape in track position. The survey also found a second, undiscovered face of the same bug — "Go to album" on a Plex track row opens an empty page. - Local rows in a hybrid list rendered placeholder discs. Traced to its real mechanism: those items are stored with `artwork_url: None` and the only backfill is behind a Qobuz-client gate, so offline or pre-login the art is on disk and never shown. `Source::artwork` is one call per row whatever the source, and keeps the cheap/cold split the local path already had. Adding Jellyfin is one new file, four diff lines inside this crate, and one line in `auth_qt.rs` — and the design states this only holds BECAUSE artwork sits on the trait. 36 tests. The id tests derive their fixtures from `PLEX_TRACK_ID_FLOOR` instead of transcribing them, which is not pedantry: the survey's own id table — the artefact meant to be the definitive reference — paired a namespaced id with the wrong rating key, and the transcribed test caught it on the first run. Design and adversarial review (6 BLOCKER / 10 MAJOR / 7 MINOR, all corrected): qbz-nix-docs/qt-frontend/2026-07-30-source-seam/. cc
58 lines
2.3 KiB
Rust
58 lines
2.3 KiB
Rust
//! Adapts the registry to `qbz_mixtape::ItemResolver`.
|
||
//!
|
||
//! `qbz-mixtape` is NOT modified, NOT absorbed, and stays a leaf of the graph:
|
||
//! this crate depends on it, never the reverse. `ItemResolver`,
|
||
//! `ProdItemResolver`, `resolve_collection_tracks`, `shuffle_items`,
|
||
//! `next_item_index` and every free resolver fn stay byte-identical, so the
|
||
//! `qbz` (Slint) crate keeps compiling and behaving exactly as today with zero
|
||
//! edits.
|
||
|
||
use qbz_models::mixtape::MixtapeCollectionItem;
|
||
use qbz_models::QueueTrack;
|
||
|
||
use crate::id::RawRef;
|
||
use crate::registry::SourceRegistry;
|
||
|
||
/// A `qbz_mixtape::ItemResolver` backed by the whole registry.
|
||
///
|
||
/// It replaces `ProdItemResolver::new(&client, resolve_local)` at the five
|
||
/// construction sites in `myqbz_play_qt.rs` (:148, :159, :193, :235, :533) and
|
||
/// deletes `resolve_local` (:110-115) — the function that IS bug 1's measured
|
||
/// 23–34 opens per collection.
|
||
///
|
||
/// **No lifetime parameter:** the registry is `'static`, and a
|
||
/// `RegistryResolver<'a>` would only re-import the borrow that stops
|
||
/// `ProdItemResolver` (which borrows a stack-local client clone) from being
|
||
/// moved into a spawned task.
|
||
///
|
||
/// **Behavioural note for review:** this resolver takes NO Qobuz client. A
|
||
/// Qobuz item in a collection therefore fails PER ITEM with
|
||
/// `NotConfigured { by: QOBUZ, why: "no client" }` — which
|
||
/// `resolve_collection_tracks` logs and skips (enqueue.rs:58-66) — while the
|
||
/// local and Plex items in the same collection resolve normally. Today the
|
||
/// *whole* resolve returns an empty vec before the resolver is even built
|
||
/// (myqbz_play_qt.rs:145, :156, :190, :232). That is survey IC-5, and it is the
|
||
/// direct upstream cause of bug 3's MyQBZ half.
|
||
pub struct RegistryResolver {
|
||
registry: &'static SourceRegistry,
|
||
}
|
||
|
||
impl RegistryResolver {
|
||
/// Wrap the process-wide registry (`crate::registry()`).
|
||
pub fn new(registry: &'static SourceRegistry) -> Self {
|
||
Self { registry }
|
||
}
|
||
}
|
||
|
||
#[async_trait::async_trait]
|
||
impl qbz_mixtape::ItemResolver for RegistryResolver {
|
||
async fn resolve(&self, item: &MixtapeCollectionItem) -> Result<Vec<QueueTrack>, String> {
|
||
let raw = RawRef::from_mixtape_item(item);
|
||
let media = self.registry.claim(&raw).map_err(|e| e.to_string())?;
|
||
self.registry
|
||
.tracks(&media)
|
||
.await
|
||
.map_err(|e| e.to_string())
|
||
}
|
||
}
|