From ea201ab4b0238fe807a09a0c43e368e1b7074261 Mon Sep 17 00:00:00 2001 From: Lukas Parsons Date: Mon, 6 Jul 2026 21:13:46 -0400 Subject: [PATCH] fix: always show Scan button in Serve tab; invalidate cache after download - Added persistent Scan button to the Serve tab toolbar (was only shown in empty state, making it impossible to refresh when localStorage had cached results) - Hooked into background poll to clear model scan cache (key: cookbook_cached_models_scan_v1) when downloads transition to done, so the Serve tab doesn't show stale data after a download completes Event handler for #hwfit-cache-scan already existed in the codebase but the button element was never rendered in the HTML template. --- static/js/cookbook.js | 1 + static/js/cookbookRunning.js | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/static/js/cookbook.js b/static/js/cookbook.js index 73965faf..124f883d 100644 --- a/static/js/cookbook.js +++ b/static/js/cookbook.js @@ -2802,6 +2802,7 @@ function _renderRecipes() { html += '
'; html += ''; html += ''; + html += ''; html += '
'; html += '
'; html += ''; diff --git a/static/js/cookbookRunning.js b/static/js/cookbookRunning.js index 3fd77cfa..a76bc316 100644 --- a/static/js/cookbookRunning.js +++ b/static/js/cookbookRunning.js @@ -3948,6 +3948,12 @@ async function _pollBackgroundStatus() { _showDiagnosis(el, task._backendDiagnosis, task.output || ''); } completedDeps.forEach(t => _refreshDepsAfterInstall(t)); + // Ulysses: when a download finishes, invalidate the model scan cache + // so the Serve tab doesn't show stale results. + const justDownloaded = localTasks.filter(t => t.type === 'download' && t.status === 'done'); + if (justDownloaded.length) { + try { localStorage.removeItem('cookbook_cached_models_scan_v1'); } catch {} + } } } catch (_) { /* non-fatal: background status should never break polling */ }