@feigi/fleet-ctl 3.108.0 → 3.109.0

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/scripts/board.html +130 -17
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@feigi/fleet-ctl",
3
- "version": "3.108.0",
3
+ "version": "3.109.0",
4
4
  "description": "Agent fleet: run-team controller, merge bot, PR reviewer, and the ticket pipeline they share",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -8,12 +8,13 @@
8
8
  :root { color-scheme: dark; --bg:#0d1117; --panel:#161b22; --line:#30363d;
9
9
  --fg:#e6edf3; --dim:#8b949e; --red:#f85149; --amber:#d29922; --green:#3fb950; --blue:#58a6ff; }
10
10
  * { box-sizing: border-box; }
11
- /* The page is the window's height: header, banner, attention strip,
12
- spend panel and footer keep their natural height and never shrink; #board
13
- takes the rest, and each column scrolls on its own past that. The board's
14
- min-height is the floor for a window too short for the fixed parts — they
15
- then overflow body and the PAGE scrolls, rather than squeezing the
16
- columns to nothing or clipping anything off. */
11
+ /* The page is the window's height: header, banner, attention strip, the tab
12
+ strip and footer keep their natural height and never shrink; the open
13
+ tab's pane (#board or #spend, the other is hidden) takes the rest, and
14
+ each board column scrolls on its own past that. The panes' min-height is
15
+ the floor for a window too short for the fixed parts — they then overflow
16
+ body and the PAGE scrolls, rather than squeezing the columns to nothing or
17
+ clipping anything off. */
17
18
  body { margin:0; background:var(--bg); color:var(--fg);
18
19
  font:14px/1.4 ui-monospace,SFMono-Regular,Menlo,monospace;
19
20
  height:100vh; display:flex; flex-direction:column; }
@@ -32,7 +33,8 @@
32
33
  #stale-banner.dead { background:var(--red); color:#fff; }
33
34
  #attention { padding:8px 16px; border-bottom:1px solid var(--line); background:#2d1618; }
34
35
  #attention:empty { display:none; }
35
- .att { display:inline-block; margin:2px 10px 2px 0; }
36
+ .att { display:inline-block; margin:2px 10px 2px 0; color:inherit; text-decoration:none; }
37
+ .att:hover { text-decoration:underline; }
36
38
  .att .n { color:var(--blue); font-weight:600; }
37
39
  .flag { color:var(--red); font-weight:600; }
38
40
  #board { display:grid; grid-template-columns:repeat(5,1fr); grid-template-rows:minmax(0,1fr); gap:10px; padding:14px; align-items:start;
@@ -59,9 +61,19 @@
59
61
  .badge { border:1px solid var(--line); border-radius:10px; padding:0 6px; }
60
62
  .badge.flag { border-color:var(--red); color:var(--red); }
61
63
  footer { color:var(--dim); padding:10px 16px; border-top:1px solid var(--line); font-size:12px; }
64
+ /* A pane carries its own display (grid, block), which would beat the UA's
65
+ [hidden] rule; the closed tab's pane must stay closed. */
66
+ [hidden] { display:none !important; }
67
+ #tabs { display:flex; gap:4px; padding:8px 14px 0; border-bottom:1px solid var(--line); }
68
+ #tabs a { color:var(--dim); text-decoration:none; padding:5px 14px; border:1px solid transparent; border-bottom:0;
69
+ border-radius:6px 6px 0 0; margin-bottom:-1px; }
70
+ #tabs a:hover { color:var(--fg); }
71
+ #tabs a.on { color:var(--fg); background:var(--bg); border-color:var(--line); }
72
+ /* A hash link's target flashes once on arrival. The duration is FLASH_MS in the script. */
73
+ .card.flash { animation:flash 1.2s ease-out 1; }
74
+ @keyframes flash { from { box-shadow:0 0 0 2px var(--blue); background:#12233a; } to { box-shadow:0 0 0 2px transparent; } }
62
75
  footer .filed { margin-top:4px; }
63
- #spend { padding:0 14px 14px; }
64
- #spend:empty { display:none; }
76
+ #spend { padding:14px; flex:1 1 0; min-height:200px; overflow-y:auto; }
65
77
  .spend-wrap { background:var(--panel); border:1px solid var(--line); border-radius:8px; padding:10px 12px; }
66
78
  .spend-hd { display:flex; align-items:baseline; gap:10px; margin-bottom:8px; }
67
79
  .spend-hd h2 { font-size:11px; letter-spacing:.06em; color:var(--dim); margin:0; text-transform:uppercase; }
@@ -83,8 +95,9 @@
83
95
  <header><h1 id="heading">🛰 fleet cockpit</h1><span id="age"></span></header>
84
96
  <div id="stale-banner"></div>
85
97
  <div id="attention"></div>
98
+ <nav id="tabs"><a id="tab-board" class="on" href="#board" aria-current="page">Board</a><a id="tab-tokens" href="#tokens">Tokens</a></nav>
86
99
  <div id="board"></div>
87
- <div id="spend"></div>
100
+ <div id="spend" hidden></div>
88
101
  <footer id="footer"></footer>
89
102
  <script>
90
103
  const COLUMNS = ["POOL", "IMPLEMENTING", "REVIEW", "READY", "MERGED"];
@@ -110,6 +123,37 @@ let repoUrl = null; // full repo URL from the model (carries the host) — PR li
110
123
  const TITLE = "fleet cockpit";
111
124
  function boardTitle(repo) { return repo ? `${TITLE} — ${repo}` : TITLE; }
112
125
 
126
+ // Where a URL hash lands: which tab is open, and which card (an issue number,
127
+ // as a string) to bring into view on it. The router's whole decision, as a
128
+ // value with no DOM or location touched, so it is liftable out of the source
129
+ // the way spendView is. It closes over nothing, for the same reason.
130
+ //
131
+ // Every hash the page draws is a tab (`#board`, `#tokens`) or a card on the
132
+ // Board (`#board/<issue>`). Anything else — no hash, a tab the page does not
133
+ // have, a target the tab does not have — lands on Board's top, or the named
134
+ // tab's top, never on a blank page and never on an error.
135
+ function routeHash(hash) {
136
+ const [tab, target, ...more] = String(hash).replace(/^#/, "").split("/");
137
+ if (tab === "board") return { tab, target: more.length === 0 && /^[1-9]\d*$/.test(target) ? target : null };
138
+ if (tab === "tokens") return { tab, target: null };
139
+ return { tab: "board", target: null };
140
+ }
141
+
142
+ // Each tab, and the pane it opens.
143
+ const PANES = { board: "board", tokens: "spend" };
144
+
145
+ // Which card is still owed a scroll. The cards are rebuilt every tick, so a
146
+ // hash that arrives before the first render (a reload, a pasted link) cannot
147
+ // scroll yet: it waits here for the render.
148
+ let rendered = false;
149
+ let pending = null;
150
+
151
+ // The card flashing now, and when it started. A tick rebuilds every card, so
152
+ // the flash lives here rather than on a node the next tick throws away.
153
+ // FLASH_MS is `.card.flash`'s animation duration.
154
+ const FLASH_MS = 1200;
155
+ let flashing = null;
156
+
113
157
  const el = (t, cls, txt) => { const e = document.createElement(t); if (cls) e.className = cls; if (txt != null) e.textContent = txt; return e; };
114
158
  const mins = (ms) => Math.floor((Date.now() - ms) / 60000);
115
159
 
@@ -236,14 +280,14 @@ function renderSpend(sp) {
236
280
 
237
281
  const wrap = el("div", "spend-wrap");
238
282
  const hd = el("div", "spend-hd");
239
- hd.append(el("h2", null, "spend"));
283
+ hd.append(el("h2", null, "tokens"));
240
284
  hd.append(el("span", "lede", v.lede));
241
285
  hd.append(el("span", "note", v.note));
242
286
  wrap.append(hd);
243
287
 
244
288
  const cols = el("div", "spend-cols");
245
289
  const byRole = el("div");
246
- byRole.append(el("h3", null, "by role"));
290
+ byRole.append(el("h3", null, "by member role"));
247
291
  spendRows(byRole, v.roles, {
248
292
  label: (r) => `${r.role} ×${r.agents}`,
249
293
  value: (r) => k(r.cacheWrite),
@@ -285,10 +329,12 @@ function render(m) {
285
329
  const att = document.getElementById("attention");
286
330
  att.innerHTML = "";
287
331
  for (const t of m.attention || []) {
288
- const span = el("span", "att");
289
- span.append(el("span", "n", "#" + t.issue), document.createTextNode(" "));
290
- span.append(el("span", "flag", (t.flags || []).join(" ")));
291
- att.append(span);
332
+ // A link into the Board, never a new window: the hash carries the card.
333
+ const a = el("a", "att");
334
+ a.href = "#board/" + t.issue;
335
+ a.append(el("span", "n", "#" + t.issue), document.createTextNode(" "));
336
+ a.append(el("span", "flag", (t.flags || []).join(" ")));
337
+ att.append(a);
292
338
  }
293
339
  // columns — each built once and kept, its contents rewritten every tick.
294
340
  // A column scrolls on its own and a scroll offset lives on
@@ -374,6 +420,12 @@ function render(m) {
374
420
  } else if (capMsg) {
375
421
  showBanner(capMsg);
376
422
  } else { banner.style.display = "none"; banner.className = ""; }
423
+ // Last, once the banner and footer have taken their place in the layout, so
424
+ // a card scrolled to is scrolled to where it will stay.
425
+ rendered = true;
426
+ // Its own catch: the board above is already written, so a failed scroll is
427
+ // not a failed render.
428
+ try { settle(); } catch (e) { warn("⚠ scroll to card failed: " + e.message); }
377
429
  }
378
430
 
379
431
  // The heartbeat's mark, rendered. A dead run's tickets keep the label
@@ -421,6 +473,7 @@ function ledgerBanner(state) {
421
473
 
422
474
  function card(t) {
423
475
  const c = el("div", "card");
476
+ c.id = "card-" + t.issue;
424
477
  const top = el("div", "top");
425
478
  top.append(el("span", "n", "#" + t.issue));
426
479
  top.append(el("span", "title", t.title || ""));
@@ -438,6 +491,9 @@ function card(t) {
438
491
  for (const f of t.flags || []) meta.append(el("span", "badge flag", f));
439
492
  if (t.ruling) meta.append(el("span", "badge", "ruled:" + t.ruling));
440
493
  c.append(meta);
494
+ // A card rebuilt mid-flash picks the flash up where it was, not from the start.
495
+ const age = flashing && flashing.issue === String(t.issue) ? Date.now() - flashing.at : Infinity;
496
+ if (age < FLASH_MS) flash(c, age);
441
497
  return c;
442
498
  }
443
499
 
@@ -454,6 +510,49 @@ function warn(msg) {
454
510
  showBanner(msg);
455
511
  }
456
512
 
513
+ // Opens the tab the hash names and settles the card it targets. The two
514
+ // panes stay in the page either way, so a tick keeps filling both.
515
+ function applyHash() {
516
+ const r = routeHash(location.hash);
517
+ for (const [t, pane] of Object.entries(PANES)) {
518
+ const on = t === r.tab;
519
+ document.getElementById(pane).hidden = !on;
520
+ const a = document.getElementById("tab-" + t);
521
+ a.classList.toggle("on", on);
522
+ if (on) a.setAttribute("aria-current", "page"); else a.removeAttribute("aria-current");
523
+ }
524
+ pending = r;
525
+ settle();
526
+ }
527
+
528
+ // The arrival: the target card scrolls into view and flashes once; no target,
529
+ // or a target no card on the board carries, lands on the tab's top. Taken
530
+ // off `pending` first, so a later tick never scrolls the page again; nothing
531
+ // settles before the first render.
532
+ function settle() {
533
+ if (!pending || !rendered) return;
534
+ const { target } = pending;
535
+ pending = null;
536
+ const hit = target && document.getElementById("card-" + target);
537
+ if (!hit) {
538
+ window.scrollTo(0, 0);
539
+ document.getElementById("spend").scrollTop = 0;
540
+ return;
541
+ }
542
+ hit.scrollIntoView({ block: "center" });
543
+ flashing = { issue: target, at: Date.now() };
544
+ flash(hit, 0);
545
+ }
546
+
547
+ // Runs the flash on a card `age` ms into it.
548
+ function flash(node, age) {
549
+ node.classList.remove("flash");
550
+ void node.offsetWidth; // restart the animation when the same card is targeted again
551
+ node.style.animationDelay = -age + "ms";
552
+ node.classList.add("flash");
553
+ node.addEventListener("animationend", () => node.classList.remove("flash"), { once: true });
554
+ }
555
+
457
556
  async function poll() {
458
557
  let r;
459
558
  try {
@@ -473,7 +572,21 @@ async function poll() {
473
572
  }
474
573
  setTimeout(poll, interval * 1000);
475
574
  }
476
- poll();
575
+
576
+ // Clicking the link to the hash already open fires no hashchange, so the
577
+ // click is routed to applyHash by hand: a card scrolled away from can be
578
+ // brought back by the same link.
579
+ function boot() {
580
+ window.addEventListener("hashchange", applyHash);
581
+ document.addEventListener("click", (e) => {
582
+ if (e.defaultPrevented || e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;
583
+ const a = e.target.closest?.('a[href^="#"]');
584
+ if (a && a.getAttribute("href") === location.hash) { e.preventDefault(); applyHash(); }
585
+ });
586
+ applyHash();
587
+ poll();
588
+ }
589
+ boot();
477
590
  </script>
478
591
  </body>
479
592
  </html>