From a7d879a08796ced6c42ea7a2ec8ded6a2537c5e5 Mon Sep 17 00:00:00 2001 From: Sleeps Date: Wed, 7 Oct 2026 13:02:18 +0100 Subject: [PATCH 1/3] Keep plugin job status polling live while page is open --- .../Configuration/configPage.html | 36 +++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/jellyfin-plugin/Jellyfin.Plugin.SceneSearch/Configuration/configPage.html b/jellyfin-plugin/Jellyfin.Plugin.SceneSearch/Configuration/configPage.html index c0419f1..aaed910 100644 --- a/jellyfin-plugin/Jellyfin.Plugin.SceneSearch/Configuration/configPage.html +++ b/jellyfin-plugin/Jellyfin.Plugin.SceneSearch/Configuration/configPage.html @@ -109,6 +109,8 @@ var currentConfig = null; var statusTimer = null; var captionTimer = null; + var lastIndexRunning = false; + var lastCaptionRunning = false; var lastCaptionStatus = null; function selectedLibraryIds() { @@ -198,16 +200,13 @@ function refreshStatus() { return ApiClient.getJSON(ApiClient.getUrl('Plugins/SceneSearch/IndexStatus')) .then(function (status) { + var running = !!(status && status.running); renderStatus(status); - if (status && status.running) { - if (!statusTimer) { - statusTimer = setInterval(refreshStatus, 2000); - } - } else if (statusTimer) { - clearInterval(statusTimer); - statusTimer = null; + + if (lastIndexRunning && !running) { loadLibraries(); } + lastIndexRunning = running; }) .catch(function () { renderStatus(null); @@ -314,15 +313,9 @@ function refreshCaptionStatus() { return ApiClient.getJSON(ApiClient.getUrl('Plugins/SceneSearch/CaptionStatus')) .then(function (status) { + var running = !!(status && status.running); renderCaptionStatus(status); - if (status && status.running) { - if (!captionTimer) { - captionTimer = setInterval(refreshCaptionStatus, 2000); - } - } else if (captionTimer) { - clearInterval(captionTimer); - captionTimer = null; - } + lastCaptionRunning = running; }) .catch(function () { renderCaptionStatus(null); @@ -351,6 +344,13 @@ page.querySelector('#timeoutSeconds').value = config.TimeoutSeconds || 60; return Promise.all([loadLibraries(), refreshStatus(), refreshCaptionStatus()]); + }).then(function () { + if (!statusTimer) { + statusTimer = setInterval(refreshStatus, 2000); + } + if (!captionTimer) { + captionTimer = setInterval(refreshCaptionStatus, 2000); + } }).finally(function () { Dashboard.hideLoadingMsg(); }); @@ -400,6 +400,9 @@ }); }).then(function () { refreshStatus(); + if (!statusTimer) { + statusTimer = setInterval(refreshStatus, 2000); + } }).catch(function () { page.querySelector('#indexStatus').textContent = 'Could not start indexing. Check Jellyfin logs and Scene Search API status.'; @@ -431,6 +434,9 @@ }); }).then(function () { refreshCaptionStatus(); + if (!captionTimer) { + captionTimer = setInterval(refreshCaptionStatus, 2000); + } }).catch(function () { page.querySelector('#captionStatus').textContent = 'Could not start captioning. Check Jellyfin logs and Scene Search API status.'; From d18fa8441df718a2a906d9ff433010e06c980988 Mon Sep 17 00:00:00 2001 From: Sleeps Date: Wed, 7 Oct 2026 13:02:40 +0100 Subject: [PATCH 2/3] Keep web job status polling live while dashboard is open --- scene_search/web/index.html | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/scene_search/web/index.html b/scene_search/web/index.html index adc10ce..d0fa1ea 100644 --- a/scene_search/web/index.html +++ b/scene_search/web/index.html @@ -123,6 +123,8 @@ const $ = id => document.getElementById(id); let statusTimer = null; let captionTimer = null; + let lastIndexRunning = false; + let lastCaptionRunning = false; let captionLastStatus = null; let thumbnailUrls = []; @@ -222,13 +224,13 @@ async function refreshStatus() { try { const s = await api('/api/jellyfin/index/status'); + const running = !!s.running; renderStatus(s); - if (!s.running && statusTimer) { - clearInterval(statusTimer); - statusTimer = null; + if (lastIndexRunning && !running) { loadLibraries(); refreshHealth(); } + lastIndexRunning = running; return s; } catch (e) { $('indexStatus').className = 'status error'; @@ -250,6 +252,7 @@ body:JSON.stringify({library_ids:ids, force:$('forceIndex').checked}) }); renderStatus(s); + lastIndexRunning = !!s.running; if (!statusTimer) statusTimer = setInterval(refreshStatus, 2000); } catch (e) { $('indexStatus').className = 'status error'; @@ -324,14 +327,12 @@ async function refreshCaptionStatus() { try { const s = await api('/api/caption/status'); + const running = !!s.running; renderCaptionStatus(s); - if (s.running) { - if (!captionTimer) captionTimer = setInterval(refreshCaptionStatus, 2000); - } else if (captionTimer) { - clearInterval(captionTimer); - captionTimer = null; + if (lastCaptionRunning && !running) { refreshHealth(); } + lastCaptionRunning = running; return s; } catch (e) { $('captionStatus').className = 'status error'; @@ -353,7 +354,8 @@ body:JSON.stringify({library_ids:ids, force:$('forceCaption').checked}) }); renderCaptionStatus(s); - if (s.running && !captionTimer) captionTimer = setInterval(refreshCaptionStatus, 2000); + lastCaptionRunning = !!s.running; + if (!captionTimer) captionTimer = setInterval(refreshCaptionStatus, 2000); } catch (e) { $('captionStatus').className = 'status error'; $('captionStatus').textContent = e.message; @@ -442,12 +444,10 @@ refreshHealth(); loadLibraries(); - refreshStatus().then(s => { - if (s && s.running && !statusTimer) statusTimer = setInterval(refreshStatus, 2000); - }); - refreshCaptionStatus().then(s => { - if (s && s.running && !captionTimer) captionTimer = setInterval(refreshCaptionStatus, 2000); - }); + refreshStatus(); + refreshCaptionStatus(); + statusTimer = setInterval(refreshStatus, 2000); + captionTimer = setInterval(refreshCaptionStatus, 2000); })(); From d8002d8272e7152db2162367c0e9ca0d3c6d0fdd Mon Sep 17 00:00:00 2001 From: Sleeps Date: Wed, 7 Oct 2026 13:04:33 +0100 Subject: [PATCH 3/3] Reload dashboard after API key changes --- scene_search/web/index.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scene_search/web/index.html b/scene_search/web/index.html index d0fa1ea..2677738 100644 --- a/scene_search/web/index.html +++ b/scene_search/web/index.html @@ -428,11 +428,11 @@ $('saveKey').onclick = () => { localStorage.setItem('sceneSearchApiKey', $('apiKey').value.trim()); - loadLibraries(); refreshStatus(); refreshCaptionStatus(); + window.location.reload(); }; $('clearKey').onclick = () => { - localStorage.removeItem('sceneSearchApiKey'); $('apiKey').value = ''; - loadLibraries(); refreshStatus(); refreshCaptionStatus(); + localStorage.removeItem('sceneSearchApiKey'); + window.location.reload(); }; $('refreshLibraries').onclick = loadLibraries; $('selectAll').onclick = () => document.querySelectorAll('.libraryCheck').forEach(x => x.checked = true);