From 43135865e29a1d3194f2416018694efaeb11b44d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Padez?= Date: Mon, 27 Jul 2026 15:15:35 +0000 Subject: [PATCH] music indexer: 3s progress heartbeat log during a build A long full rebuild logged only "resync started" then nothing until "done". Add a console heartbeat (throttled to 3s, piggybacked on emitProgress) showing folders/built/skipped/tracks/videos/posters/lyrics counts + the current path, so progress is visible in the pm2 logs. Co-Authored-By: Claude Opus 4.8 --- src/servers/sidecar/music/indexer.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/servers/sidecar/music/indexer.ts b/src/servers/sidecar/music/indexer.ts index ddc9fba3..9a2cb440 100644 --- a/src/servers/sidecar/music/indexer.ts +++ b/src/servers/sidecar/music/indexer.ts @@ -202,6 +202,7 @@ export function buildReport(s: IndexStatus = status): IndexReport { type ProgressListener = (s: IndexStatus) => void; const listeners = new Set(); let lastEmit = 0; +let lastLog = 0; export function onIndexProgress(cb: ProgressListener): () => void { listeners.add(cb); @@ -211,6 +212,15 @@ export function onIndexProgress(cb: ProgressListener): () => void { /** Notify subscribers of progress; throttled to ~200ms unless `force` (e.g. terminal 'done'). */ function emitProgress(force = false): void { const now = Date.now(); + // Console heartbeat (throttled to 3s, independent of the SSE cadence) so a long build shows life. + if (now - lastLog >= 3000) { + lastLog = now; + console.log( + `[music] … ${status.foldersScanned} folders · ${status.albumsBuilt} built/${status.albumsSkipped} skipped · ` + + `${status.tracksIndexed} tracks · ${status.videosIndexed} videos · ${status.postersSaved} posters · ` + + `${status.lyricsIndexed} lyrics — ${status.currentPath}`, + ); + } if (!force && now - lastEmit < 200) return; lastEmit = now; const snap = getIndexStatus();