diff --git a/src-tauri/src/commands/notification.rs b/src-tauri/src/commands/notification.rs index 81c0fec83..82f5d15ad 100644 --- a/src-tauri/src/commands/notification.rs +++ b/src-tauri/src/commands/notification.rs @@ -76,13 +76,24 @@ fn resolve_local_artwork(url: &str) -> Option { } /// Format quality info for notification -fn format_quality(bit_depth: Option, sample_rate: Option) -> String { +fn format_quality(bit_depth: Option, sample_rate: Option) -> String { match (bit_depth, sample_rate) { - (Some(bits), Some(rate)) if bits >= 24 || rate > 48 => { - format!("Hi-Res • {}-bit/{}kHz", bits, rate) + (Some(bits), Some(rate)) if bits >= 24 || rate > 48.0 => { + // Format sample rate: 44.1 → 44.1, 48.0 → 48, 192.0 → 192 + let rate_str = if rate.fract() == 0.0 { + format!("{}", rate as u32) + } else { + format!("{}", rate) + }; + format!("Hi-Res • {}-bit/{}kHz", bits, rate_str) } (Some(bits), Some(rate)) => { - format!("CD Quality • {}-bit/{}kHz", bits, rate) + let rate_str = if rate.fract() == 0.0 { + format!("{}", rate as u32) + } else { + format!("{}", rate) + }; + format!("CD Quality • {}-bit/{}kHz", bits, rate_str) } _ => String::new() } @@ -96,7 +107,7 @@ pub fn show_track_notification( album: String, artwork_url: Option, bit_depth: Option, - sample_rate: Option, + sample_rate: Option, // Changed from u32 to f64 to support 44.1, 88.2, 176.4, etc. ) -> Result<(), String> { log::info!("Command: show_track_notification - {} by {}", title, artist); diff --git a/src-tauri/src/queue/mod.rs b/src-tauri/src/queue/mod.rs index a1c8e3d7b..a0da14f07 100644 --- a/src-tauri/src/queue/mod.rs +++ b/src-tauri/src/queue/mod.rs @@ -164,6 +164,29 @@ impl QueueManager { // Regenerate shuffle order Self::regenerate_shuffle_order_internal(&mut state); + + // CRITICAL FIX: When shuffle is enabled and we have a start_index, + // ensure the start_index track is at the BEGINNING of shuffle order + // This fixes the bug where shuffle shows incomplete queue + if state.shuffle { + if let Some(start_idx) = start_index { + if start_idx < state.tracks.len() { + // Find where start_idx is in the current shuffle_order + if let Some(pos) = state.shuffle_order.iter().position(|&x| x == start_idx) { + // Move it to the front by swapping + state.shuffle_order.swap(0, pos); + // Set shuffle position to 0 so we start from the beginning + state.shuffle_position = 0; + + log::info!( + "Queue: Adjusted shuffle order to start with track index {} (was at position {})", + start_idx, + pos + ); + } + } + } + } } /// Clear the queue diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index ed274e585..e1043f8f7 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -1363,7 +1363,8 @@ async function handleLocalTrackPlay(track: LocalLibraryTrack) { console.log('Playing local track:', track); - await clearPlaybackContext(); + // DO NOT clear context - LocalLibraryView already sets it correctly + // await clearPlaybackContext(); const artwork = track.artwork_path ? convertFileSrc(track.artwork_path) : ''; const quality = track.bit_depth && track.sample_rate