[object Object]

← back to build-pages

home: auto-refresh 'Recent across the fleet' rail every 60s via /api/recent

8fd3a31b8642f993475bcc958ad4bad21823f13a · 2026-05-13 15:19:24 -0700 · SteveStudio2

Files touched

Diff

commit 8fd3a31b8642f993475bcc958ad4bad21823f13a
Author: SteveStudio2 <stevestudio2@SteveStacStudio.lan>
Date:   Wed May 13 15:19:24 2026 -0700

    home: auto-refresh 'Recent across the fleet' rail every 60s via /api/recent
---
 server.js | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/server.js b/server.js
index 4b84e8a..f19f3f8 100644
--- a/server.js
+++ b/server.js
@@ -353,7 +353,8 @@ app.get('/', async (req, res, next) => {
 
       <section class="bp-section">
         <h2>Recent across the fleet</h2>
-        <ol class="bp-commits">${recentRows}</ol>
+        <ol id="bp-recent" class="bp-commits">${recentRows}</ol>
+        <p id="bp-recent-meta" class="bp-meta">auto-refreshes every 60s</p>
       </section>
 
       <section class="bp-section">
@@ -402,6 +403,26 @@ app.get('/', async (req, res, next) => {
         });
         // Fire once on load if ?q= was server-rendered into the input.
         if (fq.value.trim().length >= 2) doFleetSearch();
+
+        // Auto-refresh the "Recent across the fleet" rail every 60s so a fresh
+        // commit in any project shows up without a full reload. Bails silently
+        // on fetch failure so a transient network blip doesn't blank the rail.
+        async function refreshRecent() {
+          try {
+            const r = await fetch('/api/recent?limit=10');
+            if (!r.ok) return;
+            const data = await r.json();
+            const ol = document.getElementById('bp-recent');
+            const meta = document.getElementById('bp-recent-meta');
+            ol.innerHTML = data.results.map(h => \`<li>
+              <a href="/p/\${h.slug}/c/\${h.hash}"><code>\${h.hash}</code></a>
+              <span class="bp-d">\${h.date.slice(0,10)}</span>
+              <span class="bp-s"><strong>\${h.project}</strong> — \${h.subject.replace(/</g,'&lt;')}</span>
+            </li>\`).join('');
+            meta.textContent = 'last refreshed ' + new Date().toLocaleTimeString();
+          } catch (_) {}
+        }
+        setInterval(refreshRecent, 60_000);
       </script>
     `));
   } catch (e) { next(e); }

← 98d376b security: Permissions-Policy header (geolocation/microphone/  ·  back to build-pages  ·  api: /api/fleet/{agents,skills} — cross-project aggregated f 232a253 →