From f746fb4fc43874a022cf0b649b5417ffd803bfdf Mon Sep 17 00:00:00 2001 From: BoulderBadgeDad Date: Mon, 29 Jun 2026 10:03:14 -0700 Subject: [PATCH] fix(#947): poll ALL staging queries while scanning, not just files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Re-review caught a real bug in the phase-2 polling: it refetched only the files query, but the album import tab uses its OWN groups query (album-import-tab.tsx). So after a large-folder scan completed, the album tab would stay stuck on its initial {scanning} response and never populate (the singles tab was fine — it reads the polled files query). Switched the scan poll to invalidateImportStagingQueries (files + groups + suggestions) so every mounted staging query refetches when the scan finishes. (Suggestions is already async/cached, so it just no-ops.) typecheck clean, scanning test still passes. --- webui/src/routes/import/-ui/import-shared.tsx | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/webui/src/routes/import/-ui/import-shared.tsx b/webui/src/routes/import/-ui/import-shared.tsx index fba4e240..f45656c6 100644 --- a/webui/src/routes/import/-ui/import-shared.tsx +++ b/webui/src/routes/import/-ui/import-shared.tsx @@ -22,19 +22,20 @@ export function useImportStaging() { }); // A large staging folder (whole-library migration, #947) is scanned in the background; the - // endpoint returns `scanning: true` until it's done. While scanning, poll so the page fills - // in automatically once the scan completes. A plain setInterval (NOT react-query's - // refetchInterval, which interferes with the data query's error/retry settling) that only - // runs while scanning, so the normal and error states are left completely untouched. + // endpoints return `scanning: true` until it's done. While scanning, poll so the page fills + // in automatically once the scan completes. Invalidate ALL staging queries (files, groups, + // suggestions) — not just files — so the album tab's separate groups query refetches too, + // otherwise it would stay stuck on its initial {scanning} response. A plain setInterval (NOT + // react-query's refetchInterval) that only runs while scanning leaves normal/error states + // untouched; only currently-mounted queries actually refetch. const scanning = stagingQuery.data?.scanning === true; - const { refetch } = stagingQuery; useEffect(() => { if (!scanning) return undefined; const id = window.setInterval(() => { - void refetch(); + void invalidateImportStagingQueries(queryClient); }, 1500); return () => window.clearInterval(id); - }, [scanning, refetch]); + }, [scanning, queryClient]); return { refreshStaging: async () => {