Browse Source

feat-indicator-blink-parse-exec-send-states

master
Serge Shutov 2 weeks ago
parent
commit
d33938d25c
  1. 6
      content/content.js
  2. 2
      content/overlay.css
  3. 4
      content/panel.js

6
content/content.js

@ -179,7 +179,7 @@ @@ -179,7 +179,7 @@
processed.add(m);
continue;
}
var parsed = extractCalls(text, 3);
if (UI && UI.setDot) UI.setDot('busy'); var parsed = extractCalls(text, 3);
if (!parsed) continue;
if (!parsed.calls) continue;
if (parsed.calls.length === 0) continue;
@ -188,7 +188,7 @@ @@ -188,7 +188,7 @@
rememberCallsHash(ch);
processed.add(m);
rememberHash(h);
for (k = 0; k < parsed.calls.length; k++) queue.push(parsed.calls[k]);
for (k = 0; k < parsed.calls.length; k++) queue.push(parsed.calls[k]); if (UI && UI.setDot) UI.setDot('ok-busy');
if (UI) UI.setPhase('executing');
}
pump();
@ -215,7 +215,7 @@ @@ -215,7 +215,7 @@
if (results.length > 0) {
var payload = buildResultMessage(results);
if (UI) UI.setPhase('sending');
sendText(payload).then(function () { if (UI) UI.setPhase('idle'); }).catch(function (err) { console.warn('[dsh-memory] sendText failed', String(err)); if (UI) UI.setPhase('idle'); });
var anyFail = results.some(function (r) { return !r || !r.ok; }); sendText(payload).then(function () { if (UI) { UI.setPhase('idle'); if (UI.setDot) UI.setDot(anyFail ? 'busy' : 'ok'); } }).catch(function (err) { console.warn('[dsh-memory] sendText failed', String(err)); if (UI) { UI.setPhase('idle'); if (UI.setDot) UI.setDot('busy'); } });
} else { if (UI) UI.setPhase('idle'); }
return;
}

2
content/overlay.css

@ -35,7 +35,7 @@ @@ -35,7 +35,7 @@
}
.dshmem-dot.ok { background: #34c759; }
.dshmem-dot.err { background: #ff5f57; }
.dshmem-dot.busy { background: #ffcc00; animation: dshmem-blink 1s infinite; }
.dshmem-dot.busy { background: #ffcc00; animation: dshmem-blink 1s infinite; } .dshmem-dot.ok-busy { background: #34c759; animation: dshmem-blink 1s infinite; }
@keyframes dshmem-blink { 50% { opacity: 0.35; } }
.dshmem-title { font-weight: 600; letter-spacing: 0.4px; }

4
content/panel.js

@ -7,7 +7,7 @@ @@ -7,7 +7,7 @@
connected: false,
loopsLeft: 0, loopsMax: 0,
dailyCount: 0, dailyMax: 0,
resetCbs: [], stopCbs: [], saveCbs: [], startCbs: []
resetCbs: [], stopCbs: [], saveCbs: [], startCbs: [], dotMode: null
};
var el = {};
function byId(id) { return document.getElementById(id); }
@ -74,7 +74,7 @@ @@ -74,7 +74,7 @@
}
var API = {
setPhase: function (p) { state.phase = p; if (el.phase) el.phase.textContent = p; },
setConnected: function (b) { state.connected = !!b; if (el.dot) el.dot.className = 'dshmem-dot ' + (b ? 'ok' : 'err'); },
setConnected: function (b) { state.connected = !!b; API._applyDot(); }, setDot: function (m) { state.dotMode = (m === 'ok') ? null : m; API._applyDot(); }, _applyDot: function () { if (!el.dot) return; var md = state.dotMode || (state.connected ? 'ok' : 'err'); var cls = 'dshmem-dot'; if (md === 'ok' || md === 'err' || md === 'busy' || md === 'ok-busy') cls += ' ' + md; 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; } 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'; },
log: function (m) {
if (!el.log) return;

Loading…
Cancel
Save