fwdloop 0.16.0 → 0.18.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/README.md +2 -0
- package/bin/fwdloop +10 -7
- package/package.json +1 -1
- package/src/authoring.js +6 -6
- package/src/books.js +6 -1
- package/src/catalogue.json +9 -3
- package/src/ctx-tools.js +245 -0
- package/src/draft-steps.js +89 -30
- package/src/drafter.js +28 -4
- package/src/draftspend.js +109 -3
- package/src/liveness.js +34 -10
- package/src/panel/author.js +125 -37
- package/src/panel/authorcard.js +15 -10
- package/src/panel/authorflows.js +9 -3
- package/src/panel/authorresume.js +5 -4
- package/src/panel/authorstart.js +21 -9
- package/src/panel/authortrigger.js +384 -0
- package/src/panel/authorvalues.js +5 -3
- package/src/panel/data.js +104 -16
- package/src/panel/index.html +257 -44
- package/src/panel/scheduler.js +125 -0
- package/src/panel/server.js +24 -10
- package/src/panel/settings.js +2 -2
- package/src/plain-checks.js +51 -0
- package/src/primitives.js +34 -3
- package/src/provider.js +17 -8
- package/src/run-store.js +47 -0
- package/src/runner.js +2 -0
- package/src/runvalues.js +5 -3
- package/src/setup.js +24 -0
- package/src/signed-text.js +26 -0
- package/src/summary-words.js +155 -0
- package/src/trigger-clock.js +142 -0
- package/src/trigger-files.js +212 -0
- package/src/trigger-line.js +86 -0
- package/src/types.js +1 -0
- package/src/version.js +13 -0
- package/types/authoring.d.ts +1 -3
- package/types/ctx-tools.d.ts +18 -0
- package/types/draft-steps.d.ts +38 -5
- package/types/drafter.d.ts +3 -3
- package/types/draftspend.d.ts +56 -0
- package/types/liveness.d.ts +7 -1
- package/types/panel/author.d.ts +149 -146
- package/types/panel/authorcard.d.ts +12 -2
- package/types/panel/authorflows.d.ts +11 -3
- package/types/panel/authorstart.d.ts +7 -4
- package/types/panel/authortrigger.d.ts +210 -0
- package/types/panel/authorvalues.d.ts +3 -1
- package/types/panel/data.d.ts +14 -7
- package/types/panel/scheduler.d.ts +15 -0
- package/types/panel/server.d.ts +11 -3
- package/types/plain-checks.d.ts +22 -0
- package/types/primitives.d.ts +0 -6
- package/types/provider.d.ts +7 -1
- package/types/run-store.d.ts +11 -0
- package/types/runvalues.d.ts +1 -1
- package/types/setup.d.ts +27 -0
- package/types/summary-words.d.ts +53 -0
- package/types/trigger-clock.d.ts +60 -0
- package/types/trigger-files.d.ts +90 -0
- package/types/trigger-line.d.ts +44 -0
- package/types/types.d.ts +4 -0
- package/types/version.d.ts +2 -0
package/src/panel/index.html
CHANGED
|
@@ -119,6 +119,11 @@
|
|
|
119
119
|
.topbar > div:first-child{display:flex;align-items:baseline;gap:0;white-space:nowrap;overflow:hidden;}
|
|
120
120
|
.topbar .brand{font-weight:700;font-size:17px;letter-spacing:0.06em;flex:none;}
|
|
121
121
|
.topbar .brand::before{content:"■ ";}
|
|
122
|
+
.update-bar{display:flex;flex-wrap:wrap;align-items:center;gap:6px 12px;padding:6px 16px;background:var(--amber);color:#000;font-size:13px;}
|
|
123
|
+
.update-bar[hidden]{display:none;}
|
|
124
|
+
.update-bar .btn{color:#000;border-color:#000;}
|
|
125
|
+
.topbar .version{font-size:12px;color:var(--text-dim);margin-left:8px;flex:none;white-space:nowrap;}
|
|
126
|
+
.topbar .version::before{content:"· ";color:var(--text-faint);}
|
|
122
127
|
.topbar .tagline{font-size:12px;color:var(--text-dim);margin-left:8px;overflow:hidden;text-overflow:ellipsis;}
|
|
123
128
|
.topbar .tagline::before{content:"· ";color:var(--text-faint);}
|
|
124
129
|
@media (max-width: 600px){ .topbar .tagline{display:none;} }
|
|
@@ -278,6 +283,20 @@
|
|
|
278
283
|
.counters{display:block;padding:9px 12px;border:none;border-bottom:2px solid var(--border-strong);background:var(--panel2);color:var(--text-dim);margin:-12px -12px 14px;font-size:12px;font-weight:700;white-space:normal;overflow-wrap:break-word;}
|
|
279
284
|
.counters b,.counters span{color:var(--accent);}
|
|
280
285
|
|
|
286
|
+
/* borrowed-from: bareloop src/panel/index.html@f845ee7 (the ENDED block, P5); amber added for stopped/expired, a SCHEDULED twin */
|
|
287
|
+
.ended-block{position:relative;border:1px solid var(--border-strong);padding:12px;margin-bottom:12px;background:var(--panel2);font-size:13px;}
|
|
288
|
+
.ended-block.magenta{border-color:var(--magenta);}
|
|
289
|
+
.ended-block.red{border-color:var(--red);}
|
|
290
|
+
.ended-text.is-red{color:var(--red);}
|
|
291
|
+
.ended-block.green{border-color:var(--green);}
|
|
292
|
+
.ended-block.amber{border-color:var(--amber);}
|
|
293
|
+
.ended-row{display:flex;gap:10px;align-items:baseline;flex-wrap:wrap;margin-bottom:6px;}
|
|
294
|
+
.ended-row:last-child{margin-bottom:0;}
|
|
295
|
+
.ended-label{color:var(--text-faint);font-size:11px;letter-spacing:0.08em;min-width:84px;}
|
|
296
|
+
.ended-text{flex:1 1 220px;min-width:0;overflow-wrap:anywhere;}
|
|
297
|
+
.when-sub{display:flex;gap:8px;flex-wrap:wrap;margin-top:6px;}
|
|
298
|
+
.when-sub > *{flex:1 1 120px;min-width:0;}
|
|
299
|
+
.when-sub[hidden]{display:none;}
|
|
281
300
|
.summary-box{position:relative;border:1px solid var(--border-strong);padding:16px 12px 12px;margin-top:16px;background:var(--panel2);font-size:12px;}
|
|
282
301
|
.summary-box.red{border-color:var(--red);}
|
|
283
302
|
.summary-box.amber{border-color:var(--amber);}
|
|
@@ -499,7 +518,9 @@
|
|
|
499
518
|
.chat-steps .step.wait .step-label{color:var(--amber);}
|
|
500
519
|
.chat-steps .step-detail{display:block;flex-basis:100%;min-width:0;padding-left:1.2em;color:var(--text-faint);word-break:break-word;white-space:pre-wrap;}
|
|
501
520
|
.chat-steps .step.bad .step-detail{color:var(--red);}
|
|
521
|
+
.chat-steps .step.note .step-label{color:var(--text);padding-left:1.2em;}
|
|
502
522
|
.chat-steps .step[data-step="thinking"].bad .step-label{color:var(--red);font-weight:600;}
|
|
523
|
+
.audit-raw{color:var(--text-faint);font-size:11px;word-break:break-word;white-space:pre-wrap;margin-top:2px;}
|
|
503
524
|
.chat-steps .step-raw{margin-top:2px;color:var(--text-faint);}
|
|
504
525
|
.chat-steps .step-raw summary{cursor:pointer;}
|
|
505
526
|
.chat-steps .step.run .step-sign::after{content:"\2026";}
|
|
@@ -762,9 +783,15 @@
|
|
|
762
783
|
|
|
763
784
|
<div id="FwdloopPanel">
|
|
764
785
|
|
|
786
|
+
<div id="update-bar" class="update-bar" data-testid="update-bar" role="status" hidden>
|
|
787
|
+
<span id="update-text"></span>
|
|
788
|
+
<button class="btn" type="button" id="update-reload" data-testid="update-reload">Reload</button>
|
|
789
|
+
</div>
|
|
790
|
+
|
|
765
791
|
<header class="topbar">
|
|
766
792
|
<div>
|
|
767
793
|
<span class="brand">fwdloop</span>
|
|
794
|
+
<span class="version" data-version="__FWDLOOP_VERSION__">v__FWDLOOP_VERSION__</span>
|
|
768
795
|
<span class="tagline">automate a job — it has humans in it</span>
|
|
769
796
|
</div>
|
|
770
797
|
<div class="topbar-right">
|
|
@@ -903,6 +930,7 @@
|
|
|
903
930
|
<label for="jf-cap-money">Cap $</label>
|
|
904
931
|
<input id="jf-cap-money" type="text" inputmode="decimal" placeholder="per run" data-testid="jf-cap-money">
|
|
905
932
|
<div class="hint" id="jf-cap-note" data-testid="cap-note"></div>
|
|
933
|
+
<div class="hint" id="jf-cap-job-note" data-testid="jf-cap-job-note"></div>
|
|
906
934
|
<div class="jf-err" id="jf-err-capUsd" data-testid="jf-err-capUsd"></div>
|
|
907
935
|
</div>
|
|
908
936
|
<div class="cap-field">
|
|
@@ -947,6 +975,30 @@
|
|
|
947
975
|
<div id="jf-run-inputs" data-testid="jf-run-inputs"></div>
|
|
948
976
|
<div class="jf-err" id="jf-err-run-inputs" data-testid="jf-err-run-inputs"></div>
|
|
949
977
|
</div>
|
|
978
|
+
<div class="field" id="jf-when-field" data-testid="jf-when-field">
|
|
979
|
+
<label for="jf-when">When</label>
|
|
980
|
+
<select id="jf-when" data-testid="jf-when" aria-label="When this job runs">
|
|
981
|
+
<option value="hand">By hand</option>
|
|
982
|
+
<option value="daily">Every day at HH:MM</option>
|
|
983
|
+
<option value="weekdays">Weekdays at HH:MM</option>
|
|
984
|
+
<option value="weekly">Every <day> at HH:MM</option>
|
|
985
|
+
<option value="file-updated">When <file> is updated</option>
|
|
986
|
+
<option value="new-file">When a new file arrives in <folder></option>
|
|
987
|
+
</select>
|
|
988
|
+
<div class="when-sub" id="jf-when-clock" hidden>
|
|
989
|
+
<select id="jf-when-day" data-testid="jf-when-day" aria-label="Day of the week">
|
|
990
|
+
<option value="mon">Monday</option><option value="tue">Tuesday</option><option value="wed">Wednesday</option><option value="thu">Thursday</option>
|
|
991
|
+
<option value="fri">Friday</option><option value="sat">Saturday</option><option value="sun">Sunday</option>
|
|
992
|
+
</select>
|
|
993
|
+
<input id="jf-when-time" type="time" value="09:00" data-testid="jf-when-time" aria-label="Time, HH:MM">
|
|
994
|
+
</div>
|
|
995
|
+
<div class="when-sub" id="jf-when-filebox" hidden>
|
|
996
|
+
<select id="jf-when-role" data-testid="jf-when-role" aria-label="Which of the job's inputs"></select>
|
|
997
|
+
<input id="jf-when-path" type="text" autocomplete="off" spellcheck="false" data-testid="jf-when-path" aria-label="File or folder">
|
|
998
|
+
</div>
|
|
999
|
+
<div class="hint" id="jf-when-now" data-testid="jf-when-now"></div>
|
|
1000
|
+
<div class="jf-err" id="jf-err-when" data-testid="jf-err-when"></div>
|
|
1001
|
+
</div>
|
|
950
1002
|
<div class="cap-row">
|
|
951
1003
|
<div class="cap-field">
|
|
952
1004
|
<label for="jf-run-cap">Cap $</label>
|
|
@@ -1077,6 +1129,11 @@
|
|
|
1077
1129
|
<section id="panel-run" class="tabpanel active" role="tabpanel" aria-labelledby="tab-run">
|
|
1078
1130
|
<div id="run-empty" class="hint" style="font-size:13px;padding:24px 0;">select a run from Workflows or History</div>
|
|
1079
1131
|
<div id="run-content" hidden>
|
|
1132
|
+
<div id="summary-blocks" data-testid="summary-blocks">
|
|
1133
|
+
<div id="ended-block" class="ended-block" data-testid="ended-block" hidden></div>
|
|
1134
|
+
<div id="sched-block" class="ended-block" data-testid="sched-block" hidden></div>
|
|
1135
|
+
<div class="hint" id="catchup-note" data-testid="catchup-note" hidden></div>
|
|
1136
|
+
</div>
|
|
1080
1137
|
<div class="run-actions" id="run-actions" data-testid="run-actions" hidden></div>
|
|
1081
1138
|
<div class="counters" id="run-counters" data-testid="live-counters"></div>
|
|
1082
1139
|
<div class="summary-box" id="run-summary" data-testid="run-summary"></div>
|
|
@@ -1192,6 +1249,7 @@
|
|
|
1192
1249
|
"use strict";
|
|
1193
1250
|
|
|
1194
1251
|
var PORT = "__FWDLOOP_PANEL_PORT__";
|
|
1252
|
+
var PLAN_CHECK_RULES = __FWDLOOP_PLAN_CHECK_RULES__;
|
|
1195
1253
|
// No token, no cookie (M4e amendment 4 item 8): the panel is local and trusted; the server checks Host and, on a POST, Origin.
|
|
1196
1254
|
document.getElementById("host-line").textContent = "127.0.0.1:" + PORT;
|
|
1197
1255
|
|
|
@@ -1285,7 +1343,7 @@
|
|
|
1285
1343
|
return (r.gapHead || []).concat(["ask waits " + waits]).join(" · ");
|
|
1286
1344
|
}
|
|
1287
1345
|
function auditCostCellText(r){
|
|
1288
|
-
if(r.setup && typeof r.usd !== "number" && r.verdict === "hitl") return "—"; // a setup row you wrote (card, note, sign) has no cost
|
|
1346
|
+
if(r.setup && typeof r.usd !== "number" && (r.verdict === "hitl" || r.tryRow === true)) return "—"; // a try row (its plan row has the cost) or a setup row you wrote (card, note, sign) has no cost of its own
|
|
1289
1347
|
if(r.setup) return money(r.usd, r.spendComplete) + (typeof r.wallMs === "number" ? " \u00b7 " + duration(r.wallMs) : ""); // a draft/change row: its own booked cost ("unknown" when nobody booked it) and time (left out when not recorded)
|
|
1290
1348
|
var bits = [money(r.usd, r.spendComplete)];
|
|
1291
1349
|
var td = r.tokensDisplay;
|
|
@@ -2162,6 +2220,32 @@
|
|
|
2162
2220
|
// (ruling A, 2026-09-26: "no per-round parts") — built off getRunDetail's
|
|
2163
2221
|
// `steps[]` (declaration.steps joined with audit.jsonl attempts), never a
|
|
2164
2222
|
// second client-side re-derivation of the step list. ----
|
|
2223
|
+
// ---- M9 piece 6: the summary block, first thing on the run page. The sentences are CODE-OWNED on the server (`summary` of the run detail,
|
|
2224
|
+
// src/summary-words.js); this only paints them. ENDED / NEXT while a finished run; SCHEDULED / NEXT for a job with a trigger.
|
|
2225
|
+
// borrowed-from: bareloop src/panel/index.html@f845ee7 (renderEnded)
|
|
2226
|
+
function summaryRows(a, b){
|
|
2227
|
+
return '<div class="ended-row"><span class="ended-label">' + a[0] + '</span><span class="ended-text" data-testid="' + a[2] + '">' + escapeXml(a[1]) + '</span></div>' +
|
|
2228
|
+
'<div class="ended-row"><span class="ended-label">' + b[0] + '</span><span class="ended-text" data-testid="' + b[2] + '">' + escapeXml(b[1]) + '</span></div>';
|
|
2229
|
+
}
|
|
2230
|
+
function renderSummary(detail){
|
|
2231
|
+
var sm = detail.summary || {};
|
|
2232
|
+
var ended = document.getElementById("ended-block");
|
|
2233
|
+
var sched = document.getElementById("sched-block");
|
|
2234
|
+
var note = document.getElementById("catchup-note");
|
|
2235
|
+
if(sm.ended){
|
|
2236
|
+
ended.hidden = false;
|
|
2237
|
+
ended.className = "ended-block " + (detail.glyph === "[✓]" ? "green" : (detail.glyph === "[?]" ? "magenta" : ((detail.glyph === "[■]" || detail.glyph === "[!]") ? "amber" : "red")));
|
|
2238
|
+
ended.innerHTML = summaryRows(["ENDED", sm.ended.reason, "ended-reason"], ["NEXT", sm.ended.next, "ended-next"]);
|
|
2239
|
+
} else { ended.hidden = true; ended.innerHTML = ""; }
|
|
2240
|
+
if(sm.scheduled){
|
|
2241
|
+
sched.hidden = false;
|
|
2242
|
+
sched.className = "ended-block" + (sm.scheduled.nextRed === true ? " red" : "");
|
|
2243
|
+
sched.innerHTML = summaryRows(["SCHEDULED", sm.scheduled.text, "sched-text"], ["NEXT", sm.scheduled.next, "sched-next"]);
|
|
2244
|
+
if(sm.scheduled.nextRed === true) sched.querySelector('[data-testid="sched-next"]').classList.add("is-red");
|
|
2245
|
+
} else { sched.hidden = true; sched.innerHTML = ""; }
|
|
2246
|
+
note.hidden = !sm.catchUp;
|
|
2247
|
+
note.textContent = sm.catchUp || "";
|
|
2248
|
+
}
|
|
2165
2249
|
function renderRun(detail){
|
|
2166
2250
|
var name = document.getElementById("active-wf-name");
|
|
2167
2251
|
var dot = document.getElementById("active-wf-dot");
|
|
@@ -2181,6 +2265,7 @@
|
|
|
2181
2265
|
|
|
2182
2266
|
document.getElementById("run-empty").hidden = true;
|
|
2183
2267
|
document.getElementById("run-content").hidden = false;
|
|
2268
|
+
renderSummary(detail);
|
|
2184
2269
|
|
|
2185
2270
|
// "took Xs" for a finished run, straight off the history row's own
|
|
2186
2271
|
// wallMs (never derived/guessed) — a died/parked run or one whose
|
|
@@ -2272,6 +2357,8 @@
|
|
|
2272
2357
|
el.innerHTML = "";
|
|
2273
2358
|
// amendment 7 item 6: Run again sits first, with Stop and Resume — every run control in this one row
|
|
2274
2359
|
el.appendChild(makeButton("Run again", "run-again", function(){ if(window.fwdloopRunAgain) window.fwdloopRunAgain(detail); }));
|
|
2360
|
+
// 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
|
+
if(detail.summary && detail.summary.scheduled) el.appendChild(makeButton("Cancel / modify schedule", "run-cancel-schedule", function(){ if(window.fwdloopRunAgain) window.fwdloopRunAgain(detail); }));
|
|
2275
2362
|
if(stopSay && stopSay.key !== detail.flow + "/" + detail.runId) stopSay = null;
|
|
2276
2363
|
if(c.canStop){
|
|
2277
2364
|
var stopBtn = makeButton(c.stopRequested ? "stopping after this step\u2026" : "Stop", "run-stop", function(){
|
|
@@ -2467,6 +2554,7 @@
|
|
|
2467
2554
|
function auditDetailHtml(r, word, actionText, isRejectRow){
|
|
2468
2555
|
var lines = (typeof r.step === "string" && r.step.length > 0 ? [["step", r.step]] : []).concat([["result", word], ["action", actionText]]);
|
|
2469
2556
|
if(!isRejectRow && r.gap) lines.push(["gap", auditGapText(r)]);
|
|
2557
|
+
if(Array.isArray(r.raw) && r.raw.length > 0) lines.push(["raw", r.raw.join(" | ")]);
|
|
2470
2558
|
if(Array.isArray(r.refused) && r.refused.length > 0){
|
|
2471
2559
|
lines.push(["refused", r.refused.map(function(x){ return x.verb + " " + x.path + " (" + x.rule + ")"; }).join("; ")]);
|
|
2472
2560
|
}
|
|
@@ -2487,6 +2575,11 @@
|
|
|
2487
2575
|
// number and no close class — it shows nothing / "—", never "null", "unknown" or "#null".
|
|
2488
2576
|
function auditAttemptText(r){ return (typeof r.attempt === "number" || (typeof r.attempt === "string" && r.attempt.length > 0)) ? String(r.attempt) : ""; }
|
|
2489
2577
|
function auditCloseText(r){ return (r.setup || r.class === null || r.class === undefined) ? "—" : closeClassLabel(r.class); }
|
|
2578
|
+
// M4d am15 item 4: a try row's raw checker text, under its plain reason (the Gap cell). Server data, always escaped.
|
|
2579
|
+
function auditRawHtml(r){
|
|
2580
|
+
if(!Array.isArray(r.raw) || r.raw.length === 0) return "";
|
|
2581
|
+
return r.raw.map(function(t){ return "<div class=\"audit-raw\">" + escapeXml(String(t)) + "</div>"; }).join("");
|
|
2582
|
+
}
|
|
2490
2583
|
function buildAuditRowEl(r, includeStep){
|
|
2491
2584
|
var tr = document.createElement("tr");
|
|
2492
2585
|
var glyph = verdictGlyph(r.verdict, r.class);
|
|
@@ -2503,7 +2596,7 @@
|
|
|
2503
2596
|
"<td data-label=\"Attempt\">" + escapeXml(auditAttemptText(r)) + "</td>" +
|
|
2504
2597
|
(includeStep ? "<td data-label=\"Step\">" + escapeXml(r.stepName || r.step) + "</td>" : "") +
|
|
2505
2598
|
"<td data-label=\"Action\">" + escapeXml(actionText) + "</td>" +
|
|
2506
|
-
"<td data-label=\"Gap\">" + escapeXml(isRejectRow ? "" : auditGapText(r)) + "</td>" +
|
|
2599
|
+
"<td data-label=\"Gap\">" + escapeXml(isRejectRow ? "" : auditGapText(r)) + auditRawHtml(r) + "</td>" +
|
|
2507
2600
|
"<td data-label=\"Cost\">" + escapeXml(auditCostCellText(r)) + "</td>" +
|
|
2508
2601
|
"<td data-label=\"Verdict\"><span class=\"badge " + badgeClass + "\">" + escapeXml(word) + "</span></td>" +
|
|
2509
2602
|
"<td data-label=\"Close\">" + escapeXml(auditCloseText(r)) + "</td>" +
|
|
@@ -2980,6 +3073,19 @@
|
|
|
2980
3073
|
el._say = say;
|
|
2981
3074
|
say(timeLeftMs);
|
|
2982
3075
|
}
|
|
3076
|
+
// M4d am18: the page keeps the version it was served with (the header's data-version, am17); the Inbox poll reports the server's. A different one = the panel
|
|
3077
|
+
// restarted on newer code under this open tab: say so. Pure text rule (null = no bar), one painter.
|
|
3078
|
+
function updateBarText(pageVersion, serverVersion){
|
|
3079
|
+
if(typeof pageVersion !== "string" || pageVersion === "" || typeof serverVersion !== "string" || serverVersion === "") return null;
|
|
3080
|
+
return pageVersion === serverVersion ? null : "fwdloop was updated to v" + serverVersion + ". Reload this page.";
|
|
3081
|
+
}
|
|
3082
|
+
function paintUpdateBar(serverVersion){
|
|
3083
|
+
var vEl = document.querySelector(".topbar .version");
|
|
3084
|
+
var text = updateBarText(vEl ? vEl.getAttribute("data-version") : "", serverVersion);
|
|
3085
|
+
document.getElementById("update-bar").hidden = text === null;
|
|
3086
|
+
if(text !== null) document.getElementById("update-text").textContent = text;
|
|
3087
|
+
}
|
|
3088
|
+
document.getElementById("update-reload").addEventListener("click", function(){ location.reload(); });
|
|
2983
3089
|
function tickLeft(){
|
|
2984
3090
|
document.querySelectorAll(".live-left").forEach(function(el){ el._say(Math.max(0, el._endsAt - Date.now())); });
|
|
2985
3091
|
}
|
|
@@ -3075,7 +3181,7 @@
|
|
|
3075
3181
|
// Immediate (every user action that re-reads calls this); the tick uses `listsDue` to throttle.
|
|
3076
3182
|
function reloadLists(){
|
|
3077
3183
|
lastListsAt = Date.now();
|
|
3078
|
-
getJSON("/api/inbox").then(function(r){ renderInbox(r.rows || [], r.openCount); }).catch(function(){});
|
|
3184
|
+
getJSON("/api/inbox").then(function(r){ renderInbox(r.rows || [], r.openCount); paintUpdateBar(r.version); }).catch(function(){});
|
|
3079
3185
|
getJSON("/api/runs").then(function(r){
|
|
3080
3186
|
var rows = r.rows || [];
|
|
3081
3187
|
var next = sig(rows);
|
|
@@ -3938,7 +4044,7 @@
|
|
|
3938
4044
|
var sessionId = null; // the draft's id (GET /api/author/<id>)
|
|
3939
4045
|
var sessionLive = false; // a draft exists that is not abandoned or signed
|
|
3940
4046
|
var lastState = null; // the draft as the server last described it
|
|
3941
|
-
var signInfo = null; // the first Sign click's reply: { hash, flowName, capUsd, runId }
|
|
4047
|
+
var signInfo = null; // the first Sign click's reply: { hash, flowName, capUsd, runId, split }
|
|
3942
4048
|
var signClickedOnce = false;
|
|
3943
4049
|
var reviseOpen = false; // amendment 14 item 2: Revise was pressed on a green plan, so every card field is open (ONE writer: setReviseOpen)
|
|
3944
4050
|
var qKey = ""; // which question the box is showing (draft id + k): the answer box is rewritten only when this changes
|
|
@@ -3976,6 +4082,12 @@
|
|
|
3976
4082
|
var spends = (cap !== undefined && cap !== null && cap !== "") ? " — spends up to $" + cap : "";
|
|
3977
4083
|
var blocked = !st.startOk || !!st.busy;
|
|
3978
4084
|
if(st.mode === "run"){
|
|
4085
|
+
// M9 am5: When changed from the signed value = the one button is Sign schedule (or Cancel schedule when the choice is By hand), two clicks, $0,
|
|
4086
|
+
// starts nothing; after click 1 it reads "Confirm: <words>". It never reaches the run routes.
|
|
4087
|
+
if(st.whenChanged){
|
|
4088
|
+
var whenText = st.whenConfirm ? "Confirm: " + st.whenConfirm : (st.whenCancel ? "Cancel schedule" : "Sign schedule");
|
|
4089
|
+
return {text: whenText, action: st.whenSigning ? "when-sign" : "when-sign-prepare", disabled: !!st.whenBusy || !!st.busy || !!st.whenLocked};
|
|
4090
|
+
}
|
|
3979
4091
|
// amendment 5 item 3: inputs alone = Run (one click); a Destination, Cap $ or ask wait different from the flow's = Sign & run (two clicks, bound to a hash)
|
|
3980
4092
|
if(st.runDiffers){
|
|
3981
4093
|
if(st.runSignClicked){
|
|
@@ -3984,7 +4096,7 @@
|
|
|
3984
4096
|
}
|
|
3985
4097
|
return {text: "Sign & run", action: "run-sign-prepare", disabled: blocked};
|
|
3986
4098
|
}
|
|
3987
|
-
return {text: "Run" + spends, action: "run", disabled: blocked};
|
|
4099
|
+
return {text: "Run now" + spends, action: "run", disabled: blocked || !!st.whenLocked};
|
|
3988
4100
|
}
|
|
3989
4101
|
if(st.mode === "resume"){
|
|
3990
4102
|
if(st.runSignClicked){
|
|
@@ -4059,33 +4171,11 @@
|
|
|
4059
4171
|
// am41 item 7: ONE function turns a checker's red (the text src/declaration.js writes) into one plain sentence for the card. The raw text rides
|
|
4060
4172
|
// along unchanged and is folded under "details"; a red no rule below knows gets the generic sentence and still shows its raw text. This reads
|
|
4061
4173
|
// the checker's own fixed wording, never the model's prose.
|
|
4174
|
+
// M4d am15: the plain words are src/plain-checks.js, handed to the page by the server (PLAN_CHECK_RULES, top of this script): one copy.
|
|
4062
4175
|
function plainPlanCheck(raw){
|
|
4063
|
-
var PLAN_CHECK_RULES = [
|
|
4064
|
-
[/which is not in the job line's words/, "A section name in the plan's check is not in your job line. Change the job line to use the section words you want."],
|
|
4065
|
-
[/the job line says .*; the check says/, "The sections in the plan's check come in a different order than your job line. Change the job line to change the order."],
|
|
4066
|
-
[/the guardrail says \d+ sections; the check has/, "The number of sections in your guardrail is not the number in the plan's check."],
|
|
4067
|
-
[/section name is a short phrase|which is the job line or most of it/, "A section name in the plan's check is too long; it must be a short phrase from your job line."],
|
|
4068
|
-
[/one section name may not contain another/, "One section name in the plan's check contains another, which cannot be checked."],
|
|
4069
|
-
[/wordsPerSection/, "The words for each section in your guardrail and in the plan's check do not match."],
|
|
4070
|
-
[/work as a pair/, "The plan's check has one part of a pair without the other, so it cannot be checked."],
|
|
4071
|
-
[/is blank|characters; the most one entry|ends in ":"/, "A name in the plan's check is empty, too long or ends in a colon, so it cannot be matched."],
|
|
4072
|
-
[/cannot be built into a check/, "The plan's check cannot be built from what the AI wrote."],
|
|
4073
|
-
[/is not its signed line/, "A step does not use your job line word for word as its goal."],
|
|
4074
|
-
[/not in the catalogue|not wired|which is not signed|checkpoint/, "A step uses a tool that is not available for this job."],
|
|
4075
|
-
[/reads artifact|is a duplicate|\.reads must|\.emits must/, "The steps do not pass their results to each other in a workable order."],
|
|
4076
|
-
[/ask at line \d+|signed ask at line|ask slot/, "The ask on one of your lines is not set up as a plain stop where you decide."],
|
|
4077
|
-
[/send at line \d+|signed send at line|send slot/, "The send step is not set up to follow your accept and write only to your destination."],
|
|
4078
|
-
[/hitl after the last signed ask/, "A step after your last ask would leave without your seeing it, so it is refused."],
|
|
4079
|
-
[/is a pause .* unsigned line/, "A step pauses at a line you did not sign as an ask."],
|
|
4080
|
-
[/neither served by any step/, "A line of your job is not covered by any step."],
|
|
4081
|
-
[/picks|inputFacts|invented name/, "The plan names a field that is not in your input."],
|
|
4082
|
-
[/guardrailClasses|unjudgeable|refused/, "The AI's notes on which lines it can check are not in a form the checker accepts."],
|
|
4083
|
-
[/^line \d+'s (guardrail|check)|can't write files/, null],
|
|
4084
|
-
[/must be an? |is required|must name|does not name/, "The plan the AI wrote is not in the shape the checker needs."]
|
|
4085
|
-
];
|
|
4086
4176
|
var text = typeof raw === "string" ? raw : "";
|
|
4087
4177
|
for(var i = 0; i < PLAN_CHECK_RULES.length; i++){
|
|
4088
|
-
if(PLAN_CHECK_RULES[i]
|
|
4178
|
+
if(new RegExp(PLAN_CHECK_RULES[i].re).test(text)) return {say: PLAN_CHECK_RULES[i].say === null ? text.replace(/^declaration: /, "") : PLAN_CHECK_RULES[i].say, raw: text};
|
|
4089
4179
|
}
|
|
4090
4180
|
return {say: "One of the checks on the plan failed.", raw: text};
|
|
4091
4181
|
}
|
|
@@ -4104,8 +4194,8 @@
|
|
|
4104
4194
|
function draftLines(fallback){
|
|
4105
4195
|
if(!state || !Array.isArray(state.stepList) || state.stepList.length === 0) return fallback();
|
|
4106
4196
|
state.stepList.forEach(function(st){
|
|
4107
|
-
var row = {id: st.id, label: st.label, status: st.status === "failed" ? "failed" : "done", details: st.details || []};
|
|
4108
|
-
if(
|
|
4197
|
+
var row = {id: st.id, label: st.label, status: st.status === "failed" ? "failed" : (st.status === "waiting" ? "waiting" : "done"), details: st.details || []};
|
|
4198
|
+
if(st.note === true) row.note = true;
|
|
4109
4199
|
out.push(row);
|
|
4110
4200
|
});
|
|
4111
4201
|
}
|
|
@@ -4119,11 +4209,18 @@
|
|
|
4119
4209
|
draftLines(function(){ out.push({id: "drafted", label: "drafted with " + who, status: "done", details: []}); });
|
|
4120
4210
|
var reviseNo = 0;
|
|
4121
4211
|
state.revises.forEach(function(rv){
|
|
4122
|
-
// an answer redraft (amendment 24 item 4) is not a revise and is not counted as one
|
|
4123
|
-
|
|
4212
|
+
// an answer redraft (amendment 24 item 4) is not a revise and is not counted as one; the server names each one (`rv.name`) and, from the plan's own log,
|
|
4213
|
+
// writes its line (`rv.lines`, src/draft-steps.js `reviseStepList`): one line, facts joined by " · ", a red one with one plain reason and a Fix line (am15)
|
|
4214
|
+
var label = rv.name || (rv.kind === "answers" ? "drafted again with your answers" : "revise " + (reviseNo += 1));
|
|
4124
4215
|
if(rv.phase === "running") out.push({id: "revise-" + rv.n, label: label, status: "running", details: []});
|
|
4125
|
-
else if(rv.
|
|
4126
|
-
|
|
4216
|
+
else if(Array.isArray(rv.lines) && rv.lines.length){
|
|
4217
|
+
rv.lines.forEach(function(l){
|
|
4218
|
+
var row = {id: "revise-" + rv.n + "-" + l.id, label: l.label, status: l.status === "failed" ? "failed" : "done", details: []};
|
|
4219
|
+
if(l.note === true) row.note = true;
|
|
4220
|
+
out.push(row);
|
|
4221
|
+
});
|
|
4222
|
+
}
|
|
4223
|
+
else out.push({id: "revise-" + rv.n, label: label, status: rv.phase === "green" ? "done" : "failed", details: []});
|
|
4127
4224
|
});
|
|
4128
4225
|
if(state.phase === "green"){
|
|
4129
4226
|
if(ctx.starting) out.push({id: "signed", label: "signed", status: "done", details: []});
|
|
@@ -4133,8 +4230,7 @@
|
|
|
4133
4230
|
} else if(state.phase === "red"){
|
|
4134
4231
|
draftLines(function(){
|
|
4135
4232
|
out.push({id: "drafted", label: "drafted with " + who, status: "done", details: []});
|
|
4136
|
-
|
|
4137
|
-
out.push({id: "checks", label: "plan checks", status: "failed", details: cf.details, raw: cf.raw});
|
|
4233
|
+
out.push({id: "checks", label: "plan checks", status: "failed", details: []}); // no log to read a reason from: the card's own sentence says it
|
|
4138
4234
|
});
|
|
4139
4235
|
} else if(state.phase === "stopped"){
|
|
4140
4236
|
out.push({id: "drafting", label: "drafting with " + who + capPart, status: "failed", details: []});
|
|
@@ -4358,23 +4454,33 @@
|
|
|
4358
4454
|
function jobHasModelStep(){
|
|
4359
4455
|
return byId("jf-job").value.split("\n").some(function(l){ var t = l.trim(); return t !== "" && t.charAt(0) !== "~" && !/^ask\b/i.test(t); });
|
|
4360
4456
|
}
|
|
4457
|
+
// M4d am21 item 3: with no step that needs a model the cap cannot be checked against one yet: a grey line says so (the New job card only)
|
|
4458
|
+
function paintCapJobNote(m){
|
|
4459
|
+
byId("jf-cap-job-note").textContent = (m === "new" && !jobHasModelStep()) ? "The cap is checked against the model once the job has a step." : "";
|
|
4460
|
+
}
|
|
4361
4461
|
function refreshCapNote(){
|
|
4462
|
+
paintCapJobNote(mode);
|
|
4362
4463
|
var cap = mode === "run" ? runCapEl.value.trim() : (mode === "resume" ? resumeCapEl.value.trim() : byId("jf-cap-money").value.trim());
|
|
4363
4464
|
var seq = ++capNoteSeq;
|
|
4364
4465
|
if(cap === ""){ setMoneyNote("", false); return; }
|
|
4365
4466
|
// a Resume holds only what the run has still to spend (amendment 4 item 1): the server is told what is already spent
|
|
4366
|
-
var spent = (mode === "resume" && resumeCtx) ? "&spent=" + encodeURIComponent(String(resumeCtx.form.spentUsd)) + "&flow=" + encodeURIComponent(resumeCtx.flow) : "";
|
|
4467
|
+
var spent = (mode === "resume" && resumeCtx) ? "&spent=" + encodeURIComponent(String(resumeCtx.form.spentUsd)) + "&flow=" + encodeURIComponent(resumeCtx.flow) + "&kind=run" : "";
|
|
4367
4468
|
var pk = modelPick();
|
|
4368
4469
|
var picked = (mode === "new" && pk.provider !== "") ? "&provider=" + encodeURIComponent(pk.provider) + "&model=" + encodeURIComponent(pk.model) : "";
|
|
4369
|
-
|
|
4470
|
+
// M4d am20: Run a signed flow does not draft: the server writes the same cap-too-small sentence with "run" (the flow's recorded model, else the one picked in Chat)
|
|
4471
|
+
var sfNow = selectedFlow();
|
|
4472
|
+
if(mode === "run" && sfNow) picked = "&kind=run&flow=" + encodeURIComponent(sfNow.flow) + (pk.provider !== "" ? "&provider=" + encodeURIComponent(pk.provider) + "&model=" + encodeURIComponent(pk.model) : "");
|
|
4473
|
+
// M4d am21 item 1: a card that belongs to a live draft (a revise, or the Start over about to be made) is checked for the pot left, as the doors do
|
|
4474
|
+
var ofDraft = (mode === "new" && sessionLive && sessionId) ? "&draft=" + encodeURIComponent(sessionId) : "";
|
|
4475
|
+
authorGet("/api/author/monthly-check?cap=" + encodeURIComponent(cap) + spent + picked + ofDraft).then(function(j){
|
|
4370
4476
|
if(seq !== capNoteSeq) return;
|
|
4371
4477
|
if(!j || j.ok !== true){ setMoneyNote("", false); return; }
|
|
4372
4478
|
var v = Number(cap);
|
|
4373
4479
|
if(mode === "new" && j.floorText && isFinite(v) && v > 0 && v < j.floorUsd && jobHasModelStep()){ setMoneyNote(j.floorText, true); return; }
|
|
4374
4480
|
// a Run's own cap is never judged against the floor (an old flow signed lower still runs plain); a changed cap below it is red
|
|
4375
4481
|
var sf = selectedFlow();
|
|
4376
|
-
if(mode === "run" && sf && j.floorText && isFinite(v) && v > 0 && v !== sf.capUsd && v < sf.capFloorUsd){ setMoneyNote(
|
|
4377
|
-
if(mode === "resume" && resumeCtx && j.floorText && isFinite(v) && v > resumeCtx.form.spentUsd && v < resumeCtx.form.floorUsd){ setMoneyNote(
|
|
4482
|
+
if(mode === "run" && sf && j.floorText && isFinite(v) && v > 0 && v !== sf.capUsd && v < sf.capFloorUsd){ setMoneyNote(j.floorText, true); return; }
|
|
4483
|
+
if(mode === "resume" && resumeCtx && j.floorText && isFinite(v) && v > resumeCtx.form.spentUsd && v < resumeCtx.form.floorUsd){ setMoneyNote(j.floorText, true); return; }
|
|
4378
4484
|
setMoneyNote(typeof j.text === "string" ? j.text : "", j.red === true);
|
|
4379
4485
|
}).catch(function(){ if(seq === capNoteSeq) setMoneyNote("", false); });
|
|
4380
4486
|
}
|
|
@@ -4420,6 +4526,7 @@
|
|
|
4420
4526
|
}
|
|
4421
4527
|
function syncCardLock(){
|
|
4422
4528
|
var on = cardLocked();
|
|
4529
|
+
whenSyncButton();
|
|
4423
4530
|
card.querySelectorAll("input[type=text], textarea").forEach(function(el){ el.readOnly = on; el.classList.toggle("locked", on); });
|
|
4424
4531
|
if(editOf !== null){ byId("jf-name").readOnly = true; byId("jf-name").classList.add("locked"); } // M6: an edit keeps its job's name
|
|
4425
4532
|
runFlowSel.disabled = on;
|
|
@@ -4482,7 +4589,8 @@
|
|
|
4482
4589
|
setMode("new");
|
|
4483
4590
|
setVal("jf-name", f.flow); setVal("jf-job", c.job); setVal("jf-cap-money", c.capUsd);
|
|
4484
4591
|
setVal("jf-dest-folder", c.destination); setVal("jf-inputs", c.inputs); setVal("jf-ask-wait", c.askWait || "1h");
|
|
4485
|
-
|
|
4592
|
+
// M9 am1: a job with a trigger is told, before it signs, that the edit clears the trigger back to By hand (the sentence is the server's)
|
|
4593
|
+
editBannerEl.textContent = "Editing \u201c" + f.flow + "\u201d. Draft it, read the new plan, then sign: signing replaces this job. Clear leaves it exactly as it was." + (f.trigger && f.trigger.editNote ? " " + f.trigger.editNote : "");
|
|
4486
4594
|
editBannerEl.hidden = false;
|
|
4487
4595
|
chatActionOk();
|
|
4488
4596
|
refreshCapNote(); fitCardBoxes(); refreshStartEnabled();
|
|
@@ -4525,7 +4633,101 @@
|
|
|
4525
4633
|
clearFieldErrors();
|
|
4526
4634
|
refreshCapNote();
|
|
4527
4635
|
syncEditBtn();
|
|
4636
|
+
paintWhen();
|
|
4637
|
+
}
|
|
4638
|
+
// ---- M9 piece 5: When [By hand v] on the Run card (ladder M9 item 1, item 2). One dropdown, no cron text. Changing it asks the server what
|
|
4639
|
+
// would be signed (click 1, signs nothing, returns a hash), click 2 signs it with that hash: the Run door's two clicks. $0, no drafter.
|
|
4640
|
+
// A job with no good run gets the dropdown refused with the SERVER's sentence (`trigger.refusal`); the page writes no sentence of its own.
|
|
4641
|
+
var whenHash = null;
|
|
4642
|
+
var whenBusy = false;
|
|
4643
|
+
var whenConfirmText = ""; // the words the button shows after click 1 ("every day at 13:15", "cancel schedule"); read only while whenHash is set
|
|
4644
|
+
var whenLocked = false; // ~1.5 s after a successful sign the main button is disabled, so a fast extra click cannot start a run
|
|
4645
|
+
var whenReady = false; // the lock sync can run before this block has
|
|
4646
|
+
function whenCanon(t){ return t === null ? "null" : JSON.stringify(Object.keys(t).sort().map(function(k){ return [k, t[k]]; })); }
|
|
4647
|
+
function whenTriggerFromBoxes(){
|
|
4648
|
+
var kind = byId("jf-when").value;
|
|
4649
|
+
if(kind === "hand") return null;
|
|
4650
|
+
if(kind === "daily" || kind === "weekdays" || kind === "weekly"){
|
|
4651
|
+
var m = /^(\d{2}):(\d{2})$/.exec(byId("jf-when-time").value);
|
|
4652
|
+
var o = m ? {kind: kind, hour: Number(m[1]), minute: Number(m[2])} : {kind: kind}; // an empty time goes to the server, which says so
|
|
4653
|
+
if(kind === "weekly") o.day = byId("jf-when-day").value;
|
|
4654
|
+
return o;
|
|
4655
|
+
}
|
|
4656
|
+
var q = {kind: kind, role: byId("jf-when-role").value};
|
|
4657
|
+
q[kind === "new-file" ? "folder" : "path"] = byId("jf-when-path").value.trim();
|
|
4658
|
+
return q;
|
|
4659
|
+
}
|
|
4660
|
+
function whenShowSubs(){
|
|
4661
|
+
var kind = byId("jf-when").value;
|
|
4662
|
+
byId("jf-when-clock").hidden = !(kind === "daily" || kind === "weekdays" || kind === "weekly");
|
|
4663
|
+
byId("jf-when-day").hidden = kind !== "weekly";
|
|
4664
|
+
byId("jf-when-filebox").hidden = !(kind === "file-updated" || kind === "new-file");
|
|
4665
|
+
byId("jf-when-path").placeholder = kind === "new-file" ? "/full/path/to/folder" : "/full/path/to/file";
|
|
4666
|
+
}
|
|
4667
|
+
// M9 am4: is When changed from the signed value? The ONE reader; the main button turns into Sign schedule while it is.
|
|
4668
|
+
function whenChanged(){
|
|
4669
|
+
if(!whenReady) return false;
|
|
4670
|
+
var f = selectedFlow();
|
|
4671
|
+
var c = f && f.trigger;
|
|
4672
|
+
return !!c && !c.refusal && whenCanon(whenTriggerFromBoxes()) !== whenCanon(c.trigger);
|
|
4673
|
+
}
|
|
4674
|
+
function whenSyncButton(){
|
|
4675
|
+
if(!whenReady) return;
|
|
4676
|
+
renderMain();
|
|
4677
|
+
}
|
|
4678
|
+
function paintWhen(){
|
|
4679
|
+
var f = selectedFlow();
|
|
4680
|
+
var c = f ? f.trigger : null;
|
|
4681
|
+
var sel = byId("jf-when");
|
|
4682
|
+
whenHash = null; whenBusy = false;
|
|
4683
|
+
byId("jf-err-when").textContent = "";
|
|
4684
|
+
var roleSel = byId("jf-when-role");
|
|
4685
|
+
roleSel.innerHTML = "";
|
|
4686
|
+
((f && f.roles) || []).forEach(function(r){ var o = document.createElement("option"); o.value = r; o.textContent = r; roleSel.appendChild(o); });
|
|
4687
|
+
var t = c ? c.trigger : null;
|
|
4688
|
+
sel.querySelector('option[value="hand"]').textContent = t ? "Cancel schedule" : "By hand"; // M9 am5: on a scheduled job, By hand reads Cancel schedule
|
|
4689
|
+
sel.value = t ? t.kind : "hand";
|
|
4690
|
+
if(t && t.hour !== undefined){ byId("jf-when-time").value = ("0" + t.hour).slice(-2) + ":" + ("0" + t.minute).slice(-2); }
|
|
4691
|
+
if(t && t.day) byId("jf-when-day").value = t.day;
|
|
4692
|
+
if(t && t.role) roleSel.value = t.role;
|
|
4693
|
+
byId("jf-when-path").value = t ? (t.path || t.folder || "") : "";
|
|
4694
|
+
var refused = !f || !c || !!c.refusal;
|
|
4695
|
+
sel.disabled = refused;
|
|
4696
|
+
byId("jf-when-day").disabled = byId("jf-when-time").disabled = roleSel.disabled = byId("jf-when-path").disabled = refused;
|
|
4697
|
+
byId("jf-when-now").textContent = !c ? "" : (c.refusal ? c.refusal : (c.words ? "Now: " + c.words : ""));
|
|
4698
|
+
whenShowSubs(); whenSyncButton();
|
|
4699
|
+
}
|
|
4700
|
+
function whenEdited(){ whenHash = null; byId("jf-err-when").textContent = ""; whenShowSubs(); whenSyncButton(); }
|
|
4701
|
+
["jf-when", "jf-when-day", "jf-when-time", "jf-when-role"].forEach(function(id){ document.getElementById(id).addEventListener("change", whenEdited); });
|
|
4702
|
+
document.getElementById("jf-when-path").addEventListener("input", whenEdited);
|
|
4703
|
+
function doWhenSign(){
|
|
4704
|
+
var f = selectedFlow();
|
|
4705
|
+
if(!f || whenBusy || cardLocked()) return;
|
|
4706
|
+
var body = {flow: f.flow, trigger: whenTriggerFromBoxes()};
|
|
4707
|
+
var second = whenHash !== null;
|
|
4708
|
+
if(second) body.hash = whenHash;
|
|
4709
|
+
whenBusy = true; whenSyncButton();
|
|
4710
|
+
authorPost(second ? "/api/author/trigger" : "/api/author/trigger-prepare", body).then(function(r){
|
|
4711
|
+
whenBusy = false;
|
|
4712
|
+
if(!(r.status >= 200 && r.status < 300 && r.body && r.body.ok === true)){
|
|
4713
|
+
whenHash = null; byId("jf-err-when").textContent = refusalText(r); whenSyncButton(); return;
|
|
4714
|
+
}
|
|
4715
|
+
var words = typeof r.body.words === "string" ? r.body.words : "";
|
|
4716
|
+
if(!second){
|
|
4717
|
+
whenHash = r.body.hash;
|
|
4718
|
+
whenConfirmText = words ? words.charAt(0).toLowerCase() + words.slice(1) : "cancel schedule";
|
|
4719
|
+
byId("jf-err-when").textContent = ""; whenSyncButton(); return;
|
|
4720
|
+
}
|
|
4721
|
+
// M9 am5: after click 2 the card clears (like Clear) and nothing runs; the signed schedule is read back by the flows list
|
|
4722
|
+
whenHash = null;
|
|
4723
|
+
whenLocked = true; setTimeout(function(){ whenLocked = false; renderMain(); }, 1500);
|
|
4724
|
+
var say = typeof r.body.say === "string" ? r.body.say : "";
|
|
4725
|
+
resetCard();
|
|
4726
|
+
setMode("new"); // the default empty card a fresh page load shows, not Run a signed flow with the pick emptied
|
|
4727
|
+
if(say) chatActionFailed(say);
|
|
4728
|
+
}).catch(function(){ whenBusy = false; whenHash = null; byId("jf-err-when").textContent = NETWORK_SAY; whenSyncButton(); });
|
|
4528
4729
|
}
|
|
4730
|
+
whenReady = true;
|
|
4529
4731
|
// borrowed-from: bareloop src/panel/index.html@b5e37b8 — the Reuse workflow picker: ONE function shows the search box + list before a pick and the
|
|
4530
4732
|
// picked box after; a row is the name (the typed part marked) over the flow's track record line.
|
|
4531
4733
|
function rwMark(name, q){
|
|
@@ -4682,7 +4884,9 @@
|
|
|
4682
4884
|
progressRow.hidden = steps.length === 0;
|
|
4683
4885
|
var html = steps.map(function(st){
|
|
4684
4886
|
var cls = st.status === "waiting" ? "wait" : (st.status === "running" ? "run" : (st.status === "failed" ? "bad" : "ok"));
|
|
4685
|
-
var sign = cls === "ok" ? "✓" : (cls === "bad" ? "✗" : "");
|
|
4887
|
+
var sign = st.note ? "" : (cls === "ok" ? "✓" : (cls === "bad" ? "✗" : ""));
|
|
4888
|
+
// M4d am15: a line with no ✓/✗ (the Fix line under a red plan check)
|
|
4889
|
+
if(st.note) cls += " note";
|
|
4686
4890
|
return '<li class="step ' + cls + '" data-step="' + escapeXml(st.id) + '"><div class="step-line"><span class="step-label">' + escapeXml(st.label) + '</span>' +
|
|
4687
4891
|
'<span class="step-sign">' + sign + '</span></div>' +
|
|
4688
4892
|
(st.details || []).map(function(d, k){
|
|
@@ -4755,6 +4959,12 @@
|
|
|
4755
4959
|
st.runDiffers = runDiffers();
|
|
4756
4960
|
st.runSignClicked = !!runSignInfo;
|
|
4757
4961
|
st.hash = runSignInfo ? runSignInfo.hash : "";
|
|
4962
|
+
st.whenChanged = whenChanged();
|
|
4963
|
+
st.whenSigning = whenHash !== null;
|
|
4964
|
+
st.whenConfirm = whenHash !== null ? whenConfirmText : "";
|
|
4965
|
+
st.whenCancel = whenTriggerFromBoxes() === null;
|
|
4966
|
+
st.whenBusy = whenBusy;
|
|
4967
|
+
st.whenLocked = whenLocked;
|
|
4758
4968
|
} else if(mode === "resume"){
|
|
4759
4969
|
st.capUsd = resumeCapEl.value.trim();
|
|
4760
4970
|
st.runSignClicked = !!resumeSignInfo;
|
|
@@ -4770,6 +4980,8 @@
|
|
|
4770
4980
|
mainAction = b.action; mainStartOver = !!b.startOver;
|
|
4771
4981
|
// amendment 14 item 3: the count shows while a draft has revises to count; at 0 the way on is Start over
|
|
4772
4982
|
mainHint.textContent = (mode === "new" && sessionLive && st.revisable && st.phase !== "signed" && st.phase !== "questions-open") ? (st.left > 0 ? revisesLeftText(st.left) : "No revises left: Start over keeps the fields and gives 2 new ones.") : "";
|
|
4983
|
+
// M4d am16 item 3: the first Sign click shows how the card's Cap $ is split between drafting and this run, before the second click starts it
|
|
4984
|
+
if(mode === "new" && sessionLive && signInfo && signInfo.split && signClickedOnce) mainHint.textContent = signInfo.split.line;
|
|
4773
4985
|
reviseBtn.hidden = !reviseShownFor(st);
|
|
4774
4986
|
reviseBtn.disabled = !!st.busy;
|
|
4775
4987
|
startOverBtn.hidden = !startOverShownFor(st);
|
|
@@ -5063,7 +5275,7 @@
|
|
|
5063
5275
|
var o = chatPostOutcome(r);
|
|
5064
5276
|
if(!o.ok){ failFrom(r); refreshStartEnabled(); return; }
|
|
5065
5277
|
chatActionOk();
|
|
5066
|
-
signInfo = {hash: r.body.hash, flowName: r.body.flowName, capUsd: r.body.capUsd, runId: r.body.runId};
|
|
5278
|
+
signInfo = {hash: r.body.hash, flowName: r.body.flowName, capUsd: r.body.capUsd, runId: r.body.runId, split: r.body.split || null};
|
|
5067
5279
|
signClickedOnce = true;
|
|
5068
5280
|
if(lastState) renderActions(lastState); else refreshStartEnabled();
|
|
5069
5281
|
}).catch(function(){ busy = false; chatActionFailed(NETWORK_SAY); refreshStartEnabled(); });
|
|
@@ -5175,6 +5387,7 @@
|
|
|
5175
5387
|
mainBtn.addEventListener("click", function(){
|
|
5176
5388
|
if(mainBtn.disabled) return;
|
|
5177
5389
|
if(mainAction === "draft") doDraft(mainStartOver ? sessionId : null);
|
|
5390
|
+
else if(mainAction === "when-sign-prepare" || mainAction === "when-sign") doWhenSign();
|
|
5178
5391
|
else if(mainAction === "run") doRun();
|
|
5179
5392
|
else if(mainAction === "run-sign-prepare" || mainAction === "run-sign") doRunSign();
|
|
5180
5393
|
else if(mainAction === "resume-sign-prepare" || mainAction === "resume-sign") doResumeSign();
|