From 49fe9e6b1174adda4e63fb1854d21af0befaeb96 Mon Sep 17 00:00:00 2001 From: vicrodh <103399283+vicrodh@users.noreply.github.com> Date: Sun, 18 Jan 2026 00:26:54 -0600 Subject: [PATCH 01/72] feat(player): implement playback context system - Add PlaybackContext module with ContextManager - Context tracks semantic origin (album, playlist, artist top, etc.) - Separate from queue - defines what 'next' means - Backend: Rust struct with track IDs and position tracking - Frontend: Svelte store with reactive subscriptions - Tauri commands for context CRUD operations - Context is nullable (single track playback has no context) cp --- src-tauri/src/commands/mod.rs | 2 + src-tauri/src/commands/playback_context.rs | 64 +++++++ src-tauri/src/lib.rs | 9 + src-tauri/src/playback_context/mod.rs | 213 +++++++++++++++++++++ src/lib/stores/playbackContextStore.ts | 152 +++++++++++++++ 5 files changed, 440 insertions(+) create mode 100644 src-tauri/src/commands/playback_context.rs create mode 100644 src-tauri/src/playback_context/mod.rs create mode 100644 src/lib/stores/playbackContextStore.ts diff --git a/src-tauri/src/commands/mod.rs b/src-tauri/src/commands/mod.rs index 08aec6dc9..2467ab022 100644 --- a/src-tauri/src/commands/mod.rs +++ b/src-tauri/src/commands/mod.rs @@ -10,6 +10,7 @@ pub mod favorites; pub mod lastfm; pub mod notification; pub mod playback; +pub mod playback_context; pub mod playlist; pub mod playlist_import; pub mod queue; @@ -24,6 +25,7 @@ pub use favorites::*; pub use lastfm::*; pub use notification::*; pub use playback::*; +pub use playback_context::*; pub use playlist::*; pub use playlist_import::*; pub use queue::*; diff --git a/src-tauri/src/commands/playback_context.rs b/src-tauri/src/commands/playback_context.rs new file mode 100644 index 000000000..b28918b36 --- /dev/null +++ b/src-tauri/src/commands/playback_context.rs @@ -0,0 +1,64 @@ +//! Playback context commands + +use tauri::State; +use crate::playback_context::{PlaybackContext, ContextType, ContentSource}; +use crate::AppState; + +/// Get the current playback context +#[tauri::command] +pub fn get_playback_context(state: State<'_, AppState>) -> Option { + state.context.get_context() +} + +/// Set a new playback context +#[tauri::command] +pub fn set_playback_context( + context_type: String, + id: String, + label: String, + source: String, + track_ids: Vec, + start_position: usize, + state: State<'_, AppState>, +) -> Result<(), String> { + // Parse context type + let ctx_type = match context_type.as_str() { + "album" => ContextType::Album, + "playlist" => ContextType::Playlist, + "artist_top" => ContextType::ArtistTop, + "home_list" => ContextType::HomeList, + "favorites" => ContextType::Favorites, + _ => return Err(format!("Invalid context type: {}", context_type)), + }; + + // Parse source + let content_source = match source.as_str() { + "qobuz" => ContentSource::Qobuz, + "local" => ContentSource::Local, + _ => return Err(format!("Invalid source: {}", source)), + }; + + let context = PlaybackContext::new( + ctx_type, + id, + label, + content_source, + track_ids, + start_position, + ); + + state.context.set_context(context); + Ok(()) +} + +/// Clear the current playback context +#[tauri::command] +pub fn clear_playback_context(state: State<'_, AppState>) { + state.context.clear_context(); +} + +/// Check if a playback context is active +#[tauri::command] +pub fn has_playback_context(state: State<'_, AppState>) -> bool { + state.context.has_context() +} diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index d8812b2cd..0fe15d203 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -19,6 +19,7 @@ pub mod lyrics; pub mod media_controls; pub mod network; pub mod offline; +pub mod playback_context; pub mod player; pub mod playlist_import; pub mod queue; @@ -35,6 +36,7 @@ use api::QobuzClient; use cache::{AudioCache, PlaybackCache}; use lastfm::LastFmClient; use media_controls::{MediaControlsManager, TrackInfo}; +use playback_context::ContextManager; use player::Player; use queue::QueueManager; use share::SongLinkClient; @@ -44,6 +46,7 @@ pub struct AppState { pub client: Arc>, pub player: Player, pub queue: QueueManager, + pub context: ContextManager, pub media_controls: MediaControlsManager, pub audio_cache: Arc, pub lastfm: Arc>, @@ -83,6 +86,7 @@ impl AppState { client: Arc::new(Mutex::new(QobuzClient::default())), player: Player::new(device_name, audio_settings), queue: QueueManager::new(), + context: ContextManager::new(), media_controls: MediaControlsManager::new(), audio_cache, lastfm: Arc::new(Mutex::new(LastFmClient::default())), @@ -352,6 +356,11 @@ pub fn run() { commands::set_repeat, commands::get_repeat, commands::get_queue_state, + // Playback context commands + commands::get_playback_context, + commands::set_playback_context, + commands::clear_playback_context, + commands::has_playback_context, // Playlist commands commands::get_user_playlists, commands::get_playlist, diff --git a/src-tauri/src/playback_context/mod.rs b/src-tauri/src/playback_context/mod.rs new file mode 100644 index 000000000..fa866f197 --- /dev/null +++ b/src-tauri/src/playback_context/mod.rs @@ -0,0 +1,213 @@ +//! Playback context module +//! +//! Manages the semantic origin of playback to determine what "next" means. +//! A playback context is NOT the queue - it's the source that defines +//! the boundaries and continuation behavior for playback. +//! +//! Examples: +//! - Album: next track in the album +//! - Playlist: next track in the playlist +//! - Artist Top Songs: next ranked track +//! - Single track: no context, playback ends when track finishes + +use std::sync::Mutex; +use serde::{Deserialize, Serialize}; + +/// Type of playback context +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[serde(rename_all = "snake_case")] +pub enum ContextType { + Album, + Playlist, + ArtistTop, + HomeList, + Favorites, +} + +/// Source of the content (Qobuz or Local Library) +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[serde(rename_all = "lowercase")] +pub enum ContentSource { + Qobuz, + Local, +} + +/// Playback context - the semantic origin of playback +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct PlaybackContext { + /// Type of context (album, playlist, etc.) + #[serde(rename = "type")] + pub context_type: ContextType, + /// Unique identifier for this context + pub id: String, + /// Human-readable label + pub label: String, + /// Source of content + pub source: ContentSource, + /// Original track list for this context (track IDs) + pub track_ids: Vec, + /// Current position in the context + pub current_position: usize, +} + +impl PlaybackContext { + /// Create a new playback context + pub fn new( + context_type: ContextType, + id: String, + label: String, + source: ContentSource, + track_ids: Vec, + start_position: usize, + ) -> Self { + Self { + context_type, + id, + label, + source, + track_ids, + current_position: start_position, + } + } + + /// Get the next track ID in this context (if any) + pub fn next_track_id(&self) -> Option { + let next_pos = self.current_position + 1; + if next_pos < self.track_ids.len() { + self.track_ids.get(next_pos).copied() + } else { + None + } + } + + /// Get multiple upcoming track IDs in this context + pub fn upcoming_track_ids(&self, count: usize) -> Vec { + let start_pos = self.current_position + 1; + self.track_ids + .iter() + .skip(start_pos) + .take(count) + .copied() + .collect() + } + + /// Advance to the next track in context + pub fn advance(&mut self) -> bool { + let next_pos = self.current_position + 1; + if next_pos < self.track_ids.len() { + self.current_position = next_pos; + true + } else { + false + } + } + + /// Check if context has more tracks + pub fn has_next(&self) -> bool { + self.current_position + 1 < self.track_ids.len() + } + + /// Get total tracks in context + pub fn total_tracks(&self) -> usize { + self.track_ids.len() + } + + /// Get context info for display + pub fn display_info(&self) -> String { + let type_str = match self.context_type { + ContextType::Album => "Album", + ContextType::Playlist => "Playlist", + ContextType::ArtistTop => "Artist Top Songs", + ContextType::HomeList => "Home List", + ContextType::Favorites => "Favorites", + }; + format!("{} · {}", type_str, self.label) + } +} + +/// Manager for the current playback context +pub struct ContextManager { + current: Mutex>, +} + +impl Default for ContextManager { + fn default() -> Self { + Self::new() + } +} + +impl ContextManager { + pub fn new() -> Self { + Self { + current: Mutex::new(None), + } + } + + /// Set the current playback context + pub fn set_context(&self, context: PlaybackContext) { + let mut current = self.current.lock().unwrap(); + *current = Some(context); + log::info!("Playback context set: {:?}", current.as_ref().map(|c| &c.label)); + } + + /// Clear the current context (for single track playback) + pub fn clear_context(&self) { + let mut current = self.current.lock().unwrap(); + *current = None; + log::info!("Playback context cleared"); + } + + /// Get the current context (cloned) + pub fn get_context(&self) -> Option { + self.current.lock().unwrap().clone() + } + + /// Check if a context is active + pub fn has_context(&self) -> bool { + self.current.lock().unwrap().is_some() + } + + /// Get the next track ID from the current context + pub fn next_track_id(&self) -> Option { + self.current + .lock() + .unwrap() + .as_ref() + .and_then(|ctx| ctx.next_track_id()) + } + + /// Get multiple upcoming track IDs from the current context + pub fn upcoming_track_ids(&self, count: usize) -> Vec { + self.current + .lock() + .unwrap() + .as_ref() + .map(|ctx| ctx.upcoming_track_ids(count)) + .unwrap_or_default() + } + + /// Advance the context to the next track + pub fn advance_context(&self) -> bool { + let mut current = self.current.lock().unwrap(); + if let Some(ctx) = current.as_mut() { + let advanced = ctx.advance(); + if !advanced { + log::info!("Playback context ended (no more tracks)"); + } + advanced + } else { + false + } + } + + /// Update current track position in context (when user seeks within context) + pub fn set_position(&self, track_id: u64) { + let mut current = self.current.lock().unwrap(); + if let Some(ctx) = current.as_mut() { + if let Some(pos) = ctx.track_ids.iter().position(|&id| id == track_id) { + ctx.current_position = pos; + log::debug!("Context position updated to {}", pos); + } + } + } +} diff --git a/src/lib/stores/playbackContextStore.ts b/src/lib/stores/playbackContextStore.ts new file mode 100644 index 000000000..3e0507af8 --- /dev/null +++ b/src/lib/stores/playbackContextStore.ts @@ -0,0 +1,152 @@ +/** + * Playback Context Store + * + * Manages the semantic origin of playback (album, playlist, artist top, etc.) + * Determines what "next" means and displays the stack icon. + */ + +import { invoke } from '@tauri-apps/api/core'; + +// ============ Types ============ + +export type ContextType = 'album' | 'playlist' | 'artist_top' | 'home_list' | 'favorites'; +export type ContentSource = 'qobuz' | 'local'; + +export interface PlaybackContext { + type: ContextType; + id: string; + label: string; + source: ContentSource; + track_ids: number[]; + current_position: number; +} + +// ============ State ============ + +let currentContext: PlaybackContext | null = null; +const listeners = new Set<() => void>(); + +function notifyListeners(): void { + for (const listener of listeners) { + listener(); + } +} + +// ============ Public API ============ + +/** + * Set a playback context (e.g., when playing from album/playlist) + */ +export async function setPlaybackContext( + contextType: ContextType, + id: string, + label: string, + source: ContentSource, + trackIds: number[], + startPosition: number +): Promise { + await invoke('set_playback_context', { + contextType, + id, + label, + source, + trackIds, + startPosition + }); + + // Update local state + currentContext = { + type: contextType, + id, + label, + source, + track_ids: trackIds, + current_position: startPosition + }; + + notifyListeners(); +} + +/** + * Clear the playback context (e.g., when playing single track) + */ +export async function clearPlaybackContext(): Promise { + await invoke('clear_playback_context'); + currentContext = null; + notifyListeners(); +} + +/** + * Get the current playback context + */ +export async function getPlaybackContext(): Promise { + const context = await invoke('get_playback_context'); + currentContext = context; + notifyListeners(); + return context; +} + +/** + * Check if a context is active + */ +export async function hasPlaybackContext(): Promise { + return await invoke('has_playback_context'); +} + +/** + * Get the current context (cached, no backend call) + */ +export function getCurrentContext(): PlaybackContext | null { + return currentContext; +} + +/** + * Get display info for the current context + */ +export function getContextDisplayInfo(): string | null { + if (!currentContext) return null; + + const typeStr = { + album: 'Album', + playlist: 'Playlist', + artist_top: 'Artist Top Songs', + home_list: 'Home List', + favorites: 'Favorites' + }[currentContext.type]; + + return `${typeStr} · ${currentContext.label}`; +} + +/** + * Subscribe to context changes + */ +export function subscribe(listener: () => void): () => void { + listeners.add(listener); + return () => { + listeners.delete(listener); + }; +} + +/** + * Initialize context store (call on app startup) + */ +export async function initPlaybackContextStore(): Promise { + // Sync initial state from backend + await getPlaybackContext(); +} + +// Export a reactive getter for Svelte components +export function usePlaybackContext() { + let context = currentContext; + + const unsubscribe = subscribe(() => { + context = currentContext; + }); + + return { + get context() { + return context; + }, + unsubscribe + }; +} From cf5be434e368807a8ba1d939c9013124b6769d9c Mon Sep 17 00:00:00 2001 From: vicrodh <103399283+vicrodh@users.noreply.github.com> Date: Sun, 18 Jan 2026 00:39:25 -0600 Subject: [PATCH 02/72] feat(ui): add stack icon to all 4 players - Create StackIcon component with reactive context subscription - Display Layers icon before track title when context exists - Show tooltip with origin info on hover - Add to: NowPlayingBar, ExpandedPlayer, FocusMode, MiniPlayer - Icon hidden when no playback context (single track) - Responsive sizing per player (14px-18px) cp --- src/lib/components/ExpandedPlayer.svelte | 21 +++++++++- src/lib/components/FocusMode.svelte | 20 +++++++++- src/lib/components/NowPlayingBar.svelte | 22 ++++++++++- src/lib/components/StackIcon.svelte | 50 ++++++++++++++++++++++++ src/routes/miniplayer/+page.svelte | 20 +++++++++- 5 files changed, 128 insertions(+), 5 deletions(-) create mode 100644 src/lib/components/StackIcon.svelte diff --git a/src/lib/components/ExpandedPlayer.svelte b/src/lib/components/ExpandedPlayer.svelte index 6aba10e77..be29b8ae8 100644 --- a/src/lib/components/ExpandedPlayer.svelte +++ b/src/lib/components/ExpandedPlayer.svelte @@ -2,6 +2,7 @@ import { invoke } from '@tauri-apps/api/core'; import { X, Shuffle, SkipBack, Play, Pause, SkipForward, Repeat, Heart, List, Maximize2, MoreHorizontal, Cast } from 'lucide-svelte'; import QualityBadge from './QualityBadge.svelte'; + import StackIcon from './StackIcon.svelte'; import LyricsLines from './lyrics/LyricsLines.svelte'; import { startActiveLineUpdates } from '$lib/stores/lyricsStore'; @@ -244,7 +245,10 @@
-

{trackTitle}

+
+ +

{trackTitle}

+

{artist}

{album}

@@ -508,14 +512,27 @@ width: 100%; } + .title-row { + display: flex; + align-items: center; + gap: 8px; + margin-bottom: 6px; + } + + .title-row :global(.stack-icon) { + flex-shrink: 0; + } + .title { font-size: 22px; font-weight: 600; color: white; - margin: 0 0 6px; + margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; + flex: 1; + min-width: 0; } .artist { diff --git a/src/lib/components/FocusMode.svelte b/src/lib/components/FocusMode.svelte index d6fcbf613..001ab45a3 100644 --- a/src/lib/components/FocusMode.svelte +++ b/src/lib/components/FocusMode.svelte @@ -1,5 +1,6 @@ + +{#if context && displayInfo} +
+ +
+{/if} + + diff --git a/src/routes/miniplayer/+page.svelte b/src/routes/miniplayer/+page.svelte index 515c378a2..b103c1f70 100644 --- a/src/routes/miniplayer/+page.svelte +++ b/src/routes/miniplayer/+page.svelte @@ -12,6 +12,7 @@ Maximize2, ListMusic } from 'lucide-svelte'; + import StackIcon from '$lib/components/StackIcon.svelte'; import { subscribe as subscribePlayer, getPlayerState, @@ -230,7 +231,10 @@
-
{playerState.currentTrack?.title ?? 'No track'}
+
+ +
{playerState.currentTrack?.title ?? 'No track'}
+
{playerState.currentTrack?.artist ?? '—'} {#if playerState.currentTrack?.album} @@ -408,6 +412,18 @@ padding-right: 30px; } + .title-row { + display: flex; + align-items: center; + gap: 6px; + white-space: nowrap; + overflow: hidden; + } + + .title-row :global(.stack-icon) { + flex-shrink: 0; + } + .title { font-weight: 600; font-size: 14px; @@ -416,6 +432,8 @@ text-overflow: ellipsis; color: #fff; line-height: 1.4; + flex: 1; + min-width: 0; } .artist-album { From 515632913d997ff04db638fb31ae643a145268eb Mon Sep 17 00:00:00 2001 From: vicrodh <103399283+vicrodh@users.noreply.github.com> Date: Sun, 18 Jan 2026 00:41:17 -0600 Subject: [PATCH 03/72] feat(ui): add context menu actions for playback context - Add 'Play track only' option (clears context, single track) - Add 'Play from here' option (sets context from current position) - Update TrackMenu component with new actions - Update TrackRow to pass new menu actions - Backend integration ready for Phase 3 (settings + wiring) cp --- src/lib/components/TrackMenu.svelte | 18 +++++++++++++++++- src/lib/components/TrackRow.svelte | 4 ++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/lib/components/TrackMenu.svelte b/src/lib/components/TrackMenu.svelte index fa78fcede..ce11600aa 100644 --- a/src/lib/components/TrackMenu.svelte +++ b/src/lib/components/TrackMenu.svelte @@ -17,6 +17,8 @@ interface Props { onPlayNow?: () => void; + onPlayTrackOnly?: () => void; + onPlayFromHere?: () => void; onPlayNext?: () => void; onPlayLater?: () => void; onAddFavorite?: () => void; @@ -30,6 +32,8 @@ let { onPlayNow, + onPlayTrackOnly, + onPlayFromHere, onPlayNext, onPlayLater, onAddFavorite, @@ -63,7 +67,7 @@ }; } - const hasPlayback = $derived(!!(onPlayNow || onPlayNext || onPlayLater)); + const hasPlayback = $derived(!!(onPlayNow || onPlayTrackOnly || onPlayFromHere || onPlayNext || onPlayLater)); const hasLibrary = $derived(!!(onAddFavorite || onAddToPlaylist || onRemoveFromPlaylist)); const hasShare = $derived(!!(onShareQobuz || onShareSonglink)); const hasNav = $derived(!!(onGoToAlbum || onGoToArtist)); @@ -193,6 +197,18 @@ Play now {/if} + {#if onPlayTrackOnly} + + {/if} + {#if onPlayFromHere} + + {/if} {#if onPlayNext} {/if} @@ -68,17 +67,15 @@ display: inline-flex; align-items: center; justify-content: center; - gap: 4px; color: var(--text-secondary); opacity: 0.7; transition: all 0.2s; flex-shrink: 0; background: none; border: none; - padding: 4px 6px; + padding: 4px; border-radius: 4px; cursor: pointer; - font-size: 12px; } .stack-icon-wrapper:hover { @@ -90,14 +87,4 @@ .stack-icon-wrapper:active { transform: scale(0.95); } - - .arrow { - opacity: 0; - transition: opacity 0.2s; - margin-left: -2px; - } - - .stack-icon-wrapper:hover .arrow { - opacity: 1; - } diff --git a/src/lib/components/views/SettingsView.svelte b/src/lib/components/views/SettingsView.svelte index ef1f298e2..789ac7a1e 100644 --- a/src/lib/components/views/SettingsView.svelte +++ b/src/lib/components/views/SettingsView.svelte @@ -1467,8 +1467,8 @@

{$t('settings.playback.title')}

- Autoplay behavior - Choose what happens when you click a track + {$t('settings.playback.autoplayBehavior')} + {$t('settings.playback.autoplayBehaviorDesc')}
- Show track playing context in player - -
- English: Shows the context from which the current track is being played, such as from an album view, artist page, playlist, etc. -

- Español: Muestra el contexto desde donde se está reproduciendo el track actual, por ejemplo desde la vista de álbum, de artista, playlist, etc. -
-
+ {$t('settings.playback.showContextIcon')} +
diff --git a/src/lib/i18n/locales/en.json b/src/lib/i18n/locales/en.json index de35c2a82..63b0e9c5c 100644 --- a/src/lib/i18n/locales/en.json +++ b/src/lib/i18n/locales/en.json @@ -311,7 +311,13 @@ "gapless": "Gapless Playback", "crossfade": "Crossfade", "crossfadeSeconds": "{seconds}s", - "normalizeVolume": "Normalize Volume" + "normalizeVolume": "Normalize Volume", + "autoplayBehavior": "Autoplay behavior", + "autoplayBehaviorDesc": "Choose what happens when you click a track", + "continueWithinSource": "Continue within source", + "playOnlySelectedTrack": "Play only selected track", + "showContextIcon": "Show track playing context in player", + "showContextIconTooltip": "Shows the context from which the current track is being played (album, artist, playlist, etc.)" }, "appearance": { "title": "Appearance", diff --git a/src/lib/i18n/locales/es.json b/src/lib/i18n/locales/es.json index d89ed262c..d4e5952c2 100644 --- a/src/lib/i18n/locales/es.json +++ b/src/lib/i18n/locales/es.json @@ -311,7 +311,13 @@ "gapless": "Reproducción Sin Pausas", "crossfade": "Crossfade", "crossfadeSeconds": "{seconds}s", - "normalizeVolume": "Normalizar Volumen" + "normalizeVolume": "Normalizar Volumen", + "autoplayBehavior": "Comportamiento de autoreproducción", + "autoplayBehaviorDesc": "Elige qué sucede al hacer clic en una pista", + "continueWithinSource": "Continuar dentro del contexto", + "playOnlySelectedTrack": "Reproducir solo la pista seleccionada", + "showContextIcon": "Mostrar contexto de reproducción en el reproductor", + "showContextIconTooltip": "Muestra el contexto desde donde se reproduce la pista actual (álbum, artista, playlist, etc.)" }, "appearance": { "title": "Apariencia", From 0feb1e1b4a7997920f585b20a63c41024d5d0540 Mon Sep 17 00:00:00 2001 From: vicrodh <103399283+vicrodh@users.noreply.github.com> Date: Sun, 18 Jan 2026 04:09:31 -0600 Subject: [PATCH 26/72] debug: add detailed logging to StackIcon click handler cp --- src/lib/components/StackIcon.svelte | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lib/components/StackIcon.svelte b/src/lib/components/StackIcon.svelte index 7da65d152..6c94bca00 100644 --- a/src/lib/components/StackIcon.svelte +++ b/src/lib/components/StackIcon.svelte @@ -17,9 +17,15 @@ function handleClick(e: MouseEvent) { e.stopPropagation(); + e.preventDefault(); + console.log('[StackIcon] Button clicked'); + console.log('[StackIcon] onClick prop:', onClick); + console.log('[StackIcon] Current context:', context); if (onClick) { - console.log('[StackIcon] Clicked - navigating to source'); + console.log('[StackIcon] Calling onClick callback'); onClick(); + } else { + console.warn('[StackIcon] No onClick callback provided'); } } From 92f1644601a8f1225ea297cc46457847dbfec24a Mon Sep 17 00:00:00 2001 From: vicrodh <103399283+vicrodh@users.noreply.github.com> Date: Sun, 18 Jan 2026 04:34:42 -0600 Subject: [PATCH 27/72] fix(context): add custom tooltip and pass onClick callback - Implemented custom tooltip for StackIcon (similar to AudioOutputBadges) - Shows 'Playing from', context name, and 'Click to navigate' hint - Added onContextClick={handleContextNavigation} to ExpandedPlayer - Fixed onClick prop not being passed, enabling navigation cp --- src/lib/components/StackIcon.svelte | 82 ++++++++++++++++++++++++++--- src/routes/+page.svelte | 1 + 2 files changed, 76 insertions(+), 7 deletions(-) diff --git a/src/lib/components/StackIcon.svelte b/src/lib/components/StackIcon.svelte index 6c94bca00..4df559f13 100644 --- a/src/lib/components/StackIcon.svelte +++ b/src/lib/components/StackIcon.svelte @@ -14,6 +14,7 @@ let context = $state(getCurrentContext()); let displayInfo = $state(context ? getContextDisplayInfo() : null); let showIcon = $state(getCachedPreferences().show_context_icon); + let isHovering = $state(false); function handleClick(e: MouseEvent) { e.stopPropagation(); @@ -58,17 +59,35 @@ {#if context && displayInfo && showIcon} - + + + {#if isHovering} +
+
Playing from
+
{displayInfo}
+
Click to navigate
+
+ {/if} +
{/if} diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 68d522eea..eb65ad4aa 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -2325,6 +2325,7 @@ }} onCast={openCastPicker} {isCastConnected} + onContextClick={handleContextNavigation} lyricsLines={lyricsLines.map(l => ({ text: l.text }))} lyricsActiveIndex={lyricsActiveIndex} lyricsActiveProgress={lyricsActiveProgress} From b666722b9830bb151eacc25bdc615d714d7384cb Mon Sep 17 00:00:00 2001 From: vicrodh <103399283+vicrodh@users.noreply.github.com> Date: Sun, 18 Jan 2026 04:34:54 -0600 Subject: [PATCH 28/72] debug: add detailed logging to loadPlaybackPreferences cp --- src/lib/components/views/SettingsView.svelte | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lib/components/views/SettingsView.svelte b/src/lib/components/views/SettingsView.svelte index 789ac7a1e..86c47d732 100644 --- a/src/lib/components/views/SettingsView.svelte +++ b/src/lib/components/views/SettingsView.svelte @@ -1113,10 +1113,14 @@ } async function loadPlaybackPreferences() { + console.log('[Settings] Loading playback preferences...'); try { const prefs = await getPlaybackPreferences(); + console.log('[Settings] Loaded preferences:', prefs); autoplayMode = prefs.autoplay_mode; showContextIcon = prefs.show_context_icon; + console.log('[Settings] Set autoplayMode to:', autoplayMode); + console.log('[Settings] Set showContextIcon to:', showContextIcon); } catch (err) { console.error('Failed to load playback preferences:', err); } From 315bdce79c721746717d1e424c2328717f4298e1 Mon Sep 17 00:00:00 2001 From: vicrodh <103399283+vicrodh@users.noreply.github.com> Date: Sun, 18 Jan 2026 04:38:15 -0600 Subject: [PATCH 29/72] fix(settings): reload playback preferences when view renders - Added $effect to reload preferences each time SettingsView is visible - Fixes autoplay mode not persisting when navigating away and back - Settings view doesn't unmount, so onMount only runs once per session cp --- src/lib/components/views/SettingsView.svelte | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/lib/components/views/SettingsView.svelte b/src/lib/components/views/SettingsView.svelte index 86c47d732..b43492dfe 100644 --- a/src/lib/components/views/SettingsView.svelte +++ b/src/lib/components/views/SettingsView.svelte @@ -467,6 +467,15 @@ }; }); + // Reload playback preferences each time the view becomes visible + // This ensures settings are fresh when navigating back to settings + $effect(() => { + // This effect runs whenever the component is rendered + // We reload preferences to ensure they're in sync with backend + console.log('[Settings] Component rendered, reloading playback preferences'); + loadPlaybackPreferences(); + }); + async function loadLastfmState() { try { // Check if embedded (build-time) credentials are available From 12067d7a61df859a1fc5cd651f7c514170a3f18e Mon Sep 17 00:00:00 2001 From: vicrodh <103399283+vicrodh@users.noreply.github.com> Date: Sun, 18 Jan 2026 04:53:43 -0600 Subject: [PATCH 30/72] fix(phase3): context navigation and autoplay persistence - Fixed context navigation using correct property names (.type, .id) - Simplified autoplay setting from radio buttons to toggle switch - Fixed tooltip using native title attribute (like QualityBadge) - Removed custom tooltip CSS and hover state - Updated translations (en/es) for clearer autoplay behavior description cp --- src/lib/components/StackIcon.svelte | 88 ++------------------ src/lib/components/views/SettingsView.svelte | 23 +---- src/lib/i18n/locales/en.json | 4 +- src/lib/i18n/locales/es.json | 4 +- src/routes/+page.svelte | 10 +-- 5 files changed, 17 insertions(+), 112 deletions(-) diff --git a/src/lib/components/StackIcon.svelte b/src/lib/components/StackIcon.svelte index 4df559f13..174498aeb 100644 --- a/src/lib/components/StackIcon.svelte +++ b/src/lib/components/StackIcon.svelte @@ -14,19 +14,12 @@ let context = $state(getCurrentContext()); let displayInfo = $state(context ? getContextDisplayInfo() : null); let showIcon = $state(getCachedPreferences().show_context_icon); - let isHovering = $state(false); function handleClick(e: MouseEvent) { e.stopPropagation(); e.preventDefault(); - console.log('[StackIcon] Button clicked'); - console.log('[StackIcon] onClick prop:', onClick); - console.log('[StackIcon] Current context:', context); if (onClick) { - console.log('[StackIcon] Calling onClick callback'); onClick(); - } else { - console.warn('[StackIcon] No onClick callback provided'); } } @@ -59,35 +52,17 @@ {#if context && displayInfo && showIcon} -
isHovering = true} - onmouseleave={() => isHovering = false} + - - {#if isHovering} -
-
Playing from
-
{displayInfo}
-
Click to navigate
-
- {/if} -
+ + {/if} diff --git a/src/lib/components/views/SettingsView.svelte b/src/lib/components/views/SettingsView.svelte index b43492dfe..ad51aa62b 100644 --- a/src/lib/components/views/SettingsView.svelte +++ b/src/lib/components/views/SettingsView.svelte @@ -1483,28 +1483,7 @@ {$t('settings.playback.autoplayBehavior')} {$t('settings.playback.autoplayBehaviorDesc')}
-
- - -
+ handleAutoplayModeChange(enabled ? 'continue' : 'track_only')} />
diff --git a/src/lib/i18n/locales/en.json b/src/lib/i18n/locales/en.json index 63b0e9c5c..d6532da0b 100644 --- a/src/lib/i18n/locales/en.json +++ b/src/lib/i18n/locales/en.json @@ -312,8 +312,8 @@ "crossfade": "Crossfade", "crossfadeSeconds": "{seconds}s", "normalizeVolume": "Normalize Volume", - "autoplayBehavior": "Autoplay behavior", - "autoplayBehaviorDesc": "Choose what happens when you click a track", + "autoplayBehavior": "Continue playback after track ends", + "autoplayBehaviorDesc": "When enabled, plays next track in the source. When disabled, stops after each track", "continueWithinSource": "Continue within source", "playOnlySelectedTrack": "Play only selected track", "showContextIcon": "Show track playing context in player", diff --git a/src/lib/i18n/locales/es.json b/src/lib/i18n/locales/es.json index d4e5952c2..a61428ba8 100644 --- a/src/lib/i18n/locales/es.json +++ b/src/lib/i18n/locales/es.json @@ -312,8 +312,8 @@ "crossfade": "Crossfade", "crossfadeSeconds": "{seconds}s", "normalizeVolume": "Normalizar Volumen", - "autoplayBehavior": "Comportamiento de autoreproducción", - "autoplayBehaviorDesc": "Elige qué sucede al hacer clic en una pista", + "autoplayBehavior": "Continuar reproducción al finalizar pista", + "autoplayBehaviorDesc": "Cuando está activado, reproduce la siguiente pista del contexto. Cuando está desactivado, se detiene después de cada pista", "continueWithinSource": "Continuar dentro del contexto", "playOnlySelectedTrack": "Reproducir solo la pista seleccionada", "showContextIcon": "Mostrar contexto de reproducción en el reproductor", diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index eb65ad4aa..e23f3e6a1 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -385,15 +385,15 @@ console.log('[ContextNav] Navigating to:', context); try { - switch (context.context_type) { + switch (context.type) { case 'album': // Navigate to album page - await handleAlbumClick(context.context_id); + await handleAlbumClick(context.id); break; case 'playlist': // Navigate to playlist page - const playlistId = parseInt(context.context_id); + const playlistId = parseInt(context.id); if (!isNaN(playlistId)) { selectedPlaylistId = playlistId; navigateTo('playlist'); @@ -402,7 +402,7 @@ case 'artist_top': // Navigate to artist page - const artistId = parseInt(context.context_id); + const artistId = parseInt(context.id); if (!isNaN(artistId)) { await handleArtistClick(artistId); } @@ -424,7 +424,7 @@ break; default: - console.warn('[ContextNav] Unknown context type:', context.context_type); + console.warn('[ContextNav] Unknown context type:', context.type); } } catch (err) { console.error('[ContextNav] Navigation failed:', err); From d96233730b80454df7b072e453ad18c61953e2e3 Mon Sep 17 00:00:00 2001 From: vicrodh <103399283+vicrodh@users.noreply.github.com> Date: Sun, 18 Jan 2026 04:58:35 -0600 Subject: [PATCH 31/72] fix(phase3): custom tooltip for context icon - Replace native title with custom tooltip similar to DAC/EXC badges - Add hover state and styled tooltip with context info - Add debug logs to investigate onClick callback issue cp --- src/lib/components/StackIcon.svelte | 54 +++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 3 deletions(-) diff --git a/src/lib/components/StackIcon.svelte b/src/lib/components/StackIcon.svelte index 174498aeb..df1657054 100644 --- a/src/lib/components/StackIcon.svelte +++ b/src/lib/components/StackIcon.svelte @@ -14,12 +14,17 @@ let context = $state(getCurrentContext()); let displayInfo = $state(context ? getContextDisplayInfo() : null); let showIcon = $state(getCachedPreferences().show_context_icon); + let isHovering = $state(false); function handleClick(e: MouseEvent) { e.stopPropagation(); e.preventDefault(); + console.log('[StackIcon] Clicked, onClick=', onClick, 'typeof=', typeof onClick); if (onClick) { + console.log('[StackIcon] Calling onClick callback'); onClick(); + } else { + console.warn('[StackIcon] No onClick callback provided'); } } @@ -28,7 +33,6 @@ const unsubscribe = subscribe(() => { const newContext = getCurrentContext(); const newDisplayInfo = newContext ? getContextDisplayInfo() : null; - console.log('[StackIcon] Context changed:', { newContext, newDisplayInfo }); context = newContext; displayInfo = newDisplayInfo; }); @@ -42,7 +46,6 @@ $effect(() => { const unsubscribe = subscribePrefs(() => { showIcon = getCachedPreferences().show_context_icon; - console.log('[StackIcon] Icon visibility:', showIcon); }); return () => { @@ -55,10 +58,19 @@ {/if} @@ -76,6 +88,7 @@ padding: 4px; border-radius: 4px; cursor: pointer; + position: relative; } .stack-icon-wrapper:hover { @@ -87,4 +100,39 @@ .stack-icon-wrapper:active { transform: scale(0.95); } + + .context-tooltip { + position: absolute; + bottom: calc(100% + 8px); + left: 50%; + transform: translateX(-50%); + background: rgba(20, 20, 20, 0.95); + backdrop-filter: blur(10px); + border: 1px solid rgba(255, 255, 255, 0.1); + border-radius: 8px; + padding: 8px 12px; + box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3); + white-space: nowrap; + z-index: 1000; + pointer-events: none; + } + + .tooltip-text { + font-size: 11px; + color: rgba(255, 255, 255, 0.6); + margin-bottom: 2px; + } + + .tooltip-context { + font-size: 13px; + font-weight: 500; + color: rgba(255, 255, 255, 0.9); + margin-bottom: 2px; + } + + .tooltip-hint { + font-size: 11px; + color: rgba(255, 255, 255, 0.5); + font-style: italic; + } From c2628b0076c7a5f9b57e6516b1d6984955fd8f86 Mon Sep 17 00:00:00 2001 From: vicrodh <103399283+vicrodh@users.noreply.github.com> Date: Sun, 18 Jan 2026 05:32:49 -0600 Subject: [PATCH 32/72] fix(config): align autoplay mode serialization cx --- src-tauri/src/config/playback_preferences.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src-tauri/src/config/playback_preferences.rs b/src-tauri/src/config/playback_preferences.rs index 9c3f89a7d..674afc6c5 100644 --- a/src-tauri/src/config/playback_preferences.rs +++ b/src-tauri/src/config/playback_preferences.rs @@ -8,11 +8,12 @@ use std::sync::{Arc, Mutex}; use log::info; #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] -#[serde(rename_all = "snake_case")] pub enum AutoplayMode { /// Continue playing within the source (album, playlist, etc.) + #[serde(rename = "continue")] ContinueWithinSource, /// Play only the selected track, then stop + #[serde(rename = "track_only")] PlayTrackOnly, } From c67c479bac31afad97d009cfff7fe9fe291bc0dd Mon Sep 17 00:00:00 2001 From: vicrodh <103399283+vicrodh@users.noreply.github.com> Date: Sun, 18 Jan 2026 05:33:00 -0600 Subject: [PATCH 33/72] fix(ui): wire stack icon click and tooltip cx --- src/lib/components/NowPlayingBar.svelte | 6 ++- src/lib/components/StackIcon.svelte | 53 +++---------------------- 2 files changed, 9 insertions(+), 50 deletions(-) diff --git a/src/lib/components/NowPlayingBar.svelte b/src/lib/components/NowPlayingBar.svelte index c0f94617f..785d36b88 100644 --- a/src/lib/components/NowPlayingBar.svelte +++ b/src/lib/components/NowPlayingBar.svelte @@ -63,6 +63,7 @@ isCastConnected?: boolean; onArtistClick?: () => void; onAlbumClick?: () => void; + onContextClick?: () => void; } let { @@ -98,7 +99,8 @@ lyricsActive = false, isCastConnected = false, onArtistClick, - onAlbumClick + onAlbumClick, + onContextClick }: Props = $props(); let progressRef: HTMLDivElement; @@ -297,7 +299,7 @@
{trackTitle}
- + {#if artist} {/if} @@ -101,38 +88,8 @@ transform: scale(0.95); } - .context-tooltip { - position: absolute; - bottom: calc(100% + 8px); - left: 50%; - transform: translateX(-50%); - background: rgba(20, 20, 20, 0.95); - backdrop-filter: blur(10px); - border: 1px solid rgba(255, 255, 255, 0.1); - border-radius: 8px; - padding: 8px 12px; - box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3); - white-space: nowrap; - z-index: 1000; - pointer-events: none; - } - - .tooltip-text { - font-size: 11px; - color: rgba(255, 255, 255, 0.6); - margin-bottom: 2px; - } - - .tooltip-context { - font-size: 13px; - font-weight: 500; - color: rgba(255, 255, 255, 0.9); - margin-bottom: 2px; - } - - .tooltip-hint { - font-size: 11px; - color: rgba(255, 255, 255, 0.5); - font-style: italic; + .stack-icon-wrapper:focus-visible { + outline: 2px solid var(--accent-primary); + outline-offset: 2px; } From 5a42df35a4e5490b388f5fedb5f2045ea8be76f6 Mon Sep 17 00:00:00 2001 From: vicrodh <103399283+vicrodh@users.noreply.github.com> Date: Sun, 18 Jan 2026 05:38:22 -0600 Subject: [PATCH 34/72] fix(ui): lock playlist import button after success cx --- src/lib/components/PlaylistImportModal.svelte | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/lib/components/PlaylistImportModal.svelte b/src/lib/components/PlaylistImportModal.svelte index f60c2d23d..10a846725 100644 --- a/src/lib/components/PlaylistImportModal.svelte +++ b/src/lib/components/PlaylistImportModal.svelte @@ -48,6 +48,8 @@ let lockedProvider = $state(null); let logEntries = $state<{ message: string; status: 'info' | 'success' | 'error' }[]>([]); let isOffline = $state(checkIsOffline()); + let importCompleted = $state(false); + let lastImportedUrl = $state(''); // Subscribe to offline state changes $effect(() => { @@ -76,6 +78,20 @@ summary = null; lockedProvider = null; logEntries = []; + importCompleted = false; + lastImportedUrl = ''; + } + }); + + $effect(() => { + if (!importCompleted) return; + const trimmed = url.trim(); + if (trimmed !== lastImportedUrl) { + error = null; + summary = null; + lockedProvider = null; + logEntries = []; + importCompleted = false; } }); @@ -127,6 +143,8 @@ }); summary = result; + importCompleted = true; + lastImportedUrl = url.trim(); pushLog(`Imported ${result.matched_tracks} of ${result.total_tracks} tracks into QBZ.`, 'success'); if (result.qobuz_playlist_id) { @@ -259,7 +277,7 @@ Date: Mon, 19 Jan 2026 14:13:08 -0600 Subject: [PATCH 72/72] fix(favorites): migrate custom icon storage to cache cx --- src-tauri/src/config/favorites_preferences.rs | 31 ++++++++++++++++--- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/src-tauri/src/config/favorites_preferences.rs b/src-tauri/src/config/favorites_preferences.rs index 49a8a8c9c..f0495e780 100644 --- a/src-tauri/src/config/favorites_preferences.rs +++ b/src-tauri/src/config/favorites_preferences.rs @@ -75,15 +75,15 @@ impl FavoritesPreferencesStore { } fn favorites_icon_dir() -> Result { - let data_dir = dirs::data_dir() - .ok_or("Could not determine data directory")? + let cache_dir = dirs::cache_dir() + .ok_or("Could not determine cache directory")? .join("qbz") .join("favorites"); - fs::create_dir_all(&data_dir) + fs::create_dir_all(&cache_dir) .map_err(|e| format!("Failed to create favorites icon directory: {}", e))?; - Ok(data_dir) + Ok(cache_dir) } fn normalize_custom_icon_path(&self, path: String) -> Result { @@ -155,7 +155,28 @@ impl FavoritesPreferencesStore { }); match result { - Ok(prefs) => Ok(prefs), + Ok(mut prefs) => { + if let Some(path) = prefs.custom_icon_path.clone() { + match self.normalize_custom_icon_path(path) { + Ok(resolved) => { + let normalized = if resolved.trim().is_empty() { + None + } else { + Some(resolved) + }; + if normalized != prefs.custom_icon_path { + prefs.custom_icon_path = normalized; + let _ = self.save_preferences(prefs.clone()); + } + } + Err(_) => { + prefs.custom_icon_path = None; + let _ = self.save_preferences(prefs.clone()); + } + } + } + Ok(prefs) + } Err(rusqlite::Error::QueryReturnedNoRows) => Ok(FavoritesPreferences::default()), Err(e) => Err(format!("Failed to query preferences: {}", e)), }