Commit Graph
436 Commits
Author SHA1 Message Date
vicrodh 4548845fbf fix(notification): fail silently when notification system unavailable
Systems without a notification daemon (e.g., minimal Linux setups) would
crash when the app tried to show notifications. Now we log a warning and
continue instead of propagating the error.

Fixes #32
2026-02-01 04:35:59 -06:00
vicrodh 90e4216826 Merge feature/immersive-player into pre-release 2026-02-01 04:31:59 -06:00
vicrodh 52bde38d9f fix(audio): return format_id from play_track and set device name for backend system
1. play_track now returns PlayTrackResult with format_id from Qobuz API
   - Returns actual format (5=MP3, 6=FLAC16, 7=FLAC24, 27=Hi-Res)
   - Returns None for cache hits (format unknown)

2. Frontend updates track.format based on format_id
   - QualityBadge can now correctly show "MP3" when format_id=5
   - Previously badge showed "CD" even for MP3 because format was empty

3. Device name now set after backend system init
   - PipeWire and ALSA backends now set current_device from settings
   - Fixes tooltip showing no device when using backend system
2026-02-01 04:27:23 -06:00
vicrodh ba4c969570 fix(playback): respect streaming_only setting in prefetch
When streaming_only is enabled, prefetch is now skipped entirely.
This ensures tracks are always streamed fresh from the network
without being pre-cached in the background.

When streaming_only is disabled, prefetch works normally.
2026-02-01 03:55:16 -06:00
vicrodh d33ea8b69e feat(playback): add detailed logging for cache vs streaming behavior
Logs now clearly show:
- [CACHE HIT] when playing from memory/disk/offline cache
- [STREAMING] when streaming from network with cache_after flag
- [DOWNLOAD] when using full download mode
- [CACHED] / [NOT CACHED] after download completes
- [Playback Settings] shows stream_first, streaming_only, buffer values
2026-02-01 03:49:37 -06:00
vicrodh f699cf0e63 fix(search): resolve notification loops causing multiple API requests
- Make auth_token() public for catalog/search endpoint authentication
- Fix setSearchQuery to skip notification when value unchanged
- Fix setSearchState to only notify listeners when query actually changed
- Add title case transformation for better most_popular API results
- Add stale result detection to ignore outdated search responses
- Preserve most_popular when API returns inconsistent results
- Clean up debug logging
2026-02-01 02:41:55 -06:00
vicrodh d8bd93374f feat(search): use Qobuz API most_popular field directly
Replace heuristic-based most popular detection with Qobuz's actual
most_popular field from the catalog/search endpoint.

- Add CATALOG_SEARCH endpoint path
- Make app_id() and get_http() public on QobuzClient
- Add MostPopularItem enum with tagged serialization (artists/albums/tracks)
- Update search_all to use catalog/search and parse most_popular field
- Update SearchView template to use allResults.most_popular with new types
- Add MostPopularItem type to searchState store
2026-02-01 01:33:17 -06:00
vicrodh b4944aa527 feat(audio): add streaming-only mode backend
Add streaming_only setting that skips L1+L2 cache writes while still
respecting offline cache (local-first). When enabled:
- download_and_stream() skips final cache.insert()
- Standard download path skips cache.insert()
- Offline cache continues to work normally

This reduces storage usage for users who prefer pure streaming.
2026-02-01 00:37:26 -06:00
vicrodh ae81b1c3c4 Fix quality setting and device name display issues (#34)
- Clear both L1 memory and L2 disk caches when quality setting changes
  This ensures cached tracks at wrong quality are removed
- Fix device name not showing in popup on first hover
  Now refreshes status on each hover instead of only when null
- Add quality downgrade indicator when stream quality is lower than
  track's original quality (shows yellow arrow with tooltip)
- Store original track quality values for comparison with actual stream
2026-01-31 23:46:02 -06:00
vicrodh 8b7e4dab27 feat: show actual stream quality in player UI
Issue #34 - Display actual stream quality, not track metadata

Backend changes:
- Add sample_rate and bit_depth to PlaybackEvent
- Add stream quality tracking to SharedState
- Extract bit_depth from FLAC/M4A headers in streaming path
- Player sets stream quality when decoding audio

Frontend changes:
- Update PlaybackEvent interface with new fields
- Update currentTrack with actual stream quality from backend

This allows the UI to show the actual quality being played (e.g., 44.1kHz
when streaming a 192kHz track at CD Quality) instead of the track's
maximum advertised quality.
2026-01-31 23:32:29 -06:00
vicrodh f83eed1076 debug: add quality logging to diagnose issue #34
- Log requested vs returned format_id and sample_rate in get_stream_url_with_fallback
- Log quality_str, parsed quality, and format_id in play_track and prefetch_track commands
- Add console.log in getStreamingQuality for frontend debugging

This will help diagnose why 192kHz is played despite lower quality settings.
2026-01-31 20:54:05 -06:00
vicrodh 011ee02ec9 Merge pre-release into feature/immersive-player
Resolved conflicts:
- src-tauri/src/api/client.rs: Keep TrackUnavailable error handling
- i18n files: Combined immersive player keys with trackUnavailable key
2026-01-31 17:19:03 -06:00
vicrodh e68c3128b6 feat: auto-skip unavailable tracks with user-friendly error
Backend:
- Add TrackUnavailable error type for tracks removed from Qobuz
- Validate stream URL response - detect missing URL with restrictions
- Add SampleRestrictedByRightHolders to restriction check
- Return specific error when track is unavailable vs quality unavailable

Frontend:
- Detect track unavailable errors in playTrack()
- Show friendly toast: Track title is no longer available
- Auto-skip to next track in queue after 500ms delay
- Add i18n translations (en/es) for trackUnavailable message
2026-01-31 16:10:26 -06:00
vicrodh 1483c05913 Fix: Validate stream URL response before making HEAD request
- Add validation to check if URL is empty before returning StreamUrl
- Add debug logging for JSON response keys
- Return proper error instead of silently using empty URL
- This prevents 'builder error' from HEAD request to empty URL
2026-01-31 15:58:36 -06:00
vicrodh 5ecf9ce24f Fix intermittent HEAD request builder error in streaming playback
- Use lazy_static to create a single reusable HTTP client instead of
  creating a new client for each stream info request
- Add retry logic (3 attempts with 100ms delay) to handle transient
  network/TLS initialization failures
- This fixes 'Failed HEAD request: builder error' toasts that required
  pressing play button twice
2026-01-31 15:54:57 -06:00
vicrodh 14f0cae1c1 feat(suggestions): major UX overhaul with popular tracks fallback
Backend:
- Add get_artist_tracks command for fetching artist's popular tracks

Frontend:
- Fallback to artist's popular tracks when tracks_appears_on is sparse
- Remove card hover movement, only image moves up on hover
- Add hover overlay with (add to queue) (play) (play next) buttons
- Use playlist.svg icon for playlist cards and glyph
- Radio glyph shown by default, replaced by action buttons on hover
- Fix icon sizes: QBZ (22px) vs Qobuz (18px) for visual balance
- Track playlist.svg asset
2026-01-31 14:48:26 -06:00
vicrodh d495c43c39 Revert "feat(visualizer): real-time audio FFT visualization"
This reverts commit 16b35c33fd.
2026-01-30 22:29:05 -06:00
vicrodh 7e17b74f99 fix(visualizer): improve responsiveness and visibility
- Increase FFT emit rate: ~21fps → ~60fps (interval 2048 → 735 samples)
- Boost scale factor: 4x → 50x for more visible response
- Gentler log mapping: powf(2.0) → powf(1.4) for better spread across bars
- Faster smoothing: attack 0.7→0.85, decay 0.15→0.5
- Faster CSS transitions: 80ms → 35ms
- Solid colors instead of gradients for better visibility
2026-01-30 22:20:11 -06:00
vicrodh 16b35c33fd feat(visualizer): real-time audio FFT visualization
Backend (Rust):
- Add rustfft crate for Fast Fourier Transform
- Create visualizer module with FFT computation (1024 samples, Hann window)
- VisualizerSource wrapper taps into audio stream without modifying playback
- Logarithmic frequency bin mapping for perceptual accuracy
- Emit audio-spectrum events to frontend (~20-30fps)
- Tauri commands: set_visualizer_enabled, get_visualizer_enabled

Frontend (Svelte):
- CSS-based rendering (GPU accelerated via transform/transition)
- Three visualization modes: bars, wave, mirror
- Dynamic colors extracted from album artwork
- Listens to audio-spectrum Tauri events
- ~0% CPU usage (GPU handles all transforms)
2026-01-30 21:51:25 -06:00
vicrodh 3926209b0d fix(auth): persist ToS acceptance in Rust/SQLite backend
ToS acceptance was stored in localStorage which gets cleared on app
updates, causing users to re-login frequently. Now stores ToS state
in SQLite (~/.local/share/qbz/legal_settings.db) which survives
updates.

- Add legal_settings.rs with SQLite storage for ToS acceptance
- Update qobuzLegalStore.ts to use Rust invoke commands
- LoginView now loads ToS from Rust before auto-login check
- Migration from localStorage for existing users

Closes #31
2026-01-30 14:49:39 -06:00
vicrodh 5b03af41bc feat(audio): add alsa-utils help modal with distro-specific install commands
- Add check_alsa_utils_installed and get_linux_distro Tauri commands
- Detect Linux distribution from /etc/os-release
- Show appropriate package manager command for each distro
- Add (?) help icon next to ALSA Direct device dropdown in Settings
- Modal explains why alsa-utils is needed for bit-perfect detection
- Updated PKGBUILDs to list alsa-utils as optdepend
2026-01-30 11:43:34 -06:00
vicrodh 2838b25738 Replace 'Downloading' with 'Caching' in logs 2026-01-30 11:37:55 -06:00
vicrodh f67b13e27e Add grouped device dropdown for PipeWire with USB/HDMI categorization
Backend changes:
- Add device_bus and is_hardware fields to AudioDevice
- Parse PipeWire Flags (HARDWARE) and device.bus property from pactl output

Frontend changes:
- DeviceDropdown now supports both ALSA and PipeWire backends
- ALSA grouping: Defaults, Bit-perfect, Plugin Hardware, Other
- PipeWire grouping: Defaults, USB Audio (BP capable), HDMI/DisplayPort, Other HW, Virtual
- BP badge shown for USB Audio devices in PipeWire mode
2026-01-30 11:18:09 -06:00
vicrodh 0ccdd9981f Add supported sample rates detection and display for ALSA devices
Backend changes:
- Add supported_sample_rates field to AudioDevice struct
- Detect common audio sample rates (44.1, 48, 88.2, 96, 176.4, 192, 352.8, 384 kHz)
- Use CPAL's supported_output_configs() to check rate support for hw: devices

Frontend changes:
- Display sample rates as subtitle in DeviceDropdown (e.g., "44.1, 48, 96, 192 kHz")
- Only shown for bit-perfect devices where detection is available
- Search not sensitive to sample rates field (per user request)
2026-01-30 11:11:05 -06:00
vicrodh 10788f877f feat(tracks): add streamable field infrastructure for unavailable tracks
Adds streamable field throughout the stack to detect tracks that have
been removed from Qobuz but still appear in playlists/favorites:

Backend (Rust):
- QueueTrack: add streamable field with default true
- PersistedQueueTrack: add streamable for session persistence
- radio.rs: log warning when non-streamable track is encountered

Frontend:
- BackendQueueTrack: add streamable? field
- QobuzTrack, Track, PlaylistTrack types: add streamable
- qobuzAdapters.ts: include streamable in track conversions
- trackActions.ts: all queue builders now include streamable
- +page.svelte: debug logging includes streamable field

This prepares the infrastructure for graying out unavailable tracks
in the UI (to be implemented when we can reproduce the issue).

Refs: User report about "Failed to fetch audio" for removed tracks
2026-01-29 22:50:02 -06:00
vicrodh 4c606e029e feat(favorites): implement local SQLite persistence for favorites
This ensures favorites sync properly across all views (album detail,
continue listening, etc.) by using local persistence as the source
of truth for UI, with API calls for actual operations.

Backend (Rust):
- Add favorites_cache.rs module with SQLite tables:
  - favorite_tracks (track_id INTEGER PRIMARY KEY)
  - favorite_albums (album_id TEXT PRIMARY KEY)
  - favorite_artists (artist_id INTEGER PRIMARY KEY)
- Add Tauri commands for cache operations:
  - get_cached_favorite_* - read from local cache
  - cache_favorite_* / uncache_favorite_* - add/remove single items
  - sync_cached_favorite_* - bulk sync from API data
  - clear_favorites_cache - for logout

Frontend:
- Rewrite favoritesStore.ts to use persistence:
  - loadFavorites(): Load from cache first, then sync from API
  - toggleFavorite(): API call first → update cache on success
  - No optimistic updates - UI shows loading state until confirmed
- Rewrite albumFavoritesStore.ts with same pattern
- Create artistFavoritesStore.ts for artist favorites
- Update +page.svelte to load all favorites on login
- Update FavoritesView to sync cache when loading from API

Sync strategy:
- On login: Fetch from Qobuz API → sync to local cache
- On toggle: API call → on success → update local cache → notify UI
- FavoritesView reads from API and syncs local cache
- All other views read from local cache (instant UI)
2026-01-29 19:42:04 -06:00
vicrodh 19d84326b8 fix: enable resume for streaming tracks
Previously, streaming tracks could not be resumed after pause timeout
because current_audio_data was never set for streaming playback.

Changes:
- Store BufferedMediaSource in current_streaming_source for streaming tracks
- On resume, check if streaming source has complete data and use it
- Clear streaming source on Stop and when switching to non-streaming play
- Log buffered bytes when streaming not complete yet

This allows users to pause streaming tracks and resume them after the
download completes, instead of getting "no audio data available" error.
2026-01-29 11:23:58 -06:00
vicrodh 56faddf2dc chore: update app logo to v3
New logo design with vinyl/gear motif, replacing old GPT-generated logo.
Updated all icon sizes for Tauri, Windows Store, favicon, and static assets.
2026-01-29 01:22:05 -06:00
vicrodh 7ed3dac7f5 fix(library): reduce artwork cache bloat with thumbnails
- metadata.rs now creates 500px thumbnails instead of copying full images
- Added cache management commands: library_get_cache_stats,
  library_clear_artwork_cache, library_clear_thumbnails_cache
- Thumbnails stored in ~/.local/share/qbz/thumbnails/ (was ~/.cache/qbz/artwork)
- Reduces cache size from GB to MB for large libraries
2026-01-28 11:24:19 -06:00
vicrodh a6fc264903 fix(playback): persist streaming quality setting
Quality was hardcoded to UltraHiRes in backend. Now:
- Frontend passes quality from localStorage to play_track command
- Backend parses quality string to Quality enum
- All prefetch and stream URL calls use the user's preferred quality
2026-01-28 11:24:11 -06:00
vicrodh 700dc07014 fix(library): improve artist consolidation and album matching
- Add all_artists field to LocalAlbum for accurate artist matching
- Consolidate duplicate artists with case differences (e.g., "Alice in Chains" / "Alice In Chains")
- Fix album count calculation to avoid double-counting
- Show Various Artists albums under contributing artists
- Handle multi-artist names (e.g., "A, B, C") with union matching
- Add cleanup missing files feature in settings maintenance section
- Improve settings UI with side-by-side Maintenance/Danger Zone layout
- Add status indicator during cleanup operations
2026-01-28 08:13:07 -06:00
vicrodh e8f0c96ccc feat(library): add source badge to album cards in Local Library
Albums now show a small badge indicating their source:
- HardDrive icon for local files (source='user')
- Qobuz logo for offline cached content (source='qobuz_download')

Badge appears in bottom-right corner of album artwork.
2026-01-28 02:40:00 -06:00
vicrodh a483c766ab fix(offline): clean up empty folders when removing cached tracks
When deleting a cached track (individually, via clear all, or via LRU
eviction), the audio file was deleted but cover.jpg remained orphaned.

Now the system removes the entire album folder if no audio files remain,
and recursively removes the artist folder if it also becomes empty.
2026-01-27 19:36:15 -06:00
vicrodh fab1ff3003 fix(suggestions): wrap artist_id in Some for Option type 2026-01-27 17:13:03 -06:00
vicrodh 79c68d292e feat(suggestions): improve vector store and add cache management
- Add get_all_related_artists for direct relationship lookup
- Add get_related_artists helper method
- Add clear_all method to vector store for cache management
- Add clear_vector_store Tauri command
- Add Artist Vectors cache section to Settings view
- Use artist_info tuples (mbid, name) for better track searching
2026-01-27 16:54:11 -06:00
vicrodh 9a89074b5f feat(suggestions): add interactive navigation and track info modal
- Add artist_id field to SuggestedTrack for navigation
- Make artist names clickable to navigate to artist view
- Make album names clickable to navigate to album view
- Add TrackInfo button (info icon) to view track credits
- Integrate TrackInfoModal component with suggestions
- Update PlaylistDetailView to pass navigation callbacks
2026-01-27 16:53:56 -06:00
vicrodh 54315c2e4e fix(suggestions): fix deadlock in build_vector
The build_vector function was calling build_from_musicbrainz and
build_from_qobuz while holding the store lock. These functions also
try to acquire the store lock, causing a deadlock.

Fixed by saving the vectors from the first call and reusing them
for storage, instead of calling the functions again.
2026-01-27 14:42:10 -06:00
vicrodh 7e76fd6925 debug: add info-level logging to build_from_musicbrainz 2026-01-27 14:22:40 -06:00
vicrodh d90edc4feb debug(suggestions): add more logging to find deadlock 2026-01-27 13:40:17 -06:00
vicrodh 5f13617ae7 debug(suggestions): add logging to vector building
Added info-level logs to track:
- ensure_vector start/success/failure
- build_from_musicbrainz cache hit/API fetch
2026-01-27 13:35:18 -06:00
vicrodh 12d3c6b654 style: remove emojis from log messages 2026-01-27 13:26:57 -06:00
vicrodh b551df71c0 perf(suggestions): limit to top 5 artists and reduce rate limiting
Major optimizations:
- Extract only top 5 artists by track frequency instead of all artists
- Use faster rate limiter (200ms) when using MusicBrainz proxy
- Remove skip_vector_build since we now have manageable artist count

Expected load time: ~5-8 seconds for first load with 5 artists
vs previous: 50+ seconds with 50 artists
2026-01-27 13:20:16 -06:00
vicrodh a49cdf483a perf(suggestions): skip MusicBrainz API calls when skip_vector_build=true
When skip_vector_build is enabled, also skip network calls for MBID
resolution of uncached artists. This prevents rate limiting (429) errors
that were causing 55+ second delays on initial load.

Tradeoff: First load with empty cache may have no results, but
subsequent loads will be instant using cached data.
2026-01-27 12:31:51 -06:00
vicrodh ff9e11db5c perf(suggestions): add skip_vector_build option for faster initial load
- Add skip_vector_build config option to SuggestionConfig
- When true, skips ensure_vector calls (which can be very slow)
- Uses only cached/existing vectors for similarity search
- Frontend now uses skip_vector_build=true for initial load

- Add timestamped logging helper in frontend component
2026-01-27 12:23:05 -06:00
vicrodh 541c93f06d fix(suggestions): fix config deserialization and effect loop
- Add #[serde(default)] to SuggestionConfig to allow partial config
  from frontend (fixes "missing field max_artists" error)

- Fix effect loop in PlaylistSuggestions.svelte:
  - Add loadingInitiated flag to prevent re-triggering
  - Add cleanup effect when playlistId changes
  - Prevent concurrent loading attempts
2026-01-27 12:07:08 -06:00
vicrodh 1560cd4e3d debug(suggestions): add detailed timing logs for debugging
Frontend logging:
- Log when effect triggers with artist count
- Log when backend call starts/finishes with timing
- Log result details (tracks, artists counts)

Backend logging (playlist_suggestions.rs):
- Log MBID resolution with cache hits/misses/failures
- Log config values
- Log engine call timing

Engine logging (suggestions.rs):
- Step 1: ensure_vector timing per artist
- Step 2: playlist vector computation
- Step 3: find_nearest timing
- Step 4: track search timing per artist
- Early exit when pool size reached
2026-01-27 12:02:31 -06:00
vicrodh e9a5dfcb80 perf(suggestions): optimize loading with backend MBID resolution
- Move MBID resolution from frontend to backend
  - Eliminates multiple sequential IPC calls
  - Uses MusicBrainz cache for faster resolution
  - Logs resolution progress for debugging

- Implement progressive loading in UI
  - Initial load: 18 tracks (3 pages)
  - "Load more" expands to 60 tracks on demand
  - Better feedback during loading states

- Fix refresh button styling
  - Remove background while spinning
  - Update title based on available actions

- Add "Load more" link in pagination area
2026-01-27 11:58:54 -06:00
vicrodh cadb346e32 feat(suggestions): add vector-based playlist suggestions engine
- Add suggestions.rs with SuggestionsEngine for generating suggestions
- Add SuggestionConfig with configurable parameters
- Add SuggestedTrack and SuggestionResult types
- Integrate with MusicBrainz relationships and Qobuz track search
- Add Tauri commands: get_playlist_suggestions_v2, get_vector_store_stats
- Add cleanup_vector_store command for maintenance
- Add Serialize to StoreStats for IPC
- Register ArtistVectorStoreState in app initialization
- 23 tests passing
2026-01-27 11:38:56 -06:00
vicrodh f3dcb6ebf2 feat(vectors): add vector builder with MB and Qobuz sources
- Add weights.rs with configurable RelationshipWeights
- Add builder.rs with ArtistVectorBuilder for constructing vectors
- Integrate MusicBrainz relationships (members, groups, collaborators)
- Integrate Qobuz similar artists API
- Add ensure_vector() with TTL for lazy building
- Add resolve_qobuz_to_mbid() for ID resolution via name search
- 21 tests passing (sparse_vector, store, weights, builder)
2026-01-27 11:30:06 -06:00
vicrodh 1d2e28c1a8 feat(vectors): add sparse vector foundation for playlist suggestions
Phase 1 of playlist-suggestions feature:
- SparseVector: memory-efficient vector with math operations
  - set/get with sorted indices for O(log n) access
  - add, sub, scale, dot product, magnitude
  - normalize, cosine_similarity, top_k_similar
- ArtistVectorStore: SQLite persistence
  - artist_index table: MBID to integer index mapping
  - vector_entries table: sparse representation (one row per non-zero)
  - vector_metadata table: track freshness with TTL
  - find_nearest: cosine similarity search with exclusion
- 17 unit tests all passing
2026-01-27 11:19:55 -06:00