[object Object]

← back to Macstudio2 Dashboard

feat: same self-healing version check on Mac2 dashboard

aee1fddc0a0a2b23d664ed561756752cc8a251c1 · 2026-05-08 00:04:14 -0700 · SteveStudio2

Files touched

Diff

commit aee1fddc0a0a2b23d664ed561756752cc8a251c1
Author: SteveStudio2 <steve@designerwallcoverings.com>
Date:   Fri May 8 00:04:14 2026 -0700

    feat: same self-healing version check on Mac2 dashboard
---
 public/index.html | 24 ++++++++++++++++++++++++
 server.js         | 17 ++++++++++++++++-
 2 files changed, 40 insertions(+), 1 deletion(-)

diff --git a/public/index.html b/public/index.html
index ba06d2b..da4a0a1 100644
--- a/public/index.html
+++ b/public/index.html
@@ -980,6 +980,30 @@ async function tickLog() {
 }
 tickLog();
 setInterval(tickLog, 3000);
+
+// ─── Self-healing version watch — auto-reload if server has new HTML ────
+let LOADED_VERSION = null;
+async function checkVersion() {
+  try {
+    const r = await fetch('/api/version').then(r => r.json());
+    if (LOADED_VERSION === null) {
+      LOADED_VERSION = r.version;
+      console.log('[dashboard] loaded version', LOADED_VERSION);
+      return;
+    }
+    if (r.version && r.version !== LOADED_VERSION) {
+      console.log('[dashboard] new version', r.version, '— reloading in 2s');
+      // Brief flash so Steve sees a deploy happened
+      const banner = document.createElement('div');
+      banner.textContent = 'New build deployed · reloading…';
+      banner.style.cssText = 'position:fixed;top:0;left:0;right:0;z-index:9999;background:#d4b683;color:#0a0a0c;font-family:JetBrains Mono,monospace;font-weight:600;font-size:13px;letter-spacing:.18em;text-align:center;padding:14px;box-shadow:0 4px 12px rgba(0,0,0,0.6);text-transform:uppercase';
+      document.body.appendChild(banner);
+      setTimeout(() => { location.reload(true); }, 2000);
+    }
+  } catch (e) { /* network blip */ }
+}
+checkVersion();
+setInterval(checkVersion, 5000);
 </script>
 
 </body>
diff --git a/server.js b/server.js
index b317a08..0a15b0b 100644
--- a/server.js
+++ b/server.js
@@ -1,4 +1,4 @@
-// Mac Studio 2 dashboard — '57 Cadillac Eldorado aesthetic (red/ivory).
+// Mac Studio 2 dashboard — '57 Cadillac Eldorado aesthetic.
 // - GET /api/status      live Ollama state + CPU/RAM
 // - POST /api/control/X  hyperdrive controls (RAM-pin models / power mode)
 // - GET /                static dashboard
@@ -288,6 +288,21 @@ app.get('/api/ollama/log', async (req, res) => {
   }
 });
 
+// Server-side build version — hash of public/index.html. Polling clients
+// compare to their loaded copy and force-reload when it changes.
+const crypto = require('node:crypto');
+let _buildVersion = '';
+function computeBuildVersion() {
+  try {
+    const html = fs.readFileSync(path.join(__dirname, 'public', 'index.html'), 'utf8');
+    _buildVersion = crypto.createHash('sha1').update(html).digest('hex').slice(0, 10);
+  } catch { _buildVersion = 'unknown'; }
+  return _buildVersion;
+}
+computeBuildVersion();
+fs.watch(path.join(__dirname, 'public'), { recursive: true }, () => computeBuildVersion());
+app.get('/api/version', (_req, res) => res.json({ version: _buildVersion, ts: Date.now() }));
+
 app.get('/api/health', (_req, res) => res.json({ ok: true, ts: Date.now() }));
 
 app.listen(PORT, '0.0.0.0', () => {

← a6e6d69 fix: macstudio2-dashboard retitled + 9931 + Eldorado red/ivo  ·  back to Macstudio2 Dashboard  ·  feat: viewer counter on dashboard odometer — same as Mac1 a87669d →