From 112761075263e665e41da229394b0db4254efc10 Mon Sep 17 00:00:00 2001 From: Scott Idem Date: Tue, 17 Mar 2026 23:22:47 -0400 Subject: [PATCH] UI: show distill schedule next-run times in settings panel MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fetches /distill/status when the ⚙ panel opens and renders next run times below the distill buttons (monospace, muted). Shows "today", "tomorrow", or "Mar 18" format depending on how far away. Co-Authored-By: Claude Sonnet 4.6 --- cortex/static/app.js | 30 ++++++++++++++++++++++++++++++ cortex/static/index.html | 1 + cortex/static/style.css | 8 ++++++++ 3 files changed, 39 insertions(+) diff --git a/cortex/static/app.js b/cortex/static/app.js index 7d39400..14d17eb 100644 --- a/cortex/static/app.js +++ b/cortex/static/app.js @@ -813,9 +813,39 @@ document.getElementById('mem-short-btn').classList.toggle('mem-on', memShort); } + function formatNextRun(iso) { + if (!iso) return 'n/a'; + const dt = new Date(iso); + const now = new Date(); + const diffMs = dt - now; + const diffDays = Math.floor(diffMs / 86400000); + const time = dt.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' }); + if (diffDays === 0) return `today ${time}`; + if (diffDays === 1) return `tomorrow ${time}`; + return dt.toLocaleDateString([], { month: 'short', day: 'numeric' }) + ' ' + time; + } + + async function loadSchedule() { + const schedEl = document.getElementById('ctx-schedule'); + try { + const res = await fetch('/distill/status'); + const d = await res.json(); + if (!d.enabled || !d.jobs.length) { + schedEl.textContent = 'auto-distill disabled'; + return; + } + schedEl.innerHTML = d.jobs + .map(j => `${j.id.replace('distill_', '').padEnd(6)} → ${formatNextRun(j.next_run)}`) + .join('
'); + } catch { + schedEl.textContent = ''; + } + } + ctxOpenBtn.addEventListener('click', (e) => { e.stopPropagation(); ctxPanel.classList.toggle('open'); + if (ctxPanel.classList.contains('open')) loadSchedule(); }); document.addEventListener('click', (e) => { diff --git a/cortex/static/index.html b/cortex/static/index.html index cc628af..1e47385 100644 --- a/cortex/static/index.html +++ b/cortex/static/index.html @@ -61,6 +61,7 @@
+
Backend
diff --git a/cortex/static/style.css b/cortex/static/style.css index 62fb467..ab3639c 100644 --- a/cortex/static/style.css +++ b/cortex/static/style.css @@ -766,6 +766,14 @@ #ctx-distill-status.show { opacity: 1; } #ctx-distill-status.err { color: var(--error-text); } + #ctx-schedule { + margin-top: 6px; + font-size: 0.66rem; + color: var(--muted); + line-height: 1.7; + font-family: 'Courier New', monospace; + } + /* Ctx header button — shows current tier as a dim superscript */ #ctx-open-btn .tier-badge { font-size: 0.6em;