From 173b82ceb88bc7bcb3e93d37a386b436af4fa749 Mon Sep 17 00:00:00 2001 From: tegwick Date: Thu, 26 Feb 2026 13:33:23 +0100 Subject: [PATCH] dashboard: remove stale KPI box before re-inserting on each poll Assign a stable id to the KPI element so the previous instance can be found and removed before the fresh one is prepended to the TOC sidebar. Co-Authored-By: Claude Sonnet 4.6 --- state-hub/dashboard/src/decisions.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/state-hub/dashboard/src/decisions.md b/state-hub/dashboard/src/decisions.md index c186425..bca6a20 100644 --- a/state-hub/dashboard/src/decisions.md +++ b/state-hub/dashboard/src/decisions.md @@ -151,9 +151,12 @@ const _kpiBox = html`
withDocHelp(_kpiBox, "/docs/decisions-kpi"); // ── Inject into the TOC sidebar (right column, non-scrolling) ─────────────── +_kpiBox.id = "decisions-kpi-box"; const _toc = document.querySelector("#observablehq-toc"); -if (_toc) _toc.prepend(_kpiBox); -else display(html`
${_kpiBox}
`); +if (_toc) { + document.getElementById("decisions-kpi-box")?.remove(); + _toc.prepend(_kpiBox); +} else display(html`
${_kpiBox}
`); ``` ```js