fwdloop 0.18.0 → 0.19.1
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/package.json +1 -1
- package/src/panel/authortrigger.js +6 -7
- package/src/panel/data.js +93 -9
- package/src/panel/index.html +304 -262
- package/src/panel/scheduler.js +3 -2
- package/src/panel/server.js +10 -2
- package/src/primitives.js +5 -6
- package/src/summary-words.js +21 -5
- package/src/trigger-files.js +4 -4
- package/types/panel/author.d.ts +1 -21
- package/types/panel/authortrigger.d.ts +3 -23
- package/types/panel/data.d.ts +58 -3
- package/types/primitives.d.ts +5 -0
- package/types/summary-words.d.ts +7 -2
package/src/panel/index.html
CHANGED
|
@@ -182,8 +182,8 @@
|
|
|
182
182
|
|
|
183
183
|
/* M4c inbox: section 1 (waiting on you) carries the page's amber accent
|
|
184
184
|
treatment; section 3 (answered/expired) is dimmed. Tokens only. */
|
|
185
|
-
.inbox-h{font-size:12px;color:var(--text-dim);font-weight:700;margin:12px 0 6px;}
|
|
186
|
-
.inbox-h:first-child{margin-top:0;}
|
|
185
|
+
.rl-sect,.inbox-h{font-size:12px;color:var(--text-dim);font-weight:700;margin:12px 0 6px;}
|
|
186
|
+
.rl-sect:first-child,.inbox-h:first-child{margin-top:0;}
|
|
187
187
|
.inbox-row.s1{border-left:4px solid var(--amber);background:var(--amber-bg);}
|
|
188
188
|
.inbox-row.s3{opacity:.6;}
|
|
189
189
|
.inbox-row .wf-line1{min-width:0;}
|
|
@@ -221,13 +221,11 @@
|
|
|
221
221
|
.answer-msg.stuck{border-color:var(--amber);}
|
|
222
222
|
.answer-msg.info::before{content:"[·] ";color:var(--amber);font-weight:700;}
|
|
223
223
|
|
|
224
|
-
.
|
|
224
|
+
.hist-row{
|
|
225
225
|
display:flex;flex-direction:column;row-gap:4px;min-width:0;
|
|
226
226
|
padding:8px 8px 8px 18px;position:relative;border:1px solid var(--border);margin-bottom:6px;background:var(--panel2);cursor:pointer;
|
|
227
227
|
}
|
|
228
|
-
.
|
|
229
|
-
.wf-row:hover,.hist-row:hover{border-color:var(--border-strong);}
|
|
230
|
-
.wf-row.selected::before{content:">";}
|
|
228
|
+
.hist-row:hover{border-color:var(--border-strong);}
|
|
231
229
|
/* line 1: glyph + name, kept on ONE line — truncated with an ellipsis
|
|
232
230
|
(never wrapped) when the job/runid text is longer than the row; the
|
|
233
231
|
full text is still reachable via the span's own title attribute. */
|
|
@@ -246,15 +244,37 @@
|
|
|
246
244
|
.hdr-verdict{font-size:12px;color:var(--text-dim);min-width:0;overflow-wrap:anywhere;}
|
|
247
245
|
.wf-meta{font-size:12px;color:var(--text-dim);}
|
|
248
246
|
.wf-sep{font-size:12px;color:var(--text-faint);}
|
|
249
|
-
.
|
|
250
|
-
/*
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
.
|
|
254
|
-
.
|
|
255
|
-
.
|
|
256
|
-
.
|
|
257
|
-
.
|
|
247
|
+
.hist-row.selected{border:2px solid var(--accent);border-radius:4px;}
|
|
248
|
+
/* M11: the one runs list. Copied from docs/product/m11-runs-list-mock.html (the right box, "F - fwdloop"); only the class names carry the rl- prefix
|
|
249
|
+
(the page already has .chip, .hint, .live ...), a card's lines clip with an ellipsis exactly as the mockup does (the full text is on the run page). */
|
|
250
|
+
:root{--rl-accent-bg:rgba(122,162,247,.12);--rl-accent-bg-strong:rgba(122,162,247,.2);}
|
|
251
|
+
.rl-card{display:block;width:100%;text-align:left;background:var(--panel2);border:1px solid var(--border);padding:6px 8px;margin:0 0 6px;cursor:pointer;min-height:44px;color:inherit;font:inherit;}
|
|
252
|
+
div.rl-card{cursor:default;}
|
|
253
|
+
.rl-card:hover{border-color:var(--accent);background:var(--rl-accent-bg);}
|
|
254
|
+
div.rl-card:hover{border-color:var(--border);background:var(--panel2);}
|
|
255
|
+
.rl-card.rl-sel,div.rl-card.rl-sel:hover{border:2px solid var(--accent);border-radius:4px;background:var(--rl-accent-bg-strong);}
|
|
256
|
+
.rl-card:focus-visible,.rl-fold:focus-visible{outline:2px solid var(--accent);outline-offset:2px;}
|
|
257
|
+
.rl-card.rl-live{border-color:var(--amber);}
|
|
258
|
+
.rl-card.rl-need{border-color:var(--accent);}
|
|
259
|
+
.rl-l1{display:flex;gap:6px;align-items:center;min-width:0;overflow:hidden;}
|
|
260
|
+
.rl-nm{font-weight:700;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0;}
|
|
261
|
+
.rl-rn{color:var(--accent);flex:none;}
|
|
262
|
+
.rl-l2{display:block;font-size:12px;color:var(--text-dim);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
|
|
263
|
+
.rl-l2 .sign-word{color:var(--text);}
|
|
264
|
+
.rl-dim{color:var(--text-dim);font-size:12px;flex:none;}
|
|
265
|
+
.rl-faint{color:var(--text-faint);font-size:12px;}
|
|
266
|
+
.rl-cnt{color:var(--text-faint);font-size:inherit;flex:none;}
|
|
267
|
+
.rl-runs{margin:6px 0 0 6px;padding-left:8px;border-left:2px solid var(--border);}
|
|
268
|
+
.rl-runs .rl-card{background:var(--bg);}
|
|
269
|
+
.rl-runs .rl-card.rl-sel{background:var(--rl-accent-bg-strong);}
|
|
270
|
+
.rl-fold{background:none;border:0;color:var(--text-dim);font:inherit;font-size:12px;padding:4px 0;cursor:pointer;min-height:32px;}
|
|
271
|
+
.rl-fold:hover{color:var(--accent);}
|
|
272
|
+
.rl-hint{font-size:12px;color:var(--text-faint);padding:2px 0 6px;}
|
|
273
|
+
.rl-pill{font-size:11px;border:1px solid var(--amber);color:var(--amber);padding:0 5px;margin-left:auto;flex:none;}
|
|
274
|
+
.rl-pill-need{border-color:var(--accent);color:var(--accent);}
|
|
275
|
+
.rl-dash{border-top:1px dashed var(--border-strong);margin:10px 0 6px;}
|
|
276
|
+
#panel-runs .rl-faint{margin-bottom:4px;}
|
|
277
|
+
@media (max-width:899px){ .rl-fold{min-height:44px;} }
|
|
258
278
|
|
|
259
279
|
.rp-header{display:flex;align-items:center;justify-content:space-between;padding:10px 16px;border-bottom:2px solid var(--border-strong);background:var(--panel);flex-wrap:wrap;gap:8px;}
|
|
260
280
|
.rp-header h2{margin:0;font-size:15px;min-width:0;overflow-wrap:anywhere;text-transform:none;letter-spacing:normal;}
|
|
@@ -354,7 +374,7 @@
|
|
|
354
374
|
.chip::before{content:"[ ";color:var(--text-faint);}
|
|
355
375
|
.chip::after{content:" ]";color:var(--text-faint);}
|
|
356
376
|
.chip[aria-pressed="true"]{background:var(--panel);color:var(--accent);border-color:var(--accent);font-weight:700;}
|
|
357
|
-
/* Compact filter-bar chips (
|
|
377
|
+
/* Compact filter-bar chips (the runs list's filter bar): single
|
|
358
378
|
letters/bare glyphs, no "[ ]" brackets — hamr's 2026-09-25 feedback on
|
|
359
379
|
the live panel ("icons are taking too much space", "one letter without
|
|
360
380
|
brackets"). */
|
|
@@ -1091,16 +1111,19 @@
|
|
|
1091
1111
|
— the wide right pane is where the evidence lives now. The
|
|
1092
1112
|
answer doors are in the Ask tab, not here (M4b). -->
|
|
1093
1113
|
<div id="inbox-list" data-testid="inbox-list"></div>
|
|
1114
|
+
<div class="rl-dash"></div>
|
|
1115
|
+
<div class="rl-faint" data-testid="inbox-filter-note">filters below act on answered and expired only</div>
|
|
1116
|
+
<div id="inbox-filterbar-anchor"></div>
|
|
1117
|
+
<div id="inbox-list-old" data-testid="inbox-list-old"></div>
|
|
1094
1118
|
</section>
|
|
1095
1119
|
|
|
1096
1120
|
<section id="panel-runs" class="tabpanel" role="tabpanel" aria-labelledby="tab-runs" hidden>
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
</div>
|
|
1121
|
+
<!-- M11: ONE list. Running now, Needs you and Scheduled are not filtered; the filters below act on Jobs and quiet jobs only. -->
|
|
1122
|
+
<div id="rl-top" data-testid="rl-top"></div>
|
|
1123
|
+
<div class="rl-dash"></div>
|
|
1124
|
+
<div class="rl-faint" data-testid="rl-filter-note">filters below act on Jobs and quiet jobs only</div>
|
|
1101
1125
|
<div id="runs-filterbar-anchor"></div>
|
|
1102
1126
|
<div id="wf-list" data-testid="wf-list"></div>
|
|
1103
|
-
<div id="history-list" data-testid="history-list" hidden></div>
|
|
1104
1127
|
</section>
|
|
1105
1128
|
|
|
1106
1129
|
</div>
|
|
@@ -1127,7 +1150,7 @@
|
|
|
1127
1150
|
<div class="pane-body" id="right-pane-body">
|
|
1128
1151
|
|
|
1129
1152
|
<section id="panel-run" class="tabpanel active" role="tabpanel" aria-labelledby="tab-run">
|
|
1130
|
-
<div id="run-empty" class="hint" style="font-size:13px;padding:24px 0;">select a run from
|
|
1153
|
+
<div id="run-empty" class="hint" style="font-size:13px;padding:24px 0;">select a run from the list</div>
|
|
1131
1154
|
<div id="run-content" hidden>
|
|
1132
1155
|
<div id="summary-blocks" data-testid="summary-blocks">
|
|
1133
1156
|
<div id="ended-block" class="ended-block" data-testid="ended-block" hidden></div>
|
|
@@ -1576,9 +1599,9 @@
|
|
|
1576
1599
|
// says this sign is [▶] running or [·] waiting on you (data.js glyphPulses).
|
|
1577
1600
|
// M4c-fix amendment 2 (g): one bold word after every sign, then " — " and the plain line. The word comes from the
|
|
1578
1601
|
// server's one sign->word table (data.js SIGN_WORDS) on `word`; this only draws it, the same in Runs, Inbox and the header.
|
|
1579
|
-
function signHtml(word, line, fallback){
|
|
1602
|
+
function signHtml(word, line, fallback, sep){
|
|
1580
1603
|
if(!word) return escapeXml(fallback || "unknown");
|
|
1581
|
-
return '<b class="sign-word">' + escapeXml(word) + '</b>' + (line ? " — " + escapeXml(line) : "");
|
|
1604
|
+
return '<b class="sign-word">' + escapeXml(word) + '</b>' + (line ? (sep || " — ") + escapeXml(line) : "");
|
|
1582
1605
|
}
|
|
1583
1606
|
function dotClass(g, pulse){ return "dot " + glyphClass(g) + (pulse ? " pulse" : ""); }
|
|
1584
1607
|
function glyphClass(g){
|
|
@@ -1722,56 +1745,6 @@
|
|
|
1722
1745
|
window.addEventListener("resize", reflowMapSoon);
|
|
1723
1746
|
}
|
|
1724
1747
|
|
|
1725
|
-
// ---- Runs tab: ONE run-row builder shared by History (flat) and the
|
|
1726
|
-
// Workflows view's per-flow expansion — the two never drift on how a run
|
|
1727
|
-
// row reads. Rekeyed from bareloop's job/runid to fwdloop's flow/runId
|
|
1728
|
-
// (GET /api/runs row shape: src/panel/data.js's listRuns).
|
|
1729
|
-
// opts.sub (amendment 12): a Workflows sub-card drops the flow name from its visible text; no other caller passes opts.
|
|
1730
|
-
function buildRunRowEl(r, opts){
|
|
1731
|
-
var row = document.createElement("div");
|
|
1732
|
-
// Selected state is computed here, off the module's own `currentRunId`,
|
|
1733
|
-
// so a row freshly built by a RE-RENDER (switching Runs view mode, or a
|
|
1734
|
-
// Workflows parent auto-expanding onto an older run picked from
|
|
1735
|
-
// History) shows selected without needing a click on this exact
|
|
1736
|
-
// element — `selectRun`'s imperative class toggle (used when a click
|
|
1737
|
-
// passes its own `rowEl`) stays layered on top of this, never replaced.
|
|
1738
|
-
var selected = r.flow === currentFlow && r.runId === currentRunId;
|
|
1739
|
-
row.className = "hist-row" + (selected ? " selected" : "");
|
|
1740
|
-
row.setAttribute("data-testid", "hist-row-" + r.flow + "-" + (r.runId || "none"));
|
|
1741
|
-
row.setAttribute("tabindex", "0");
|
|
1742
|
-
row.setAttribute("role", "button");
|
|
1743
|
-
row.setAttribute("aria-pressed", selected ? "true" : "false");
|
|
1744
|
-
var fullName = r.flow + (r.runId ? ' (' + r.runId + ')' : '');
|
|
1745
|
-
if(r.runId === null){
|
|
1746
|
-
// this flow has no runs yet — empty state names why, never a made-up row.
|
|
1747
|
-
row.innerHTML =
|
|
1748
|
-
'<span class="wf-line1"><span class="dot grey"></span>' +
|
|
1749
|
-
'<span class="wf-name" title="' + escapeXml(fullName) + '">' + escapeXml(fullName) + '</span></span>' +
|
|
1750
|
-
'<span class="wf-meta-line"><span class="wf-meta">' + escapeXml(r.why || "no runs yet") + '</span></span>';
|
|
1751
|
-
row.removeAttribute("tabindex");
|
|
1752
|
-
row.removeAttribute("role");
|
|
1753
|
-
return row;
|
|
1754
|
-
}
|
|
1755
|
-
if(opts && opts.sub){
|
|
1756
|
-
// amendment 12: line 1 `(run-<n>) <word> — <label>`; the flow name stays in title/aria only
|
|
1757
|
-
row.setAttribute("aria-label", fullName);
|
|
1758
|
-
row.innerHTML =
|
|
1759
|
-
'<span class="wf-line1"><span class="' + dotClass(r.glyph, r.pulse) + '"></span>' +
|
|
1760
|
-
'<span class="wf-name" title="' + escapeXml(fullName) + '">(' + escapeXml(r.runId) + ')</span> ' +
|
|
1761
|
-
'<span class="wf-sign-line" data-testid="run-sign-word">' + signHtml(r.word, (r.word === 'passed' && r.glyph === '[✓]' && !r.line) ? 'goal met' : r.line, r.label) + '</span></span>' +
|
|
1762
|
-
runMetaLineHtml(r, null);
|
|
1763
|
-
} else {
|
|
1764
|
-
row.innerHTML =
|
|
1765
|
-
'<span class="wf-line1"><span class="' + dotClass(r.glyph, r.pulse) + '"></span>' +
|
|
1766
|
-
'<span class="wf-name" title="' + escapeXml(fullName) + '">' + escapeXml(fullName) + '</span></span>' +
|
|
1767
|
-
'<span class="wf-sign-line" data-testid="run-sign-word">' + signHtml(r.word, r.line, r.label) + '</span>' +
|
|
1768
|
-
runMetaLineHtml(r, null);
|
|
1769
|
-
}
|
|
1770
|
-
row.addEventListener("click", function(){ openRunFromRuns(r, row); });
|
|
1771
|
-
row.addEventListener("keydown", function(e){ if(e.key === "Enter" || e.key === " "){ e.preventDefault(); row.click(); } });
|
|
1772
|
-
return row;
|
|
1773
|
-
}
|
|
1774
|
-
|
|
1775
1748
|
// M4c amendment 1 (a): the ONE place a click on a run in Runs decides where it lands.
|
|
1776
1749
|
// Right side: that run, on the Run tab, at once. Whether the run has an ask waiting on the human (or is
|
|
1777
1750
|
// stuck, which counts as waiting: M4c amendment 2 (b)) is decided from THAT RUN's own asks, fetched on
|
|
@@ -1803,22 +1776,10 @@
|
|
|
1803
1776
|
}).catch(function(){ /* unreadable books: the run stays open on the Run tab, the left side stays on Runs */ });
|
|
1804
1777
|
}
|
|
1805
1778
|
|
|
1806
|
-
// ----
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
if(!(runs || []).length){
|
|
1811
|
-
el.innerHTML = '<div class="hint">no runs listed yet — no flow under this root has been run</div>';
|
|
1812
|
-
return;
|
|
1813
|
-
}
|
|
1814
|
-
runs.forEach(function(r){ el.appendChild(buildRunRowEl(r)); });
|
|
1815
|
-
}
|
|
1816
|
-
|
|
1817
|
-
// ---- Workflows view: groups the ONE /api/runs payload by flow name
|
|
1818
|
-
// client-side. Runs arrive newest-first within a flow (server contract,
|
|
1819
|
-
// listRuns), so the first run seen for a flow is its latest.
|
|
1820
|
-
// The words for a run row's spend and time cells — the Workflows card (a flow's latest run) and
|
|
1821
|
-
// every History/expanded row say the same thing, from the same server fields.
|
|
1779
|
+
// ---- Jobs: groups the ONE /api/runs payload by flow name client-side. Runs arrive in
|
|
1780
|
+
// the server's order within a flow (listRuns), so the first run seen for a flow is its head.
|
|
1781
|
+
// The words for a run card's spend and time — every card of the runs list says the same
|
|
1782
|
+
// thing, from the same server fields.
|
|
1822
1783
|
function runSpendText(r){
|
|
1823
1784
|
return r.spend || r.spendWhy || "unknown";
|
|
1824
1785
|
}
|
|
@@ -1826,14 +1787,16 @@
|
|
|
1826
1787
|
function runWallText(r){
|
|
1827
1788
|
return typeof r.wallMs === "number" ? duration(r.wallMs) : null;
|
|
1828
1789
|
}
|
|
1829
|
-
// ONE
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1790
|
+
// The ONE date of every card in the runs list: local `MM/DD HH:MM` (the mockup's "10/13 19:12"). An unparseable stamp is shown raw, never blank.
|
|
1791
|
+
function rlShortDate(iso){
|
|
1792
|
+
var d = new Date(iso);
|
|
1793
|
+
if(isNaN(d.getTime())) return String(iso);
|
|
1794
|
+
var t = function(n){ return ("0" + n).slice(-2); };
|
|
1795
|
+
return t(d.getMonth() + 1) + "/" + t(d.getDate()) + " " + t(d.getHours()) + ":" + t(d.getMinutes());
|
|
1834
1796
|
}
|
|
1835
1797
|
function runAtText(r){
|
|
1836
|
-
|
|
1798
|
+
var when = r.at || r.askedAt || r.startedAt;
|
|
1799
|
+
return when ? rlShortDate(when) : (r.atWhy || "unknown");
|
|
1837
1800
|
}
|
|
1838
1801
|
function groupRunsByFlow(runs){
|
|
1839
1802
|
var byFlow = {};
|
|
@@ -1850,8 +1813,6 @@
|
|
|
1850
1813
|
runs: flowRuns,
|
|
1851
1814
|
runCount: last.runId === null ? 0 : flowRuns.length,
|
|
1852
1815
|
lastRunId: last.runId,
|
|
1853
|
-
lastGlyph: last.glyph,
|
|
1854
|
-
lastLabel: last.label,
|
|
1855
1816
|
lastRow: last,
|
|
1856
1817
|
};
|
|
1857
1818
|
});
|
|
@@ -1874,137 +1835,207 @@
|
|
|
1874
1835
|
));
|
|
1875
1836
|
}
|
|
1876
1837
|
|
|
1877
|
-
//
|
|
1878
|
-
//
|
|
1879
|
-
//
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1838
|
+
// ---- M11: ONE runs list (docs/wiki/the-module-ladder.md "M11 scope", amendments 1 and 2; docs/product/m11-runs-list-mock.html, the right box).
|
|
1839
|
+
// Top to bottom: Running now, Needs you, Scheduled (never filtered), a dashed line and the filters (they act on Jobs and quiet jobs only), Jobs, the
|
|
1840
|
+
// quiet fold. The page works out NOTHING: `live`, the Needs-you tag (`needs`), the job order and quiet split (`jobs`), the Scheduled cards and the two
|
|
1841
|
+
// limits all come from GET /api/runs (src/panel/data.js). `rlModel` is pure (payload in, cards out); the rl*Html functions only draw it.
|
|
1842
|
+
var rlData = { rows: [], jobs: [], scheduled: [], limits: { quietDays: 0, olderRuns: 0 } };
|
|
1843
|
+
// manual fold memory, keyed by flow ("__quiet" is the quiet fold): a per-viewer convenience, reset on reload. A manual click wins over an automatic open.
|
|
1844
|
+
var rlOpen = {};
|
|
1845
|
+
// the last markup written into each box: an identical repaint (every poll) writes nothing, so focus, scroll and a half-read card survive it
|
|
1846
|
+
var rlLast = { top: null, jobs: null };
|
|
1847
|
+
// The ONE writer of `rlData`: the whole /api/runs payload, as the server sent it.
|
|
1848
|
+
function setRunsData(r){
|
|
1849
|
+
rlData = { rows: r.rows || [], jobs: r.jobs || [], scheduled: r.scheduled || [], limits: r.limits || rlData.limits };
|
|
1850
|
+
}
|
|
1851
|
+
function rlModel(data, groups, filters, limits, sel, open){
|
|
1852
|
+
var active = filtersActive(filters);
|
|
1853
|
+
var place = {};
|
|
1854
|
+
(data.jobs || []).forEach(function(j, i){ place[j.flow] = { quiet: j.quiet === true, at: i }; });
|
|
1855
|
+
var cards = groups.slice().sort(function(a, b){
|
|
1856
|
+
return (place[a.flow] ? place[a.flow].at : Infinity) - (place[b.flow] ? place[b.flow].at : Infinity);
|
|
1857
|
+
}).map(function(g){
|
|
1858
|
+
var quiet = !!(place[g.flow] && place[g.flow].quiet);
|
|
1859
|
+
if(g.lastRunId === null) return { flow: g.flow, group: g, head: g.lastRow, empty: true, quiet: quiet, selected: false, count: 0, sel: sel, older: { open: false, shown: [], hidden: 0, total: 0 } };
|
|
1860
|
+
var head = g.runs[0];
|
|
1861
|
+
var matching = active ? filterRuns(g.runs, filters, Date.now()) : g.runs;
|
|
1862
|
+
var older = g.runs.slice(1);
|
|
1863
|
+
var isSel = function(r){ return sel.flow === g.flow && r.runId === sel.runId; };
|
|
1864
|
+
// the fold is capped; past the cap only the selected run stays, plus (search or filter active) the ONE newest older run that matches (when it is past the cap)
|
|
1865
|
+
var past = older.slice(limits.olderRuns);
|
|
1866
|
+
var firstMatch = active ? older.filter(function(r){ return matching.indexOf(r) !== -1; })[0] : undefined;
|
|
1867
|
+
var shown = older.slice(0, limits.olderRuns).concat(past.filter(function(r){ return isSel(r) || r === firstMatch; }));
|
|
1868
|
+
// the fold opens by itself when any older run matches (even if the head matches too), or when the selected run is an older one
|
|
1869
|
+
var auto = (active && older.some(function(r){ return matching.indexOf(r) !== -1; })) || older.some(isSel);
|
|
1870
|
+
return {
|
|
1871
|
+
flow: g.flow, group: g, head: head, empty: false, quiet: quiet, count: g.runCount, sel: sel,
|
|
1872
|
+
selected: g.runs.some(isSel),
|
|
1873
|
+
older: { open: Object.prototype.hasOwnProperty.call(open, g.flow) ? open[g.flow] : auto, shown: shown, hidden: older.length - shown.length, total: older.length },
|
|
1874
|
+
};
|
|
1875
|
+
});
|
|
1876
|
+
var quietCards = cards.filter(function(c){ return c.quiet; });
|
|
1877
|
+
return {
|
|
1878
|
+
running: data.rows.filter(function(r){ return r.live === true; }),
|
|
1879
|
+
needs: data.rows.filter(function(r){ return typeof r.needs === "string" && r.needs !== ""; }),
|
|
1880
|
+
scheduled: data.scheduled || [],
|
|
1881
|
+
jobs: cards.filter(function(c){ return !c.quiet; }),
|
|
1882
|
+
quiet: quietCards,
|
|
1883
|
+
quietOpen: Object.prototype.hasOwnProperty.call(open, "__quiet") ? open.__quiet : quietCards.some(function(c){ return c.selected; }),
|
|
1884
|
+
limits: limits,
|
|
1885
|
+
noRows: data.rows.length === 0,
|
|
1886
|
+
};
|
|
1885
1887
|
}
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
//
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1888
|
+
function rlSectHtml(label, n, note){
|
|
1889
|
+
return '<div class="rl-sect">' + label + ' (' + n + ')' + (note ? ' ' + note : '') + '</div>';
|
|
1890
|
+
}
|
|
1891
|
+
// line 1 and 2 of a Running now / Needs you card; both jump to the run (rlJump). The tag is a label (a span), never a button.
|
|
1892
|
+
function rlJumpCardHtml(r, need){
|
|
1893
|
+
var cost = r.spend || "unknown";
|
|
1894
|
+
var faint = r.startedAt ? '<span data-rl-since="' + escapeXml(r.startedAt) + '"></span>' : 'time unknown';
|
|
1895
|
+
return '<button class="rl-card ' + (need ? 'rl-need' : 'rl-live') + '" type="button" data-rl-jump="' + escapeXml(r.flow + "|" + r.runId) + '" data-testid="rl-' + (need ? 'need' : 'live') + '-' + escapeXml(r.flow) + '-' + escapeXml(r.runId) + '">' +
|
|
1896
|
+
'<span class="rl-l1"><span class="' + dotClass(r.glyph, r.pulse) + '"></span><span class="rl-nm" title="' + escapeXml(r.flow) + '">' + escapeXml(r.flow) + '</span> <span class="rl-rn">' + escapeXml(r.runId) + '</span>' +
|
|
1897
|
+
(need ? '<span class="rl-pill rl-pill-need">' + escapeXml(r.needs) + '</span>' : ' <span class="rl-faint">' + faint + ' · ' + escapeXml(cost) + '</span>') + '</span>' +
|
|
1898
|
+
'<span class="rl-l2">' + escapeXml(r.label || "unknown") + (need ? ' · ' + escapeXml(runAtText(r)) : '') + '</span></button>';
|
|
1899
|
+
}
|
|
1900
|
+
// Scheduled: a click does what Running now does (rlJump to the job's newest run, `runId` from the server). `at` / `in` are null when the job has no next clock time (a file trigger): nothing is made up.
|
|
1901
|
+
// A job with no run has nothing to open: that card stays a plain box.
|
|
1902
|
+
function rlScheduledCardHtml(s){
|
|
1903
|
+
var body = '<span class="rl-l1"><span class="dot grey"></span><span class="rl-nm" title="' + escapeXml(s.flow) + '">' + escapeXml(s.flow) + '</span>' +
|
|
1904
|
+
(s.at ? ' <span class="rl-faint">' + escapeXml(s.at) + '</span>' : '') + '</span>' +
|
|
1905
|
+
'<span class="rl-l2">' + escapeXml([s.in, s.words].filter(function(x){ return x; }).join(" · ")) + '</span>';
|
|
1906
|
+
if(typeof s.runId !== "string" || s.runId === "") return '<div class="rl-card" data-testid="rl-sched-' + escapeXml(s.flow) + '">' + body + '</div>';
|
|
1907
|
+
return '<button class="rl-card" type="button" data-rl-jump="' + escapeXml(s.flow + "|" + s.runId) + '" data-testid="rl-sched-' + escapeXml(s.flow) + '">' + body + '</button>';
|
|
1908
|
+
}
|
|
1909
|
+
function rlTopHtml(m){
|
|
1910
|
+
var h = "";
|
|
1911
|
+
if(m.running.length) h += rlSectHtml("Running now", m.running.length) + m.running.map(function(r){ return rlJumpCardHtml(r, false); }).join("");
|
|
1912
|
+
if(m.needs.length) h += rlSectHtml("Needs you", m.needs.length) + m.needs.map(function(r){ return rlJumpCardHtml(r, true); }).join("");
|
|
1913
|
+
if(m.scheduled.length) h += rlSectHtml("Scheduled", m.scheduled.length) + m.scheduled.map(rlScheduledCardHtml).join("");
|
|
1914
|
+
return h;
|
|
1915
|
+
}
|
|
1916
|
+
// a run card inside a job: `[sign] run-N date · model` / `word — why · $cost · wall`
|
|
1917
|
+
function rlRunCardHtml(r, selected){
|
|
1918
|
+
var why = (r.word === "passed" && r.glyph === "[✓]" && !r.line) ? "goal met" : r.line;
|
|
1919
|
+
var bits = [runSpendText(r), runWallText(r)].filter(function(b){ return b !== null && b !== undefined; });
|
|
1920
|
+
return '<button class="rl-card' + (selected ? ' rl-sel' : '') + (r.live ? ' rl-live' : '') + '" type="button" data-rl-run="' + escapeXml(r.flow + "|" + r.runId) + '" data-testid="rl-run-' + escapeXml(r.flow) + '-' + escapeXml(r.runId) + '" aria-pressed="' + (selected ? 'true' : 'false') + '" title="' + escapeXml(r.flow + " (" + r.runId + ")") + '">' +
|
|
1921
|
+
'<span class="rl-l1"><span class="' + dotClass(r.glyph, r.pulse) + '"></span><span class="rl-rn">' + escapeXml(r.runId) + '</span> <span class="rl-faint">' + escapeXml([runAtText(r), r.model].filter(function(b){ return b; }).join(" · ")) + '</span></span>' +
|
|
1922
|
+
'<span class="rl-l2">' + signHtml(r.word, why, r.label) + ' · ' + escapeXml(bits.join(" · ")) + '</span></button>';
|
|
1923
|
+
}
|
|
1924
|
+
// a job card: `[sign] job k runs` / `word · why` of its newest run, highlighted when the selected run is one of its runs; not clickable. Inside: the newest run's card, then the older-runs fold.
|
|
1925
|
+
function rlJobCardHtml(c){
|
|
1926
|
+
var h = c.head;
|
|
1927
|
+
var top = '<div class="rl-card' + (c.selected ? ' rl-sel' : '') + '" id="rl-job-' + escapeXml(c.flow) + '" data-testid="rl-job-' + escapeXml(c.flow) + '">';
|
|
1928
|
+
if(c.empty){
|
|
1929
|
+
return top + '<span class="rl-l1"><span class="dot grey"></span><span class="rl-nm" title="' + escapeXml(c.flow) + '">' + escapeXml(c.flow) + '</span></span><span class="rl-l2">' + escapeXml(h.why || "no runs yet") + '</span></div>';
|
|
1930
|
+
}
|
|
1931
|
+
var why = (h.word === "passed" && h.glyph === "[✓]" && !h.line) ? "goal met" : h.line;
|
|
1932
|
+
var isSel = function(r){ return c.sel.flow === c.flow && r.runId === c.sel.runId; };
|
|
1933
|
+
var out = top + '<span class="rl-l1"><span class="' + dotClass(h.glyph, h.pulse) + '"></span><span class="rl-nm" title="' + escapeXml(c.flow) + '">' + escapeXml(c.flow) + '</span> <span class="rl-cnt">· ' + c.count + ' run' + (c.count === 1 ? '' : 's') + '</span></span>' +
|
|
1934
|
+
'<span class="rl-l2">' + signHtml(h.word, why, h.label, " · ") + '</span>' +
|
|
1935
|
+
'<div class="rl-runs">' + rlRunCardHtml(h, isSel(h));
|
|
1936
|
+
if(c.older.total > 0){
|
|
1937
|
+
out += '<button class="rl-fold" type="button" data-rl-fold="' + escapeXml(c.flow) + '" data-testid="rl-fold-' + escapeXml(c.flow) + '" aria-expanded="' + (c.older.open ? 'true' : 'false') + '">' + (c.older.open ? '▾' : '▸') + ' older runs (' + c.older.total + ')</button>';
|
|
1938
|
+
if(c.older.open){
|
|
1939
|
+
out += c.older.shown.map(function(r){ return rlRunCardHtml(r, isSel(r)); }).join("");
|
|
1940
|
+
if(c.older.hidden > 0) out += '<div class="rl-hint">(and ' + c.older.hidden + ' older: use search)</div>';
|
|
1941
|
+
}
|
|
1942
|
+
}
|
|
1943
|
+
return out + '</div></div>';
|
|
1899
1944
|
}
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
if(
|
|
1908
|
-
|
|
1909
|
-
return found ? currentRunId : null;
|
|
1945
|
+
function rlJobsHtml(m){
|
|
1946
|
+
var h = "";
|
|
1947
|
+
if(m.jobs.length) h += rlSectHtml("Jobs", m.jobs.length, "· run in the last " + m.limits.quietDays + " days") + m.jobs.map(rlJobCardHtml).join("");
|
|
1948
|
+
if(m.quiet.length){
|
|
1949
|
+
h += '<button class="rl-fold" type="button" data-rl-fold="__quiet" data-testid="rl-fold-quiet" aria-expanded="' + (m.quietOpen ? 'true' : 'false') + '">' + (m.quietOpen ? '▾' : '▸') + ' quiet jobs (' + m.quiet.length + ') · no run in ' + m.limits.quietDays + ' days</button>';
|
|
1950
|
+
if(m.quietOpen) h += m.quiet.map(rlJobCardHtml).join("");
|
|
1951
|
+
}
|
|
1952
|
+
if(h === "" && m.noRows) h = '<div class="hint">no runs listed yet — no flow under this root has been run</div>';
|
|
1953
|
+
return h;
|
|
1910
1954
|
}
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
var wfExpanded = {};
|
|
1918
|
-
|
|
1919
|
-
// am41 item 5: a job card shows its latest 7 sub-cards (`runs` is newest first); the rest are reached by search.
|
|
1920
|
-
function capChildRuns(runs){
|
|
1921
|
-
return {shown: runs.slice(0, 7), hidden: Math.max(0, runs.length - 7)};
|
|
1955
|
+
// Running now / Needs you: "time so far" counts up IN PLACE from the run's start time (no rebuild): the page's 2 s tick calls this.
|
|
1956
|
+
function tickSince(){
|
|
1957
|
+
document.querySelectorAll("[data-rl-since]").forEach(function(el){
|
|
1958
|
+
var t = Date.parse(el.getAttribute("data-rl-since"));
|
|
1959
|
+
el.textContent = isNaN(t) ? "time unknown" : duration(Math.max(0, Date.now() - t));
|
|
1960
|
+
});
|
|
1922
1961
|
}
|
|
1923
|
-
|
|
1924
|
-
function
|
|
1925
|
-
var
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1962
|
+
// The ONE painter of the list. Called by the filter bar (a poll, a chip, the search box) and by every click here; it writes a box only when its markup changed.
|
|
1963
|
+
function paintRunsList(){
|
|
1964
|
+
var filters = currentRunsFilters();
|
|
1965
|
+
var groups = filterWorkflows(groupRunsByFlow(rlData.rows), filters, Date.now());
|
|
1966
|
+
var m = rlModel(rlData, groups, filters, rlData.limits, { flow: currentFlow, runId: currentRunId }, rlOpen);
|
|
1967
|
+
var topEl = document.getElementById("rl-top");
|
|
1968
|
+
var listEl = document.getElementById("wf-list");
|
|
1969
|
+
var top = rlTopHtml(m);
|
|
1970
|
+
var jobs = rlJobsHtml(m);
|
|
1971
|
+
if(top !== rlLast.top){ rlLast.top = top; withFocusPreserved(topEl, function(){ topEl.innerHTML = top; }); }
|
|
1972
|
+
if(jobs !== rlLast.jobs){ rlLast.jobs = jobs; withFocusPreserved(listEl, function(){ listEl.innerHTML = jobs; }); }
|
|
1973
|
+
tickSince();
|
|
1974
|
+
}
|
|
1975
|
+
// Running now / Needs you / Scheduled click: select that run, show it on the Run tab and scroll its job card into view. (A run card inside a job is the old click, `openRunFromRuns`.)
|
|
1976
|
+
function rlJump(flow, runId){
|
|
1977
|
+
selectRun(flow, runId, null, ".inbox-row");
|
|
1978
|
+
document.getElementById("tab-run").click();
|
|
1979
|
+
paintRunsList();
|
|
1980
|
+
var card = document.getElementById("rl-job-" + flow);
|
|
1981
|
+
if(card && card.scrollIntoView) card.scrollIntoView({ block: "nearest" });
|
|
1982
|
+
}
|
|
1983
|
+
function rlRowOf(key){
|
|
1984
|
+
var p = String(key).split("|");
|
|
1985
|
+
return rlData.rows.find(function(r){ return r.flow === p[0] && r.runId === p[1]; }) || null;
|
|
1986
|
+
}
|
|
1987
|
+
// one delegated click handler for the whole list: a fold, a jump card or a run card
|
|
1988
|
+
function rlClick(ev){
|
|
1989
|
+
var t = ev.target && ev.target.closest ? ev.target : null;
|
|
1990
|
+
if(!t) return;
|
|
1991
|
+
var fold = t.closest("[data-rl-fold]");
|
|
1992
|
+
if(fold){
|
|
1993
|
+
rlOpen[fold.getAttribute("data-rl-fold")] = fold.getAttribute("aria-expanded") !== "true";
|
|
1994
|
+
paintRunsList();
|
|
1929
1995
|
return;
|
|
1930
1996
|
}
|
|
1931
|
-
var
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
var expanded = hasOtherRuns && (Object.prototype.hasOwnProperty.call(wfExpanded, g.flow) ? wfExpanded[g.flow] : autoExpand);
|
|
1944
|
-
var targetRunId = representedRun(g, candidateRuns, active);
|
|
1945
|
-
|
|
1946
|
-
var wrap = document.createElement("div");
|
|
1947
|
-
wrap.className = "wf-job";
|
|
1948
|
-
|
|
1949
|
-
var row = document.createElement("div");
|
|
1950
|
-
// a flow (parent) row also opens its latest run in the Run tab, same
|
|
1951
|
-
// as a child row — computed HERE, at render time (this function tears
|
|
1952
|
-
// down and rebuilds every row on every click).
|
|
1953
|
-
var isSelected = currentFlow === g.flow && currentRunId === targetRunId;
|
|
1954
|
-
row.className = "wf-row" + (isSelected ? " selected" : "");
|
|
1955
|
-
row.setAttribute("data-wf", g.flow);
|
|
1956
|
-
row.setAttribute("data-testid", "wf-row-" + g.flow);
|
|
1957
|
-
row.setAttribute("tabindex", "0");
|
|
1958
|
-
row.setAttribute("role", "button");
|
|
1959
|
-
row.setAttribute("aria-expanded", expanded ? "true" : "false");
|
|
1960
|
-
row.setAttribute("aria-pressed", isSelected ? "true" : "false");
|
|
1961
|
-
var wfFullName = g.flow + ' (' + g.lastRunId + ')';
|
|
1962
|
-
row.innerHTML =
|
|
1963
|
-
'<span class="wf-line1"><span class="wf-caret">' + (hasOtherRuns ? (expanded ? "▼" : "▶") : "") + '</span><span class="' + dotClass(g.lastGlyph, g.lastRow.pulse) + '"></span>' +
|
|
1964
|
-
'<span class="wf-name" title="' + escapeXml(wfFullName) + '">' + escapeXml(wfFullName) + '</span></span>' +
|
|
1965
|
-
'<span class="wf-sign-line" data-testid="run-sign-word">' + signHtml(g.lastRow.word, g.lastRow.line, g.lastLabel) + '</span>' +
|
|
1966
|
-
runMetaLineHtml(g.lastRow, g.runCount + ' run' + (g.runCount === 1 ? '' : 's'));
|
|
1967
|
-
row.addEventListener("click", function(){
|
|
1968
|
-
// a single-run flow has nothing to expand — the click still opens
|
|
1969
|
-
// the run, it just never toggles `wfExpanded` for it.
|
|
1970
|
-
if(hasOtherRuns) wfExpanded[g.flow] = !expanded;
|
|
1971
|
-
openRunFromRuns(g.runs.filter(function(x){ return x.runId === targetRunId; })[0] || g.lastRow, null);
|
|
1972
|
-
renderWorkflows(flows);
|
|
1973
|
-
});
|
|
1974
|
-
row.addEventListener("keydown", function(e){ if(e.key === "Enter" || e.key === " "){ e.preventDefault(); row.click(); } });
|
|
1975
|
-
wrap.appendChild(row);
|
|
1976
|
-
|
|
1977
|
-
if(expanded){
|
|
1978
|
-
var runsWrap = document.createElement("div");
|
|
1979
|
-
runsWrap.className = "wf-runs";
|
|
1980
|
-
var capped = capChildRuns(childRuns);
|
|
1981
|
-
capped.shown.forEach(function(r){ runsWrap.appendChild(buildRunRowEl(r, { sub: true })); });
|
|
1982
|
-
if(capped.hidden > 0) runsWrap.appendChild(textDiv("hint wf-older", "older runs: use search"));
|
|
1983
|
-
wrap.appendChild(runsWrap);
|
|
1984
|
-
}
|
|
1985
|
-
el.appendChild(wrap);
|
|
1986
|
-
});
|
|
1997
|
+
var jump = t.closest("[data-rl-jump]");
|
|
1998
|
+
if(jump){
|
|
1999
|
+
var j = String(jump.getAttribute("data-rl-jump")).split("|");
|
|
2000
|
+
rlJump(j[0], j[1]);
|
|
2001
|
+
return;
|
|
2002
|
+
}
|
|
2003
|
+
var card = t.closest("[data-rl-run]");
|
|
2004
|
+
var row = card ? rlRowOf(card.getAttribute("data-rl-run")) : null;
|
|
2005
|
+
if(row){
|
|
2006
|
+
openRunFromRuns(row, null);
|
|
2007
|
+
paintRunsList();
|
|
2008
|
+
}
|
|
1987
2009
|
}
|
|
2010
|
+
document.getElementById("panel-runs").addEventListener("click", rlClick);
|
|
1988
2011
|
|
|
1989
2012
|
// ---- Filter bar — ONE component, ONE state shape ({results, time,
|
|
1990
|
-
// search}), used by
|
|
1991
|
-
// the Workflows tab (filters by each flow's OWN latest-run fields).
|
|
2013
|
+
// search}), used by the one runs list (a job stays when ANY of its runs match).
|
|
1992
2014
|
// bareloop's checkType (deterministic/rubric) chips are dropped — fwdloop
|
|
1993
2015
|
// has no such concept; the result chips use fwdloop's own glyph
|
|
1994
2016
|
// vocabulary ([✓]/[✗]/[·]/[▶]/[?] — `[▶]` running is known from M4c's pid
|
|
1995
2017
|
// rows, src/liveness.js).
|
|
1996
|
-
|
|
2018
|
+
// `noSigns`: M11 am3 item 4 — the Inbox has no sign chips; M11 am4 item 4 — it has the status chips instead (accepted / redo / rerun / expired, the
|
|
2019
|
+
// row status the server sends; the rerun chip is the status `reran`), picked into the same `results` list.
|
|
2020
|
+
// The ONE map of an Inbox row's status to the word on its chip (`reran` reads "rerun"); the Inbox search matches the chip word too.
|
|
2021
|
+
var INBOX_CHIP_WORD = { accepted: "accepted", redo: "redo", reran: "rerun", expired: "expired" };
|
|
2022
|
+
function filterBarHTML(scope, noSigns){
|
|
1997
2023
|
return (
|
|
1998
2024
|
'<div class="filterbar" data-scope="' + scope + '" data-testid="' + scope + '-filters">' +
|
|
1999
|
-
'<input type="text" class="search-input" placeholder="search flow or run id…" ' +
|
|
2025
|
+
'<input type="text" class="search-input" placeholder="' + (noSigns ? 'search job, run, status, question or reason…' : 'search flow or run id…') + '" ' +
|
|
2000
2026
|
'id="' + scope + '-filter-search" data-testid="' + scope + '-filter-search" autocomplete="off">' +
|
|
2001
2027
|
'<div class="chips" role="group" aria-label="Filter">' +
|
|
2028
|
+
(noSigns ?
|
|
2029
|
+
Object.keys(INBOX_CHIP_WORD).map(function(st){
|
|
2030
|
+
var w = INBOX_CHIP_WORD[st];
|
|
2031
|
+
return '<button class="chip fchip" type="button" aria-pressed="false" data-filter-group="result" data-filter-value="' + st + '" title="' + w + '" data-testid="chip-' + scope + '-st-' + w + '">' + w + '</button>';
|
|
2032
|
+
}).join('') :
|
|
2002
2033
|
'<button class="chip fchip" type="button" aria-pressed="false" data-filter-group="result" data-filter-value="[✓]" title="passed" data-testid="chip-' + scope + '-res-pass">✓</button>' +
|
|
2003
2034
|
'<button class="chip fchip" type="button" aria-pressed="false" data-filter-group="result" data-filter-value="[✗]" title="stopped" data-testid="chip-' + scope + '-res-fail">✗</button>' +
|
|
2004
2035
|
'<button class="chip fchip" type="button" aria-pressed="false" data-filter-group="result" data-filter-value="[■]" title="stopped, can be resumed" data-testid="chip-' + scope + '-res-stopped">■</button>' +
|
|
2005
2036
|
'<button class="chip fchip" type="button" aria-pressed="false" data-filter-group="result" data-filter-value="[·]" title="waiting on a human" data-testid="chip-' + scope + '-res-waiting">·</button>' +
|
|
2006
2037
|
'<button class="chip fchip" type="button" aria-pressed="false" data-filter-group="result" data-filter-value="[▶]" title="running" data-testid="chip-' + scope + '-res-running">▶</button>' +
|
|
2007
|
-
'<button class="chip fchip" type="button" aria-pressed="false" data-filter-group="result" data-filter-value="[?]" title="died or unknown" data-testid="chip-' + scope + '-res-unknown">?</button>' +
|
|
2038
|
+
'<button class="chip fchip" type="button" aria-pressed="false" data-filter-group="result" data-filter-value="[?]" title="died or unknown" data-testid="chip-' + scope + '-res-unknown">?</button>') +
|
|
2008
2039
|
'<button class="chip fchip" type="button" aria-pressed="false" data-filter-group="time" data-filter-value="7d" title="last 7 days" data-testid="chip-' + scope + '-time-7d">7d</button>' +
|
|
2009
2040
|
'<button class="chip fchip" type="button" aria-pressed="false" data-filter-group="time" data-filter-value="30d" title="last 30 days" data-testid="chip-' + scope + '-time-30d">30d</button>' +
|
|
2010
2041
|
'<button class="chip fchip" type="button" aria-pressed="true" data-filter-group="time" data-filter-value="all" title="all time" data-testid="chip-' + scope + '-time-all">all</button>' +
|
|
@@ -2052,7 +2083,7 @@
|
|
|
2052
2083
|
* One filter-bar instance: its own localStorage key, its own DOM scope
|
|
2053
2084
|
* (`.filterbar[data-scope="..."]`), its own item list — but the same
|
|
2054
2085
|
* wiring as every other instance.
|
|
2055
|
-
* @param {{scope:string, storageKey:string, filterFn:Function, applyFn:Function}} opts
|
|
2086
|
+
* @param {{scope:string, storageKey:string, noun?:string, filterFn:Function, applyFn:Function}} opts
|
|
2056
2087
|
*/
|
|
2057
2088
|
function createFilterBar(opts){
|
|
2058
2089
|
var scope = opts.scope;
|
|
@@ -2092,7 +2123,7 @@
|
|
|
2092
2123
|
var filtered = opts.filterFn(allItems, state, Date.now());
|
|
2093
2124
|
opts.applyFn(filtered);
|
|
2094
2125
|
var countEl = document.getElementById(scope + "-filter-count");
|
|
2095
|
-
if(countEl) countEl.textContent = "showing " + filtered.length + " of " + allItems.length + " runs";
|
|
2126
|
+
if(countEl) countEl.textContent = "showing " + filtered.length + " of " + allItems.length + " " + (opts.noun || "runs");
|
|
2096
2127
|
}
|
|
2097
2128
|
document.querySelectorAll('.filterbar[data-scope="' + scope + '"] .chip[data-filter-group]').forEach(function(chip){
|
|
2098
2129
|
chip.addEventListener("click", function(){
|
|
@@ -2136,33 +2167,14 @@
|
|
|
2136
2167
|
};
|
|
2137
2168
|
}
|
|
2138
2169
|
|
|
2139
|
-
//
|
|
2140
|
-
// posture as every other localStorage read/write on this page.
|
|
2141
|
-
var RUNS_VIEW_KEY = "fwdloop-panel-runs-view";
|
|
2142
|
-
function loadRunsViewMode(){
|
|
2143
|
-
try{
|
|
2144
|
-
var v = localStorage.getItem(RUNS_VIEW_KEY);
|
|
2145
|
-
if(v === "workflows" || v === "history") return v;
|
|
2146
|
-
}catch(e){ /* per-viewer convenience only */ }
|
|
2147
|
-
return "workflows";
|
|
2148
|
-
}
|
|
2149
|
-
function saveRunsViewMode(v){
|
|
2150
|
-
try{ localStorage.setItem(RUNS_VIEW_KEY, v); }catch(e){ /* best-effort only */ }
|
|
2151
|
-
}
|
|
2152
|
-
|
|
2153
|
-
// ONE shared filter bar drives whichever view (Workflows/History) is
|
|
2154
|
-
// currently on — one scope, one localStorage key, so switching views
|
|
2155
|
-
// never loses the search/chip state.
|
|
2170
|
+
// ONE filter bar, mounted between the unfiltered sections and Jobs (M11). It acts on Jobs and quiet jobs only: `runsFilterFn` keeps a job when ANY of its runs match.
|
|
2156
2171
|
document.getElementById("runs-filterbar-anchor").innerHTML = filterBarHTML("runs");
|
|
2157
2172
|
|
|
2158
|
-
var runsViewMode = loadRunsViewMode();
|
|
2159
2173
|
function runsFilterFn(items, filters, nowMs){
|
|
2160
|
-
if(runsViewMode === "history") return filterRuns(items, filters, nowMs);
|
|
2161
2174
|
return filterWorkflows(groupRunsByFlow(items), filters, nowMs);
|
|
2162
2175
|
}
|
|
2163
|
-
function runsApplyFn(
|
|
2164
|
-
|
|
2165
|
-
else renderWorkflows(filtered);
|
|
2176
|
+
function runsApplyFn(){
|
|
2177
|
+
paintRunsList();
|
|
2166
2178
|
}
|
|
2167
2179
|
var runsFilterBar = createFilterBar({
|
|
2168
2180
|
scope: "runs",
|
|
@@ -2173,24 +2185,6 @@
|
|
|
2173
2185
|
function currentRunsFilters(){
|
|
2174
2186
|
return runsFilterBar ? runsFilterBar.getState() : { results: [], time: "all", search: "" };
|
|
2175
2187
|
}
|
|
2176
|
-
function paintRunsViewToggle(){
|
|
2177
|
-
document.querySelectorAll('.chip[data-runs-view]').forEach(function(c){
|
|
2178
|
-
c.setAttribute("aria-pressed", c.getAttribute("data-runs-view") === runsViewMode ? "true" : "false");
|
|
2179
|
-
});
|
|
2180
|
-
document.getElementById("wf-list").hidden = runsViewMode !== "workflows";
|
|
2181
|
-
document.getElementById("history-list").hidden = runsViewMode !== "history";
|
|
2182
|
-
}
|
|
2183
|
-
document.querySelectorAll('.chip[data-runs-view]').forEach(function(chip){
|
|
2184
|
-
chip.addEventListener("click", function(){
|
|
2185
|
-
var next = chip.getAttribute("data-runs-view");
|
|
2186
|
-
if(next === runsViewMode) return;
|
|
2187
|
-
runsViewMode = next;
|
|
2188
|
-
saveRunsViewMode(runsViewMode);
|
|
2189
|
-
paintRunsViewToggle();
|
|
2190
|
-
runsFilterBar.refresh();
|
|
2191
|
-
});
|
|
2192
|
-
});
|
|
2193
|
-
paintRunsViewToggle();
|
|
2194
2188
|
|
|
2195
2189
|
// item 4: phone-only "scroll the run view into view" on row select, and
|
|
2196
2190
|
// the matching "↑ list" jump back. Desktop never runs either — both panes
|
|
@@ -2213,7 +2207,7 @@
|
|
|
2213
2207
|
}
|
|
2214
2208
|
|
|
2215
2209
|
function clearSelection(selector){
|
|
2216
|
-
document.querySelectorAll(".
|
|
2210
|
+
document.querySelectorAll(".inbox-row").forEach(function(r){ r.classList.remove("selected"); r.setAttribute("aria-pressed","false"); });
|
|
2217
2211
|
}
|
|
2218
2212
|
|
|
2219
2213
|
// ---- Run tab: header + summary + step map + one card per step ATTEMPT
|
|
@@ -2358,7 +2352,10 @@
|
|
|
2358
2352
|
// amendment 7 item 6: Run again sits first, with Stop and Resume — every run control in this one row
|
|
2359
2353
|
el.appendChild(makeButton("Run again", "run-again", function(){ if(window.fwdloopRunAgain) window.fwdloopRunAgain(detail); }));
|
|
2360
2354
|
// M9 am5 item 3: a scheduled job's Run tab offers the schedule's own door, next to Run again: the same route, the Run card showing When
|
|
2361
|
-
|
|
2355
|
+
// M11 am3 item 1: a job with a green run and no schedule reads Schedule run (the server's `canSchedule`); the same door either way
|
|
2356
|
+
var schedDoor = function(){ if(window.fwdloopRunAgain) window.fwdloopRunAgain(detail); };
|
|
2357
|
+
if(detail.summary && detail.summary.scheduled) el.appendChild(makeButton("Cancel / modify schedule", "run-cancel-schedule", schedDoor));
|
|
2358
|
+
else if(detail.summary && detail.summary.canSchedule) el.appendChild(makeButton("Schedule run", "run-schedule", schedDoor));
|
|
2362
2359
|
if(stopSay && stopSay.key !== detail.flow + "/" + detail.runId) stopSay = null;
|
|
2363
2360
|
if(c.canStop){
|
|
2364
2361
|
var stopBtn = makeButton(c.stopRequested ? "stopping after this step\u2026" : "Stop", "run-stop", function(){
|
|
@@ -3153,7 +3150,7 @@
|
|
|
3153
3150
|
// ---- The ONE refresh loop (M4b piece 4, widened by the M4c exit walk). The page used to load
|
|
3154
3151
|
// once, so a run that parked after load kept `[▶]`, Inbox stayed (0) and the run header kept its
|
|
3155
3152
|
// first words. Now `pageTick` runs every LIVE_POLL_MS for the whole life of the page: it re-reads
|
|
3156
|
-
// the Runs list,
|
|
3153
|
+
// the Runs list, the Inbox list + (N), and the selected run's detail, asks and
|
|
3157
3154
|
// audit — all through the SAME render functions, so the same guards hold (`holdAskRender` never
|
|
3158
3155
|
// redraws over a typed reason; a refusal lives in `answerMsg` and is repainted). `startLive` no
|
|
3159
3156
|
// longer owns a timer: it only names the answer being watched, and the tick judges it from the
|
|
@@ -3183,11 +3180,11 @@
|
|
|
3183
3180
|
lastListsAt = Date.now();
|
|
3184
3181
|
getJSON("/api/inbox").then(function(r){ renderInbox(r.rows || [], r.openCount); paintUpdateBar(r.version); }).catch(function(){});
|
|
3185
3182
|
getJSON("/api/runs").then(function(r){
|
|
3186
|
-
var
|
|
3187
|
-
var next = sig(rows);
|
|
3183
|
+
var next = sig(r);
|
|
3188
3184
|
if(next !== null && next === lastSig.runs) return;
|
|
3189
3185
|
lastSig.runs = next;
|
|
3190
|
-
|
|
3186
|
+
setRunsData(r);
|
|
3187
|
+
withScrollPreserved(["left-pane-body"], function(){ runsFilterBar.setItems(rlData.rows); runsFilterBar.refresh(); });
|
|
3191
3188
|
}).catch(function(){});
|
|
3192
3189
|
}
|
|
3193
3190
|
// The ONE way the Ask tab is drawn from the books: the Ask tab is drawn from the books AND the page's own pending answer ("working…" block).
|
|
@@ -3225,6 +3222,7 @@
|
|
|
3225
3222
|
var catchUp = wasHidden; // first tick after the tab came back: force both
|
|
3226
3223
|
wasHidden = false;
|
|
3227
3224
|
tickLeft();
|
|
3225
|
+
tickSince();
|
|
3228
3226
|
var watch = live;
|
|
3229
3227
|
var sel = currentFlow !== null && currentRunId !== null;
|
|
3230
3228
|
var watchIsSelected = watch && sel && watch.flow === currentFlow && watch.runId === currentRunId;
|
|
@@ -3296,12 +3294,13 @@
|
|
|
3296
3294
|
});
|
|
3297
3295
|
|
|
3298
3296
|
getJSON("/api/runs").then(function(result){
|
|
3299
|
-
|
|
3297
|
+
setRunsData(result);
|
|
3298
|
+
var runs = rlData.rows;
|
|
3300
3299
|
runsFilterBar.setItems(runs);
|
|
3301
3300
|
var first = runs.find(function(r){ return r.runId !== null; });
|
|
3302
3301
|
if(first){
|
|
3303
3302
|
// the LEFT side is not switched here: a load or refresh always opens on the Chat tab (hamr 2026-10-06)
|
|
3304
|
-
// newest run overall, opened directly — the
|
|
3303
|
+
// newest run overall, opened directly — the job's older runs start
|
|
3305
3304
|
// collapsed, but its flow row still renders "selected" since
|
|
3306
3305
|
// `runsFilterBar.refresh()` re-renders AFTER currentFlow/currentRunId
|
|
3307
3306
|
// are set.
|
|
@@ -3311,7 +3310,6 @@
|
|
|
3311
3310
|
}
|
|
3312
3311
|
}).catch(function(e){
|
|
3313
3312
|
document.getElementById("wf-list").innerHTML = '<div class="hint">' + escapeXml(loadFailureText(e)) + '</div>';
|
|
3314
|
-
document.getElementById("history-list").innerHTML = '<div class="hint">' + escapeXml(loadFailureText(e)) + '</div>';
|
|
3315
3313
|
});
|
|
3316
3314
|
|
|
3317
3315
|
// ---- shared text-node helper — book text (question/draft/artifact
|
|
@@ -3398,28 +3396,72 @@
|
|
|
3398
3396
|
return wrap;
|
|
3399
3397
|
}
|
|
3400
3398
|
var INBOX_HEADS = { 1: "waiting on you", 2: "working on your answer", 3: "answered and expired" };
|
|
3399
|
+
// M11 am3 item 3: every Inbox header carries its count, counted off the rows the server sent (after the filters, for section 3)
|
|
3400
|
+
function inboxHeadText(section, n){ return (INBOX_HEADS[section] || "") + " (" + n + ")"; }
|
|
3401
|
+
// M11 am3 item 4: the Inbox filters act on "answered and expired" (section 3) only; sections 1 and 2 are never hidden. M11 am4 item 4: the status chips
|
|
3402
|
+
// (`results`, none = all) match the row's `status`.
|
|
3403
|
+
// A row's time is its answer, else its expiry (the server orders section 3 by the same two). No date + a time chip = out, as in Runs.
|
|
3404
|
+
// M11 am4 item 3: the Inbox search reads the whole row — job, run, status word, question, answer reason — case-insensitive. (`matchesSearch` stays Runs': job and run only.)
|
|
3405
|
+
function inboxMatchesSearch(r, query){
|
|
3406
|
+
var q = String(query || "").trim().toLowerCase();
|
|
3407
|
+
if(!q) return true;
|
|
3408
|
+
return [r.flow, r.runId, r.status, INBOX_CHIP_WORD[r.status], r.question, r.reason].some(function(x){ return typeof x === "string" && x.toLowerCase().indexOf(q) !== -1; });
|
|
3409
|
+
}
|
|
3410
|
+
function inboxFilterRows(rows, filters, nowMs){
|
|
3411
|
+
var time = (filters && filters.time) || "all";
|
|
3412
|
+
var q = (filters && filters.search) || "";
|
|
3413
|
+
var rs = (filters && filters.results) || [];
|
|
3414
|
+
return (rows || []).filter(function(r){
|
|
3415
|
+
if(r.section !== 3) return true;
|
|
3416
|
+
if(rs.length && rs.indexOf(r.status) === -1) return false;
|
|
3417
|
+
if(!inboxMatchesSearch(r, q)) return false;
|
|
3418
|
+
if(time !== "all"){
|
|
3419
|
+
var days = time === "7d" ? 7 : 30;
|
|
3420
|
+
var t = Date.parse(r.answeredAt || r.expiresAt);
|
|
3421
|
+
if(!isFinite(t) || nowMs - t > days * 24 * 60 * 60 * 1000) return false;
|
|
3422
|
+
}
|
|
3423
|
+
return true;
|
|
3424
|
+
});
|
|
3425
|
+
}
|
|
3426
|
+
document.getElementById("inbox-filterbar-anchor").innerHTML = filterBarHTML("inbox", true);
|
|
3427
|
+
var inboxOpenN = 0, inboxTotal = 0;
|
|
3428
|
+
var inboxBar = createFilterBar({
|
|
3429
|
+
scope: "inbox",
|
|
3430
|
+
storageKey: "fwdloop-panel-inbox-filters",
|
|
3431
|
+
noun: "asks",
|
|
3432
|
+
filterFn: inboxFilterRows,
|
|
3433
|
+
applyFn: function(shown){ buildInbox(document.getElementById("inbox-list"), shown, inboxOpenN); },
|
|
3434
|
+
});
|
|
3401
3435
|
// N comes from the server (data.js inboxOpenCount); the page only shows it.
|
|
3402
3436
|
function renderInbox(rows, openCount){
|
|
3403
3437
|
var el = document.getElementById("inbox-list");
|
|
3404
3438
|
var next = sig({ rows: rows, openCount: openCount });
|
|
3405
3439
|
if(next !== null && next === lastSig.inbox) return; // unchanged payload — never rebuild the DOM for nothing
|
|
3406
3440
|
lastSig.inbox = next;
|
|
3407
|
-
|
|
3441
|
+
inboxOpenN = openCount;
|
|
3442
|
+
inboxTotal = rows ? rows.length : 0;
|
|
3443
|
+
var old = document.getElementById("inbox-list-old");
|
|
3444
|
+
withScrollPreserved(["left-pane-body"], function(){ withFocusPreserved(old, function(){ withFocusPreserved(el, function(){ inboxBar.setItems(rows); }); }); });
|
|
3408
3445
|
}
|
|
3409
3446
|
function buildInbox(el, rows, openCount){
|
|
3447
|
+
var old = document.getElementById("inbox-list-old");
|
|
3410
3448
|
el.innerHTML = "";
|
|
3449
|
+
old.innerHTML = "";
|
|
3411
3450
|
document.getElementById("inbox-count-label").textContent = " (" + (typeof openCount === "number" ? openCount : 0) + ")";
|
|
3412
|
-
if(!
|
|
3451
|
+
if(!inboxTotal){
|
|
3413
3452
|
el.innerHTML = '<div class="hint">nothing waiting on you — no stops recorded under this root</div>';
|
|
3414
3453
|
return;
|
|
3415
3454
|
}
|
|
3455
|
+
var counts = {};
|
|
3456
|
+
rows.forEach(function(row){ counts[row.section] = (counts[row.section] || 0) + 1; });
|
|
3416
3457
|
var lastSection = 0;
|
|
3417
3458
|
rows.forEach(function(row){
|
|
3459
|
+
var into = row.section === 3 ? old : el;
|
|
3418
3460
|
if(row.section !== lastSection){
|
|
3419
3461
|
lastSection = row.section;
|
|
3420
|
-
|
|
3462
|
+
into.appendChild(textDiv("inbox-h", inboxHeadText(row.section, counts[row.section])));
|
|
3421
3463
|
}
|
|
3422
|
-
|
|
3464
|
+
into.appendChild(renderStopRow(row));
|
|
3423
3465
|
});
|
|
3424
3466
|
}
|
|
3425
3467
|
getJSON("/api/inbox").then(function(result){ renderInbox(result.rows || [], result.openCount); }).catch(function(e){
|