From 6566b507de844db2dc27cc900e83f9bc9fe28c8a Mon Sep 17 00:00:00 2001 From: vicrodh <103399283+vicrodh@users.noreply.github.com> Date: Wed, 17 Jun 2026 00:44:47 -0600 Subject: [PATCH] feat(slint): stamp is-blacklisted on album/playlist/favorites/suggest rows; protect local+Plex; nav-only menu on blacklisted rows cc --- crates/qbz-slint/src/album.rs | 13 ++++ crates/qbz-slint/src/artist.rs | 3 + crates/qbz-slint/src/artist_blacklist.rs | 34 +++++++++ crates/qbz-slint/src/favorites.rs | 4 ++ crates/qbz-slint/src/label.rs | 2 + crates/qbz-slint/src/local_library.rs | 2 + crates/qbz-slint/src/local_playlist.rs | 9 +++ crates/qbz-slint/src/mix.rs | 7 ++ crates/qbz-slint/src/myqbz_detail.rs | 3 + crates/qbz-slint/src/playlist.rs | 8 +++ crates/qbz-slint/src/search.rs | 3 + .../ui/primitives/TrackContextMenu.slint | 71 ++++++++++++------- crates/qbz-slint/ui/primitives/TrackRow.slint | 32 +++++---- 13 files changed, 150 insertions(+), 41 deletions(-) diff --git a/crates/qbz-slint/src/album.rs b/crates/qbz-slint/src/album.rs index 71b98f8c1..f0dceaeb5 100644 --- a/crates/qbz-slint/src/album.rs +++ b/crates/qbz-slint/src/album.rs @@ -300,6 +300,9 @@ pub fn apply_album(window: &AppWindow, data: AlbumData) { // album link target is this album's own id (the album column is not // shown here, but album-id keeps the row model complete). let album_id: slint::SharedString = data.id.clone().into(); + // Album's primary artist id — the fallback blacklist key for rows whose + // own performer id is missing (Task 6: `track.artist_id ?? album.artist_id`). + let album_artist_id = data.artist_id.clone(); // Multi-disc grouping (Tauri PurchaseAlbumDetailView: groupByDisc + // isMultiDisc). The album is "multi-disc" when its tracks span more than // one distinct disc number; only then do we emit "Disc N" headers. The @@ -334,6 +337,15 @@ pub fn apply_album(window: &AppWindow, data: AlbumData) { 0 }; prev_disc = Some(track.disc); + // Blacklist key: the row's own performer id, falling back to the + // album's primary artist when the track carries none (Task 6). + let row_artist_id = if track.artist_id.is_empty() { + album_artist_id.as_str() + } else { + track.artist_id.as_str() + }; + let is_blacklisted = + crate::artist_blacklist::stamp_row("qobuz", &[row_artist_id]); TrackItem { id: track.id.clone().into(), number: track.number.into(), @@ -350,6 +362,7 @@ pub fn apply_album(window: &AppWindow, data: AlbumData) { is_favorite: crate::fav_cache::is_favorite(&track.id), artist_id: track.artist_id.into(), album_id: album_id.clone(), + is_blacklisted, removing: false, cache_status: if crate::offline_cache::is_cached(&track.id) { 3 } else { 0 }, cache_progress: 0.0, diff --git a/crates/qbz-slint/src/artist.rs b/crates/qbz-slint/src/artist.rs index cc99079cd..75425a670 100644 --- a/crates/qbz-slint/src/artist.rs +++ b/crates/qbz-slint/src/artist.rs @@ -494,6 +494,9 @@ pub fn apply_artist(window: &AppWindow, data: ArtistData) { .top_tracks .into_iter() .map(|track| TrackItem { + // Out of Task 6 row-stamping scope: ArtistView gets the T9 + // hidden-artist banner, not per-row greyout. Never stamped here. + is_blacklisted: false, id: track.id.clone().into(), number: track.number.into(), title: track.title.into(), diff --git a/crates/qbz-slint/src/artist_blacklist.rs b/crates/qbz-slint/src/artist_blacklist.rs index 4ad461878..2a9cecd57 100644 --- a/crates/qbz-slint/src/artist_blacklist.rs +++ b/crates/qbz-slint/src/artist_blacklist.rs @@ -91,6 +91,40 @@ pub fn is_blacklisted_id_str(artist_id: &str) -> bool { is_blacklisted(id) } +/// Stamp value for a `TrackItem.is-blacklisted` cell (Task 6). The single +/// rule every in-scope track controller (album / playlist / favorites / the +/// four Q-mixes) reuses so render and the Task 7 queue filters agree on what +/// "blacklisted" means per row: +/// +/// - **HARD local/Plex guard** — a non-Qobuz `source` is NEVER blacklisted +/// (Codex guardrail; local copies with a numeric Qobuz id must still stay +/// playable). `qobuz_download` rows render `source == "qobuz"`, so they are +/// treated as Qobuz here — that matches Tauri (VTL keys on `!isLocal`). +/// - Resolve the artist from the candidate string ids in order; the first +/// non-empty, numeric, blacklisted id wins (D-FEAT: performer OR composer; +/// album rows that lack a performer fall back to the album's primary artist). +/// - Missing / zero / non-numeric ids => fail-open (`false`). +/// +/// The enabled-flag gate and the no-session fail-open live in +/// [`is_blacklisted`], so this never blocks when the feature is off or no +/// session is bound. +/// +/// Live re-stamp contract (Step B): there is no change-notify here (the +/// fav_cache pattern). Every in-scope controller already calls this at LOAD +/// time, so navigating to a view always shows correct state. To refresh the +/// CURRENTLY-loaded lists after a blacklist mutation (Task 9 artist toggle / +/// Task 11 manager), the mutation site re-runs that controller's existing +/// reload / re-push path (which re-invokes `stamp_row` per row) — same as how +/// favorites re-push after a `fav_cache` change. There is intentionally no +/// global listener/observer. +pub fn stamp_row(source: &str, artist_ids: &[&str]) -> bool { + // Local / Plex / ephemeral rows are protected — never blacklisted. + if source != "qobuz" { + return false; + } + artist_ids.iter().any(|id| is_blacklisted_id_str(id)) +} + /// True when the blacklist feature is enabled. Default-enabled (`true`) when no /// session is bound. pub fn is_enabled() -> bool { diff --git a/crates/qbz-slint/src/favorites.rs b/crates/qbz-slint/src/favorites.rs index dba057ae7..75f7f1af0 100644 --- a/crates/qbz-slint/src/favorites.rs +++ b/crates/qbz-slint/src/favorites.rs @@ -464,6 +464,10 @@ pub fn apply_favorites(window: &AppWindow, data: FavData) { let rows: Vec = items .into_iter() .map(|t| TrackItem { + is_blacklisted: crate::artist_blacklist::stamp_row( + "qobuz", + &[t.artist_id.as_str()], + ), id: t.id.clone().into(), number: "".into(), title: t.title.into(), diff --git a/crates/qbz-slint/src/label.rs b/crates/qbz-slint/src/label.rs index 21d09b5ea..40c487d7a 100644 --- a/crates/qbz-slint/src/label.rs +++ b/crates/qbz-slint/src/label.rs @@ -756,6 +756,8 @@ fn truncate_words(text: &str, max: usize) -> String { fn top_track_to_item(t: &TopTrack) -> TrackItem { TrackItem { + // Label landing top-tracks are out of Task 6 row-stamping scope. + is_blacklisted: false, id: t.id.clone().into(), number: "".into(), title: t.title.clone().into(), diff --git a/crates/qbz-slint/src/local_library.rs b/crates/qbz-slint/src/local_library.rs index f4fa0fe1c..4488ead0f 100644 --- a/crates/qbz-slint/src/local_library.rs +++ b/crates/qbz-slint/src/local_library.rs @@ -755,6 +755,8 @@ fn map_local_track(t: qbz_library::LocalTrack) -> TrackItem { let (tier, quality_detail, _) = crate::quality::badge(&t.format.to_string(), t.bit_depth, Some(t.sample_rate)); TrackItem { + // Local Library rows are local assets — never blacklisted (protected). + is_blacklisted: false, id: t.id.to_string().into(), number: t.track_number.map(|n| n.to_string()).unwrap_or_default().into(), title: t.title.into(), diff --git a/crates/qbz-slint/src/local_playlist.rs b/crates/qbz-slint/src/local_playlist.rs index c14a7731b..61d81246b 100644 --- a/crates/qbz-slint/src/local_playlist.rs +++ b/crates/qbz-slint/src/local_playlist.rs @@ -860,6 +860,9 @@ fn row_item(item: &RowItem, queue: Option<&QueueTrack>) -> TrackItem { sample_rate, artwork_path, } => TrackItem { + // Offline cached copy — a local asset, never blacklisted (no + // artist id carried; protected by the local guard either way). + is_blacklisted: false, id: track_id.to_string().into(), number: "".into(), title: title.clone().into(), @@ -895,6 +898,8 @@ fn row_item(item: &RowItem, queue: Option<&QueueTrack>) -> TrackItem { Some(track.sample_rate), ); TrackItem { + // Local / Plex / offline rows are protected — never blacklisted. + is_blacklisted: false, // The queue id (library row id; the Qobuz id for offline // copies; the synthetic 2^40-namespaced id for Plex rows) // so visible-order playback resolves this row. @@ -936,6 +941,8 @@ fn row_item(item: &RowItem, queue: Option<&QueueTrack>) -> TrackItem { .and_then(|s| s.to_str()) .unwrap_or(path.as_str()); TrackItem { + // Bare local file — never blacklisted. + is_blacklisted: false, id: format!("file:{path}").into(), number: "".into(), title: name.into(), @@ -967,6 +974,8 @@ fn row_item(item: &RowItem, queue: Option<&QueueTrack>) -> TrackItem { // qobuz refs get an unparseable id so no drag/pick path can ever // re-type them as a catalog id. RowItem::Unresolved { kind, reference } => TrackItem { + // Unresolved/unavailable row — never blacklisted. + is_blacklisted: false, id: if *kind == "plex" { format!("plex:{reference}") } else { diff --git a/crates/qbz-slint/src/mix.rs b/crates/qbz-slint/src/mix.rs index 4a75261b0..8b8d78eb6 100644 --- a/crates/qbz-slint/src/mix.rs +++ b/crates/qbz-slint/src/mix.rs @@ -240,7 +240,14 @@ fn to_item(track: &Track) -> TrackItem { if let Some(v) = track.version.as_ref().filter(|v| !v.is_empty()) { title = format!("{title} ({v})"); } + // Blacklist key: the track's performer id (Qobuz mixes; Task 6). + let performer_id = track + .performer + .as_ref() + .map(|p| p.id.to_string()) + .unwrap_or_default(); TrackItem { + is_blacklisted: crate::artist_blacklist::stamp_row("qobuz", &[performer_id.as_str()]), id: track.id.to_string().into(), number: "".into(), title: title.into(), diff --git a/crates/qbz-slint/src/myqbz_detail.rs b/crates/qbz-slint/src/myqbz_detail.rs index 4fd5f8aa1..923e95d8c 100644 --- a/crates/qbz-slint/src/myqbz_detail.rs +++ b/crates/qbz-slint/src/myqbz_detail.rs @@ -686,6 +686,9 @@ fn track_to_item(track: &qbz_models::QueueTrack, resolver_index: usize) -> Track .unwrap_or_else(|| if track.is_local { "local".into() } else { "qobuz".into() }); TrackItem { + // MyQBZ detail is out of Task 6 row-stamping scope (mixed local/Qobuz + // entity; handled by its own epic). Never stamped here. + is_blacklisted: false, id: track.id.to_string().into(), number: (resolver_index + 1).to_string().into(), title: inline_track_title(track).into(), diff --git a/crates/qbz-slint/src/playlist.rs b/crates/qbz-slint/src/playlist.rs index 09c5b5b08..d20ae1ada 100644 --- a/crates/qbz-slint/src/playlist.rs +++ b/crates/qbz-slint/src/playlist.rs @@ -493,7 +493,15 @@ pub(crate) fn to_item(track: &Track) -> TrackItem { if let Some(v) = track.version.as_ref().filter(|v| !v.is_empty()) { title = format!("{title} ({v})"); } + // Blacklist key: the track's performer id (pure-Qobuz playlist rows; + // local / Plex rows go through local_playlist::row_item, never stamped). + let performer_id = track + .performer + .as_ref() + .map(|p| p.id.to_string()) + .unwrap_or_default(); TrackItem { + is_blacklisted: crate::artist_blacklist::stamp_row("qobuz", &[performer_id.as_str()]), id: track.id.to_string().into(), number: "".into(), title: title.into(), diff --git a/crates/qbz-slint/src/search.rs b/crates/qbz-slint/src/search.rs index b8d3fda9e..4b7e89029 100644 --- a/crates/qbz-slint/src/search.rs +++ b/crates/qbz-slint/src/search.rs @@ -368,6 +368,9 @@ fn track_item(row: TrackRowData) -> TrackItem { let is_favorite = crate::fav_cache::is_favorite(&row.id); let is_cached = crate::offline_cache::is_cached(&row.id); TrackItem { + // Combined search DROPS blacklisted rows at build time (T4 snapshot + // filter), so a row reaching here is never blacklisted (no greyout). + is_blacklisted: false, id: row.id.into(), number: "".into(), title: row.title.into(), diff --git a/crates/qbz-slint/ui/primitives/TrackContextMenu.slint b/crates/qbz-slint/ui/primitives/TrackContextMenu.slint index dd80a43a7..9fd2bd1ff 100644 --- a/crates/qbz-slint/ui/primitives/TrackContextMenu.slint +++ b/crates/qbz-slint/ui/primitives/TrackContextMenu.slint @@ -38,6 +38,20 @@ export component TrackContextMenu inherits PopupWindow { in property track-info-action: true; in property go-album-action: root.qobuz-actions; in property go-artist-action: root.qobuz-actions; + // Nav-only reduction (blacklisted/inert rows, Task 6 step C): hides every + // transient / mutating / destructive entry (play, play-next, queue, radio, + // favorite, mixtape, add/remove-playlist, share, offline) and keeps only + // navigation + info (Go to album / Go to artist / Track info). Mirrors + // Tauri keeping a reduced nav-only menu on a blacklisted row so the user + // can still reach the album/artist/track-info from the "..." menu — only + // playback/queue is denied. Default off, so every other surface is + // unchanged. + in property nav-only: false; + // Track Info shows on a nav-only row even when it's not a Qobuz-block row, + // so a blacklisted row keeps the info entry; otherwise it rides the Qobuz + // block as before. + property show-track-info: + root.track-info-action && (root.nav-only || root.qobuz-actions); // The row's offline-cache status (TrackItem.cache-status): when cached // (3) the single "Make available offline" entry swaps for the // Refresh / Remove pair — Tauri's ready-state submenu, rendered flat @@ -46,64 +60,69 @@ export component TrackContextMenu inherits PopupWindow { callback media-action(string, string, string); width: 224px; - // 3 transient + optional favorite/mixtape/add-to-playlist/remove + - // optional go-to pair + the Qobuz block (3 fixed + 1-or-2 offline + // Nav-only (blacklisted): only Go to album / Go to artist / Track info. + // Otherwise: 3 transient + optional favorite/mixtape/add-to-playlist/remove + // + optional go-to pair + the Qobuz block (3 fixed + 1-or-2 offline // entries + optional track info). - height: (3 - + (root.favorite-action ? 1 : 0) - + (root.mixtape-action ? 1 : 0) - + (root.playlist-action ? 1 : 0) - + (root.remove-from-playlist-action ? 1 : 0) - + (root.go-album-action ? 1 : 0) - + (root.go-artist-action ? 1 : 0) - + (root.qobuz-actions - ? 3 + (root.cache-status == 3 ? 2 : 1) + (root.track-info-action ? 1 : 0) - : 0)) * 30px; + height: (root.nav-only + ? ((root.go-album-action ? 1 : 0) + + (root.go-artist-action ? 1 : 0) + + (root.show-track-info ? 1 : 0)) + : (3 + + (root.favorite-action ? 1 : 0) + + (root.mixtape-action ? 1 : 0) + + (root.playlist-action ? 1 : 0) + + (root.remove-from-playlist-action ? 1 : 0) + + (root.go-album-action ? 1 : 0) + + (root.go-artist-action ? 1 : 0) + + (root.qobuz-actions + ? 3 + (root.cache-status == 3 ? 2 : 1) + (root.track-info-action ? 1 : 0) + : 0))) * 30px; ContextMenu { - ContextMenuItem { + if !root.nav-only: ContextMenuItem { icon: @image-url("../assets/icons/play.svg"); label: @tr("Play now"); clicked => { root.media-action("track", root.track-id, "play"); } } - ContextMenuItem { + if !root.nav-only: ContextMenuItem { icon: @image-url("../assets/icons/list-plus.svg"); label: @tr("Play next"); clicked => { root.media-action("track", root.track-id, "play-next"); } } - ContextMenuItem { + if !root.nav-only: ContextMenuItem { icon: @image-url("../assets/icons/list-end.svg"); label: @tr("Add to queue"); clicked => { root.media-action("track", root.track-id, "queue"); } } - if root.qobuz-actions: ContextMenuItem { + if root.qobuz-actions && !root.nav-only: ContextMenuItem { icon: @image-url("../assets/icons/radio.svg"); label: @tr("Create radio"); clicked => { root.media-action("track", root.track-id, "create-radio"); } } - if root.favorite-action: ContextMenuItem { + if root.favorite-action && !root.nav-only: ContextMenuItem { icon: @image-url("../assets/icons/heart.svg"); label: @tr("Add to library"); clicked => { root.media-action("track", root.track-id, "favorite"); } } - if root.mixtape-action: ContextMenuItem { + if root.mixtape-action && !root.nav-only: ContextMenuItem { icon: @image-url("../assets/icons/cassette-tape.svg"); label: @tr("Add to mixtape"); clicked => { root.media-action("track", root.track-id, "add-to-mixtape"); } } - if root.playlist-action: ContextMenuItem { + if root.playlist-action && !root.nav-only: ContextMenuItem { icon: @image-url("../assets/icons/list-music.svg"); label: @tr("Add to playlist"); clicked => { @@ -112,7 +131,7 @@ export component TrackContextMenu inherits PopupWindow { } // Remove from playlist (danger) — playlist detail only, after Add // to playlist (Tauri group order, spec §1.3 #8). - if root.remove-from-playlist-action: ContextMenuItem { + if root.remove-from-playlist-action && !root.nav-only: ContextMenuItem { icon: @image-url("../assets/icons/trash-2.svg"); label: @tr("Remove from playlist"); danger: true; @@ -120,14 +139,14 @@ export component TrackContextMenu inherits PopupWindow { root.media-action("track", root.track-id, "remove-from-playlist"); } } - if root.qobuz-actions: ContextMenuItem { + if root.qobuz-actions && !root.nav-only: ContextMenuItem { icon: @image-url("../assets/icons/link.svg"); label: @tr("Share Qobuz link"); clicked => { root.media-action("track", root.track-id, "share-qobuz"); } } - if root.qobuz-actions: ContextMenuItem { + if root.qobuz-actions && !root.nav-only: ContextMenuItem { icon: @image-url("../assets/icons/link.svg"); label: @tr("Share Song.link"); clicked => { @@ -138,21 +157,21 @@ export component TrackContextMenu inherits PopupWindow { // submenu, flat per spec §3.5): not cached -> Make available // offline; cached -> Refresh + Remove (icons 1:1 with Tauri's // RefreshCw / Trash2). - if root.qobuz-actions && root.cache-status != 3: ContextMenuItem { + if root.qobuz-actions && !root.nav-only && root.cache-status != 3: ContextMenuItem { icon: @image-url("../assets/icons/cloud-download.svg"); label: @tr("Make available offline"); clicked => { root.media-action("track", root.track-id, "download"); } } - if root.qobuz-actions && root.cache-status == 3: ContextMenuItem { + if root.qobuz-actions && !root.nav-only && root.cache-status == 3: ContextMenuItem { icon: @image-url("../assets/icons/refresh-cw.svg"); label: @tr("Refresh offline copy"); clicked => { root.media-action("track", root.track-id, "recache"); } } - if root.qobuz-actions && root.cache-status == 3: ContextMenuItem { + if root.qobuz-actions && !root.nav-only && root.cache-status == 3: ContextMenuItem { icon: @image-url("../assets/icons/trash-2.svg"); label: @tr("Remove offline copy"); danger: true; @@ -174,7 +193,7 @@ export component TrackContextMenu inherits PopupWindow { root.media-action("track", root.track-id, "go-to-artist"); } } - if root.qobuz-actions && root.track-info-action: ContextMenuItem { + if root.show-track-info: ContextMenuItem { icon: @image-url("../assets/icons/info.svg"); label: @tr("Track info"); clicked => { diff --git a/crates/qbz-slint/ui/primitives/TrackRow.slint b/crates/qbz-slint/ui/primitives/TrackRow.slint index be6996620..86f1bdef3 100644 --- a/crates/qbz-slint/ui/primitives/TrackRow.slint +++ b/crates/qbz-slint/ui/primitives/TrackRow.slint @@ -147,11 +147,14 @@ export component TrackRow inherits Rectangle { // Right-click opens the same context menu at the pointer (Tauri's // contextmenu mode, spec §3.5). Suppressed in multi-select mode // (Tauri parity: row right-click toggles nothing there) and on - // menu-less rows (ephemeral). x clamps to the row so the menu - // never overflows past the "..." gutter; vertical overflow at the - // window bottom matches the existing "..." anchor behavior. + // menu-less rows (ephemeral). A blacklisted (inert) row STILL + // opens it — reduced to nav-only (Go to album/artist, Track info) + // via track-menu.nav-only below, so the user keeps navigation. + // x clamps to the row so the menu never overflows past the "..." + // gutter; vertical overflow at the window bottom matches the + // existing "..." anchor behavior. if (e.kind == PointerEventKind.down && e.button == PointerEventButton.right - && root.show-menu && !root.multi-select-mode && !root.row-inert) { + && root.show-menu && !root.multi-select-mode) { root.menu-at-pointer = true; root.menu-click-x = ta.mouse-x; root.menu-click-y = ta.mouse-y; @@ -661,11 +664,13 @@ export component TrackRow inherits Rectangle { } } - // Context menu. Suppressed on a blacklisted (inert) row — Tauri's - // shared TrackRow short-circuits contextmenu and renders no block - // menu item; the per-list wrappers (VTL / Album / Playlist) do the - // nav-only reduction, not this shared primitive. - if root.show-menu && !root.row-inert: VerticalLayout { + // Context menu trigger. KEPT on a blacklisted (inert) row — the menu + // it opens is reduced to nav-only (Go to album/artist, Track info) via + // track-menu.nav-only, so the row still offers navigation while every + // play/queue/mutating entry is gone. Mirrors Tauri keeping a reduced + // nav-only menu on a blacklisted row (the T5 deviation that hid the + // whole menu is reverted here). + if root.show-menu: VerticalLayout { alignment: center; Rectangle { width: 32px; @@ -692,12 +697,6 @@ export component TrackRow inherits Rectangle { } } } - // Menu-slot placeholder on a blacklisted row whose surface has the - // "..." menu — keeps the dimmed row's trailing edge aligned with - // its interactive siblings. - if root.show-menu && root.row-inert: Rectangle { - width: 32px; - } } // True for rows whose source is Qobuz-backed (Qobuz surfaces + offline @@ -714,6 +713,9 @@ export component TrackRow inherits Rectangle { : parent.width - self.width - 12px; y: root.menu-at-pointer ? root.menu-click-y : 48px; track-id: root.track.id; + // Blacklisted (inert) rows get the nav-only reduction: only Go to + // album / Go to artist / Track info, no play/queue/mutating entries. + nav-only: root.row-inert; // Per-source menu logic: the Qobuz block (radio, share, offline, // go-to, track-info) only for Qobuz/offline rows, and never on // library surfaces (force-local-menu — its arms are dead on library