feat(slint): immersive suggestions panel (split) with live artist queries

Add ImmersiveSuggestionsPanel for the split-right slot (split-panel 2):
a cards row (up to 2 artist-playlist book-collage cards + a Song-Radio
diamond-collage card) and a recommended-tracks list. New suggestions.rs
controller assembles everything in Rust (ADR-006): artist tracks_appears_on
with an artist-tracks fallback under 5, dedupe by title, drop the current
track, shuffle, take 10; cards from the first two playlists plus a track
radio. New core method QbzCore::create_smart_track_radio mirrors the smart
artist radio (spawn_blocking + block_on, seed hoisted to index 0). Does NOT
use reco_store (live Qobuz queries only). Collage tilt deferred (flat for
now); blacklist drop happens downstream in play_tracks.

cc
This commit is contained in:
vicrodh committed 2026-06-19 06:43:00 -06:00
1 parent 816da9cd47
commit db41e78383
8 files changed
+1296 -2

No files matched your search

+77
View File
@@ -1496,6 +1496,83 @@ impl<A: FrontendAdapter + Send + Sync + 'static> QbzCore<A> {
Ok(tracks)
}
/// Smart Song Radio seeded by a single track via the local `qbz-radio`
/// pool builder — the immersive Suggestions panel's "Song Radio" card.
///
/// Mirrors `create_smart_artist_radio` (same `!Send` RadioDb/RadioEngine
/// orchestration via `spawn_blocking` + `Handle::current().block_on`) but
/// seeds with `create_track_radio(track_id, artist_id)` and HOISTS the
/// seed track to index 0 (mirroring the Tauri `v2_create_track_radio`
/// hoist) so the radio always starts on the song the user was playing.
/// Pulls up to 60 ids, hoists the seed, takes 50, resolves to full tracks.
///
/// Frontend-agnostic (no `tauri::State`, no blacklist filter — the
/// blacklist lives in the UI/integration layer; callers that need it drop
/// blacklisted rows after this returns). `seed_track_name` is accepted for
/// call-site parity with the Tauri command (the local builder seeds by id,
/// so the name is not needed here) and currently unused.
pub async fn create_smart_track_radio(
&self,
track_id: u64,
artist_id: u64,
_seed_track_name: String,
) -> Result<Vec<Track>, CoreError> {
let client = {
let guard = self.client.read().await;
guard.as_ref().ok_or(CoreError::NotInitialized)?.clone()
};
let build_client = client.clone();
let session_id = tokio::task::spawn_blocking(move || -> Result<String, String> {
let db = qbz_radio::RadioDb::open_default()?;
let builder = qbz_radio::RadioPoolBuilder::new(
&db,
&build_client,
qbz_radio::BuildRadioOptions::default(),
);
let session = tokio::runtime::Handle::current()
.block_on(builder.create_track_radio(track_id, artist_id))?;
Ok(session.id)
})
.await
.map_err(|e| CoreError::Internal(format!("song radio build task: {e}")))?
.map_err(CoreError::Internal)?;
let seed_track_id = track_id;
let ids = tokio::task::spawn_blocking(move || -> Result<Vec<u64>, String> {
let db = qbz_radio::RadioDb::open_default()?;
let engine = qbz_radio::RadioEngine::new(db);
let mut pulled: Vec<(u64, String)> = Vec::new();
for _ in 0..60 {
match engine.next_track(&session_id) {
Ok(track) => pulled.push((track.track_id, track.source.clone())),
Err(_) => break,
}
}
// Hoist the seed track to the front (mirror of link_resolver.rs).
if let Some(seed_idx) = pulled
.iter()
.position(|(id, source)| *id == seed_track_id && source == "seed_track")
{
if seed_idx != 0 {
pulled.swap(0, seed_idx);
}
}
Ok(pulled.into_iter().take(50).map(|(id, _)| id).collect())
})
.await
.map_err(|e| CoreError::Internal(format!("song radio pull task: {e}")))?
.map_err(CoreError::Internal)?;
let mut tracks = Vec::new();
for id in ids {
if let Ok(track) = client.get_track(id).await {
tracks.push(track);
}
}
Ok(tracks)
}
/// Get artist with albums (for album pagination)
pub async fn get_artist_with_albums(
&self,
+28
View File
@@ -173,6 +173,13 @@ pub enum ArtworkTarget {
/// One hero-mosaic cover slot (0-8) of the My QBZ collection-detail view
/// (`MyQbzDetailState.cover{N}`).
MyQbzDetailCover { slot: usize },
/// One collage cover slot (0-3) of an immersive Suggestions card
/// (`SuggestionsState.cards[card_idx].cover{slot}`). Playlist cards use
/// up to 3 slots (book collage), the radio card up to 4 (diamond collage).
SuggestionCardCover { card_idx: usize, slot: usize },
/// A row thumbnail in the immersive Suggestions recommended-tracks list
/// (`SuggestionsState.tracks[idx]`).
SuggestionTrackCover { idx: usize },
}
impl ArtworkTarget {
@@ -186,6 +193,7 @@ impl ArtworkTarget {
| ArtworkTarget::FavoriteTrack { .. }
| ArtworkTarget::MixTrack { .. }
| ArtworkTarget::PlaylistTrack { .. }
| ArtworkTarget::SuggestionTrackCover { .. }
| ArtworkTarget::LocalArtistRowImage { .. } => 96,
// Sidebar micro-collage tiles render at ~10-20px; decode tiny.
ArtworkTarget::SidebarPlaylistCover { .. } => 48,
@@ -1141,5 +1149,25 @@ fn apply_artwork(
ArtworkTarget::MyQbzDetailCover { slot } => {
crate::myqbz_detail::set_hero_cover(window, slot, image);
}
ArtworkTarget::SuggestionCardCover { card_idx, slot } => {
let model = window.global::<crate::SuggestionsState>().get_cards();
if let Some(mut item) = model.row_data(card_idx) {
match slot {
0 => item.cover0 = image,
1 => item.cover1 = image,
2 => item.cover2 = image,
3 => item.cover3 = image,
_ => return,
}
model.set_row_data(card_idx, item);
}
}
ArtworkTarget::SuggestionTrackCover { idx } => {
let model = window.global::<crate::SuggestionsState>().get_tracks();
if let Some(mut item) = model.row_data(idx) {
item.artwork = image;
model.set_row_data(idx, item);
}
}
}
}
+201
View File
@@ -101,6 +101,7 @@ mod shader_underlay;
mod settings;
mod share;
mod sidebar;
mod suggestions;
mod toast;
mod tray;
mod tray_settings;
@@ -1675,6 +1676,43 @@ fn navigate_award(
});
}
/// Load the immersive Suggestions split panel for the current track. Reads the
/// artist-id + track-id + title off NowPlayingState, resets the panel, and
/// spawns the live artist load (mirror of navigate_award). An empty artist-id
/// or track-id resets to the no-track empty state. Refreshed on track change
/// while the panel is open via the mount's `changed live-track-id` -> the
/// SuggestionsActions.load callback (which calls this).
fn navigate_suggestions(
runtime: Arc<AppRuntime<SlintAdapter>>,
weak: slint::Weak<AppWindow>,
handle: &tokio::runtime::Handle,
image_cache: artwork::ImageCache,
artist_id: String,
track_id: String,
track_name: String,
) {
// No track / no artist -> reset to the empty state and stop. apply with an
// empty payload clears cards/tracks and leaves artist-id "" (the empty
// branch in the panel).
let (Ok(aid), Ok(tid)) = (artist_id.parse::<u64>(), track_id.parse::<u64>()) else {
let _ = weak.upgrade_in_event_loop(|w| {
suggestions::apply_suggestions(&w, suggestions::empty_payload());
});
return;
};
handle.spawn(async move {
let _ = weak.upgrade_in_event_loop(|w| {
suggestions::reset_suggestions(&w);
});
let payload = suggestions::load_suggestions(&runtime, aid, tid, track_name).await;
let jobs = suggestions::suggestions_artwork_jobs(&payload);
let _ = weak.upgrade_in_event_loop(move |w| {
suggestions::apply_suggestions(&w, payload);
});
artwork::spawn_loads(jobs, weak.clone(), image_cache.clone());
});
}
/// Open the full AwardAlbumsView listing for `award_id` (paginated grid +
/// client-side search). No hero — the kicker uses the passed name (1:1 Tauri).
fn navigate_award_albums(
@@ -8308,6 +8346,169 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
});
}
// Immersive Suggestions panel actions (Checkpoint D — split-panel == 2).
{
// load(track-id) — entry + now-playing-change refresh. Reads the
// artist-id + title off NowPlayingState (the panel only has the track
// id) and kicks the live artist load (mirror of navigate_award).
let runtime = app_runtime.clone();
let weak = window.as_weak();
let handle = tokio_rt.handle().clone();
let image_cache = image_cache.clone();
window
.global::<SuggestionsActions>()
.on_load(move |track_id| {
let Some(w) = weak.upgrade() else {
return;
};
let np = w.global::<NowPlayingState>();
let artist_id = np.get_artist_id().to_string();
let track_id = track_id.to_string();
let track_name = np.get_title().to_string();
// Dedup: skip a reload when the panel already shows this artist
// for this seed track (the changed-watcher can refire on
// unrelated NowPlayingState churn).
let ss = w.global::<SuggestionsState>();
if ss.get_artist_id().as_str() == artist_id
&& ss.get_seed_track_id().as_str() == track_id
&& !track_id.is_empty()
{
return;
}
navigate_suggestions(
runtime.clone(),
weak.clone(),
&handle,
image_cache.clone(),
artist_id,
track_id,
track_name,
);
});
}
{
// play / queue / play-next a curated artist playlist by id — reuse the
// existing playback seams (same paths the playlist cards use).
let runtime = app_runtime.clone();
let weak = window.as_weak();
let handle = tokio_rt.handle().clone();
window
.global::<SuggestionsActions>()
.on_play_playlist(move |playlist_id| {
let id = playlist_id.to_string();
if id.is_empty() {
return;
}
playback::play_playlist(runtime.clone(), weak.clone(), handle.clone(), id);
});
}
{
let runtime = app_runtime.clone();
let weak = window.as_weak();
let handle = tokio_rt.handle().clone();
window
.global::<SuggestionsActions>()
.on_queue_playlist(move |playlist_id| {
let id = playlist_id.to_string();
if id.is_empty() {
return;
}
playback::enqueue_playlist(
runtime.clone(),
weak.clone(),
handle.clone(),
id,
false,
);
});
}
{
let runtime = app_runtime.clone();
let weak = window.as_weak();
let handle = tokio_rt.handle().clone();
window
.global::<SuggestionsActions>()
.on_play_next_playlist(move |playlist_id| {
let id = playlist_id.to_string();
if id.is_empty() {
return;
}
playback::enqueue_playlist(
runtime.clone(),
weak.clone(),
handle.clone(),
id,
true,
);
});
}
{
// start-radio — build the Song Radio off the seed track via core, then
// start it (set_queue + play) through the shared play_tracks seam. The
// radio card spinner is flipped on optimistically and cleared on apply.
let runtime = app_runtime.clone();
let weak = window.as_weak();
let handle = tokio_rt.handle().clone();
window
.global::<SuggestionsActions>()
.on_start_radio(move |track_id, track_name, artist_id| {
let (Ok(tid), Ok(aid)) =
(track_id.parse::<u64>(), artist_id.parse::<u64>())
else {
return;
};
let track_name = track_name.to_string();
suggestions::set_radio_loading(&weak, true);
let runtime = runtime.clone();
let weak = weak.clone();
let handle2 = handle.clone();
handle.spawn(async move {
let result = runtime
.core()
.create_smart_track_radio(tid, aid, track_name)
.await;
suggestions::set_radio_loading(&weak, false);
match result {
Ok(tracks) if !tracks.is_empty() => {
playback::play_tracks(runtime, weak, handle2, tracks, 0);
}
Ok(_) => {
log::warn!("[qbz-slint] song radio returned no tracks");
}
Err(e) => {
log::error!("[qbz-slint] song radio failed: {e}");
}
}
});
});
}
{
// play-track — play a single recommended track by id NOW.
let runtime = app_runtime.clone();
let weak = window.as_weak();
let handle = tokio_rt.handle().clone();
window
.global::<SuggestionsActions>()
.on_play_track(move |track_id| {
let Ok(tid) = track_id.parse::<u64>() else {
return;
};
let runtime = runtime.clone();
let weak = weak.clone();
let handle2 = handle.clone();
handle.spawn(async move {
match runtime.core().get_track(tid).await {
Ok(track) => {
playback::play_tracks(runtime, weak, handle2, vec![track], 0);
}
Err(e) => {
log::error!("[qbz-slint] suggestions play-track {tid} failed: {e}");
}
}
});
});
}
// Artist Blacklist Manager actions (Task 11). Mutations are synchronous
// (in-memory set + single SQLite ops via the artist_blacklist wrapper), so
// no tokio handle is needed; each callback runs on the event-loop thread.
+419
View File
@@ -0,0 +1,419 @@
//! Immersive Suggestions panel controller (split-only, split-panel == 2).
//!
//! Ports Tauri's `SuggestionsPanel.svelte` 1:1, with all assembly logic in
//! Rust (ADR-006): live artist queries only (NEVER `reco_store` — that powers
//! the home page; see data-panels.md §6). Two data products:
//!
//! * RECOMMENDED TRACKS — `artist.tracks_appears_on`, falling back to
//! `get_artist_tracks(limit 30)` when sparse (<5), deduped by exact
//! lowercase title, the current track filtered out, shuffled, take 10.
//! * CARDS — the first 2 curated `artist.playlists` (each a book-collage of
//! up to 3 distinct album covers, fetched via `get_playlist`) + ONE seed
//! "Song Radio" card (diamond-collage of up to 4 rec-track covers).
//!
//! The shuffle is a deterministic splitmix64 seeded off the artist+track ids
//! (matches qbz-radio's RNG family; avoids pulling `rand` just for this).
use std::collections::HashSet;
use std::sync::Arc;
use qbz_app::shell::AppRuntime;
use qbz_core::FrontendAdapter;
use slint::{ComponentHandle, Model, ModelRc, VecModel};
use crate::artwork::{ArtworkJob, ArtworkTarget};
use crate::{AppWindow, SuggestionCard, SuggestionsState, TrackItem};
/// Recommended-track target count (Tauri `slice(0, 10)`).
const REC_LIMIT: usize = 10;
/// Sparse threshold below which the artist-tracks fallback runs (Tauri `< 5`).
const SPARSE_THRESHOLD: usize = 5;
/// Artist-tracks fallback page size (Tauri `limit: 30`).
const FALLBACK_LIMIT: u32 = 30;
/// Max curated playlist cards (Tauri `slice(0, 2)`).
const MAX_PLAYLIST_CARDS: usize = 2;
/// Book-collage cover count per playlist card (Tauri 3).
const BOOK_COVERS: usize = 3;
/// Diamond-collage cover count for the radio card (Tauri max 4).
const RADIO_COVERS: usize = 4;
/// A resolved playlist card (book collage of up to 3 distinct album covers).
pub(crate) struct PlaylistCard {
id: String,
name: String,
track_count: u32,
/// Up to 3 distinct album-cover URLs for the book collage.
cover_urls: Vec<String>,
}
/// The fully-assembled suggestions for one (artist, track) pair.
pub struct SuggestionsPayload {
pub artist_id: String,
pub seed_track_id: String,
pub seed_track_name: String,
pub seed_artist_id: String,
pub playlist_cards: Vec<PlaylistCard>,
pub rec_tracks: Vec<qbz_models::Track>,
/// Up to 4 distinct rec-track album covers for the radio diamond collage.
pub radio_cover_urls: Vec<String>,
pub error: bool,
}
/// An empty payload (no cards, no tracks, no error) — the "no track selected"
/// reset state applied when the immersive panel opens with no current track.
pub fn empty_payload() -> SuggestionsPayload {
SuggestionsPayload {
artist_id: String::new(),
seed_track_id: String::new(),
seed_track_name: String::new(),
seed_artist_id: String::new(),
playlist_cards: Vec::new(),
rec_tracks: Vec::new(),
radio_cover_urls: Vec::new(),
error: false,
}
}
/// Deterministic splitmix64 step (qbz-radio's RNG family). Used for an
/// in-place Fisher-Yates shuffle so the rec list is varied but reproducible
/// per (artist, track) — no `rand` dependency pulled just for this.
fn splitmix64(state: &mut u64) -> u64 {
*state = state.wrapping_add(0x9E3779B97F4A7C15);
let mut z = *state;
z = (z ^ (z >> 30)).wrapping_mul(0xBF58476D1CE4E5B9);
z = (z ^ (z >> 27)).wrapping_mul(0x94D049BB133111EB);
z ^ (z >> 31)
}
/// Fisher-Yates shuffle seeded off the (artist, track) ids.
fn shuffle_tracks(tracks: &mut [qbz_models::Track], seed: u64) {
let mut state = seed ^ 0xD1B54A32D192ED03;
for i in (1..tracks.len()).rev() {
let j = (splitmix64(&mut state) % (i as u64 + 1)) as usize;
tracks.swap(i, j);
}
}
/// Best collage cover URL for a track's album (large → best variant).
fn track_album_cover(track: &qbz_models::Track) -> Option<String> {
track
.album
.as_ref()
.and_then(|a| a.image.best().cloned())
.filter(|s| !s.is_empty())
}
/// Album id of a track (for distinct-cover dedupe in the book collage).
fn track_album_id(track: &qbz_models::Track) -> Option<String> {
track
.album
.as_ref()
.map(|a| a.id.clone())
.filter(|s| !s.is_empty())
}
/// Build the suggestions payload for `artist_id` + `current_track_id`. All
/// queries are live Qobuz artist calls (NEVER reco_store). On the top-level
/// artist-detail failure, returns an error payload (drives the panel's error
/// branch); individual playlist-cover fetch failures are tolerated.
pub async fn load_suggestions<A>(
runtime: &Arc<AppRuntime<A>>,
artist_id: u64,
current_track_id: u64,
seed_track_name: String,
) -> SuggestionsPayload
where
A: FrontendAdapter + Send + Sync + 'static,
{
let artist = match runtime.core().get_artist_detail(artist_id, None, None).await {
Ok(a) => a,
Err(e) => {
log::error!("[qbz-slint] suggestions get_artist_detail({artist_id}) failed: {e}");
return SuggestionsPayload {
artist_id: artist_id.to_string(),
seed_track_id: current_track_id.to_string(),
seed_track_name,
seed_artist_id: artist_id.to_string(),
playlist_cards: Vec::new(),
rec_tracks: Vec::new(),
radio_cover_urls: Vec::new(),
error: true,
};
}
};
// ---- Recommended tracks --------------------------------------------
// Base = tracks_appears_on (current track filtered, deduped by title).
let mut rec: Vec<qbz_models::Track> = Vec::new();
let mut seen_titles: HashSet<String> = HashSet::new();
if let Some(container) = artist.tracks_appears_on.as_ref() {
for track in &container.items {
if track.id == current_track_id {
continue;
}
let key = track.title.to_lowercase().trim().to_string();
if key.is_empty() || !seen_titles.insert(key) {
continue;
}
rec.push(track.clone());
}
}
// Sparse fallback: merge artist popular tracks (dedupe by title + id).
if rec.len() < SPARSE_THRESHOLD {
match runtime
.core()
.get_artist_tracks(artist_id, FALLBACK_LIMIT, 0)
.await
{
Ok(container) => {
let existing_ids: HashSet<u64> = rec.iter().map(|t| t.id).collect();
for track in container.items {
if track.id == current_track_id || existing_ids.contains(&track.id) {
continue;
}
let key = track.title.to_lowercase().trim().to_string();
if key.is_empty() || !seen_titles.insert(key) {
continue;
}
rec.push(track);
}
}
Err(e) => log::warn!("[qbz-slint] suggestions artist-tracks fallback failed: {e}"),
}
}
// Shuffle (deterministic per artist+track), take 10.
let seed = (artist_id << 1) ^ current_track_id.wrapping_add(1);
shuffle_tracks(&mut rec, seed);
rec.truncate(REC_LIMIT);
// Radio diamond collage: up to 4 distinct rec-track album covers.
let mut radio_cover_urls: Vec<String> = Vec::new();
for track in &rec {
if let Some(url) = track_album_cover(track) {
if !radio_cover_urls.contains(&url) {
radio_cover_urls.push(url);
if radio_cover_urls.len() >= RADIO_COVERS {
break;
}
}
}
}
// ---- Curated playlist cards (first 2) ------------------------------
let mut playlist_cards: Vec<PlaylistCard> = Vec::new();
if let Some(playlists) = artist.playlists.as_ref() {
for playlist in playlists.iter().take(MAX_PLAYLIST_CARDS) {
// Fetch the full playlist to harvest up to 3 distinct album covers.
let mut cover_urls: Vec<String> = Vec::new();
match runtime.core().get_playlist(playlist.id).await {
Ok(full) => {
if let Some(container) = full.tracks.as_ref() {
let mut seen_albums: HashSet<String> = HashSet::new();
for track in &container.items {
let (Some(url), Some(album_id)) =
(track_album_cover(track), track_album_id(track))
else {
continue;
};
if seen_albums.insert(album_id) {
cover_urls.push(url);
if cover_urls.len() >= BOOK_COVERS {
break;
}
}
}
}
}
Err(e) => {
log::warn!(
"[qbz-slint] suggestions get_playlist({}) failed: {e}",
playlist.id
);
}
}
// Fallback to the playlist's own images when no track covers found.
if cover_urls.is_empty() {
if let Some(images) = playlist.images.as_ref() {
if let Some(img) = images.iter().find(|s| !s.is_empty()) {
cover_urls.push(img.clone());
}
}
}
playlist_cards.push(PlaylistCard {
id: playlist.id.to_string(),
name: playlist.name.clone(),
track_count: playlist.tracks_count,
cover_urls,
});
}
}
SuggestionsPayload {
artist_id: artist_id.to_string(),
seed_track_id: current_track_id.to_string(),
seed_track_name,
seed_artist_id: artist_id.to_string(),
playlist_cards,
rec_tracks: rec,
radio_cover_urls,
error: false,
}
}
/// Build a `SuggestionCard` for a playlist (book collage).
fn playlist_to_card(card: &PlaylistCard) -> SuggestionCard {
SuggestionCard {
kind: "playlist".into(),
title: card.name.clone().into(),
subtitle: format!("{} tracks", card.track_count).into(),
cover_urls: ModelRc::new(VecModel::from(
card.cover_urls
.iter()
.map(|s| slint::SharedString::from(s.as_str()))
.collect::<Vec<_>>(),
)),
cover0: slint::Image::default(),
cover1: slint::Image::default(),
cover2: slint::Image::default(),
cover3: slint::Image::default(),
playlist_id: card.id.clone().into(),
seed_track_id: "".into(),
seed_track_name: "".into(),
seed_artist_id: "".into(),
badge: "qobuz".into(),
loading: false,
}
}
/// Build the seed "Song Radio" card (diamond collage).
fn radio_card(payload: &SuggestionsPayload) -> SuggestionCard {
SuggestionCard {
kind: "radio".into(),
title: "Song Radio".into(),
subtitle: payload.seed_track_name.clone().into(),
cover_urls: ModelRc::new(VecModel::from(
payload
.radio_cover_urls
.iter()
.map(|s| slint::SharedString::from(s.as_str()))
.collect::<Vec<_>>(),
)),
cover0: slint::Image::default(),
cover1: slint::Image::default(),
cover2: slint::Image::default(),
cover3: slint::Image::default(),
playlist_id: "".into(),
seed_track_id: payload.seed_track_id.clone().into(),
seed_track_name: payload.seed_track_name.clone().into(),
seed_artist_id: payload.seed_artist_id.clone().into(),
badge: "qbz".into(),
loading: false,
}
}
/// Apply the assembled suggestions to `SuggestionsState`. Runs on the event loop.
pub fn apply_suggestions(window: &AppWindow, payload: SuggestionsPayload) {
let mut cards: Vec<SuggestionCard> =
payload.playlist_cards.iter().map(playlist_to_card).collect();
// The radio card always trails the playlist cards (Tauri order).
if !payload.seed_track_id.is_empty() {
cards.push(radio_card(&payload));
}
let tracks: Vec<TrackItem> = payload
.rec_tracks
.iter()
.map(crate::playlist::to_item)
.collect();
let state = window.global::<SuggestionsState>();
state.set_artist_id(payload.artist_id.into());
state.set_seed_track_id(payload.seed_track_id.into());
state.set_cards(ModelRc::new(VecModel::from(cards)));
state.set_tracks(ModelRc::new(VecModel::from(tracks)));
state.set_error(if payload.error { "error".into() } else { "".into() });
state.set_loading(false);
}
/// Flip the radio card's `loading` flag (the building spinner) on/off. The
/// radio card is the LAST card in the model (Tauri order: playlists then
/// radio). Scheduled on the event loop; safe to call from any thread.
pub fn set_radio_loading(weak: &slint::Weak<AppWindow>, loading: bool) {
let _ = weak.upgrade_in_event_loop(move |w| {
let model = w.global::<SuggestionsState>().get_cards();
let n = model.row_count();
if n == 0 {
return;
}
// Find the radio card (kind == "radio"); fall back to the last card.
let idx = (0..n)
.find(|&i| {
model
.row_data(i)
.map(|c| c.kind.as_str() == "radio")
.unwrap_or(false)
})
.unwrap_or(n - 1);
if let Some(mut card) = model.row_data(idx) {
card.loading = loading;
model.set_row_data(idx, card);
}
});
}
/// Clear the suggestions state before a (re)load. Runs on the event loop.
pub fn reset_suggestions(window: &AppWindow) {
let state = window.global::<SuggestionsState>();
state.set_cards(ModelRc::new(VecModel::from(Vec::<SuggestionCard>::new())));
state.set_tracks(ModelRc::new(VecModel::from(Vec::<TrackItem>::new())));
state.set_error("".into());
state.set_loading(true);
}
/// Artwork jobs for the assembled suggestions: per-card collage slots +
/// rec-track row thumbnails.
pub fn suggestions_artwork_jobs(payload: &SuggestionsPayload) -> Vec<ArtworkJob> {
let mut jobs = Vec::new();
// Card collage slots: playlist cards first (their order matches the model),
// then the radio card (appended last in apply_suggestions).
for (card_idx, card) in payload.playlist_cards.iter().enumerate() {
for (slot, url) in card.cover_urls.iter().enumerate() {
if !url.is_empty() {
jobs.push(ArtworkJob {
url: url.clone(),
target: ArtworkTarget::SuggestionCardCover { card_idx, slot },
});
}
}
}
if !payload.seed_track_id.is_empty() {
let radio_idx = payload.playlist_cards.len();
for (slot, url) in payload.radio_cover_urls.iter().enumerate() {
if !url.is_empty() {
jobs.push(ArtworkJob {
url: url.clone(),
target: ArtworkTarget::SuggestionCardCover {
card_idx: radio_idx,
slot,
},
});
}
}
}
// Rec-track row thumbnails.
for (idx, track) in payload.rec_tracks.iter().enumerate() {
if let Some(url) = track
.album
.as_ref()
.and_then(|a| a.image.smallest().cloned())
.filter(|s| !s.is_empty())
{
jobs.push(ArtworkJob {
url,
target: ArtworkTarget::SuggestionTrackCover { idx },
});
}
}
jobs
}
+1 -1
View File
@@ -20,7 +20,7 @@ import { ShellState, MiniPlayerState } from "state.slint";
import { MiniShell } from "miniplayer/MiniShell.slint";
// Re-export the state globals so the Rust layer can populate them.
export { HomeState, HomeActions, DiscoverState, DiscoverActions, SectionDescriptor, ConfigRow, DiscoverBrowseState, DiscoverBrowseActions, ForYouState, MixState, GenreFilterState, GenreFilterActions, AlbumState, ArtistState, NavState, ShellState, SessionState, SettingsState, AlbumActions, ArtistActions, ArtworkActions, NowPlayingState, QueueState, LyricsState, LyricsLineItem, SearchState, SearchActions, NetworkSidebarState, NetworkSidebarActions, MusicianState, MusicianActions, LabelState, LabelActions, AwardState, AwardActions, AwardEntry, LocationViewState, LocationViewActions, FavoritesState, FavoritesActions, PlaylistPickerState, PlaylistPickerActions, DuplicateConfirmState, DuplicateConfirmActions, PlaylistState, PlaylistActions, SidebarState, SidebarActions, SidebarFolderPopupState, CreatePlaylistState, CreatePlaylistActions, EditPlaylistState, EditPlaylistActions, CreateFolderState, CreateFolderActions, MyQbzCreateState, MyQbzCreateActions, DragState, DragActions, PlaylistManagerState, PlaylistManagerActions, OfflineManagerState, OfflineManagerActions, BlacklistState, BlacklistActions, BlacklistedArtistItem, MyQbzState, MyQbzActions, MixtapeCardItem, MyQbzAddState, MyQbzAddActions, MyQbzAddRow, MyQbzDetailState, MyQbzDetailActions, MixtapeDetailItem, MyQbzEditState, MyQbzEditActions, MyQbzMixState, MyQbzMixActions, DiscoBuilderState, DiscoBuilderActions, DiscoGroup, DiscoCandidate, LocalLibraryState, LocalLibraryActions, LibraryFoldersState, LibFolderEditState, LibraryManageActions, LibraryScanState, LibAlbumFilterState, LocalAlbumState, LocalAlbumActions, TagEditorState, TagEditorActions, FolderEditState, FolderEditActions, ToastState, TextUtil, QconnectDevState, QconnectDevice, CastState, CastDevice, CastActions, AppearanceState, MyQbzBrandingState, EphemeralPlayChoiceState, EphemeralPlayChoiceActions, PlexSettingsState, PlexAuthActions, PlexSectionItem, ScrobbleState, ScrobbleActions, OfflineState, OfflineModeActions, OfflineFavoritesState, OfflineFavoritesActions, ImportLogEntry, PlaylistImportState, PlaylistImportActions, DacWizardState, DacWizardActions, DacCandidateRow, RemediationRow, DacConfigRow, InfoCreditRow, InfoCreditPair, AlbumCreditPerformer, AlbumCreditTrack, TrackInfoState, TrackInfoActions, AlbumInfoState, AlbumInfoActions, VisualizerState, ImmersiveState, MiniPlayerState } from "state.slint";
export { HomeState, HomeActions, DiscoverState, DiscoverActions, SectionDescriptor, ConfigRow, DiscoverBrowseState, DiscoverBrowseActions, ForYouState, MixState, GenreFilterState, GenreFilterActions, AlbumState, ArtistState, NavState, ShellState, SessionState, SettingsState, AlbumActions, ArtistActions, ArtworkActions, NowPlayingState, QueueState, LyricsState, LyricsLineItem, SearchState, SearchActions, NetworkSidebarState, NetworkSidebarActions, MusicianState, MusicianActions, LabelState, LabelActions, AwardState, AwardActions, AwardEntry, LocationViewState, LocationViewActions, FavoritesState, FavoritesActions, PlaylistPickerState, PlaylistPickerActions, DuplicateConfirmState, DuplicateConfirmActions, PlaylistState, PlaylistActions, SidebarState, SidebarActions, SidebarFolderPopupState, CreatePlaylistState, CreatePlaylistActions, EditPlaylistState, EditPlaylistActions, CreateFolderState, CreateFolderActions, MyQbzCreateState, MyQbzCreateActions, DragState, DragActions, PlaylistManagerState, PlaylistManagerActions, OfflineManagerState, OfflineManagerActions, BlacklistState, BlacklistActions, BlacklistedArtistItem, MyQbzState, MyQbzActions, MixtapeCardItem, MyQbzAddState, MyQbzAddActions, MyQbzAddRow, MyQbzDetailState, MyQbzDetailActions, MixtapeDetailItem, MyQbzEditState, MyQbzEditActions, MyQbzMixState, MyQbzMixActions, DiscoBuilderState, DiscoBuilderActions, DiscoGroup, DiscoCandidate, LocalLibraryState, LocalLibraryActions, LibraryFoldersState, LibFolderEditState, LibraryManageActions, LibraryScanState, LibAlbumFilterState, LocalAlbumState, LocalAlbumActions, TagEditorState, TagEditorActions, FolderEditState, FolderEditActions, ToastState, TextUtil, QconnectDevState, QconnectDevice, CastState, CastDevice, CastActions, AppearanceState, MyQbzBrandingState, EphemeralPlayChoiceState, EphemeralPlayChoiceActions, PlexSettingsState, PlexAuthActions, PlexSectionItem, ScrobbleState, ScrobbleActions, OfflineState, OfflineModeActions, OfflineFavoritesState, OfflineFavoritesActions, ImportLogEntry, PlaylistImportState, PlaylistImportActions, DacWizardState, DacWizardActions, DacCandidateRow, RemediationRow, DacConfigRow, InfoCreditRow, InfoCreditPair, AlbumCreditPerformer, AlbumCreditTrack, TrackInfoState, TrackInfoActions, AlbumInfoState, AlbumInfoActions, SuggestionsState, SuggestionsActions, SuggestionCard, VisualizerState, ImmersiveState, MiniPlayerState } from "state.slint";
// Which top-level screen is shown. The app starts on `splash` while it
// restores a saved session, then resolves to `shell` or `login`.
@@ -0,0 +1,470 @@
// Immersive split Suggestions panel — mounted in the SPLIT-right slot
// (ImmersiveState.split-panel == 2). 1:1 with Tauri's SuggestionsPanel.svelte
// (recon data-panels.md §6): a cards row (curated artist-playlist book-collage
// cards + the seed Song-Radio diamond-collage card, each with play/queue/
// play-next hover overlays + a corner badge; the radio card shows a spinner
// while building) and below, a "Recommended tracks" list (play on click).
// Split-only (no focus variant).
//
// Data is fed by crate::suggestions::apply_suggestions into SuggestionsState;
// actions resolve through SuggestionsActions (play/queue/play-next playlist,
// start-radio, play-track). Rendered white-on-dark over the atmosphere backdrop
// like the other immersive split panels.
//
// Slint gotchas observed (reference_slint_*): viewport dims are passed as props
// (no `parent` in the root binding); no `opacity:` on the root; no `changed`
// watcher on layout geometry; ADR-009 declaration order; no pills (ADR-008);
// @tr() for visible strings; Theme tokens for accent.
import { SuggestionsState, SuggestionsActions, SuggestionCard } from "../state.slint";
import { TrackItem } from "../state.slint";
import { QbzIcon } from "../primitives/QbzIcon.slint";
import { ListScrollbar } from "../primitives/ListScrollbar.slint";
import { LoadingSpinner } from "../primitives/LoadingSpinner.slint";
import { Theme } from "../foundation/semantic-colors.slint";
// Circular overlay action button (no pill — a true circle; ADR-008 forbids
// pill-shaped chips, a circle is fine). `primary` = 40px accent disc, else a
// 32px translucent disc.
component OverlayButton inherits Rectangle {
in property <image> icon;
in property <bool> primary: false;
in property <length> icon-size: 16px;
callback clicked();
width: root.primary ? 40px : 32px;
height: root.primary ? 40px : 32px;
border-radius: self.width / 2;
background: root.primary
? (ta.has-hover ? Theme.accent-hover : Theme.accent)
: (ta.has-hover ? #ffffff80 : #ffffff4d);
QbzIcon {
source: root.icon;
width: root.icon-size;
height: root.icon-size;
x: (parent.width - self.width) / 2;
y: (parent.height - self.height) / 2;
tint: #ffffff;
}
ta := TouchArea {
mouse-cursor: pointer;
clicked => { root.clicked(); }
}
}
// One collage cover tile — absolutely placed + rotated by the card layout.
component CollageTile inherits Rectangle {
in property <image> img;
border-radius: 4px;
clip: true;
drop-shadow-blur: 8px;
drop-shadow-color: #00000066;
Image {
source: root.img;
image-fit: cover;
width: parent.width;
height: parent.height;
}
}
// One suggestion card (playlist book-collage OR radio diamond-collage). 168px
// wide, fixed height; collage on top, title/subtitle below; hover overlay with
// the play/queue/play-next (playlist) or single start (radio) actions.
component SuggestionCardView inherits Rectangle {
in property <SuggestionCard> card;
in property <int> index;
width: 168px;
height: 220px;
border-radius: 12px;
background: card-ta.has-hover ? #ffffff26 : #ffffff1a;
border-width: 1px;
border-color: #ffffff1a;
animate background { duration: 150ms; }
property <bool> is-radio: root.card.kind == "radio";
card-ta := TouchArea { mouse-cursor: default; }
VerticalLayout {
padding: 12px;
spacing: 10px;
// ---- Collage / image well ------------------------------------
well := Rectangle {
height: 144px;
border-radius: 8px;
background: #00000040;
clip: true;
// Book collage (playlist): 3 covers, left/center/right.
if !root.is-radio: Rectangle {
width: 100%;
height: 100%;
CollageTile {
img: root.card.cover0;
width: parent.width * 0.62;
height: parent.height * 0.82;
x: parent.width * 0.06;
y: (parent.height - self.height) / 2;
}
CollageTile {
img: root.card.cover2;
width: parent.width * 0.62;
height: parent.height * 0.82;
x: parent.width * 0.32;
y: (parent.height - self.height) / 2;
}
CollageTile {
img: root.card.cover1;
width: parent.width * 0.66;
height: parent.height * 0.88;
x: (parent.width - self.width) / 2;
y: (parent.height - self.height) / 2;
}
}
// Diamond collage (radio): up to 4 covers.
if root.is-radio: Rectangle {
width: 100%;
height: 100%;
CollageTile {
img: root.card.cover1;
width: parent.width * 0.62;
height: parent.height * 0.62;
x: parent.width * 0.04;
y: (parent.height - self.height) / 2;
}
CollageTile {
img: root.card.cover2;
width: parent.width * 0.62;
height: parent.height * 0.62;
x: parent.width * 0.34;
y: (parent.height - self.height) / 2;
}
CollageTile {
img: root.card.cover0;
width: parent.width * 0.64;
height: parent.height * 0.64;
x: (parent.width - self.width) / 2;
y: parent.height * 0.06;
}
CollageTile {
img: root.card.cover3;
width: parent.width * 0.5;
height: parent.height * 0.5;
x: (parent.width - self.width) / 2;
y: parent.height * 0.42;
}
}
// Corner badge (above the collage): the full-colour Qobuz logo
// (playlist cards) or a white radio glyph (radio card).
if root.card.badge == "qobuz": Image {
x: parent.width - self.width - 8px;
y: 8px;
width: 22px;
height: 22px;
image-fit: contain;
source: @image-url("../assets/icons/qobuz-logo-filled.svg");
}
if root.card.badge != "qobuz": QbzIcon {
x: parent.width - self.width - 8px;
y: 8px;
width: 20px;
height: 20px;
source: @image-url("../assets/icons/radio.svg");
tint: #ffffffcc;
}
// Radio building spinner — dim veil + the shared LoadingSpinner
// (animation-tick rotation; same as every other heavy-load spinner).
if root.is-radio && root.card.loading: Rectangle {
width: 100%;
height: 100%;
background: #00000099;
LoadingSpinner {
size: 28px;
tint: #ffffffcc;
x: (parent.width - self.width) / 2;
y: (parent.height - self.height) / 2;
}
}
// Hover overlay with actions.
overlay := Rectangle {
width: 100%;
height: 100%;
background: #00000099;
opacity: ov-ta.has-hover ? 1.0 : 0.0;
animate opacity { duration: 150ms; }
ov-ta := TouchArea { mouse-cursor: pointer; }
if !root.is-radio: HorizontalLayout {
alignment: center;
spacing: 10px;
padding: 8px;
VerticalLayout {
alignment: center;
OverlayButton {
icon: @image-url("../assets/icons/list-plus.svg");
clicked => { SuggestionsActions.queue-playlist(root.card.playlist-id); }
}
}
VerticalLayout {
alignment: center;
OverlayButton {
primary: true;
icon: @image-url("../assets/icons/play-fill.svg");
icon-size: 18px;
clicked => { SuggestionsActions.play-playlist(root.card.playlist-id); }
}
}
VerticalLayout {
alignment: center;
OverlayButton {
icon: @image-url("../assets/icons/list-end.svg");
clicked => { SuggestionsActions.play-next-playlist(root.card.playlist-id); }
}
}
}
if root.is-radio: HorizontalLayout {
alignment: center;
padding: 8px;
VerticalLayout {
alignment: center;
OverlayButton {
primary: true;
icon: @image-url("../assets/icons/radio.svg");
icon-size: 18px;
clicked => {
if (!root.card.loading) {
SuggestionsActions.start-radio(
root.card.seed-track-id,
root.card.seed-track-name,
root.card.seed-artist-id);
}
}
}
}
}
}
}
// ---- Title + subtitle ----------------------------------------
Text {
text: root.card.title;
color: #ffffff;
font-size: 15px;
font-weight: 600;
overflow: elide;
}
Text {
text: root.card.subtitle;
color: #ffffff80;
font-size: 13px;
overflow: elide;
}
}
}
// One recommended-track row: 40px cover + title/artist, play on click/hover.
component RecTrackRow inherits Rectangle {
in property <TrackItem> track;
callback clicked();
height: 56px;
border-radius: 8px;
background: row-ta.has-hover ? #ffffff1a : transparent;
animate background { duration: 150ms; }
HorizontalLayout {
padding-left: 8px;
padding-right: 8px;
spacing: 10px;
// Artwork + hover play overlay.
VerticalLayout {
alignment: center;
art := Rectangle {
width: 40px;
height: 40px;
border-radius: 4px;
clip: true;
background: #ffffff14;
Image {
source: root.track.artwork;
image-fit: cover;
width: parent.width;
height: parent.height;
}
Rectangle {
width: 100%;
height: 100%;
background: #00000080;
opacity: row-ta.has-hover ? 1.0 : 0.0;
animate opacity { duration: 150ms; }
QbzIcon {
source: @image-url("../assets/icons/play-fill.svg");
width: 14px;
height: 14px;
x: (parent.width - self.width) / 2;
y: (parent.height - self.height) / 2;
tint: #ffffff;
}
}
}
}
// Title + artist.
VerticalLayout {
alignment: center;
horizontal-stretch: 1;
spacing: 2px;
Text {
text: root.track.title;
color: #ffffff;
font-size: 15px;
overflow: elide;
}
Text {
text: root.track.artist;
color: #ffffff99;
font-size: 13px;
overflow: elide;
}
}
// Duration.
VerticalLayout {
alignment: center;
Text {
text: root.track.duration;
color: #ffffff80;
font-size: 13px;
}
}
}
row-ta := TouchArea {
mouse-cursor: pointer;
clicked => { root.clicked(); }
}
}
export component ImmersiveSuggestionsPanel inherits Rectangle {
in property <length> viewport-width: 480px;
in property <length> viewport-height: 600px;
in property <bool> centered: true;
width: root.viewport-width;
height: root.viewport-height;
background: transparent;
VerticalLayout {
alignment: root.centered ? center : start;
Rectangle {
height: root.centered
? Math.min(root.viewport-height,
Math.clamp(340px, root.viewport-height * 0.62, 760px))
: root.viewport-height;
// ---- Empty (no track selected) ----------------------------
if SuggestionsState.artist-id == "" && !SuggestionsState.loading: VerticalLayout {
alignment: center;
spacing: 12px;
HorizontalLayout {
alignment: center;
QbzIcon {
source: @image-url("../assets/icons/radio.svg");
width: 32px;
height: 32px;
tint: #ffffff80;
}
}
Text {
text: @tr("No track selected");
color: #ffffff80;
font-size: 18px;
horizontal-alignment: center;
}
}
// ---- Loading (no content yet) -----------------------------
if SuggestionsState.loading && SuggestionsState.cards.length == 0
&& SuggestionsState.tracks.length == 0: Text {
text: @tr("Loading suggestions...");
color: #ffffff80;
font-size: 18px;
horizontal-alignment: center;
vertical-alignment: center;
width: 100%;
height: 100%;
}
// ---- Error ------------------------------------------------
if SuggestionsState.error != "": Text {
text: @tr("Failed to load suggestions");
color: #ffffff80;
font-size: 18px;
horizontal-alignment: center;
vertical-alignment: center;
width: 100%;
height: 100%;
}
// ---- Loaded -----------------------------------------------
if SuggestionsState.error == "" && SuggestionsState.artist-id != ""
&& (SuggestionsState.cards.length > 0 || SuggestionsState.tracks.length > 0): Rectangle {
clip: true;
flick := Flickable {
viewport-width: self.width;
viewport-height: body.preferred-height;
body := VerticalLayout {
width: parent.width;
padding-right: 12px;
spacing: 24px;
// Cards row.
if SuggestionsState.cards.length > 0: HorizontalLayout {
spacing: 12px;
alignment: start;
for card[i] in SuggestionsState.cards: SuggestionCardView {
card: card;
index: i;
}
}
// Recommended tracks.
if SuggestionsState.tracks.length > 0: Text {
text: @tr("Recommended tracks");
color: #ffffff80;
font-size: 14px;
font-weight: 600;
}
if SuggestionsState.tracks.length > 0: VerticalLayout {
spacing: 4px;
for track in SuggestionsState.tracks: RecTrackRow {
track: track;
clicked => { SuggestionsActions.play-track(track.id); }
}
}
}
}
ListScrollbar {
x: parent.width - self.width;
width: 14px;
height: 100%;
viewport-height: flick.viewport-height;
visible-height: flick.height;
viewport-y <=> flick.viewport-y;
}
}
}
}
}
@@ -4,7 +4,7 @@
import { Radius } from "../foundation/radius.slint";
import { QbzIcon } from "../primitives/QbzIcon.slint";
import { NowPlayingState, VisualizerState, ImmersiveState, SettingsState, LyricsState, QueueState, TrackInfoActions } from "../state.slint";
import { NowPlayingState, VisualizerState, ImmersiveState, SettingsState, LyricsState, QueueState, TrackInfoActions, SuggestionsActions } from "../state.slint";
import { ImmersiveAtmosphere } from "ImmersiveAtmosphere.slint";
import { AlbumReactivePanel } from "AlbumReactivePanel.slint";
import { StaticPanel } from "StaticPanel.slint";
@@ -14,6 +14,7 @@ import { ImmersiveLyricsFocusPanel } from "ImmersiveLyricsFocusPanel.slint";
import { ImmersiveQueuePanel } from "ImmersiveQueuePanel.slint";
import { ImmersiveTrackInfo } from "ImmersiveTrackInfo.slint";
import { ImmersiveTrackInfoPanel } from "ImmersiveTrackInfoPanel.slint";
import { ImmersiveSuggestionsPanel } from "ImmersiveSuggestionsPanel.slint";
import { LyricsLinesView } from "../shell/LyricsLinesView.slint";
component GhostButton inherits Rectangle {
@@ -495,6 +496,9 @@ component ModeBar inherits Rectangle {
// Fired when the user enters the split Track Info panel so the parent can
// kick the inline load for the current track (TrackInfoActions.load-inline).
callback trackinfo-entered();
// Fired when the user enters the split Suggestions panel so the parent can
// kick the live artist load for the current track.
callback suggestions-entered();
property <bool> is-split: ImmersiveState.view-mode == 1;
@@ -623,6 +627,15 @@ component ModeBar inherits Rectangle {
root.trackinfo-entered();
}
}
ModeTab {
icon: @image-url("../assets/icons/radio.svg");
label: @tr("Suggestions");
active: ImmersiveState.split-panel == 2;
clicked => {
root.select-split(2);
root.suggestions-entered();
}
}
ModeTab {
icon: @image-url("../assets/icons/list-music.svg");
label: @tr("Queue");
@@ -885,6 +898,23 @@ export component ImmersiveView inherits Rectangle {
viewport-height: parent.height;
centered: true;
}
// Checkpoint D: the live Suggestions panel (artist playlists +
// Song Radio + recommended tracks), centered in the right half
// (split-only, data-panels §6). `init` kicks the live artist load
// for the current track; a `changed NowPlayingState.track-id`
// guard re-fires the load so the panel refreshes when the track
// changes while it's open (track-id is a string — safe to watch,
// no layout geometry involved).
if ImmersiveState.split-panel == 2: ImmersiveSuggestionsPanel {
property <string> live-track-id: NowPlayingState.track-id;
init => { SuggestionsActions.load(NowPlayingState.track-id); }
changed live-track-id => { SuggestionsActions.load(self.live-track-id); }
width: 100%;
height: 100%;
viewport-width: parent.width;
viewport-height: parent.height;
centered: true;
}
// Checkpoint B: the Queue + History panel, centered in the right
// half. Same component as the focus mount; `centered: true` fills
// the slot (data-panels §4 — one QueuePanel in both placements).
@@ -938,6 +968,9 @@ export component ImmersiveView inherits Rectangle {
if (ImmersiveState.view-mode == 1 && ImmersiveState.split-panel == 1) {
TrackInfoActions.load-inline(NowPlayingState.track-id);
}
if (ImmersiveState.view-mode == 1 && ImmersiveState.split-panel == 2) {
SuggestionsActions.load(NowPlayingState.track-id);
}
root.wake();
}
lyrics-entered => {
@@ -952,5 +985,9 @@ export component ImmersiveView inherits Rectangle {
TrackInfoActions.load-inline(NowPlayingState.track-id);
root.wake();
}
suggestions-entered => {
SuggestionsActions.load(NowPlayingState.track-id);
root.wake();
}
}
}
+62
View File
@@ -539,6 +539,68 @@ export global TrackInfoActions {
callback load-inline(string /* track-id */);
}
// One card in the immersive Suggestions panel (data-panels.md §6): either a
// curated artist PLAYLIST (`kind == "playlist"`, book-collage of up to 3 album
// covers) or the seed-track SONG RADIO (`kind == "radio"`, diamond-collage of
// up to 4 covers). `cover-urls` is the artwork pipeline's input (slot-indexed);
// `covers` holds the decoded images, applied per-slot by the controller. Slots
// 0-3 are addressed via the parallel cover0..cover3 fields (Slint structs can't
// have per-element image arrays painted in place, so flat slots are used — same
// pattern as the search/favorites playlist collages).
export struct SuggestionCard {
// "playlist" | "radio".
kind: string,
title: string,
subtitle: string,
// Remote URLs for the (up to 4) collage slots — the artwork-job input.
cover-urls: [string],
// Decoded collage covers, painted per-slot by the artwork pipeline.
cover0: image,
cover1: image,
cover2: image,
cover3: image,
// Playlist-card target id ("" for the radio card).
playlist-id: string,
// Radio-card seed (empty for playlist cards).
seed-track-id: string,
seed-track-name: string,
seed-artist-id: string,
// "qobuz" (playlist) | "qbz" (radio) — drives the corner badge glyph.
badge: string,
// Radio card: true while the Song Radio session is building (spinner).
loading: bool,
}
// Immersive Suggestions panel state (split-only, split-panel == 2). Populated
// by crate::suggestions::apply_suggestions; the recommended-track list reuses
// the shared TrackItem struct.
export global SuggestionsState {
in property <bool> loading: false;
in property <string> error: "";
// The artist whose suggestions are loaded (dedup guard mirror).
in property <string> artist-id: "";
// The seed track these suggestions were built for.
in property <string> seed-track-id: "";
in property <[SuggestionCard]> cards: [];
in property <[TrackItem]> tracks: [];
}
export global SuggestionsActions {
// Play / queue / play-next a curated artist playlist by id.
callback play-playlist(string /* playlist-id */);
callback queue-playlist(string /* playlist-id */);
callback play-next-playlist(string /* playlist-id */);
// Start the seed-track Song Radio: (seed-track-id, seed-track-name, seed-artist-id).
callback start-radio(string, string, string);
// Play a single recommended track by id.
callback play-track(string /* track-id */);
// Load suggestions for the given track id (the Rust side reads the
// artist-id + name off NowPlayingState). Fired on panel entry and on
// now-playing track change while the panel is open. A "" id resets to the
// empty (no-track) state.
callback load(string /* track-id */);
}
// Album Info modal — opened from the AlbumPageView header (i) button via
// media-action("album", id, "info").
export global AlbumInfoState {