fix: ResizeObserver leak, CSS class lowercase, active sessions live update

This commit is contained in:
William Valentin
2026-03-14 11:11:42 -07:00
parent eaf73e5ff5
commit e7dd954f6a
+13 -3
View File
@@ -13,6 +13,7 @@
let dashboardState = null;
let dashboardUnsubscribe = null;
let dashboardChart = null;
let dashboardResizeObserver = null;
function getWsURL() {
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
@@ -81,6 +82,10 @@
dashboardChart.destroy();
dashboardChart = null;
}
if (dashboardResizeObserver) {
dashboardResizeObserver.disconnect();
dashboardResizeObserver = null;
}
}
function route() {
@@ -1068,6 +1073,8 @@
}
if (dashboardState.summary) {
if (eventType === 'session.start') dashboardState.summary.active_sessions++;
if (eventType === 'session.end') dashboardState.summary.active_sessions = Math.max(0, dashboardState.summary.active_sessions - 1);
if (eventType === 'run.start') dashboardState.summary.runs_today++;
if (eventType === 'error') dashboardState.summary.errors_today++;
if (eventType === 'span.end') {
@@ -1212,14 +1219,17 @@
dashboardChart = new uPlot(opts, [timestamps, runs, tools, errors], container);
const ro = new ResizeObserver(entries => {
if (dashboardResizeObserver) {
dashboardResizeObserver.disconnect();
}
dashboardResizeObserver = new ResizeObserver(entries => {
for (const entry of entries) {
if (dashboardChart) {
dashboardChart.setSize({ width: entry.contentRect.width, height: 200 });
}
}
});
ro.observe(container);
dashboardResizeObserver.observe(container);
}
function appendToCurrentBucket(evt) {
@@ -1270,7 +1280,7 @@
container.innerHTML = entries.map(([name, stats]) => {
const total = stats.runs + stats.tools + stats.errors;
const pct = maxTotal > 0 ? (total / maxTotal * 100) : 0;
const cssClass = name.replace(/[^a-z0-9-]/g, '-');
const cssClass = name.toLowerCase().replace(/[^a-z0-9-]/g, '-');
return `
<div class="fw-bar-row">
<div class="fw-bar-label">