2026-02-09 09:04:57 +00:00
|
|
|
pub const DASHBOARD_HTML: &str = r##"<!DOCTYPE html>
|
|
|
|
|
<html lang="en">
|
|
|
|
|
<head>
|
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
|
<title>Swactor Runtime Dashboard</title>
|
|
|
|
|
<style>
|
|
|
|
|
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
|
|
|
body { font-family: 'Menlo', 'Consolas', 'Monaco', monospace; background: #0f1117; color: #e0e0e0; font-size: 13px; }
|
|
|
|
|
|
|
|
|
|
.header {
|
|
|
|
|
display: flex; align-items: center; justify-content: space-between;
|
|
|
|
|
padding: 12px 20px; background: #161822; border-bottom: 1px solid #2a2d3e;
|
|
|
|
|
}
|
|
|
|
|
.header h1 { font-size: 16px; font-weight: 600; color: #fff; }
|
|
|
|
|
.status-dot {
|
|
|
|
|
width: 10px; height: 10px; border-radius: 50%; background: #4caf50;
|
|
|
|
|
display: inline-block; margin-left: 8px; vertical-align: middle;
|
|
|
|
|
}
|
|
|
|
|
.status-dot.disconnected { background: #f44336; }
|
|
|
|
|
.status-dot.done { background: #ff9800; }
|
|
|
|
|
.status-dot.replaying { background: #2196f3; animation: pulse 1.5s infinite; }
|
|
|
|
|
|
|
|
|
|
@keyframes pulse {
|
|
|
|
|
0%, 100% { opacity: 1; }
|
|
|
|
|
50% { opacity: 0.4; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.replay-badge {
|
|
|
|
|
display: none; background: #2196f3; color: #fff; font-size: 10px; font-weight: 700;
|
|
|
|
|
padding: 2px 8px; border-radius: 3px; margin-left: 10px; letter-spacing: 1px;
|
|
|
|
|
vertical-align: middle;
|
|
|
|
|
}
|
|
|
|
|
.replay-badge.visible { display: inline-block; }
|
|
|
|
|
|
2026-02-11 15:23:26 +00:00
|
|
|
.header-left { display: flex; align-items: center; }
|
|
|
|
|
.nav-links { display: flex; gap: 4px; margin-left: 20px; }
|
|
|
|
|
.nav-link {
|
|
|
|
|
color: #888; text-decoration: none; font-size: 12px;
|
|
|
|
|
padding: 4px 10px; border-radius: 3px; transition: color 0.2s;
|
|
|
|
|
}
|
|
|
|
|
.nav-link:hover { color: #e0e0e0; }
|
|
|
|
|
.nav-link.active { color: #fff; background: #2a2d3e; }
|
|
|
|
|
|
2026-02-09 09:04:57 +00:00
|
|
|
.header-right { display: flex; align-items: center; gap: 12px; }
|
|
|
|
|
|
|
|
|
|
.progress-bar-wrap {
|
|
|
|
|
display: none; width: 100%; height: 3px; background: #2a2d3e;
|
|
|
|
|
}
|
|
|
|
|
.progress-bar-wrap.visible { display: block; }
|
|
|
|
|
.progress-fill {
|
|
|
|
|
height: 100%; width: 0%; background: #2196f3; transition: width 0.3s;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.grid {
|
|
|
|
|
display: grid;
|
|
|
|
|
grid-template-columns: 1fr 1fr;
|
|
|
|
|
grid-template-rows: auto auto;
|
|
|
|
|
gap: 12px; padding: 12px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.panel {
|
|
|
|
|
background: #161822; border: 1px solid #2a2d3e; border-radius: 6px;
|
|
|
|
|
padding: 14px; overflow: hidden;
|
|
|
|
|
}
|
|
|
|
|
.panel h2 { font-size: 12px; color: #888; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 10px; }
|
|
|
|
|
|
|
|
|
|
.stats-cards {
|
|
|
|
|
display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
|
|
|
|
|
}
|
|
|
|
|
.stat-card {
|
|
|
|
|
background: #1c1f2e; border-radius: 4px; padding: 10px; text-align: center;
|
|
|
|
|
}
|
|
|
|
|
.stat-card .value { font-size: 22px; font-weight: 700; color: #fff; }
|
|
|
|
|
.stat-card .label { font-size: 10px; color: #888; text-transform: uppercase; margin-top: 2px; }
|
|
|
|
|
|
|
|
|
|
.chart-panel { grid-row: span 2; }
|
|
|
|
|
canvas#workerChart { width: 100%; height: 200px; }
|
|
|
|
|
|
2026-02-13 08:56:30 +00:00
|
|
|
.worker-cards { display: flex; flex-direction: column; gap: 6px; }
|
|
|
|
|
.worker-card {
|
|
|
|
|
display: flex; align-items: center; gap: 10px;
|
|
|
|
|
background: #1c1f2e; border-radius: 4px; padding: 6px 10px;
|
|
|
|
|
}
|
|
|
|
|
.worker-card .wc-id { font-weight: 700; min-width: 32px; }
|
|
|
|
|
.worker-card .wc-bar-wrap { flex: 1; height: 14px; background: #0f1117; border-radius: 2px; overflow: hidden; display: flex; }
|
|
|
|
|
.worker-card .wc-bar-seg { height: 100%; }
|
|
|
|
|
.worker-card .wc-stats { font-size: 11px; color: #888; min-width: 200px; text-align: right; }
|
|
|
|
|
.worker-card .wc-spark { display: inline-flex; gap: 4px; margin-left: 6px; }
|
|
|
|
|
|
2026-02-09 09:04:57 +00:00
|
|
|
.actor-table-wrap { max-height: 200px; overflow-y: auto; }
|
|
|
|
|
.actor-table-wrap table { width: 100%; border-collapse: collapse; }
|
|
|
|
|
.actor-table-wrap th, .actor-table-wrap td {
|
|
|
|
|
padding: 4px 8px; text-align: left; border-bottom: 1px solid #2a2d3e; font-size: 12px;
|
|
|
|
|
}
|
|
|
|
|
.actor-table-wrap th { color: #888; font-weight: 500; position: sticky; top: 0; background: #161822; }
|
|
|
|
|
|
|
|
|
|
.log-panel {
|
|
|
|
|
grid-column: 1 / -1;
|
|
|
|
|
}
|
|
|
|
|
.log-wrap { max-height: 300px; overflow-y: auto; }
|
|
|
|
|
.log-wrap table { width: 100%; border-collapse: collapse; }
|
|
|
|
|
.log-wrap th, .log-wrap td {
|
|
|
|
|
padding: 3px 8px; text-align: left; border-bottom: 1px solid #1c1f2e; font-size: 11px;
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
}
|
|
|
|
|
.log-wrap th { color: #888; font-weight: 500; position: sticky; top: 0; background: #161822; }
|
|
|
|
|
.log-wrap td.msg { white-space: normal; word-break: break-all; max-width: 400px; }
|
|
|
|
|
|
|
|
|
|
.level-ERROR { color: #f44336; font-weight: 700; }
|
|
|
|
|
.level-WARN { color: #ff9800; }
|
|
|
|
|
.level-INFO { color: #4caf50; }
|
|
|
|
|
.level-DEBUG { color: #2196f3; }
|
|
|
|
|
.level-TRACE { color: #666; }
|
|
|
|
|
|
2026-02-11 15:23:26 +00:00
|
|
|
.worker-detail-panel { grid-column: 1 / -1; }
|
|
|
|
|
.worker-detail-scroll { max-height: 360px; overflow-y: auto; }
|
|
|
|
|
.worker-group { margin-bottom: 8px; border: 1px solid #2a2d3e; border-radius: 4px; overflow: hidden; }
|
|
|
|
|
.worker-group-header {
|
|
|
|
|
display: flex; align-items: center; justify-content: space-between;
|
|
|
|
|
padding: 7px 12px; background: #1c1f2e; cursor: pointer; user-select: none;
|
|
|
|
|
}
|
|
|
|
|
.worker-group-header:hover { background: #22253a; }
|
|
|
|
|
.worker-group-header .wid { font-weight: 700; }
|
|
|
|
|
.worker-group-header .summary { color: #888; font-size: 11px; }
|
|
|
|
|
.worker-group-header .toggle { color: #555; font-size: 14px; }
|
2026-02-13 08:49:19 +00:00
|
|
|
.worker-group-header .sparkline-wrap { display: inline-flex; gap: 8px; margin-left: 12px; }
|
|
|
|
|
.worker-group-header .sparkline-wrap svg { vertical-align: middle; }
|
2026-02-11 15:23:26 +00:00
|
|
|
.worker-group-body { display: none; }
|
|
|
|
|
.worker-group.open .worker-group-body { display: block; }
|
|
|
|
|
.worker-group-body table { width: 100%; border-collapse: collapse; }
|
|
|
|
|
.worker-group-body th, .worker-group-body td {
|
|
|
|
|
padding: 3px 10px; text-align: left; border-bottom: 1px solid #1c1f2e; font-size: 11px;
|
|
|
|
|
}
|
|
|
|
|
.worker-group-body th { color: #888; font-weight: 500; background: #161822; }
|
|
|
|
|
.msg-type { color: #4caf50; }
|
|
|
|
|
.msg-type.none { color: #555; font-style: italic; }
|
|
|
|
|
|
2026-02-09 09:04:57 +00:00
|
|
|
::-webkit-scrollbar { width: 6px; }
|
|
|
|
|
::-webkit-scrollbar-track { background: #0f1117; }
|
|
|
|
|
::-webkit-scrollbar-thumb { background: #2a2d3e; border-radius: 3px; }
|
|
|
|
|
</style>
|
|
|
|
|
</head>
|
|
|
|
|
<body>
|
|
|
|
|
<div class="header">
|
2026-02-11 15:23:26 +00:00
|
|
|
<div class="header-left">
|
|
|
|
|
<h1>
|
|
|
|
|
Swactor Runtime Dashboard
|
|
|
|
|
<span id="statusDot" class="status-dot"></span>
|
|
|
|
|
<span id="replayBadge" class="replay-badge">REPLAY</span>
|
|
|
|
|
</h1>
|
|
|
|
|
<nav class="nav-links">
|
|
|
|
|
<a href="/" class="nav-link active">Overview</a>
|
|
|
|
|
<a href="/actors" class="nav-link">Actors</a>
|
2026-02-12 09:13:50 +00:00
|
|
|
<a href="/distribution" class="nav-link">Distribution</a>
|
2026-02-11 15:23:26 +00:00
|
|
|
</nav>
|
|
|
|
|
</div>
|
2026-02-09 09:04:57 +00:00
|
|
|
<div class="header-right">
|
|
|
|
|
<span id="replaySpeed" style="color:#2196f3;font-size:12px;display:none;"></span>
|
|
|
|
|
<span id="replayPct" style="color:#888;font-size:12px;display:none;"></span>
|
|
|
|
|
<span id="uptimeLabel" style="color:#888;font-size:12px;"></span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div id="progressBarWrap" class="progress-bar-wrap">
|
|
|
|
|
<div id="progressFill" class="progress-fill"></div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2026-02-13 08:59:38 +00:00
|
|
|
<div id="warningBanner" style="display:none;padding:8px 20px;background:#1c1f2e;border-bottom:1px solid #2a2d3e;font-size:12px;"></div>
|
2026-02-09 09:04:57 +00:00
|
|
|
<div class="grid">
|
|
|
|
|
<div class="panel chart-panel">
|
2026-02-13 08:56:30 +00:00
|
|
|
<h2>Worker Utilization</h2>
|
|
|
|
|
<div id="workerCards" class="worker-cards"></div>
|
|
|
|
|
<div style="margin-top:6px;font-size:10px;color:#555;">
|
|
|
|
|
<span style="color:#4caf50;">\u25A0</span> processing
|
|
|
|
|
<span style="color:#2196f3;">\u25A0</span> delivery
|
|
|
|
|
<span style="color:#00bcd4;">\u25A0</span> spawns
|
|
|
|
|
<span style="color:#f44336;">\u25A0</span> overhead
|
|
|
|
|
</div>
|
2026-02-09 09:04:57 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="panel">
|
|
|
|
|
<h2>Stats</h2>
|
|
|
|
|
<div class="stats-cards">
|
|
|
|
|
<div class="stat-card"><div class="value" id="statActors">0</div><div class="label">Actors</div></div>
|
|
|
|
|
<div class="stat-card"><div class="value" id="statMessages">0</div><div class="label">Messages</div></div>
|
|
|
|
|
<div class="stat-card"><div class="value" id="statWorkers">0</div><div class="label">Workers</div></div>
|
|
|
|
|
<div class="stat-card"><div class="value" id="statMailbox">0</div><div class="label">Mailbox</div></div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="panel">
|
|
|
|
|
<h2>Actors</h2>
|
|
|
|
|
<div class="actor-table-wrap">
|
|
|
|
|
<table>
|
|
|
|
|
<thead><tr><th>Address</th><th>Worker</th></tr></thead>
|
|
|
|
|
<tbody id="actorTableBody"></tbody>
|
|
|
|
|
</table>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2026-02-11 15:23:26 +00:00
|
|
|
<div class="panel worker-detail-panel">
|
|
|
|
|
<h2>Worker Details</h2>
|
|
|
|
|
<div class="worker-detail-scroll" id="workerDetailContainer"></div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2026-02-09 09:04:57 +00:00
|
|
|
<div class="panel log-panel">
|
|
|
|
|
<h2>Activity Log <span id="logCount" style="color:#555;font-weight:400;"></span></h2>
|
|
|
|
|
<div class="log-wrap" id="logWrap">
|
|
|
|
|
<table>
|
|
|
|
|
<thead><tr><th>Seq</th><th>Time</th><th>Level</th><th>Worker</th><th>Message</th><th>Fields</th></tr></thead>
|
|
|
|
|
<tbody id="logTableBody"></tbody>
|
|
|
|
|
</table>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
(function() {
|
|
|
|
|
var DASHBOARD_MODE = '__DASHBOARD_MODE__';
|
|
|
|
|
var logRowCount = 0;
|
|
|
|
|
var MAX_LOG_ROWS = 2000;
|
|
|
|
|
var isReplay = (DASHBOARD_MODE === 'replay');
|
2026-02-11 15:23:26 +00:00
|
|
|
var lastUptimeMs = null;
|
|
|
|
|
var lastStatsTime = null;
|
2026-02-13 08:49:19 +00:00
|
|
|
var workerHistory = {}; // { id: { message_rates: [], mailbox_depths: [] } }
|
2026-02-09 09:04:57 +00:00
|
|
|
|
|
|
|
|
var dot = document.getElementById('statusDot');
|
|
|
|
|
var uptimeLabel = document.getElementById('uptimeLabel');
|
|
|
|
|
var replayBadge = document.getElementById('replayBadge');
|
|
|
|
|
var replaySpeed = document.getElementById('replaySpeed');
|
|
|
|
|
var replayPct = document.getElementById('replayPct');
|
|
|
|
|
var progressBarWrap = document.getElementById('progressBarWrap');
|
|
|
|
|
var progressFill = document.getElementById('progressFill');
|
|
|
|
|
|
|
|
|
|
if (isReplay) {
|
|
|
|
|
replayBadge.className = 'replay-badge visible';
|
|
|
|
|
progressBarWrap.className = 'progress-bar-wrap visible';
|
|
|
|
|
dot.className = 'status-dot replaying';
|
|
|
|
|
uptimeLabel.style.display = 'none';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function updateUptime() {
|
|
|
|
|
if (isReplay) return;
|
2026-02-11 15:23:26 +00:00
|
|
|
var up = lastUptimeMs;
|
|
|
|
|
if (up !== null && lastStatsTime !== null) {
|
|
|
|
|
up += (Date.now() - lastStatsTime);
|
|
|
|
|
}
|
|
|
|
|
if (up === null) { uptimeLabel.textContent = ''; return; }
|
|
|
|
|
var s = Math.floor(up / 1000);
|
|
|
|
|
var d = Math.floor(s / 86400);
|
|
|
|
|
var h = Math.floor((s % 86400) / 3600);
|
|
|
|
|
var m = Math.floor((s % 3600) / 60);
|
|
|
|
|
var sec = s % 60;
|
|
|
|
|
var parts = [];
|
|
|
|
|
if (d > 0) parts.push(d + 'd');
|
|
|
|
|
if (h > 0 || d > 0) parts.push(h + 'h');
|
|
|
|
|
parts.push(m + 'm');
|
|
|
|
|
parts.push(sec + 's');
|
|
|
|
|
uptimeLabel.textContent = parts.join(' ');
|
2026-02-09 09:04:57 +00:00
|
|
|
}
|
|
|
|
|
setInterval(updateUptime, 1000);
|
|
|
|
|
|
|
|
|
|
var colors = ['#4caf50','#2196f3','#ff9800','#f44336','#9c27b0','#00bcd4','#ffeb3b','#e91e63'];
|
|
|
|
|
|
2026-02-13 08:56:30 +00:00
|
|
|
var phaseColors = ['#4caf50', '#2196f3', '#00bcd4', '#f44336'];
|
|
|
|
|
// Group tick phases: processing=2, delivery=1+4, spawns=0+3, overhead=5
|
|
|
|
|
|
|
|
|
|
function computePhases(timings) {
|
|
|
|
|
if (!timings || timings.length === 0) return [0.25, 0.25, 0.25, 0.25];
|
|
|
|
|
var sums = [0,0,0,0,0,0];
|
|
|
|
|
var active = 0;
|
|
|
|
|
for (var i = 0; i < timings.length; i++) {
|
|
|
|
|
var t = timings[i];
|
|
|
|
|
if (t.did_work) active++;
|
|
|
|
|
for (var p = 0; p < 6 && p < t.phase_us.length; p++) sums[p] += t.phase_us[p];
|
|
|
|
|
}
|
|
|
|
|
var total = sums.reduce(function(a,b) { return a+b; }, 0);
|
|
|
|
|
if (total === 0) return [0.25, 0.25, 0.25, 0.25];
|
|
|
|
|
var processing = sums[2] / total;
|
|
|
|
|
var delivery = (sums[1] + sums[4]) / total;
|
|
|
|
|
var spawns = (sums[0] + sums[3]) / total;
|
|
|
|
|
var overhead = sums[5] / total;
|
|
|
|
|
var load = timings.length > 0 ? active / timings.length : 0;
|
|
|
|
|
return { fracs: [processing, delivery, spawns, overhead], load: load };
|
|
|
|
|
}
|
2026-02-09 09:04:57 +00:00
|
|
|
|
2026-02-13 08:56:30 +00:00
|
|
|
function renderWorkerCards(data) {
|
|
|
|
|
var container = document.getElementById('workerCards');
|
|
|
|
|
if (!data.workers) return;
|
|
|
|
|
container.innerHTML = '';
|
|
|
|
|
|
|
|
|
|
data.workers.forEach(function(w, idx) {
|
|
|
|
|
var timings = data.tick_timings ? data.tick_timings[idx] : null;
|
|
|
|
|
var phases = computePhases(timings);
|
|
|
|
|
var load = phases.load || 0;
|
|
|
|
|
var fracs = phases.fracs || [0.25, 0.25, 0.25, 0.25];
|
|
|
|
|
|
|
|
|
|
var card = document.createElement('div');
|
|
|
|
|
card.className = 'worker-card';
|
|
|
|
|
|
|
|
|
|
// ID
|
|
|
|
|
var idSpan = document.createElement('span');
|
|
|
|
|
idSpan.className = 'wc-id';
|
|
|
|
|
idSpan.style.color = colors[w.id % colors.length];
|
|
|
|
|
idSpan.textContent = 'W' + w.id;
|
|
|
|
|
card.appendChild(idSpan);
|
|
|
|
|
|
|
|
|
|
// Phase bar
|
|
|
|
|
var barWrap = document.createElement('span');
|
|
|
|
|
barWrap.className = 'wc-bar-wrap';
|
|
|
|
|
var filledPct = Math.round(load * 100);
|
|
|
|
|
for (var p = 0; p < 4; p++) {
|
|
|
|
|
var seg = document.createElement('span');
|
|
|
|
|
seg.className = 'wc-bar-seg';
|
|
|
|
|
seg.style.width = (fracs[p] * filledPct) + '%';
|
|
|
|
|
seg.style.background = phaseColors[p];
|
|
|
|
|
barWrap.appendChild(seg);
|
|
|
|
|
}
|
|
|
|
|
card.appendChild(barWrap);
|
|
|
|
|
|
|
|
|
|
// Sparklines
|
|
|
|
|
var sparkWrap = document.createElement('span');
|
|
|
|
|
sparkWrap.className = 'wc-spark';
|
|
|
|
|
var wh = workerHistory[w.id];
|
|
|
|
|
if (wh) {
|
|
|
|
|
sparkWrap.innerHTML = renderSparklineSvg(wh.message_rates, 60, 14, '#4caf50');
|
|
|
|
|
}
|
|
|
|
|
card.appendChild(sparkWrap);
|
|
|
|
|
|
|
|
|
|
// Stats
|
|
|
|
|
var statsSpan = document.createElement('span');
|
|
|
|
|
statsSpan.className = 'wc-stats';
|
|
|
|
|
statsSpan.textContent = w.num_actors + ' actors ' +
|
|
|
|
|
w.messages_processed.toLocaleString() + ' msgs mbox ' + w.mailbox_depth +
|
|
|
|
|
' ' + Math.round(load * 100) + '%';
|
|
|
|
|
card.appendChild(statsSpan);
|
|
|
|
|
|
|
|
|
|
container.appendChild(card);
|
|
|
|
|
});
|
2026-02-09 09:04:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function updateStats(data) {
|
2026-02-11 15:23:26 +00:00
|
|
|
if (typeof data.uptime_ms === 'number') {
|
|
|
|
|
lastUptimeMs = data.uptime_ms;
|
|
|
|
|
lastStatsTime = Date.now();
|
|
|
|
|
}
|
2026-02-09 09:04:57 +00:00
|
|
|
var totalActors = data.actors ? data.actors.length : 0;
|
|
|
|
|
var totalMsgs = data.workers ? data.workers.reduce(function(s, w) { return s + w.messages_processed; }, 0) : 0;
|
|
|
|
|
var totalMailbox = data.workers ? data.workers.reduce(function(s, w) { return s + w.mailbox_depth; }, 0) : 0;
|
|
|
|
|
|
|
|
|
|
document.getElementById('statActors').textContent = totalActors;
|
|
|
|
|
document.getElementById('statMessages').textContent = totalMsgs.toLocaleString();
|
|
|
|
|
document.getElementById('statWorkers').textContent = data.num_workers || 0;
|
|
|
|
|
document.getElementById('statMailbox').textContent = totalMailbox;
|
|
|
|
|
|
2026-02-13 08:56:30 +00:00
|
|
|
renderWorkerCards(data);
|
2026-02-09 09:04:57 +00:00
|
|
|
|
|
|
|
|
var tbody = document.getElementById('actorTableBody');
|
|
|
|
|
tbody.innerHTML = '';
|
|
|
|
|
if (data.actors) {
|
|
|
|
|
var shown = data.actors.slice(0, 200);
|
|
|
|
|
shown.forEach(function(entry) {
|
|
|
|
|
var addr = entry[0];
|
|
|
|
|
var wid = entry[1];
|
|
|
|
|
var hex = '';
|
|
|
|
|
if (addr && addr.length > 0) {
|
|
|
|
|
var bytes = Array.isArray(addr) ? addr : Object.values(addr);
|
|
|
|
|
for (var j = 0; j < Math.min(8, bytes.length); j++) {
|
|
|
|
|
hex += ('0' + bytes[j].toString(16)).slice(-2);
|
|
|
|
|
}
|
|
|
|
|
hex += '\u2026';
|
|
|
|
|
}
|
|
|
|
|
var tr = document.createElement('tr');
|
2026-02-13 08:53:00 +00:00
|
|
|
tr.innerHTML = '<td style="color:#aaa;font-size:11px;"><a href="/actor/' + hex + '" style="color:#aaa;text-decoration:none;">' + hex + '</a></td><td>W' + wid + '</td>';
|
2026-02-09 09:04:57 +00:00
|
|
|
tbody.appendChild(tr);
|
|
|
|
|
});
|
|
|
|
|
if (data.actors.length > 200) {
|
|
|
|
|
var tr2 = document.createElement('tr');
|
|
|
|
|
tr2.innerHTML = '<td colspan="2" style="color:#555;">... and ' + (data.actors.length - 200) + ' more</td>';
|
|
|
|
|
tbody.appendChild(tr2);
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-02-11 15:23:26 +00:00
|
|
|
|
|
|
|
|
updateWorkerDetails(data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function formatAddr(addr) {
|
|
|
|
|
var hex = '';
|
|
|
|
|
if (addr && addr.length > 0) {
|
|
|
|
|
var bytes = Array.isArray(addr) ? addr : Object.values(addr);
|
|
|
|
|
for (var j = 0; j < Math.min(8, bytes.length); j++) {
|
|
|
|
|
hex += ('0' + bytes[j].toString(16)).slice(-2);
|
|
|
|
|
}
|
|
|
|
|
hex += '\u2026';
|
|
|
|
|
}
|
|
|
|
|
return hex;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function shortTypeName(full) {
|
|
|
|
|
if (!full) return '';
|
|
|
|
|
var parts = full.split('::');
|
|
|
|
|
return parts[parts.length - 1];
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-13 08:49:19 +00:00
|
|
|
function renderSparklineSvg(data, w, h, color) {
|
|
|
|
|
if (!data || data.length < 2) return '';
|
|
|
|
|
var max = Math.max.apply(null, data);
|
|
|
|
|
if (max === 0) max = 1;
|
|
|
|
|
var step = w / (data.length - 1);
|
|
|
|
|
var points = data.map(function(v, i) {
|
|
|
|
|
return (i * step).toFixed(1) + ',' + (h - (v / max) * (h - 2) - 1).toFixed(1);
|
|
|
|
|
}).join(' ');
|
|
|
|
|
return '<svg width="' + w + '" height="' + h + '" style="vertical-align:middle">' +
|
|
|
|
|
'<polyline fill="none" stroke="' + color + '" stroke-width="1.5" points="' + points + '"/></svg>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function pushHistorySample(stats) {
|
|
|
|
|
if (!stats.workers) return;
|
|
|
|
|
stats.workers.forEach(function(w) {
|
|
|
|
|
if (!workerHistory[w.id]) {
|
|
|
|
|
workerHistory[w.id] = { message_rates: [], mailbox_depths: [], prev_msgs: w.messages_processed };
|
|
|
|
|
}
|
|
|
|
|
var wh = workerHistory[w.id];
|
|
|
|
|
var rate = w.messages_processed - wh.prev_msgs;
|
|
|
|
|
if (rate < 0) rate = 0;
|
|
|
|
|
wh.prev_msgs = w.messages_processed;
|
|
|
|
|
wh.message_rates.push(rate);
|
|
|
|
|
wh.mailbox_depths.push(w.mailbox_depth);
|
|
|
|
|
if (wh.message_rates.length > 300) { wh.message_rates.shift(); wh.mailbox_depths.shift(); }
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-11 15:23:26 +00:00
|
|
|
function updateWorkerDetails(data) {
|
|
|
|
|
var container = document.getElementById('workerDetailContainer');
|
|
|
|
|
if (!data.workers) return;
|
|
|
|
|
|
|
|
|
|
var groups = {};
|
|
|
|
|
data.workers.forEach(function(w) { groups[w.id] = { info: w, actors: [] }; });
|
|
|
|
|
if (data.actor_details) {
|
|
|
|
|
data.actor_details.forEach(function(a) {
|
|
|
|
|
if (groups[a.worker_id]) groups[a.worker_id].actors.push(a);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var openState = {};
|
|
|
|
|
container.querySelectorAll('.worker-group').forEach(function(g) {
|
|
|
|
|
openState[g.dataset.wid] = g.classList.contains('open');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
container.innerHTML = '';
|
|
|
|
|
var wids = Object.keys(groups).sort(function(a, b) { return a - b; });
|
|
|
|
|
|
|
|
|
|
wids.forEach(function(wid) {
|
|
|
|
|
var g = groups[wid];
|
|
|
|
|
var div = document.createElement('div');
|
|
|
|
|
var isOpen = openState[wid] || false;
|
|
|
|
|
div.className = 'worker-group' + (isOpen ? ' open' : '');
|
|
|
|
|
div.dataset.wid = wid;
|
|
|
|
|
|
|
|
|
|
var hdr = document.createElement('div');
|
|
|
|
|
hdr.className = 'worker-group-header';
|
|
|
|
|
var panicHtml = g.info.panics > 0 ? ', <span style="color:#f44336">' + g.info.panics + ' panics</span>' : '';
|
2026-02-13 08:49:19 +00:00
|
|
|
var wh = workerHistory[wid];
|
|
|
|
|
var sparkHtml = '';
|
|
|
|
|
if (wh) {
|
|
|
|
|
sparkHtml = '<span class="sparkline-wrap">' +
|
|
|
|
|
renderSparklineSvg(wh.message_rates, 80, 16, '#4caf50') +
|
|
|
|
|
renderSparklineSvg(wh.mailbox_depths, 80, 16, '#2196f3') +
|
|
|
|
|
'</span>';
|
|
|
|
|
}
|
2026-02-11 15:23:26 +00:00
|
|
|
hdr.innerHTML =
|
|
|
|
|
'<span class="wid" style="color:' + colors[wid % colors.length] + '">W' + wid + '</span>' +
|
2026-02-13 08:49:19 +00:00
|
|
|
sparkHtml +
|
2026-02-11 15:23:26 +00:00
|
|
|
'<span class="summary">' + g.actors.length + ' actors, ' +
|
|
|
|
|
g.info.messages_processed.toLocaleString() + ' msgs, mbox ' + g.info.mailbox_depth + panicHtml + '</span>' +
|
|
|
|
|
'<span class="toggle">' + (isOpen ? '\u25BC' : '\u25B6') + '</span>';
|
|
|
|
|
hdr.onclick = function() {
|
|
|
|
|
div.classList.toggle('open');
|
|
|
|
|
hdr.querySelector('.toggle').textContent = div.classList.contains('open') ? '\u25BC' : '\u25B6';
|
|
|
|
|
};
|
|
|
|
|
div.appendChild(hdr);
|
|
|
|
|
|
|
|
|
|
var body = document.createElement('div');
|
|
|
|
|
body.className = 'worker-group-body';
|
|
|
|
|
if (g.actors.length === 0) {
|
|
|
|
|
body.innerHTML = '<div style="padding:6px 12px;color:#555;">No actors</div>';
|
|
|
|
|
} else {
|
|
|
|
|
var rows = '';
|
|
|
|
|
g.actors.forEach(function(a) {
|
|
|
|
|
var hex = formatAddr(a.address);
|
|
|
|
|
var hasMsg = !!a.last_msg_type;
|
|
|
|
|
var msgShort = hasMsg ? shortTypeName(a.last_msg_type) : 'none';
|
|
|
|
|
var msgClass = hasMsg ? 'msg-type' : 'msg-type none';
|
|
|
|
|
var title = hasMsg ? ' title="' + escapeHtml(a.last_msg_type) + '"' : '';
|
2026-02-13 08:53:00 +00:00
|
|
|
rows += '<tr><td style="color:#aaa;"><a href="/actor/' + hex + '" style="color:#aaa;text-decoration:none;">' + hex + '</a></td>' +
|
2026-02-11 15:23:26 +00:00
|
|
|
'<td>' + a.mailbox_depth + '</td>' +
|
|
|
|
|
'<td class="' + msgClass + '"' + title + '>' + escapeHtml(msgShort) + '</td></tr>';
|
|
|
|
|
});
|
|
|
|
|
body.innerHTML = '<table><thead><tr><th>Address</th><th>Mailbox</th><th>Last Message</th></tr></thead><tbody>' + rows + '</tbody></table>';
|
|
|
|
|
}
|
|
|
|
|
div.appendChild(body);
|
|
|
|
|
container.appendChild(div);
|
|
|
|
|
});
|
2026-02-09 09:04:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function addLogEvents(events) {
|
|
|
|
|
var tbody = document.getElementById('logTableBody');
|
|
|
|
|
var wrap = document.getElementById('logWrap');
|
|
|
|
|
var wasAtBottom = wrap.scrollTop + wrap.clientHeight >= wrap.scrollHeight - 20;
|
|
|
|
|
|
|
|
|
|
events.forEach(function(ev) {
|
|
|
|
|
if (logRowCount >= MAX_LOG_ROWS) {
|
|
|
|
|
tbody.removeChild(tbody.firstChild);
|
|
|
|
|
logRowCount--;
|
|
|
|
|
}
|
|
|
|
|
var tr = document.createElement('tr');
|
|
|
|
|
var ts = new Date(ev.timestamp_ms);
|
|
|
|
|
var timeStr = ts.toLocaleTimeString() + '.' + String(ts.getMilliseconds()).padStart(3, '0');
|
|
|
|
|
var wid = ev.worker_id !== null && ev.worker_id !== undefined ? 'W' + ev.worker_id : '-';
|
|
|
|
|
var fieldsStr = Object.keys(ev.fields).length > 0 ? JSON.stringify(ev.fields) : '';
|
|
|
|
|
|
|
|
|
|
tr.innerHTML =
|
|
|
|
|
'<td>' + ev.seq + '</td>' +
|
|
|
|
|
'<td>' + timeStr + '</td>' +
|
|
|
|
|
'<td class="level-' + ev.level + '">' + ev.level + '</td>' +
|
|
|
|
|
'<td>' + wid + '</td>' +
|
|
|
|
|
'<td class="msg">' + escapeHtml(ev.message) + '</td>' +
|
|
|
|
|
'<td style="color:#555;max-width:300px;overflow:hidden;text-overflow:ellipsis;">' + escapeHtml(fieldsStr) + '</td>';
|
|
|
|
|
tbody.appendChild(tr);
|
|
|
|
|
logRowCount++;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
document.getElementById('logCount').textContent = '(' + logRowCount + ')';
|
|
|
|
|
|
|
|
|
|
if (wasAtBottom) {
|
|
|
|
|
wrap.scrollTop = wrap.scrollHeight;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function escapeHtml(s) {
|
|
|
|
|
if (!s) return '';
|
|
|
|
|
return s.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function setStatus(s) {
|
|
|
|
|
if (s === 'done') {
|
|
|
|
|
dot.className = 'status-dot done';
|
|
|
|
|
if (isReplay) {
|
|
|
|
|
replayPct.textContent = '100%';
|
|
|
|
|
progressFill.style.width = '100%';
|
|
|
|
|
}
|
|
|
|
|
} else if (s === 'disconnected') {
|
|
|
|
|
dot.className = 'status-dot disconnected';
|
|
|
|
|
} else {
|
|
|
|
|
dot.className = isReplay ? 'status-dot replaying' : 'status-dot';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var es = new EventSource('/events');
|
|
|
|
|
|
|
|
|
|
es.addEventListener('stats', function(e) {
|
2026-02-13 08:49:19 +00:00
|
|
|
try {
|
|
|
|
|
var data = JSON.parse(e.data);
|
|
|
|
|
pushHistorySample(data);
|
|
|
|
|
updateStats(data);
|
|
|
|
|
} catch(err) { console.error('stats parse error', err); }
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
es.addEventListener('history', function(e) {
|
|
|
|
|
try {
|
|
|
|
|
var data = JSON.parse(e.data);
|
|
|
|
|
if (data.workers) {
|
|
|
|
|
data.workers.forEach(function(w) {
|
|
|
|
|
workerHistory[w.id] = {
|
|
|
|
|
message_rates: w.message_rates || [],
|
|
|
|
|
mailbox_depths: w.mailbox_depths || [],
|
|
|
|
|
prev_msgs: 0
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
} catch(err) { console.error('history parse error', err); }
|
2026-02-09 09:04:57 +00:00
|
|
|
});
|
|
|
|
|
|
2026-02-13 08:59:38 +00:00
|
|
|
es.addEventListener('warnings', function(e) {
|
|
|
|
|
try {
|
|
|
|
|
var warnings = JSON.parse(e.data);
|
|
|
|
|
var banner = document.getElementById('warningBanner');
|
|
|
|
|
if (warnings.length === 0) {
|
|
|
|
|
banner.style.display = 'none';
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
banner.style.display = 'block';
|
|
|
|
|
var sevColors = {critical:'#f44336',high:'#ff5722',medium:'#ff9800',low:'#888'};
|
|
|
|
|
var html = warnings.map(function(w) {
|
|
|
|
|
var c = sevColors[w.severity] || '#888';
|
|
|
|
|
return '<span style="color:' + c + ';">\u26A0 ' + w.description + '</span>';
|
|
|
|
|
}).join(' ');
|
|
|
|
|
banner.innerHTML = '<span style="color:#ff9800;font-weight:700;">WARNINGS (' + warnings.length + ')</span> ' + html;
|
|
|
|
|
} catch(err) { console.error('warnings parse error', err); }
|
|
|
|
|
});
|
|
|
|
|
|
2026-02-09 09:04:57 +00:00
|
|
|
es.addEventListener('activity', function(e) {
|
|
|
|
|
try { addLogEvents(JSON.parse(e.data)); } catch(err) { console.error('activity parse error', err); }
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
es.addEventListener('replay_meta', function(e) {
|
|
|
|
|
try {
|
|
|
|
|
var meta = JSON.parse(e.data);
|
|
|
|
|
replaySpeed.textContent = meta.speed + 'x';
|
|
|
|
|
replaySpeed.style.display = 'inline';
|
|
|
|
|
replayPct.style.display = 'inline';
|
|
|
|
|
replayPct.textContent = '0%';
|
|
|
|
|
} catch(err) { console.error('replay_meta parse error', err); }
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
es.addEventListener('replay_progress', function(e) {
|
|
|
|
|
try {
|
|
|
|
|
var data = JSON.parse(e.data);
|
|
|
|
|
var pct = Math.round(data.progress * 100);
|
|
|
|
|
replayPct.textContent = pct + '%';
|
|
|
|
|
progressFill.style.width = pct + '%';
|
|
|
|
|
} catch(err) { console.error('replay_progress parse error', err); }
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
es.addEventListener('done', function() {
|
|
|
|
|
setStatus('done');
|
|
|
|
|
es.close();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
es.onerror = function() {
|
|
|
|
|
setStatus('disconnected');
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
es.onopen = function() {
|
|
|
|
|
setStatus('connected');
|
|
|
|
|
};
|
|
|
|
|
})();
|
|
|
|
|
</script>
|
|
|
|
|
</body>
|
|
|
|
|
</html>
|
|
|
|
|
"##;
|