diff --git a/content/panel.js b/content/panel.js index e1fe67e..1f4e03c 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; if (el.dot) el.dot.className = 'dshmem-dot ' + (b ? 'ok' : 'err'); }, - 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_pct || 0) + 'pct'; }, + 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; var t = new Date().toLocaleTimeString(); diff --git a/injected/chat-logger.js b/injected/chat-logger.js index 494351e..e21816d 100644 --- a/injected/chat-logger.js +++ b/injected/chat-logger.js @@ -204,9 +204,9 @@ accum: accum, delta: delta, chars: ctxChars, - est_tok: Math.round(ctxChars / K_RATIO), ctx_chars: charsAccum, ctx_pct: Math.round(charsAccum * 100 / CONTEXT_LIMIT) + est_tok: Math.round(ctxChars / K_RATIO), ctx_chars: charsAccum, ctx_tok: Math.round(charsAccum / K_RATIO), ctx_pct: Math.round(charsAccum / K_RATIO * 1000 / CONTEXT_LIMIT) / 10 } - lines.push(JSON.stringify(meta)); try { window.dispatchEvent(new CustomEvent('dshmem:metrics', { detail: JSON.stringify({ accum: accum, delta: delta, chars: ctxChars, est_tok: Math.round(ctxChars / K_RATIO), ctx_chars: charsAccum, ctx_pct: Math.round(charsAccum * 100 / CONTEXT_LIMIT) }) })) } catch (e) { } + lines.push(JSON.stringify(meta)); try { window.dispatchEvent(new CustomEvent('dshmem:metrics', { detail: JSON.stringify({ accum: accum, delta: delta, chars: ctxChars, est_tok: Math.round(ctxChars / K_RATIO), ctx_chars: charsAccum, ctx_tok: Math.round(charsAccum / K_RATIO), ctx_pct: Math.round(charsAccum / K_RATIO * 1000 / CONTEXT_LIMIT) / 10 }) })) } catch (e) { } } if (!lines.length) return sendLines(file, lines).then(function (ok) {