@babylonjs-toolkit/agent 1.1.55 → 1.1.56

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.
@@ -0,0 +1,1610 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <title>Feature Dashboard</title>
7
+ <!--
8
+ Feature Dashboard — the live, visual record of one feature's spec → plan → execute run, ending in its
9
+ After Action Report.
10
+
11
+ This page is a fixed template: copy it to .agents/specs/<slug>/dashboard.html, replace {{slug}} below with the
12
+ feature slug, and never hand-edit anything else. Everything shown comes from the data file
13
+ documents/<slug>_dashboard.js (schema: bt-execute/templates/dashboard/dashboard.template.js) and, while a run
14
+ is going, the live status in documents/<slug>_live.js (schema: live.template.js).
15
+ It opens straight from disk (file://) — no server, no build, no network.
16
+ -->
17
+ <style>
18
+ :root {
19
+ --bg: #0b0f14;
20
+ --bg-raised: #121821;
21
+ --bg-sunken: #080b0f;
22
+ --line: #1f2935;
23
+ --line-strong: #2c3a4a;
24
+ --text: #e6edf3;
25
+ --text-muted: #8b98a8;
26
+ --text-faint: #5d6b7c;
27
+ --accent: #5cc8ff;
28
+ --accent-soft: rgba(92, 200, 255, 0.12);
29
+ --done: #3fd18b;
30
+ --done-soft: rgba(63, 209, 139, 0.12);
31
+ --active: #ffb547;
32
+ --active-soft: rgba(255, 181, 71, 0.14);
33
+ --deferred: #c792ea;
34
+ --deferred-soft: rgba(199, 146, 234, 0.14);
35
+ --failed: #ff6b6b;
36
+ --failed-soft: rgba(255, 107, 107, 0.14);
37
+ --pending: #5d6b7c;
38
+ --pending-soft: rgba(93, 107, 124, 0.14);
39
+ --updated: #ffd23f;
40
+ --updated-soft: rgba(255, 210, 63, 0.14);
41
+ --radius: 14px;
42
+ --radius-small: 8px;
43
+ --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 12px 32px rgba(0, 0, 0, 0.35);
44
+ --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
45
+ --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
46
+ color-scheme: dark;
47
+ }
48
+ @media (prefers-color-scheme: light) {
49
+ :root {
50
+ --bg: #f5f7fa;
51
+ --bg-raised: #ffffff;
52
+ --bg-sunken: #eceff3;
53
+ --line: #dde3ea;
54
+ --line-strong: #c7d0da;
55
+ --text: #111821;
56
+ --text-muted: #556274;
57
+ --text-faint: #8593a3;
58
+ --accent: #0a7bbd;
59
+ --accent-soft: rgba(10, 123, 189, 0.10);
60
+ --done: #0f9d58;
61
+ --done-soft: rgba(15, 157, 88, 0.10);
62
+ --active: #c27400;
63
+ --active-soft: rgba(194, 116, 0, 0.12);
64
+ --deferred: #8a4fbf;
65
+ --deferred-soft: rgba(138, 79, 191, 0.10);
66
+ --failed: #d33b3b;
67
+ --failed-soft: rgba(211, 59, 59, 0.10);
68
+ --pending: #8593a3;
69
+ --pending-soft: rgba(133, 147, 163, 0.12);
70
+ --updated: #a07800;
71
+ --updated-soft: rgba(255, 196, 0, 0.16);
72
+ --shadow: 0 1px 2px rgba(17, 24, 33, 0.05), 0 8px 24px rgba(17, 24, 33, 0.06);
73
+ color-scheme: light;
74
+ }
75
+ }
76
+
77
+ * { box-sizing: border-box; }
78
+ html { scroll-behavior: smooth; scroll-padding-top: 72px; }
79
+ body {
80
+ margin: 0;
81
+ background: var(--bg);
82
+ color: var(--text);
83
+ font: 15px/1.6 var(--font-sans);
84
+ -webkit-font-smoothing: antialiased;
85
+ }
86
+ a { color: var(--accent); text-decoration: none; }
87
+ a:hover { text-decoration: underline; }
88
+ code {
89
+ font: 0.86em var(--font-mono);
90
+ background: var(--bg-sunken);
91
+ border: 1px solid var(--line);
92
+ border-radius: 5px;
93
+ padding: 0.05em 0.35em;
94
+ overflow-wrap: anywhere;
95
+ }
96
+ .page { max-width: 1180px; margin: 0 auto; padding: 0 16px 80px; }
97
+
98
+ /* ---------- Header ---------- */
99
+ .masthead {
100
+ position: relative;
101
+ overflow: hidden;
102
+ border-bottom: 1px solid var(--line);
103
+ background:
104
+ radial-gradient(900px 340px at 85% -10%, var(--accent-soft), transparent 70%),
105
+ linear-gradient(180deg, var(--bg-raised), var(--bg));
106
+ }
107
+ .masthead::after {
108
+ content: "";
109
+ position: absolute;
110
+ inset: 0;
111
+ background-image:
112
+ linear-gradient(var(--line) 1px, transparent 1px),
113
+ linear-gradient(90deg, var(--line) 1px, transparent 1px);
114
+ background-size: 44px 44px;
115
+ opacity: 0.35;
116
+ mask-image: linear-gradient(180deg, black, transparent 85%);
117
+ -webkit-mask-image: linear-gradient(180deg, black, transparent 85%);
118
+ pointer-events: none;
119
+ }
120
+ .masthead-inner {
121
+ position: relative;
122
+ z-index: 1;
123
+ max-width: 1180px;
124
+ margin: 0 auto;
125
+ padding: 44px 16px 36px;
126
+ display: grid;
127
+ grid-template-columns: minmax(0, 1fr) auto;
128
+ gap: 32px;
129
+ align-items: center;
130
+ }
131
+ .kicker {
132
+ font: 600 12px/1 var(--font-mono);
133
+ letter-spacing: 0.18em;
134
+ text-transform: uppercase;
135
+ color: var(--accent);
136
+ margin: 0 0 14px;
137
+ }
138
+ .kicker span { color: var(--text-faint); }
139
+ h1 {
140
+ margin: 0 0 12px;
141
+ font-size: clamp(28px, 4.4vw, 46px);
142
+ line-height: 1.08;
143
+ letter-spacing: -0.02em;
144
+ }
145
+ .lede { margin: 0 0 20px; max-width: 760px; color: var(--text-muted); font-size: 16.5px; }
146
+ .meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
147
+ .chip {
148
+ display: inline-flex;
149
+ align-items: center;
150
+ gap: 6px;
151
+ padding: 4px 10px;
152
+ border: 1px solid var(--line-strong);
153
+ border-radius: 999px;
154
+ background: var(--bg-raised);
155
+ font: 500 12.5px/1.4 var(--font-mono);
156
+ color: var(--text-muted);
157
+ max-width: 100%;
158
+ overflow-wrap: anywhere;
159
+ }
160
+ .chip strong { color: var(--text); font-weight: 600; }
161
+ .chip-warning { border-color: var(--failed); color: var(--failed); background: var(--failed-soft); }
162
+ .chip-warning strong { color: var(--failed); }
163
+ .doc-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
164
+ .doc-links a {
165
+ display: inline-flex;
166
+ gap: 6px;
167
+ align-items: center;
168
+ padding: 5px 12px;
169
+ border-radius: var(--radius-small);
170
+ background: var(--accent-soft);
171
+ font: 500 13px/1.4 var(--font-sans);
172
+ }
173
+
174
+ /* ---------- Status pills ---------- */
175
+ .status {
176
+ display: inline-flex;
177
+ align-items: center;
178
+ gap: 7px;
179
+ padding: 4px 11px;
180
+ border-radius: 999px;
181
+ font: 700 11.5px/1.4 var(--font-mono);
182
+ letter-spacing: 0.08em;
183
+ text-transform: uppercase;
184
+ white-space: nowrap;
185
+ }
186
+ .status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
187
+ .status-done, .status-complete { color: var(--done); background: var(--done-soft); }
188
+ .status-in-progress { color: var(--active); background: var(--active-soft); }
189
+ .status-in-progress::before { animation: pulse 1.6s ease-in-out infinite; }
190
+ .status-pending, .status-planned, .status-paused { color: var(--pending); background: var(--pending-soft); }
191
+ .status-deferred, .status-partial, .status-incomplete { color: var(--deferred); background: var(--deferred-soft); }
192
+ .status-failed { color: var(--failed); background: var(--failed-soft); }
193
+ .status-built, .status-verifying { color: var(--accent); background: var(--accent-soft); }
194
+ .status-verifying::before { animation: pulse 1.6s ease-in-out infinite; }
195
+ @keyframes pulse { 50% { opacity: 0.25; transform: scale(0.7); } }
196
+
197
+ /* ---------- Progress ring ---------- */
198
+ .ring { position: relative; width: 168px; height: 168px; }
199
+ .ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
200
+ .ring circle { fill: none; stroke-width: 10; }
201
+ .ring .track { stroke: var(--line); }
202
+ .ring .value { stroke: var(--done); stroke-linecap: round; transition: stroke-dashoffset 900ms cubic-bezier(.2, .8, .2, 1); }
203
+ .ring .label {
204
+ position: absolute;
205
+ inset: 0;
206
+ display: grid;
207
+ place-content: center;
208
+ text-align: center;
209
+ }
210
+ .ring .percent { font: 700 36px/1 var(--font-sans); letter-spacing: -0.03em; }
211
+ .ring .fraction { margin-top: 6px; font: 500 12px/1 var(--font-mono); color: var(--text-muted); }
212
+
213
+ /* ---------- Sticky nav ---------- */
214
+ .nav {
215
+ position: sticky;
216
+ top: 0;
217
+ z-index: 20;
218
+ background: color-mix(in srgb, var(--bg) 86%, transparent);
219
+ backdrop-filter: blur(10px);
220
+ -webkit-backdrop-filter: blur(10px);
221
+ border-bottom: 1px solid var(--line);
222
+ }
223
+ .nav-inner {
224
+ max-width: 1180px;
225
+ margin: 0 auto;
226
+ padding: 10px 16px;
227
+ display: flex;
228
+ gap: 6px;
229
+ align-items: center;
230
+ overflow-x: auto;
231
+ scrollbar-width: none;
232
+ }
233
+ .nav-inner::-webkit-scrollbar { display: none; }
234
+ .nav a {
235
+ padding: 6px 11px;
236
+ border-radius: var(--radius-small);
237
+ color: var(--text-muted);
238
+ font: 500 13.5px/1 var(--font-sans);
239
+ white-space: nowrap;
240
+ }
241
+ .nav a:hover { background: var(--bg-raised); color: var(--text); text-decoration: none; }
242
+ .nav .spacer { flex: 1; }
243
+ .nav .count {
244
+ margin-left: 5px;
245
+ padding: 1px 6px;
246
+ border-radius: 999px;
247
+ background: var(--updated-soft);
248
+ color: var(--updated);
249
+ font: 700 11px/1.4 var(--font-mono);
250
+ }
251
+ .live-toggle {
252
+ display: inline-flex;
253
+ gap: 8px;
254
+ align-items: center;
255
+ padding: 6px 12px;
256
+ border: 1px solid var(--line-strong);
257
+ border-radius: 999px;
258
+ background: var(--bg-raised);
259
+ color: var(--text-muted);
260
+ font: 600 12px/1 var(--font-mono);
261
+ cursor: pointer;
262
+ white-space: nowrap;
263
+ }
264
+ .live-toggle[aria-pressed="true"] { color: var(--active); border-color: var(--active); }
265
+ .live-toggle[aria-pressed="true"]::before {
266
+ content: "";
267
+ width: 7px;
268
+ height: 7px;
269
+ border-radius: 50%;
270
+ background: var(--active);
271
+ animation: pulse 1.6s ease-in-out infinite;
272
+ }
273
+
274
+ /* ---------- Sections ---------- */
275
+ section { margin-top: 48px; }
276
+ .section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
277
+ h2 { margin: 0; font-size: 22px; letter-spacing: -0.01em; }
278
+ .section-note { color: var(--text-faint); font-size: 13.5px; }
279
+ .card {
280
+ background: var(--bg-raised);
281
+ border: 1px solid var(--line);
282
+ border-radius: var(--radius);
283
+ box-shadow: var(--shadow);
284
+ }
285
+ .empty {
286
+ padding: 28px;
287
+ text-align: center;
288
+ color: var(--text-muted);
289
+ border: 1px dashed var(--line-strong);
290
+ border-radius: var(--radius);
291
+ }
292
+
293
+ /* ---------- Stat tiles ---------- */
294
+ .stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-top: 28px; }
295
+ .stat { padding: 16px 18px; }
296
+ .stat-label { font: 600 11px/1 var(--font-mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-faint); }
297
+ .stat-value { margin-top: 10px; font: 700 26px/1.1 var(--font-sans); letter-spacing: -0.02em; }
298
+ .stat-value small { font-size: 14px; color: var(--text-muted); font-weight: 500; letter-spacing: 0; }
299
+ .stat-sub { margin-top: 4px; font-size: 12.5px; color: var(--text-muted); }
300
+
301
+ /* ---------- Phase route ---------- */
302
+ .route { display: flex; gap: 6px; margin-top: 16px; }
303
+ .route a {
304
+ flex: 1;
305
+ min-width: 0;
306
+ text-decoration: none;
307
+ color: inherit;
308
+ }
309
+ .route-bar { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; }
310
+ .route-fill { height: 100%; border-radius: 999px; background: var(--done); }
311
+ .route a.is-in-progress .route-fill { background: var(--active); }
312
+ .route a.is-deferred .route-fill, .route a.is-partial .route-fill { background: var(--deferred); }
313
+ .route-label {
314
+ margin-top: 7px;
315
+ font: 500 11.5px/1.3 var(--font-mono);
316
+ color: var(--text-muted);
317
+ white-space: nowrap;
318
+ overflow: hidden;
319
+ text-overflow: ellipsis;
320
+ }
321
+
322
+ /* ---------- Summary ---------- */
323
+ .headline { margin: 0 0 12px; font-size: 21px; line-height: 1.35; letter-spacing: -0.01em; }
324
+ .highlights { list-style: none; margin: 18px 0 0; padding: 0; display: grid; gap: 10px; }
325
+ .highlights li { display: grid; grid-template-columns: 22px 1fr; gap: 8px; }
326
+ .highlights li::before { content: "✦"; color: var(--accent); }
327
+
328
+ /* ---------- After Action Report ---------- */
329
+ .after-action { padding: 24px 28px 26px; border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
330
+ .after-action-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
331
+ .after-action-head .kicker { margin: 0; }
332
+ .after-action .headline { margin: 14px 0 18px; font-size: 24px; }
333
+ .plan-compare .shot { box-shadow: none; }
334
+ .plan-compare .shot-frame { aspect-ratio: auto !important; height: min(64vh, 54vw); }
335
+ .after-action-columns { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 28px; margin-top: 22px; }
336
+ .after-action-columns p { margin: 0 0 12px; color: var(--text-muted); }
337
+ .figures { margin: 0; padding: 14px 18px; border-radius: var(--radius-small); background: var(--bg-sunken); border: 1px solid var(--line); display: grid; gap: 2px; align-self: start; }
338
+ .figures div { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-top: 1px solid var(--line); }
339
+ .figures div:first-child { border-top: 0; }
340
+ .figures dt { color: var(--text-muted); font-size: 13px; }
341
+ .figures dd { margin: 0; font: 700 13.5px/1.5 var(--font-mono); text-align: right; }
342
+
343
+ /* ---------- Snapshots ---------- */
344
+ .gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); gap: 16px; margin-top: 18px; }
345
+ .shot { margin: 0; overflow: hidden; }
346
+ .shot-frame {
347
+ position: relative;
348
+ aspect-ratio: 16 / 9;
349
+ background: var(--bg-sunken);
350
+ border-bottom: 1px solid var(--line);
351
+ overflow: hidden;
352
+ }
353
+ .shot-frame img {
354
+ position: absolute;
355
+ inset: 0;
356
+ width: 100%;
357
+ height: 100%;
358
+ object-fit: contain;
359
+ display: block;
360
+ }
361
+ .shot-frame .before-layer { clip-path: inset(0 calc(100% - var(--split, 50%)) 0 0); }
362
+ .shot-frame .divider {
363
+ position: absolute;
364
+ top: 0;
365
+ bottom: 0;
366
+ left: var(--split, 50%);
367
+ width: 2px;
368
+ margin-left: -1px;
369
+ background: #fff;
370
+ box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
371
+ pointer-events: none;
372
+ }
373
+ .shot-frame .divider::after {
374
+ content: "⟷";
375
+ position: absolute;
376
+ top: 50%;
377
+ left: 50%;
378
+ width: 34px;
379
+ height: 34px;
380
+ margin: -17px 0 0 -17px;
381
+ display: grid;
382
+ place-content: center;
383
+ border-radius: 50%;
384
+ background: #fff;
385
+ color: #111;
386
+ font-size: 15px;
387
+ box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
388
+ }
389
+ .shot-frame input[type="range"] {
390
+ position: absolute;
391
+ inset: 0;
392
+ width: 100%;
393
+ height: 100%;
394
+ margin: 0;
395
+ opacity: 0;
396
+ cursor: ew-resize;
397
+ }
398
+ .shot-tag {
399
+ position: absolute;
400
+ top: 10px;
401
+ padding: 3px 8px;
402
+ border-radius: 6px;
403
+ background: rgba(0, 0, 0, 0.62);
404
+ color: #fff;
405
+ font: 700 10.5px/1.4 var(--font-mono);
406
+ letter-spacing: 0.1em;
407
+ text-transform: uppercase;
408
+ pointer-events: none;
409
+ }
410
+ .shot-tag.left { left: 10px; }
411
+ .shot-tag.right { right: 10px; }
412
+ .shot-expand {
413
+ position: absolute;
414
+ right: 10px;
415
+ bottom: 10px;
416
+ z-index: 2;
417
+ padding: 5px 9px;
418
+ border: 0;
419
+ border-radius: 6px;
420
+ background: rgba(0, 0, 0, 0.62);
421
+ color: #fff;
422
+ font: 600 11px/1 var(--font-mono);
423
+ cursor: zoom-in;
424
+ }
425
+ .shot-frame.single { cursor: zoom-in; }
426
+ .shot-missing {
427
+ position: absolute;
428
+ inset: 0;
429
+ display: grid;
430
+ place-content: center;
431
+ padding: 16px;
432
+ text-align: center;
433
+ color: var(--text-faint);
434
+ font: 500 12.5px/1.5 var(--font-mono);
435
+ }
436
+ .shot-missing[hidden] { display: none; }
437
+ .shot figcaption { padding: 12px 16px 14px; }
438
+ .shot-title { font-weight: 600; }
439
+ .shot-caption { color: var(--text-muted); font-size: 13.5px; }
440
+ .shot-source { font: 500 11px/1 var(--font-mono); color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.1em; margin-top: 8px; }
441
+
442
+ /* ---------- Progressions (storyboard of a build, stage by stage) ---------- */
443
+ .gallery .progression { grid-column: 1 / -1; }
444
+ .progression .shot-frame { aspect-ratio: auto !important; height: min(62vh, 52vw); }
445
+ .progression .shot-frame img { transition: opacity 260ms ease; }
446
+ .stage-counter {
447
+ position: absolute;
448
+ left: 10px;
449
+ top: 10px;
450
+ padding: 3px 8px;
451
+ border-radius: 6px;
452
+ background: rgba(0, 0, 0, 0.62);
453
+ color: #fff;
454
+ font: 700 10.5px/1.4 var(--font-mono);
455
+ letter-spacing: 0.1em;
456
+ text-transform: uppercase;
457
+ }
458
+ .stage-controls { display: flex; gap: 8px; align-items: center; padding: 12px 16px 0; }
459
+ .stage-button {
460
+ padding: 6px 12px;
461
+ border: 1px solid var(--line-strong);
462
+ border-radius: var(--radius-small);
463
+ background: var(--bg);
464
+ color: var(--text);
465
+ font: 600 12px/1 var(--font-mono);
466
+ cursor: pointer;
467
+ }
468
+ .stage-button:hover { border-color: var(--accent); color: var(--accent); }
469
+ .stage-progress { flex: 1; height: 4px; border-radius: 999px; background: var(--line); overflow: hidden; }
470
+ .stage-progress div { height: 100%; background: var(--accent); transition: width 260ms ease; }
471
+ .filmstrip {
472
+ display: grid;
473
+ grid-auto-flow: column;
474
+ grid-auto-columns: minmax(132px, 1fr);
475
+ gap: 10px;
476
+ padding: 12px 16px 4px;
477
+ overflow-x: auto;
478
+ scroll-snap-type: x mandatory;
479
+ }
480
+ .film-frame {
481
+ position: relative;
482
+ padding: 0;
483
+ border: 2px solid transparent;
484
+ border-radius: var(--radius-small);
485
+ background: var(--bg-sunken);
486
+ color: inherit;
487
+ text-align: left;
488
+ cursor: pointer;
489
+ overflow: hidden;
490
+ scroll-snap-align: start;
491
+ }
492
+ .film-frame img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
493
+ .film-frame .film-label {
494
+ display: block;
495
+ padding: 6px 8px 7px;
496
+ font: 600 11.5px/1.3 var(--font-sans);
497
+ color: var(--text-muted);
498
+ white-space: nowrap;
499
+ overflow: hidden;
500
+ text-overflow: ellipsis;
501
+ }
502
+ .film-frame .film-step {
503
+ position: absolute;
504
+ top: 6px;
505
+ left: 6px;
506
+ min-width: 20px;
507
+ padding: 1px 6px;
508
+ border-radius: 5px;
509
+ background: rgba(0, 0, 0, 0.66);
510
+ color: #fff;
511
+ font: 700 10.5px/1.5 var(--font-mono);
512
+ text-align: center;
513
+ }
514
+ .film-frame[aria-current="true"] { border-color: var(--accent); }
515
+ .film-frame[aria-current="true"] .film-label { color: var(--text); }
516
+ .stage-caption { padding: 10px 16px 0; }
517
+ .stage-caption .stage-name { font-weight: 700; }
518
+ .stage-caption .stage-note { color: var(--text-muted); font-size: 13.5px; }
519
+
520
+ /* ---------- Phases ---------- */
521
+ .phase { margin-top: 20px; overflow: hidden; }
522
+ .phase-head {
523
+ display: grid;
524
+ grid-template-columns: auto minmax(0, 1fr) auto;
525
+ gap: 16px;
526
+ align-items: center;
527
+ padding: 20px 24px;
528
+ border-bottom: 1px solid var(--line);
529
+ }
530
+ .phase-number {
531
+ width: 44px;
532
+ height: 44px;
533
+ display: grid;
534
+ place-content: center;
535
+ border-radius: 12px;
536
+ background: var(--bg-sunken);
537
+ border: 1px solid var(--line-strong);
538
+ font: 700 16px/1 var(--font-mono);
539
+ }
540
+ .phase.is-done .phase-number { background: var(--done-soft); border-color: transparent; color: var(--done); }
541
+ .phase.is-in-progress .phase-number { background: var(--active-soft); border-color: transparent; color: var(--active); }
542
+ .phase h3 { margin: 0; font-size: 18px; }
543
+ .phase-meta { margin-top: 4px; font: 500 12.5px/1.4 var(--font-mono); color: var(--text-muted); }
544
+ .phase-body { padding: 20px 24px 24px; }
545
+ .phase-summary { margin: 0; color: var(--text-muted); }
546
+ .verifier {
547
+ margin-top: 14px;
548
+ padding: 10px 14px;
549
+ border-left: 3px solid var(--done);
550
+ border-radius: 0 var(--radius-small) var(--radius-small) 0;
551
+ background: var(--done-soft);
552
+ font-size: 13.5px;
553
+ }
554
+ .verifier.is-fail { border-color: var(--failed); background: var(--failed-soft); }
555
+ .verifier strong { font-family: var(--font-mono); }
556
+
557
+ /* ---------- Tasks ---------- */
558
+ .tasks { margin-top: 20px; display: grid; gap: 8px; }
559
+ .task { border: 1px solid var(--line); border-radius: var(--radius-small); background: var(--bg); }
560
+ .task > summary {
561
+ list-style: none;
562
+ display: grid;
563
+ grid-template-columns: 22px auto minmax(0, 1fr) auto;
564
+ gap: 12px;
565
+ align-items: center;
566
+ padding: 12px 14px;
567
+ cursor: pointer;
568
+ }
569
+ .task > summary::-webkit-details-marker { display: none; }
570
+ .task-icon { width: 22px; height: 22px; display: grid; place-content: center; border-radius: 50%; font: 700 12px/1 var(--font-sans); }
571
+ .task.is-done .task-icon { background: var(--done-soft); color: var(--done); }
572
+ .task.is-in-progress .task-icon { background: var(--active-soft); color: var(--active); }
573
+ .task.is-pending .task-icon { background: var(--pending-soft); color: var(--pending); }
574
+ .task.is-deferred .task-icon { background: var(--deferred-soft); color: var(--deferred); }
575
+ .task.is-failed .task-icon { background: var(--failed-soft); color: var(--failed); }
576
+ .task.is-built .task-icon, .task.is-verifying .task-icon { background: var(--accent-soft); color: var(--accent); }
577
+ .task.is-live { border-color: var(--active); box-shadow: 0 0 0 3px var(--active-soft); }
578
+ .task.is-live .task-icon { animation: pulse 1.6s ease-in-out infinite; }
579
+
580
+ /* ---------- Now: what is being worked on this minute ---------- */
581
+ .now {
582
+ padding: 18px 22px;
583
+ border-color: color-mix(in srgb, var(--active) 45%, var(--line));
584
+ background: linear-gradient(90deg, var(--active-soft), transparent 65%), var(--bg-raised);
585
+ }
586
+ .now-head {
587
+ display: flex;
588
+ flex-wrap: wrap;
589
+ gap: 8px 12px;
590
+ align-items: center;
591
+ font: 700 11.5px/1.4 var(--font-mono);
592
+ letter-spacing: 0.12em;
593
+ text-transform: uppercase;
594
+ color: var(--active);
595
+ }
596
+ .now-head .live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--active); animation: pulse 1.6s ease-in-out infinite; }
597
+ .now-age { color: var(--text-muted); font-weight: 500; letter-spacing: 0; text-transform: none; }
598
+ .now.is-stale .now-age { color: var(--failed); font-weight: 700; }
599
+ .now-task { display: block; margin-top: 8px; color: var(--text); font-size: 19px; font-weight: 700; line-height: 1.35; }
600
+ .now-task:hover { text-decoration: none; color: var(--accent); }
601
+ .now-activity { margin: 4px 0 0; font-size: 15.5px; }
602
+ .live-steps { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 4px; font-size: 13.5px; color: var(--text-muted); }
603
+ .live-steps li { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 10px; }
604
+ .live-steps time { font: 600 12px/1.6 var(--font-mono); color: var(--text-faint); }
605
+ .live-steps li:last-child { color: var(--text); font-weight: 600; }
606
+ .task-live { padding: 12px 14px; border-radius: var(--radius-small); background: var(--active-soft); }
607
+ .task-live .now-head { font-size: 10.5px; }
608
+ .task-id { font: 700 13px/1 var(--font-mono); color: var(--text-muted); }
609
+ .task-title { font-weight: 600; min-width: 0; }
610
+ .task-tags { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
611
+ .tag {
612
+ padding: 2px 7px;
613
+ border-radius: 5px;
614
+ background: var(--bg-sunken);
615
+ border: 1px solid var(--line);
616
+ font: 600 10.5px/1.4 var(--font-mono);
617
+ color: var(--text-muted);
618
+ letter-spacing: 0.06em;
619
+ text-transform: uppercase;
620
+ }
621
+ .task-body { padding: 0 14px 16px 48px; display: grid; gap: 12px; }
622
+ .task-body p { margin: 0; color: var(--text-muted); }
623
+ .facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; font-size: 13.5px; margin: 0; }
624
+ .facts dt { font: 600 11px/1.9 var(--font-mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-faint); }
625
+ .facts dd { margin: 0; overflow-wrap: anywhere; }
626
+ .file-list { margin: 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 6px; }
627
+ .deferred-note {
628
+ padding: 10px 14px;
629
+ border-radius: var(--radius-small);
630
+ background: var(--deferred-soft);
631
+ color: var(--text);
632
+ font-size: 13.5px;
633
+ }
634
+
635
+ /* ---------- Updated notifications ---------- */
636
+ .updated-badge {
637
+ display: inline-flex;
638
+ align-items: center;
639
+ gap: 6px;
640
+ padding: 3px 9px;
641
+ border: 1px solid color-mix(in srgb, var(--updated) 45%, transparent);
642
+ border-radius: 999px;
643
+ background: var(--updated-soft);
644
+ color: var(--updated);
645
+ font: 700 10.5px/1.4 var(--font-mono);
646
+ letter-spacing: 0.08em;
647
+ text-transform: uppercase;
648
+ white-space: nowrap;
649
+ }
650
+ .updated-badge::before { content: "↻"; font-size: 12px; letter-spacing: 0; }
651
+ .updated-badge.is-new { box-shadow: 0 0 0 3px var(--updated-soft); }
652
+ .update-notes {
653
+ margin: 12px 0 0;
654
+ padding: 10px 14px;
655
+ list-style: none;
656
+ border-left: 3px solid var(--updated);
657
+ border-radius: 0 var(--radius-small) var(--radius-small) 0;
658
+ background: var(--updated-soft);
659
+ font-size: 13.5px;
660
+ display: grid;
661
+ gap: 6px;
662
+ }
663
+ .update-notes .when { font: 600 11.5px/1.4 var(--font-mono); color: var(--updated); margin-right: 6px; }
664
+
665
+ /* ---------- Lists: decisions, follow-ups, updates, activity ---------- */
666
+ .list-card { padding: 6px 0; }
667
+ .row { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 16px; padding: 12px 22px; border-top: 1px solid var(--line); }
668
+ .row:first-child { border-top: 0; }
669
+ .row-key { font: 600 12.5px/1.6 var(--font-mono); color: var(--accent); overflow-wrap: anywhere; }
670
+ .row-source { margin-top: 4px; color: var(--text-faint); font-size: 12.5px; }
671
+ .timeline { position: relative; margin: 0; padding: 4px 0 4px 26px; list-style: none; }
672
+ .timeline::before { content: ""; position: absolute; left: 7px; top: 8px; bottom: 8px; width: 2px; background: var(--line); }
673
+ .timeline li { position: relative; padding: 8px 0; }
674
+ .timeline li::before {
675
+ content: "";
676
+ position: absolute;
677
+ left: -24px;
678
+ top: 15px;
679
+ width: 10px;
680
+ height: 10px;
681
+ border-radius: 50%;
682
+ background: var(--bg);
683
+ border: 2px solid var(--line-strong);
684
+ }
685
+ .timeline li.is-new::before { border-color: var(--updated); background: var(--updated); }
686
+ .timeline time { display: block; font: 600 12px/1.4 var(--font-mono); color: var(--text-faint); }
687
+
688
+ .recent-activity { margin-top: 14px; padding: 14px 22px 8px; }
689
+ .recent-activity .timeline { max-height: 340px; overflow-y: auto; }
690
+ .recent-title, .activity-log > summary { font: 700 11px/1.4 var(--font-mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-faint); }
691
+ .activity-log { padding: 14px 22px; }
692
+ .activity-log > summary { cursor: pointer; }
693
+ .activity-log[open] > summary { margin-bottom: 8px; }
694
+
695
+ /* ---------- Lightbox ---------- */
696
+ .lightbox {
697
+ position: fixed;
698
+ inset: 0;
699
+ z-index: 50;
700
+ display: none;
701
+ place-items: center;
702
+ padding: 24px;
703
+ background: rgba(4, 6, 9, 0.9);
704
+ cursor: zoom-out;
705
+ }
706
+ .lightbox.is-open { display: grid; }
707
+ .lightbox figure { margin: 0; max-width: min(1600px, 100%); }
708
+ .lightbox img { display: block; max-width: 100%; max-height: calc(100vh - 110px); margin: 0 auto; border-radius: var(--radius-small); }
709
+ .lightbox figcaption { margin-top: 12px; color: #c9d4df; text-align: center; font-size: 14px; }
710
+
711
+ .error-panel { margin-top: 48px; padding: 28px; border-color: var(--failed); }
712
+ .error-panel h2 { color: var(--failed); margin-bottom: 8px; }
713
+ footer { margin-top: 64px; padding-top: 20px; border-top: 1px solid var(--line); color: var(--text-faint); font-size: 12.5px; }
714
+
715
+ @media (max-width: 760px) {
716
+ .masthead-inner { grid-template-columns: 1fr; padding-top: 32px; }
717
+ .ring { width: 128px; height: 128px; }
718
+ .ring .percent { font-size: 28px; }
719
+ .phase-head { grid-template-columns: auto minmax(0, 1fr); padding: 16px; }
720
+ .phase-head .phase-status { grid-column: 1 / -1; }
721
+ .phase-body { padding: 16px; }
722
+ .task > summary { grid-template-columns: 22px auto minmax(0, 1fr); }
723
+ .task-tags { grid-column: 2 / -1; justify-content: flex-start; }
724
+ .task-body { padding: 0 14px 16px; }
725
+ .row { grid-template-columns: 1fr; gap: 4px; padding: 12px 16px; }
726
+ .after-action { padding: 18px; }
727
+ .after-action-columns { grid-template-columns: 1fr; }
728
+ .route-label { display: none; }
729
+ }
730
+ @media (prefers-reduced-motion: reduce) {
731
+ *, *::before { animation: none !important; transition: none !important; }
732
+ html { scroll-behavior: auto; }
733
+ }
734
+ </style>
735
+ </head>
736
+ <body>
737
+ <div id="app"></div>
738
+ <div class="lightbox" id="lightbox" role="dialog" aria-modal="true" aria-label="Snapshot">
739
+ <figure><img id="lightbox-image" alt=""><figcaption id="lightbox-caption"></figcaption></figure>
740
+ </div>
741
+
742
+ <script src="documents/{{slug}}_dashboard.js"></script>
743
+ <script src="documents/{{slug}}_live.js"></script>
744
+ <script>
745
+ (() => {
746
+ 'use strict';
747
+
748
+ /** Seconds between checks of the data files for changes while a run is executing, and otherwise. */
749
+ const RUNNING_CHECK_SECONDS = 10;
750
+ const IDLE_CHECK_SECONDS = 30;
751
+ /** Seconds between refreshes of the "updated N min ago" labels. */
752
+ const AGE_REFRESH_SECONDS = 30;
753
+ const STATUS_ICONS = { done: '✓', 'in-progress': '◐', built: '◆', verifying: '⟳', pending: '○', deferred: '⏭', failed: '✕' };
754
+ /** Where the Babylon Toolkit Desktop Agent, whose skills generate this dashboard, is published. */
755
+ const SKILLS_DOWNLOAD_URL = 'https://www.npmjs.com/package/@babylonjs-toolkit/agent';
756
+ /** Minutes without a live update before the Now banner warns that the run has gone quiet. */
757
+ const STALE_AFTER_MINUTES = 20;
758
+ /** How many of the current task's latest steps the Now banner lists. */
759
+ const NOW_STEP_COUNT = 6;
760
+ const STATUS_LABELS = {
761
+ planned: 'Planned',
762
+ 'in-progress': 'In progress',
763
+ complete: 'Complete',
764
+ incomplete: 'Complete with deferrals',
765
+ done: 'Done',
766
+ pending: 'Pending',
767
+ deferred: 'Deferred',
768
+ failed: 'Failed',
769
+ partial: 'Partial',
770
+ built: 'Built — awaiting verifier',
771
+ paused: 'Paused — plan not finished',
772
+ verifying: 'Verifying',
773
+ };
774
+
775
+ const appRoot = document.getElementById('app');
776
+ const report = window.FEATURE_DASHBOARD;
777
+ /** Live status of the step being worked on now; written far more often than the report itself. */
778
+ const live = window.FEATURE_LIVE || null;
779
+ /** Progression snapshots in render order; the storyboard controls look their frames up here. */
780
+ const progressions = [];
781
+
782
+ if (!report) {
783
+ renderMissingData();
784
+ return;
785
+ }
786
+
787
+ const storageKey = `dashboard:${report.feature && report.feature.slug ? report.feature.slug : location.pathname}`;
788
+ const lastVisit = readStorage(localStorage, `${storageKey}:lastSeen`) || '';
789
+
790
+ render();
791
+ wireLightbox();
792
+ wireAutoUpdate();
793
+ restoreScroll();
794
+ writeStorage(localStorage, `${storageKey}:lastSeen`, report.updatedAt || '');
795
+
796
+ /* ===================== Rendering ===================== */
797
+
798
+ /** Builds the whole page from the report data. */
799
+ function render() {
800
+ const feature = report.feature || {};
801
+ const allTasks = collectTasks();
802
+ const doneCount = allTasks.filter((task) => task.status === 'done').length;
803
+ const allUpdates = collectUpdates();
804
+ document.title = `${feature.title || 'Feature'} — Dashboard`;
805
+
806
+ const view = pageView();
807
+ // Stat tiles and phase bars first; then one slot that follows the run: Current run activity while it runs,
808
+ // the plan summary (After Action Report) once it is over.
809
+ appRoot.innerHTML = [
810
+ renderMasthead(feature, allTasks.length, doneCount),
811
+ renderNav(allUpdates.length, view),
812
+ '<main class="page">',
813
+ renderStats(allTasks, doneCount),
814
+ view === 'running' ? renderCurrentActivity(allTasks) : '',
815
+ view === 'finished' ? renderAfterAction(allTasks, doneCount) : '',
816
+ renderPhases(),
817
+ renderDecisions(),
818
+ renderFollowUps(allTasks),
819
+ renderUpdateLog(allUpdates),
820
+ view === 'running' ? '' : renderActivityLog(),
821
+ renderFooter(),
822
+ '</main>',
823
+ ].join('');
824
+
825
+ wireCompareSliders();
826
+ animateRing(allTasks.length ? doneCount / allTasks.length : 0);
827
+ }
828
+
829
+ function renderMasthead(feature, totalTasks, doneCount) {
830
+ const percent = totalTasks ? Math.round((doneCount / totalTasks) * 100) : 0;
831
+ const activeCount = collectTasks().filter((task) => ['in-progress', 'built', 'verifying'].includes(task.status)).length;
832
+ const status = effectiveStatus();
833
+ const chips = [
834
+ `<span class="status status-${escapeAttribute(status)}">${escapeHtml(STATUS_LABELS[status] || status)}</span>`,
835
+ feature.branch ? `<span class="chip">⎇ <strong>${escapeHtml(feature.branch)}</strong></span>` : '',
836
+ feature.origin ? `<span class="chip">from <strong>${escapeHtml(feature.origin === 'quick-plan' ? 'Quick Plan' : 'Spec')}</strong></span>` : '',
837
+ feature.size ? `<span class="chip">size <strong>${escapeHtml(feature.size)}</strong></span>` : '',
838
+ feature.proof ? `<span class="chip">proof <strong>${escapeHtml(feature.proof)}</strong></span>` : '',
839
+ report.updatedAt ? `<span class="chip">updated <strong>${escapeHtml(report.updatedAt)}</strong></span>` : '',
840
+ report.status !== status ? `<span class="chip chip-warning"><span>status says <strong>${escapeHtml(report.status)}</strong>, but ${escapeHtml(unfinishedTasks().map((task) => task.id).join(', '))} ${unfinishedTasks().length === 1 ? 'is' : 'are'} not done</span></span>` : '',
841
+ ].join('');
842
+ const documentLinks = (report.documents || [])
843
+ .map((documentLink) => `<a href="${safeUrl(documentLink.path)}">📄 ${escapeHtml(documentLink.label)}</a>`)
844
+ .join('');
845
+
846
+ return `
847
+ <header class="masthead">
848
+ <div class="masthead-inner">
849
+ <div>
850
+ <p class="kicker">Feature Dashboard <span>· Technical Specification</span></p>
851
+ <h1>${escapeHtml(feature.title || 'Untitled feature')}</h1>
852
+ ${feature.summary ? `<p class="lede">${formatInline(feature.summary)}</p>` : ''}
853
+ <div class="meta">${chips}</div>
854
+ ${documentLinks ? `<div class="doc-links">${documentLinks}</div>` : ''}
855
+ </div>
856
+ <div class="ring" role="img" aria-label="${percent}% of tasks complete">
857
+ <svg viewBox="0 0 120 120"><circle class="track" cx="60" cy="60" r="52"/><circle class="value" id="ring-value" cx="60" cy="60" r="52"/></svg>
858
+ <div class="label"><div class="percent">${percent}%</div><div class="fraction">${doneCount} / ${totalTasks} tasks</div>${activeCount ? `<div class="fraction">${activeCount} active</div>` : ''}</div>
859
+ </div>
860
+ </div>
861
+ </header>`;
862
+ }
863
+
864
+ function renderNav(updateCount, view) {
865
+ const links = [
866
+ view === 'running' ? ['current-activity', 'Current run'] : null,
867
+ view === 'finished' ? ['after-action', 'Plan summary'] : null,
868
+ ['phases', 'Phases'],
869
+ ['decisions', 'Decisions'],
870
+ ['follow-ups', 'Follow ups'],
871
+ ['updates', `Updates${updateCount ? `<span class="count">${updateCount}</span>` : ''}`],
872
+ view === 'running' ? null : ['activity', 'Milestones'],
873
+ ].filter(Boolean).map(([target, label]) => `<a href="#${target}">${label}</a>`).join('');
874
+ const liveButton = `<button class="live-toggle" id="live-toggle" type="button" aria-pressed="${isLiveEnabled()}" title="Re-read the data files every ${view === 'running' ? RUNNING_CHECK_SECONDS : IDLE_CHECK_SECONDS} s and refresh when they change">${autoUpdateLabel()}</button>`;
875
+ return `<nav class="nav" aria-label="Report sections"><div class="nav-inner">${links}<span class="spacer"></span>${liveButton}</div></nav>`;
876
+ }
877
+
878
+ function renderStats(allTasks, doneCount) {
879
+ const phases = report.phases || [];
880
+ const donePhases = phases.filter((phase) => phase.status === 'done').length;
881
+ const deferredCount = allTasks.filter((task) => task.status === 'deferred' || task.status === 'failed').length;
882
+ const testTotals = allTasks.reduce((totals, task) => {
883
+ if (task.tests) {
884
+ totals.passed += Number(task.tests.passed) || 0;
885
+ totals.failed += Number(task.tests.failed) || 0;
886
+ }
887
+ return totals;
888
+ }, { passed: 0, failed: 0 });
889
+
890
+ const tiles = [
891
+ statTile('Tasks', `${doneCount}<small> / ${allTasks.length}</small>`, 'verified and ticked'),
892
+ statTile('Phases', `${donePhases}<small> / ${phases.length}</small>`, 'independently verified'),
893
+ statTile('Tests', `${testTotals.passed}<small> passed</small>`, testTotals.failed ? `${testTotals.failed} failing` : 'no failures recorded'),
894
+ statTile('Active time', escapeHtml(report.activeTime || '—'), report.estimate ? `estimate ${escapeHtml(report.estimate)}` : 'no estimate'),
895
+ statTile('Deferred', String(deferredCount), deferredCount ? 'see Follow ups' : 'nothing deferred'),
896
+ statTile('Runs', String(report.runs || 0), 'bt-execute runs so far'),
897
+ ].join('');
898
+
899
+ const route = phases.map((phase) => {
900
+ const tasks = phase.tasks || [];
901
+ const finished = tasks.filter((task) => task.status === 'done').length;
902
+ const awaitingVerifier = tasks.filter((task) => task.status === 'built' || task.status === 'verifying').length;
903
+ const fill = tasks.length ? Math.round(((finished + awaitingVerifier / 2) / tasks.length) * 100) : 0;
904
+ return `<a href="#phase-${escapeAttribute(phase.number)}" class="is-${escapeAttribute(phase.status || 'pending')}" title="Phase ${escapeAttribute(phase.number)} — ${escapeAttribute(phase.name || '')}">
905
+ <div class="route-bar"><div class="route-fill" style="width:${fill}%"></div></div>
906
+ <div class="route-label">P${escapeHtml(phase.number)} · ${escapeHtml(phase.name || '')}</div>
907
+ </a>`;
908
+ }).join('');
909
+
910
+ return `<div class="stats">${tiles}</div>${route ? `<nav class="route" aria-label="Phase progress">${route}</nav>` : ''}`;
911
+ }
912
+
913
+ function statTile(label, valueHtml, subText) {
914
+ return `<div class="card stat"><div class="stat-label">${label}</div><div class="stat-value">${valueHtml}</div><div class="stat-sub">${subText}</div></div>`;
915
+ }
916
+
917
+ /**
918
+ * The final section: the whole plan's execution in one place — the plan-wide before/after, what was built,
919
+ * how it was proven, the figures, and the snapshots that best show it. Written when a run ends.
920
+ */
921
+ function renderAfterAction(allTasks, doneCount) {
922
+ const afterAction = report.afterAction;
923
+ const hasContent = afterAction && (afterAction.headline || (afterAction.body || []).length || afterAction.comparison);
924
+ const isFinal = ['complete', 'incomplete'].includes(effectiveStatus());
925
+ let body;
926
+ if (!hasContent) {
927
+ body = `<div class="empty">${report.status === 'planned'
928
+ ? 'Execution has not started. The After Action Report is written when the plan has run.'
929
+ : 'Written when the run ends — the phases above are current.'}</div>`;
930
+ } else {
931
+ const comparison = afterAction.comparison;
932
+ body = `
933
+ <article class="card after-action">
934
+ <div class="after-action-head">
935
+ <span class="kicker">After Action Report${afterAction.writtenAt ? ` <span>· ${escapeHtml(afterAction.writtenAt)}</span>` : ''}</span>
936
+ <span class="meta">${isFinal ? '' : '<span class="status status-in-progress">Interim — plan not finished</span>'}${updatedBadge(afterAction.updates)}</span>
937
+ </div>
938
+ ${afterAction.headline ? `<h3 class="headline">${formatInline(afterAction.headline)}</h3>` : ''}
939
+ ${comparison && comparison.before && comparison.after ? `<div class="plan-compare">${renderSnapshot(comparison)}</div>` : ''}
940
+ <div class="after-action-columns">
941
+ <div>
942
+ ${(afterAction.body || []).map((paragraph) => `<p>${formatInline(paragraph)}</p>`).join('')}
943
+ ${(afterAction.highlights || []).length ? `<ul class="highlights">${afterAction.highlights.map((item) => `<li><span>${formatInline(item)}</span></li>`).join('')}</ul>` : ''}
944
+ </div>
945
+ ${renderFigures(allTasks, doneCount)}
946
+ </div>
947
+ ${updateNotes(afterAction.updates)}
948
+ </article>
949
+ ${(afterAction.snapshots || []).length ? `<div class="gallery">${afterAction.snapshots.map(renderSnapshot).join('')}</div>` : ''}`;
950
+ }
951
+ return `
952
+ <section id="after-action">
953
+ <div class="section-head"><h2>The plan summary</h2><span class="section-note">The whole plan's execution, start to finish</span></div>
954
+ ${body}
955
+ </section>`;
956
+ }
957
+
958
+ /** The run's figures, computed from the data so they can never disagree with the phases above. */
959
+ function renderFigures(allTasks, doneCount) {
960
+ const phases = report.phases || [];
961
+ const retried = allTasks.filter((task) => Number(task.attempts) > 1).length;
962
+ const deferred = allTasks.filter((task) => task.status === 'deferred' || task.status === 'failed').length;
963
+ const testsPassed = allTasks.reduce((total, task) => total + (task.tests ? Number(task.tests.passed) || 0 : 0), 0);
964
+ const rows = [
965
+ ['Tasks verified', `${doneCount} / ${allTasks.length}`],
966
+ ['Phases', `${phases.filter((phase) => phase.status === 'done').length} / ${phases.length}`],
967
+ ['Tests passing', String(testsPassed)],
968
+ ['Needed a second attempt', String(retried)],
969
+ ['Deferred', String(deferred)],
970
+ ['Active time', report.activeTime || '—'],
971
+ ['Estimate', report.estimate || '—'],
972
+ ['Runs', String(report.runs || 0)],
973
+ ];
974
+ return `<dl class="figures">${rows.map(([label, value]) => `<div><dt>${label}</dt><dd>${escapeHtml(value)}</dd></div>`).join('')}</dl>`;
975
+ }
976
+
977
+ function renderPhases() {
978
+ const phases = report.phases || [];
979
+ const content = phases.length
980
+ ? phases.map(renderPhase).join('')
981
+ : '<div class="empty">No phases recorded yet.</div>';
982
+ return `
983
+ <section id="phases">
984
+ <div class="section-head"><h2>Execution phases</h2><span class="section-note">Each phase is checked by an independent verifier</span></div>
985
+ ${content}
986
+ </section>`;
987
+ }
988
+
989
+ function renderPhase(phase) {
990
+ const status = phase.status || 'pending';
991
+ const timing = [
992
+ phase.started && phase.finished ? `${phase.started} → ${phase.finished}` : phase.started ? `started ${phase.started}` : '',
993
+ phase.minutes ? `${phase.minutes} min` : '',
994
+ `${(phase.tasks || []).length} tasks`,
995
+ ].filter(Boolean).map(escapeHtml).join(' · ');
996
+ const verifier = phase.verifier
997
+ ? `<div class="verifier ${/fail/i.test(phase.verifier.result || '') ? 'is-fail' : ''}"><strong>Verifier: ${escapeHtml(phase.verifier.result || '')}</strong>${phase.verifier.note ? ` — ${formatInline(phase.verifier.note)}` : ''}</div>`
998
+ : '';
999
+ const snapshots = (phase.snapshots || []).length
1000
+ ? `<div class="gallery">${phase.snapshots.map(renderSnapshot).join('')}</div>`
1001
+ : '';
1002
+
1003
+ return `
1004
+ <article class="card phase is-${escapeAttribute(status)}" id="phase-${escapeAttribute(phase.number)}">
1005
+ <div class="phase-head">
1006
+ <div class="phase-number">P${escapeHtml(phase.number)}</div>
1007
+ <div><h3>${escapeHtml(phase.name || '')}</h3><div class="phase-meta">${timing}</div></div>
1008
+ <div class="phase-status meta">${updatedBadge(phase.updates)}<span class="status status-${escapeAttribute(status)}">${escapeHtml(STATUS_LABELS[status] || status)}</span></div>
1009
+ </div>
1010
+ <div class="phase-body">
1011
+ ${phase.summary ? `<p class="phase-summary">${formatInline(phase.summary)}</p>` : ''}
1012
+ ${updateNotes(phase.updates)}
1013
+ ${verifier}
1014
+ ${snapshots}
1015
+ <div class="tasks">${(phase.tasks || []).map(renderTask).join('')}</div>
1016
+ </div>
1017
+ </article>`;
1018
+ }
1019
+
1020
+ function renderTask(task) {
1021
+ const status = task.status || 'pending';
1022
+ const tags = [
1023
+ task.kind ? `<span class="tag">${escapeHtml(task.kind)}</span>` : '',
1024
+ task.verifyLevel === 'live' ? '<span class="tag">live check</span>' : '',
1025
+ task.attempts > 1 ? `<span class="tag">${escapeHtml(task.attempts)} attempts</span>` : '',
1026
+ status === 'built' || status === 'verifying' ? `<span class="status status-${status}">${STATUS_LABELS[status]}</span>` : '',
1027
+ updatedBadge(task.updates),
1028
+ ].join('');
1029
+ const facts = [
1030
+ factRow('Files', (task.files || []).length ? `<ul class="file-list">${task.files.map((file) => `<li><code>${escapeHtml(file)}</code></li>`).join('')}</ul>` : ''),
1031
+ factRow('Tests', task.tests ? describeTests(task.tests) : ''),
1032
+ factRow('Verifier', task.verifier ? formatInline(task.verifier) : ''),
1033
+ factRow('Commit', task.commit ? `<code>${escapeHtml(task.commit)}</code>` : ''),
1034
+ factRow('Done', task.doneAt ? escapeHtml(task.doneAt) : ''),
1035
+ factRow('Decisions', (task.decisions || []).length ? task.decisions.map(formatInline).join('<br>') : ''),
1036
+ ].join('');
1037
+ const isCurrent = isRunActive() && live && live.task === task.id;
1038
+ const hasBody = isCurrent || task.summary || facts || task.deferredReason || (task.snapshots || []).length || (task.updates || []).length;
1039
+
1040
+ return `
1041
+ <details class="task is-${escapeAttribute(status)}${isCurrent ? ' is-live' : ''}" id="task-${escapeAttribute(task.id || '')}" ${isCurrent || status === 'in-progress' || isNew(task.updates) ? 'open' : ''}>
1042
+ <summary>
1043
+ <span class="task-icon" title="${escapeAttribute(STATUS_LABELS[status] || status)}">${STATUS_ICONS[status] || '○'}</span>
1044
+ <span class="task-id">${escapeHtml(task.id || '')}</span>
1045
+ <span class="task-title">${escapeHtml(task.title || '')}</span>
1046
+ <span class="task-tags">${tags}</span>
1047
+ </summary>
1048
+ ${hasBody ? `<div class="task-body">
1049
+ ${isCurrent ? renderTaskLive() : ''}
1050
+ ${task.summary ? `<p>${formatInline(task.summary)}</p>` : ''}
1051
+ ${task.deferredReason ? `<div class="deferred-note"><strong>Deferred:</strong> ${formatInline(task.deferredReason)}</div>` : ''}
1052
+ ${updateNotes(task.updates)}
1053
+ ${facts ? `<dl class="facts">${facts}</dl>` : ''}
1054
+ ${(task.snapshots || []).length ? `<div class="gallery">${task.snapshots.map(renderSnapshot).join('')}</div>` : ''}
1055
+ </div>` : ''}
1056
+ </details>`;
1057
+ }
1058
+
1059
+ /** The Now banner: the task being worked on this minute, what is happening, and how fresh that is. */
1060
+ function renderNow(allTasks) {
1061
+ if (!isRunActive() || !live) return '';
1062
+ const task = allTasks.find((candidate) => candidate.id === live.task);
1063
+ const heading = [
1064
+ live.phase != null ? `Phase ${escapeHtml(live.phase)}` : '',
1065
+ live.task ? escapeHtml(live.task) : '',
1066
+ live.role ? escapeHtml(live.role) : '',
1067
+ ].filter(Boolean).join(' · ');
1068
+ const title = task ? `${escapeHtml(task.id)} — ${escapeHtml(task.title || '')}` : escapeHtml(live.title || live.task || 'Between tasks');
1069
+ const age = describeAge(live.updatedAt);
1070
+ return `
1071
+ <div class="card now ${age.isStale ? 'is-stale' : ''}" aria-live="polite">
1072
+ <div class="now-head"><span class="live-dot"></span>Now${heading ? ` · ${heading}` : ''}<span class="now-age" data-age="${escapeAttribute(live.updatedAt || '')}">${escapeHtml(age.text)}</span></div>
1073
+ <a class="now-task" href="#task-${escapeAttribute(live.task || '')}">${title}</a>
1074
+ ${live.activity ? `<p class="now-activity">${formatInline(live.activity)}</p>` : ''}
1075
+ ${renderLiveSteps(NOW_STEP_COUNT)}
1076
+ </div>`;
1077
+ }
1078
+
1079
+ /** The live step log, shown inside the task that is being worked on. */
1080
+ function renderTaskLive() {
1081
+ const age = describeAge(live.updatedAt);
1082
+ return `<div class="task-live"><div class="now-head"><span class="live-dot"></span>Working now${live.role ? ` · ${escapeHtml(live.role)}` : ''}<span class="now-age" data-age="${escapeAttribute(live.updatedAt || '')}">${escapeHtml(age.text)}</span></div>
1083
+ ${live.activity ? `<p class="now-activity">${formatInline(live.activity)}</p>` : ''}${renderLiveSteps(Infinity)}</div>`;
1084
+ }
1085
+
1086
+ function renderLiveSteps(limit) {
1087
+ const steps = (live.steps || []).slice(-limit);
1088
+ if (!steps.length) return '';
1089
+ return `<ol class="live-steps">${steps.map((step) => `<li><time>${escapeHtml(step.at || '')}</time><span>${formatInline(step.text || '')}</span></li>`).join('')}</ol>`;
1090
+ }
1091
+
1092
+ function isRunActive() {
1093
+ return report.status === 'in-progress';
1094
+ }
1095
+
1096
+ /** "updated 3 min ago", or a warning once nothing has been written for STALE_AFTER_MINUTES. */
1097
+ function describeAge(timestamp) {
1098
+ const updated = parseTimestamp(timestamp);
1099
+ if (!updated) return { text: timestamp ? `updated ${timestamp}` : '', isStale: false };
1100
+ const minutes = Math.max(0, Math.round((Date.now() - updated.getTime()) / 60000));
1101
+ const duration = minutes < 60 ? `${minutes} min` : `${Math.floor(minutes / 60)} h ${minutes % 60} min`;
1102
+ if (minutes >= STALE_AFTER_MINUTES) return { text: `no update for ${duration}`, isStale: true };
1103
+ return { text: minutes < 1 ? 'updated just now' : `updated ${duration} ago`, isStale: false };
1104
+ }
1105
+
1106
+ /** Reads the report's "YYYY-MM-DD HH:MM" local timestamps. */
1107
+ function parseTimestamp(timestamp) {
1108
+ const match = /^(\d{4})-(\d{2})-(\d{2})[ T](\d{2}):(\d{2})/.exec(String(timestamp || ''));
1109
+ if (!match) return null;
1110
+ const [, year, month, day, hour, minute] = match.map(Number);
1111
+ return new Date(year, month - 1, day, hour, minute);
1112
+ }
1113
+
1114
+ function factRow(label, valueHtml) {
1115
+ return valueHtml ? `<dt>${label}</dt><dd>${valueHtml}</dd>` : '';
1116
+ }
1117
+
1118
+ function describeTests(tests) {
1119
+ const counts = [
1120
+ tests.passed != null ? `${escapeHtml(tests.passed)} passed` : '',
1121
+ tests.failed ? `${escapeHtml(tests.failed)} failed` : '',
1122
+ ].filter(Boolean).join(' · ');
1123
+ const files = (tests.files || []).map((file) => `<code>${escapeHtml(file)}</code>`).join(' ');
1124
+ const note = tests.note ? formatInline(tests.note) : '';
1125
+ return [counts, files, note].filter(Boolean).join('<br>');
1126
+ }
1127
+
1128
+ /**
1129
+ * Three snapshot shapes: a progression (`frames`) renders as a storyboard of the build stage by stage;
1130
+ * a before/after pair renders as a drag-to-compare slider; a single image renders as a zoomable still.
1131
+ */
1132
+ function renderSnapshot(snapshot) {
1133
+ const source = snapshot.source ? `<div class="shot-source">${escapeHtml(snapshot.source)}</div>` : '';
1134
+ const header = `${snapshot.title ? `<div class="shot-title">${formatInline(snapshot.title)} ${updatedBadge(snapshot.updates)}</div>` : ''}`;
1135
+ if ((snapshot.frames || []).length) {
1136
+ return renderProgression(snapshot, header, source);
1137
+ }
1138
+ if (snapshot.before && snapshot.after) {
1139
+ const caption = [snapshot.caption, snapshot.before.caption && `Before: ${snapshot.before.caption}`, snapshot.after.caption && `After: ${snapshot.after.caption}`]
1140
+ .filter(Boolean).map((line) => `<div class="shot-caption">${formatInline(line)}</div>`).join('');
1141
+ return `
1142
+ <figure class="card shot">
1143
+ <div class="shot-frame compare" style="--split:50%">
1144
+ ${imageTag(snapshot.after.src, 'After', '')}
1145
+ ${imageTag(snapshot.before.src, 'Before', 'before-layer')}
1146
+ <div class="divider"></div>
1147
+ <span class="shot-tag left">Before</span><span class="shot-tag right">After</span>
1148
+ <input type="range" min="0" max="100" value="50" aria-label="Drag to compare before and after">
1149
+ <button class="shot-expand" type="button" data-zoom="${safeUrl(snapshot.after.src)}" data-caption="${escapeAttribute(snapshot.title || 'After')}">After ⤢</button>
1150
+ </div>
1151
+ <figcaption>${header}${caption}${source}${updateNotes(snapshot.updates)}</figcaption>
1152
+ </figure>`;
1153
+ }
1154
+ return `
1155
+ <figure class="card shot">
1156
+ <div class="shot-frame single" data-zoom="${safeUrl(snapshot.src)}" data-caption="${escapeAttribute(snapshot.caption || snapshot.title || '')}">
1157
+ ${imageTag(snapshot.src, snapshot.title || 'Snapshot', '')}
1158
+ </div>
1159
+ <figcaption>${header}${snapshot.caption ? `<div class="shot-caption">${formatInline(snapshot.caption)}</div>` : ''}${source}${updateNotes(snapshot.updates)}</figcaption>
1160
+ </figure>`;
1161
+ }
1162
+
1163
+ /** A storyboard: the large stage view, prev / play / next, and a filmstrip of every stage in build order. */
1164
+ function renderProgression(snapshot, header, source) {
1165
+ const progressionIndex = progressions.push(snapshot) - 1;
1166
+ const firstFrame = snapshot.frames[0];
1167
+ const filmstrip = snapshot.frames.map((frame, frameIndex) => `
1168
+ <button class="film-frame" type="button" data-stage="${frameIndex}" aria-current="${frameIndex === 0}" title="${escapeAttribute(frame.stage || '')}">
1169
+ <span class="film-step">${frameIndex + 1}</span>
1170
+ <img src="${safeUrl(frame.src)}" alt="" loading="lazy">
1171
+ <span class="film-label">${escapeHtml(frame.stage || `Stage ${frameIndex + 1}`)}</span>
1172
+ </button>`).join('');
1173
+ return `
1174
+ <figure class="card shot progression" data-progression="${progressionIndex}">
1175
+ <div class="shot-frame single" data-zoom="${safeUrl(firstFrame.src)}" data-caption="${escapeAttribute(firstFrame.stage || '')}">
1176
+ <img class="stage-image" src="${safeUrl(firstFrame.src)}" alt="${escapeAttribute(firstFrame.stage || 'Stage 1')}">
1177
+ <div class="shot-missing" hidden>Snapshot not found</div>
1178
+ <span class="stage-counter">Stage 1 / ${snapshot.frames.length}</span>
1179
+ </div>
1180
+ <div class="stage-controls">
1181
+ <button class="stage-button" type="button" data-step="-1" aria-label="Previous stage">◀</button>
1182
+ <button class="stage-button" type="button" data-play>▶ Play</button>
1183
+ <div class="stage-progress"><div style="width:${100 / snapshot.frames.length}%"></div></div>
1184
+ <button class="stage-button" type="button" data-step="1" aria-label="Next stage">▶</button>
1185
+ </div>
1186
+ <div class="stage-caption" aria-live="polite"></div>
1187
+ <div class="filmstrip">${filmstrip}</div>
1188
+ <figcaption>${header}${snapshot.caption ? `<div class="shot-caption">${formatInline(snapshot.caption)}</div>` : ''}${source}${updateNotes(snapshot.updates)}</figcaption>
1189
+ </figure>`;
1190
+ }
1191
+
1192
+ function imageTag(src, alt, className) {
1193
+ if (!src) return '<div class="shot-missing">No snapshot</div>';
1194
+ return `<img class="${className}" src="${safeUrl(src)}" alt="${escapeAttribute(alt)}" loading="lazy" onerror="this.outerHTML='<div class=&quot;shot-missing&quot;>Snapshot not found:<br>${escapeAttribute(escapeAttribute(src))}</div>'">`;
1195
+ }
1196
+
1197
+ function renderDecisions() {
1198
+ const decisions = report.decisions || [];
1199
+ const rows = decisions.map((decision) => `
1200
+ <div class="row">
1201
+ <div class="row-key">${escapeHtml(decision.id || '')}</div>
1202
+ <div>${formatInline(decision.text || '')} ${updatedBadge(decision.updates)}${decision.source ? `<div class="row-source">${formatInline(decision.source)}</div>` : ''}${updateNotes(decision.updates)}</div>
1203
+ </div>`).join('');
1204
+ return `
1205
+ <section id="decisions">
1206
+ <div class="section-head"><h2>Decisions made</h2><span class="section-note">The calls that shaped the build, and why</span></div>
1207
+ ${rows ? `<div class="card list-card">${rows}</div>` : '<div class="empty">No decisions recorded yet.</div>'}
1208
+ </section>`;
1209
+ }
1210
+
1211
+ function renderFollowUps(allTasks) {
1212
+ const deferredRows = allTasks
1213
+ .filter((task) => task.status === 'deferred' || task.status === 'failed')
1214
+ .map((task) => `<div class="row"><div class="row-key">${escapeHtml(task.id || '')}</div><div><strong>${escapeHtml(task.title || '')}</strong>${task.deferredReason ? `<div class="row-source">${formatInline(task.deferredReason)}</div>` : ''}</div></div>`);
1215
+ const followUpRows = (report.followUps || [])
1216
+ .map((item, index) => `<div class="row"><div class="row-key">#${index + 1}</div><div>${formatInline(item)}</div></div>`);
1217
+ const rows = deferredRows.concat(followUpRows).join('');
1218
+ return `
1219
+ <section id="follow-ups">
1220
+ <div class="section-head"><h2>Deferred follow ups</h2><span class="section-note">What a human should look at next</span></div>
1221
+ ${rows ? `<div class="card list-card">${rows}</div>` : '<div class="empty">Nothing deferred, nothing outstanding.</div>'}
1222
+ </section>`;
1223
+ }
1224
+
1225
+ function renderUpdateLog(allUpdates) {
1226
+ const rows = allUpdates
1227
+ .slice()
1228
+ .sort((first, second) => String(second.at || '').localeCompare(String(first.at || '')))
1229
+ .map((update) => `
1230
+ <div class="row">
1231
+ <div class="row-key">${escapeHtml(update.at || '')}${isNewTimestamp(update.at) ? ' <span class="updated-badge is-new">new</span>' : ''}</div>
1232
+ <div><a href="#${escapeAttribute(update.anchor)}">${escapeHtml(update.where)}</a>${update.by ? ` — by <strong>${escapeHtml(update.by)}</strong>` : ''}<div class="row-source">${formatInline(update.note || '')}</div></div>
1233
+ </div>`).join('');
1234
+ return `
1235
+ <section id="updates">
1236
+ <div class="section-head"><h2>Updates and revisions</h2><span class="section-note">Earlier results revised by later work — nothing is rewritten silently</span></div>
1237
+ ${rows ? `<div class="card list-card">${rows}</div>` : '<div class="empty">No earlier section has been revised.</div>'}
1238
+ </section>`;
1239
+ }
1240
+
1241
+ /** While a run is going: what is being worked on this minute, and the milestones so far. */
1242
+ function renderCurrentActivity(allTasks) {
1243
+ const timeline = renderTimeline();
1244
+ return `
1245
+ <section id="current-activity">
1246
+ <div class="section-head"><h2>Current run activity</h2><span class="section-note">Live — this page refreshes itself whenever the run writes an update</span></div>
1247
+ ${renderNow(allTasks) || '<div class="empty">Run in progress — waiting for the first live update.</div>'}
1248
+ ${timeline ? `<div class="card recent-activity"><div class="recent-title">Milestones · newest first</div>${timeline}</div>` : ''}
1249
+ </section>`;
1250
+ }
1251
+
1252
+ /** Once the run is over (or before it starts): the full milestone history, folded away. */
1253
+ function renderActivityLog() {
1254
+ const timeline = renderTimeline();
1255
+ const count = (report.activity || []).length;
1256
+ return `
1257
+ <section id="activity">
1258
+ <div class="section-head"><h2>Milestone activity logs</h2><span class="section-note">Every milestone of every run</span></div>
1259
+ ${timeline ? `<details class="card activity-log"><summary>Show all ${count} ${count === 1 ? 'entry' : 'entries'}, newest first</summary>${timeline}</details>` : '<div class="empty">No activity yet.</div>'}
1260
+ </section>`;
1261
+ }
1262
+
1263
+ function renderTimeline() {
1264
+ const entries = (report.activity || []).slice().reverse();
1265
+ if (!entries.length) return '';
1266
+ return `<ol class="timeline">${entries.map((entry) => `
1267
+ <li class="${isNewTimestamp(entry.at) ? 'is-new' : ''}"><time>${escapeHtml(entry.at || '')}</time>${formatInline(entry.text || '')}</li>`).join('')}</ol>`;
1268
+ }
1269
+
1270
+ /** "running" while a run is executing, "finished" once a run has ended (plan done or paused), else "planned". */
1271
+ function pageView() {
1272
+ const status = effectiveStatus();
1273
+ if (status === 'in-progress') return 'running';
1274
+ if (['paused', 'complete', 'incomplete'].includes(status)) return 'finished';
1275
+ return 'planned';
1276
+ }
1277
+
1278
+
1279
+ function renderFooter() {
1280
+ return `<footer>Generated by the <a href="${SKILLS_DOWNLOAD_URL}" target="_blank" rel="noopener noreferrer">Babylon Toolkit Desktop Agent</a></footer>`;
1281
+ }
1282
+
1283
+ function renderMissingData() {
1284
+ appRoot.innerHTML = `
1285
+ <main class="page">
1286
+ <div class="card error-panel">
1287
+ <h2>No dashboard data found</h2>
1288
+ <p>This page reads <code>documents/&lt;slug&gt;_dashboard.js</code> next to it. The file is missing, misnamed, or has a syntax error
1289
+ (open the browser console for details). bt-plan writes it when the plan is created, and bt-execute updates it after every phase.</p>
1290
+ </div>
1291
+ </main>`;
1292
+ }
1293
+
1294
+ /* ===================== Updated notifications ===================== */
1295
+
1296
+ function updatedBadge(updates) {
1297
+ if (!updates || !updates.length) return '';
1298
+ const latest = updates[updates.length - 1];
1299
+ const label = `Updated${latest.at ? ` ${latest.at}` : ''}${latest.by ? ` · ${latest.by}` : ''}`;
1300
+ return `<span class="updated-badge ${isNew(updates) ? 'is-new' : ''}" title="${escapeAttribute(latest.note || '')}">${escapeHtml(label)}</span>`;
1301
+ }
1302
+
1303
+ function updateNotes(updates) {
1304
+ if (!updates || !updates.length) return '';
1305
+ const items = updates.map((update) => `<li><span class="when">${escapeHtml(update.at || '')}${update.by ? ` · ${escapeHtml(update.by)}` : ''}</span>${formatInline(update.note || '')}</li>`).join('');
1306
+ return `<ul class="update-notes" aria-label="Updates">${items}</ul>`;
1307
+ }
1308
+
1309
+ function isNew(updates) {
1310
+ return Boolean(updates && updates.some((update) => isNewTimestamp(update.at)));
1311
+ }
1312
+
1313
+ /** Timestamps use "YYYY-MM-DD HH:MM", so plain string comparison orders them. */
1314
+ function isNewTimestamp(timestamp) {
1315
+ return Boolean(lastVisit && timestamp && String(timestamp) > lastVisit);
1316
+ }
1317
+
1318
+ /* ===================== Data helpers ===================== */
1319
+
1320
+ function collectTasks() {
1321
+ return (report.phases || []).flatMap((phase) => phase.tasks || []);
1322
+ }
1323
+
1324
+ /** Every update anywhere in the report, with where it lives, for the Updates section. */
1325
+ function collectUpdates() {
1326
+ const collected = [];
1327
+ const add = (updates, where, anchor) => (updates || []).forEach((update) => collected.push({ ...update, where, anchor }));
1328
+ if (report.afterAction) {
1329
+ add(report.afterAction.updates, 'After Action Report', 'after-action');
1330
+ (report.afterAction.snapshots || []).forEach((snapshot) => add(snapshot.updates, `After Action Report — ${snapshot.title || 'snapshot'}`, 'after-action'));
1331
+ }
1332
+ (report.phases || []).forEach((phase) => {
1333
+ const anchor = `phase-${phase.number}`;
1334
+ add(phase.updates, `Phase ${phase.number} — ${phase.name || ''}`, anchor);
1335
+ (phase.snapshots || []).forEach((snapshot) => add(snapshot.updates, `Phase ${phase.number} snapshot — ${snapshot.title || ''}`, anchor));
1336
+ (phase.tasks || []).forEach((task) => {
1337
+ add(task.updates, `${task.id} — ${task.title || ''}`, anchor);
1338
+ (task.snapshots || []).forEach((snapshot) => add(snapshot.updates, `${task.id} snapshot — ${snapshot.title || ''}`, anchor));
1339
+ });
1340
+ });
1341
+ (report.decisions || []).forEach((decision) => add(decision.updates, `Decision ${decision.id || ''}`, 'decisions'));
1342
+ return collected;
1343
+ }
1344
+
1345
+ /* ===================== Formatting & safety ===================== */
1346
+
1347
+ function escapeHtml(value) {
1348
+ return String(value == null ? '' : value)
1349
+ .replace(/&/g, '&amp;')
1350
+ .replace(/</g, '&lt;')
1351
+ .replace(/>/g, '&gt;')
1352
+ .replace(/"/g, '&quot;')
1353
+ .replace(/'/g, '&#39;');
1354
+ }
1355
+
1356
+ function escapeAttribute(value) {
1357
+ return escapeHtml(value);
1358
+ }
1359
+
1360
+ /** Escapes text, then allows `code` and **bold** — the only markup report text may use. */
1361
+ function formatInline(text) {
1362
+ return escapeHtml(text)
1363
+ .replace(/`([^`]+)`/g, '<code>$1</code>')
1364
+ .replace(/\*\*([^*]+)\*\*/g, '<strong>$1</strong>');
1365
+ }
1366
+
1367
+ /** Report links and images are relative paths inside the feature folder; anything with a scheme other than http(s) is dropped. */
1368
+ function cleanUrl(url) {
1369
+ const value = String(url || '').trim();
1370
+ return /^[a-z][a-z0-9+.-]*:/i.test(value) && !/^https?:/i.test(value) ? '#' : value;
1371
+ }
1372
+
1373
+ /** `cleanUrl`, escaped for use inside an HTML attribute. */
1374
+ function safeUrl(url) {
1375
+ return escapeAttribute(cleanUrl(url));
1376
+ }
1377
+
1378
+ /* ===================== Interaction ===================== */
1379
+
1380
+ function animateRing(fraction) {
1381
+ const ring = document.getElementById('ring-value');
1382
+ if (!ring) return;
1383
+ const circumference = 2 * Math.PI * 52;
1384
+ ring.style.strokeDasharray = String(circumference);
1385
+ ring.style.strokeDashoffset = String(circumference);
1386
+ requestAnimationFrame(() => requestAnimationFrame(() => {
1387
+ ring.style.strokeDashoffset = String(circumference * (1 - fraction));
1388
+ }));
1389
+ }
1390
+
1391
+ /** Seconds each stage stays on screen while a progression plays. */
1392
+ const PROGRESSION_PLAY_SECONDS = 2.2;
1393
+
1394
+ function wireProgressions() {
1395
+ document.querySelectorAll('[data-progression]').forEach((figure) => {
1396
+ const snapshot = progressions[Number(figure.dataset.progression)];
1397
+ const frames = snapshot.frames;
1398
+ const stageFrame = figure.querySelector('.shot-frame');
1399
+ const stageImage = figure.querySelector('.stage-image');
1400
+ const missingNote = figure.querySelector('.shot-missing');
1401
+ const counter = figure.querySelector('.stage-counter');
1402
+ const progressFill = figure.querySelector('.stage-progress div');
1403
+ const caption = figure.querySelector('.stage-caption');
1404
+ const playButton = figure.querySelector('[data-play]');
1405
+ const filmstrip = figure.querySelector('.filmstrip');
1406
+ const filmButtons = Array.from(figure.querySelectorAll('.film-frame'));
1407
+ let currentStage = 0;
1408
+ let playTimer = null;
1409
+
1410
+ const showStage = (stageIndex) => {
1411
+ currentStage = (stageIndex + frames.length) % frames.length;
1412
+ const frame = frames[currentStage];
1413
+ stageImage.src = cleanUrl(frame.src);
1414
+ stageImage.alt = frame.stage || `Stage ${currentStage + 1}`;
1415
+ stageFrame.dataset.zoom = cleanUrl(frame.src) || '#';
1416
+ stageFrame.dataset.caption = [frame.stage, frame.caption].filter(Boolean).join(' — ');
1417
+ counter.textContent = `Stage ${currentStage + 1} / ${frames.length}`;
1418
+ progressFill.style.width = `${((currentStage + 1) / frames.length) * 100}%`;
1419
+ caption.innerHTML = `
1420
+ <div class="stage-name">${formatInline(frame.stage || `Stage ${currentStage + 1}`)}${frame.task ? ` <span class="tag">${escapeHtml(frame.task)}</span>` : ''}${frame.at ? ` <span class="tag">${escapeHtml(frame.at)}</span>` : ''}</div>
1421
+ ${frame.caption ? `<div class="stage-note">${formatInline(frame.caption)}</div>` : ''}`;
1422
+ filmButtons.forEach((button, buttonIndex) => button.setAttribute('aria-current', String(buttonIndex === currentStage)));
1423
+ const activeButton = filmButtons[currentStage];
1424
+ const overflowsLeft = activeButton.offsetLeft < filmstrip.scrollLeft;
1425
+ const overflowsRight = activeButton.offsetLeft + activeButton.offsetWidth > filmstrip.scrollLeft + filmstrip.clientWidth;
1426
+ if (overflowsLeft || overflowsRight) filmstrip.scrollTo({ left: activeButton.offsetLeft - 16, behavior: 'smooth' });
1427
+ };
1428
+
1429
+ const stopPlaying = () => {
1430
+ clearInterval(playTimer);
1431
+ playTimer = null;
1432
+ playButton.textContent = '▶ Play';
1433
+ };
1434
+
1435
+ stageImage.addEventListener('load', () => { missingNote.hidden = true; stageImage.style.opacity = ''; fitFrameToImage(stageFrame, stageImage); });
1436
+ stageImage.addEventListener('error', () => { missingNote.hidden = false; stageImage.style.opacity = '0'; });
1437
+ figure.querySelectorAll('[data-step]').forEach((button) => button.addEventListener('click', () => {
1438
+ stopPlaying();
1439
+ showStage(currentStage + Number(button.dataset.step));
1440
+ }));
1441
+ filmButtons.forEach((button) => button.addEventListener('click', () => {
1442
+ stopPlaying();
1443
+ showStage(Number(button.dataset.stage));
1444
+ }));
1445
+ playButton.addEventListener('click', () => {
1446
+ if (playTimer) {
1447
+ stopPlaying();
1448
+ return;
1449
+ }
1450
+ playButton.textContent = '❚❚ Pause';
1451
+ if (currentStage === frames.length - 1) showStage(0);
1452
+ playTimer = setInterval(() => {
1453
+ if (currentStage === frames.length - 1) {
1454
+ stopPlaying();
1455
+ return;
1456
+ }
1457
+ showStage(currentStage + 1);
1458
+ }, PROGRESSION_PLAY_SECONDS * 1000);
1459
+ });
1460
+ showStage(0);
1461
+ });
1462
+ }
1463
+
1464
+ function wireCompareSliders() {
1465
+ wireProgressions();
1466
+ document.querySelectorAll('.shot-frame.compare').forEach((frame) => {
1467
+ const slider = frame.querySelector('input[type="range"]');
1468
+ slider.addEventListener('input', () => frame.style.setProperty('--split', `${slider.value}%`));
1469
+ const afterImage = frame.querySelector('img:not(.before-layer)');
1470
+ if (afterImage) afterImage.addEventListener('load', () => fitFrameToImage(frame, afterImage));
1471
+ });
1472
+ document.querySelectorAll('.shot-frame.single img:not(.stage-image)').forEach((image) => {
1473
+ image.addEventListener('load', () => fitFrameToImage(image.parentElement, image));
1474
+ });
1475
+ }
1476
+
1477
+ /** Matches the frame to the snapshot's own proportions so nothing is letterboxed. */
1478
+ function fitFrameToImage(frame, image) {
1479
+ if (image.naturalWidth && image.naturalHeight) {
1480
+ frame.style.aspectRatio = `${image.naturalWidth} / ${image.naturalHeight}`;
1481
+ }
1482
+ }
1483
+
1484
+ function wireLightbox() {
1485
+ const lightbox = document.getElementById('lightbox');
1486
+ const lightboxImage = document.getElementById('lightbox-image');
1487
+ const lightboxCaption = document.getElementById('lightbox-caption');
1488
+ document.addEventListener('click', (event) => {
1489
+ const trigger = event.target.closest('[data-zoom]');
1490
+ if (!trigger || trigger.dataset.zoom === '#') return;
1491
+ lightboxImage.src = trigger.dataset.zoom;
1492
+ lightboxCaption.textContent = trigger.dataset.caption || '';
1493
+ lightbox.classList.add('is-open');
1494
+ });
1495
+ const close = () => lightbox.classList.remove('is-open');
1496
+ lightbox.addEventListener('click', close);
1497
+ document.addEventListener('keydown', (event) => { if (event.key === 'Escape') close(); });
1498
+ }
1499
+
1500
+ /** While a run is in progress the page reloads itself, so an open tab always shows the latest phase. */
1501
+ /**
1502
+ * Keeps an open tab current in every state: re-reads the data files in the background and reloads only when
1503
+ * something changed — a new task result, a finished run, a plan reopened with an added task, the next run starting.
1504
+ */
1505
+ function wireAutoUpdate() {
1506
+ const toggle = document.getElementById('live-toggle');
1507
+ toggle.addEventListener('click', () => {
1508
+ writeStorage(localStorage, `${storageKey}:live`, isLiveEnabled() ? 'off' : 'on');
1509
+ toggle.setAttribute('aria-pressed', String(isLiveEnabled()));
1510
+ toggle.textContent = autoUpdateLabel();
1511
+ });
1512
+ const dashboardSource = scriptSource('_dashboard.js');
1513
+ const liveSource = scriptSource('_live.js');
1514
+ const renderedFingerprint = fingerprint(report, live);
1515
+ const checkSeconds = pageView() === 'running' ? RUNNING_CHECK_SECONDS : IDLE_CHECK_SECONDS;
1516
+ setInterval(async () => {
1517
+ if (!isLiveEnabled() || document.querySelector('.lightbox.is-open')) return;
1518
+ const nextReport = await reloadGlobal(dashboardSource, 'FEATURE_DASHBOARD');
1519
+ if (!nextReport) return; // missing or caught mid-write — try again next time
1520
+ const nextLive = liveSource ? await reloadGlobal(liveSource, 'FEATURE_LIVE') : null;
1521
+ if (fingerprint(nextReport, nextLive) === renderedFingerprint) return;
1522
+ writeStorage(sessionStorage, `${storageKey}:scroll`, String(window.scrollY));
1523
+ location.reload();
1524
+ }, checkSeconds * 1000);
1525
+ setInterval(refreshAges, AGE_REFRESH_SECONDS * 1000);
1526
+ }
1527
+
1528
+ function autoUpdateLabel() {
1529
+ return `Auto-update ${isLiveEnabled() ? 'on' : 'off'}`;
1530
+ }
1531
+
1532
+ function scriptSource(suffix) {
1533
+ const script = Array.from(document.scripts).find((candidate) => (candidate.getAttribute('src') || '').endsWith(suffix));
1534
+ return script ? script.getAttribute('src') : '';
1535
+ }
1536
+
1537
+ /** Loads a data file again from disk (the query string defeats the cache) and returns the global it assigns. */
1538
+ function reloadGlobal(source, globalName) {
1539
+ return new Promise((resolve) => {
1540
+ window[globalName] = undefined;
1541
+ const script = document.createElement('script');
1542
+ script.src = `${source}?check=${Date.now()}`;
1543
+ script.onload = () => { script.remove(); resolve(window[globalName] || null); };
1544
+ script.onerror = () => { script.remove(); resolve(null); };
1545
+ document.head.appendChild(script);
1546
+ });
1547
+ }
1548
+
1549
+ function fingerprint(dashboardData, liveData) {
1550
+ return JSON.stringify([dashboardData, liveData || null]);
1551
+ }
1552
+
1553
+ /** Re-words every "updated N min ago" label as time passes, without reloading the page. */
1554
+ function refreshAges() {
1555
+ document.querySelectorAll('[data-age]').forEach((label) => {
1556
+ const age = describeAge(label.dataset.age);
1557
+ label.textContent = age.text;
1558
+ const card = label.closest('.now');
1559
+ if (card) card.classList.toggle('is-stale', age.isStale);
1560
+ });
1561
+ }
1562
+
1563
+ /**
1564
+ * The status the page acts on. The data's `status` is written by bt-execute, but "complete" is only believed
1565
+ * when every task really is done; otherwise the plan is shown as paused, with a warning in the header.
1566
+ */
1567
+ function effectiveStatus() {
1568
+ const status = report.status || 'planned';
1569
+ if (status === 'complete' && unfinishedTasks().length) return 'paused';
1570
+ return status;
1571
+ }
1572
+
1573
+ function unfinishedTasks() {
1574
+ return collectTasks().filter((task) => task.status !== 'done');
1575
+ }
1576
+
1577
+ function isLiveEnabled() {
1578
+ return readStorage(localStorage, `${storageKey}:live`) !== 'off';
1579
+ }
1580
+
1581
+ function restoreScroll() {
1582
+ const savedScroll = readStorage(sessionStorage, `${storageKey}:scroll`);
1583
+ if (savedScroll == null) return;
1584
+ document.documentElement.style.scrollBehavior = 'auto';
1585
+ window.scrollTo(0, Number(savedScroll) || 0);
1586
+ document.documentElement.style.scrollBehavior = '';
1587
+ writeStorage(sessionStorage, `${storageKey}:scroll`, null);
1588
+ }
1589
+
1590
+ /** Browser storage can be blocked for file:// pages; the report works without it. */
1591
+ function readStorage(storage, key) {
1592
+ try {
1593
+ return storage.getItem(key);
1594
+ } catch (error) {
1595
+ return null;
1596
+ }
1597
+ }
1598
+
1599
+ function writeStorage(storage, key, value) {
1600
+ try {
1601
+ if (value == null) storage.removeItem(key);
1602
+ else storage.setItem(key, value);
1603
+ } catch (error) {
1604
+ /* storage unavailable — live toggle and "new" markers simply reset */
1605
+ }
1606
+ }
1607
+ })();
1608
+ </script>
1609
+ </body>
1610
+ </html>