[object Object]

← back to Macstudio1 Dashboard

feat: TEST button on Mac1 dashboard — single-prompt latency check

6a9b5d8f5c8a6e88cb87d560f579262fb4a47315 · 2026-05-08 01:05:33 -0700 · SteveStudio2

Files touched

Diff

commit 6a9b5d8f5c8a6e88cb87d560f579262fb4a47315
Author: SteveStudio2 <steve@designerwallcoverings.com>
Date:   Fri May 8 01:05:33 2026 -0700

    feat: TEST button on Mac1 dashboard — single-prompt latency check
---
 public/index.html | 28 +++++++++++++++++++++++++---
 server.js         | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 59 insertions(+), 3 deletions(-)

diff --git a/public/index.html b/public/index.html
index 22b3446..e321280 100644
--- a/public/index.html
+++ b/public/index.html
@@ -658,8 +658,16 @@ footer a { color: var(--gold); text-decoration: none; }
     </div>
   </div>
 
-  <!-- Push-button shifter / hyperdrive controls (4 columns now to fit BOOST) -->
-  <div class="controls" style="grid-template-columns: 1fr 1fr 1fr 1fr">
+  <!-- last test result lozenge -->
+  <div id="test-result" style="margin-bottom:10px;text-align:center;font-family:'JetBrains Mono',monospace;font-size:12px;color:var(--gold);min-height:18px"></div>
+
+  <!-- Push-button shifter / hyperdrive controls (5 columns) -->
+  <div class="controls" style="grid-template-columns: repeat(5, 1fr)">
+    <button class="btn" data-mode="test" onclick="trigger('test', this)" style="border:3px solid var(--turq-dark)" title="Fires a tiny prompt at the loaded model, times the round-trip. Use to compare before/after BOOST.">
+      <span class="light"></span>
+      🏁 Test
+      <span class="sub-label">prompt + latency check</span>
+    </button>
     <button class="btn" data-mode="boost" onclick="trigger('boost', this)" style="border:3px solid var(--metal-glow)" title="Restart ollama with NUM_PARALLEL=4, MAX_LOADED=2, FLASH_ATTENTION, q4_0 KV cache, KEEP_ALIVE=-1. Big-deal — kills in-flight calls.">
       <span class="light"></span>
       🏎️ Boost
@@ -887,17 +895,31 @@ async function tick() {
 }
 
 async function trigger(mode, btn) {
-  // Visual feedback: light up the pressed button, dim the others
   document.querySelectorAll('.btn').forEach(b => b.classList.remove('active'));
   btn.classList.add('active');
+  const resEl = document.getElementById('test-result');
+  if (resEl && mode === 'test') resEl.textContent = '… firing test prompt …';
   try {
     const r = await fetch('/api/control/' + mode, { method: 'POST' });
     const j = await r.json();
     console.log('[control]', mode, j);
+    if (mode === 'test' && resEl) {
+      if (j.ok) {
+        resEl.style.color = 'var(--gold)';
+        resEl.textContent = `🏁 ${j.model} · ${j.ms}ms wall · ${j.tokens_per_s ? j.tokens_per_s + ' tok/s · ' : ''}reply: "${(j.reply||'').slice(0,40)}"`;
+      } else {
+        resEl.style.color = '#c47b7b';
+        resEl.textContent = `× test failed · ${j.status||''} · ${(j.error||j.reply||'unknown').slice(0,80)}`;
+      }
+    }
     setTimeout(() => tick(), 400);
   } catch (e) {
     console.warn('control failed', e);
     btn.classList.remove('active');
+    if (resEl && mode === 'test') {
+      resEl.style.color = '#c47b7b';
+      resEl.textContent = '× network error: ' + (e.message || e);
+    }
   }
 }
 
diff --git a/server.js b/server.js
index 233e493..ba8d49a 100644
--- a/server.js
+++ b/server.js
@@ -215,6 +215,40 @@ app.post('/api/control/max-ram', async (_req, res) => {
   res.json({ ok: true, mode: 'max-ram', loaded: out });
 });
 
+// 🏁 TEST — fires a tiny prompt at the loaded model and times it. Useful to
+// directly compare before/after a BOOST or to see if Mac1 is responsive.
+app.post('/api/control/test', async (_req, res) => {
+  try {
+    const ps = await fetch(`${OLLAMA}/api/ps`, { signal: AbortSignal.timeout(2500) });
+    const psJ: any = ps.ok ? await ps.json() : { models: [] };
+    const model = (psJ.models || [])[0]?.name || 'qwen3:14b';
+    const t0 = Date.now();
+    const r = await fetch(`${OLLAMA}/api/chat`, {
+      method: 'POST',
+      headers: { 'Content-Type': 'application/json' },
+      body: JSON.stringify({
+        model, stream: false,
+        messages: [{ role: 'user', content: 'Reply with exactly the phrase "BOOST OK" and nothing else, no thinking.' }],
+        options: { num_predict: 8, num_ctx: 512 }
+      }),
+      signal: AbortSignal.timeout(60000)
+    });
+    const ms = Date.now() - t0;
+    if (!r.ok) {
+      const txt = await r.text();
+      return res.json({ ok: false, mode: 'test', model, ms, status: r.status, error: txt.slice(0, 240) });
+    }
+    const j: any = await r.json();
+    res.json({
+      ok: true, mode: 'test', model, ms,
+      reply: (j?.message?.content || '').slice(0, 120),
+      tokens_per_s: j.eval_count && j.eval_duration ? +(j.eval_count / (j.eval_duration / 1e9)).toFixed(1) : null
+    });
+  } catch (e: any) {
+    res.status(500).json({ ok: false, error: String(e?.message || e) });
+  }
+});
+
 // 🏎️ BOOST — runs ~/bin/ollama-boost.sh which kills the manual ollama serve
 // and relaunches via launchd com.steve.ollama-boost with these env vars:
 //   OLLAMA_NUM_PARALLEL=4         (4× concurrent inference per model)

← fda8505 feat: BOOST button on Mac1 dashboard restarts ollama with NU  ·  back to Macstudio1 Dashboard  ·  fix: drop TS-style :any annotations from server.js (was cras cf7ec96 →