fix: always show Scan button in Serve tab; invalidate cache after download
Some checks are pending
CI / Focused test guidance (report-only) (push) Waiting to run
CI / Python syntax (compileall) (push) Waiting to run
CI / JS syntax (node --check) (push) Waiting to run
CI / Python tests (pytest) (push) Waiting to run
Container scan / hadolint (Dockerfile lint) (push) Waiting to run
Container scan (Trivy) / Trivy (image scan, advisory) (push) Waiting to run
Container scan (Trivy) / Trivy (image scan + SARIF upload) (push) Waiting to run
Dependency review / dependency-review (PR gate) (push) Waiting to run
Dependency review / pip-audit (advisory) (push) Waiting to run
ci / docker publish / build (amd64) (push) Waiting to run
ci / docker publish / build (arm64) (push) Waiting to run
ci / docker publish / merge manifest + tag (push) Blocked by required conditions
Secret scan / gitleaks (push) Waiting to run
Workflow security / actionlint (push) Waiting to run
Workflow security / zizmor (Actions SAST) (push) Waiting to run

- 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.
This commit is contained in:
Lukas Parsons 2026-07-06 21:13:46 -04:00
parent 1f6dc80525
commit ea201ab4b0
2 changed files with 7 additions and 0 deletions

View file

@ -2802,6 +2802,7 @@ function _renderRecipes() {
html += '<div class="memory-category-filters">';
html += '<input type="text" class="memory-search-input" id="serve-search" placeholder="Search cached models\u2026" style="flex:1;min-width:120px;" />';
html += '<button class="memory-toolbar-btn" id="hwfit-cache-select">Select</button>';
html += '<button class="memory-toolbar-btn" id="hwfit-cache-scan" title="Rescan model cache" style="margin-left:4px;">Scan</button>';
html += '</div>';
html += '<div class="doclib-lang-chips" id="serve-tags"></div>';
html += '</div>';

View file

@ -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 */ }