From 13d68abd3df03cce7c76b7def7a6adab9dae8d99 Mon Sep 17 00:00:00 2001 From: Serge Alex Date: Thu, 5 Nov 2026 14:56:50 +0300 Subject: [PATCH] status-indicator-ready-and-stopped-colors --- content/content.js | 6 +++--- content/overlay.css | 2 +- content/panel.js | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/content/content.js b/content/content.js index bf23e6e..ef4f8c2 100644 --- a/content/content.js +++ b/content/content.js @@ -18,7 +18,7 @@ UI.onStop(function () { queue.length = 0; started = false; try { obs.disconnect(); } catch (e) {} if (UI) { UI.setPhase('off'); UI.setStartEnabled(true); if (UI.setDot) UI.setDot('stopped'); UI.log('stopped'); } }); UI.onSaveToken(function (v) { chrome.storage.local.set({ 'dshmem-bridge-token': v }, function () { if (UI) UI.log('token saved, reload page'); }); }); } - if (UI) { UI.onStart(function () { if (!canStart) { if (UI.setStartEnabled) UI.setStartEnabled(true); return; } started = true; markExistingAsProcessed(); obs.observe(document.documentElement, { childList: true, subtree: true, characterData: true }); UI.setPhase('idle'); UI.setConnected(true); UI.log('started'); }); } + if (UI) { UI.onStart(function () { if (!canStart) { if (UI.setStartEnabled) UI.setStartEnabled(true); return; } started = true; markExistingAsProcessed(); obs.observe(document.documentElement, { childList: true, subtree: true, characterData: true }); UI.setPhase('idle'); UI.setConnected(true); if (UI.setDot) UI.setDot('ok'); UI.log('started'); }); } window.addEventListener('dshmem:metrics', function (e) { try { var mm = JSON.parse(e.detail); if (UI && UI.setMetrics) UI.setMetrics(mm); } catch (err) {} }); if (!SEL) return; if (!BRIDGE) return; if (typeof extractCalls !== "function") return; @@ -359,7 +359,7 @@ if (parsed.calls.length === 0) { if (hasMarker) { try { var __dh = hashText(text UI.setPhase('off'); UI.setConnected(!!(r && r.ok)); if (!r || !r.ok) UI.log('bridge down: ' + ((r && r.error && r.error.message) || '?')); - else UI.log('ready, press Start'); + else { if (UI.setDot) UI.setDot('ok'); UI.log('ready, press Start'); } } canStart = true; }).catch(function (e) { @@ -367,7 +367,7 @@ if (parsed.calls.length === 0) { if (hasMarker) { try { var __dh = hashText(text canStart = true; }); setInterval(function () { - BRIDGE.health().then(function (r) { if (UI && UI.setConnected) UI.setConnected(!!(r && r.ok)); }); + BRIDGE.health().then(function (r) { if (UI && UI.setConnected) { UI.setConnected(!!(r && r.ok)); if (r && r.ok && UI.setDot) UI.setDot('ok'); } }); }, 30000); __refreshStats(); }); diff --git a/content/overlay.css b/content/overlay.css index 7622225..12c29ea 100644 --- a/content/overlay.css +++ b/content/overlay.css @@ -37,7 +37,7 @@ .dshmem-dot.err { background: #ff5f57; } .dshmem-dot.busy { background: #ffcc00; animation: dshmem-blink 1s infinite; } .dshmem-dot.ok-busy { background: #34c759; animation: dshmem-blink 1s infinite; } .dshmem-dot.off { background: #666; } -.dshmem-dot.stopped { background: #666; } +.dshmem-dot.stopped { background: #ff9500; } .dshmem-dot.error { background: #ff5f57; animation: dshmem-blink 1s infinite; } @keyframes dshmem-blink { 50% { opacity: 0.35; } } diff --git a/content/panel.js b/content/panel.js index 13052ab..6977388 100644 --- a/content/panel.js +++ b/content/panel.js @@ -75,7 +75,7 @@ } var API = { setPhase: function (p) { state.phase = p; if (el.phase) el.phase.textContent = p; }, - setConnected: function (b) { state.connected = !!b; API._applyDot(); }, setDot: function (m) { state.dotMode = m || null; API._applyDot(); }, _applyDot: function () { if (!el.dot) return; var cls = 'dshmem-dot'; if (!state.connected) { cls += ' err'; } else { var m = state.dotMode || 'off'; if (m === 'busy' || m === 'ok-busy') cls += ' busy'; else if (m === 'error') cls += ' error'; else if (m === 'stopped') cls += ' stopped'; else if (m === 'ok') cls += ' ok'; else cls += ' off'; } el.dot.className = cls; }, + setConnected: function (b) { state.connected = !!b; API._applyDot(); }, setDot: function (m) { state.dotMode = m || null; API._applyDot(); }, _applyDot: function () { if (!el.dot) return; var cls = 'dshmem-dot'; if (!state.connected) { cls += ' err'; } else { var m = state.dotMode || 'ok'; if (m === 'busy' || m === 'ok-busy') cls += ' busy'; else if (m === 'error') cls += ' error'; else if (m === 'stopped') cls += ' stopped'; else if (m === 'ok') cls += ' ok'; else cls += ' off'; } el.dot.className = cls; }, setStartEnabled: function (b) { if (el.start) el.start.disabled = !b; }, setStats: function (ws, memN, skillN) { if (!el.stats) return; el.stats.textContent = 'WS: ' + (ws || '?') + ' mem: ' + (memN || 0) + ' skills: ' + (skillN || 0); }, setMetrics: function (m) { if (!el.metrics) return; if (!m) { el.metrics.textContent = 'metrics: —'; return; } state.lastMetrics = m; var __pct = 0; if (state.accLimit > 0) __pct = Math.round((m.accum || 0) * 100 / state.accLimit); var __cls = 'dshmem-acc-ok'; if (__pct > 100) __cls = 'dshmem-acc-crit'; else if (__pct >= 80) __cls = 'dshmem-acc-err'; else if (__pct >= 40) __cls = 'dshmem-acc-warn'; el.metrics.className = 'dshmem-stats ' + __cls; el.metrics.textContent = 'acc: ' + m.accum + ' · turn: ' + m.delta + ' · msg: ' + m.chars + 'ch (~' + m.est_tok + 't) ctx ' + (m.ctx_tok || 0) + 't ' + (m.ctx_pct || 0) + 'pct'; }, toggleForceInject: function () { state.forceInject = !state.forceInject;