From fa750b6e89240c97e26aa35b4209dd36b2686981 Mon Sep 17 00:00:00 2001 From: BoulderBadgeDad Date: Sat, 30 May 2026 15:34:34 -0700 Subject: [PATCH] Search: bump live-search debounce 300ms -> 600ms (#751) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reporter (Vicky-2418) saw the artist search fire a separate external-API search for nearly every letter typed. There WAS a 300ms debounce, but that's short enough that a deliberately-typed name lands a keystroke per debounce window, so each letter kicked off (and aborted) a fresh search — noisy in the logs and wasteful. Bumped both live-search surfaces that drive the shared SearchController (external metadata APIs) to 600ms: the /search enhanced input (search.js) and the global-search widget (downloads.js). 600ms coalesces a name being typed into one search after the user pauses, while still feeling live. Enter still triggers an immediate search on both (existing keypress/keydown handlers), and the per-change abort already cancels stale in-flight fetches. Frontend-only; both files syntax-clean. --- webui/static/downloads.js | 5 ++++- webui/static/search.js | 7 +++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/webui/static/downloads.js b/webui/static/downloads.js index 39f0cf5a..2681da13 100644 --- a/webui/static/downloads.js +++ b/webui/static/downloads.js @@ -5658,7 +5658,10 @@ let _gsController = null; if (clearBtn) clearBtn.style.display = q.length > 0 ? '' : 'none'; if (_gsState.debounceTimer) clearTimeout(_gsState.debounceTimer); if (q.length < 2) { _gsHideResults(); return; } - _gsState.debounceTimer = setTimeout(() => _gsController.submitQuery(q), 300); + // 600ms (was 300) — coalesce a name being typed into one search + // instead of one external-API search per letter (#751). Enter still + // fires immediately via the keydown handler. + _gsState.debounceTimer = setTimeout(() => _gsController.submitQuery(q), 600); }); if (clearBtn) { diff --git a/webui/static/search.js b/webui/static/search.js index f963f465..71d4ae58 100644 --- a/webui/static/search.js +++ b/webui/static/search.js @@ -243,10 +243,13 @@ function initializeSearchModeToggle() { return; } - // Debounce search + // Debounce search. 600ms (was 300) so a name being typed coalesces + // into ONE search after the user pauses, instead of firing a new + // external-API search per letter (#751). Enter still triggers an + // immediate search via the keypress handler below. debounceTimer = setTimeout(() => { searchController.submitQuery(query); - }, 300); + }, 600); }); enhancedInput.addEventListener('keypress', (e) => {