From 49a78c2ca0719b494903d4d675a5f29e0e688e3b Mon Sep 17 00:00:00 2001 From: vicrodh <103399283+vicrodh@users.noreply.github.com> Date: Fri, 26 Jun 2026 21:04:23 -0600 Subject: [PATCH] feat(reco): per-user artist-vector store lifecycle (T7) Open the per-user ArtistVectorStore (/cache/artist_vectors.db) and install it on the core (core.set_artist_vectors) at the three session-activation sites (login, restore, offline entry), next to the sub-plan-1 reco init; drop it on logout (core.clear_artist_vectors). The store is core-owned (no bin-side static), so the suggestions engine reads/writes it through QbzCore. Adds qbz-reco as a bin dependency. cc --- crates/Cargo.lock | 1 + crates/qbz/Cargo.toml | 1 + crates/qbz/src/auth.rs | 11 +++++++++++ crates/qbz/src/main.rs | 4 ++++ 4 files changed, 17 insertions(+) diff --git a/crates/Cargo.lock b/crates/Cargo.lock index 9e0e0d922..1efa4de08 100644 --- a/crates/Cargo.lock +++ b/crates/Cargo.lock @@ -5433,6 +5433,7 @@ dependencies = [ "qbz-playlist-import", "qbz-plex", "qbz-qobuz", + "qbz-reco", "qbz-slint-common", "qbz-text-utils", "qbz-theme", diff --git a/crates/qbz/Cargo.toml b/crates/qbz/Cargo.toml index 5e6a6cf14..ef378c36f 100644 --- a/crates/qbz/Cargo.toml +++ b/crates/qbz/Cargo.toml @@ -69,6 +69,7 @@ qbz-theme = { path = "../qbz-theme" } qbz-media-controls = { path = "../qbz-media-controls" } qbz-audio = { path = "../qbz-audio" } qbz-core = { path = "../qbz-core" } +qbz-reco = { path = "../qbz-reco" } qbz-player = { path = "../qbz-player" } qbz-cast = { path = "../qbz-cast" } qconnect-app = { path = "../qconnect-app" } diff --git a/crates/qbz/src/auth.rs b/crates/qbz/src/auth.rs index 94c7381a8..12538bf66 100644 --- a/crates/qbz/src/auth.rs +++ b/crates/qbz/src/auth.rs @@ -114,6 +114,11 @@ where // after init (off-thread) so the seeds reflect this session's events. crate::reco::init_for_user(&dir); crate::reco::train_async(); + // Playlist Suggested Songs: open the per-user artist-vector store on + // the core (the suggestions engine reads/writes it). + if let Ok(store) = qbz_reco::ArtistVectorStore::open_at(&dir) { + runtime.core().set_artist_vectors(store).await; + } crate::discover_prefs::init_for_user(&dir); crate::artist_blacklist::init_for_user(&dir); // Intelligent Search (cache + ranking), seeded from the persisted pref. @@ -235,6 +240,11 @@ where // session's events. crate::reco::init_for_user(&dir); crate::reco::train_async(); + // Playlist Suggested Songs: open the per-user artist-vector + // store on the core (the suggestions engine reads/writes it). + if let Ok(store) = qbz_reco::ArtistVectorStore::open_at(&dir) { + runtime.core().set_artist_vectors(store).await; + } crate::discover_prefs::init_for_user(&dir); crate::artist_blacklist::init_for_user(&dir); // Intelligent Search (cache + ranking), seeded from the pref. @@ -289,6 +299,7 @@ where crate::offline_mode::teardown(); crate::fav_cache::teardown(); crate::reco::teardown(); + runtime.core().clear_artist_vectors().await; crate::discover_prefs::teardown(); crate::artist_blacklist::teardown(); crate::search_service::teardown(); diff --git a/crates/qbz/src/main.rs b/crates/qbz/src/main.rs index 087b2a78b..063c077fd 100644 --- a/crates/qbz/src/main.rs +++ b/crates/qbz/src/main.rs @@ -519,6 +519,10 @@ async fn enter_shell_offline( crate::fav_cache::init_for_user(&dir); // Recommendation event store (shared events.db with Tauri). crate::reco::init_for_user(&dir); + // Playlist Suggested Songs: open the per-user artist-vector store. + if let Ok(store) = qbz_reco::ArtistVectorStore::open_at(&dir) { + runtime.core().set_artist_vectors(store).await; + } crate::discover_prefs::init_for_user(&dir); // D-FIX-a: bind the blacklist offline too — Tauri never initialized it // in offline mode, so blacklisted artists leaked into offline surfaces.