From 916b4c145a367a25a51f39ef780589728446dfd7 Mon Sep 17 00:00:00 2001 From: vicrodh <103399283+vicrodh@users.noreply.github.com> Date: Fri, 6 Feb 2026 08:25:21 -0600 Subject: [PATCH] debug: add aggressive logging to home loading flow (#43) Log every decision point in loadHome(): - totalVisibleSections count - mlPromise invoke/resolve/reject with seed counts - fetchDiscoverData invoke/result with container keys - checkAllSectionsReady transition with hasContent/error state - catch block entry (which blocks all content rendering) Backend: reco_get_home_ml logs call, success with counts, and explicit error when RecoState.db is None. --- src-tauri/src/reco_store/commands.rs | 15 +++++++++++++- src/lib/components/views/HomeView.svelte | 26 ++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/src-tauri/src/reco_store/commands.rs b/src-tauri/src/reco_store/commands.rs index b2670c226..3c75d692e 100644 --- a/src-tauri/src/reco_store/commands.rs +++ b/src-tauri/src/reco_store/commands.rs @@ -146,13 +146,17 @@ pub async fn reco_get_home_ml( limit_favorites: Option, state: State<'_, RecoState>, ) -> Result { + log::info!("[DEBUG-43] reco_get_home_ml called"); let limit_recent_albums = limit_recent_albums.unwrap_or(12); let limit_continue_tracks = limit_continue_tracks.unwrap_or(10); let limit_top_artists = limit_top_artists.unwrap_or(10); let limit_favorites = limit_favorites.unwrap_or(12); let guard__ = state.db.lock().await; - let db = guard__.as_ref().ok_or("No active session - please log in")?; + let db = guard__.as_ref().ok_or_else(|| { + log::error!("[DEBUG-43] reco_get_home_ml FAILED: No active session (RecoState.db is None)"); + "No active session - please log in".to_string() + })?; let has_scores = db.has_scores("all")?; // HYBRID APPROACH: Always get fresh recent plays first, then supplement with scored @@ -217,6 +221,15 @@ pub async fn reco_get_home_ml( favorite_track_ids = db.get_favorite_track_ids(limit_favorites)?; } + log::info!( + "[DEBUG-43] reco_get_home_ml OK: recent_albums={}, continue_tracks={}, top_artists={}, fav_albums={}, fav_tracks={}", + recently_played_album_ids.len(), + continue_listening_track_ids.len(), + top_artist_ids.len(), + favorite_album_ids.len(), + favorite_track_ids.len() + ); + Ok(HomeSeeds { recently_played_album_ids, continue_listening_track_ids, diff --git a/src/lib/components/views/HomeView.svelte b/src/lib/components/views/HomeView.svelte index 18bbd4524..1d3562245 100644 --- a/src/lib/components/views/HomeView.svelte +++ b/src/lib/components/views/HomeView.svelte @@ -319,10 +319,17 @@ // Check if all visible sections have finished loading function checkAllSectionsReady() { if (sectionsFinished >= totalVisibleSections && totalVisibleSections > 0 && isOverlayVisible) { + console.warn(`[DEBUG-43] ALL SECTIONS READY (${sectionsFinished}/${totalVisibleSections}), removing overlay in 150ms`); // Small delay to ensure DOM has rendered, then fade out setTimeout(() => { isOverlayVisible = false; isInitializing = false; + console.warn('[DEBUG-43] Overlay removed. hasContent =', + newReleases.length > 0 || pressAwards.length > 0 || mostStreamed.length > 0 || + qobuzissimes.length > 0 || editorPicks.length > 0 || recentAlbums.length > 0 || + continueTracks.length > 0 || topArtists.length > 0 || favoriteAlbums.length > 0 || + qobuzPlaylists.length > 0 || essentialDiscography.length > 0, + 'error =', error); }, 150); // Enable deferred sections after a short delay using requestIdleCallback @@ -658,11 +665,14 @@ async function fetchDiscoverData() { try { + console.warn('[DEBUG-43] fetchDiscoverData: invoking get_discover_index...'); const response = await invoke('get_discover_index', { genreIds: null }); + console.warn('[DEBUG-43] fetchDiscoverData: response received, containers:', Object.keys(response.containers || {})); // Extract playlists (limited) - initial load without tag filter if (response.containers.playlists?.data?.items) { qobuzPlaylists = response.containers.playlists.data.items.slice(0, LIMITS.qobuzPlaylists); + console.warn('[DEBUG-43] fetchDiscoverData: playlists =', qobuzPlaylists.length); } // Extract playlist tags @@ -673,6 +683,7 @@ // Extract essential discography (limited) if (response.containers.ideal_discography?.data?.items) { essentialDiscography = response.containers.ideal_discography.data.items.slice(0, LIMITS.essentialDiscography); + console.warn('[DEBUG-43] fetchDiscoverData: essentialDiscography =', essentialDiscography.length); } loadingQobuzPlaylists = false; @@ -685,7 +696,7 @@ markSectionFinished(); } } catch (err) { - console.error('Failed to fetch discover data:', err); + console.error('[DEBUG-43] fetchDiscoverData FAILED:', err); loadingQobuzPlaylists = false; loadingEssentialDiscography = false; // Still mark sections as finished even on error @@ -728,8 +739,10 @@ if (isSectionVisible('favoriteAlbums')) totalVisibleSections++; if (isSectionVisible('qobuzPlaylists')) totalVisibleSections++; if (isSectionVisible('essentialDiscography')) totalVisibleSections++; + console.warn('[DEBUG-43] loadHome: totalVisibleSections =', totalVisibleSections); // Start ML data loading FIRST (local SQLite) - this gets the seeds + console.warn('[DEBUG-43] loadHome: invoking reco_get_home_ml...'); const mlPromise = invoke('reco_get_home_ml', { limitRecentAlbums: homeLimits.recentAlbums, limitContinueTracks: homeLimits.continueTracks, @@ -833,6 +846,13 @@ try { // Wait for ML seeds (local data) const seeds = await mlPromise; + console.warn('[DEBUG-43] mlPromise resolved:', { + recentAlbums: seeds.recentlyPlayedAlbumIds?.length ?? 0, + continueTracks: seeds.continueListeningTrackIds?.length ?? 0, + topArtists: seeds.topArtistIds?.length ?? 0, + favoriteAlbums: seeds.favoriteAlbumIds?.length ?? 0, + favoriteTracks: seeds.favoriteTrackIds?.length ?? 0, + }); // Load ML-based sections in parallel // Continue Listening (tracks) @@ -915,7 +935,9 @@ } } catch (err) { - console.error('Failed to load home data:', err); + console.error('[DEBUG-43] mlPromise FAILED — catch block entered:', err); + console.error('[DEBUG-43] This sets error= which BLOCKS all content rendering.'); + console.error('[DEBUG-43] Featured album sections already in flight will finish but be invisible.'); error = String(err); isInitializing = false; isOverlayVisible = false;