minga-swarm 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +41 -4
- package/README.md +17 -1
- package/dist/minga.mjs +532 -79
- package/examples/pnp-lean/project.toml +1 -1
- package/package.json +1 -1
- package/src/cli/client.ts +9 -3
- package/src/cli/commands.ts +218 -24
- package/src/cli/dispatch.ts +86 -21
- package/src/cli/doctor.ts +53 -2
- package/src/cli/init.ts +5 -3
- package/src/cli/join-doc.ts +29 -14
- package/src/cli/main.ts +28 -7
- package/src/cli/mcp.ts +54 -13
- package/src/cli/runtime.ts +2 -2
- package/src/cli/store.ts +60 -3
- package/src/cli/sync.ts +157 -0
- package/src/core/protocol.ts +27 -2
- package/src/log/reducer.ts +6 -0
- package/src/sched/scheduler.ts +17 -5
- package/src/server/app.ts +65 -10
- package/src/server/git-http.ts +76 -0
- package/src/server/latency.ts +38 -0
- package/src/server/main.ts +39 -2
- package/src/ui/dev-server.ts +39 -21
- package/src/ui/index.html +266 -116
package/src/ui/index.html
CHANGED
|
@@ -6,25 +6,24 @@
|
|
|
6
6
|
<title>Minga — pnp-lean</title>
|
|
7
7
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
8
8
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
9
|
-
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=IBM+Plex+Sans:wght@400;500;600&
|
|
9
|
+
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=IBM+Plex+Sans:wght@400;500;600&display=swap">
|
|
10
10
|
<style>
|
|
11
11
|
:root{
|
|
12
|
-
--paper:#
|
|
13
|
-
--rule:#
|
|
12
|
+
--paper:#f6f6f4; --paper-2:#ececea; --ink:#161616; --ink-2:#4d4d4d; --ink-3:#8a8a8a;
|
|
13
|
+
--rule:#d9d9d6; --accent:#c8381c;
|
|
14
14
|
--sans:"IBM Plex Sans",system-ui,-apple-system,"Segoe UI",sans-serif;
|
|
15
15
|
--mono:"IBM Plex Mono",ui-monospace,SFMono-Regular,Consolas,monospace;
|
|
16
|
-
--serif:"Newsreader",Georgia,"Times New Roman",serif;
|
|
17
16
|
color-scheme:light;
|
|
18
17
|
}
|
|
19
18
|
@media (prefers-color-scheme: dark){
|
|
20
19
|
:root:not([data-theme=light]){
|
|
21
|
-
--paper:#
|
|
22
|
-
--rule:#
|
|
20
|
+
--paper:#111111; --paper-2:#1a1a1a; --ink:#ececec; --ink-2:#b0b0b0; --ink-3:#767676;
|
|
21
|
+
--rule:#2e2e2e; --accent:#ff6b45; color-scheme:dark;
|
|
23
22
|
}
|
|
24
23
|
}
|
|
25
24
|
:root[data-theme=dark]{
|
|
26
|
-
--paper:#
|
|
27
|
-
--rule:#
|
|
25
|
+
--paper:#111111; --paper-2:#1a1a1a; --ink:#ececec; --ink-2:#b0b0b0; --ink-3:#767676;
|
|
26
|
+
--rule:#2e2e2e; --accent:#ff6b45; color-scheme:dark;
|
|
28
27
|
}
|
|
29
28
|
*{box-sizing:border-box}
|
|
30
29
|
body{
|
|
@@ -36,7 +35,8 @@ body{
|
|
|
36
35
|
.num{text-align:right; font-family:var(--mono); font-variant-numeric:tabular-nums}
|
|
37
36
|
.sc{font-variant-caps:all-small-caps; letter-spacing:.04em; font-size:12px}
|
|
38
37
|
.label{font-variant-caps:all-small-caps; letter-spacing:.04em; font-size:12px; color:var(--ink-2)}
|
|
39
|
-
.caption{font:
|
|
38
|
+
.caption{font:500 15px/1.4 var(--sans); color:var(--ink); margin:6px 0 10px}
|
|
39
|
+
.caption.note,.caption .note{font:400 13px/1.5 var(--sans); color:var(--ink-2)}
|
|
40
40
|
button.textbtn{
|
|
41
41
|
font:500 12px/1.4 var(--sans); color:var(--ink-2); background:none; border:0;
|
|
42
42
|
padding:0 2px; text-decoration:underline; text-underline-offset:3px; cursor:pointer;
|
|
@@ -49,8 +49,8 @@ button.textbtn:hover{color:var(--ink)}
|
|
|
49
49
|
padding:32px 0 24px; border-bottom:1px solid var(--rule);
|
|
50
50
|
}
|
|
51
51
|
.wordmark{font:500 13px/1.2 var(--sans); font-variant-caps:all-small-caps; letter-spacing:.04em; color:var(--ink-2)}
|
|
52
|
-
.masthead h1{font:
|
|
53
|
-
.goal{font:
|
|
52
|
+
.masthead h1{font:600 32px/1.1 var(--sans); letter-spacing:-0.01em; margin:8px 0 6px}
|
|
53
|
+
.goal{font:400 15px/1.45 var(--sans); color:var(--ink-2); margin:0; max-width:68ch}
|
|
54
54
|
.join{text-align:left; min-width:260px}
|
|
55
55
|
.join .line{display:flex; align-items:baseline; gap:10px; margin:4px 0 14px}
|
|
56
56
|
.join .url{font-size:13px; color:var(--ink); overflow-wrap:anywhere}
|
|
@@ -59,18 +59,22 @@ button.textbtn:hover{color:var(--ink)}
|
|
|
59
59
|
.readouts{display:grid; grid-template-columns:repeat(6,minmax(0,1fr)); gap:24px; padding:20px 0; border-bottom:1px solid var(--rule)}
|
|
60
60
|
.readout{min-width:0}
|
|
61
61
|
.readout .val{font:500 20px/1.2 var(--mono); font-variant-numeric:tabular-nums; margin-top:5px; white-space:nowrap}
|
|
62
|
+
.readout .val .sc{font-family:var(--sans); font-size:12px; font-weight:400; color:var(--ink-3)}
|
|
63
|
+
.readout .val .sep{font:400 15px/1 var(--sans); color:var(--ink-3)}
|
|
62
64
|
.spark{display:block; width:100%; height:14px; margin-top:8px; overflow:visible}
|
|
63
65
|
.spark polyline{fill:none; stroke:var(--ink); stroke-width:1; vector-effect:non-scaling-stroke}
|
|
64
66
|
.spark line{stroke:var(--accent); stroke-width:1; vector-effect:non-scaling-stroke}
|
|
65
67
|
|
|
66
68
|
.block{border-bottom:1px solid var(--rule); padding:20px 0}
|
|
67
|
-
.section{font:
|
|
69
|
+
.section{font:500 15px/1.3 var(--sans); margin:0 0 4px; font-variant-caps:all-small-caps; letter-spacing:.02em}
|
|
68
70
|
.section .sc{font-family:var(--sans); color:var(--ink-2); margin-right:8px}
|
|
69
71
|
.main{display:grid; grid-template-columns:minmax(0,3fr) minmax(280px,2fr); gap:24px; border-bottom:1px solid var(--rule); padding:20px 0}
|
|
70
|
-
.cwrap{position:relative; height:
|
|
72
|
+
.cwrap{position:relative; height:min(70vh,900px); min-height:320px; overflow-y:auto; border-top:1px solid var(--rule); border-bottom:1px solid var(--rule); scrollbar-width:thin}
|
|
71
73
|
.cwrap canvas{position:sticky; top:0; left:0; display:block; width:100%; height:100%; outline-offset:-1px}
|
|
72
74
|
.cspacer{width:1px; pointer-events:none}
|
|
73
|
-
.
|
|
75
|
+
.figline{display:flex; align-items:baseline; gap:12px; margin:0 0 8px}
|
|
76
|
+
.figline .label{margin-right:auto}
|
|
77
|
+
.tasklist{position:relative; height:min(70vh,900px); overflow-y:auto; border-top:1px solid var(--rule); border-bottom:1px solid var(--rule); display:none}
|
|
74
78
|
.tasklist .spacer{width:1px}
|
|
75
79
|
.task-row{position:absolute; left:0; right:0; height:22px; display:grid; grid-template-columns:18px 58px minmax(0,1fr) 48px; gap:8px; align-items:center; font-size:12px}
|
|
76
80
|
.task-row .t{font-family:var(--mono); font-size:12px}
|
|
@@ -79,7 +83,7 @@ button.textbtn:hover{color:var(--ink)}
|
|
|
79
83
|
|
|
80
84
|
.rightcol{min-width:0; display:flex; flex-direction:column; gap:20px}
|
|
81
85
|
.margin-note{min-width:0}
|
|
82
|
-
.margin-note .ntitle{font:
|
|
86
|
+
.margin-note .ntitle{font:500 15px/1.3 var(--sans); margin:6px 0}
|
|
83
87
|
.margin-note .nbody{font-size:13px; color:var(--ink-2); margin:0 0 10px; overflow-wrap:anywhere}
|
|
84
88
|
.nlist{margin:0; padding:0; list-style:none}
|
|
85
89
|
.nlist li{font:400 12px/1.5 var(--mono); padding:1px 0; overflow-wrap:anywhere; color:var(--ink-2)}
|
|
@@ -87,33 +91,37 @@ button.textbtn:hover{color:var(--ink)}
|
|
|
87
91
|
.nlist li .role{font-family:var(--sans)}
|
|
88
92
|
.nhead{font-size:12px; color:var(--ink-2); margin:10px 0 3px}
|
|
89
93
|
|
|
90
|
-
.qlist{position:relative; height:
|
|
94
|
+
.qlist{position:relative; max-height:240px; overflow-y:auto; border-top:1px solid var(--rule); border-bottom:1px solid var(--rule); scrollbar-width:thin}
|
|
91
95
|
.qlist .spacer{width:1px}
|
|
92
|
-
.qrow{position:absolute; left:0; right:0; height:20px; display:grid; grid-template-columns:56px 48px minmax(0,1fr) 58px 72px; gap:8px; align-items:center; font:400 12px/20px var(--mono); font-variant-numeric:tabular-nums}
|
|
96
|
+
.qrow{position:absolute; top:0; left:0; right:0; height:20px; display:grid; grid-template-columns:56px 48px minmax(0,1fr) 58px 72px; gap:8px; align-items:center; font:400 12px/20px var(--mono); font-variant-numeric:tabular-nums}
|
|
93
97
|
.qrow .who,.qrow .task{overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
|
|
94
98
|
.qrow.checking{color:var(--accent)}
|
|
95
99
|
.qrow .claim{color:var(--ink-2); font-variant-caps:all-small-caps; letter-spacing:.04em}
|
|
100
|
+
.qrow.more{color:var(--ink-3); font-family:var(--sans); font-size:12px}
|
|
101
|
+
.qlist .qempty{font:400 12px/20px var(--sans); color:var(--ink-3)}
|
|
96
102
|
.loglist{list-style:none; margin:8px 0 0; padding:0; max-height:200px; overflow-y:auto; border-top:1px solid var(--rule); scrollbar-width:thin}
|
|
97
103
|
.logline{display:grid; grid-template-columns:72px 62px 76px minmax(0,1fr); gap:8px; font:400 12px/1.7 var(--mono); font-variant-numeric:tabular-nums; color:var(--ink); overflow-wrap:anywhere}
|
|
98
|
-
.logline
|
|
99
|
-
.logline .verb{color:var(--ink-2)}
|
|
100
|
-
.logline.
|
|
101
|
-
@
|
|
102
|
-
@media (prefers-reduced-motion: reduce){ .logline.new{animation:none} }
|
|
104
|
+
.logline time{color:var(--ink-3)}
|
|
105
|
+
.logline .who,.logline .verb{color:var(--ink-2)}
|
|
106
|
+
.logline.fresh{color:var(--accent); transition:color 1.2s linear}
|
|
107
|
+
@media (prefers-reduced-motion: reduce){ .logline.fresh{transition:none} }
|
|
103
108
|
|
|
104
|
-
table{width:100%; border-collapse:collapse; table-layout:
|
|
105
|
-
caption{text-align:left; font:
|
|
109
|
+
table{width:100%; border-collapse:collapse; table-layout:auto}
|
|
110
|
+
caption{text-align:left; font:400 13px/1.4 var(--sans); color:var(--ink-2); padding:6px 0 10px}
|
|
106
111
|
thead th{
|
|
107
112
|
font-variant-caps:all-small-caps; letter-spacing:.04em; font-size:12px; font-weight:400;
|
|
108
113
|
color:var(--ink-2); text-align:left; border-top:1px solid var(--rule); border-bottom:1px solid var(--rule); padding:6px 8px;
|
|
109
114
|
}
|
|
110
115
|
thead th.num{text-align:right}
|
|
111
|
-
tbody td{
|
|
116
|
+
thead th.rank,tbody td.rank{width:3.5em; text-align:right}
|
|
117
|
+
tbody td{font:400 13px/1.5 var(--sans); padding:5px 8px; border-bottom:1px solid var(--rule); white-space:nowrap}
|
|
118
|
+
tbody td.trunc{max-width:28ch; overflow:hidden; text-overflow:ellipsis}
|
|
112
119
|
tbody td.num{font-size:12px}
|
|
113
120
|
tbody tr:nth-child(even){background:var(--paper-2)}
|
|
114
121
|
td.mono{font:400 12px/1.5 var(--mono); font-variant-numeric:tabular-nums}
|
|
115
|
-
.barcell{width:
|
|
116
|
-
.
|
|
122
|
+
.barcell{width:80px}
|
|
123
|
+
.track{display:block; width:80px; height:1px; background:var(--rule)}
|
|
124
|
+
.bar{display:block; height:2px; max-width:80px; background:var(--ink)}
|
|
117
125
|
.tables{display:grid; grid-template-columns:minmax(0,3fr) minmax(0,2fr); gap:24px; padding:20px 0; border-bottom:1px solid var(--rule)}
|
|
118
126
|
.tables section{min-width:0}
|
|
119
127
|
|
|
@@ -174,7 +182,7 @@ td.mono{font:400 12px/1.5 var(--mono); font-variant-numeric:tabular-nums}
|
|
|
174
182
|
<div class="main">
|
|
175
183
|
<section class="figure-section" aria-label="Task field">
|
|
176
184
|
<h2 class="section"><span class="sc">Fig. 1</span> Task field</h2>
|
|
177
|
-
<p class="caption">
|
|
185
|
+
<p class="caption"><span class="mono" id="rowCount">0 rows</span> · <button type="button" class="textbtn" id="collapseAll">collapse all</button> / <button type="button" class="textbtn" id="expandAll">expand all</button> <span class="note">— areas are branch points, expanded on load. Leaves carry one tick per live attempt; tick height is the lease left. Hover or focus a row for the note at right. Arrows move, Enter opens an area.</span></p>
|
|
178
186
|
<div class="cwrap" id="cwrap">
|
|
179
187
|
<canvas id="cv" tabindex="0" role="img" aria-label="Task field dendrogram with live attempt ticks"></canvas>
|
|
180
188
|
<div class="cspacer" id="cspacer"></div>
|
|
@@ -193,7 +201,7 @@ td.mono{font:400 12px/1.5 var(--mono); font-variant-numeric:tabular-nums}
|
|
|
193
201
|
|
|
194
202
|
<section aria-label="Queue">
|
|
195
203
|
<h2 class="section">Queue</h2>
|
|
196
|
-
<p class="caption">Pending checks in order. Checking rows are marked in vermilion.</p>
|
|
204
|
+
<p class="caption note">Pending checks in order. Checking rows are marked in vermilion.</p>
|
|
197
205
|
<div class="qlist" id="qlist"><div class="spacer" id="qspacer"></div></div>
|
|
198
206
|
</section>
|
|
199
207
|
|
|
@@ -208,7 +216,7 @@ td.mono{font:400 12px/1.5 var(--mono); font-variant-numeric:tabular-nums}
|
|
|
208
216
|
<section aria-label="Leaderboard">
|
|
209
217
|
<h2 class="section"><span class="sc">Table 1</span> Leaderboard</h2>
|
|
210
218
|
<table><caption>Agents by points, at most one hundred rows.</caption>
|
|
211
|
-
<thead><tr><th>rank</th><th>agent</th><th>owner</th><th>model</th><th>harness</th><th class="num">points</th><th class="num">accepted</th><th class="num">submissions</th></tr></thead>
|
|
219
|
+
<thead><tr><th class="num rank">rank</th><th>agent</th><th>owner</th><th>model</th><th>harness</th><th class="num">points</th><th class="num">accepted</th><th class="num">submissions</th></tr></thead>
|
|
212
220
|
<tbody id="leaderBody"></tbody>
|
|
213
221
|
</table>
|
|
214
222
|
</section>
|
|
@@ -246,7 +254,18 @@ td.mono{font:400 12px/1.5 var(--mono); font-variant-numeric:tabular-nums}
|
|
|
246
254
|
const clamp = (x, lo, hi) => x < lo ? lo : x > hi ? hi : x;
|
|
247
255
|
const TAU = Math.PI * 2;
|
|
248
256
|
const ROW_H = 22;
|
|
249
|
-
const
|
|
257
|
+
const SAMPLE_MS = 5000; // one sample every 5 s
|
|
258
|
+
const HISTORY = 60; // 60 samples = the last 5 minutes
|
|
259
|
+
const MIN_SAMPLES = 3; // fewer samples leave the spark space empty
|
|
260
|
+
const MAX_QUEUE_ROWS = 12; // 12 rows x 20px = the 240px strip cap
|
|
261
|
+
const X_COUNT = 268; // fixed, right-aligned child-count column
|
|
262
|
+
// Only fonts from the design spec are ever handed to the canvas.
|
|
263
|
+
const FONT_SANS = '"IBM Plex Sans"';
|
|
264
|
+
const FONT_MONO = '"IBM Plex Mono"';
|
|
265
|
+
const AREA_FONT = "500 13px " + FONT_SANS;
|
|
266
|
+
const TITLE_FONT = "400 13px " + FONT_SANS;
|
|
267
|
+
const ID_FONT = "400 12px " + FONT_MONO;
|
|
268
|
+
const TICK_FONT = "400 12px " + FONT_MONO;
|
|
250
269
|
|
|
251
270
|
const EVENT_TYPES = [
|
|
252
271
|
"agent.joined", "agent.banned", "task.posted", "task.closed", "attempt.started",
|
|
@@ -319,6 +338,19 @@ td.mono{font:400 12px/1.5 var(--mono); font-variant-numeric:tabular-nums}
|
|
|
319
338
|
let W = 0, H = 0, dpr = 1, scrollTop = 0;
|
|
320
339
|
let pendingEvents = [];
|
|
321
340
|
let flushing = false;
|
|
341
|
+
let fontsReady = !document.fonts;
|
|
342
|
+
|
|
343
|
+
function watchFonts() {
|
|
344
|
+
if (!document.fonts) return;
|
|
345
|
+
const ready = () => {
|
|
346
|
+
fontsReady = true;
|
|
347
|
+
staticDirty = true;
|
|
348
|
+
needDraw = true;
|
|
349
|
+
if (reduce) draw(0);
|
|
350
|
+
};
|
|
351
|
+
try { document.fonts.ready.then(ready, ready); } catch (_) { fontsReady = true; }
|
|
352
|
+
try { document.fonts.addEventListener("loadingdone", ready); } catch (_) { /* not supported */ }
|
|
353
|
+
}
|
|
322
354
|
|
|
323
355
|
function clock(iso) {
|
|
324
356
|
const d = new Date(iso);
|
|
@@ -335,6 +367,60 @@ td.mono{font:400 12px/1.5 var(--mono); font-variant-numeric:tabular-nums}
|
|
|
335
367
|
const familyGlyph = modelName => hash(S(modelName)) % 6;
|
|
336
368
|
const numId = id => N(S(id).replace(/^T-/, ""));
|
|
337
369
|
|
|
370
|
+
// Pure formatting helpers. Exposed on the test hook so layout rules can be
|
|
371
|
+
// checked without a browser; each one is also used by a renderer below.
|
|
372
|
+
function clipText(text, maxWidth, measure) {
|
|
373
|
+
const full = S(text);
|
|
374
|
+
if (measure(full) <= maxWidth) return full;
|
|
375
|
+
if (maxWidth <= 0) return "";
|
|
376
|
+
const ell = "…";
|
|
377
|
+
let lo = 0, hi = full.length;
|
|
378
|
+
while (lo < hi) {
|
|
379
|
+
const mid = Math.ceil((lo + hi) / 2);
|
|
380
|
+
if (measure(full.slice(0, mid) + ell) <= maxWidth) lo = mid; else hi = mid - 1;
|
|
381
|
+
}
|
|
382
|
+
return lo > 0 ? full.slice(0, lo) + ell : ell;
|
|
383
|
+
}
|
|
384
|
+
function sparkGeometry(a) {
|
|
385
|
+
if (!Array.isArray(a) || a.length < MIN_SAMPLES) return { points: "", y1: 7, y2: 7 };
|
|
386
|
+
let min = Infinity, max = -Infinity;
|
|
387
|
+
for (const v of a) { if (v < min) min = v; if (v > max) max = v; }
|
|
388
|
+
const span = Math.max(1, max - min);
|
|
389
|
+
const yOf = v => 13 - Math.round((v - min) / span * 12);
|
|
390
|
+
const points = a.map((v, k) => k + "," + yOf(v)).join(" ");
|
|
391
|
+
const y = yOf(a[a.length - 1]);
|
|
392
|
+
return { points, y1: y - 2, y2: y + 2 };
|
|
393
|
+
}
|
|
394
|
+
function queueLayout(count) {
|
|
395
|
+
const n = Math.max(0, N(count));
|
|
396
|
+
const shown = Math.min(n, MAX_QUEUE_ROWS);
|
|
397
|
+
const extra = n - shown;
|
|
398
|
+
return { shown, extra, rows: shown + (extra > 0 ? 1 : 0) };
|
|
399
|
+
}
|
|
400
|
+
function busiestOpenLeaf(tasks, liveByTask) {
|
|
401
|
+
let best = null, bestCount = -1;
|
|
402
|
+
for (const t of tasks || []) {
|
|
403
|
+
if (!t || t.status !== "open" || (t.children || []).length > 0) continue;
|
|
404
|
+
const list = (liveByTask && liveByTask.get(t.id)) || [];
|
|
405
|
+
if (list.length > bestCount) { best = t; bestCount = list.length; }
|
|
406
|
+
}
|
|
407
|
+
return best;
|
|
408
|
+
}
|
|
409
|
+
function logObject(type, d, actor, task) {
|
|
410
|
+
switch (type) {
|
|
411
|
+
case "attempt.beat":
|
|
412
|
+
case "attempt.ended": return S(task) + " · " + S(d.attempt);
|
|
413
|
+
case "note.added": return S(task) + " " + S(d.kind);
|
|
414
|
+
case "submission.checked": return S(task) + " " + (d.ok ? "accepted" : "rejected");
|
|
415
|
+
case "task.closed": return S(task) + " " + S(d.status);
|
|
416
|
+
case "attempt.started": return S(task) + " " + S(d.role);
|
|
417
|
+
case "proposal.decided": return S(d.proposal) + " " + (d.accepted ? "accepted" : "rejected");
|
|
418
|
+
case "agent.joined": return S(d.model) + " · " + S(d.harness);
|
|
419
|
+
case "rule.changed": return Object.keys(d.rules || {}).join(" ");
|
|
420
|
+
default: return S(task || d.proposal || d.submission || d.agent || actor || "");
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
|
|
338
424
|
function reindex() {
|
|
339
425
|
agentById = new Map(model.agents.map(a => [a.id, a]));
|
|
340
426
|
taskById = new Map(model.tasks.map(t => [t.id, t]));
|
|
@@ -350,7 +436,7 @@ td.mono{font:400 12px/1.5 var(--mono); font-variant-numeric:tabular-nums}
|
|
|
350
436
|
pendingSubs = [];
|
|
351
437
|
subsByAttempt = new Map();
|
|
352
438
|
for (const s of model.submissions) {
|
|
353
|
-
if (s.status === "queued" || s.status === "checking") pendingSubs.
|
|
439
|
+
if (s.status === "queued" || s.status === "checking") pendingSubs.push(s);
|
|
354
440
|
if (s.status === "checking") checking.add(s.attempt);
|
|
355
441
|
const list = subsByAttempt.get(s.attempt) || [];
|
|
356
442
|
list.unshift(s);
|
|
@@ -379,15 +465,20 @@ td.mono{font:400 12px/1.5 var(--mono); font-variant-numeric:tabular-nums}
|
|
|
379
465
|
N(t.accepted), N(t.openTasks), eventTimes.length,
|
|
380
466
|
];
|
|
381
467
|
}
|
|
382
|
-
function pushSample(
|
|
468
|
+
function pushSample() {
|
|
383
469
|
const vals = sampleValues();
|
|
384
470
|
for (let i = 0; i < vals.length; i += 1) {
|
|
385
471
|
const key = "s" + i;
|
|
386
472
|
const a = samples[key] || (samples[key] = []);
|
|
387
|
-
|
|
388
|
-
|
|
473
|
+
a.push(vals[i]);
|
|
474
|
+
if (a.length > HISTORY) a.shift();
|
|
389
475
|
}
|
|
390
476
|
}
|
|
477
|
+
function maybeSample() {
|
|
478
|
+
const at = Date.now();
|
|
479
|
+
if (at - lastSample >= SAMPLE_MS) { pushSample(); lastSample = at; }
|
|
480
|
+
}
|
|
481
|
+
const sampleLengths = () => Object.keys(samples).sort().map(k => samples[k].length);
|
|
391
482
|
|
|
392
483
|
function applyView(view) {
|
|
393
484
|
if (!view || !view.project || !Array.isArray(view.tasks)) return;
|
|
@@ -401,8 +492,8 @@ td.mono{font:400 12px/1.5 var(--mono); font-variant-numeric:tabular-nums}
|
|
|
401
492
|
$("joinUrl").textContent = location.origin + "/join";
|
|
402
493
|
$("headAgent").textContent = S(view.project.headAgent) || "not set";
|
|
403
494
|
eventTimes = [];
|
|
404
|
-
|
|
405
|
-
lastSample = Date.now();
|
|
495
|
+
// Seed once, and never let later view resyncs reset the sampling clock.
|
|
496
|
+
if (Object.keys(samples).length === 0) { pushSample(); lastSample = Date.now(); }
|
|
406
497
|
if (!selectedTask || !model.tasks.some(t => t.id === selectedTask)) selectedTask = null;
|
|
407
498
|
reindex();
|
|
408
499
|
renderLogAll();
|
|
@@ -440,16 +531,11 @@ td.mono{font:400 12px/1.5 var(--mono); font-variant-numeric:tabular-nums}
|
|
|
440
531
|
|
|
441
532
|
function logEvent(e) {
|
|
442
533
|
const d = e.data || {};
|
|
443
|
-
|
|
534
|
+
// Beat/released events carry only an attempt id; resolve its task before formatting.
|
|
535
|
+
const task = S(d.task) || S(attemptById.get(S(d.attempt))?.task || "");
|
|
536
|
+
const object = logObject(e.type, d, e.actor, task);
|
|
444
537
|
let verb = VERBS[e.type] || S(e.type).split(".")[1] || "event";
|
|
445
538
|
if (e.type === "submission.checked") verb = d.ok ? "accepted" : "rejected";
|
|
446
|
-
if (e.type === "note.added") object = S(d.task) + " " + S(d.kind);
|
|
447
|
-
else if (e.type === "submission.checked") object = S(d.task) + " " + (d.ok ? "accepted" : "rejected");
|
|
448
|
-
else if (e.type === "task.closed") object = S(d.task) + " " + S(d.status);
|
|
449
|
-
else if (e.type === "attempt.started") object = S(d.task) + " " + S(d.role);
|
|
450
|
-
else if (e.type === "proposal.decided") object = S(d.proposal) + " " + (d.accepted ? "accepted" : "rejected");
|
|
451
|
-
else if (e.type === "agent.joined") object = S(d.model) + " " + S(d.harness);
|
|
452
|
-
else if (e.type === "rule.changed") object = Object.keys(d.rules || {}).join(" ");
|
|
453
539
|
logLines.unshift({ at: S(e.at), actor: S(e.actor), verb, object, fresh: true });
|
|
454
540
|
if (logLines.length > 200) logLines.pop();
|
|
455
541
|
logCount += 1;
|
|
@@ -540,7 +626,7 @@ td.mono{font:400 12px/1.5 var(--mono); font-variant-numeric:tabular-nums}
|
|
|
540
626
|
bytes: N(d.bytes), status: "queued", queuedAt: S(e.at), runs: 0, points: 0,
|
|
541
627
|
};
|
|
542
628
|
model.submissions.unshift(s);
|
|
543
|
-
pendingSubs.
|
|
629
|
+
pendingSubs.push(s);
|
|
544
630
|
const list = subsByAttempt.get(s.attempt) || [];
|
|
545
631
|
list.unshift(s); subsByAttempt.set(s.attempt, list);
|
|
546
632
|
if (list.length > 6) list.pop();
|
|
@@ -617,8 +703,7 @@ td.mono{font:400 12px/1.5 var(--mono); font-variant-numeric:tabular-nums}
|
|
|
617
703
|
logEvent(e);
|
|
618
704
|
eventTimes.push(Date.now());
|
|
619
705
|
if (eventTimes.length > 600) eventTimes.shift();
|
|
620
|
-
|
|
621
|
-
if (at - lastSample > 10000) { pushSample(false); lastSample = at; }
|
|
706
|
+
maybeSample();
|
|
622
707
|
}
|
|
623
708
|
|
|
624
709
|
function flush() {
|
|
@@ -641,7 +726,15 @@ td.mono{font:400 12px/1.5 var(--mono); font-variant-numeric:tabular-nums}
|
|
|
641
726
|
|
|
642
727
|
// ------------------------------------------------------------------ figure
|
|
643
728
|
|
|
729
|
+
function syncFigure() {
|
|
730
|
+
$("cspacer").style.height = Math.max(0, rows.length * ROW_H - H) + "px";
|
|
731
|
+
$("rowCount").textContent = rows.length + " rows";
|
|
732
|
+
staticDirty = true;
|
|
733
|
+
needDraw = true;
|
|
734
|
+
}
|
|
735
|
+
|
|
644
736
|
function buildRows() {
|
|
737
|
+
if (!model) return;
|
|
645
738
|
const byParent = new Map();
|
|
646
739
|
for (const t of model.tasks) {
|
|
647
740
|
const key = t.parent && taskById.has(t.parent) ? t.parent : "";
|
|
@@ -651,25 +744,20 @@ td.mono{font:400 12px/1.5 var(--mono); font-variant-numeric:tabular-nums}
|
|
|
651
744
|
}
|
|
652
745
|
for (const list of byParent.values()) list.sort((a, b) => numId(a.id) - numId(b.id));
|
|
653
746
|
rows = [];
|
|
654
|
-
|
|
747
|
+
// All areas start expanded: an empty `collapsed` set means no branch is hidden.
|
|
748
|
+
// Each row remembers its nearest area ancestor so connectors never need an O(n) scan.
|
|
749
|
+
const walk = (t, parentIndex, depth) => {
|
|
655
750
|
const kids = byParent.get(t.id) || [];
|
|
656
|
-
|
|
751
|
+
const index = rows.length;
|
|
752
|
+
const area = kids.length > 0;
|
|
753
|
+
rows.push({ kind: area ? "area" : "leaf", task: t, depth, parentIndex });
|
|
657
754
|
if (collapsed.has(t.id)) return;
|
|
658
|
-
for (const k of kids)
|
|
659
|
-
const start = rows.length;
|
|
660
|
-
walk(k);
|
|
661
|
-
if (rows[start]) rows[start].depth = rows[start].depth || 1;
|
|
662
|
-
}
|
|
663
|
-
if (kids.length) {
|
|
664
|
-
const end = rows.length - 1;
|
|
665
|
-
for (let i = start; i <= end; i += 1) if (rows[i]) rows[i].depth = Math.max(rows[i].depth, 1);
|
|
666
|
-
}
|
|
755
|
+
for (const k of kids) walk(k, area ? index : parentIndex, depth + 1);
|
|
667
756
|
};
|
|
668
|
-
for (const t of byParent.get("") || []) walk(t);
|
|
757
|
+
for (const t of byParent.get("") || []) walk(t, -1, 0);
|
|
669
758
|
const placed = new Set(rows.map(r => r.task.id));
|
|
670
|
-
for (const t of model.tasks) if (!placed.has(t.id)) rows.push({ kind: "leaf", task: t, depth: 1 });
|
|
671
|
-
|
|
672
|
-
needDraw = true;
|
|
759
|
+
for (const t of model.tasks) if (!placed.has(t.id)) rows.push({ kind: "leaf", task: t, depth: 1, parentIndex: -1 });
|
|
760
|
+
syncFigure();
|
|
673
761
|
}
|
|
674
762
|
|
|
675
763
|
const canvas = $("cv");
|
|
@@ -688,9 +776,7 @@ td.mono{font:400 12px/1.5 var(--mono); font-variant-numeric:tabular-nums}
|
|
|
688
776
|
plate.height = canvas.height;
|
|
689
777
|
ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
|
|
690
778
|
pctx.setTransform(dpr, 0, 0, dpr, 0, 0);
|
|
691
|
-
|
|
692
|
-
staticDirty = true;
|
|
693
|
-
needDraw = true;
|
|
779
|
+
syncFigure();
|
|
694
780
|
if (reduce) draw(0);
|
|
695
781
|
}
|
|
696
782
|
|
|
@@ -739,10 +825,10 @@ td.mono{font:400 12px/1.5 var(--mono); font-variant-numeric:tabular-nums}
|
|
|
739
825
|
const xMark = 152;
|
|
740
826
|
const xId = 170;
|
|
741
827
|
const xTitle = 224;
|
|
742
|
-
const monoFont = "12px " + (css("--mono") || "monospace");
|
|
743
|
-
const sansFont = "13px " + (css("--sans") || "sans-serif");
|
|
744
828
|
|
|
745
|
-
|
|
829
|
+
// Text is painted only with the loaded spec fonts; the grid above stays visible meanwhile.
|
|
830
|
+
if (!fontsReady) return;
|
|
831
|
+
pctx.font = ID_FONT;
|
|
746
832
|
pctx.textBaseline = "middle";
|
|
747
833
|
pctx.textAlign = "left";
|
|
748
834
|
for (let i = first; i < last; i += 1) {
|
|
@@ -750,30 +836,44 @@ td.mono{font:400 12px/1.5 var(--mono); font-variant-numeric:tabular-nums}
|
|
|
750
836
|
if (!row) continue;
|
|
751
837
|
const y = i * ROW_H - scrollTop + ROW_H / 2;
|
|
752
838
|
const t = row.task;
|
|
753
|
-
pctx.fillStyle = C["--ink-2"];
|
|
754
839
|
if (row.kind === "area") {
|
|
755
840
|
const x = 12 + row.depth * 18;
|
|
756
|
-
|
|
757
|
-
pctx.
|
|
841
|
+
const count = String((t.children || []).length);
|
|
842
|
+
pctx.font = ID_FONT;
|
|
843
|
+
const countWidth = pctx.measureText(count).width;
|
|
844
|
+
pctx.font = AREA_FONT;
|
|
845
|
+
const maxWidth = Math.max(24, X_COUNT - 10 - countWidth - x);
|
|
846
|
+
const label = clipText((collapsed.has(t.id) ? "+ " : "- ") + S(t.title), maxWidth, w => pctx.measureText(w).width);
|
|
847
|
+
pctx.fillStyle = C["--ink-2"];
|
|
848
|
+
pctx.textAlign = "left";
|
|
849
|
+
pctx.fillText(label, x, y);
|
|
850
|
+
pctx.font = ID_FONT;
|
|
758
851
|
pctx.fillStyle = C["--ink-3"];
|
|
759
|
-
pctx.
|
|
852
|
+
pctx.textAlign = "right";
|
|
853
|
+
pctx.fillText(count, X_COUNT, y);
|
|
854
|
+
pctx.textAlign = "left";
|
|
760
855
|
} else {
|
|
761
|
-
const
|
|
762
|
-
if (
|
|
856
|
+
const p = row.parentIndex;
|
|
857
|
+
if (p >= 0 && p !== i - 1) {
|
|
858
|
+
// Start below the parent label's baseline (the row edge) so no text is crossed.
|
|
859
|
+
const top = p * ROW_H - scrollTop + ROW_H / 2 + 12;
|
|
860
|
+
const xLine = 8 + row.depth * 6;
|
|
763
861
|
pctx.strokeStyle = alpha(C["--ink"], 0.35);
|
|
862
|
+
pctx.lineWidth = 1;
|
|
764
863
|
pctx.beginPath();
|
|
765
|
-
pctx.moveTo(
|
|
766
|
-
pctx.lineTo(
|
|
864
|
+
pctx.moveTo(xLine, top);
|
|
865
|
+
pctx.lineTo(xLine, y);
|
|
767
866
|
pctx.lineTo(xMark - 8, y);
|
|
768
867
|
pctx.stroke();
|
|
769
868
|
}
|
|
770
869
|
statusMark(pctx, t.status, N(t.liveCount) > 0, xMark, y);
|
|
870
|
+
pctx.font = ID_FONT;
|
|
771
871
|
pctx.fillStyle = C["--ink-2"];
|
|
772
872
|
pctx.fillText(S(t.id), xId, y);
|
|
873
|
+
pctx.font = TITLE_FONT;
|
|
773
874
|
pctx.fillStyle = C["--ink"];
|
|
774
|
-
pctx.font = sansFont;
|
|
775
875
|
pctx.fillText(S(t.title).slice(0, 96), xTitle, y);
|
|
776
|
-
pctx.font =
|
|
876
|
+
pctx.font = ID_FONT;
|
|
777
877
|
}
|
|
778
878
|
}
|
|
779
879
|
}
|
|
@@ -783,7 +883,7 @@ td.mono{font:400 12px/1.5 var(--mono); font-variant-numeric:tabular-nums}
|
|
|
783
883
|
if (staticDirty) drawPlate();
|
|
784
884
|
ctx.clearRect(0, 0, W, H);
|
|
785
885
|
ctx.drawImage(plate, 0, 0, W, H);
|
|
786
|
-
ctx.font =
|
|
886
|
+
ctx.font = TICK_FONT;
|
|
787
887
|
ctx.textBaseline = "middle";
|
|
788
888
|
ctx.textAlign = "left";
|
|
789
889
|
ctx.lineWidth = 1;
|
|
@@ -841,25 +941,23 @@ td.mono{font:400 12px/1.5 var(--mono); font-variant-numeric:tabular-nums}
|
|
|
841
941
|
const t = model.totals;
|
|
842
942
|
$("rAgents").textContent = String(N(t.activeAgents));
|
|
843
943
|
$("rAttempts").textContent = String(N(t.liveAttempts));
|
|
844
|
-
$("rQueue").
|
|
944
|
+
$("rQueue").replaceChildren(
|
|
945
|
+
node("span", "mono", N(t.queuedSubmissions)), node("span", "sc", " queued "),
|
|
946
|
+
node("span", "sep", " · "),
|
|
947
|
+
node("span", "mono", N(t.checkingSubmissions)), node("span", "sc", " checking "),
|
|
948
|
+
);
|
|
845
949
|
$("rAccepted").textContent = String(N(t.accepted));
|
|
846
950
|
$("rOpen").textContent = String(N(t.openTasks));
|
|
847
951
|
$("rEvents").textContent = String(eventTimes.length);
|
|
848
952
|
$("serverTime").textContent = clock(model.now);
|
|
849
953
|
$("seq").textContent = String(lastSeq);
|
|
850
954
|
const series = [0, 1, 2, 3, 4, 5].map(i => samples["s" + i] || []);
|
|
955
|
+
const names = ["Agents", "Attempts", "Queue", "Accepted", "Open", "Events"];
|
|
851
956
|
for (let i = 0; i < series.length; i += 1) {
|
|
852
|
-
const
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
const span = Math.max(1, max - min);
|
|
857
|
-
const points = a.map((v, k) => k + "," + (13 - Math.round((v - min) / span * 12))).join(" ");
|
|
858
|
-
$("sp" + ["Agents", "Attempts", "Queue", "Accepted", "Open", "Events"][i]).setAttribute("points", points);
|
|
859
|
-
const last = a[a.length - 1];
|
|
860
|
-
const y = 13 - Math.round((last - min) / span * 12);
|
|
861
|
-
$("lp" + ["Agents", "Attempts", "Queue", "Accepted", "Open", "Events"][i]).setAttribute("y1", String(y - 2));
|
|
862
|
-
$("lp" + ["Agents", "Attempts", "Queue", "Accepted", "Open", "Events"][i]).setAttribute("y2", String(y + 2));
|
|
957
|
+
const g = sparkGeometry(series[i]);
|
|
958
|
+
$("sp" + names[i]).setAttribute("points", g.points);
|
|
959
|
+
$("lp" + names[i]).setAttribute("y1", String(g.y1));
|
|
960
|
+
$("lp" + names[i]).setAttribute("y2", String(g.y2));
|
|
863
961
|
}
|
|
864
962
|
}
|
|
865
963
|
|
|
@@ -868,16 +966,15 @@ td.mono{font:400 12px/1.5 var(--mono); font-variant-numeric:tabular-nums}
|
|
|
868
966
|
dirtyQueue = false;
|
|
869
967
|
const list = $("qlist");
|
|
870
968
|
const holder = document.createDocumentFragment ? document.createDocumentFragment() : document.createElement("div");
|
|
871
|
-
const
|
|
872
|
-
const
|
|
873
|
-
$("qspacer").style.height =
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
for (let i = start; i < end; i += 1) {
|
|
969
|
+
const rowH = 20;
|
|
970
|
+
const { shown, extra, rows: rowTotal } = queueLayout(pendingSubs.length);
|
|
971
|
+
$("qspacer").style.height = rowTotal * rowH + "px";
|
|
972
|
+
if (rowTotal === 0) holder.appendChild(node("div", "qempty", "queue empty"));
|
|
973
|
+
for (let i = 0; i < shown; i += 1) {
|
|
877
974
|
const s = pendingSubs[i];
|
|
878
975
|
if (!s) continue;
|
|
879
976
|
const row = node("div", "qrow" + (s.status === "checking" ? " checking" : ""));
|
|
880
|
-
row.style.transform = "translateY(" + (i *
|
|
977
|
+
row.style.transform = "translateY(" + (i * rowH) + "px)";
|
|
881
978
|
row.appendChild(node("span", "", s.id));
|
|
882
979
|
row.appendChild(node("span", "task", S(s.task)));
|
|
883
980
|
row.appendChild(node("span", "who", shortId(s.agent, 6)));
|
|
@@ -886,6 +983,11 @@ td.mono{font:400 12px/1.5 var(--mono); font-variant-numeric:tabular-nums}
|
|
|
886
983
|
row.appendChild(node("span", "claim", s.status + " " + elapsed + "s"));
|
|
887
984
|
holder.appendChild(row);
|
|
888
985
|
}
|
|
986
|
+
if (extra > 0) {
|
|
987
|
+
const more = node("div", "qrow more", "+" + extra + " more");
|
|
988
|
+
more.style.transform = "translateY(" + (shown * rowH) + "px)";
|
|
989
|
+
holder.appendChild(more);
|
|
990
|
+
}
|
|
889
991
|
list.replaceChildren($("qspacer"), holder);
|
|
890
992
|
}
|
|
891
993
|
|
|
@@ -899,18 +1001,32 @@ td.mono{font:400 12px/1.5 var(--mono); font-variant-numeric:tabular-nums}
|
|
|
899
1001
|
function appendLog(newCount) {
|
|
900
1002
|
const list = $("logList");
|
|
901
1003
|
const holder = document.createDocumentFragment ? document.createDocumentFragment() : document.createElement("div");
|
|
902
|
-
|
|
1004
|
+
const freshEls = [];
|
|
1005
|
+
let taken = 0;
|
|
1006
|
+
// logLines is newest-first; walk it in that order so the batch lands newest-first too.
|
|
1007
|
+
for (let i = 0; i < newCount && i < logLines.length; i += 1) {
|
|
903
1008
|
const line = logLines[i];
|
|
904
|
-
if (line
|
|
1009
|
+
if (!line || !line.fresh) continue;
|
|
1010
|
+
// Only the newest line of a batch may start in accent; the rest are plain ink.
|
|
1011
|
+
const fresh = !reduce && taken === 0;
|
|
1012
|
+
const li = makeLogLine(line, fresh);
|
|
1013
|
+
holder.appendChild(li);
|
|
1014
|
+
if (fresh) freshEls.push(li);
|
|
1015
|
+
taken += 1;
|
|
1016
|
+
line.fresh = false;
|
|
905
1017
|
}
|
|
906
1018
|
if (holder.childNodes && holder.childNodes.length) {
|
|
907
1019
|
const oldFirst = list.firstChild;
|
|
908
1020
|
if (oldFirst) list.insertBefore(holder, oldFirst); else list.appendChild(holder);
|
|
1021
|
+
// Removing the class on a later frame lets the CSS transition run accent -> ink.
|
|
1022
|
+
if (freshEls.length) requestAnimationFrame(() => requestAnimationFrame(() => {
|
|
1023
|
+
for (const el of freshEls) el.className = "logline";
|
|
1024
|
+
}));
|
|
909
1025
|
}
|
|
910
1026
|
while (list.childNodes.length > 200) list.removeChild(list.lastChild);
|
|
911
1027
|
}
|
|
912
1028
|
function makeLogLine(line, fresh) {
|
|
913
|
-
const li = node("li", fresh ? "logline
|
|
1029
|
+
const li = node("li", fresh ? "logline fresh" : "logline");
|
|
914
1030
|
li.appendChild(node("time", "", clock(line.at)));
|
|
915
1031
|
li.appendChild(node("span", "who", line.actor === "server" ? "server" : "A·" + shortId(line.actor, 6)));
|
|
916
1032
|
li.appendChild(node("span", "verb", line.verb));
|
|
@@ -918,8 +1034,12 @@ td.mono{font:400 12px/1.5 var(--mono); font-variant-numeric:tabular-nums}
|
|
|
918
1034
|
return li;
|
|
919
1035
|
}
|
|
920
1036
|
|
|
921
|
-
function cell(row, value, cls) {
|
|
922
|
-
const
|
|
1037
|
+
function cell(row, value, cls, truncate) {
|
|
1038
|
+
const text = S(value);
|
|
1039
|
+
const over = !!truncate && text.length > 28;
|
|
1040
|
+
const klass = ((cls || "") + (over ? " trunc" : "")).trim() || null;
|
|
1041
|
+
const td = node("td", klass, over ? text.slice(0, 27) + "…" : text);
|
|
1042
|
+
if (over) td.setAttribute("title", text);
|
|
923
1043
|
row.appendChild(td);
|
|
924
1044
|
return td;
|
|
925
1045
|
}
|
|
@@ -931,11 +1051,11 @@ td.mono{font:400 12px/1.5 var(--mono); font-variant-numeric:tabular-nums}
|
|
|
931
1051
|
for (let i = 0; i < rowsL.length; i += 1) {
|
|
932
1052
|
const r = rowsL[i];
|
|
933
1053
|
const tr = node("tr");
|
|
934
|
-
cell(tr, i + 1, "num");
|
|
935
|
-
cell(tr, r.agent, "mono");
|
|
936
|
-
cell(tr, r.owner === undefined ? "" : r.owner);
|
|
937
|
-
cell(tr, r.model);
|
|
938
|
-
cell(tr, r.harness);
|
|
1054
|
+
cell(tr, i + 1, "num rank");
|
|
1055
|
+
cell(tr, r.agent, "mono", true);
|
|
1056
|
+
cell(tr, r.owner === undefined ? "" : r.owner, null, true);
|
|
1057
|
+
cell(tr, r.model, null, true);
|
|
1058
|
+
cell(tr, r.harness, null, true);
|
|
939
1059
|
cell(tr, r.points, "num");
|
|
940
1060
|
cell(tr, r.accepted, "num");
|
|
941
1061
|
cell(tr, r.submissions, "num");
|
|
@@ -946,16 +1066,18 @@ td.mono{font:400 12px/1.5 var(--mono); font-variant-numeric:tabular-nums}
|
|
|
946
1066
|
const models = document.createDocumentFragment ? document.createDocumentFragment() : document.createElement("div");
|
|
947
1067
|
for (const r of model.leaderboard.models) {
|
|
948
1068
|
const tr = node("tr");
|
|
949
|
-
cell(tr, r.model, "mono");
|
|
1069
|
+
cell(tr, r.model, "mono", true);
|
|
950
1070
|
cell(tr, r.agents, "num");
|
|
951
1071
|
cell(tr, r.points, "num");
|
|
952
1072
|
cell(tr, r.accepted, "num");
|
|
953
1073
|
cell(tr, r.submissions, "num");
|
|
954
|
-
cell(tr,
|
|
1074
|
+
cell(tr, Math.round(N(r.passRate) * 100) + "%", "num");
|
|
955
1075
|
const rate = node("td", "barcell");
|
|
1076
|
+
const track = node("i", "track");
|
|
956
1077
|
const bar = node("i", "bar");
|
|
957
|
-
bar.style.width = Math.round(clamp(N(r.passRate), 0, 1) *
|
|
958
|
-
|
|
1078
|
+
bar.style.width = Math.round(clamp(N(r.passRate), 0, 1) * 80) + "px";
|
|
1079
|
+
track.appendChild(bar);
|
|
1080
|
+
rate.appendChild(track);
|
|
959
1081
|
tr.appendChild(rate);
|
|
960
1082
|
models.appendChild(tr);
|
|
961
1083
|
}
|
|
@@ -971,8 +1093,8 @@ td.mono{font:400 12px/1.5 var(--mono); font-variant-numeric:tabular-nums}
|
|
|
971
1093
|
if (!model) return;
|
|
972
1094
|
dirtyNote = false;
|
|
973
1095
|
const holder = document.createDocumentFragment ? document.createDocumentFragment() : document.createElement("div");
|
|
974
|
-
const row = hover >= 0 ? rows[hover] : (focusRow >= 0 ? rows[focusRow] :
|
|
975
|
-
const t = row ? row.task :
|
|
1096
|
+
const row = hover >= 0 ? rows[hover] : (focusRow >= 0 ? rows[focusRow] : null);
|
|
1097
|
+
const t = row ? row.task : busiestOpenLeaf(model.tasks, liveByTask);
|
|
976
1098
|
selectedTask = t ? t.id : null;
|
|
977
1099
|
const box = $("marginNote");
|
|
978
1100
|
const title = $("noteTitle");
|
|
@@ -1129,7 +1251,6 @@ td.mono{font:400 12px/1.5 var(--mono); font-variant-numeric:tabular-nums}
|
|
|
1129
1251
|
const id = rows[i].task.id;
|
|
1130
1252
|
if (collapsed.has(id)) collapsed.delete(id); else collapsed.add(id);
|
|
1131
1253
|
buildRows();
|
|
1132
|
-
if ($("cspacer").style) $("cspacer").style.height = Math.max(0, rows.length * ROW_H - H) + "px";
|
|
1133
1254
|
} else return;
|
|
1134
1255
|
ev.preventDefault();
|
|
1135
1256
|
focusRow = clamp(i, 0, Math.max(0, rows.length - 1));
|
|
@@ -1153,6 +1274,19 @@ td.mono{font:400 12px/1.5 var(--mono); font-variant-numeric:tabular-nums}
|
|
|
1153
1274
|
$("copyJoin").addEventListener("click", () => {
|
|
1154
1275
|
try { navigator.clipboard.writeText(location.origin + "/join"); } catch (_) { /* clipboard may be blocked */ }
|
|
1155
1276
|
});
|
|
1277
|
+
function setAllAreas(collapse) {
|
|
1278
|
+
if (!model) return;
|
|
1279
|
+
if (collapse) for (const t of model.tasks) if ((t.children || []).length) collapsed.add(t.id);
|
|
1280
|
+
else collapsed.clear();
|
|
1281
|
+
focusRow = -1;
|
|
1282
|
+
hover = -1;
|
|
1283
|
+
buildRows();
|
|
1284
|
+
dirtyNote = true;
|
|
1285
|
+
renderNote();
|
|
1286
|
+
if (reduce) draw(0);
|
|
1287
|
+
}
|
|
1288
|
+
$("collapseAll").addEventListener("click", () => setAllAreas(true));
|
|
1289
|
+
$("expandAll").addEventListener("click", () => setAllAreas(false));
|
|
1156
1290
|
for (const [id, value] of [["themeLight", "light"], ["themeDark", "dark"], ["themeAuto", "auto"]]) {
|
|
1157
1291
|
$(id).addEventListener("click", () => { theme = value; applyTheme(true); });
|
|
1158
1292
|
}
|
|
@@ -1163,6 +1297,7 @@ td.mono{font:400 12px/1.5 var(--mono); font-variant-numeric:tabular-nums}
|
|
|
1163
1297
|
function boot() {
|
|
1164
1298
|
readColors();
|
|
1165
1299
|
applyTheme(false);
|
|
1300
|
+
watchFonts();
|
|
1166
1301
|
setConnection("connecting");
|
|
1167
1302
|
$("joinUrl").textContent = location.origin + "/join";
|
|
1168
1303
|
resize();
|
|
@@ -1172,6 +1307,7 @@ td.mono{font:400 12px/1.5 var(--mono); font-variant-numeric:tabular-nums}
|
|
|
1172
1307
|
function frame(now) {
|
|
1173
1308
|
requestAnimationFrame(frame);
|
|
1174
1309
|
if (!model) return;
|
|
1310
|
+
maybeSample(); // keep the 5 s cadence even when the event stream is quiet
|
|
1175
1311
|
if (reduce) { if (needDraw) { draw(0); needDraw = false; } return; }
|
|
1176
1312
|
if (needDraw || (now - lastFrame > 50 && (model.totals.liveAttempts > 0))) {
|
|
1177
1313
|
lastFrame = now;
|
|
@@ -1185,10 +1321,24 @@ td.mono{font:400 12px/1.5 var(--mono); font-variant-numeric:tabular-nums}
|
|
|
1185
1321
|
loadView().then(connectStream);
|
|
1186
1322
|
}
|
|
1187
1323
|
|
|
1324
|
+
// Small read-only debug surface for layout checks in headless environments.
|
|
1325
|
+
if (typeof window !== "undefined") {
|
|
1326
|
+
window.__minga = {
|
|
1327
|
+
get rowCount() { return rows.length; },
|
|
1328
|
+
get areaCount() { return rows.reduce((n, r) => n + (r.kind === "area" ? 1 : 0), 0); },
|
|
1329
|
+
get leafCount() { return rows.reduce((n, r) => n + (r.kind === "leaf" ? 1 : 0), 0); },
|
|
1330
|
+
get collapsedCount() { return collapsed.size; },
|
|
1331
|
+
get queueCount() { return pendingSubs.length; },
|
|
1332
|
+
get maxScrollRows() { return Math.ceil(H / ROW_H); },
|
|
1333
|
+
get sampleLengths() { return sampleLengths(); },
|
|
1334
|
+
};
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1188
1337
|
// Browser-free test hook: no effect during normal operation.
|
|
1189
1338
|
const hook = globalThis.__MINGA_UI_TEST__;
|
|
1190
1339
|
if (typeof hook === "function") hook({
|
|
1191
1340
|
applyView, queueEvent, flush, renderNow, reindex, buildRows, renderTables, renderQueue, renderNote, renderReadouts, ctx, plate,
|
|
1341
|
+
clipText, sparkGeometry, queueLayout, busiestOpenLeaf, logObject, pushSample, sampleLengths,
|
|
1192
1342
|
});
|
|
1193
1343
|
else boot();
|
|
1194
1344
|
})();
|