extract ctx token thresholds into named constants

This commit is contained in:
iris 2026-05-20 15:05:42 +02:00
parent de13e80082
commit 808b9cbe1a

View file

@ -3,6 +3,13 @@
// and tails the unified dashboard event channel over `/dashboard/stream`.
(() => {
// ─── constants ──────────────────────────────────────────────────────────
// Context-window token thresholds — mirror the harness compaction watermarks
// in hive-ag3nt (HIVE_COMPACT_WATERMARK_TOKENS = 150k; auto-reset at 100k).
// TODO: source these from model metadata once damocles lands that feature.
const CTX_WARN_TOKENS = 150_000; // ≥ this → compact territory (red)
const CTX_CAUTION_TOKENS = 100_000; // ≥ this → approaching reset (yellow)
// ─── helpers ────────────────────────────────────────────────────────────
const $ = (id) => document.getElementById(id);
const esc = (s) => String(s).replace(/[&<>"]/g, (c) =>
@ -551,12 +558,9 @@
`${c.pending_reminders}`));
}
if (c.ctx_tokens != null) {
// Colour thresholds mirror the harness compaction watermarks:
// < 100k = safe (green), 100k150k = approaching reset (yellow),
// ≥ 150k = compact territory (red).
const k = Math.round(c.ctx_tokens / 1000);
const ctxClass = c.ctx_tokens >= 150_000 ? 'badge-ctx-warn'
: c.ctx_tokens >= 100_000 ? 'badge-ctx-caution'
const ctxClass = c.ctx_tokens >= CTX_WARN_TOKENS ? 'badge-ctx-warn'
: c.ctx_tokens >= CTX_CAUTION_TOKENS ? 'badge-ctx-caution'
: 'badge-ctx-ok';
head.append(el('span',
{