fwdloop 0.18.0 → 0.19.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.
- package/package.json +1 -1
- package/src/panel/data.js +93 -9
- package/src/panel/index.html +304 -262
- package/src/panel/server.js +10 -2
- package/src/summary-words.js +21 -0
- package/types/panel/data.d.ts +58 -3
- package/types/summary-words.d.ts +7 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fwdloop",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"description": "Describe a job as steps and guardrails; an agent builds the workflow, pauses for humans where you said, checks every step happened, and reruns it under budgets it cannot touch.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
package/src/panel/data.js
CHANGED
|
@@ -39,7 +39,7 @@ import { applyRunValues, parseWaitMs, pickRunValues, VALUES_FILE_RE } from '../r
|
|
|
39
39
|
import { readSetup } from '../setup.js';
|
|
40
40
|
import { checkedLines, notCheckedBlock, NOT_CHECKED_LABEL } from '../checked.js';
|
|
41
41
|
import {
|
|
42
|
-
catchUpWords, endedWords, scheduledNextFor, scheduledWords,
|
|
42
|
+
catchUpWords, endedWords, nextInWords, nextTimeWords, scheduledNextFor, scheduledWords,
|
|
43
43
|
} from '../summary-words.js';
|
|
44
44
|
import { MAX_STRUCTURE_RETRIES } from '../drafter.js';
|
|
45
45
|
import {
|
|
@@ -906,7 +906,8 @@ function loadRunContext(root, flowDir, runDir, flowName, runId, catalogue, attem
|
|
|
906
906
|
const stateJson = readRunState(runDir);
|
|
907
907
|
const consumedAnswerExists = hasConsumedAnswer(runDir, askJson && typeof askJson.askId === 'string' ? askJson.askId : null);
|
|
908
908
|
// A finished run has no resume to report (its history row says how it ended).
|
|
909
|
-
const
|
|
909
|
+
const savedAnswer = historyRow ? null : readSavedAnswer(runDir);
|
|
910
|
+
const resume = historyRow ? null : deriveResumeState({ savedAnswer, attempt, ask: askJson });
|
|
910
911
|
const stuckInputs = historyRow ? { liveness: 'unknown', lock: 'none' } : readStuckInputs(runDir);
|
|
911
912
|
|
|
912
913
|
return {
|
|
@@ -934,6 +935,8 @@ function loadRunContext(root, flowDir, runDir, flowName, runId, catalogue, attem
|
|
|
934
935
|
consumedAnswerExists,
|
|
935
936
|
hasStateJson: stateJson !== null,
|
|
936
937
|
resume,
|
|
938
|
+
// M11 am4 item 1: when the saved answer was written (a stuck run has no stop time; its 7 days in Needs you count from here), or null
|
|
939
|
+
savedAnswerAt: savedAnswer ? savedAnswer.answeredAt : null,
|
|
937
940
|
// M4c: only read for a run with no end row (an end row always wins).
|
|
938
941
|
liveness: stuckInputs.liveness,
|
|
939
942
|
lock: stuckInputs.lock,
|
|
@@ -1047,11 +1050,11 @@ export function getRunControls({
|
|
|
1047
1050
|
* null`, an explicit `why`) — no flow is silently missing from the list.
|
|
1048
1051
|
* Ordered by `orderRuns` (waiting on you, running, then newest `at` first; a row
|
|
1049
1052
|
* with no `at` is never given a guessed one).
|
|
1050
|
-
* @param {{root: string, catalogue: any, resumeAttempt?: (flow: string, runId: string) => any, startingRun?: (flow: string, runId: string) => boolean}} opts
|
|
1051
|
-
* `startingRun`: the starter's phase-`starting` rule for one run (absent = no). `resumeAttempt`: the panel's in-memory resume-attempt lookup (M4b piece 2); absent = none.
|
|
1053
|
+
* @param {{root: string, catalogue: any, resumeAttempt?: (flow: string, runId: string) => any, startingRun?: (flow: string, runId: string) => boolean, now?: () => number}} opts
|
|
1054
|
+
* `now`: the clock for Needs you's 7-day rule (absent = Date.now). `startingRun`: the starter's phase-`starting` rule for one run (absent = no). `resumeAttempt`: the panel's in-memory resume-attempt lookup (M4b piece 2); absent = none.
|
|
1052
1055
|
* @returns {any[]}
|
|
1053
1056
|
*/
|
|
1054
|
-
export function listRuns({ root, catalogue, resumeAttempt, startingRun }) {
|
|
1057
|
+
export function listRuns({ root, catalogue, resumeAttempt, startingRun, now = Date.now }) {
|
|
1055
1058
|
const rows = [];
|
|
1056
1059
|
for (const flowName of listFlowNames(root)) {
|
|
1057
1060
|
const flowDir = join(root, flowName);
|
|
@@ -1073,6 +1076,7 @@ export function listRuns({ root, catalogue, resumeAttempt, startingRun }) {
|
|
|
1073
1076
|
}
|
|
1074
1077
|
const ctx = loadRunContext(root, run.flowDir, run.runDir, flowName, runId, catalogue, resumeAttempt?.(flowName, runId) ?? null, startingRun);
|
|
1075
1078
|
const { glyph, label } = computeGlyph(ctx);
|
|
1079
|
+
const controls = runControls(ctx, glyph, label);
|
|
1076
1080
|
// M4c amendment 1 (c): the ask waiting on the human, by the same rule
|
|
1077
1081
|
// listStops uses (deriveAskOpenFields) — the least time left if several.
|
|
1078
1082
|
const waitingAsk = runAsksInOrder(run.runDir, !!ctx.historyRow)
|
|
@@ -1103,7 +1107,10 @@ export function listRuns({ root, catalogue, resumeAttempt, startingRun }) {
|
|
|
1103
1107
|
...signParts(glyph, label, ctx.historyRow?.outcome === 'rerun'),
|
|
1104
1108
|
pulse: glyphPulses({ glyph, label }),
|
|
1105
1109
|
stuck: glyph === '[II]',
|
|
1106
|
-
controls
|
|
1110
|
+
controls,
|
|
1111
|
+
needs: needsYouTag(glyph, controls, glyph === '[II]' ? ctx.savedAnswerAt : (ctx.historyRow ? ctx.historyRow.at : null), now()),
|
|
1112
|
+
live: isRunningNow(ctx, glyph),
|
|
1113
|
+
model: deriveRunModel(ctx.auditRows),
|
|
1107
1114
|
resume: ctx.resume,
|
|
1108
1115
|
spend,
|
|
1109
1116
|
spendWhy: (!ctx.historyRow && spend === null)
|
|
@@ -1163,6 +1170,83 @@ export function orderRuns(rows) {
|
|
|
1163
1170
|
.map(({ row }) => row);
|
|
1164
1171
|
}
|
|
1165
1172
|
|
|
1173
|
+
/**
|
|
1174
|
+
* M11 am1 item 2 + am2: the ONE rule for a run's Needs-you tag, read off the sign and `runControls` (no second rule). `Accept`: waiting at an open ask.
|
|
1175
|
+
* `Resume`: stuck `[II]`, or stopped `[■]` whose Run tab shows the Resume button. An expired ask `[!]` is never here (it stays in the Inbox).
|
|
1176
|
+
* M11 am3 item 5: a Resume run leaves Needs you once its stop time (`at`, the history row's) is `RUNS_LIST_LIMITS.needsYouDays` old; exactly that old is out.
|
|
1177
|
+
* M11 am4 item 1: a stuck `[II]` run has no stop time; the caller passes the time its saved answer was written. A run with no readable time stays in. An Accept run is never dropped by age (its ask has its own wait).
|
|
1178
|
+
* @param {string} glyph a `computeGlyph` sign @param {{atAsk: boolean, canResume: boolean}} controls `runControls`' answer
|
|
1179
|
+
* @param {string|null} [at] the run's stop time from the books @param {number} [nowMs]
|
|
1180
|
+
* @returns {'Accept'|'Resume'|null}
|
|
1181
|
+
*/
|
|
1182
|
+
export function needsYouTag(glyph, controls, at = null, nowMs = Date.now()) {
|
|
1183
|
+
if (glyph === '[·]' && controls.atAsk) return 'Accept';
|
|
1184
|
+
if (glyph !== '[II]' && !(glyph === '[■]' && controls.canResume)) return null;
|
|
1185
|
+
const t = typeof at === 'string' ? Date.parse(at) : NaN;
|
|
1186
|
+
if (Number.isFinite(t) && nowMs - t >= RUNS_LIST_LIMITS.needsYouDays * 86_400_000) return null;
|
|
1187
|
+
return 'Resume';
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1190
|
+
/** M11 scope item 2.5/2.6 and rules, am3 item 5: the named limits of the runs list, in ONE place (30 quiet days, 7 older runs, 7 days in Needs you for a Resume run). The page reads them from `GET /api/runs`. */
|
|
1191
|
+
export const RUNS_LIST_LIMITS = Object.freeze({ quietDays: 30, olderRuns: 7, needsYouDays: 7 });
|
|
1192
|
+
|
|
1193
|
+
/**
|
|
1194
|
+
* M11: one entry per job (flow), newest activity first. A job's activity is its newest KNOWN run time (`at`, else `askedAt`, else `startedAt`);
|
|
1195
|
+
* `quiet` only when that time is known and older than the quiet limit: an unknown age is never guessed into quiet, and a job with no runs is not quiet.
|
|
1196
|
+
* @param {any[]} rows `listRuns` rows @param {number} nowMs
|
|
1197
|
+
* @returns {{flow: string, quiet: boolean, activityMs: number|null}[]}
|
|
1198
|
+
*/
|
|
1199
|
+
export function summarizeJobs(rows, nowMs) {
|
|
1200
|
+
/** @type {Map<string, number|null>} */
|
|
1201
|
+
const byFlow = new Map();
|
|
1202
|
+
for (const r of rows) {
|
|
1203
|
+
if (!byFlow.has(r.flow)) byFlow.set(r.flow, null);
|
|
1204
|
+
if (r.runId === null) continue; // eslint-disable-line no-continue
|
|
1205
|
+
const t = [r.at, r.askedAt, r.startedAt].map((x) => (typeof x === 'string' ? Date.parse(x) : NaN)).find((x) => Number.isFinite(x));
|
|
1206
|
+
if (t !== undefined && (byFlow.get(r.flow) === null || t > /** @type {number} */ (byFlow.get(r.flow)))) byFlow.set(r.flow, t);
|
|
1207
|
+
}
|
|
1208
|
+
const quietMs = RUNS_LIST_LIMITS.quietDays * 86_400_000;
|
|
1209
|
+
return [...byFlow.entries()]
|
|
1210
|
+
.map(([flow, activityMs]) => ({ flow, quiet: activityMs !== null && nowMs - activityMs > quietMs, activityMs }))
|
|
1211
|
+
.sort((a, b) => {
|
|
1212
|
+
if (a.activityMs !== b.activityMs) {
|
|
1213
|
+
if (a.activityMs === null) return 1;
|
|
1214
|
+
if (b.activityMs === null) return -1;
|
|
1215
|
+
return b.activityMs - a.activityMs;
|
|
1216
|
+
}
|
|
1217
|
+
return a.flow < b.flow ? -1 : a.flow > b.flow ? 1 : 0;
|
|
1218
|
+
});
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1221
|
+
/**
|
|
1222
|
+
* M11 am1 item 3: every job with a trigger, soonest next run first (a job with no clock slot — a file trigger, or not armed yet — after those that
|
|
1223
|
+
* have one, by name). Built from the owners the run page's SCHEDULED block uses (`triggerRead`, `scheduledWords`); `at` / `in` are null when
|
|
1224
|
+
* there is no next time (nothing is invented). A job that cannot be read, or has no trigger, is absent.
|
|
1225
|
+
* M11 am4 item 2: each card carries `runId`, the job's newest run (the first row `listRuns` gives that job, the one the runs list heads its job card with), or null when it has none.
|
|
1226
|
+
* @param {{root: string, triggerRead: (flow: string) => any, now?: () => number, home?: string, rows?: {flow: string, runId: string|null}[]}} opts
|
|
1227
|
+
* @returns {{flow: string, at: string|null, in: string|null, words: string, runId: string|null}[]}
|
|
1228
|
+
*/
|
|
1229
|
+
export function listScheduled({
|
|
1230
|
+
root, triggerRead, now = Date.now, home, rows = [],
|
|
1231
|
+
}) {
|
|
1232
|
+
const t0 = now();
|
|
1233
|
+
const out = [];
|
|
1234
|
+
for (const flow of listFlowNames(root)) {
|
|
1235
|
+
const t = triggerRead(flow);
|
|
1236
|
+
if (!t || !t.trigger) continue; // eslint-disable-line no-continue
|
|
1237
|
+
const ms = t.armed && typeof t.nextSlotMs === 'number' ? t.nextSlotMs : null;
|
|
1238
|
+
out.push({
|
|
1239
|
+
ms, flow, at: ms === null ? null : nextTimeWords(ms, t0), in: ms === null ? null : nextInWords(ms, t0), words: String(scheduledWords(t.trigger, home)),
|
|
1240
|
+
runId: rows.find((r) => r.flow === flow)?.runId ?? null,
|
|
1241
|
+
});
|
|
1242
|
+
}
|
|
1243
|
+
out.sort((a, b) => {
|
|
1244
|
+
if (a.ms !== b.ms) return a.ms === null ? 1 : b.ms === null ? -1 : a.ms - b.ms;
|
|
1245
|
+
return a.flow < b.flow ? -1 : a.flow > b.flow ? 1 : 0;
|
|
1246
|
+
});
|
|
1247
|
+
return out.map(({ ms, ...card }) => card);
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1166
1250
|
/**
|
|
1167
1251
|
* hamr's 2026-09-27 step-card review: the ONE place raw `audit.jsonl` rows
|
|
1168
1252
|
* get their server-derived fields (`action`/`tokensDisplay`/`atWhy`/
|
|
@@ -1245,8 +1329,8 @@ function jobWaitingLine(root, flowDir, flow, catalogue) {
|
|
|
1245
1329
|
/**
|
|
1246
1330
|
* M9 piece 6 (ladder M9 item 7): the summary block at the top of a run page, as data. Words come from `src/summary-words.js` only, built
|
|
1247
1331
|
* from typed facts (the history row's outcome, the declared step's line, the signed trigger and its ledger). `ended` is null while the run
|
|
1248
|
-
* is live; `scheduled` is null when the job has no trigger; `catchUp` is a fixed sentence when this run was started late (am2 item 1).
|
|
1249
|
-
* @returns {{ended: {reason: string, next: string}|null, scheduled: {text: string, next: string, nextRed: boolean}|null, catchUp: string|null}}
|
|
1332
|
+
* is live; `scheduled` is null when the job has no trigger; `canSchedule` (am3 item 1) is the trigger door's own `hasGreenRun` answer; `catchUp` is a fixed sentence when this run was started late (am2 item 1).
|
|
1333
|
+
* @returns {{ended: {reason: string, next: string}|null, scheduled: {text: string, next: string, nextRed: boolean}|null, canSchedule: boolean, catchUp: string|null}}
|
|
1250
1334
|
*/
|
|
1251
1335
|
function runSummary(ctx, glyph, { root, catalogue, triggerRead, now, home }) {
|
|
1252
1336
|
const died = !ctx.historyRow && glyph === '[?]';
|
|
@@ -1272,7 +1356,7 @@ function runSummary(ctx, glyph, { root, catalogue, triggerRead, now, home }) {
|
|
|
1272
1356
|
let rec = null;
|
|
1273
1357
|
const f = readFileInside(ctx.runDir, 'trigger.json');
|
|
1274
1358
|
if (f.ok) { try { rec = JSON.parse(f.text); } catch { rec = null; } }
|
|
1275
|
-
return { ended, scheduled, catchUp: catchUpWords(rec) };
|
|
1359
|
+
return { ended, scheduled, canSchedule: !!(t && t.hasGreenRun), catchUp: catchUpWords(rec) };
|
|
1276
1360
|
}
|
|
1277
1361
|
|
|
1278
1362
|
/**
|
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){
|
package/src/panel/server.js
CHANGED
|
@@ -59,7 +59,7 @@ import { readHistory, endRow } from '../books.js';
|
|
|
59
59
|
import { resolveRunDir } from '../flow.js';
|
|
60
60
|
import { readAsk, requestStop, stopParkedRun } from '../runner.js';
|
|
61
61
|
import {
|
|
62
|
-
listRuns, getRunDetail, getRunControls, getRunAudit, getRunJob, listStops, inboxOpenCount, getRunAsks, readSavedAnswer, hasConsumedAnswer, resolveFlowDir,
|
|
62
|
+
listRuns, listScheduled, summarizeJobs, RUNS_LIST_LIMITS, getRunDetail, getRunControls, getRunAudit, getRunJob, listStops, inboxOpenCount, getRunAsks, readSavedAnswer, hasConsumedAnswer, resolveFlowDir,
|
|
63
63
|
} from './data.js';
|
|
64
64
|
import { createResumer } from './resume.js';
|
|
65
65
|
import { createScheduler } from './scheduler.js';
|
|
@@ -511,7 +511,15 @@ export function handleRequest(req, res, opts) {
|
|
|
511
511
|
const startingRun = (f, r) => opts.author?.startingRun?.(f, r) === true;
|
|
512
512
|
|
|
513
513
|
if (pathname === '/api/runs') {
|
|
514
|
-
|
|
514
|
+
// M11: the page is given every state; it works none out. `jobs` is the order and the quiet split, `scheduled` the Scheduled cards, `limits` the two named numbers.
|
|
515
|
+
const now = opts.now ?? Date.now;
|
|
516
|
+
const rows = listRuns({ root: opts.root, catalogue, resumeAttempt, startingRun, now });
|
|
517
|
+
send(200, {
|
|
518
|
+
rows,
|
|
519
|
+
jobs: summarizeJobs(rows, now()),
|
|
520
|
+
scheduled: listScheduled({ root: opts.root, triggerRead: (f) => opts.author?.trigger?.read(f) ?? null, now, rows }),
|
|
521
|
+
limits: RUNS_LIST_LIMITS,
|
|
522
|
+
});
|
|
515
523
|
return;
|
|
516
524
|
}
|
|
517
525
|
|
package/src/summary-words.js
CHANGED
|
@@ -48,6 +48,27 @@ export function slotWords(ms) {
|
|
|
48
48
|
return `${DAY_SHORT[d.getDay()]} ${d.getDate()} ${MONTH_SHORT[d.getMonth()]}, ${two(d.getHours())}:${two(d.getMinutes())}`;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
/**
|
|
52
|
+
* M11 am1 item 3, the Scheduled card's first line: "today 17:00", "tomorrow 09:00", else the date the NEXT line already says ("Tue 20 Oct, 09:05").
|
|
53
|
+
* Local time, by calendar day. @param {number} ms the next run @param {number} now
|
|
54
|
+
*/
|
|
55
|
+
export function nextTimeWords(ms, now) {
|
|
56
|
+
const d = new Date(ms);
|
|
57
|
+
const day = (/** @type {Date} */ x) => new Date(x.getFullYear(), x.getMonth(), x.getDate()).getTime();
|
|
58
|
+
const apart = Math.round((day(d) - day(new Date(now))) / 86_400_000);
|
|
59
|
+
if (apart === 0) return `today ${two(d.getHours())}:${two(d.getMinutes())}`;
|
|
60
|
+
if (apart === 1) return `tomorrow ${two(d.getHours())}:${two(d.getMinutes())}`;
|
|
61
|
+
return slotWords(ms);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** M11 am1 item 3, the Scheduled card's second line start: "next in 20m" / "next in 3h" / "next in 3d" (whole units, rounded down, never "0m"). @param {number} ms @param {number} now */
|
|
65
|
+
export function nextInWords(ms, now) {
|
|
66
|
+
const mins = Math.max(1, Math.floor((ms - now) / 60_000));
|
|
67
|
+
if (mins < 60) return `next in ${mins}m`;
|
|
68
|
+
const hours = Math.floor(mins / 60);
|
|
69
|
+
return hours < 48 ? `next in ${hours}h` : `next in ${Math.floor(hours / 24)}d`;
|
|
70
|
+
}
|
|
71
|
+
|
|
51
72
|
/** am1, said before a human signs an edit of a job that has a trigger. @param {Trigger|null} t @param {string} [home] */
|
|
52
73
|
export function editClearsWords(t, home) {
|
|
53
74
|
const w = scheduledWords(t, home);
|
package/types/panel/data.d.ts
CHANGED
|
@@ -444,15 +444,16 @@ export function getRunControls({ root, flow, runId, catalogue, }: {
|
|
|
444
444
|
* null`, an explicit `why`) — no flow is silently missing from the list.
|
|
445
445
|
* Ordered by `orderRuns` (waiting on you, running, then newest `at` first; a row
|
|
446
446
|
* with no `at` is never given a guessed one).
|
|
447
|
-
* @param {{root: string, catalogue: any, resumeAttempt?: (flow: string, runId: string) => any, startingRun?: (flow: string, runId: string) => boolean}} opts
|
|
448
|
-
* `startingRun`: the starter's phase-`starting` rule for one run (absent = no). `resumeAttempt`: the panel's in-memory resume-attempt lookup (M4b piece 2); absent = none.
|
|
447
|
+
* @param {{root: string, catalogue: any, resumeAttempt?: (flow: string, runId: string) => any, startingRun?: (flow: string, runId: string) => boolean, now?: () => number}} opts
|
|
448
|
+
* `now`: the clock for Needs you's 7-day rule (absent = Date.now). `startingRun`: the starter's phase-`starting` rule for one run (absent = no). `resumeAttempt`: the panel's in-memory resume-attempt lookup (M4b piece 2); absent = none.
|
|
449
449
|
* @returns {any[]}
|
|
450
450
|
*/
|
|
451
|
-
export function listRuns({ root, catalogue, resumeAttempt, startingRun }: {
|
|
451
|
+
export function listRuns({ root, catalogue, resumeAttempt, startingRun, now }: {
|
|
452
452
|
root: string;
|
|
453
453
|
catalogue: any;
|
|
454
454
|
resumeAttempt?: (flow: string, runId: string) => any;
|
|
455
455
|
startingRun?: (flow: string, runId: string) => boolean;
|
|
456
|
+
now?: () => number;
|
|
456
457
|
}): any[];
|
|
457
458
|
/**
|
|
458
459
|
* The ONE ordering of Runs — History and Workflows both render the list in the
|
|
@@ -467,6 +468,54 @@ export function listRuns({ root, catalogue, resumeAttempt, startingRun }: {
|
|
|
467
468
|
* @returns {any[]}
|
|
468
469
|
*/
|
|
469
470
|
export function orderRuns(rows: any[]): any[];
|
|
471
|
+
/**
|
|
472
|
+
* M11 am1 item 2 + am2: the ONE rule for a run's Needs-you tag, read off the sign and `runControls` (no second rule). `Accept`: waiting at an open ask.
|
|
473
|
+
* `Resume`: stuck `[II]`, or stopped `[■]` whose Run tab shows the Resume button. An expired ask `[!]` is never here (it stays in the Inbox).
|
|
474
|
+
* M11 am3 item 5: a Resume run leaves Needs you once its stop time (`at`, the history row's) is `RUNS_LIST_LIMITS.needsYouDays` old; exactly that old is out.
|
|
475
|
+
* M11 am4 item 1: a stuck `[II]` run has no stop time; the caller passes the time its saved answer was written. A run with no readable time stays in. An Accept run is never dropped by age (its ask has its own wait).
|
|
476
|
+
* @param {string} glyph a `computeGlyph` sign @param {{atAsk: boolean, canResume: boolean}} controls `runControls`' answer
|
|
477
|
+
* @param {string|null} [at] the run's stop time from the books @param {number} [nowMs]
|
|
478
|
+
* @returns {'Accept'|'Resume'|null}
|
|
479
|
+
*/
|
|
480
|
+
export function needsYouTag(glyph: string, controls: {
|
|
481
|
+
atAsk: boolean;
|
|
482
|
+
canResume: boolean;
|
|
483
|
+
}, at?: string | null, nowMs?: number): "Accept" | "Resume" | null;
|
|
484
|
+
/**
|
|
485
|
+
* M11: one entry per job (flow), newest activity first. A job's activity is its newest KNOWN run time (`at`, else `askedAt`, else `startedAt`);
|
|
486
|
+
* `quiet` only when that time is known and older than the quiet limit: an unknown age is never guessed into quiet, and a job with no runs is not quiet.
|
|
487
|
+
* @param {any[]} rows `listRuns` rows @param {number} nowMs
|
|
488
|
+
* @returns {{flow: string, quiet: boolean, activityMs: number|null}[]}
|
|
489
|
+
*/
|
|
490
|
+
export function summarizeJobs(rows: any[], nowMs: number): {
|
|
491
|
+
flow: string;
|
|
492
|
+
quiet: boolean;
|
|
493
|
+
activityMs: number | null;
|
|
494
|
+
}[];
|
|
495
|
+
/**
|
|
496
|
+
* M11 am1 item 3: every job with a trigger, soonest next run first (a job with no clock slot — a file trigger, or not armed yet — after those that
|
|
497
|
+
* have one, by name). Built from the owners the run page's SCHEDULED block uses (`triggerRead`, `scheduledWords`); `at` / `in` are null when
|
|
498
|
+
* there is no next time (nothing is invented). A job that cannot be read, or has no trigger, is absent.
|
|
499
|
+
* M11 am4 item 2: each card carries `runId`, the job's newest run (the first row `listRuns` gives that job, the one the runs list heads its job card with), or null when it has none.
|
|
500
|
+
* @param {{root: string, triggerRead: (flow: string) => any, now?: () => number, home?: string, rows?: {flow: string, runId: string|null}[]}} opts
|
|
501
|
+
* @returns {{flow: string, at: string|null, in: string|null, words: string, runId: string|null}[]}
|
|
502
|
+
*/
|
|
503
|
+
export function listScheduled({ root, triggerRead, now, home, rows, }: {
|
|
504
|
+
root: string;
|
|
505
|
+
triggerRead: (flow: string) => any;
|
|
506
|
+
now?: () => number;
|
|
507
|
+
home?: string;
|
|
508
|
+
rows?: {
|
|
509
|
+
flow: string;
|
|
510
|
+
runId: string | null;
|
|
511
|
+
}[];
|
|
512
|
+
}): {
|
|
513
|
+
flow: string;
|
|
514
|
+
at: string | null;
|
|
515
|
+
in: string | null;
|
|
516
|
+
words: string;
|
|
517
|
+
runId: string | null;
|
|
518
|
+
}[];
|
|
470
519
|
/**
|
|
471
520
|
* `GET /api/runs/:flow/:runId` — the Run tab (M4a scope item 2): the step
|
|
472
521
|
* map from `declaration.steps`, step cards -> attempts from `audit.jsonl`
|
|
@@ -721,6 +770,12 @@ export const STUCK_REASONS: {
|
|
|
721
770
|
why: string;
|
|
722
771
|
};
|
|
723
772
|
};
|
|
773
|
+
/** M11 scope item 2.5/2.6 and rules, am3 item 5: the named limits of the runs list, in ONE place (30 quiet days, 7 older runs, 7 days in Needs you for a Resume run). The page reads them from `GET /api/runs`. */
|
|
774
|
+
export const RUNS_LIST_LIMITS: Readonly<{
|
|
775
|
+
quietDays: 30;
|
|
776
|
+
olderRuns: 7;
|
|
777
|
+
needsYouDays: 7;
|
|
778
|
+
}>;
|
|
724
779
|
/** The words the Draft says for a flow with no `setup.jsonl` (M4e amendment 6 item 4; renamed Draft by amendment 7 item 2). */
|
|
725
780
|
export const NO_DRAFT_WORDS: "no draft record";
|
|
726
781
|
/** M6: what the Job tab says for a run that started before runs kept a copy of their job. */
|
package/types/summary-words.d.ts
CHANGED
|
@@ -6,6 +6,13 @@
|
|
|
6
6
|
export function scheduledWords(t: Trigger | null, home?: string): string | null;
|
|
7
7
|
/** "Mon 13 Oct, 09:00" — local time, fixed English names (never the machine's locale). @param {number} ms */
|
|
8
8
|
export function slotWords(ms: number): string;
|
|
9
|
+
/**
|
|
10
|
+
* M11 am1 item 3, the Scheduled card's first line: "today 17:00", "tomorrow 09:00", else the date the NEXT line already says ("Tue 20 Oct, 09:05").
|
|
11
|
+
* Local time, by calendar day. @param {number} ms the next run @param {number} now
|
|
12
|
+
*/
|
|
13
|
+
export function nextTimeWords(ms: number, now: number): string;
|
|
14
|
+
/** M11 am1 item 3, the Scheduled card's second line start: "next in 20m" / "next in 3h" / "next in 3d" (whole units, rounded down, never "0m"). @param {number} ms @param {number} now */
|
|
15
|
+
export function nextInWords(ms: number, now: number): string;
|
|
9
16
|
/** am1, said before a human signs an edit of a job that has a trigger. @param {Trigger|null} t @param {string} [home] */
|
|
10
17
|
export function editClearsWords(t: Trigger | null, home?: string): string | null;
|
|
11
18
|
/**
|