fwdloop 0.12.0 → 0.14.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/bin/fwdloop +155 -27
- package/package.json +2 -2
- package/src/ask.js +3 -0
- package/src/authoring.js +135 -16
- package/src/books.js +23 -2
- package/src/canrun.js +106 -0
- package/src/catalogue.json +2 -2
- package/src/checked.js +50 -0
- package/src/closers.js +112 -91
- package/src/config.js +2 -1
- package/src/declaration.js +175 -3
- package/src/drafter.js +148 -10
- package/src/draftspend.js +70 -0
- package/src/flow.js +43 -0
- package/src/keysfile.js +4 -2
- package/src/liveness.js +1 -1
- package/src/model-step.js +31 -5
- package/src/monthly.js +195 -28
- package/src/panel/author.js +638 -0
- package/src/panel/authorcard.js +340 -0
- package/src/panel/authorflows.js +317 -0
- package/src/panel/authorresume.js +149 -0
- package/src/panel/authorstart.js +257 -0
- package/src/panel/authorvalues.js +110 -0
- package/src/panel/data.js +318 -99
- package/src/panel/index.html +2000 -330
- package/src/panel/resume.js +6 -8
- package/src/panel/server.js +122 -119
- package/src/panel/settings.js +8 -6
- package/src/panel/spawn.js +77 -0
- package/src/provider.js +12 -17
- package/src/runner.js +707 -104
- package/src/runvalues.js +178 -0
- package/src/send.js +10 -3
- package/src/setup.js +127 -0
- package/types/authoring.d.ts +56 -2
- package/types/books.d.ts +14 -2
- package/types/canrun.d.ts +64 -0
- package/types/checked.d.ts +23 -0
- package/types/closers.d.ts +47 -28
- package/types/config.d.ts +1 -0
- package/types/declaration.d.ts +23 -1
- package/types/drafter.d.ts +151 -2
- package/types/draftspend.d.ts +21 -0
- package/types/flow.d.ts +23 -0
- package/types/liveness.d.ts +2 -2
- package/types/model-step.d.ts +4 -7
- package/types/monthly.d.ts +46 -1
- package/types/panel/author.d.ts +316 -0
- package/types/panel/authorcard.d.ts +142 -0
- package/types/panel/authorflows.d.ts +175 -0
- package/types/panel/authorresume.d.ts +32 -0
- package/types/panel/authorstart.d.ts +115 -0
- package/types/panel/authorvalues.d.ts +62 -0
- package/types/panel/data.d.ts +105 -63
- package/types/panel/server.d.ts +11 -33
- package/types/panel/spawn.d.ts +30 -0
- package/types/provider.d.ts +6 -9
- package/types/runner.d.ts +129 -6
- package/types/runvalues.d.ts +97 -0
- package/types/send.d.ts +5 -1
- package/types/setup.d.ts +77 -0
package/src/panel/index.html
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
the CSS is harmless dead weight rather than a second stylesheet to maintain). */
|
|
25
25
|
:root{
|
|
26
26
|
--bg:#1a1b26; --panel:#1f2335; --panel2:#24283b; --border:#292e42; --border-strong:#3b4261;
|
|
27
|
-
--text:#c0caf5; --text-dim:#a9b1d6; --text-faint:#565f89;
|
|
27
|
+
--text:#c0caf5; --text-dim:#a9b1d6; --text-faint:#565f89; --plan:#7aa2f7;
|
|
28
28
|
--green:#9ece6a; --green-bg:#1c2b23;
|
|
29
29
|
--red:#f7768e; --red-bg:#2b1822;
|
|
30
30
|
--amber:#e0af68; --amber-bg:#2b2416;
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
--magenta:#bb9af7;
|
|
34
34
|
--accent:#7aa2f7;
|
|
35
35
|
--btn-bg:#1f2335; --btn-text:#c0caf5;
|
|
36
|
+
--field-bg:var(--bg); --field-soft-bg:var(--bg); --field-border:var(--text-dim);
|
|
36
37
|
--primary-bg:#7aa2f7; --primary-text:#1a1b26; --primary-border:#7aa2f7;
|
|
37
38
|
font: 14px/1.5 "Courier Prime", "Courier New", Courier, ui-monospace, monospace;
|
|
38
39
|
}
|
|
@@ -65,7 +66,7 @@
|
|
|
65
66
|
@media (prefers-color-scheme: light){
|
|
66
67
|
:root:not([data-theme="dark"]){
|
|
67
68
|
--bg:#e1e2e7; --panel:#d0d5e3; --panel2:#e9e9ed; --border:#c4c8da; --border-strong:#a8b0cc;
|
|
68
|
-
--text:#3760bf; --text-dim:#58679f; --text-faint:#848cb5;
|
|
69
|
+
--text:#3760bf; --text-dim:#58679f; --text-faint:#848cb5; --plan:#2668c2;
|
|
69
70
|
--green:#567238; --green-bg:#dfe7d4;
|
|
70
71
|
--red:#c92353; --red-bg:#fbe0e8;
|
|
71
72
|
--amber:#82643a; --amber-bg:#f0e6d3;
|
|
@@ -74,12 +75,13 @@
|
|
|
74
75
|
--magenta:#9854f1;
|
|
75
76
|
--accent:#2668c2;
|
|
76
77
|
--btn-bg:#e9e9ed; --btn-text:#3760bf;
|
|
78
|
+
--field-bg:#ffffff; --field-soft-bg:#f7f7f9;
|
|
77
79
|
--primary-bg:#2668c2; --primary-text:#e1e2e7; --primary-border:#2668c2;
|
|
78
80
|
}
|
|
79
81
|
}
|
|
80
82
|
:root[data-theme="light"]{
|
|
81
83
|
--bg:#e1e2e7; --panel:#d0d5e3; --panel2:#e9e9ed; --border:#c4c8da; --border-strong:#a8b0cc;
|
|
82
|
-
--text:#3760bf; --text-dim:#58679f; --text-faint:#848cb5;
|
|
84
|
+
--text:#3760bf; --text-dim:#58679f; --text-faint:#848cb5; --plan:#2668c2;
|
|
83
85
|
--green:#567238; --green-bg:#dfe7d4;
|
|
84
86
|
--red:#c92353; --red-bg:#fbe0e8;
|
|
85
87
|
--amber:#82643a; --amber-bg:#f0e6d3;
|
|
@@ -88,6 +90,7 @@
|
|
|
88
90
|
--magenta:#9854f1;
|
|
89
91
|
--accent:#2668c2;
|
|
90
92
|
--btn-bg:#e9e9ed; --btn-text:#3760bf;
|
|
93
|
+
--field-bg:#ffffff; --field-soft-bg:#f7f7f9;
|
|
91
94
|
--primary-bg:#2668c2; --primary-text:#e1e2e7; --primary-border:#2668c2;
|
|
92
95
|
}
|
|
93
96
|
.theme-toggle{padding:4px 9px;min-height:32px;border:1px solid var(--border-strong);background:var(--btn-bg);color:var(--text);}
|
|
@@ -157,6 +160,11 @@
|
|
|
157
160
|
/* M4c amendment 2: stuck — answer saved, nobody carrying the run on. Its own glyph,
|
|
158
161
|
amber like the other "needs you" signs; it pulses (server-decided, glyphPulses). */
|
|
159
162
|
.dot.stuck::before{content:"[II]";color:var(--amber);}
|
|
163
|
+
/* M4e amendment 4: stopped — by you, or at the money cap; Resume goes on. Grey like the other quiet end, never the red [✗]. */
|
|
164
|
+
.dot.stopped::before{content:"[■]";color:var(--grey-dot);}
|
|
165
|
+
/* the Run tab's top action row (Stop, Resume) */
|
|
166
|
+
.run-actions{display:flex;flex-wrap:wrap;gap:8px;align-items:center;margin-bottom:8px;}
|
|
167
|
+
.run-actions .answer-msg{margin-top:0;flex:1 1 100%;}
|
|
160
168
|
/* M4c: only the two "alive" signs pulse — [▶] running and [·] waiting on
|
|
161
169
|
you — keyed to `.pulse`, which the server decides (glyphPulses), never to
|
|
162
170
|
a colour class (.grey is also the placeholder dot). A gentle opacity wave on the existing colors;
|
|
@@ -186,6 +194,7 @@
|
|
|
186
194
|
.badge.cyan{color:var(--cyan);}
|
|
187
195
|
|
|
188
196
|
.hint{font-size:11px;color:var(--text-faint);margin-top:4px;}
|
|
197
|
+
.hint.money-red{color:var(--red);}
|
|
189
198
|
.btn{padding:8px 14px;min-height:44px;border:1px solid var(--border-strong);background:var(--panel2);color:var(--text);white-space:nowrap;flex:none;position:relative;}
|
|
190
199
|
.btn::before{content:"[ ";color:var(--text-faint);}
|
|
191
200
|
.btn::after{content:" ]";color:var(--text-faint);}
|
|
@@ -227,11 +236,11 @@
|
|
|
227
236
|
the same behavior fix #7 already gave phone width alone. */
|
|
228
237
|
.wf-meta-line{white-space:normal;overflow:visible;text-overflow:clip;min-width:0;}
|
|
229
238
|
/* M4c-fix amendment 2 (g), line 2 of a run row: **word** — plain why. Wraps, never clips. */
|
|
230
|
-
.wf-sign-line{font-size:12px;color:var(--text-dim);white-space:normal;overflow-wrap:anywhere;
|
|
239
|
+
.wf-sign-line{font-size:12px;color:var(--text-dim);white-space:normal;overflow-wrap:anywhere;}
|
|
231
240
|
.wf-sign-line .sign-word,.hdr-verdict .sign-word{color:var(--text);}
|
|
232
241
|
.hdr-verdict{font-size:12px;color:var(--text-dim);min-width:0;overflow-wrap:anywhere;}
|
|
233
242
|
.wf-meta{font-size:12px;color:var(--text-dim);}
|
|
234
|
-
.wf-
|
|
243
|
+
.wf-sep{font-size:12px;color:var(--text-faint);}
|
|
235
244
|
.wf-row.selected,.hist-row.selected{border:2px solid var(--accent);border-radius:4px;}
|
|
236
245
|
/* item 2 (2026-09-26 merge): a Workflows-view job row expands inline to
|
|
237
246
|
list ALL its runs (build spec's own design) — the caret glyph on the
|
|
@@ -280,13 +289,24 @@
|
|
|
280
289
|
.sum-val{color:var(--text);}
|
|
281
290
|
.summary-box .num{color:var(--accent);font-weight:700;}
|
|
282
291
|
|
|
283
|
-
/*
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
.map-box{border:1px solid var(--border-strong);padding:10px;overflow-x:auto;margin-top:16px;margin-bottom:14px;background:var(--panel2);text-align:center;}
|
|
292
|
+
/* borrowed-from: bareloop src/panel/index.html@9edb3e1 (on d25e52a) — boxes as wide as their own text, side by side,
|
|
293
|
+
wrapping; a name is never cut. A box + its trailing arrow are ONE unit (the arrow never wraps alone); the lead arrow
|
|
294
|
+
of a wrapped line hangs in the container's left padding (absolute, zero layout impact — toggling it moves nothing). */
|
|
295
|
+
.map-box{border:1px solid var(--border-strong);padding:10px;margin-top:16px;margin-bottom:14px;background:var(--panel2);}
|
|
288
296
|
.map-box::before{content:"┤ MAP ├";display:block;font-size:11px;color:var(--text-faint);letter-spacing:0.08em;margin:-2px 0 8px 0;}
|
|
289
|
-
.map-
|
|
297
|
+
.map-chips{display:flex;flex-wrap:wrap;gap:8px 4px;align-items:flex-start;padding-left:1.4em;}
|
|
298
|
+
.map-item{position:relative;display:inline-flex;align-items:center;gap:4px;max-width:100%;}
|
|
299
|
+
.map-arrow{color:var(--text-dim);font-size:13px;flex:none;}
|
|
300
|
+
.map-lead{display:none;position:absolute;left:-1.3em;top:50%;transform:translateY(-50%);color:var(--text-dim);font-size:13px;}
|
|
301
|
+
.map-item.line-start .map-lead{display:block;}
|
|
302
|
+
.map-chip{display:flex;flex-direction:column;align-items:flex-start;width:auto;max-width:100%;min-width:0;box-sizing:border-box;font:inherit;font-size:12px;line-height:1.4;text-align:left;padding:4px 8px;border:2px solid var(--border-strong);border-radius:0;background:var(--panel2);color:var(--text);white-space:normal;overflow-wrap:anywhere;cursor:pointer;}
|
|
303
|
+
.map-chip .chip-state{font-size:10px;color:var(--text-faint);}
|
|
304
|
+
.map-chip.s-done{border-color:var(--green);} .map-chip.s-done .chip-state{color:#2e7d32;}
|
|
305
|
+
.map-chip.s-stopped{border-color:var(--red);} .map-chip.s-stopped .chip-state{color:var(--red);}
|
|
306
|
+
.map-chip.s-waiting{border-color:var(--amber);} .map-chip.s-waiting .chip-state{color:#b8860b;}
|
|
307
|
+
.map-chip.s-user-stopped{border-color:var(--grey-dot);} .map-chip.s-user-stopped .chip-state{color:var(--grey-dot);}
|
|
308
|
+
.map-chip .chip-retry{font-size:10px;color:var(--text-faint);}
|
|
309
|
+
.map-chip.retry{border-style:dashed;} /* borrowed-from: bareloop src/panel/index.html@9edb3e1 */
|
|
290
310
|
|
|
291
311
|
.step-card{position:relative;border:1px solid var(--border);padding:10px;margin-bottom:8px;background:var(--panel2);}
|
|
292
312
|
.step-card.running{border:1px double var(--amber);}
|
|
@@ -296,7 +316,7 @@
|
|
|
296
316
|
`[✓]`, so it draws no second pair of brackets (`.sign-badge`). */
|
|
297
317
|
.step-card .step-head{display:flex;align-items:center;justify-content:space-between;gap:8px;flex-wrap:wrap;text-transform:none;font-weight:700;}
|
|
298
318
|
.step-card h4{margin:0;font-size:13px;text-transform:none;letter-spacing:normal;}
|
|
299
|
-
.
|
|
319
|
+
.sign-badge::before,.sign-badge::after{content:none;}
|
|
300
320
|
/* Every OTHER line on the card (goal, actions, granted, stopped reason) —
|
|
301
321
|
lower case exactly as the data reads, normal weight; never inherits the
|
|
302
322
|
header's uppercase/bold (same ruling, the non-header half of it). */
|
|
@@ -342,7 +362,8 @@
|
|
|
342
362
|
.audit-group h4::before{content:"┤ ";color:var(--text-faint);}
|
|
343
363
|
.audit-group h4::after{content:" ├";color:var(--text-faint);}
|
|
344
364
|
/* hamr's 2026-09-27 review: the Audit-group's own state header ("[done] ·
|
|
345
|
-
step · ...", built by buildAuditGroupHeaderEl)
|
|
365
|
+
step · ...", built by buildAuditGroupHeaderEl): M4e amendment 10 made its STATUS bold (the `> .badge`,
|
|
366
|
+
weight 700); the rest of the line stays normal — a plain h4
|
|
346
367
|
is bold by default, so its own class (`.audit-status-header`, NOT the
|
|
347
368
|
shared `.audit-group h4`, which the Ask tab's `.ask-question-heading`
|
|
348
369
|
h4 also matches and must stay bold per review #3) overrides it back to
|
|
@@ -350,6 +371,7 @@
|
|
|
350
371
|
`.audit-group h4` (0,1,1) and `.ask-question-heading` (0,1,0) alone, so
|
|
351
372
|
this never un-bolds the ask question heading. */
|
|
352
373
|
.audit-group h4.audit-status-header{font-weight:400;}
|
|
374
|
+
.audit-group h4.audit-status-header > .badge{font-weight:700;}
|
|
353
375
|
/* M4c-fix amendment 2 (f): a foldable step group. The header sits IN the box (not pinned over its top edge),
|
|
354
376
|
so a long header wraps inside its own box and never lands on the next group; a closed group is that one
|
|
355
377
|
header line with a caret and no empty table under it. */
|
|
@@ -359,6 +381,7 @@
|
|
|
359
381
|
.audit-group.audit-fold h4.audit-status-header > .badge,.audit-group.audit-fold h4.audit-status-header::before{flex:none;white-space:pre;}
|
|
360
382
|
.audit-fold-name{flex:0 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
|
|
361
383
|
.audit-fold-tail{flex:none;white-space:nowrap;}
|
|
384
|
+
.audit-fold-dot{flex:none;}
|
|
362
385
|
.audit-group.audit-fold h4.audit-status-header::before{content:"\25B6 ";color:var(--text-faint);}
|
|
363
386
|
.audit-group.audit-fold h4.audit-status-header[aria-expanded="true"]::before{content:"\25BC ";}
|
|
364
387
|
.audit-group.audit-fold h4.audit-status-header::after{content:none;}
|
|
@@ -369,8 +392,13 @@
|
|
|
369
392
|
.audit-group.audit-fold h4.audit-status-header > .badge{padding-left:0;padding-right:0;font-size:10px;}
|
|
370
393
|
.audit-group.audit-fold h4.audit-status-header::before{content:"\25B6";}
|
|
371
394
|
.audit-group.audit-fold h4.audit-status-header[aria-expanded="true"]::before{content:"\25BC";}
|
|
372
|
-
.audit-fold-sep
|
|
373
|
-
.audit-fold-
|
|
395
|
+
.audit-fold-sep{display:none;}
|
|
396
|
+
.audit-fold-try{margin-left:.4em;} /* the cost and the try count never touch: "$0.0010" + "1" must not read $0.00101 */
|
|
397
|
+
/* the tail wraps inside the header (never spills or is cut): it may break at its spaces and shrink */
|
|
398
|
+
.audit-fold-tail{flex:0 1 auto;min-width:0;max-width:100%;white-space:normal;overflow-wrap:anywhere;}
|
|
399
|
+
/* a narrow header WRAPS (amendment 7 walk): the name keeps a readable line of its own and the tail drops under it, never a one-letter name */
|
|
400
|
+
.audit-group.audit-fold h4.audit-status-header{flex-wrap:wrap;row-gap:2px;}
|
|
401
|
+
.audit-fold-name{flex:0 1 auto;max-width:100%;white-space:normal;overflow:visible;text-overflow:clip;overflow-wrap:anywhere;}
|
|
374
402
|
}
|
|
375
403
|
.audit-group.audit-fold table{margin-top:8px;}
|
|
376
404
|
.audit-group.audit-fold table[hidden]{display:none !important;}
|
|
@@ -409,11 +437,141 @@
|
|
|
409
437
|
line) so it reads as a clear, bold heading without a second border. */
|
|
410
438
|
.ask-question-heading{margin:6px 0 0;font-size:13px;font-weight:700;color:var(--text);}
|
|
411
439
|
.ro-value{padding:6px 8px;min-height:32px;box-sizing:border-box;border:1px solid var(--border);background:var(--bg);color:var(--text-dim);}
|
|
440
|
+
.art-head{color:var(--accent);}
|
|
441
|
+
.ro-value.sub{margin-left:20px;min-height:0;padding-top:2px;padding-bottom:2px;border-top-width:0;overflow-wrap:anywhere;}
|
|
442
|
+
/* M4e amendment 37 (changes 34's layout): the Job tab is ONE column at every width. Each signed line, its ~ rows, then its step(s) folded under it:
|
|
443
|
+
a native <details> whose <summary> is one short line in the text colour with a › / ⌄ marker in the plan colour; open, it shows reads / makes / may do / check. */
|
|
444
|
+
.job-line{margin-bottom:6px;}
|
|
445
|
+
.plan-fold{margin:0 0 0 20px;min-width:0;overflow-wrap:anywhere;}
|
|
446
|
+
.plan-sum{color:var(--text);cursor:pointer;list-style:none;padding:3px 0;font-size:12px;}
|
|
447
|
+
.plan-sum::-webkit-details-marker{display:none;}
|
|
448
|
+
.plan-sum::before{content:"› ";color:var(--plan);font-weight:700;}
|
|
449
|
+
.plan-fold[open] > .plan-sum::before{content:"⌄ ";}
|
|
450
|
+
.plan-legend{color:var(--text-dim);font-size:12px;margin-top:12px;overflow-wrap:anywhere;}
|
|
451
|
+
.plan-legend .plan-mark{color:var(--plan);font-weight:700;}
|
|
452
|
+
.plan-fold .plan-head,.plan-fold .plan-row{color:var(--text-dim);}
|
|
453
|
+
.plan-fold .plan-head{font-weight:400;}
|
|
454
|
+
.plan-fold .plan-row{padding-left:12px;}
|
|
455
|
+
#details-plan-tail{margin-bottom:16px;}
|
|
412
456
|
.ro-value.scroll{max-height:160px;overflow-y:auto;white-space:pre-wrap;word-break:break-word;}
|
|
413
457
|
.field-row{display:flex;flex-wrap:wrap;gap:10px;}
|
|
414
458
|
.field-row .field{flex:1 1 140px;margin-bottom:10px;}
|
|
415
459
|
|
|
416
|
-
|
|
460
|
+
/* borrowed-from: bareloop src/panel/index.html@ca7195e — the Chat card's CSS (job card, radio row, cap row, the one progress
|
|
461
|
+
list, the ask box, the one wide button, field colours, .locked, the one focus rule). fwdloop's own tokens win where both define
|
|
462
|
+
one; the global `input,select` rule is scoped to #panel-chat so no other panel box is restyled. */
|
|
463
|
+
#panel-chat input,#panel-chat select{font:inherit;padding:6px 8px;border:1px solid var(--border-strong);border-radius:0;background:var(--bg);color:var(--text);}
|
|
464
|
+
#panel-chat input::placeholder,#panel-chat textarea::placeholder{color:var(--text-faint);}
|
|
465
|
+
.job-card .card-clear{position:absolute;top:-13px;right:10px;padding:1px 8px;font-size:11px;line-height:1.4;background:var(--panel2);}
|
|
466
|
+
.job-card .locked{opacity:.55;cursor:not-allowed;}
|
|
467
|
+
.field input,.field select{width:100%;}
|
|
468
|
+
.job-card.compact{padding:14px 8px 8px;}
|
|
469
|
+
.job-card.compact .field{margin-bottom:6px;}
|
|
470
|
+
.job-card.compact label{margin-bottom:1px;font-size:11px;}
|
|
471
|
+
.job-card.compact input,
|
|
472
|
+
.job-card.compact select{padding:5px 7px;}
|
|
473
|
+
.radio-row{display:flex;flex-wrap:wrap;gap:6px 14px;align-items:center;margin-bottom:10px;}
|
|
474
|
+
.radio-row label{display:flex;align-items:center;gap:5px;font-size:13px;color:var(--text);margin:0;text-transform:none;}
|
|
475
|
+
.radio-row input{width:auto;}
|
|
476
|
+
@media (max-width:400px){.job-card .radio-row{padding-right:76px;}}
|
|
477
|
+
.cap-row{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:6px;margin-bottom:6px;}
|
|
478
|
+
.cap-field label{display:block;font-size:11px;font-weight:700;color:var(--text-dim);margin-bottom:1px;}
|
|
479
|
+
.cap-field input{width:100%;padding:5px 6px;box-sizing:border-box;}
|
|
480
|
+
.btn.primary{background:var(--primary-bg);color:var(--primary-text);border-color:var(--primary-border);font-weight:700;}
|
|
481
|
+
.btn.primary::before,.btn.primary::after{color:var(--primary-text);opacity:0.6;}
|
|
482
|
+
#panel-chat .btn:disabled{opacity:0.5;cursor:not-allowed;}
|
|
483
|
+
.btn.primary:disabled{background:var(--btn-bg);color:var(--text-faint);border-color:var(--border);}
|
|
484
|
+
.btn.primary:disabled::before,.btn.primary:disabled::after{color:var(--text-faint);opacity:0.4;}
|
|
485
|
+
#chat-action-error:empty{display:none;}
|
|
486
|
+
#chat-action-error{font-size:12px;color:var(--red);margin:4px 0;overflow-wrap:anywhere;white-space:pre-wrap;}
|
|
487
|
+
#chat-card-error:empty{display:none;}
|
|
488
|
+
#chat-card-error{overflow-wrap:anywhere;white-space:pre-wrap;}
|
|
489
|
+
|
|
490
|
+
/* the ONE progress list: a step per line — label, then dots while running / check / cross, then its reason */
|
|
491
|
+
.chat-steps{list-style:none;margin:2px 0 10px;padding:0;font-size:12px;}
|
|
492
|
+
.chat-steps .step{padding:1px 0;}
|
|
493
|
+
.chat-steps .step-line{display:flex;flex-wrap:wrap;align-items:baseline;gap:0 10px;}
|
|
494
|
+
.chat-steps .step-label{color:var(--text);min-width:11em;overflow-wrap:anywhere;}
|
|
495
|
+
.chat-steps .step-sign{font-weight:700;}
|
|
496
|
+
.chat-steps .step.run .step-sign{color:var(--amber);}
|
|
497
|
+
.chat-steps .step.ok .step-sign{color:var(--green);}
|
|
498
|
+
.chat-steps .step.bad .step-sign{color:var(--red);}
|
|
499
|
+
.chat-steps .step.wait .step-label{color:var(--amber);}
|
|
500
|
+
.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
|
+
.chat-steps .step.bad .step-detail{color:var(--red);}
|
|
502
|
+
.chat-steps .step.run .step-sign::after{content:"\2026";}
|
|
503
|
+
@keyframes step-dots{0%{content:"";}25%{content:".";}50%{content:"..";}75%{content:"...";}}
|
|
504
|
+
@media (prefers-reduced-motion: no-preference){
|
|
505
|
+
.chat-steps .step.run .step-sign::after{content:"";animation:step-dots 1.2s steps(1,end) infinite;}
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
.chat-thread{display:flex;flex-direction:column;gap:10px;margin-bottom:10px;}
|
|
509
|
+
.chat-thread:empty{display:none;}
|
|
510
|
+
.msg{padding:8px 10px;border:1px solid var(--border);max-width:100%;background:var(--panel2);font-size:13px;word-break:break-word;white-space:pre-wrap;}
|
|
511
|
+
.msg.bot{border-left:3px solid var(--border-strong);}
|
|
512
|
+
/* M4e amendments 24/25: the question the plan raised (one at a time), then Your answers / Checked / Not checked beside the plan */
|
|
513
|
+
.chat-question{border:1px solid var(--border);border-left:3px solid var(--amber);background:var(--panel2);padding:8px 10px;margin-bottom:10px;max-width:100%;box-sizing:border-box;}
|
|
514
|
+
.chat-question .q-head{font-size:11px;color:var(--text-faint);}
|
|
515
|
+
.chat-question .q-line{font-size:12px;color:var(--text-faint);margin-top:4px;overflow-wrap:anywhere;}
|
|
516
|
+
.chat-question .q-text{font-size:13px;margin-top:4px;overflow-wrap:anywhere;white-space:pre-wrap;}
|
|
517
|
+
.chat-question textarea{display:block;width:100%;max-width:100%;box-sizing:border-box;margin-top:8px;min-height:3.4em;font:inherit;padding:6px 8px;border:1px solid var(--border-strong);border-radius:0;background:var(--bg);color:var(--text);resize:vertical;}
|
|
518
|
+
.chat-question .q-err{color:var(--red);}
|
|
519
|
+
.chat-extras{display:flex;flex-direction:column;gap:10px;margin-bottom:10px;}
|
|
520
|
+
.chat-extras:empty{display:none;}
|
|
521
|
+
.msg.bot .who::before{content:"$ ";}
|
|
522
|
+
.msg .who{font-size:11px;color:var(--text-faint);margin-bottom:3px;text-transform:none;font-weight:400;}
|
|
523
|
+
/* the card's free-text boxes wrap (textarea): grow a few rows (fitBox), then scroll inside */
|
|
524
|
+
.job-card textarea.jf-wrap{width:100%;box-sizing:border-box;font:inherit;padding:6px 8px;border:1px solid var(--border-strong);border-radius:0;background:var(--bg);color:var(--text);resize:vertical;overflow-y:auto;max-height:200px;}
|
|
525
|
+
/* the focused/selected Chat-card field gets a blue border (the accent), no outline ring */
|
|
526
|
+
#panel-chat :is(input,select,textarea):focus{border-color:var(--accent);outline:none;}
|
|
527
|
+
/* amendment 2: the job and inputs boxes have a gutter OUTSIDE them on the left (`N >` per step, `~` per guardrail; a number per input
|
|
528
|
+
line), one entry per logical line, as tall as that line wraps (measured from a hidden mirror, see paintGutter) */
|
|
529
|
+
.jf-gutbox{position:relative;display:flex;align-items:stretch;gap:4px;}
|
|
530
|
+
.jf-gutbox textarea.jf-wrap{flex:1 1 auto;min-width:0;width:auto;overflow-wrap:break-word;word-wrap:break-word;white-space:pre-wrap;}
|
|
531
|
+
.jf-gut{flex:0 0 1.8em;overflow:hidden;position:relative;color:var(--text-faint);text-align:left;user-select:none;-webkit-user-select:none;font:inherit;}
|
|
532
|
+
.jf-gut-in{position:absolute;left:0;right:0;top:0;}
|
|
533
|
+
.jf-gut-in div{white-space:nowrap;overflow:hidden;}
|
|
534
|
+
.jf-mirror{position:absolute;left:0;top:0;visibility:hidden;pointer-events:none;white-space:pre-wrap;overflow-wrap:break-word;word-wrap:break-word;box-sizing:content-box;padding:0;border:0;margin:0;}
|
|
535
|
+
.jf-mirror div{margin:0;padding:0;}
|
|
536
|
+
/* editable Chat-card fields get the standard soft white (a step below the ask box); disabled/readonly keep the base colour */
|
|
537
|
+
#panel-chat input:not(:disabled):not([readonly]):not([type="radio"]):not([type="checkbox"]),
|
|
538
|
+
#panel-chat select:not(:disabled),
|
|
539
|
+
#panel-chat textarea:not(:disabled):not([readonly]){background:var(--field-soft-bg);}
|
|
540
|
+
/* ONE wide button below the message box; its wording comes from mainButtonFor */
|
|
541
|
+
.btn.wide{width:100%;margin-top:10px;white-space:normal;}
|
|
542
|
+
/* amendment 2 item 7: the main button's label ("Sign <hash8> & run · $<cap>") stays on ONE line inside the card */
|
|
543
|
+
#chat-main-btn{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0;max-width:100%;}
|
|
544
|
+
/* fwdloop's own additions (not bareloop): input rows, per-box refusal lines, the read-only Run-mode cap */
|
|
545
|
+
.jf-inrow{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,2fr) auto;gap:6px;margin-bottom:4px;align-items:start;}
|
|
546
|
+
.jf-inrow .btn.small{height:32px;padding:0 8px;}
|
|
547
|
+
.jf-inrow .jf-role-ro{padding:5px 7px;min-height:32px;overflow-wrap:anywhere;border:1px solid var(--border);background:var(--bg);color:var(--text-dim);}
|
|
548
|
+
.jf-inrow .jf-err{grid-column:1 / -1;}
|
|
549
|
+
/* M4e amendment 4/5: what a Run or a Resume cannot change shows dimmed (the signature fixes it); only the open boxes are bright */
|
|
550
|
+
.field.dimmed{opacity:.6;}
|
|
551
|
+
/* borrowed-from: bareloop src/panel/index.html@b5e37b8 — the Reuse workflow picker (search box + list, then the picked box) */
|
|
552
|
+
.rw-box{position:relative;margin-top:6px;}
|
|
553
|
+
.rw-box input{width:100%;box-sizing:border-box;}
|
|
554
|
+
.rw-list{list-style:none;margin:0;padding:0;border:1px solid var(--border-strong);border-top:none;background:var(--bg);max-height:220px;overflow:auto;}
|
|
555
|
+
.rw-list li{padding:7px 8px;border-bottom:1px dotted var(--border);cursor:pointer;}
|
|
556
|
+
.rw-list li:hover,.rw-list li.hl{background:var(--panel2);}
|
|
557
|
+
.rw-name{font-weight:700;overflow-wrap:anywhere;} .rw-name mark{background:none;color:var(--accent);text-decoration:underline;}
|
|
558
|
+
.rw-meta{font-size:11px;color:var(--text-dim);margin-top:2px;overflow-wrap:anywhere;}
|
|
559
|
+
.rw-empty{padding:7px 8px;font-size:12px;color:var(--text-dim);}
|
|
560
|
+
.rw-picked{display:flex;justify-content:space-between;align-items:center;gap:8px;margin-top:6px;padding:6px 8px;border:1px solid var(--accent);}
|
|
561
|
+
.rw-picked span{overflow-wrap:anywhere;}
|
|
562
|
+
.rw-picked a{font-size:12px;cursor:pointer;flex:none;}
|
|
563
|
+
.ro-lines{padding:6px 8px;border:1px solid var(--border);background:var(--bg);color:var(--text-dim);font-size:12px;overflow-wrap:anywhere;max-height:160px;overflow-y:auto;}
|
|
564
|
+
.ro-lines .ro-line{display:flex;gap:8px;}
|
|
565
|
+
.ro-lines .ro-n{flex:none;min-width:1.4em;color:var(--text-faint);}
|
|
566
|
+
.jf-waitrow{margin-bottom:4px;}
|
|
567
|
+
.jf-err{font-size:11px;color:var(--red);margin-top:2px;overflow-wrap:anywhere;}
|
|
568
|
+
.jf-err:empty{display:none;}
|
|
569
|
+
.dest-row{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,2fr);gap:6px;}
|
|
570
|
+
@media (max-width: 899px){
|
|
571
|
+
.jf-inrow{grid-template-columns:minmax(0,1fr) auto;}
|
|
572
|
+
.jf-inrow .jf-path{grid-column:1 / -1;order:3;}
|
|
573
|
+
.jf-inrow .jf-err{order:4;}
|
|
574
|
+
}
|
|
417
575
|
|
|
418
576
|
@media (max-width: 899px){
|
|
419
577
|
.main{flex-direction:column;}
|
|
@@ -465,10 +623,11 @@
|
|
|
465
623
|
[data-testid="audit-table"] td[data-label="Step"], .audit-group table td[data-label="Step"],
|
|
466
624
|
[data-testid="audit-table"] td[data-label="Verdict"], .audit-group table td[data-label="Verdict"]{display:block;}
|
|
467
625
|
[data-testid="audit-table"] td[data-label="Attempt"]::before, .audit-group table td[data-label="Attempt"]::before{content:"#";}
|
|
626
|
+
[data-testid="audit-table"] td[data-label="Attempt"]:empty::before, .audit-group table td[data-label="Attempt"]:empty::before{content:none;}
|
|
468
627
|
[data-testid="audit-table"] td.am-glyph, .audit-group table td.am-glyph{order:1;flex:0 0 auto;}
|
|
469
628
|
[data-testid="audit-table"] td[data-label="Attempt"], .audit-group table td[data-label="Attempt"]{order:2;flex:0 0 auto;color:var(--text-dim);}
|
|
470
629
|
[data-testid="audit-table"] td[data-label="Step"], .audit-group table td[data-label="Step"]{order:3;flex:1 1 0;overflow:hidden;text-overflow:ellipsis;}
|
|
471
|
-
[data-testid="audit-table"] td[data-label="Verdict"], .audit-group table td[data-label="Verdict"]{order:4;flex:0 1 auto;max-width:9em;
|
|
630
|
+
[data-testid="audit-table"] td[data-label="Verdict"], .audit-group table td[data-label="Verdict"]{order:4;flex:0 1 auto;max-width:9em;white-space:normal;overflow-wrap:anywhere;}
|
|
472
631
|
[data-testid="audit-table"] td.am-cost, .audit-group table td.am-cost{order:5;flex:0 0 auto;}
|
|
473
632
|
[data-testid="audit-table"] td.am-time, .audit-group table td.am-time{order:6;flex:0 0 auto;color:var(--text-dim);}
|
|
474
633
|
/* no step cell (grouped view): the verdict takes the slack so cost and time sit at the right */
|
|
@@ -561,7 +720,7 @@
|
|
|
561
720
|
<div class="table-wrap" data-testid="provider-table-wrap">
|
|
562
721
|
<table class="pv-table" data-testid="provider-table">
|
|
563
722
|
<thead>
|
|
564
|
-
<tr><th>Key</th><th>Name</th><th>API shape</th><th>Base URL</th><th>Test</th><th>Tokens used</th><th>Balance</th><th>In $/1M</th><th>
|
|
723
|
+
<tr><th>Key</th><th>Name</th><th>API shape</th><th>Base URL</th><th>Test</th><th>Tokens used</th><th>Balance</th><th>In $/1M</th><th>Out $/1M</th></tr>
|
|
565
724
|
</thead>
|
|
566
725
|
<tbody id="pv-rows"></tbody>
|
|
567
726
|
</table>
|
|
@@ -611,13 +770,171 @@
|
|
|
611
770
|
<div class="pane-body" id="left-pane-body">
|
|
612
771
|
|
|
613
772
|
<section id="panel-chat" class="tabpanel active" role="tabpanel" aria-labelledby="tab-chat">
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
773
|
+
<!-- borrowed-from: bareloop src/panel/index.html@ca7195e (Chat markup: the one always-there card, top-right Abandon/Clear,
|
|
774
|
+
the thread, the one progress list, the action-error line the poll never wipes, the ask box, the ONE wide button).
|
|
775
|
+
fwdloop fields: Flow name, The job, Cap $, Destination, Inputs (New job) or a signed flow's inputs (Run a signed flow). -->
|
|
776
|
+
<div class="job-card compact" id="chat-job-card" data-testid="job-card">
|
|
777
|
+
<h4 id="job-card-title">Job card</h4>
|
|
778
|
+
<button class="btn card-clear" type="button" id="chat-clear-btn" data-testid="chat-clear">Clear</button>
|
|
779
|
+
|
|
780
|
+
<div class="radio-row" id="jf-mode-row" role="radiogroup" aria-label="What to do" data-testid="jf-mode">
|
|
781
|
+
<label><input type="radio" name="jf-mode" value="new" checked> New job</label>
|
|
782
|
+
<label><input type="radio" name="jf-mode" value="run"> Run a signed flow</label>
|
|
783
|
+
</div>
|
|
784
|
+
|
|
785
|
+
<div id="jf-new" data-testid="jf-new">
|
|
786
|
+
<div class="field">
|
|
787
|
+
<label for="jf-name">Flow name</label>
|
|
788
|
+
<input id="jf-name" type="text" placeholder="lowercase letters, digits, - or _" autocomplete="off" spellcheck="false" data-testid="jf-name">
|
|
789
|
+
<div class="jf-err" id="jf-err-flowName" data-testid="jf-err-flowName"></div>
|
|
790
|
+
</div>
|
|
791
|
+
<div class="field">
|
|
792
|
+
<label for="jf-job">The job</label>
|
|
793
|
+
<div class="jf-gutbox">
|
|
794
|
+
<div class="jf-gut" id="jf-job-gut" data-testid="jf-job-gut" aria-hidden="true"><div class="jf-gut-in"></div></div>
|
|
795
|
+
<textarea class="jf-wrap" id="jf-job" rows="6" data-testid="jf-job" autocomplete="off" spellcheck="false" placeholder="Read my resume ~keep it under 600 words Ask: check it with me Write it out"></textarea>
|
|
796
|
+
</div>
|
|
797
|
+
<div class="hint">One step per line. A line starting with <code>~</code> is a guardrail of the step above it. <code>Ask:</code> stops for you; <code>Ask 2h:</code> sets that ask's own wait.</div>
|
|
798
|
+
<div class="jf-err" id="jf-err-job" data-testid="jf-err-job"></div>
|
|
799
|
+
</div>
|
|
800
|
+
<div class="field">
|
|
801
|
+
<label for="jf-dest-folder">Destination</label>
|
|
802
|
+
<input id="jf-dest-folder" type="text" placeholder="/full/path/to/a/folder" autocomplete="off" spellcheck="false" data-testid="jf-dest-folder">
|
|
803
|
+
<div class="hint">Where the accepted result is placed, at the last step. Leave empty for no send.</div>
|
|
804
|
+
<div class="jf-err" id="jf-err-destination" data-testid="jf-err-destination"></div>
|
|
805
|
+
</div>
|
|
806
|
+
<div class="field">
|
|
807
|
+
<label for="jf-inputs">Inputs</label>
|
|
808
|
+
<div class="jf-gutbox">
|
|
809
|
+
<div class="jf-gut" id="jf-inputs-gut" data-testid="jf-inputs-gut" aria-hidden="true"><div class="jf-gut-in"></div></div>
|
|
810
|
+
<textarea class="jf-wrap" id="jf-inputs" rows="3" data-testid="jf-inputs" autocomplete="off" spellcheck="false" placeholder="resume: /full/path/to/resume.md"></textarea>
|
|
811
|
+
</div>
|
|
812
|
+
<div class="hint">One line per file: a name, a colon, its full path starting with /. The page never reads the file.</div>
|
|
813
|
+
<div class="jf-err" id="jf-err-inputs" data-testid="jf-err-inputs"></div>
|
|
814
|
+
</div>
|
|
815
|
+
<div class="cap-row" data-testid="cap-row">
|
|
816
|
+
<div class="cap-field">
|
|
817
|
+
<label for="jf-cap-money">Cap $</label>
|
|
818
|
+
<input id="jf-cap-money" type="text" inputmode="decimal" placeholder="per run" data-testid="jf-cap-money">
|
|
819
|
+
<div class="hint" id="jf-cap-note" data-testid="cap-note"></div>
|
|
820
|
+
<div class="jf-err" id="jf-err-capUsd" data-testid="jf-err-capUsd"></div>
|
|
821
|
+
</div>
|
|
822
|
+
<div class="cap-field">
|
|
823
|
+
<label for="jf-ask-wait">Ask wait</label>
|
|
824
|
+
<input id="jf-ask-wait" type="text" value="1h" autocomplete="off" spellcheck="false" data-testid="jf-ask-wait">
|
|
825
|
+
<div class="hint">For each <code>Ask:</code> step. Number + m or h.</div>
|
|
826
|
+
<div class="jf-err" id="jf-err-askWait" data-testid="jf-err-askWait"></div>
|
|
827
|
+
</div>
|
|
828
|
+
</div>
|
|
829
|
+
</div>
|
|
830
|
+
|
|
831
|
+
<div id="jf-run" data-testid="jf-run" hidden>
|
|
832
|
+
<div class="field">
|
|
833
|
+
<label for="jf-run-flow">Signed flow</label>
|
|
834
|
+
<!-- borrowed-from: bareloop src/panel/index.html@b5e37b8 (its job picker): a search box over the list, then the picked box with `change` -->
|
|
835
|
+
<div class="rw-box" id="rw-search" data-testid="rw-search">
|
|
836
|
+
<input id="jf-run-flow" type="text" placeholder="type part of a flow or run name (run-2)…" autocomplete="off" spellcheck="false" data-testid="jf-run-flow">
|
|
837
|
+
<ul class="rw-list" id="rw-list" data-testid="rw-list"></ul>
|
|
838
|
+
</div>
|
|
839
|
+
<div class="rw-picked" id="rw-picked" data-testid="rw-picked" hidden><span id="rw-picked-txt" data-testid="rw-picked-txt"></span><a id="rw-change" data-testid="rw-change" role="button" tabindex="0">change</a></div>
|
|
840
|
+
<div class="hint" id="jf-run-empty" data-testid="jf-run-empty"></div>
|
|
841
|
+
<div class="jf-err" id="jf-err-flow" data-testid="jf-err-flow"></div>
|
|
842
|
+
</div>
|
|
843
|
+
<div class="field dimmed" data-testid="jf-run-job-field">
|
|
844
|
+
<label>The job</label>
|
|
845
|
+
<div class="ro-lines" id="jf-run-job" data-testid="jf-run-job"></div>
|
|
846
|
+
<div class="hint">Fixed by the signature (the steps, the job lines and the asks). To change one, start a new job.</div>
|
|
847
|
+
</div>
|
|
848
|
+
<div class="field">
|
|
849
|
+
<label for="jf-run-dest">Destination</label>
|
|
850
|
+
<input id="jf-run-dest" type="text" placeholder="/full/path/to/a/folder" autocomplete="off" spellcheck="false" data-testid="jf-run-dest">
|
|
851
|
+
<div class="hint" id="jf-run-dest-hint" data-testid="jf-run-dest-hint"></div>
|
|
852
|
+
<div class="jf-err" id="jf-err-run-destination" data-testid="jf-err-run-destination"></div>
|
|
853
|
+
</div>
|
|
854
|
+
<div class="field">
|
|
855
|
+
<label>Inputs</label>
|
|
856
|
+
<div id="jf-run-inputs" data-testid="jf-run-inputs"></div>
|
|
857
|
+
<div class="jf-err" id="jf-err-run-inputs" data-testid="jf-err-run-inputs"></div>
|
|
858
|
+
</div>
|
|
859
|
+
<div class="cap-row">
|
|
860
|
+
<div class="cap-field">
|
|
861
|
+
<label for="jf-run-cap">Cap $</label>
|
|
862
|
+
<input id="jf-run-cap" type="text" inputmode="decimal" autocomplete="off" data-testid="jf-run-cap">
|
|
863
|
+
<div class="hint" id="jf-run-left" data-testid="jf-run-left"></div>
|
|
864
|
+
<div class="jf-err" id="jf-err-run-capUsd" data-testid="jf-err-run-capUsd"></div>
|
|
865
|
+
</div>
|
|
866
|
+
<div class="cap-field" id="jf-run-waits" data-testid="jf-run-waits"></div>
|
|
867
|
+
</div>
|
|
868
|
+
<div class="jf-err" id="jf-err-run-askWaits" data-testid="jf-err-run-askWaits"></div>
|
|
869
|
+
<div class="hint" id="jf-run-sign-hint" data-testid="jf-run-sign-hint">A different destination, cap or ask wait is signed for this run only: two clicks. The flow's own values never change.</div>
|
|
870
|
+
<div class="field">
|
|
871
|
+
<label for="jf-run-id">Run id</label>
|
|
872
|
+
<input id="jf-run-id" type="text" autocomplete="off" spellcheck="false" data-testid="jf-run-id">
|
|
873
|
+
<div class="jf-err" id="jf-err-runId" data-testid="jf-err-runId"></div>
|
|
874
|
+
</div>
|
|
875
|
+
</div>
|
|
876
|
+
|
|
877
|
+
<div id="jf-resume" data-testid="jf-resume" hidden>
|
|
878
|
+
<div class="field dimmed" data-testid="jf-resume-job-field">
|
|
879
|
+
<label>The job</label>
|
|
880
|
+
<div class="ro-lines" id="jf-resume-job" data-testid="jf-resume-job"></div>
|
|
881
|
+
</div>
|
|
882
|
+
<div class="field dimmed">
|
|
883
|
+
<label>Destination</label>
|
|
884
|
+
<div class="ro-lines" id="jf-resume-dest" data-testid="jf-resume-dest"></div>
|
|
885
|
+
</div>
|
|
886
|
+
<div class="field dimmed">
|
|
887
|
+
<label>Inputs</label>
|
|
888
|
+
<div class="ro-lines" id="jf-resume-inputs" data-testid="jf-resume-inputs"></div>
|
|
889
|
+
</div>
|
|
890
|
+
<div class="field dimmed">
|
|
891
|
+
<label>Ask wait</label>
|
|
892
|
+
<div class="ro-lines" id="jf-resume-waits" data-testid="jf-resume-waits"></div>
|
|
893
|
+
</div>
|
|
894
|
+
<div class="cap-row">
|
|
895
|
+
<div class="cap-field">
|
|
896
|
+
<label for="jf-resume-cap">Cap $</label>
|
|
897
|
+
<input id="jf-resume-cap" type="text" inputmode="decimal" autocomplete="off" data-testid="jf-resume-cap">
|
|
898
|
+
<div class="hint" id="jf-resume-left" data-testid="jf-resume-left"></div>
|
|
899
|
+
<div class="jf-err" id="jf-err-resume-capUsd" data-testid="jf-err-resume-capUsd"></div>
|
|
900
|
+
</div>
|
|
901
|
+
</div>
|
|
902
|
+
<div class="hint" id="jf-resume-hint" data-testid="jf-resume-hint"></div>
|
|
903
|
+
</div>
|
|
904
|
+
|
|
905
|
+
<div class="hint" id="chat-card-error" data-testid="chat-card-error"></div>
|
|
906
|
+
</div>
|
|
907
|
+
|
|
908
|
+
<!-- ONE progress list: every step is one line that updates in place; a waiting step has no check -->
|
|
909
|
+
<ol class="chat-steps" id="chat-progress-row" data-testid="chat-steps" aria-live="polite" hidden></ol>
|
|
910
|
+
|
|
911
|
+
<!-- M4e amendment 14: the plan, then the main button (no bubbles, no note box): the plan sits next to Sign & run -->
|
|
912
|
+
<div class="chat-thread" id="chat-thread" data-testid="chat-thread"></div>
|
|
913
|
+
|
|
914
|
+
<!-- M4e amendments 24/25: a question the plan raised, one at a time. No Skip. Static markup: the poll only rewrites the texts when the question changes, never the answer box -->
|
|
915
|
+
<div class="chat-question" id="chat-question" data-testid="chat-question" hidden>
|
|
916
|
+
<div class="q-head" id="chat-q-head" data-testid="chat-q-head"></div>
|
|
917
|
+
<div class="q-line" id="chat-q-line" data-testid="chat-q-line"></div>
|
|
918
|
+
<div class="q-text" id="chat-q-text" data-testid="chat-q-text"></div>
|
|
919
|
+
<textarea id="chat-q-answer" data-testid="chat-q-answer" rows="2" autocomplete="off" spellcheck="false" aria-label="Your answer" placeholder="Your answer, on one line"></textarea>
|
|
920
|
+
<div class="hint q-err" id="chat-q-error" data-testid="chat-q-error" role="alert"></div>
|
|
921
|
+
<button class="btn primary wide" type="button" id="chat-q-send" data-testid="chat-q-send">Send</button>
|
|
620
922
|
</div>
|
|
923
|
+
|
|
924
|
+
<!-- M4e amendments 24/25: beside a green plan, Your answers (if it was drafted with any), Checked (built by code from the typed checks) and Not checked (the drafter's own reading) -->
|
|
925
|
+
<div class="chat-extras" id="chat-extras" data-testid="chat-extras"></div>
|
|
926
|
+
|
|
927
|
+
<!-- a refused draft / run / sign / abandon POST (or a refused start) shows here and STAYS: set only by this tab's own
|
|
928
|
+
action handlers, never cleared by the poll (the poll owns #chat-card-error instead) -->
|
|
929
|
+
<div class="hint" id="chat-action-error" data-testid="chat-action-error"></div>
|
|
930
|
+
|
|
931
|
+
<button class="btn primary wide" type="button" id="chat-main-btn" data-testid="chat-main" disabled>Draft</button>
|
|
932
|
+
<div class="hint" id="chat-main-hint" data-testid="chat-main-hint"></div>
|
|
933
|
+
<!-- M4e amendment 14 item 2: on a green plan, Revise opens every card field (the main button then reads Draft) -->
|
|
934
|
+
<button class="btn wide" type="button" id="chat-revise-btn" data-testid="chat-revise" hidden>Revise</button>
|
|
935
|
+
<!-- M4e amendment 14 item 3: after the second revise, on a green plan: Start over drafts the card as it is, a fresh draft with 2 new revises -->
|
|
936
|
+
<button class="btn wide" type="button" id="chat-startover-btn" data-testid="chat-startover" hidden>Start over</button>
|
|
937
|
+
<div class="hint">Only your click signs.</div>
|
|
621
938
|
</section>
|
|
622
939
|
|
|
623
940
|
<section id="panel-inbox" class="tabpanel" role="tabpanel" aria-labelledby="tab-inbox" hidden>
|
|
@@ -668,6 +985,7 @@
|
|
|
668
985
|
<section id="panel-run" class="tabpanel active" role="tabpanel" aria-labelledby="tab-run">
|
|
669
986
|
<div id="run-empty" class="hint" style="font-size:13px;padding:24px 0;">select a run from Workflows or History</div>
|
|
670
987
|
<div id="run-content" hidden>
|
|
988
|
+
<div class="run-actions" id="run-actions" data-testid="run-actions" hidden></div>
|
|
671
989
|
<div class="counters" id="run-counters" data-testid="live-counters"></div>
|
|
672
990
|
<div class="summary-box" id="run-summary" data-testid="run-summary"></div>
|
|
673
991
|
<div class="map-box" data-testid="step-map" id="map-box"><div id="map-mount"></div></div>
|
|
@@ -724,7 +1042,7 @@
|
|
|
724
1042
|
piece within a field — replaces the old split asks/sends/
|
|
725
1043
|
sources/signed-lines blocks. Field order (signed): Job
|
|
726
1044
|
(prose) · Ask · Model · $ cap (+ redo cap) · Source ·
|
|
727
|
-
Destination ·
|
|
1045
|
+
Destination · Signed (am34: Success is gone; the plan block holds each step check) (M4e amendment 6: each guardrail sits under its own line in Job). At 390px every
|
|
728
1046
|
field's own `label` already sits above its value (the
|
|
729
1047
|
existing global `label{display:block}` rule — no separate
|
|
730
1048
|
narrow-width override needed). -->
|
|
@@ -732,14 +1050,18 @@
|
|
|
732
1050
|
<div class="job-card" id="job-card" hidden data-testid="job-card-readonly">
|
|
733
1051
|
<h4 id="details-title">Job card — signed</h4>
|
|
734
1052
|
<div class="field"><label>Model</label><div class="ro-value" id="details-model">—</div></div>
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
<div
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
1053
|
+
<!-- M4e amendment 37: ONE column. #details-prose holds one wrapper per signed line (the line, its ~ rows, its steps folded under it);
|
|
1054
|
+
#details-plan-tail holds any step from no listed line, then the folded "not checked" line; then Ask, Destination, $ cap, Source, Signed. -->
|
|
1055
|
+
<div id="job-grid" data-testid="job-grid">
|
|
1056
|
+
<div id="details-prose"></div>
|
|
1057
|
+
<div id="details-plan-tail"></div>
|
|
1058
|
+
<div class="field"><label>Ask</label><div id="details-asks"></div></div>
|
|
1059
|
+
<div class="field"><label>Destination</label><div id="details-sends"></div></div>
|
|
1060
|
+
<div class="field"><label>$ cap</label><div class="ro-value" id="details-cap">—</div></div>
|
|
1061
|
+
<div class="field"><label>Source</label><div id="details-sources"></div></div>
|
|
1062
|
+
<div class="field"><label>Signed</label><div class="ro-value" id="details-signature">—</div></div>
|
|
1063
|
+
<div class="plan-legend" data-testid="plan-legend"><span class="plan-mark">›</span> = the approved plan</div>
|
|
1064
|
+
</div>
|
|
743
1065
|
</div>
|
|
744
1066
|
</section>
|
|
745
1067
|
|
|
@@ -775,8 +1097,7 @@
|
|
|
775
1097
|
"use strict";
|
|
776
1098
|
|
|
777
1099
|
var PORT = "__FWDLOOP_PANEL_PORT__";
|
|
778
|
-
//
|
|
779
|
-
// request (reads and the two POSTs) is authenticated by that cookie, sent by the browser itself.
|
|
1100
|
+
// No token, no cookie (M4e amendment 4 item 8): the panel is local and trusted; the server checks Host and, on a POST, Origin.
|
|
780
1101
|
document.getElementById("host-line").textContent = "127.0.0.1:" + PORT;
|
|
781
1102
|
|
|
782
1103
|
function wireTabs(tabButtons){
|
|
@@ -799,11 +1120,18 @@
|
|
|
799
1120
|
|
|
800
1121
|
// ---- fetch helpers. Reads are GET. The ONLY non-GET requests on this page are
|
|
801
1122
|
// the two POSTs below (M4b): /api/answer (a human clicking a door) and
|
|
802
|
-
// /api/resume ("try the resume again").
|
|
803
|
-
//
|
|
1123
|
+
// /api/resume ("try the resume again"). No auth header (the server checks Host and
|
|
1124
|
+
// Origin). Same-origin. ----
|
|
804
1125
|
function getJSON(path){
|
|
805
1126
|
return fetch(path, { method: "GET", headers: { accept: "application/json" } }).then(function(r){
|
|
806
|
-
if(!r.ok){
|
|
1127
|
+
if(!r.ok){
|
|
1128
|
+
// the refusal's own name rides on the error (C1): the one load-failure sentence tells "outside the folder" from the other 403
|
|
1129
|
+
return r.json().then(function(b){ return b; }, function(){ return null; }).then(function(b){
|
|
1130
|
+
var err = new Error(path + ": HTTP " + r.status); err.status = r.status;
|
|
1131
|
+
if(b && typeof b.refused === "string") err.refused = b.refused;
|
|
1132
|
+
throw err;
|
|
1133
|
+
});
|
|
1134
|
+
}
|
|
807
1135
|
return r.json();
|
|
808
1136
|
});
|
|
809
1137
|
}
|
|
@@ -811,7 +1139,8 @@
|
|
|
811
1139
|
// message (it carries the path and the HTTP code), never a status number.
|
|
812
1140
|
function loadFailureText(e){
|
|
813
1141
|
var status = e && e.status;
|
|
814
|
-
if(status === 403
|
|
1142
|
+
if(status === 403 && e.refused === "flow-outside-root") return "This flow is outside the panel's folder.";
|
|
1143
|
+
if(status === 403) return "The panel does not recognise this page. Reload it.";
|
|
815
1144
|
if(status === 404) return "This run is no longer there.";
|
|
816
1145
|
return "Could not load this; reload the page.";
|
|
817
1146
|
}
|
|
@@ -854,7 +1183,15 @@
|
|
|
854
1183
|
// recorded" in that middle slot instead of a number; a row with no model
|
|
855
1184
|
// call at all (an ask/hitl row) drops the tokens slot entirely — never a
|
|
856
1185
|
// fake "0 tokens".
|
|
1186
|
+
// a Sign & run row's ask waits read through plainWait (same as the Job tab); every other row's gap is as recorded
|
|
1187
|
+
function auditGapText(r){
|
|
1188
|
+
if(!Array.isArray(r.gapWaits) || !r.gapWaits.length) return r.gap || "";
|
|
1189
|
+
var waits = r.gapWaits.map(function(w){ return "line " + w.line + ": " + (typeof w.waitMs === "number" ? plainWait(w.waitMs) : w.wait); }).join(", ");
|
|
1190
|
+
return (r.gapHead || []).concat(["ask waits " + waits]).join(" · ");
|
|
1191
|
+
}
|
|
857
1192
|
function auditCostCellText(r){
|
|
1193
|
+
if(r.setup && typeof r.usd !== "number" && r.verdict === "hitl") return "—"; // a setup row you wrote (card, note, sign) has no cost
|
|
1194
|
+
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)
|
|
858
1195
|
var bits = [money(r.usd, r.spendComplete)];
|
|
859
1196
|
var td = r.tokensDisplay;
|
|
860
1197
|
if(td && td.kind === "total") bits.push(td.total + " tokens");
|
|
@@ -905,6 +1242,76 @@
|
|
|
905
1242
|
if(m >= 1 && Number.isInteger(m)) return m + " min";
|
|
906
1243
|
return duration(ms);
|
|
907
1244
|
}
|
|
1245
|
+
// M4e amendment 7 item 7 (hamr's ruling 2026-10-06): the second line of a Signed flow row — bareloop's reuse-estimate shape
|
|
1246
|
+
// (borrowed-from: bareloop src/panel/server.js@1927350 `reuseLine`) with fwdloop's own first part. What is unknown is said, never
|
|
1247
|
+
// rendered as $0 or 0 time; the money and the time go through the page's one money() and duration().
|
|
1248
|
+
function countWord(n, word){ return n + " " + word + (n === 1 ? "" : "s"); }
|
|
1249
|
+
function flowStatLine(f){
|
|
1250
|
+
var s = (f && f.stats) || {};
|
|
1251
|
+
var head = countWord(s.steps || 0, "step") + " · " + countWord(s.asks || 0, "ask") + " · " + (s.green || 0) + " green · " + (s.notGreen || 0) + " not green";
|
|
1252
|
+
var cost = typeof s.avgSpendUsd === "number" ? money(s.avgSpendUsd) : null;
|
|
1253
|
+
var time = typeof s.avgWallMs === "number" ? duration(s.avgWallMs) : null;
|
|
1254
|
+
if(cost !== null && time !== null) return head + " · about " + cost + " and " + time + " a run";
|
|
1255
|
+
if(cost !== null) return head + " · about " + cost + " a run, time not recorded";
|
|
1256
|
+
if(time !== null) return head + " · about " + time + " a run, cost not recorded";
|
|
1257
|
+
return head + " · cost and time not recorded";
|
|
1258
|
+
}
|
|
1259
|
+
// The rows the Signed flow search shows for what is typed: a flow whose name has the text; and, for any text, each passed run whose
|
|
1260
|
+
// name has it (`run-2` lists every flow's run-2 as "<flow> (run-2)"; typing the whole "<flow> (run-2)" finds it too). Empty text = every flow.
|
|
1261
|
+
function flowChoices(flows, text){
|
|
1262
|
+
var q = String(text || "").trim().toLowerCase();
|
|
1263
|
+
var out = [];
|
|
1264
|
+
(flows || []).forEach(function(f){
|
|
1265
|
+
if(q === "" || f.flow.toLowerCase().indexOf(q) !== -1) out.push({flow: f.flow, runId: null, label: f.flow, meta: flowStatLine(f)});
|
|
1266
|
+
});
|
|
1267
|
+
if(q !== ""){
|
|
1268
|
+
(flows || []).forEach(function(f){
|
|
1269
|
+
(f.runs || []).forEach(function(r){
|
|
1270
|
+
var label = f.flow + " (" + r.runId + ")";
|
|
1271
|
+
if(r.runId.toLowerCase().indexOf(q) !== -1 || (q.indexOf("(") !== -1 && label.toLowerCase().indexOf(q) !== -1)) out.push({flow: f.flow, runId: r.runId, label: label, meta: flowStatLine(f)});
|
|
1272
|
+
});
|
|
1273
|
+
});
|
|
1274
|
+
}
|
|
1275
|
+
return out;
|
|
1276
|
+
}
|
|
1277
|
+
// M4e amendment 9: the model-calls words, ONE function for the card's line 2 and the Audit header: `<n> model calls` (`1 model call`), `at least <n> model calls`
|
|
1278
|
+
// when a draft/change row recorded no `calls` (it counts 1), `calls unknown` with no model row.
|
|
1279
|
+
function draftCallsWord(d){
|
|
1280
|
+
if(typeof d.calls !== "number") return "calls unknown";
|
|
1281
|
+
return (d.callsAtLeast ? "at least " : "") + countWord(d.calls, "model call");
|
|
1282
|
+
}
|
|
1283
|
+
// M4e amendment 7 item 2 / 9: the Draft's one line in the Audit group's header: `drafting · <time> · $<cost> · <n> model calls · ✓`.
|
|
1284
|
+
// `d` is the server's one Draft summary (src/panel/data.js `draftTotals`): a figure not recorded reads "unknown", never 0; a flow signed before
|
|
1285
|
+
// amendment 6 reads "no draft record" and no cost.
|
|
1286
|
+
// The Draft's three figures, ONE function for the card's line 2, the Audit header and its aria: `<time> · $<cost> · <n> model calls`.
|
|
1287
|
+
function draftFigures(d){
|
|
1288
|
+
return [typeof d.timeMs === "number" ? duration(d.timeMs) : "time unknown", d.cost || "cost unknown", draftCallsWord(d)];
|
|
1289
|
+
}
|
|
1290
|
+
// M4e amendment 11: the human-checks words, ONE function for the drafting card's line 2 and the Audit Draft header (`1 human check`, `2 human checks`).
|
|
1291
|
+
function draftHumanWord(d){
|
|
1292
|
+
return typeof d.humanChecks === "number" ? countWord(d.humanChecks, "human check") : "human checks unknown";
|
|
1293
|
+
}
|
|
1294
|
+
// M4e amendment 10 item 2: with the step card's status first: `[✓] passed · drafting · <time> · $<cost> · <n> model calls ✓` (signed), `not signed · drafting · ...`
|
|
1295
|
+
// plain (no sign row, no mark), `drafting · no draft record` (no draft record, no status). The Audit header's visible words come from the same
|
|
1296
|
+
// `auditGroupHeaderParts`, so this is the aria line too.
|
|
1297
|
+
function draftLineText(d){
|
|
1298
|
+
var p = auditGroupHeaderParts({draft: true, summary: d});
|
|
1299
|
+
return [p.status, p.name].concat(p.draftFigs || [p.why]).filter(function(x){ return x; }).join(" \u00b7 ") + (p.passed ? " \u2713" : "");
|
|
1300
|
+
}
|
|
1301
|
+
// M4e amendment 9: the drafting card, step 0 of the Run tab, from ONE function: `title` (`0 · drafting`, bold h4), `status` (the step card's `stateWord`: `[✓] passed`
|
|
1302
|
+
// with a sign row, plain `not signed` without; none for a flow with no draft record), then `lines`: `<time> · $<cost> · <n> model calls · <h> human checks · ✓`
|
|
1303
|
+
// (a figure not recorded reads unknown, never 0; the mark only on passed) and what happened (`d.happened`, joined by ` · `). Same `draftTotals` as the Audit header.
|
|
1304
|
+
function draftCardLines(d){
|
|
1305
|
+
if(!d || !d.present) return {title: "0 \u00b7 drafting", status: null, passed: false, lines: [(d && d.why) || "no draft record"]};
|
|
1306
|
+
var passed = d.ended === "done";
|
|
1307
|
+
var figs = draftFigures(d).concat([draftHumanWord(d)]);
|
|
1308
|
+
if(passed) figs.push("\u2713");
|
|
1309
|
+
return {title: "0 \u00b7 drafting", status: passed ? stateWord("done") : "not signed", passed: passed, lines: [figs.join(" \u00b7 "), (d.happened || []).join(" \u00b7 ")]};
|
|
1310
|
+
}
|
|
1311
|
+
// The Map's first box: the Draft, then step 1. A box with no audit attempts of its own; its state word says "no draft record" when there is none.
|
|
1312
|
+
function draftBox(d){
|
|
1313
|
+
return {draft: true, emits: "drafting", goal: "", closeClass: null, primitives: [], attempts: [], tryCount: 0, tryMarks: [], state: d && d.present ? "done" : "pending", noRecord: !(d && d.present), n: 0};
|
|
1314
|
+
}
|
|
908
1315
|
// A readable local date/time instead of a raw ISO timestamp (fix #5) — an
|
|
909
1316
|
// unparseable value still shows the raw string (never blank/nothing), so
|
|
910
1317
|
// a books bug is visible rather than silently swallowed.
|
|
@@ -923,7 +1330,7 @@
|
|
|
923
1330
|
// M4c-fix amendment 2 (g): a step's own sign + word come from the SAME one table the run rows use (the server's
|
|
924
1331
|
// SIGN_WORDS, sent on the run detail as `signWords`); the page keeps no table of its own. Not started: no sign.
|
|
925
1332
|
var signWords = {};
|
|
926
|
-
var STEP_SIGN = { done: "[\u2713]", stopped: "[\u2717]", waiting: "[\u00b7]" };
|
|
1333
|
+
var STEP_SIGN = { done: "[\u2713]", stopped: "[\u2717]", waiting: "[\u00b7]", "user-stopped": "[\u25a0]" };
|
|
927
1334
|
function stateWord(state){
|
|
928
1335
|
if(state === "pending") return "not started";
|
|
929
1336
|
var g = STEP_SIGN[state];
|
|
@@ -990,6 +1397,9 @@
|
|
|
990
1397
|
if(verdict === "ask-timeout" || verdict === "ask-expired") return "expired waiting for you";
|
|
991
1398
|
if(verdict === "ask-reopened") return "reopened by you";
|
|
992
1399
|
if(verdict === "lock-removed") return "old lock removed by you";
|
|
1400
|
+
if(verdict === "stop-asked") return "stop asked by you";
|
|
1401
|
+
if(verdict === "stopped") return "stopped by you";
|
|
1402
|
+
if(verdict === "stop-not-honoured") return "stop not honoured";
|
|
993
1403
|
if(verdict === "green") return "passed";
|
|
994
1404
|
if(verdict === "hitl") return "human check";
|
|
995
1405
|
if(verdict === "not-done") return "not done";
|
|
@@ -1003,6 +1413,7 @@
|
|
|
1003
1413
|
function verdictGlyph(verdict, closeClass){
|
|
1004
1414
|
if(closeClass === "hitl" && verdict === "red") return null;
|
|
1005
1415
|
if(verdict === "paused" || verdict === "refused" || verdict === "ask-timeout" || verdict === "ask-expired" || verdict === "ask-reopened" || verdict === "lock-removed") return null;
|
|
1416
|
+
if(verdict === "stop-asked" || verdict === "stopped" || verdict === "stop-not-honoured") return null; // amendment 7 item 8: a Stop is neither a pass nor a failure
|
|
1006
1417
|
return verdictPassed(verdict) ? "✓" : "✗";
|
|
1007
1418
|
}
|
|
1008
1419
|
// The run-row glyph strings src/panel/data.js's computeGlyph emits are
|
|
@@ -1030,26 +1441,14 @@
|
|
|
1030
1441
|
// (never "amber", which draws the reserved running arrow [▶]).
|
|
1031
1442
|
if(g === "[!]") return "expired";
|
|
1032
1443
|
if(g === "[II]") return "stuck";
|
|
1444
|
+
if(g === "[■]") return "stopped";
|
|
1033
1445
|
return "grey"; // "[·]" — waiting on a human, or answered-not-resumed
|
|
1034
1446
|
}
|
|
1035
1447
|
|
|
1036
1448
|
// ---- step map renderer (box-drawing geometry kept from the borrowed
|
|
1037
|
-
// page's
|
|
1449
|
+
// page's step-map builder; the DATA it draws is fwdloop's own: one box per
|
|
1038
1450
|
// `declaration.steps` entry, no scout/plan/judge/fix-loop/rounds — ruling
|
|
1039
1451
|
// A, "no per-round parts"). ----
|
|
1040
|
-
function stepMapColors(state){
|
|
1041
|
-
if(state === "done") return {stroke:"var(--green)", textFill:"#2e7d32"};
|
|
1042
|
-
if(state === "stopped") return {stroke:"var(--red)", textFill:"var(--red)"};
|
|
1043
|
-
if(state === "waiting") return {stroke:"var(--amber)", textFill:"#b8860b"};
|
|
1044
|
-
return {stroke:"var(--border-strong)", textFill:"var(--text-faint)"}; // not started yet
|
|
1045
|
-
}
|
|
1046
|
-
var stepMapUidCounter = 0;
|
|
1047
|
-
var MAP_MARGIN = 10, MAP_GAP = 28;
|
|
1048
|
-
var CHAR_W = 7.2;
|
|
1049
|
-
var TITLE_HPAD = 16;
|
|
1050
|
-
var MIN_BOX_W = 100;
|
|
1051
|
-
var BOX_H = 60, BOX_H_2LINE = 78;
|
|
1052
|
-
var ROW_GAP = 70;
|
|
1053
1452
|
// hamr review #2: "map cards missing try 2 if multiple attempts/iteration"
|
|
1054
1453
|
// — a plain "try N" count whenever a step has been attempted more than
|
|
1055
1454
|
// once, plus a mark when the LATEST attempt followed a human redo (the
|
|
@@ -1072,27 +1471,15 @@
|
|
|
1072
1471
|
// failed · attempt 2 passed · …") is a map node's single biggest source of
|
|
1073
1472
|
// width — that level of detail belongs in the Audit tab, never on the
|
|
1074
1473
|
// node. A node's title is just
|
|
1075
|
-
// step number + name +
|
|
1474
|
+
// step number + name + state, kept short so naturalBoxWidth stays
|
|
1076
1475
|
// small and the map stays compact instead of stretching to the pane width.
|
|
1077
1476
|
function stepTitleText(idx, s){
|
|
1078
|
-
|
|
1079
|
-
var
|
|
1080
|
-
if(tryText) base += ' — ' + tryText;
|
|
1477
|
+
if(s.draft) return "drafting";
|
|
1478
|
+
var base = (s.n || idx + 1) + ' ' + s.emits;
|
|
1081
1479
|
return base;
|
|
1082
1480
|
}
|
|
1083
|
-
// The declared step's own run-state,
|
|
1084
|
-
//
|
|
1085
|
-
// why, from one screen"): `pending` (no attempt yet), `done` (last
|
|
1086
|
-
// attempt passed), `waiting` (the run is currently parked ON this step —
|
|
1087
|
-
// its last attempt's verdict is `paused`/`refused`, i.e. it went to a
|
|
1088
|
-
// human ask and hasn't been answered/resolved yet), `stopped` (a real
|
|
1089
|
-
// stop — the last attempt failed for any other reason).
|
|
1090
|
-
function stepBoxState(s){
|
|
1091
|
-
if(!s.attempts || !s.attempts.length) return "pending";
|
|
1092
|
-
var last = s.attempts[s.attempts.length - 1];
|
|
1093
|
-
if(last.verdict === "paused" || last.verdict === "refused") return "waiting";
|
|
1094
|
-
return verdictPassed(last.verdict) ? "done" : "stopped";
|
|
1095
|
-
}
|
|
1481
|
+
// The declared step's own run-state (map box, card, "which step stopped and why") is the server's `groupState` (src/panel/data.js
|
|
1482
|
+
// `deriveStepGroupState`, M4e amendment 10: the one decider): `pending` (no row yet), `done`, `waiting`, `stopped` (red), `user-stopped` (a Stop).
|
|
1096
1483
|
// hamr's 2026-09-27 review: a step with a server-computed `tryCount > 1`
|
|
1097
1484
|
// (M2/M3's runner already counts retries/redraft attempts honestly — never
|
|
1098
1485
|
// recounted here from `attempts.length`, which double-counts an ask step's
|
|
@@ -1121,155 +1508,40 @@
|
|
|
1121
1508
|
// book-derived list, never guessed from `primitives` by exclusion.
|
|
1122
1509
|
toolsTotal: s.toolsTotal || null, toolsWhy: s.toolsWhy || null, ungranted: s.ungranted || [],
|
|
1123
1510
|
stoppedReason: s.stoppedReason || null,
|
|
1124
|
-
state:
|
|
1511
|
+
state: s.groupState || "pending", // the server's one decider (deriveStepGroupState); no group = no row yet = not started
|
|
1125
1512
|
};
|
|
1126
1513
|
});
|
|
1127
1514
|
}
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1515
|
+
// borrowed-from: bareloop src/panel/index.html@9edb3e1 (on d25e52a). The map is plain HTML + CSS (.map-chips / .map-item /
|
|
1516
|
+
// .map-chip): the browser wraps it, so no width arithmetic and no sideways scroll. Each box keeps its two lines — the name
|
|
1517
|
+
// (stepTitleText) then the status word (stateWord); a retried box (am35) is dashed and its status line starts with "↻N".
|
|
1518
|
+
function buildStepMapHTML(steps){
|
|
1519
|
+
var last = steps.length - 1;
|
|
1520
|
+
var body = steps.map(function(s, idx){
|
|
1521
|
+
var tries = boxRetryTry(s);
|
|
1522
|
+
var cls = "map-chip s-" + String(s.state).replace(/[^a-z-]/g, "") + (tries ? " retry" : "");
|
|
1523
|
+
var name = escapeXml(stepTitleText(idx, s));
|
|
1524
|
+
var state = escapeXml(s.noRecord ? "no draft record" : stateWord(s.state));
|
|
1525
|
+
// hamr review #4: each box is a clickable button tagged with the step's own `emits` id — the click listener that
|
|
1526
|
+
// jumps to the Audit tab's matching group is wired AFTER insertion (wireMapClicks), never inline here.
|
|
1527
|
+
var chip = '<button type="button" class="' + cls + ' map-step" data-emits="' + escapeXml(s.emits) + '"' + (tries ? ' data-retry="' + tries + '"' : '') +
|
|
1528
|
+
' title="' + name + '" aria-label="open ' + escapeXml(s.emits) + ' in Audit">' +
|
|
1529
|
+
'<span class="chip-name">' + name + '</span><span class="chip-state">' +
|
|
1530
|
+
(tries ? '<span class="chip-retry">\u21bb' + tries + '</span> ' : '') + state + '</span></button>';
|
|
1531
|
+
return '<span class="map-item" role="listitem">' +
|
|
1532
|
+
(idx > 0 ? '<span class="map-lead" aria-hidden="true">\u2192</span>' : '') +
|
|
1533
|
+
chip + (idx < last ? '<span class="map-arrow" aria-hidden="true">\u2192</span>' : '') + '</span>';
|
|
1534
|
+
}).join("");
|
|
1535
|
+
return '<div class="map-chips" role="list" aria-label="step map">' + body + '</div>';
|
|
1536
|
+
}
|
|
1537
|
+
// The first box of each WRAPPED line shows a leading arrow. CSS cannot know which box starts a line, so after render/resize
|
|
1538
|
+
// this compares each item's offsetTop with the previous item's (same line = same top). Takes anything with offsetTop +
|
|
1539
|
+
// classList (real elements, or stubs in tests). The lead arrow is absolute, so toggling never reflows a box — no loop.
|
|
1540
|
+
function markLineStarts(items){
|
|
1541
|
+
for(var i = 0; i < items.length; i++){
|
|
1542
|
+
var starts = i > 0 && items[i].offsetTop > items[i - 1].offsetTop;
|
|
1543
|
+
if(starts) items[i].classList.add("line-start"); else items[i].classList.remove("line-start");
|
|
1147
1544
|
}
|
|
1148
|
-
return {perRow:1, boxW:Math.max(MIN_BOX_W, Math.min(usableW, ceiling))};
|
|
1149
|
-
}
|
|
1150
|
-
// M4c-fix amendment 2 (l): a line longer than the box is cut with … (the whole name stays in the node's <title>
|
|
1151
|
-
// and on its step card below the map).
|
|
1152
|
-
function mapLabel(line, maxChars){
|
|
1153
|
-
return line.length <= maxChars ? line : line.slice(0, Math.max(1, maxChars - 1)) + "\u2026";
|
|
1154
|
-
}
|
|
1155
|
-
function wrapTitleLines(text, maxWidth){
|
|
1156
|
-
var maxChars = Math.max(1, Math.floor((maxWidth - TITLE_HPAD) / CHAR_W));
|
|
1157
|
-
return wrapTitleLinesRaw(text, maxChars).map(function(l){ return mapLabel(l, maxChars); });
|
|
1158
|
-
}
|
|
1159
|
-
function wrapTitleLinesRaw(text, maxChars){
|
|
1160
|
-
if(text.length <= maxChars) return [text];
|
|
1161
|
-
var words = text.split(' ');
|
|
1162
|
-
var line1 = '', i = 0;
|
|
1163
|
-
for(; i < words.length; i++){
|
|
1164
|
-
var cand = line1 ? line1 + ' ' + words[i] : words[i];
|
|
1165
|
-
if(line1 && cand.length > maxChars) break;
|
|
1166
|
-
line1 = cand;
|
|
1167
|
-
}
|
|
1168
|
-
if(!line1) return [text.slice(0, maxChars), text.slice(maxChars)];
|
|
1169
|
-
var line2 = words.slice(i).join(' ');
|
|
1170
|
-
return line2 ? [line1, line2] : [line1];
|
|
1171
|
-
}
|
|
1172
|
-
function buildStepMapSVG(steps, availWidth){
|
|
1173
|
-
var n = steps.length;
|
|
1174
|
-
var naturalW = naturalBoxWidth(steps);
|
|
1175
|
-
var layout = computeMapLayout(n, availWidth, naturalW);
|
|
1176
|
-
var perRow = layout.perRow, boxW = layout.boxW, gap = MAP_GAP;
|
|
1177
|
-
var rows = Math.ceil(n / perRow);
|
|
1178
|
-
var margin = MAP_MARGIN;
|
|
1179
|
-
var titleLines = steps.map(function(s, idx){ return wrapTitleLines(stepTitleText(idx, s), boxW); });
|
|
1180
|
-
var maxLines = titleLines.reduce(function(m, l){ return Math.max(m, l.length); }, 1);
|
|
1181
|
-
var boxH = maxLines > 1 ? BOX_H_2LINE : BOX_H;
|
|
1182
|
-
var rowH = boxH + ROW_GAP;
|
|
1183
|
-
var totalW = margin * 2 + perRow * boxW + (perRow - 1) * gap;
|
|
1184
|
-
var totalH = rows * rowH;
|
|
1185
|
-
var uid = "sm" + (stepMapUidCounter++);
|
|
1186
|
-
var body =
|
|
1187
|
-
'<defs>' +
|
|
1188
|
-
'<marker id="' + uid + '-arrow" markerWidth="8" markerHeight="8" refX="6" refY="3" orient="auto">' +
|
|
1189
|
-
'<path d="M0,0 L6,3 L0,6 z" fill="var(--text-dim)"></path></marker>' +
|
|
1190
|
-
'<marker id="' + uid + '-arrow-grey" markerWidth="8" markerHeight="8" refX="6" refY="3" orient="auto">' +
|
|
1191
|
-
'<path d="M0,0 L6,3 L0,6 z" fill="var(--text-faint)"></path></marker>' +
|
|
1192
|
-
'</defs>';
|
|
1193
|
-
steps.forEach(function(s, idx){
|
|
1194
|
-
var row = Math.floor(idx / perRow);
|
|
1195
|
-
var col = idx % perRow;
|
|
1196
|
-
var rtl = (row % 2) === 1;
|
|
1197
|
-
var slotCol = rtl ? (perRow - 1 - col) : col;
|
|
1198
|
-
var x = margin + slotCol * (boxW + gap);
|
|
1199
|
-
var y = 30 + row * rowH;
|
|
1200
|
-
var colors = stepMapColors(s.state);
|
|
1201
|
-
var lines = titleLines[idx];
|
|
1202
|
-
var nextRowIdx = idx < n - 1 ? Math.floor((idx + 1) / perRow) : null;
|
|
1203
|
-
var hasDrop = nextRowIdx !== null && nextRowIdx !== row;
|
|
1204
|
-
var stateY = y + boxH - 18;
|
|
1205
|
-
// hamr review #4: each node is a clickable group ("map-step", tagged
|
|
1206
|
-
// with the step's own `emits` id) — the click listener that turns this
|
|
1207
|
-
// into a jump to the Audit tab's matching group is wired AFTER
|
|
1208
|
-
// insertion (renderStepMap, below), never inline here (this function
|
|
1209
|
-
// only ever builds a markup string).
|
|
1210
|
-
body += '<g class="map-step" data-emits="' + escapeXml(s.emits) + '" tabindex="0" role="button" aria-label="open ' + escapeXml(s.emits) + ' in Audit"><title>' + escapeXml(stepTitleText(idx, s)) + '</title>';
|
|
1211
|
-
body += '<rect x="' + x + '" y="' + y + '" width="' + boxW + '" height="' + boxH +
|
|
1212
|
-
'" rx="0" fill="var(--panel2)" stroke="' + colors.stroke + '" stroke-width="2"></rect>';
|
|
1213
|
-
if(lines.length === 1){
|
|
1214
|
-
body += '<text x="' + (x + boxW / 2) + '" y="' + (y + 25) +
|
|
1215
|
-
'" text-anchor="middle" font-size="12" fill="var(--text)">' + escapeXml(lines[0]) + '</text>';
|
|
1216
|
-
} else {
|
|
1217
|
-
body += '<text x="' + (x + boxW / 2) + '" y="' + (y + 17) +
|
|
1218
|
-
'" text-anchor="middle" font-size="12" fill="var(--text)">' + escapeXml(lines[0]) + '</text>';
|
|
1219
|
-
body += '<text x="' + (x + boxW / 2) + '" y="' + (y + 29) +
|
|
1220
|
-
'" text-anchor="middle" font-size="12" fill="var(--text)">' + escapeXml(lines[1]) + '</text>';
|
|
1221
|
-
}
|
|
1222
|
-
body += '<text x="' + (x + boxW / 2) + '" y="' + stateY +
|
|
1223
|
-
'" text-anchor="middle" font-size="10" fill="' + colors.textFill + '">' + escapeXml(stateWord(s.state)) + '</text>';
|
|
1224
|
-
body += '</g>';
|
|
1225
|
-
// hamr's 2026-09-27 retry-loop review: a step whose server-computed
|
|
1226
|
-
// tryCount is >1 gets a dashed grey self-loop under its box, labelled
|
|
1227
|
-
// "try N" — ported from bareloop commit 16825a7's own curve (same
|
|
1228
|
-
// control-point proportions, scaled to THIS box's own width). When the
|
|
1229
|
-
// same box also carries the row-to-row snake drop below (which leaves
|
|
1230
|
-
// from dead-center, x=cx), the loop's start is shifted off-center by a
|
|
1231
|
-
// fixed pixel offset so the two paths never begin at the same point.
|
|
1232
|
-
var retryTry = boxRetryTry(s);
|
|
1233
|
-
if(retryTry){
|
|
1234
|
-
var retryShift = hasDrop ? 14 : 0;
|
|
1235
|
-
var bottom = y + boxH;
|
|
1236
|
-
var sx = x + boxW * 0.50 - retryShift, sy = bottom + 5;
|
|
1237
|
-
var c1x = x + boxW * 0.278 - retryShift, c1y = bottom + 30;
|
|
1238
|
-
var c2x = x + boxW * 0.167 - retryShift, c2y = bottom + 30;
|
|
1239
|
-
var ex = x + boxW * 0.028 - retryShift, ey = bottom + 2;
|
|
1240
|
-
body += '<path d="M ' + sx + ' ' + sy + ' C ' + c1x + ' ' + c1y + ', ' + c2x + ' ' + c2y + ', ' + ex + ' ' + ey +
|
|
1241
|
-
'" fill="none" stroke="var(--text-faint)" stroke-width="1.5" stroke-dasharray="3,3" marker-end="url(#' + uid + '-arrow-grey)"></path>';
|
|
1242
|
-
body += '<text x="' + (x + boxW * 0.267 - retryShift) + '" y="' + (bottom + 32) +
|
|
1243
|
-
'" text-anchor="middle" font-size="10" fill="var(--text-faint)">try ' + retryTry + '</text>';
|
|
1244
|
-
}
|
|
1245
|
-
if(idx < n - 1){
|
|
1246
|
-
if(nextRowIdx === row){
|
|
1247
|
-
var midY = y + boxH / 2;
|
|
1248
|
-
if(!rtl){
|
|
1249
|
-
var nx = x + boxW + gap;
|
|
1250
|
-
body += '<line x1="' + (x + boxW) + '" y1="' + midY + '" x2="' + (nx - 2) + '" y2="' + midY +
|
|
1251
|
-
'" stroke="var(--text-dim)" stroke-width="2" marker-end="url(#' + uid + '-arrow)"></line>';
|
|
1252
|
-
} else {
|
|
1253
|
-
var px = x - gap - boxW;
|
|
1254
|
-
body += '<line x1="' + x + '" y1="' + midY + '" x2="' + (px + boxW + 2) + '" y2="' + midY +
|
|
1255
|
-
'" stroke="var(--text-dim)" stroke-width="2" marker-end="url(#' + uid + '-arrow)"></line>';
|
|
1256
|
-
}
|
|
1257
|
-
} else {
|
|
1258
|
-
var cx = x + boxW / 2;
|
|
1259
|
-
body += '<line x1="' + cx + '" y1="' + (y + boxH) + '" x2="' + cx + '" y2="' + (y + rowH - 2) +
|
|
1260
|
-
'" stroke="var(--text-dim)" stroke-width="2" marker-end="url(#' + uid + '-arrow)"></line>';
|
|
1261
|
-
}
|
|
1262
|
-
}
|
|
1263
|
-
});
|
|
1264
|
-
return '<svg width="' + totalW + '" height="' + totalH + '" viewBox="0 0 ' + totalW + ' ' + totalH + '" role="img" aria-label="step map">' + body + '</svg>';
|
|
1265
|
-
}
|
|
1266
|
-
var lastSteps = null;
|
|
1267
|
-
var lastWidth = null;
|
|
1268
|
-
function mapAvailWidth(wrapper){
|
|
1269
|
-
if(!wrapper) return null;
|
|
1270
|
-
var w = wrapper.getBoundingClientRect().width;
|
|
1271
|
-
if(!w) return null;
|
|
1272
|
-
return Math.max(0, w - 20);
|
|
1273
1545
|
}
|
|
1274
1546
|
// hamr review #4: "clicking on cards below codegraph maps should take you
|
|
1275
1547
|
// to audit trail" — a map node's click (or Enter/Space, since the node
|
|
@@ -1287,41 +1559,40 @@
|
|
|
1287
1559
|
function renderStepMap(steps){
|
|
1288
1560
|
var mount = document.getElementById("map-mount");
|
|
1289
1561
|
var wrapper = document.getElementById("map-box");
|
|
1290
|
-
lastSteps = steps;
|
|
1291
1562
|
if(!steps || !steps.length){
|
|
1292
1563
|
mount.innerHTML = "";
|
|
1293
1564
|
wrapper.hidden = true;
|
|
1294
1565
|
return;
|
|
1295
1566
|
}
|
|
1296
1567
|
wrapper.hidden = false;
|
|
1297
|
-
|
|
1298
|
-
lastWidth = w;
|
|
1299
|
-
mount.innerHTML = buildStepMapSVG(steps, w);
|
|
1568
|
+
mount.innerHTML = buildStepMapHTML(steps);
|
|
1300
1569
|
wireMapClicks(mount);
|
|
1570
|
+
reflowMap();
|
|
1301
1571
|
}
|
|
1302
1572
|
function reflowMap(){
|
|
1303
|
-
var
|
|
1304
|
-
if(!
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1573
|
+
var box = document.getElementById("map-box");
|
|
1574
|
+
if(!box || box.hidden) return;
|
|
1575
|
+
markLineStarts(Array.prototype.slice.call(box.querySelectorAll(".map-item")));
|
|
1576
|
+
}
|
|
1577
|
+
var reflowTimer = null;
|
|
1578
|
+
function reflowMapSoon(){
|
|
1579
|
+
if(reflowTimer) clearTimeout(reflowTimer);
|
|
1580
|
+
reflowTimer = setTimeout(function(){ reflowTimer = null; reflowMap(); }, 60);
|
|
1311
1581
|
}
|
|
1312
1582
|
if(typeof ResizeObserver !== "undefined"){
|
|
1313
|
-
var
|
|
1314
|
-
var
|
|
1315
|
-
if(
|
|
1583
|
+
var mapRo = new ResizeObserver(reflowMapSoon);
|
|
1584
|
+
var mapBoxEl = document.getElementById("map-box");
|
|
1585
|
+
if(mapBoxEl) mapRo.observe(mapBoxEl);
|
|
1316
1586
|
} else {
|
|
1317
|
-
window.addEventListener("resize",
|
|
1587
|
+
window.addEventListener("resize", reflowMapSoon);
|
|
1318
1588
|
}
|
|
1319
1589
|
|
|
1320
1590
|
// ---- Runs tab: ONE run-row builder shared by History (flat) and the
|
|
1321
1591
|
// Workflows view's per-flow expansion — the two never drift on how a run
|
|
1322
1592
|
// row reads. Rekeyed from bareloop's job/runid to fwdloop's flow/runId
|
|
1323
1593
|
// (GET /api/runs row shape: src/panel/data.js's listRuns).
|
|
1324
|
-
|
|
1594
|
+
// opts.sub (amendment 12): a Workflows sub-card drops the flow name from its visible text; no other caller passes opts.
|
|
1595
|
+
function buildRunRowEl(r, opts){
|
|
1325
1596
|
var row = document.createElement("div");
|
|
1326
1597
|
// Selected state is computed here, off the module's own `currentRunId`,
|
|
1327
1598
|
// so a row freshly built by a RE-RENDER (switching Runs view mode, or a
|
|
@@ -1346,14 +1617,21 @@
|
|
|
1346
1617
|
row.removeAttribute("role");
|
|
1347
1618
|
return row;
|
|
1348
1619
|
}
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1620
|
+
if(opts && opts.sub){
|
|
1621
|
+
// amendment 12: line 1 `(run-<n>) <word> — <label>`; the flow name stays in title/aria only
|
|
1622
|
+
row.setAttribute("aria-label", fullName);
|
|
1623
|
+
row.innerHTML =
|
|
1624
|
+
'<span class="wf-line1"><span class="' + dotClass(r.glyph, r.pulse) + '"></span>' +
|
|
1625
|
+
'<span class="wf-name" title="' + escapeXml(fullName) + '">(' + escapeXml(r.runId) + ')</span> ' +
|
|
1626
|
+
'<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>' +
|
|
1627
|
+
runMetaLineHtml(r, null);
|
|
1628
|
+
} else {
|
|
1629
|
+
row.innerHTML =
|
|
1630
|
+
'<span class="wf-line1"><span class="' + dotClass(r.glyph, r.pulse) + '"></span>' +
|
|
1631
|
+
'<span class="wf-name" title="' + escapeXml(fullName) + '">' + escapeXml(fullName) + '</span></span>' +
|
|
1632
|
+
'<span class="wf-sign-line" data-testid="run-sign-word">' + signHtml(r.word, r.line, r.label) + '</span>' +
|
|
1633
|
+
runMetaLineHtml(r, null);
|
|
1634
|
+
}
|
|
1357
1635
|
row.addEventListener("click", function(){ openRunFromRuns(r, row); });
|
|
1358
1636
|
row.addEventListener("keydown", function(e){ if(e.key === "Enter" || e.key === " "){ e.preventDefault(); row.click(); } });
|
|
1359
1637
|
return row;
|
|
@@ -1409,6 +1687,16 @@
|
|
|
1409
1687
|
function runSpendText(r){
|
|
1410
1688
|
return r.spend || r.spendWhy || "unknown";
|
|
1411
1689
|
}
|
|
1690
|
+
// M4e amendment 7 item 5: a run's wall time in plain units ("6m23s"), the ONE formatter (`duration`); unrecorded = no part, never a made-up one.
|
|
1691
|
+
function runWallText(r){
|
|
1692
|
+
return typeof r.wallMs === "number" ? duration(r.wallMs) : null;
|
|
1693
|
+
}
|
|
1694
|
+
// ONE builder for a Runs card's last line, job card and sub-card alike: "$0.0616 · 6m23s · 2026-10-06 · 1 run". The separators are real
|
|
1695
|
+
// text between the parts (a CSS ::before is not text: a text read of the card ran "2026-10-061 run" together).
|
|
1696
|
+
function runMetaLineHtml(r, extra){
|
|
1697
|
+
var bits = [runSpendText(r), runWallText(r), runAtText(r), extra].filter(function(b){ return b !== null && b !== undefined; });
|
|
1698
|
+
return '<span class="wf-meta-line">' + bits.map(function(b){ return '<span class="wf-meta">' + escapeXml(b) + '</span>'; }).join('<span class="wf-sep"> · </span>') + '</span>';
|
|
1699
|
+
}
|
|
1412
1700
|
function runAtText(r){
|
|
1413
1701
|
return r.at ? r.at.slice(0,10) : (r.askedAt ? "asked " + readableDateTime(r.askedAt) : (r.startedAt ? "started " + readableDateTime(r.startedAt) : (r.atWhy || "unknown")));
|
|
1414
1702
|
}
|
|
@@ -1535,11 +1823,7 @@
|
|
|
1535
1823
|
'<span class="wf-line1"><span class="wf-caret">' + (hasOtherRuns ? (expanded ? "▼" : "▶") : "") + '</span><span class="' + dotClass(g.lastGlyph, g.lastRow.pulse) + '"></span>' +
|
|
1536
1824
|
'<span class="wf-name" title="' + escapeXml(wfFullName) + '">' + escapeXml(wfFullName) + '</span></span>' +
|
|
1537
1825
|
'<span class="wf-sign-line" data-testid="run-sign-word">' + signHtml(g.lastRow.word, g.lastRow.line, g.lastLabel) + '</span>' +
|
|
1538
|
-
'
|
|
1539
|
-
'<span class="wf-meta">' + escapeXml(runSpendText(g.lastRow)) + '</span>' +
|
|
1540
|
-
'<span class="wf-meta">' + escapeXml(runAtText(g.lastRow)) + '</span>' +
|
|
1541
|
-
'<span class="wf-meta">' + g.runCount + ' run' + (g.runCount === 1 ? '' : 's') + '</span>' +
|
|
1542
|
-
'</span>';
|
|
1826
|
+
runMetaLineHtml(g.lastRow, g.runCount + ' run' + (g.runCount === 1 ? '' : 's'));
|
|
1543
1827
|
row.addEventListener("click", function(){
|
|
1544
1828
|
// a single-run flow has nothing to expand — the click still opens
|
|
1545
1829
|
// the run, it just never toggles `wfExpanded` for it.
|
|
@@ -1553,7 +1837,7 @@
|
|
|
1553
1837
|
if(expanded){
|
|
1554
1838
|
var runsWrap = document.createElement("div");
|
|
1555
1839
|
runsWrap.className = "wf-runs";
|
|
1556
|
-
childRuns.forEach(function(r){ runsWrap.appendChild(buildRunRowEl(r)); });
|
|
1840
|
+
childRuns.forEach(function(r){ runsWrap.appendChild(buildRunRowEl(r, { sub: true })); });
|
|
1557
1841
|
wrap.appendChild(runsWrap);
|
|
1558
1842
|
}
|
|
1559
1843
|
el.appendChild(wrap);
|
|
@@ -1575,6 +1859,7 @@
|
|
|
1575
1859
|
'<div class="chips" role="group" aria-label="Filter">' +
|
|
1576
1860
|
'<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>' +
|
|
1577
1861
|
'<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>' +
|
|
1862
|
+
'<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>' +
|
|
1578
1863
|
'<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>' +
|
|
1579
1864
|
'<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>' +
|
|
1580
1865
|
'<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>' +
|
|
@@ -1846,10 +2131,13 @@
|
|
|
1846
2131
|
'<div class="summary-row" data-testid="summary-close"><span class="sum-label">close:</span><span class="sum-val">' + escapeXml(closeText) + '</span></div>' +
|
|
1847
2132
|
'<div class="summary-row" data-testid="summary-spend"><span class="sum-label">spend:</span><span class="sum-val">' + spendSummaryText(detail.spendSummary) + '</span></div>';
|
|
1848
2133
|
|
|
1849
|
-
|
|
2134
|
+
renderRunActions(detail);
|
|
2135
|
+
// amendment 7 item 2: the Draft is the first box of the Map (an arrow runs on to step 1); the steps keep their own numbers
|
|
2136
|
+
renderStepMap(stepBoxes.length ? [draftBox(detail.draft)].concat(stepBoxes.map(function(b, i){ return Object.assign({}, b, {n: i + 1}); })) : stepBoxes);
|
|
1850
2137
|
|
|
1851
2138
|
var listEl = document.getElementById("step-list");
|
|
1852
2139
|
listEl.innerHTML = "";
|
|
2140
|
+
if(stepBoxes.length) listEl.appendChild(buildDraftCardEl(detail.draft));
|
|
1853
2141
|
stepBoxes.forEach(function(box, idx){
|
|
1854
2142
|
var card = document.createElement("div");
|
|
1855
2143
|
card.className = "step-card" + (box.state === "waiting" ? " running" : "");
|
|
@@ -1883,6 +2171,51 @@
|
|
|
1883
2171
|
listEl.appendChild(card);
|
|
1884
2172
|
});
|
|
1885
2173
|
}
|
|
2174
|
+
// M4e amendment 4 item 4: the Run tab's top action row. Stop shows only while the server says the run is running or waiting at its ask
|
|
2175
|
+
// (`detail.controls.canStop`, the same decision the door reads; amendment 13) and reads "stopping after this step…" once asked;
|
|
2176
|
+
// Resume shows on a stopped or cap-halted run. The server is the arbiter: a refusal is shown in its own words.
|
|
2177
|
+
var stopSay = null;
|
|
2178
|
+
// Walk fix 4: after Sign & resume click 2 is accepted the run is still "stopped" for a few seconds. `window.fwdloopResuming`
|
|
2179
|
+
// ({key, at}, set by the Chat card, the one writer) keeps Resume from being offered again until a detail read shows the run live or
|
|
2180
|
+
// ended (canResume false), or the start was refused, or 30 s pass (a child that died leaves the run stopped; Resume must come back).
|
|
2181
|
+
var RESUMING_MAX_MS = 30000;
|
|
2182
|
+
function resumeWaiting(m, key, canResume, now){
|
|
2183
|
+
return !!m && m.key === key && canResume && now - m.at < RESUMING_MAX_MS;
|
|
2184
|
+
}
|
|
2185
|
+
function renderRunActions(detail){
|
|
2186
|
+
var el = document.getElementById("run-actions");
|
|
2187
|
+
var c = detail.controls || {};
|
|
2188
|
+
el.innerHTML = "";
|
|
2189
|
+
// amendment 7 item 6: Run again sits first, with Stop and Resume — every run control in this one row
|
|
2190
|
+
el.appendChild(makeButton("Run again", "run-again", function(){ if(window.fwdloopRunAgain) window.fwdloopRunAgain(detail); }));
|
|
2191
|
+
if(stopSay && stopSay.key !== detail.flow + "/" + detail.runId) stopSay = null;
|
|
2192
|
+
if(c.canStop){
|
|
2193
|
+
var stopBtn = makeButton(c.stopRequested ? "stopping after this step\u2026" : "Stop", "run-stop", function(){
|
|
2194
|
+
stopBtn.disabled = true;
|
|
2195
|
+
postJSON("/api/stop", { flow: detail.flow, runId: detail.runId }).then(function(r){
|
|
2196
|
+
if(r.status === 202 && r.body && r.body.ok){ stopSay = null; }
|
|
2197
|
+
else { stopSay = { key: detail.flow + "/" + detail.runId, text: (r.body && r.body.say) || "The run could not be stopped." }; }
|
|
2198
|
+
return reloadRun(detail.flow, detail.runId);
|
|
2199
|
+
}).catch(function(){
|
|
2200
|
+
stopSay = { key: detail.flow + "/" + detail.runId, text: networkText() };
|
|
2201
|
+
return reloadRun(detail.flow, detail.runId);
|
|
2202
|
+
});
|
|
2203
|
+
});
|
|
2204
|
+
stopBtn.disabled = !!c.stopRequested;
|
|
2205
|
+
el.appendChild(stopBtn);
|
|
2206
|
+
}
|
|
2207
|
+
var runKey = detail.flow + "/" + detail.runId;
|
|
2208
|
+
if(window.fwdloopResuming && window.fwdloopResuming.key === runKey && !c.canResume) window.fwdloopResuming = null;
|
|
2209
|
+
if(resumeWaiting(window.fwdloopResuming, runKey, !!c.canResume, Date.now())){
|
|
2210
|
+
var rb = makeButton("resuming\u2026", "run-resuming", function(){});
|
|
2211
|
+
rb.disabled = true;
|
|
2212
|
+
el.appendChild(rb);
|
|
2213
|
+
} else if(c.canResume){
|
|
2214
|
+
el.appendChild(makeButton("Resume", "run-resume", function(){ if(window.fwdloopOpenResume) window.fwdloopOpenResume(detail); }));
|
|
2215
|
+
}
|
|
2216
|
+
if(stopSay){ var m = document.createElement("div"); m.className = "answer-msg refused"; m.setAttribute("data-testid", "run-stop-say"); m.textContent = stopSay.text; el.appendChild(m); }
|
|
2217
|
+
el.hidden = el.children.length === 0;
|
|
2218
|
+
}
|
|
1886
2219
|
// A plain lower-case, non-bold data line (hamr's 2026-09-27 styling
|
|
1887
2220
|
// ruling: only the header is upper case/bold) — every non-header line on
|
|
1888
2221
|
// a step card is built through this ONE helper so none of them can drift
|
|
@@ -1894,6 +2227,35 @@
|
|
|
1894
2227
|
div.textContent = text;
|
|
1895
2228
|
return div;
|
|
1896
2229
|
}
|
|
2230
|
+
// M4e amendment 9: the first card under the Map, shaped like a step card: head `0 · drafting` (bold h4) + status (`draftCardLines`), then its two lines; the rows
|
|
2231
|
+
// stay in Audit → Draft. A click opens the Audit tab on that group, like a step card's.
|
|
2232
|
+
function buildDraftCardEl(d){
|
|
2233
|
+
var card = document.createElement("div");
|
|
2234
|
+
card.className = "step-card";
|
|
2235
|
+
card.setAttribute("data-testid", "step-card-draft");
|
|
2236
|
+
var c = draftCardLines(d);
|
|
2237
|
+
var head = document.createElement("div");
|
|
2238
|
+
head.className = "step-head";
|
|
2239
|
+
var h4 = document.createElement("h4");
|
|
2240
|
+
h4.textContent = c.title;
|
|
2241
|
+
head.appendChild(h4);
|
|
2242
|
+
if(c.status !== null){
|
|
2243
|
+
var badge = document.createElement("span");
|
|
2244
|
+
badge.className = "badge " + (c.passed ? auditStateClass("done") + " sign-badge" : auditStateClass("pending"));
|
|
2245
|
+
badge.setAttribute("data-testid", "step-card-draft-state");
|
|
2246
|
+
badge.textContent = c.status;
|
|
2247
|
+
head.appendChild(badge);
|
|
2248
|
+
}
|
|
2249
|
+
card.appendChild(head);
|
|
2250
|
+
c.lines.forEach(function(t, i){
|
|
2251
|
+
if(t !== "") card.appendChild(textLineEl("step-meta", t, "step-card-draft-line-" + (i + 2)));
|
|
2252
|
+
});
|
|
2253
|
+
card.setAttribute("tabindex", "0");
|
|
2254
|
+
card.setAttribute("role", "button");
|
|
2255
|
+
card.addEventListener("click", function(){ openAuditGroup("drafting"); });
|
|
2256
|
+
card.addEventListener("keydown", function(e){ if(e.key === "Enter" || e.key === " "){ e.preventDefault(); card.click(); } });
|
|
2257
|
+
return card;
|
|
2258
|
+
}
|
|
1897
2259
|
// The card's HEADER line: "N · step-name [state] [close class]" — real
|
|
1898
2260
|
// case, bold from CSS (`.step-card .step-head`), the state/close chips
|
|
1899
2261
|
// keeping their own `.badge` color. `auditStateClass` is the SAME
|
|
@@ -2019,13 +2381,13 @@
|
|
|
2019
2381
|
// What a phone tap shows under the one-line entry: everything the line cut short, in full, as wrapped lines.
|
|
2020
2382
|
// Only fields the row actually has — a line with nothing to say is left out, never filled with a made-up value.
|
|
2021
2383
|
function auditDetailHtml(r, word, actionText, isRejectRow){
|
|
2022
|
-
var lines = [["step", r.step]
|
|
2023
|
-
if(!isRejectRow && r.gap) lines.push(["gap", r
|
|
2384
|
+
var lines = (typeof r.step === "string" && r.step.length > 0 ? [["step", r.step]] : []).concat([["result", word], ["action", actionText]]);
|
|
2385
|
+
if(!isRejectRow && r.gap) lines.push(["gap", auditGapText(r)]);
|
|
2024
2386
|
if(Array.isArray(r.refused) && r.refused.length > 0){
|
|
2025
2387
|
lines.push(["refused", r.refused.map(function(x){ return x.verb + " " + x.path + " (" + x.rule + ")"; }).join("; ")]);
|
|
2026
2388
|
}
|
|
2027
2389
|
if(Array.isArray(r.ungranted) && r.ungranted.length > 0) lines.push(["not granted, called anyway", r.ungranted.join(", ")]);
|
|
2028
|
-
lines.push(["close",
|
|
2390
|
+
lines.push(["close", auditCloseText(r)], ["cost", auditCostCellText(r)]);
|
|
2029
2391
|
var when = readableDateTime(r.at);
|
|
2030
2392
|
lines.push(["time", (typeof r.atWhy === "string" && r.atWhy.length > 0) ? r.atWhy : (when || "unknown")]);
|
|
2031
2393
|
return lines.map(function(l){ return "<div class=\"am-d\"><b>" + escapeXml(l[0]) + ":</b> " + escapeXml(l[1]) + "</div>"; }).join("");
|
|
@@ -2037,6 +2399,10 @@
|
|
|
2037
2399
|
// the mobile (max-width:480px) stacked-card CSS reads via `attr()` —
|
|
2038
2400
|
// review item #4: the Time cell (and every other cell) must stay inside
|
|
2039
2401
|
// its own card at 390px, never truncated or pushed off the page edge.
|
|
2402
|
+
// The one place the Attempt and Close cells get their text: a row that is not an attempt (a Stop's note, a setup row) has no attempt
|
|
2403
|
+
// number and no close class — it shows nothing / "—", never "null", "unknown" or "#null".
|
|
2404
|
+
function auditAttemptText(r){ return (typeof r.attempt === "number" || (typeof r.attempt === "string" && r.attempt.length > 0)) ? String(r.attempt) : ""; }
|
|
2405
|
+
function auditCloseText(r){ return (r.setup || r.class === null || r.class === undefined) ? "—" : closeClassLabel(r.class); }
|
|
2040
2406
|
function buildAuditRowEl(r, includeStep){
|
|
2041
2407
|
var tr = document.createElement("tr");
|
|
2042
2408
|
var glyph = verdictGlyph(r.verdict, r.class);
|
|
@@ -2050,17 +2416,17 @@
|
|
|
2050
2416
|
// pre-M4a-3 row or a non-model row appends nothing at all.
|
|
2051
2417
|
var actionText = action + (typeof r.toolsPhrase === "string" ? " · " + r.toolsPhrase : "");
|
|
2052
2418
|
var cells =
|
|
2053
|
-
"<td data-label=\"Attempt\">" + escapeXml(
|
|
2054
|
-
(includeStep ? "<td data-label=\"Step\">" + escapeXml(r.step) + "</td>" : "") +
|
|
2419
|
+
"<td data-label=\"Attempt\">" + escapeXml(auditAttemptText(r)) + "</td>" +
|
|
2420
|
+
(includeStep ? "<td data-label=\"Step\">" + escapeXml(r.stepName || r.step) + "</td>" : "") +
|
|
2055
2421
|
"<td data-label=\"Action\">" + escapeXml(actionText) + "</td>" +
|
|
2056
|
-
"<td data-label=\"Gap\">" + escapeXml(isRejectRow ? "" : (r
|
|
2422
|
+
"<td data-label=\"Gap\">" + escapeXml(isRejectRow ? "" : auditGapText(r)) + "</td>" +
|
|
2057
2423
|
"<td data-label=\"Cost\">" + escapeXml(auditCostCellText(r)) + "</td>" +
|
|
2058
2424
|
"<td data-label=\"Verdict\"><span class=\"badge " + badgeClass + "\">" + escapeXml(word) + "</span></td>" +
|
|
2059
|
-
"<td data-label=\"Close\">" + escapeXml(
|
|
2425
|
+
"<td data-label=\"Close\">" + escapeXml(auditCloseText(r)) + "</td>" +
|
|
2060
2426
|
"<td data-label=\"Time\">" + auditTimeCellHtml(r) + "</td>" +
|
|
2061
2427
|
// phone-only one-line cells (CSS shows these and hides the rest below 640px; hidden on desktop)
|
|
2062
2428
|
"<td class=\"am am-glyph\" aria-hidden=\"true\">" + escapeXml(glyph || "·") + "</td>" +
|
|
2063
|
-
"<td class=\"am am-cost\">" + escapeXml(money(r.usd, r.spendComplete)) + "</td>" +
|
|
2429
|
+
"<td class=\"am am-cost\">" + escapeXml(r.setup ? auditCostCellText(r) : money(r.usd, r.spendComplete)) + "</td>" +
|
|
2064
2430
|
"<td class=\"am am-time\">" + escapeXml(auditShortTime(r)) + "</td>" +
|
|
2065
2431
|
"<td class=\"am am-detail\">" + auditDetailHtml(r, word, actionText, isRejectRow) + "</td>";
|
|
2066
2432
|
tr.innerHTML = cells;
|
|
@@ -2102,13 +2468,27 @@
|
|
|
2102
2468
|
// presentational formatter; nothing here re-derives state/cost/tries).
|
|
2103
2469
|
// Tokens are appended ONLY when the server sent a real total (omitted,
|
|
2104
2470
|
// never "0 tokens", for a pre-M4a-2 row or a no-model-call step).
|
|
2471
|
+
// M4e amendment 10: ONE function for each header line's words, `auditGroupHeaderParts` (status in the step card's `stateWord`, name, then the Draft's figures
|
|
2472
|
+
// or the step's cost and tries); `buildAuditGroupHeaderEl` draws these parts and `auditGroupHeaderText` joins them, so the visible line and its aria are
|
|
2473
|
+
// the same words. `status` is null with no draft record; `state` colors it (`auditStateClass`); `signed`: the status carries its own brackets.
|
|
2474
|
+
function auditGroupHeaderParts(g){
|
|
2475
|
+
var AUDIT_DOT = "\u00b7"; // the separator between the status badge and the name, read by the visible header and the aria line alike
|
|
2476
|
+
if(g.draft){
|
|
2477
|
+
var ds = g.summary;
|
|
2478
|
+
if(!(ds && ds.present)) return {status: null, name: "drafting", why: (ds && ds.why) || "no draft record"};
|
|
2479
|
+
var passed = ds.ended === "done";
|
|
2480
|
+
return {status: passed ? stateWord("done") : "not signed", state: passed ? "done" : "pending", signed: true, name: "drafting", dot: AUDIT_DOT, draftFigs: draftFigures(ds).concat([draftHumanWord(ds)]), passed: passed};
|
|
2481
|
+
}
|
|
2482
|
+
var parts = {status: stateWord(g.state), state: g.state, signed: true, dot: AUDIT_DOT, name: g.step, cost: g.cost || "cost unknown"};
|
|
2483
|
+
if(!g.run) parts.tries = {n: g.tryCount, marks: g.tryMarks}; // the run's own group has no tries
|
|
2484
|
+
return parts;
|
|
2485
|
+
}
|
|
2105
2486
|
function auditGroupHeaderText(g){
|
|
2106
|
-
var
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
return bits.join(" · ");
|
|
2487
|
+
var p = auditGroupHeaderParts(g);
|
|
2488
|
+
if(g.draft) return draftLineText(g.summary);
|
|
2489
|
+
var line = [p.status, p.name, p.cost].join(" " + p.dot + " ");
|
|
2490
|
+
if(p.tries) line += " \u00b7 try " + p.tries.n + " " + p.tries.marks.join("");
|
|
2491
|
+
return line;
|
|
2112
2492
|
}
|
|
2113
2493
|
// hamr's 2026-09-27 review: the header's status word gets the SAME color
|
|
2114
2494
|
// vocabulary the runs list already uses (glyphClass's green/red/amber/
|
|
@@ -2120,51 +2500,70 @@
|
|
|
2120
2500
|
if(state === "done") return "green";
|
|
2121
2501
|
if(state === "waiting") return "amber";
|
|
2122
2502
|
if(state === "stopped") return "red";
|
|
2123
|
-
return "grey";
|
|
2503
|
+
return "grey"; // user-stopped (the same --grey-dot as the [■] dot), pending
|
|
2124
2504
|
}
|
|
2125
2505
|
function auditMarkClass(mark){
|
|
2126
2506
|
if(mark === "✓") return "green";
|
|
2127
2507
|
if(mark === "✗") return "red";
|
|
2128
2508
|
return "grey"; // "·" — still open, no resolution row yet
|
|
2129
2509
|
}
|
|
2510
|
+
// The Draft group's header tail (amendment 7 item 2, 10): `· <time> · $<cost> · <n> model calls ✓` from `auditGroupHeaderParts`' figures (the one
|
|
2511
|
+
// `draftFigures`, `draftCallsWord`); a flow with no draft record says so and has no cost. Apart from buildAuditGroupHeaderEl so the step groups' title keeps no time in it.
|
|
2512
|
+
function draftTailInto(tail, p){
|
|
2513
|
+
function part(cls, text){ var sp = document.createElement("span"); sp.className = cls; sp.textContent = text; tail.appendChild(sp); }
|
|
2514
|
+
part("audit-fold-sep", "\u00b7 ");
|
|
2515
|
+
if(!p.draftFigs){ tail.appendChild(document.createTextNode(p.why)); return; }
|
|
2516
|
+
tail.appendChild(document.createTextNode(p.draftFigs.join(" \u00b7 ") + (p.passed ? " " : "")));
|
|
2517
|
+
if(p.passed) part("mark green", "\u2713");
|
|
2518
|
+
}
|
|
2130
2519
|
// Builds the SAME header line `auditGroupHeaderText` renders as plain
|
|
2131
2520
|
// text (used as this header's aria-label, for a screen reader), but as
|
|
2132
|
-
// real DOM: the status word is its own `<span class="badge STATE">`
|
|
2133
|
-
// (
|
|
2134
|
-
// "[state]" string built here) and each try mark is its own colored
|
|
2521
|
+
// real DOM: the status (the step card's sign and word, amendment 10) is its own `<span class="badge STATE sign-badge">`
|
|
2522
|
+
// (the sign carries its own brackets, so `.sign-badge` draws no second pair) and each try mark is its own colored
|
|
2135
2523
|
// `<span class="mark STATE">` — built directly off `g.state`/`g.tryMarks`,
|
|
2136
2524
|
// never by parsing `auditGroupHeaderText`'s own string back apart.
|
|
2137
2525
|
function buildAuditGroupHeaderEl(g){
|
|
2138
2526
|
var h4 = document.createElement("h4");
|
|
2139
2527
|
h4.className = "audit-status-header";
|
|
2140
|
-
var
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2528
|
+
var p = auditGroupHeaderParts(g);
|
|
2529
|
+
if(p.status !== null){
|
|
2530
|
+
var stateSpan = document.createElement("span");
|
|
2531
|
+
stateSpan.className = "badge " + auditStateClass(p.state) + " sign-badge";
|
|
2532
|
+
stateSpan.setAttribute("data-testid", "audit-group-state");
|
|
2533
|
+
stateSpan.textContent = p.status;
|
|
2534
|
+
h4.appendChild(stateSpan);
|
|
2535
|
+
var dotSpan = document.createElement("span");
|
|
2536
|
+
dotSpan.className = "audit-fold-dot";
|
|
2537
|
+
dotSpan.textContent = p.dot;
|
|
2538
|
+
h4.appendChild(dotSpan);
|
|
2539
|
+
}
|
|
2145
2540
|
// M4c-fix amendment 2 (l): the title is `[sign] name · cost · try N ✗✓` — the name alone is cut with … (own flex child),
|
|
2146
2541
|
// cost and tries never; time and tokens live in each try's detail. The whole name is in the title attribute and aria-label.
|
|
2147
2542
|
var nameSpan = document.createElement("span");
|
|
2148
2543
|
nameSpan.className = "audit-fold-name";
|
|
2149
2544
|
nameSpan.setAttribute("data-testid", "audit-group-name");
|
|
2150
|
-
nameSpan.title =
|
|
2151
|
-
nameSpan.textContent =
|
|
2545
|
+
nameSpan.title = p.name;
|
|
2546
|
+
nameSpan.textContent = p.name;
|
|
2152
2547
|
h4.appendChild(nameSpan);
|
|
2153
2548
|
var tail = document.createElement("span");
|
|
2154
2549
|
tail.className = "audit-fold-tail";
|
|
2155
2550
|
// the dots and the word "try" are their own spans so a phone can drop them (keeping cost, N and the marks)
|
|
2156
2551
|
function tailPart(cls, text){ var sp = document.createElement("span"); sp.className = cls; sp.textContent = text; tail.appendChild(sp); }
|
|
2157
|
-
|
|
2158
|
-
tail.appendChild(document.createTextNode(
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2552
|
+
if(g.draft) draftTailInto(tail, p);
|
|
2553
|
+
else if(!p.tries){ tailPart("audit-fold-sep", "· "); tail.appendChild(document.createTextNode(p.cost)); } // the run's own group: no tries, no dots
|
|
2554
|
+
else {
|
|
2555
|
+
tailPart("audit-fold-sep", "· ");
|
|
2556
|
+
tail.appendChild(document.createTextNode(p.cost));
|
|
2557
|
+
tailPart("audit-fold-sep", " · ");
|
|
2558
|
+
tailPart("audit-fold-try", "try ");
|
|
2559
|
+
tailPart("audit-fold-n", p.tries.n + " ");
|
|
2560
|
+
p.tries.marks.forEach(function(mark){
|
|
2561
|
+
var markSpan = document.createElement("span");
|
|
2562
|
+
markSpan.className = "mark " + auditMarkClass(mark);
|
|
2563
|
+
markSpan.textContent = mark;
|
|
2564
|
+
tail.appendChild(markSpan);
|
|
2565
|
+
});
|
|
2566
|
+
}
|
|
2168
2567
|
h4.appendChild(tail);
|
|
2169
2568
|
return h4;
|
|
2170
2569
|
}
|
|
@@ -2179,10 +2578,17 @@
|
|
|
2179
2578
|
if(auditExpandedRun !== runKey){ auditExpanded = {}; auditExpandedRun = runKey; }
|
|
2180
2579
|
var container = document.getElementById("audit-groups");
|
|
2181
2580
|
container.innerHTML = "";
|
|
2182
|
-
if(!result
|
|
2581
|
+
if(!result) return;
|
|
2183
2582
|
var anyVisible = false;
|
|
2184
|
-
(
|
|
2583
|
+
// amendment 7 item 2: the Draft is the first group, a normal card (collapsed by default); a run with no audit rows yet still has it
|
|
2584
|
+
var draftG = draftGroupFor(result);
|
|
2585
|
+
var groups = (draftG ? [draftG] : []).concat(result.empty ? [] : (result.groups || []));
|
|
2586
|
+
groups.forEach(function(g){
|
|
2185
2587
|
var rows = (g.rows || []).filter(auditRowMatchesFilter);
|
|
2588
|
+
// a flow with no draft record: a header-only card that says so (shown under All; there is nothing to filter)
|
|
2589
|
+
var noRecord = !!g.draft && !(g.summary && g.summary.present);
|
|
2590
|
+
if(noRecord && auditFilterMode !== "all") return;
|
|
2591
|
+
if(noRecord) rows = [{}]; // one placeholder so the card is drawn; it has no table
|
|
2186
2592
|
if(rows.length === 0) return; // a group with no matching rows is hidden, never an empty shell
|
|
2187
2593
|
anyVisible = true;
|
|
2188
2594
|
var wrap = document.createElement("div");
|
|
@@ -2197,8 +2603,9 @@
|
|
|
2197
2603
|
// map/step-card jump) does, never the initial state.
|
|
2198
2604
|
// M4c-fix amendment 2 (f): a step with any failed try (a row with a gap) starts OPEN so its gap is
|
|
2199
2605
|
// seen without a click; the rest start closed. A manual toggle wins on re-render (auditExpanded).
|
|
2200
|
-
var failed = (g.rows || []).some(function(r){ return !!r.gap; });
|
|
2606
|
+
var failed = (g.rows || []).some(function(r){ return !!r.gap && !/^stop/.test(r.verdict || ""); }); // a Stop's own words are not a failed try
|
|
2201
2607
|
var isOpen = Object.prototype.hasOwnProperty.call(auditExpanded, g.step) ? auditExpanded[g.step] : failed;
|
|
2608
|
+
if(g.draft && !Object.prototype.hasOwnProperty.call(auditExpanded, g.step)) isOpen = false; // the Draft starts closed: its card row has a "gap" (the job text)
|
|
2202
2609
|
wrap.classList.add("audit-fold");
|
|
2203
2610
|
if(!isOpen) wrap.classList.add("closed");
|
|
2204
2611
|
var header = buildAuditGroupHeaderEl(g);
|
|
@@ -2208,6 +2615,7 @@
|
|
|
2208
2615
|
header.setAttribute("aria-label", auditGroupHeaderText(g));
|
|
2209
2616
|
header.style.cursor = "pointer";
|
|
2210
2617
|
wrap.appendChild(header);
|
|
2618
|
+
if(noRecord){ container.appendChild(wrap); return; } // nothing to open: the header already says "no draft record"
|
|
2211
2619
|
var table = document.createElement("table");
|
|
2212
2620
|
table.hidden = !isOpen;
|
|
2213
2621
|
table.innerHTML = "<thead><tr><th>Attempt</th><th>Action</th><th>Gap</th><th>Cost</th><th>Verdict</th><th>Close</th><th>Time</th></tr></thead><tbody></tbody>";
|
|
@@ -2243,8 +2651,9 @@
|
|
|
2243
2651
|
function renderAuditFlat(result){
|
|
2244
2652
|
var tbody = document.getElementById("audit-tbody");
|
|
2245
2653
|
tbody.innerHTML = "";
|
|
2246
|
-
if(!result
|
|
2247
|
-
var
|
|
2654
|
+
if(!result) return false;
|
|
2655
|
+
var dr = result.draft && result.draft.present ? result.draft.rows : [];
|
|
2656
|
+
var rows = dr.concat(result.empty ? [] : result.rows).filter(auditRowMatchesFilter);
|
|
2248
2657
|
rows.forEach(function(r){ tbody.appendChild(buildAuditRowEl(r, true)); });
|
|
2249
2658
|
return rows.length > 0;
|
|
2250
2659
|
}
|
|
@@ -2277,17 +2686,27 @@
|
|
|
2277
2686
|
filterEmpty.hidden = true;
|
|
2278
2687
|
}
|
|
2279
2688
|
}
|
|
2689
|
+
// M4e amendment 7 item 2: the Draft as the first Audit group (one card like the steps', collapsed by default): the group header reads the server's one
|
|
2690
|
+
// Draft summary; its rows (card, draft, notes, changes, sign, then this run's own Sign & run rows) come from the same row builder as the run's rows.
|
|
2691
|
+
function draftGroupFor(result){
|
|
2692
|
+
var d = result && result.draft;
|
|
2693
|
+
if(!d) return null;
|
|
2694
|
+
return {step: "drafting", draft: true, summary: d.summary, rows: d.rows || []};
|
|
2695
|
+
}
|
|
2280
2696
|
function renderAudit(result){
|
|
2281
2697
|
var empty = document.getElementById("audit-empty");
|
|
2282
2698
|
var content = document.getElementById("audit-content");
|
|
2283
2699
|
lastAuditResult = result;
|
|
2284
|
-
|
|
2700
|
+
// a run with no audit rows yet still has its Draft: say so in words, and show the card
|
|
2701
|
+
var hasDraft = !!(result && result.draft);
|
|
2702
|
+
if(!result || (result.empty && !hasDraft)){
|
|
2285
2703
|
empty.hidden = false;
|
|
2286
2704
|
empty.textContent = (result && result.why) || "no audit rows for this run";
|
|
2287
2705
|
content.hidden = true;
|
|
2288
2706
|
return;
|
|
2289
2707
|
}
|
|
2290
|
-
empty.hidden =
|
|
2708
|
+
empty.hidden = !result.empty;
|
|
2709
|
+
if(result.empty) empty.textContent = result.why || "no audit rows for this run";
|
|
2291
2710
|
content.hidden = false;
|
|
2292
2711
|
// a fresh run's own view keeps whatever mode (Grouped/Flat) the chips
|
|
2293
2712
|
// are already showing, defaulting to Grouped on first load.
|
|
@@ -2300,13 +2719,16 @@
|
|
|
2300
2719
|
// getRunJob (src/panel/data.js), which reads fwdloop's own signed
|
|
2301
2720
|
// declaration.json + signature.json (one per flow, unlike bareloop's
|
|
2302
2721
|
// multi-source provenance chain — DROPPED per the M4a fit-check). ----
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2722
|
+
// M4e amendment 6 item 6: ONE wait formatter for the Job block's "~ waits" row and the Ask row: "1h", "30m", "1h 30m", never "60m00s".
|
|
2723
|
+
// A wait that is not a whole number of seconds falls back to `duration`.
|
|
2724
|
+
function plainWait(ms){
|
|
2725
|
+
if(typeof ms !== "number" || !(ms > 0)) return "unknown";
|
|
2726
|
+
if(ms % 1000 !== 0) return duration(ms);
|
|
2727
|
+
var t = ms / 1000, h = Math.floor(t / 3600), m = Math.floor((t % 3600) / 60), sec = t % 60;
|
|
2728
|
+
return [h ? h + "h" : "", m ? m + "m" : "", sec ? sec + "s" : ""].filter(Boolean).join(" ");
|
|
2306
2729
|
}
|
|
2307
2730
|
// hamr's 2026-09-27 exit-check review #5: ONE row-per-piece renderer,
|
|
2308
|
-
// shared by
|
|
2309
|
-
// guardrails/success) — a real `.ro-value` per item (never a single
|
|
2731
|
+
// shared by the multi-row Job fields (asks/sources/sends) — a real `.ro-value` per item (never a single
|
|
2310
2732
|
// " · "-joined line, which used to hide a book text value if it happened
|
|
2311
2733
|
// to contain " · " itself), an explicit "none signed" hint for an empty
|
|
2312
2734
|
// list, book text always via `.textContent`.
|
|
@@ -2321,6 +2743,53 @@
|
|
|
2321
2743
|
el.appendChild(textDiv("ro-value", rowTextFn(item)));
|
|
2322
2744
|
});
|
|
2323
2745
|
}
|
|
2746
|
+
// M4e amendments 34 + 37: one step of the signed plan, folded under its job line. All of it is read off `job.plan` (src/panel/data.js
|
|
2747
|
+
// `buildJobPlan`: declaration.json and the setup.jsonl sign row); the page words nothing of its own except "nothing" for an empty list.
|
|
2748
|
+
// The summary is one short line: `step 3 · read → summaryResume · machine check` (may do, then what it makes, then the check kind from the
|
|
2749
|
+
// step's TYPED close class: green/softgreen = machine check, anything else = you check). A write/send step on a line with a signed destination
|
|
2750
|
+
// adds `→ <destination>`. The ask step reads `step 4 · ASK · waits 1h`.
|
|
2751
|
+
function stepSummaryText(st, job){
|
|
2752
|
+
var head = "step " + st.step + " · ";
|
|
2753
|
+
if(st.ask) return head + "ASK · waits " + plainWait(st.waitMs);
|
|
2754
|
+
var out = ((st.mayDo || []).length ? st.mayDo.join(", ") + " " : "") + "→ " + (st.makes || "unknown");
|
|
2755
|
+
var sends = (job.sends || []).filter(function(sd){ return sd.line === st.line; });
|
|
2756
|
+
var writes = (st.mayDo || []).some(function(p){ return p === "write" || p === "send"; });
|
|
2757
|
+
if(writes && sends.length) out += " → " + (sends[0].target || "unknown");
|
|
2758
|
+
return head + out + " · " + (st.checkClass === "green" || st.checkClass === "softgreen" ? "machine check" : "you check");
|
|
2759
|
+
}
|
|
2760
|
+
function jobStepFold(st, job){
|
|
2761
|
+
var fold = document.createElement("details");
|
|
2762
|
+
fold.className = "plan-fold";
|
|
2763
|
+
var sum = document.createElement("summary");
|
|
2764
|
+
sum.className = "plan-sum";
|
|
2765
|
+
sum.textContent = stepSummaryText(st, job);
|
|
2766
|
+
fold.appendChild(sum);
|
|
2767
|
+
fold.appendChild(textDiv("plan-head", "step " + st.step + " · from line " + (st.line === null || st.line === undefined ? "none" : st.line)));
|
|
2768
|
+
fold.appendChild(textDiv("plan-row", "reads: " + ((st.reads || []).length ? st.reads.join(", ") : "nothing")));
|
|
2769
|
+
fold.appendChild(textDiv("plan-row", "makes: " + (st.makes || "unknown")));
|
|
2770
|
+
fold.appendChild(textDiv("plan-row", "may do: " + ((st.mayDo || []).length ? st.mayDo.join(", ") : "nothing (pure stop)")));
|
|
2771
|
+
fold.appendChild(textDiv("plan-row", "check: " + (st.ask ? "ASK · waits " + plainWait(st.waitMs) : (st.check || []).join(" "))));
|
|
2772
|
+
return fold;
|
|
2773
|
+
}
|
|
2774
|
+
// The tail: any step that came from no listed line, then the folded "not checked (the AI's own reading)" summary (its label is always shown).
|
|
2775
|
+
// `placed` (step numbers already folded under a line) is filled by renderJob's line loop before this runs.
|
|
2776
|
+
function paintJobPlan(job, placed){
|
|
2777
|
+
var plan = job.plan || {steps: [], notChecked: {recorded: false, items: []}};
|
|
2778
|
+
var tail = document.getElementById("details-plan-tail");
|
|
2779
|
+
tail.innerHTML = "";
|
|
2780
|
+
(plan.steps || []).filter(function(st){ return !placed[st.step]; }).forEach(function(st){ tail.appendChild(jobStepFold(st, job)); });
|
|
2781
|
+
var nc = plan.notChecked || {};
|
|
2782
|
+
var fold = document.createElement("details");
|
|
2783
|
+
fold.className = "plan-fold plan-notchecked";
|
|
2784
|
+
var sum = document.createElement("summary");
|
|
2785
|
+
sum.className = "plan-sum";
|
|
2786
|
+
sum.textContent = "not checked (the AI's own reading)";
|
|
2787
|
+
fold.appendChild(sum);
|
|
2788
|
+
if(!nc.recorded) fold.appendChild(textDiv("plan-row", "not recorded (signed before amendment 34)"));
|
|
2789
|
+
else if(!(nc.items || []).length) fold.appendChild(textDiv("plan-row", "the AI listed nothing"));
|
|
2790
|
+
else nc.items.forEach(function(it){ fold.appendChild(textDiv("plan-row", it)); });
|
|
2791
|
+
tail.appendChild(fold);
|
|
2792
|
+
}
|
|
2324
2793
|
function renderJob(job){
|
|
2325
2794
|
var empty = document.getElementById("job-empty");
|
|
2326
2795
|
var card = document.getElementById("job-card");
|
|
@@ -2331,12 +2800,39 @@
|
|
|
2331
2800
|
document.getElementById("details-title").textContent = "Job — " + job.flow + " (signed)";
|
|
2332
2801
|
// review #5: "Job (prose)" — the signed lines, numbered, WITHOUT their
|
|
2333
2802
|
// guardrail mixed in (guardrails get their own field below).
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2803
|
+
// M4e amendment 6 item 6: the Job block reads like the card: each numbered line, then its own `~` rows: its guardrail, an ask line's
|
|
2804
|
+
// wait, a send line's destination. (The separate Guardrails field is gone.) `job` already carries the values in force for this run.
|
|
2805
|
+
var jobEl = document.getElementById("details-prose");
|
|
2806
|
+
jobEl.innerHTML = "";
|
|
2807
|
+
// M4e amendment 37: one wrapper per signed line: the human's words, its `~` rows, then its step(s) folded under it (the plan, never in the same row).
|
|
2808
|
+
var placed = {};
|
|
2809
|
+
if(!job.prose || !job.prose.length){
|
|
2810
|
+
jobEl.appendChild(textDiv("hint", "no signed prose lines"));
|
|
2811
|
+
} else {
|
|
2812
|
+
job.prose.forEach(function(l){
|
|
2813
|
+
var cell = document.createElement("div");
|
|
2814
|
+
cell.className = "job-line";
|
|
2815
|
+
cell.appendChild(textDiv("ro-value", l.line + ". " + l.text));
|
|
2816
|
+
(job.guardrails || []).filter(function(g){ return g.line === l.line; }).forEach(function(g){
|
|
2817
|
+
cell.appendChild(textDiv("ro-value sub", "~ " + g.guardrail));
|
|
2818
|
+
});
|
|
2819
|
+
(job.asks || []).filter(function(ak){ return ak.line === l.line; }).forEach(function(ak){
|
|
2820
|
+
cell.appendChild(textDiv("ro-value sub", "~ waits " + plainWait(ak.waitMs)));
|
|
2821
|
+
});
|
|
2822
|
+
(job.sends || []).filter(function(sd){ return sd.line === l.line; }).forEach(function(sd){
|
|
2823
|
+
cell.appendChild(textDiv("ro-value sub", "~ writes out to " + (sd.target || "unknown")));
|
|
2824
|
+
});
|
|
2825
|
+
((job.plan && job.plan.steps) || []).filter(function(st){ return st.line === l.line; }).forEach(function(st){
|
|
2826
|
+
placed[st.step] = true;
|
|
2827
|
+
cell.appendChild(jobStepFold(st, job));
|
|
2828
|
+
});
|
|
2829
|
+
jobEl.appendChild(cell);
|
|
2830
|
+
});
|
|
2831
|
+
}
|
|
2832
|
+
paintJobPlan(job, placed);
|
|
2337
2833
|
// review #5: "Ask" — one row per signed ask line.
|
|
2338
2834
|
renderRowsField("details-asks", job.asks, "no signed asks", function(ak){
|
|
2339
|
-
return "line " + ak.line + " · \"" + ak.question + "\" · waits " +
|
|
2835
|
+
return "line " + ak.line + " · \"" + ak.question + "\" · waits " + plainWait(ak.waitMs);
|
|
2340
2836
|
});
|
|
2341
2837
|
// hamr review #7: no declaration/signature book records a model on the
|
|
2342
2838
|
// flow itself (checked against `src/panel/data.js`'s own
|
|
@@ -2345,17 +2841,13 @@
|
|
|
2345
2841
|
document.getElementById("details-model").textContent = job.model
|
|
2346
2842
|
? ("model used: " + job.model + " (from this run's rows)")
|
|
2347
2843
|
: (job.modelWhy || "no model call recorded yet");
|
|
2348
|
-
//
|
|
2349
|
-
//
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
// `ttlMs`, which is an ask's own wait, not a run-wide time cap) — there
|
|
2353
|
-
// is no signed run-wide time-cap field anywhere in the grammar, so this
|
|
2354
|
-
// NEVER invents one; it says so in words instead.
|
|
2844
|
+
// M4e amendment 6 item 5 + amendment 7 item 4: "$<cap> per run · 1h wait · redo up to <n>"; several asks: "waits 1h, 30m", each through plainWait.
|
|
2845
|
+
// fwdloop has no run-wide time limit (each ask has its own wait), so no ask means no wait part at all.
|
|
2846
|
+
var waitParts = (job.asks || []).filter(function(ak){ return typeof ak.waitMs === "number"; }).map(function(ak){ return plainWait(ak.waitMs); });
|
|
2847
|
+
var waitText = waitParts.length === 0 ? "" : (waitParts.length === 1 ? waitParts[0] + " wait" : "waits " + waitParts.join(", "));
|
|
2355
2848
|
document.getElementById("details-cap").textContent =
|
|
2356
2849
|
(typeof job.capUsd === "number" ? ("$" + job.capUsd.toFixed(2)) : "unknown")
|
|
2357
|
-
+ " · redo
|
|
2358
|
-
+ " · time cap: no time cap signed";
|
|
2850
|
+
+ " per run" + (waitText ? " · " + waitText : "") + " · redo up to " + (typeof job.redoCap === "number" ? job.redoCap : "unknown");
|
|
2359
2851
|
// review #5: "Source" — role -> basename only (never the full signed path).
|
|
2360
2852
|
renderRowsField("details-sources", job.sources, "no signed sources", function(s){
|
|
2361
2853
|
return s.role + " → " + s.basename;
|
|
@@ -2364,15 +2856,6 @@
|
|
|
2364
2856
|
renderRowsField("details-sends", job.sends, "no signed sends", function(s){
|
|
2365
2857
|
return "line " + s.line + " · " + (s.kind || "unknown") + " → " + (s.target || "unknown");
|
|
2366
2858
|
});
|
|
2367
|
-
// review #5: "Guardrails" — ONE field, one row per numbered-line guardrail.
|
|
2368
|
-
renderRowsField("details-guardrails", job.guardrails, "no numbered-line guardrails signed", function(g){
|
|
2369
|
-
return "line " + g.line + " · " + g.guardrail;
|
|
2370
|
-
});
|
|
2371
|
-
// review #5: "Success" — one row per declared step, off data.js's own
|
|
2372
|
-
// deriveStepSuccessText (never re-derived client-side).
|
|
2373
|
-
renderRowsField("details-success", job.success, "no declared steps", function(s){
|
|
2374
|
-
return s.step + " · " + s.text;
|
|
2375
|
-
});
|
|
2376
2859
|
var sig = job.signature;
|
|
2377
2860
|
// hamr's 2026-09-27 final tweak #2: `sig.signedAt` is the raw signed ISO
|
|
2378
2861
|
// stamp (e.g. "2026-09-24T13:22:40.950Z") — rendered readable/local via
|
|
@@ -2479,7 +2962,7 @@
|
|
|
2479
2962
|
var wasHidden = false;
|
|
2480
2963
|
// One writer of `openRunLive`: every paint of the open run's detail goes through here.
|
|
2481
2964
|
function paintRun(d){
|
|
2482
|
-
openRunLive = !(d && (d.glyph === "[\u2713]" || d.glyph === "[\u2717]"));
|
|
2965
|
+
openRunLive = !(d && (d.glyph === "[\u2713]" || d.glyph === "[\u2717]" || d.glyph === "[\u25A0]"));
|
|
2483
2966
|
var next = sig(d);
|
|
2484
2967
|
if(next !== null && next === lastSig.detail) return;
|
|
2485
2968
|
lastSig.detail = next;
|
|
@@ -2560,6 +3043,7 @@
|
|
|
2560
3043
|
if(detail && detail.glyph === "[✓]") return { done: true, cls: "info", text: "run finished [✓] — the sent artifact is in the Run tab" };
|
|
2561
3044
|
if(detail && detail.outcome === "rerun") return { done: true, cls: "info", text: "rerun: this run ended and a fresh run was started — find it in Runs" };
|
|
2562
3045
|
if(detail && detail.glyph === "[✗]") return { done: true, cls: "info", text: "run ended [✗] " + (detail.label || "") };
|
|
3046
|
+
if(detail && detail.glyph === "[■]") return { done: true, cls: "info", text: "run stopped [■] — " + (detail.line || detail.label || "") };
|
|
2563
3047
|
var st = asks && asks.resume ? asks.resume.label : null;
|
|
2564
3048
|
return { done: false, cls: "info", text: (st || "answer applied") + " — run: " + ((detail && detail.label) || "state unknown") };
|
|
2565
3049
|
}
|
|
@@ -2601,7 +3085,7 @@
|
|
|
2601
3085
|
runsFilterBar.setItems(runs);
|
|
2602
3086
|
var first = runs.find(function(r){ return r.runId !== null; });
|
|
2603
3087
|
if(first){
|
|
2604
|
-
|
|
3088
|
+
// the LEFT side is not switched here: a load or refresh always opens on the Chat tab (hamr 2026-10-06)
|
|
2605
3089
|
// newest run overall, opened directly — the Workflows view starts
|
|
2606
3090
|
// collapsed, but its flow row still renders "selected" since
|
|
2607
3091
|
// `runsFilterBar.refresh()` re-renders AFTER currentFlow/currentRunId
|
|
@@ -2640,7 +3124,7 @@
|
|
|
2640
3124
|
if(row.stuck) return row.stuckLine || row.stuckLabel;
|
|
2641
3125
|
if(row.working) return "working on your " + row.working + "…";
|
|
2642
3126
|
if(row.open && row.resume) return row.resume.label;
|
|
2643
|
-
var bits = [row.status];
|
|
3127
|
+
var bits = [row.statusText || row.status];
|
|
2644
3128
|
if(row.reason) bits.push("reason: " + row.reason);
|
|
2645
3129
|
if(row.answeredAt) bits.push("answered " + (readableDateTime(row.answeredAt) || row.answeredAt));
|
|
2646
3130
|
if(row.why) bits.push(row.why);
|
|
@@ -2737,7 +3221,7 @@
|
|
|
2737
3221
|
if(ask.waiting) return textDiv("wf-meta", "time left: " + duration(ask.timeLeftMs));
|
|
2738
3222
|
// an open ask with a saved answer: the header meta line already says the resume label (stuck or starting) — once.
|
|
2739
3223
|
if(ask.open && ask.resume) return null;
|
|
2740
|
-
var bits = [ask.status];
|
|
3224
|
+
var bits = [ask.statusText || ask.status];
|
|
2741
3225
|
if(ask.reason) bits.push("reason: " + ask.reason);
|
|
2742
3226
|
if(ask.answeredAt) bits.push("answered " + (readableDateTime(ask.answeredAt) || ask.answeredAt));
|
|
2743
3227
|
if(ask.why) bits.push(ask.why);
|
|
@@ -2830,9 +3314,8 @@
|
|
|
2830
3314
|
"askid-required": "That click was not understood. Reload the page and try again.",
|
|
2831
3315
|
"body-not-json": "That click was not understood. Reload the page and try again.",
|
|
2832
3316
|
"body-too-large": "That is too long to send. Please shorten your reason.",
|
|
2833
|
-
"
|
|
2834
|
-
"
|
|
2835
|
-
"host-not-own-address": "The panel does not recognise this page. Open the link the terminal printed.",
|
|
3317
|
+
"origin-not-own": "The panel does not recognise this page. Reload it.",
|
|
3318
|
+
"host-not-own-address": "The panel does not recognise this page. Reload it.",
|
|
2836
3319
|
"internal": "Something went wrong inside the panel. Nothing was changed."
|
|
2837
3320
|
};
|
|
2838
3321
|
var byWords = [
|
|
@@ -3043,7 +3526,7 @@
|
|
|
3043
3526
|
if(evidence.draft){
|
|
3044
3527
|
var draftEl = document.createElement("div");
|
|
3045
3528
|
draftEl.className = "ro-value scroll";
|
|
3046
|
-
draftEl
|
|
3529
|
+
fillArtifactText(draftEl, evidence.draft);
|
|
3047
3530
|
// hamr's 2026-09-27 exit-check review #3: "the box headers should be
|
|
3048
3531
|
// bolder" — a real heading class (same weight/size/uppercase posture
|
|
3049
3532
|
// as the Job tab's own field `<label>`s), never the plain `.hint`
|
|
@@ -3069,11 +3552,54 @@
|
|
|
3069
3552
|
}
|
|
3070
3553
|
var art = document.createElement("div");
|
|
3071
3554
|
art.className = "ro-value scroll";
|
|
3072
|
-
|
|
3555
|
+
if(typeof u.text === "string"){ fillArtifactText(art, u.text); } else { art.textContent = "no artifact text on file"; }
|
|
3073
3556
|
ev.appendChild(art);
|
|
3074
3557
|
});
|
|
3075
3558
|
return ev;
|
|
3076
3559
|
}
|
|
3560
|
+
// M4e amendment 4 item 7: a section header of the artifact shows in the panel's blue accent. The signed text gives no
|
|
3561
|
+
// rule for what a header is, so the simplest honest one: a paragraph (text between blank lines) that is one short line
|
|
3562
|
+
// (60 characters or fewer), does not end in a sentence stop, and has another paragraph after it. The text itself is
|
|
3563
|
+
// untouched (textContent still equals the artifact, byte for byte); only the colour of those lines changes.
|
|
3564
|
+
var ART_HEAD_MAX = 60;
|
|
3565
|
+
// A markdown heading line (1-6 "#", a space, then text) is a header wherever it sits, single newlines included, last paragraph too.
|
|
3566
|
+
var ART_MD_HEAD = /^#{1,6} \S/;
|
|
3567
|
+
function isArtifactHeader(para, hasNext){
|
|
3568
|
+
if(ART_MD_HEAD.test(para) && para.indexOf("\n") === -1) return true;
|
|
3569
|
+
return hasNext && para.length > 0 && para.length <= ART_HEAD_MAX && para.indexOf("\n") === -1 && !/[.!?:;,]$/.test(para.trim());
|
|
3570
|
+
}
|
|
3571
|
+
function fillArtifactText(el, text){
|
|
3572
|
+
el.textContent = "";
|
|
3573
|
+
var paras = String(text).split("\n\n");
|
|
3574
|
+
paras.forEach(function(para, i){
|
|
3575
|
+
if(i > 0) el.appendChild(document.createTextNode("\n\n"));
|
|
3576
|
+
if(para.indexOf("\n") !== -1){
|
|
3577
|
+
// several lines in one paragraph: only markdown heading lines are headers; the "\n" between lines stays in the text
|
|
3578
|
+
var plain = "";
|
|
3579
|
+
para.split("\n").forEach(function(line, j){
|
|
3580
|
+
var sep = j > 0 ? "\n" : "";
|
|
3581
|
+
if(ART_MD_HEAD.test(line)){
|
|
3582
|
+
el.appendChild(document.createTextNode(plain + sep));
|
|
3583
|
+
plain = "";
|
|
3584
|
+
var hh = document.createElement("span");
|
|
3585
|
+
hh.className = "art-head";
|
|
3586
|
+
hh.textContent = line;
|
|
3587
|
+
el.appendChild(hh);
|
|
3588
|
+
} else {
|
|
3589
|
+
plain += sep + line;
|
|
3590
|
+
}
|
|
3591
|
+
});
|
|
3592
|
+
if(plain !== "") el.appendChild(document.createTextNode(plain));
|
|
3593
|
+
} else if(isArtifactHeader(para, i < paras.length - 1)){
|
|
3594
|
+
var h = document.createElement("span");
|
|
3595
|
+
h.className = "art-head";
|
|
3596
|
+
h.textContent = para;
|
|
3597
|
+
el.appendChild(h);
|
|
3598
|
+
} else {
|
|
3599
|
+
el.appendChild(document.createTextNode(para));
|
|
3600
|
+
}
|
|
3601
|
+
});
|
|
3602
|
+
}
|
|
3077
3603
|
// M4c item 5: "your answers so far" — one line per answered draft, every field from
|
|
3078
3604
|
// the server's block (data.js groupAskBlocks); the page only lays it out.
|
|
3079
3605
|
function answerLineText(a){
|
|
@@ -3106,7 +3632,7 @@
|
|
|
3106
3632
|
bits.push(stepBit);
|
|
3107
3633
|
bits.push("draft " + block.draftNo);
|
|
3108
3634
|
bits.push(typeof ask.askedAt === "string" ? "asked " + (readableDateTime(ask.askedAt) || ask.askedAt) : "asked: unknown");
|
|
3109
|
-
bits.push(ask.waiting ? "waiting on you" : (ask.open && ask.resume ? ask.resume.label : ask.status));
|
|
3635
|
+
bits.push(ask.waiting ? "waiting on you" : (ask.open && ask.resume ? ask.resume.label : (ask.statusText || ask.status)));
|
|
3110
3636
|
return bits.join(" · ");
|
|
3111
3637
|
}
|
|
3112
3638
|
// One block per signed ask line (M4c item 5), drawn from the server's `blocks`.
|
|
@@ -3225,6 +3751,1150 @@
|
|
|
3225
3751
|
return true;
|
|
3226
3752
|
}
|
|
3227
3753
|
|
|
3754
|
+
// ---- Chat tab: describe, draft, sign and run a job from this page (M4e piece 3). ----
|
|
3755
|
+
// borrowed-from: bareloop src/panel/index.html@ca7195e — `mainButtonFor`, `renderMain`, `renderProgress`, the
|
|
3756
|
+
// scroll-on-change block in `renderActions`, `attachSession`/`reattachLive` (without the reuse/auto-sign branch), `syncCardLock`,
|
|
3757
|
+
// `CLIENT_TERMINAL_PHASES`, `openNewCard`/`resetCard`/`refreshStartEnabled`, `authorPost`/`authorGet`, `fitBox`. fwdloop differs where its shape does: the draft is a detached CLI child whose state is
|
|
3758
|
+
// READ from files (GET /api/author/live and /:id), a start is polled (GET /api/author/start/:id), no token or cookie. Sign is two clicks, no typed name (M4e amendment 2); Revise reopens the card fields and drafts the card again, no note (amendment 14).
|
|
3759
|
+
(function(){
|
|
3760
|
+
var card = document.getElementById("chat-job-card");
|
|
3761
|
+
var clearBtn = document.getElementById("chat-clear-btn");
|
|
3762
|
+
var thread = document.getElementById("chat-thread");
|
|
3763
|
+
var jobEl = document.getElementById("jf-job");
|
|
3764
|
+
var inputsBox = document.getElementById("jf-inputs"); // the New-job inputs textarea (`name: path` per line)
|
|
3765
|
+
var destEl = document.getElementById("jf-dest-folder");
|
|
3766
|
+
var askWaitEl = document.getElementById("jf-ask-wait");
|
|
3767
|
+
var mainBtn = document.getElementById("chat-main-btn");
|
|
3768
|
+
var mainHint = document.getElementById("chat-main-hint");
|
|
3769
|
+
var startOverBtn = document.getElementById("chat-startover-btn");
|
|
3770
|
+
var reviseBtn = document.getElementById("chat-revise-btn");
|
|
3771
|
+
var errEl = document.getElementById("chat-card-error"); // POLL-OWNED: the draft's own sentence (red / stopped)
|
|
3772
|
+
var actionErrEl = document.getElementById("chat-action-error"); // ACTION-OWNED: only a click's refusal; the poll never wipes it
|
|
3773
|
+
var progressRow = document.getElementById("chat-progress-row");
|
|
3774
|
+
var questionBox = document.getElementById("chat-question");
|
|
3775
|
+
var qHead = document.getElementById("chat-q-head");
|
|
3776
|
+
var qLine = document.getElementById("chat-q-line");
|
|
3777
|
+
var qText = document.getElementById("chat-q-text");
|
|
3778
|
+
var qAnswer = document.getElementById("chat-q-answer");
|
|
3779
|
+
var qError = document.getElementById("chat-q-error");
|
|
3780
|
+
var qSend = document.getElementById("chat-q-send");
|
|
3781
|
+
var extrasEl = document.getElementById("chat-extras");
|
|
3782
|
+
var newBox = document.getElementById("jf-new");
|
|
3783
|
+
var runBox = document.getElementById("jf-run");
|
|
3784
|
+
var runInputsEl = document.getElementById("jf-run-inputs");
|
|
3785
|
+
var runFlowSel = document.getElementById("jf-run-flow"); // the Signed flow search box (amendment 7 item 7); nothing is picked until the human picks
|
|
3786
|
+
var rwSearchEl = document.getElementById("rw-search");
|
|
3787
|
+
var rwListEl = document.getElementById("rw-list");
|
|
3788
|
+
var rwPickedEl = document.getElementById("rw-picked");
|
|
3789
|
+
var rwPickedTxt = document.getElementById("rw-picked-txt");
|
|
3790
|
+
var capNoteEl = document.getElementById("jf-cap-note");
|
|
3791
|
+
var runDestEl = document.getElementById("jf-run-dest"); // Run a signed flow: the open Destination box (amendment 5)
|
|
3792
|
+
var runCapEl = document.getElementById("jf-run-cap"); // ... and the open Cap $ box
|
|
3793
|
+
var runWaitsEl = document.getElementById("jf-run-waits"); // ... and one wait box per ask
|
|
3794
|
+
var resumeBox = document.getElementById("jf-resume"); // the "Resume run-<n>" form (amendment 4 item 4): only Cap $ is open
|
|
3795
|
+
var resumeCapEl = document.getElementById("jf-resume-cap");
|
|
3796
|
+
var modeRow = document.getElementById("jf-mode-row");
|
|
3797
|
+
var titleEl = document.getElementById("job-card-title");
|
|
3798
|
+
|
|
3799
|
+
var mode = "new"; // "new" | "run" | "resume"
|
|
3800
|
+
var runSignInfo = null; // Run form, first Sign & run click: { hash } (cleared by any edit)
|
|
3801
|
+
var resumeCtx = null; // the run being resumed: { flow, runId, form }
|
|
3802
|
+
var resumeSignInfo = null; // Resume form, first Sign & resume click: { hash }
|
|
3803
|
+
var modeBeforeResume = "new";
|
|
3804
|
+
var mainAction = "none";
|
|
3805
|
+
var mainStartOver = false; // the main button reads Start over (amendment 14 item 6: that draft names the one it started over from)
|
|
3806
|
+
var startOk = false;
|
|
3807
|
+
var sessionId = null; // the draft's id (GET /api/author/<id>)
|
|
3808
|
+
var sessionLive = false; // a draft exists that is not abandoned or signed
|
|
3809
|
+
var lastState = null; // the draft as the server last described it
|
|
3810
|
+
var signInfo = null; // the first Sign click's reply: { hash, flowName, capUsd, runId }
|
|
3811
|
+
var signClickedOnce = false;
|
|
3812
|
+
var reviseOpen = false; // amendment 14 item 2: Revise was pressed on a green plan, so every card field is open (ONE writer: setReviseOpen)
|
|
3813
|
+
var qKey = ""; // which question the box is showing (draft id + k): the answer box is rewritten only when this changes
|
|
3814
|
+
var qBusy = false; // an answer POST is in flight
|
|
3815
|
+
var extrasKey = "";
|
|
3816
|
+
var busy = false; // a POST is in flight (disabled from the click until the reply)
|
|
3817
|
+
var startId = null; // the run start being watched (GET /api/author/start/<id>)
|
|
3818
|
+
var refusedStartId = null; // a refused start whose sentence is on the card; Clear dismisses it on the server (cleared.json)
|
|
3819
|
+
var pollTimer = null;
|
|
3820
|
+
var startTimer = null;
|
|
3821
|
+
var drafterModel = "";
|
|
3822
|
+
var flows = [];
|
|
3823
|
+
// a draft that is abandoned or signed ends the card's life; red/stopped drafts stay on the card (to read, to fix, to retry)
|
|
3824
|
+
var CLIENT_TERMINAL_PHASES = ["abandoned", "signed"];
|
|
3825
|
+
|
|
3826
|
+
function authorPost(path, body){
|
|
3827
|
+
return postJSON(path, body || {}).then(function(r){ return {status: r.status, body: r.body}; });
|
|
3828
|
+
}
|
|
3829
|
+
function authorGet(path){
|
|
3830
|
+
return fetch(path, { method: "GET", headers: { accept: "application/json" } }).then(function(r){
|
|
3831
|
+
return r.text().then(function(t){
|
|
3832
|
+
var j = null;
|
|
3833
|
+
try{ j = JSON.parse(t); }catch(e){}
|
|
3834
|
+
return j;
|
|
3835
|
+
});
|
|
3836
|
+
});
|
|
3837
|
+
}
|
|
3838
|
+
|
|
3839
|
+
// ---- the pure decisions (no DOM) ----
|
|
3840
|
+
// ONE wide button below the card. Its wording, action and enabled state are ONE pure function of
|
|
3841
|
+
// state = { mode, session, startOk, busy, phase, signClicked, hash, capUsd }.
|
|
3842
|
+
// Actions: draft | run | run-sign-prepare | run-sign | resume-sign-prepare | resume-sign | revise | sign-prepare | sign | none.
|
|
3843
|
+
function mainButtonFor(st){
|
|
3844
|
+
var cap = st.capUsd;
|
|
3845
|
+
var spends = (cap !== undefined && cap !== null && cap !== "") ? " — spends up to $" + cap : "";
|
|
3846
|
+
var blocked = !st.startOk || !!st.busy;
|
|
3847
|
+
if(st.mode === "run"){
|
|
3848
|
+
// 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)
|
|
3849
|
+
if(st.runDiffers){
|
|
3850
|
+
if(st.runSignClicked){
|
|
3851
|
+
var runCap = (cap !== undefined && cap !== null && cap !== "") ? " \u00b7 $" + cap : "";
|
|
3852
|
+
return {text: "Sign " + String(st.hash || "").slice(0, 8) + " & run" + runCap, action: "run-sign", disabled: !!st.busy};
|
|
3853
|
+
}
|
|
3854
|
+
return {text: "Sign & run", action: "run-sign-prepare", disabled: blocked};
|
|
3855
|
+
}
|
|
3856
|
+
return {text: "Run" + spends, action: "run", disabled: blocked};
|
|
3857
|
+
}
|
|
3858
|
+
if(st.mode === "resume"){
|
|
3859
|
+
if(st.runSignClicked){
|
|
3860
|
+
var resCap = (cap !== undefined && cap !== null && cap !== "") ? " \u00b7 $" + cap : "";
|
|
3861
|
+
return {text: "Sign " + String(st.hash || "").slice(0, 8) + " & resume" + resCap, action: "resume-sign", disabled: !!st.busy};
|
|
3862
|
+
}
|
|
3863
|
+
return {text: "Sign & resume", action: "resume-sign-prepare", disabled: blocked};
|
|
3864
|
+
}
|
|
3865
|
+
if(!st.session){
|
|
3866
|
+
return {text: "Draft", action: "draft", disabled: blocked};
|
|
3867
|
+
}
|
|
3868
|
+
if(st.phase === "drafting"){
|
|
3869
|
+
return {text: "Draft", action: "none", disabled: true};
|
|
3870
|
+
}
|
|
3871
|
+
if((st.phase === "red" || st.phase === "stopped") && st.revisable){
|
|
3872
|
+
// amendment 14 items 3-4: a red revise keeps the edits; Draft is another revise, Start over (no revises left) a fresh draft
|
|
3873
|
+
return (st.left || 0) > 0 ? {text: "Draft", action: "revise", disabled: blocked} : {text: "Start over", action: "draft", startOver: true, disabled: blocked};
|
|
3874
|
+
}
|
|
3875
|
+
if(st.phase === "red"){
|
|
3876
|
+
return {text: "Fix and draft again", action: "draft", disabled: blocked};
|
|
3877
|
+
}
|
|
3878
|
+
if(st.phase === "stopped"){
|
|
3879
|
+
return {text: "Draft again", action: "draft", disabled: blocked};
|
|
3880
|
+
}
|
|
3881
|
+
if(st.phase === "revising" || st.phase === "redrafting"){
|
|
3882
|
+
return {text: "Sign & run", action: "none", disabled: true};
|
|
3883
|
+
}
|
|
3884
|
+
if(st.phase === "questions-open"){
|
|
3885
|
+
// amendments 24/25: nothing is signable, and a revise is no way round it: the question is answered first
|
|
3886
|
+
return {text: "Sign & run", action: "none", disabled: true};
|
|
3887
|
+
}
|
|
3888
|
+
if(st.phase === "green"){
|
|
3889
|
+
// amendment 14 item 2: Revise opened the card, so the one button is Draft (the card posted to the revise route)
|
|
3890
|
+
if(st.reviseOpen && st.revisable && (st.left || 0) > 0){
|
|
3891
|
+
return {text: "Draft", action: "revise", disabled: blocked};
|
|
3892
|
+
}
|
|
3893
|
+
if(st.signClicked){
|
|
3894
|
+
var signCap = (cap !== undefined && cap !== null && cap !== "") ? " \u00b7 $" + cap : "";
|
|
3895
|
+
return {text: "Sign " + String(st.hash || "").slice(0, 8) + " & run" + signCap, action: "sign", disabled: !!st.busy};
|
|
3896
|
+
}
|
|
3897
|
+
return {text: "Sign & run", action: "sign-prepare", disabled: !!st.busy};
|
|
3898
|
+
}
|
|
3899
|
+
return {text: "Draft", action: "none", disabled: true};
|
|
3900
|
+
}
|
|
3901
|
+
// pure: the green plan's Revise button (amendment 14 item 2): on a green plan with revises left, before Revise is pressed
|
|
3902
|
+
function reviseShownFor(st){
|
|
3903
|
+
return st.mode === "new" && !!st.session && st.phase === "green" && !!st.revisable && (st.left || 0) > 0 && !st.reviseOpen;
|
|
3904
|
+
}
|
|
3905
|
+
// pure: Start over beside Sign & run (amendment 14 item 3): a green plan whose revises are all used. (A red or stopped one has it as the main button.)
|
|
3906
|
+
function startOverShownFor(st){
|
|
3907
|
+
return st.mode === "new" && !!st.session && st.phase === "green" && !!st.revisable && st.left === 0;
|
|
3908
|
+
}
|
|
3909
|
+
// pure: are the card fields open on a green plan? After Revise, or when no revise is left (amendment 14 item 3: all fields stay open)
|
|
3910
|
+
function greenFieldsOpenFor(st){
|
|
3911
|
+
return !!st.revisable && (!!st.reviseOpen || st.left === 0);
|
|
3912
|
+
}
|
|
3913
|
+
function revisesLeftText(left){
|
|
3914
|
+
return left + (left === 1 ? " revise left" : " revises left");
|
|
3915
|
+
}
|
|
3916
|
+
// pure: the gutter beside a box (amendment 2, plain numbers by amendment 3), one entry per LOGICAL line. The job: `N` on a step line (numbers go on), `~` on a
|
|
3917
|
+
// guardrail line, nothing on an empty line. The inputs: a number per non-empty line.
|
|
3918
|
+
function gutterMarks(kind, text){
|
|
3919
|
+
var n = 0;
|
|
3920
|
+
return String(text).split("\n").map(function(line){
|
|
3921
|
+
var t = line.trim();
|
|
3922
|
+
if(t === "") return "";
|
|
3923
|
+
if(kind === "job" && t.charAt(0) === "~") return "~";
|
|
3924
|
+
n += 1;
|
|
3925
|
+
return String(n);
|
|
3926
|
+
});
|
|
3927
|
+
}
|
|
3928
|
+
// pure: the progress list for a draft. Chronological; a waiting step has no check; a step's detail lines sit under it; no two
|
|
3929
|
+
// identical lines in a row. `ctx` = { model, starting }.
|
|
3930
|
+
function stepsFor(state, ctx){
|
|
3931
|
+
var out = [];
|
|
3932
|
+
var who = ctx.model ? ctx.model : "the drafter";
|
|
3933
|
+
var cap = state && state.card && state.card.capUsd !== undefined && state.card.capUsd !== "" ? state.card.capUsd : "";
|
|
3934
|
+
var capPart = cap !== "" ? ", run cap $" + cap : "";
|
|
3935
|
+
if(state){
|
|
3936
|
+
if(state.phase === "drafting"){
|
|
3937
|
+
out.push({id: "drafting", label: "drafting with " + who + capPart, status: "running", details: []});
|
|
3938
|
+
} else if(Array.isArray(state.revises)){
|
|
3939
|
+
// amendment 14: a draft whose first plan was green. One line per revise with its result; a red one shows its reds (its sentence is on the card error line).
|
|
3940
|
+
out.push({id: "drafted", label: "drafted with " + who, status: "done", details: []});
|
|
3941
|
+
var reviseNo = 0;
|
|
3942
|
+
state.revises.forEach(function(rv){
|
|
3943
|
+
// an answer redraft (amendment 24 item 4) is not a revise and is not counted as one
|
|
3944
|
+
var label = rv.kind === "answers" ? "drafted again with your answers" : "revise " + (reviseNo += 1);
|
|
3945
|
+
if(rv.phase === "running") out.push({id: "revise-" + rv.n, label: label, status: "running", details: []});
|
|
3946
|
+
else if(rv.phase === "green") out.push({id: "revise-" + rv.n, label: label, status: "done", details: []});
|
|
3947
|
+
else out.push({id: "revise-" + rv.n, label: label, status: "failed", details: (rv.reds && rv.reds.length ? rv.reds.slice() : [])});
|
|
3948
|
+
});
|
|
3949
|
+
if(state.phase === "green"){
|
|
3950
|
+
if(ctx.starting) out.push({id: "signed", label: "signed", status: "done", details: []});
|
|
3951
|
+
else out.push({id: "sign", label: ctx.signClicked ? "waiting for your second click" : "waiting for your signature", status: "waiting", details: []});
|
|
3952
|
+
}
|
|
3953
|
+
if(state.phase === "questions-open") out.push({id: "question", label: "waiting for your answer (" + state.openK + " of " + state.total + ")", status: "waiting", details: []});
|
|
3954
|
+
} else if(state.phase === "red"){
|
|
3955
|
+
out.push({id: "drafted", label: "drafted with " + who, status: "done", details: []});
|
|
3956
|
+
out.push({id: "checks", label: "plan checks", status: "failed", details: (state.reds || []).slice()});
|
|
3957
|
+
} else if(state.phase === "stopped"){
|
|
3958
|
+
out.push({id: "drafting", label: "drafting with " + who + capPart, status: "failed", details: []});
|
|
3959
|
+
} else if(state.phase === "green" || state.phase === "revising"){
|
|
3960
|
+
out.push({id: "drafted", label: "drafted with " + who, status: "done", details: []});
|
|
3961
|
+
if(ctx.starting){
|
|
3962
|
+
out.push({id: "signed", label: "signed", status: "done", details: []});
|
|
3963
|
+
} else if(state.phase !== "revising"){
|
|
3964
|
+
out.push({id: "sign", label: ctx.signClicked ? "waiting for your second click" : "waiting for your signature", status: "waiting", details: []});
|
|
3965
|
+
}
|
|
3966
|
+
}
|
|
3967
|
+
}
|
|
3968
|
+
if(ctx.starting) out.push({id: "starting", label: "starting the run", status: "running", details: []});
|
|
3969
|
+
return out.filter(function(s, i){ return i === 0 || JSON.stringify(s) !== JSON.stringify(out[i - 1]); });
|
|
3970
|
+
}
|
|
3971
|
+
// pure: the question box's content (amendments 24/25), or null when no question is open. One question at a time: `openK` of `total`.
|
|
3972
|
+
function questionViewFor(state){
|
|
3973
|
+
if(!state || state.phase !== "questions-open" || !Array.isArray(state.questions)) return null;
|
|
3974
|
+
var q = state.questions.filter(function(x){ return x.k === state.openK; })[0];
|
|
3975
|
+
if(!q) return null;
|
|
3976
|
+
return {
|
|
3977
|
+
key: String(state.draftId) + ":" + q.k, k: q.k,
|
|
3978
|
+
head: "A question the plan raised (" + q.k + " of " + state.total + ")",
|
|
3979
|
+
line: q.lineText ? "About job line " + q.line + ": " + q.lineText : "About job line " + q.line,
|
|
3980
|
+
question: q.question
|
|
3981
|
+
};
|
|
3982
|
+
}
|
|
3983
|
+
// pure: what sits beside a green plan: Your answers (only when the plan was drafted with some), Checked (the machine's sentences from the
|
|
3984
|
+
// typed checks) and Not checked (the drafter's own list, ALWAYS with its label), or null when there is no plan to show
|
|
3985
|
+
function extrasFor(state){
|
|
3986
|
+
if(!state || state.phase !== "green" || !Array.isArray(state.checked)) return null;
|
|
3987
|
+
var blocks = [];
|
|
3988
|
+
if(Array.isArray(state.answers) && state.answers.length){
|
|
3989
|
+
blocks.push({id: "chat-answers", head: "Your answers", sub: "", lines: state.answers.map(function(a){
|
|
3990
|
+
return "line " + a.line + (a.lineText ? ": " + a.lineText : "") + "\n > " + a.answer;
|
|
3991
|
+
})});
|
|
3992
|
+
}
|
|
3993
|
+
blocks.push({id: "chat-checked", head: "Checked", sub: "built by the machine from the plan's checks", lines: state.checked.map(function(c){
|
|
3994
|
+
return (c.line !== null && c.line !== undefined ? "line " + c.line : "step " + c.step) + ": " + c.sentences.join(" ");
|
|
3995
|
+
})});
|
|
3996
|
+
var nc = state.notChecked || {};
|
|
3997
|
+
blocks.push({id: "chat-notchecked", head: "Not checked", sub: nc.label || "the drafter's own reading, not a guarantee", lines: (nc.items && nc.items.length) ? nc.items.map(function(x){ return "- " + x; }) : ["The drafter listed nothing."]});
|
|
3998
|
+
return {blocks: blocks};
|
|
3999
|
+
}
|
|
4000
|
+
// pure: did this POST succeed (one decision for every handler)
|
|
4001
|
+
function chatPostOutcome(r){
|
|
4002
|
+
var ok = !!(r && r.status >= 200 && r.status < 300 && r.body && r.body.ok === true);
|
|
4003
|
+
return {ok: ok, error: ok ? "" : refusalText(r)};
|
|
4004
|
+
}
|
|
4005
|
+
var FIX_BOXES_SAY = "Not started. Fix the marked boxes. Nothing spent.";
|
|
4006
|
+
// the banner that only points at marked boxes goes when the last marked box clears; any other sentence (a refusal with no box) stays
|
|
4007
|
+
function dropFixBoxesBanner(){
|
|
4008
|
+
if(actionErrEl.textContent !== FIX_BOXES_SAY) return;
|
|
4009
|
+
var any = false;
|
|
4010
|
+
card.querySelectorAll(".jf-err").forEach(function(x){ if(x.textContent) any = true; });
|
|
4011
|
+
if(!any) actionErrEl.textContent = "";
|
|
4012
|
+
}
|
|
4013
|
+
// pure: the one sentence for a refused call — the server's own `say`, else its field refusals, else a plain fallback
|
|
4014
|
+
function refusalText(r){
|
|
4015
|
+
var b = r && r.body;
|
|
4016
|
+
if(b && typeof b.say === "string" && b.say !== "") return b.say;
|
|
4017
|
+
if(b && Array.isArray(b.refusals) && b.refusals.length) return FIX_BOXES_SAY;
|
|
4018
|
+
return "The request failed. Nothing was sent.";
|
|
4019
|
+
}
|
|
4020
|
+
|
|
4021
|
+
// grow a text box with its text (a few rows, then it scrolls inside); ONE function for the card boxes.
|
|
4022
|
+
// A box that is hidden (or not laid out) measures 0 and gets no inline height.
|
|
4023
|
+
function fitBox(el){
|
|
4024
|
+
el.style.height = "auto";
|
|
4025
|
+
if(!el.scrollHeight){ el.style.height = ""; return; }
|
|
4026
|
+
var border = el.offsetHeight - el.clientHeight;
|
|
4027
|
+
el.style.height = Math.min(el.scrollHeight + border, 200) + "px";
|
|
4028
|
+
}
|
|
4029
|
+
// Paint a gutter: a hidden mirror of the textarea (same font, same content width, same wrapping) measures each logical line's height;
|
|
4030
|
+
// the gutter gets one entry of exactly that height, its mark on the first visual line. Re-run on every input, resize and fit.
|
|
4031
|
+
function paintGutter(ta, kind){
|
|
4032
|
+
var gut = document.getElementById(ta.id + "-gut");
|
|
4033
|
+
if(!gut || !ta.clientWidth) return; // hidden (the other mode): painted when it is shown
|
|
4034
|
+
var inner = gut.firstChild;
|
|
4035
|
+
var cs = getComputedStyle(ta);
|
|
4036
|
+
var mir = ta.jfMirror;
|
|
4037
|
+
if(!mir){ mir = document.createElement("div"); mir.className = "jf-mirror"; ta.parentNode.appendChild(mir); ta.jfMirror = mir; }
|
|
4038
|
+
["fontFamily", "fontSize", "fontWeight", "fontStyle", "letterSpacing", "wordSpacing", "lineHeight", "tabSize"].forEach(function(k){ mir.style[k] = cs[k]; });
|
|
4039
|
+
gut.style.lineHeight = cs.lineHeight;
|
|
4040
|
+
var padT = (parseFloat(cs.paddingTop) || 0) + (parseFloat(cs.borderTopWidth) || 0);
|
|
4041
|
+
mir.style.width = Math.max(0, ta.clientWidth - (parseFloat(cs.paddingLeft) || 0) - (parseFloat(cs.paddingRight) || 0)) + "px";
|
|
4042
|
+
mir.innerHTML = "";
|
|
4043
|
+
var lines = ta.value.split("\n");
|
|
4044
|
+
lines.forEach(function(l){ var d = document.createElement("div"); d.textContent = l === "" ? "\u200b" : l; mir.appendChild(d); });
|
|
4045
|
+
var marks = gutterMarks(kind, ta.value);
|
|
4046
|
+
var hs = Array.prototype.map.call(mir.children, function(d){ return d.getBoundingClientRect().height; });
|
|
4047
|
+
inner.innerHTML = "";
|
|
4048
|
+
inner.style.paddingTop = padT + "px";
|
|
4049
|
+
marks.forEach(function(m, i){ var d = document.createElement("div"); d.style.height = hs[i] + "px"; d.textContent = m; inner.appendChild(d); });
|
|
4050
|
+
inner.style.transform = "translateY(" + (-ta.scrollTop) + "px)";
|
|
4051
|
+
}
|
|
4052
|
+
function fitCardBoxes(){
|
|
4053
|
+
fitBox(jobEl); fitBox(inputsBox);
|
|
4054
|
+
paintGutter(jobEl, "job"); paintGutter(inputsBox, "inputs");
|
|
4055
|
+
}
|
|
4056
|
+
[[jobEl, "job"], [inputsBox, "inputs"]].forEach(function(pair){
|
|
4057
|
+
pair[0].addEventListener("scroll", function(){
|
|
4058
|
+
var inner = document.getElementById(pair[0].id + "-gut").firstChild;
|
|
4059
|
+
inner.style.transform = "translateY(" + (-pair[0].scrollTop) + "px)";
|
|
4060
|
+
});
|
|
4061
|
+
});
|
|
4062
|
+
|
|
4063
|
+
// ---- the card's boxes ----
|
|
4064
|
+
function byId(id){ return document.getElementById(id); }
|
|
4065
|
+
function setVal(id, v){ byId(id).value = (v === undefined || v === null) ? "" : String(v); }
|
|
4066
|
+
function makeInput(cls, placeholder, value){
|
|
4067
|
+
var el = document.createElement("input");
|
|
4068
|
+
el.type = "text"; el.className = cls; el.placeholder = placeholder; el.autocomplete = "off"; el.spellcheck = false;
|
|
4069
|
+
el.value = (value === undefined || value === null) ? "" : String(value);
|
|
4070
|
+
return el;
|
|
4071
|
+
}
|
|
4072
|
+
function makeErr(){ var d = document.createElement("div"); d.className = "jf-err"; return d; }
|
|
4073
|
+
// Run a signed flow: one row per DECLARED role (the role is fixed), the path prefilled from the last run
|
|
4074
|
+
function paintRunRows(f, sources){
|
|
4075
|
+
runInputsEl.innerHTML = "";
|
|
4076
|
+
((f && f.roles) || []).forEach(function(role){
|
|
4077
|
+
var row = document.createElement("div");
|
|
4078
|
+
row.className = "jf-inrow";
|
|
4079
|
+
var ro = document.createElement("div");
|
|
4080
|
+
ro.className = "jf-role-ro"; ro.textContent = role; ro.setAttribute("data-role", role);
|
|
4081
|
+
row.appendChild(ro);
|
|
4082
|
+
row.appendChild(makeInput("jf-path", "/full/path/to/file", sources ? sources[role] : ""));
|
|
4083
|
+
row.appendChild(makeErr());
|
|
4084
|
+
runInputsEl.appendChild(row);
|
|
4085
|
+
});
|
|
4086
|
+
syncCardLock();
|
|
4087
|
+
}
|
|
4088
|
+
function readRows(container){
|
|
4089
|
+
return Array.prototype.map.call(container.children, function(row){
|
|
4090
|
+
var roleEl = row.querySelector(".jf-role");
|
|
4091
|
+
var role = roleEl ? roleEl.value.trim() : row.querySelector(".jf-role-ro").getAttribute("data-role");
|
|
4092
|
+
return {role: role, path: row.querySelector(".jf-path").value.trim()};
|
|
4093
|
+
});
|
|
4094
|
+
}
|
|
4095
|
+
function currentCard(){
|
|
4096
|
+
return {
|
|
4097
|
+
flowName: byId("jf-name").value.trim(),
|
|
4098
|
+
job: jobEl.value,
|
|
4099
|
+
destination: destEl.value.trim(),
|
|
4100
|
+
inputs: inputsBox.value,
|
|
4101
|
+
capUsd: byId("jf-cap-money").value.trim(),
|
|
4102
|
+
askWait: askWaitEl.value.trim()
|
|
4103
|
+
};
|
|
4104
|
+
}
|
|
4105
|
+
function runWaits(){
|
|
4106
|
+
var waits = {};
|
|
4107
|
+
runWaitsEl.querySelectorAll("input.jf-wait").forEach(function(el){ waits[el.getAttribute("data-line")] = el.value.trim(); });
|
|
4108
|
+
return waits;
|
|
4109
|
+
}
|
|
4110
|
+
function currentRun(){
|
|
4111
|
+
return {
|
|
4112
|
+
flow: pickedFlow || "", inputs: readRows(runInputsEl), runId: (byId("jf-run-id").value.trim() === autoRunId ? "" : byId("jf-run-id").value.trim()),
|
|
4113
|
+
destination: runDestEl.value.trim(), capUsd: runCapEl.value.trim(), askWaits: runWaits()
|
|
4114
|
+
};
|
|
4115
|
+
}
|
|
4116
|
+
// pure-ish (reads the boxes): does the Run form differ from the flow's own signed values? Only a convenience that picks the button's wording
|
|
4117
|
+
// (Run vs Sign & run); the server decides again and never trusts this.
|
|
4118
|
+
function runDiffers(){
|
|
4119
|
+
var f = selectedFlow();
|
|
4120
|
+
if(!f || !f.values) return false;
|
|
4121
|
+
var dest = runDestEl.value.trim();
|
|
4122
|
+
if(f.hasSend && dest !== "" && dest !== f.values.destination) return true;
|
|
4123
|
+
var cap = runCapEl.value.trim();
|
|
4124
|
+
if(cap !== "" && !(isFinite(Number(cap)) && Number(cap) === f.values.capUsd)) return true;
|
|
4125
|
+
var waits = runWaits();
|
|
4126
|
+
return Object.keys(waits).some(function(k){ return waits[k] !== "" && waits[k].toLowerCase() !== f.values.askWaits[k]; });
|
|
4127
|
+
}
|
|
4128
|
+
function capValid(text){
|
|
4129
|
+
var v = Number(text);
|
|
4130
|
+
return text !== "" && isFinite(v) && v > 0;
|
|
4131
|
+
}
|
|
4132
|
+
function selectedFlow(){
|
|
4133
|
+
if(pickedFlow === null) return null;
|
|
4134
|
+
for(var i = 0; i < flows.length; i++){ if(flows[i].flow === pickedFlow) return flows[i]; }
|
|
4135
|
+
return (againEntry && againEntry.flow === pickedFlow) ? againEntry : null;
|
|
4136
|
+
}
|
|
4137
|
+
// client-side convenience only (the server's $0 checks are the real gate): is there enough on the card to click?
|
|
4138
|
+
function startReady(){
|
|
4139
|
+
if(moneyRed) return false; // amendment 4 item 1: a cap that does not fit this month stops you before the click (the server still refuses)
|
|
4140
|
+
if(mode === "run"){
|
|
4141
|
+
return !!selectedFlow() && readRows(runInputsEl).every(function(r){ return r.path !== ""; }) && capValid(runCapEl.value.trim());
|
|
4142
|
+
}
|
|
4143
|
+
if(mode === "resume"){
|
|
4144
|
+
return !!resumeCtx && capValid(resumeCapEl.value.trim());
|
|
4145
|
+
}
|
|
4146
|
+
var c = currentCard();
|
|
4147
|
+
var v = Number(c.capUsd);
|
|
4148
|
+
return c.flowName !== "" && c.job.trim() !== "" && c.capUsd !== "" && isFinite(v) && v > 0;
|
|
4149
|
+
}
|
|
4150
|
+
|
|
4151
|
+
// ---- the money note under Cap (M4e amendment 4 items 1-2) ----
|
|
4152
|
+
// borrowed-from: bareloop src/panel/index.html@c1d87ce — `refreshCapNote` (debounced re-read as the cap is typed), without its
|
|
4153
|
+
// plain-text-only rule: here a note that is red turns the main button off. The words and the numbers come from the server
|
|
4154
|
+
// (GET /api/author/monthly-check, one read-only check); the page decides nothing but where to show them. A fetch error clears the note.
|
|
4155
|
+
var moneyRed = false;
|
|
4156
|
+
var capNoteSeq = 0;
|
|
4157
|
+
var capNoteTimer = null;
|
|
4158
|
+
function setMoneyNote(text, red){
|
|
4159
|
+
var els = [capNoteEl, byId("jf-run-left"), byId("jf-resume-left")];
|
|
4160
|
+
els.forEach(function(el){ el.textContent = ""; el.classList.remove("money-red"); });
|
|
4161
|
+
var el = els[mode === "run" ? 1 : (mode === "resume" ? 2 : 0)];
|
|
4162
|
+
el.textContent = text;
|
|
4163
|
+
el.classList.toggle("money-red", !!red && text !== "");
|
|
4164
|
+
var was = moneyRed;
|
|
4165
|
+
moneyRed = !!red && text !== "";
|
|
4166
|
+
if(was !== moneyRed) refreshStartEnabled();
|
|
4167
|
+
}
|
|
4168
|
+
// a job with a step that is not an Ask needs a model round (the server's own rule decides; this only skips the floor line for an empty box)
|
|
4169
|
+
function jobHasModelStep(){
|
|
4170
|
+
return byId("jf-job").value.split("\n").some(function(l){ var t = l.trim(); return t !== "" && t.charAt(0) !== "~" && !/^ask\b/i.test(t); });
|
|
4171
|
+
}
|
|
4172
|
+
function refreshCapNote(){
|
|
4173
|
+
var cap = mode === "run" ? runCapEl.value.trim() : (mode === "resume" ? resumeCapEl.value.trim() : byId("jf-cap-money").value.trim());
|
|
4174
|
+
var seq = ++capNoteSeq;
|
|
4175
|
+
if(cap === ""){ setMoneyNote("", false); return; }
|
|
4176
|
+
// a Resume holds only what the run has still to spend (amendment 4 item 1): the server is told what is already spent
|
|
4177
|
+
var spent = (mode === "resume" && resumeCtx) ? "&spent=" + encodeURIComponent(String(resumeCtx.form.spentUsd)) : "";
|
|
4178
|
+
authorGet("/api/author/monthly-check?cap=" + encodeURIComponent(cap) + spent).then(function(j){
|
|
4179
|
+
if(seq !== capNoteSeq) return;
|
|
4180
|
+
if(!j || j.ok !== true){ setMoneyNote("", false); return; }
|
|
4181
|
+
var v = Number(cap);
|
|
4182
|
+
if(mode === "new" && j.floorText && isFinite(v) && v > 0 && v < j.floorUsd && jobHasModelStep()){ setMoneyNote(j.floorText, true); return; }
|
|
4183
|
+
// 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
|
|
4184
|
+
var sf = selectedFlow();
|
|
4185
|
+
if(mode === "run" && sf && j.floorText && isFinite(v) && v > 0 && v !== sf.capUsd && v < sf.capFloorUsd){ setMoneyNote(sf.floorText, true); return; }
|
|
4186
|
+
if(mode === "resume" && resumeCtx && j.floorText && isFinite(v) && v > resumeCtx.form.spentUsd && v < resumeCtx.form.floorUsd){ setMoneyNote(resumeCtx.form.floorText, true); return; }
|
|
4187
|
+
setMoneyNote(typeof j.text === "string" ? j.text : "", j.red === true);
|
|
4188
|
+
}).catch(function(){ if(seq === capNoteSeq) setMoneyNote("", false); });
|
|
4189
|
+
}
|
|
4190
|
+
function scheduleCapNote(){
|
|
4191
|
+
if(capNoteTimer) clearTimeout(capNoteTimer);
|
|
4192
|
+
capNoteTimer = setTimeout(refreshCapNote, 250);
|
|
4193
|
+
}
|
|
4194
|
+
|
|
4195
|
+
// ---- a refusal shows next to its box ----
|
|
4196
|
+
function clearFieldErrors(){
|
|
4197
|
+
card.querySelectorAll(".jf-err").forEach(function(e){ e.textContent = ""; });
|
|
4198
|
+
}
|
|
4199
|
+
function errElFor(field){
|
|
4200
|
+
var m = /^inputs\.(\d+)$/.exec(field);
|
|
4201
|
+
if(m){ // a Run-a-signed-flow row (the New job card reports "inputs" by line number)
|
|
4202
|
+
var row = runInputsEl.children[Number(m[1])];
|
|
4203
|
+
return row ? row.querySelector(".jf-err") : null;
|
|
4204
|
+
}
|
|
4205
|
+
if(field === "inputs") return byId(mode === "run" ? "jf-err-run-inputs" : "jf-err-inputs");
|
|
4206
|
+
if(mode === "run" && (field === "destination" || field === "capUsd")) return byId("jf-err-run-" + field);
|
|
4207
|
+
if(mode === "run" && /^askWaits/.test(field)) return byId("jf-err-run-askWaits");
|
|
4208
|
+
if(mode === "resume" && field === "capUsd") return byId("jf-err-resume-capUsd");
|
|
4209
|
+
return byId("jf-err-" + field);
|
|
4210
|
+
}
|
|
4211
|
+
// returns the sentences that had no box to sit next to
|
|
4212
|
+
function showRefusals(list){
|
|
4213
|
+
var unplaced = [];
|
|
4214
|
+
list.forEach(function(r){
|
|
4215
|
+
var el = errElFor(String(r.field));
|
|
4216
|
+
if(el){ el.textContent = el.textContent ? el.textContent + " " + r.say : r.say; } else { unplaced.push(r.say); }
|
|
4217
|
+
});
|
|
4218
|
+
return unplaced;
|
|
4219
|
+
}
|
|
4220
|
+
|
|
4221
|
+
// ---- the lock: while a draft is drafting or waiting to be signed, a start is in flight, or a POST is out, NOTHING on the card
|
|
4222
|
+
// is editable (the draft was made from these values). ONE function owns it. A red or stopped draft unlocks the card (fix, draft again).
|
|
4223
|
+
function cardLocked(){
|
|
4224
|
+
var ph = (sessionLive && lastState) ? lastState.phase : null;
|
|
4225
|
+
// amendment 14: a green plan locks the card until Revise opens it (or no revise is left); a red or stopped one is open
|
|
4226
|
+
var greenOpen = ph === "green" && greenFieldsOpenFor({revisable: Array.isArray(lastState.revises), reviseOpen: reviseOpen, left: lastState.revisesLeft});
|
|
4227
|
+
return busy || startId !== null || (mode === "new" && (ph === "drafting" || ph === "revising" || ph === "redrafting" || ph === "questions-open" || (ph === "green" && !greenOpen)));
|
|
4228
|
+
}
|
|
4229
|
+
function syncCardLock(){
|
|
4230
|
+
var on = cardLocked();
|
|
4231
|
+
card.querySelectorAll("input[type=text], textarea").forEach(function(el){ el.readOnly = on; el.classList.toggle("locked", on); });
|
|
4232
|
+
runFlowSel.disabled = on;
|
|
4233
|
+
runFlowSel.classList.toggle("locked", on);
|
|
4234
|
+
rwPickedEl.classList.toggle("locked", on);
|
|
4235
|
+
card.querySelectorAll('input[name="jf-mode"]').forEach(function(r){ r.disabled = on || sessionLive; });
|
|
4236
|
+
}
|
|
4237
|
+
// top-right: Abandon while a draft is live and unsigned, else Clear
|
|
4238
|
+
function clearButtonFor(live, hasId){
|
|
4239
|
+
return live ? {text: "Abandon", disabled: !hasId || busy} : {text: "Clear", disabled: busy};
|
|
4240
|
+
}
|
|
4241
|
+
function refreshClearBtn(){
|
|
4242
|
+
var b = mode === "resume" ? {text: "Cancel", disabled: busy} : clearButtonFor(sessionLive, !!sessionId);
|
|
4243
|
+
clearBtn.textContent = b.text;
|
|
4244
|
+
clearBtn.disabled = b.disabled;
|
|
4245
|
+
}
|
|
4246
|
+
function refreshStartEnabled(){
|
|
4247
|
+
startOk = startReady();
|
|
4248
|
+
syncCardLock();
|
|
4249
|
+
renderMain();
|
|
4250
|
+
refreshClearBtn();
|
|
4251
|
+
}
|
|
4252
|
+
|
|
4253
|
+
// ---- Run a signed flow: the list comes from the server (only flows whose signature checks out) ----
|
|
4254
|
+
var paintedFlow = null;
|
|
4255
|
+
// the Signed flow search (amendment 7 item 7): what is picked is a flow, and optionally one of its runs (then that run's values fill the boxes)
|
|
4256
|
+
var pickedFlow = null, pickedRun = null, pickedLabel = "", againEntry = null, rwShown = [], rwHl = 0;
|
|
4257
|
+
function pickedKey(){ return pickedFlow === null ? "" : pickedFlow + "/" + (pickedRun ? pickedRun.runId : ""); }
|
|
4258
|
+
var autoRunId = ""; // the prefilled next name (amendment 3): an untouched box sends "" and the server claims the next number itself
|
|
4259
|
+
// the signed job as the dimmed read-only block both forms show (amendment 4/5: what a run cannot change is shown, not editable)
|
|
4260
|
+
function paintJobDim(el, lines){
|
|
4261
|
+
el.innerHTML = "";
|
|
4262
|
+
(lines || []).forEach(function(l){
|
|
4263
|
+
var row = document.createElement("div");
|
|
4264
|
+
row.className = "ro-line";
|
|
4265
|
+
var n = document.createElement("span"); n.className = "ro-n"; n.textContent = String(l.n);
|
|
4266
|
+
var t = document.createElement("span"); t.textContent = (l.ask ? "Ask: " : "") + l.text + (l.guardrail ? " ~ " + l.guardrail : "");
|
|
4267
|
+
row.appendChild(n); row.appendChild(t);
|
|
4268
|
+
el.appendChild(row);
|
|
4269
|
+
});
|
|
4270
|
+
}
|
|
4271
|
+
function paintRunFlow(){
|
|
4272
|
+
var f = selectedFlow();
|
|
4273
|
+
var v = f ? (pickedRun ? pickedRun.values : f.values) : null; // a picked run's own values, else the flow's own
|
|
4274
|
+
paintedFlow = pickedKey();
|
|
4275
|
+
runSignInfo = null;
|
|
4276
|
+
paintJobDim(byId("jf-run-job"), f ? f.jobLines : []);
|
|
4277
|
+
runDestEl.value = v && v.destination ? v.destination : "";
|
|
4278
|
+
runDestEl.readOnly = !(f && f.hasSend);
|
|
4279
|
+
runDestEl.classList.toggle("locked", !(f && f.hasSend));
|
|
4280
|
+
byId("jf-run-dest-hint").textContent = !f ? "" : (f.hasSend ? "Where the accepted result is placed, at the last step. A different folder is signed for this run only." : "This flow has no send step, so there is no destination to set.");
|
|
4281
|
+
runCapEl.value = v ? String(v.capUsd) : "";
|
|
4282
|
+
runWaitsEl.innerHTML = "";
|
|
4283
|
+
Object.keys((v && v.askWaits) || {}).forEach(function(line){
|
|
4284
|
+
var row = document.createElement("div");
|
|
4285
|
+
row.className = "jf-waitrow";
|
|
4286
|
+
var lab = document.createElement("label");
|
|
4287
|
+
lab.textContent = "Ask wait \u00b7 line " + line;
|
|
4288
|
+
var inp = makeInput("jf-wait", "e.g. 30m", v.askWaits[line]);
|
|
4289
|
+
inp.setAttribute("data-line", line);
|
|
4290
|
+
inp.setAttribute("data-testid", "jf-run-wait-" + line);
|
|
4291
|
+
row.appendChild(lab); row.appendChild(inp);
|
|
4292
|
+
runWaitsEl.appendChild(row);
|
|
4293
|
+
});
|
|
4294
|
+
paintRunRows(f, pickedRun ? pickedRun.sources : (f ? f.lastSources : null));
|
|
4295
|
+
autoRunId = f && f.nextRunId ? f.nextRunId : "";
|
|
4296
|
+
byId("jf-run-id").value = autoRunId;
|
|
4297
|
+
clearFieldErrors();
|
|
4298
|
+
refreshCapNote();
|
|
4299
|
+
}
|
|
4300
|
+
// borrowed-from: bareloop src/panel/index.html@b5e37b8 — the Reuse workflow picker: ONE function shows the search box + list before a pick and the
|
|
4301
|
+
// picked box after; a row is the name (the typed part marked) over the flow's track record line.
|
|
4302
|
+
function rwMark(name, q){
|
|
4303
|
+
var i = q ? name.toLowerCase().indexOf(q.toLowerCase()) : -1;
|
|
4304
|
+
if(i < 0) return escapeXml(name);
|
|
4305
|
+
return escapeXml(name.slice(0, i)) + "<mark>" + escapeXml(name.slice(i, i + q.length)) + "</mark>" + escapeXml(name.slice(i + q.length));
|
|
4306
|
+
}
|
|
4307
|
+
function renderFlowSearch(){
|
|
4308
|
+
var picked = pickedFlow !== null;
|
|
4309
|
+
rwSearchEl.hidden = picked;
|
|
4310
|
+
rwPickedEl.hidden = !picked;
|
|
4311
|
+
rwPickedTxt.innerHTML = picked ? "<b>" + escapeXml(pickedLabel) + "</b>" : "";
|
|
4312
|
+
if(picked) return;
|
|
4313
|
+
var q = runFlowSel.value.trim();
|
|
4314
|
+
rwShown = flowChoices(flows, q);
|
|
4315
|
+
if(rwHl >= rwShown.length) rwHl = 0;
|
|
4316
|
+
rwListEl.innerHTML = rwShown.length ? rwShown.map(function(c, i){
|
|
4317
|
+
return '<li data-i="' + i + '" data-testid="rw-item" class="' + (i === rwHl ? "hl" : "") + '"><div class="rw-name">' + rwMark(c.label, q) + '</div><div class="rw-meta">' + escapeXml(c.meta) + "</div></li>";
|
|
4318
|
+
}).join("") : '<div class="rw-empty" data-testid="rw-empty">' + (flows.length === 0 ? "No signed flow has a passed run yet." : 'No flow or run matches "' + escapeXml(q) + '".') + "</div>";
|
|
4319
|
+
}
|
|
4320
|
+
function pickFlowChoice(c){
|
|
4321
|
+
if(!c || cardLocked()) return;
|
|
4322
|
+
var entry = null;
|
|
4323
|
+
flows.forEach(function(f){ if(f.flow === c.flow) entry = f; });
|
|
4324
|
+
if(entry === null) return;
|
|
4325
|
+
var run = null;
|
|
4326
|
+
(entry.runs || []).forEach(function(r){ if(r.runId === c.runId) run = r; });
|
|
4327
|
+
pickedFlow = c.flow; pickedRun = c.runId ? run : null; pickedLabel = c.label; againEntry = null;
|
|
4328
|
+
runFlowSel.value = c.label;
|
|
4329
|
+
byId("jf-err-flow").textContent = "";
|
|
4330
|
+
renderFlowSearch(); paintRunFlow(); refreshStartEnabled();
|
|
4331
|
+
}
|
|
4332
|
+
function unpickFlow(){
|
|
4333
|
+
if(cardLocked()) return;
|
|
4334
|
+
pickedFlow = null; pickedRun = null; pickedLabel = ""; againEntry = null; rwHl = 0;
|
|
4335
|
+
runFlowSel.value = "";
|
|
4336
|
+
renderFlowSearch(); paintRunFlow(); refreshStartEnabled();
|
|
4337
|
+
}
|
|
4338
|
+
function loadFlows(force){
|
|
4339
|
+
authorGet("/api/author/flows").then(function(j){
|
|
4340
|
+
if(!j || j.ok !== true) return;
|
|
4341
|
+
flows = j.flows || [];
|
|
4342
|
+
if(pickedFlow !== null && !selectedFlow()){ pickedFlow = null; pickedRun = null; againEntry = null; pickedLabel = ""; runFlowSel.value = ""; }
|
|
4343
|
+
byId("jf-run-empty").textContent = flows.length ? "" : "No signed flow has a passed run yet. Run a job first, or use Run again on one of its runs.";
|
|
4344
|
+
renderFlowSearch();
|
|
4345
|
+
if(force || paintedFlow !== pickedKey() || (flows.length === 0 && runInputsEl.children.length > 0)) paintRunFlow();
|
|
4346
|
+
refreshCapNote();
|
|
4347
|
+
refreshStartEnabled();
|
|
4348
|
+
}).catch(function(){ /* the card keeps what it had */ });
|
|
4349
|
+
}
|
|
4350
|
+
// the drafting line names the model the drafter really uses (Settings' deepseek row), never a guess
|
|
4351
|
+
function loadModel(){
|
|
4352
|
+
authorGet("/api/settings/providers").then(function(j){
|
|
4353
|
+
var rows = (j && j.ok === true && Array.isArray(j.rows)) ? j.rows : [];
|
|
4354
|
+
for(var i = 0; i < rows.length; i++){ if(rows[i].slot === "deepseek" && rows[i].model){ drafterModel = String(rows[i].model); } }
|
|
4355
|
+
}).catch(function(){ /* the line then says "the drafter" */ });
|
|
4356
|
+
}
|
|
4357
|
+
function setMode(m){
|
|
4358
|
+
mode = m;
|
|
4359
|
+
runSignInfo = null; resumeSignInfo = null;
|
|
4360
|
+
document.querySelectorAll('input[name="jf-mode"]').forEach(function(r){ r.checked = (r.value === m); });
|
|
4361
|
+
newBox.hidden = (m !== "new");
|
|
4362
|
+
runBox.hidden = (m !== "run");
|
|
4363
|
+
resumeBox.hidden = (m !== "resume");
|
|
4364
|
+
modeRow.hidden = (m === "resume");
|
|
4365
|
+
titleEl.textContent = (m === "resume" && resumeCtx) ? "Resume " + resumeCtx.runId + " \u00b7 " + resumeCtx.flow : "Job card";
|
|
4366
|
+
clearFieldErrors();
|
|
4367
|
+
if(m === "run") loadFlows();
|
|
4368
|
+
refreshCapNote();
|
|
4369
|
+
refreshStartEnabled();
|
|
4370
|
+
fitCardBoxes();
|
|
4371
|
+
}
|
|
4372
|
+
|
|
4373
|
+
// ---- render: the progress list, the readout and the one main button ----
|
|
4374
|
+
// Returns true when the list's content actually changed (a new line, or the latest line changed) so the caller can scroll only
|
|
4375
|
+
// then; an identical poll tick returns false and leaves the person's scroll position alone.
|
|
4376
|
+
function renderProgress(steps){
|
|
4377
|
+
var before = progressRow.innerHTML;
|
|
4378
|
+
progressRow.hidden = steps.length === 0;
|
|
4379
|
+
progressRow.innerHTML = steps.map(function(st){
|
|
4380
|
+
var cls = st.status === "waiting" ? "wait" : (st.status === "running" ? "run" : (st.status === "failed" ? "bad" : "ok"));
|
|
4381
|
+
var sign = cls === "ok" ? "✓" : (cls === "bad" ? "✗" : "");
|
|
4382
|
+
return '<li class="step ' + cls + '" data-step="' + escapeXml(st.id) + '"><div class="step-line"><span class="step-label">' + escapeXml(st.label) + '</span>' +
|
|
4383
|
+
'<span class="step-sign">' + sign + '</span></div>' +
|
|
4384
|
+
(st.details || []).map(function(d){ return '<div class="step-detail">' + escapeXml("> " + d) + '</div>'; }).join("") + '</li>';
|
|
4385
|
+
}).join("");
|
|
4386
|
+
return progressRow.innerHTML !== before;
|
|
4387
|
+
}
|
|
4388
|
+
// the plan the human is about to sign: the drafter's readout and the hash; nothing else goes in the thread
|
|
4389
|
+
var threadKey = "";
|
|
4390
|
+
// M4e amendment 7 item 3: the readout is plain text; the server names which lines are headings (one list, authoring.js), shown bold.
|
|
4391
|
+
function readoutHtml(state){
|
|
4392
|
+
var heads = Array.isArray(state.readoutHeads) ? state.readoutHeads : [];
|
|
4393
|
+
return String(state.readout).replace(/\s+$/, "").split("\n").map(function(l, i){
|
|
4394
|
+
return heads.indexOf(i) >= 0 ? '<b class="readout-head">' + escapeXml(l) + '</b>' : escapeXml(l);
|
|
4395
|
+
}).join("\n");
|
|
4396
|
+
}
|
|
4397
|
+
function renderThread(state){
|
|
4398
|
+
// a revise being drafted leaves the plan on show until the new one replaces it (the view carries no plan meanwhile)
|
|
4399
|
+
if(state && (state.phase === "revising" || state.phase === "redrafting")) return;
|
|
4400
|
+
var html = "";
|
|
4401
|
+
if(state && state.phase === "green" && state.readout){
|
|
4402
|
+
html = '<div class="msg bot" data-testid="chat-plan"><div class="who">fwdloop</div>' + readoutHtml(state) +
|
|
4403
|
+
'\n\nPlan hash: ' + escapeXml(state.hash || "") + '</div>';
|
|
4404
|
+
}
|
|
4405
|
+
if(html !== threadKey){ threadKey = html; thread.innerHTML = html; }
|
|
4406
|
+
}
|
|
4407
|
+
// the question box: static markup, so the poll never re-renders over an unsent answer. The texts and the empty answer box are written only
|
|
4408
|
+
// when the QUESTION changes (a new key); the same question on the next tick touches nothing.
|
|
4409
|
+
function renderQuestion(state){
|
|
4410
|
+
var v = questionViewFor(state);
|
|
4411
|
+
if(!v){
|
|
4412
|
+
if(qKey !== ""){ qKey = ""; qAnswer.value = ""; qError.textContent = ""; }
|
|
4413
|
+
questionBox.hidden = true;
|
|
4414
|
+
return;
|
|
4415
|
+
}
|
|
4416
|
+
questionBox.hidden = false;
|
|
4417
|
+
if(v.key !== qKey){
|
|
4418
|
+
qKey = v.key;
|
|
4419
|
+
qHead.textContent = v.head; qLine.textContent = v.line; qText.textContent = v.question;
|
|
4420
|
+
qAnswer.value = ""; qError.textContent = "";
|
|
4421
|
+
}
|
|
4422
|
+
}
|
|
4423
|
+
// Your answers / Checked / Not checked; a plan being drafted again leaves them on show (like the plan), anything else without a green plan clears them
|
|
4424
|
+
function renderExtras(state){
|
|
4425
|
+
if(state && (state.phase === "revising" || state.phase === "redrafting")) return;
|
|
4426
|
+
var v = extrasFor(state);
|
|
4427
|
+
var html = v ? v.blocks.map(function(b){
|
|
4428
|
+
return '<div class="msg" id="' + b.id + '" data-testid="' + b.id + '"><b class="readout-head">' + escapeXml(b.head) + '</b>' +
|
|
4429
|
+
(b.sub ? ' <span class="hint">(' + escapeXml(b.sub) + ')</span>' : '') + '\n' + b.lines.map(escapeXml).join("\n") + '</div>';
|
|
4430
|
+
}).join("") : "";
|
|
4431
|
+
if(html !== extrasKey){ extrasKey = html; extrasEl.innerHTML = html; }
|
|
4432
|
+
}
|
|
4433
|
+
function renderMain(){
|
|
4434
|
+
var st = {mode: mode, session: sessionLive, startOk: startOk, busy: busy || startId !== null, signClicked: signClickedOnce, reviseOpen: reviseOpen};
|
|
4435
|
+
if(sessionLive && lastState){
|
|
4436
|
+
st.phase = lastState.phase;
|
|
4437
|
+
st.hash = signInfo ? signInfo.hash : lastState.hash;
|
|
4438
|
+
st.revisable = Array.isArray(lastState.revises);
|
|
4439
|
+
st.left = lastState.revisesLeft;
|
|
4440
|
+
}
|
|
4441
|
+
if(mode === "run"){
|
|
4442
|
+
st.capUsd = runCapEl.value.trim();
|
|
4443
|
+
st.runDiffers = runDiffers();
|
|
4444
|
+
st.runSignClicked = !!runSignInfo;
|
|
4445
|
+
st.hash = runSignInfo ? runSignInfo.hash : "";
|
|
4446
|
+
} else if(mode === "resume"){
|
|
4447
|
+
st.capUsd = resumeCapEl.value.trim();
|
|
4448
|
+
st.runSignClicked = !!resumeSignInfo;
|
|
4449
|
+
st.hash = resumeSignInfo ? resumeSignInfo.hash : "";
|
|
4450
|
+
} else if(signInfo){
|
|
4451
|
+
st.capUsd = signInfo.capUsd;
|
|
4452
|
+
} else if(lastState && lastState.card){
|
|
4453
|
+
st.capUsd = lastState.card.capUsd;
|
|
4454
|
+
}
|
|
4455
|
+
var b = mainButtonFor(st);
|
|
4456
|
+
mainBtn.textContent = b.text;
|
|
4457
|
+
mainBtn.disabled = b.disabled;
|
|
4458
|
+
mainAction = b.action; mainStartOver = !!b.startOver;
|
|
4459
|
+
// amendment 14 item 3: the count shows while a draft has revises to count; at 0 the way on is Start over
|
|
4460
|
+
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.") : "";
|
|
4461
|
+
reviseBtn.hidden = !reviseShownFor(st);
|
|
4462
|
+
reviseBtn.disabled = !!st.busy;
|
|
4463
|
+
startOverBtn.hidden = !startOverShownFor(st);
|
|
4464
|
+
startOverBtn.disabled = !!st.busy;
|
|
4465
|
+
fitCardBoxes();
|
|
4466
|
+
}
|
|
4467
|
+
function renderActions(state){
|
|
4468
|
+
lastState = state;
|
|
4469
|
+
renderQuestion(state);
|
|
4470
|
+
renderExtras(state);
|
|
4471
|
+
// a newer plan than the one the first Sign click showed (a change came back, or another tab): the first click is void; sign re-checks on the server too
|
|
4472
|
+
if(signInfo && state.hash && state.hash !== signInfo.hash){ signInfo = null; signClickedOnce = false; }
|
|
4473
|
+
// #chat-card-error is POLL-OWNED: it carries only the draft's own sentence (a red plan or a stopped child), written here and
|
|
4474
|
+
// nowhere else. A refused click goes to #chat-action-error, which this function never touches.
|
|
4475
|
+
errEl.textContent = ((state.phase === "red" || state.phase === "stopped") && state.say) ? state.say : "";
|
|
4476
|
+
var progressChanged = renderProgress(stepsFor(state, {model: drafterModel, starting: startId !== null, signClicked: signClickedOnce}));
|
|
4477
|
+
sessionLive = CLIENT_TERMINAL_PHASES.indexOf(state.phase) === -1;
|
|
4478
|
+
refreshStartEnabled();
|
|
4479
|
+
// while the draft is live and the list changed, bring the newest progress line into view.
|
|
4480
|
+
// Never moves keyboard focus, and an unchanged poll tick never scrolls.
|
|
4481
|
+
if(progressChanged && sessionLive && progressRow.lastElementChild){
|
|
4482
|
+
progressRow.lastElementChild.scrollIntoView({block: "nearest"});
|
|
4483
|
+
}
|
|
4484
|
+
}
|
|
4485
|
+
|
|
4486
|
+
// ---- actions ----
|
|
4487
|
+
function stopPoll(){ if(pollTimer){ clearInterval(pollTimer); pollTimer = null; } }
|
|
4488
|
+
function startPoll(){ stopPoll(); pollTimer = setInterval(poll, 2000); }
|
|
4489
|
+
function stopStart(){ if(startTimer){ clearInterval(startTimer); startTimer = null; } startId = null; }
|
|
4490
|
+
// the card's draft is over (abandoned or signed somewhere else, or signed here and its run refused): forget the session, keep
|
|
4491
|
+
// the boxes. Touches neither error line, so a refusal on screen stays on screen.
|
|
4492
|
+
function endSession(){
|
|
4493
|
+
stopPoll();
|
|
4494
|
+
sessionId = null; sessionLive = false; lastState = null; signInfo = null; signClickedOnce = false; reviseOpen = false;
|
|
4495
|
+
threadKey = ""; thread.innerHTML = "";
|
|
4496
|
+
renderQuestion(null); renderExtras(null);
|
|
4497
|
+
errEl.textContent = "";
|
|
4498
|
+
progressRow.hidden = true; progressRow.innerHTML = "";
|
|
4499
|
+
refreshStartEnabled();
|
|
4500
|
+
}
|
|
4501
|
+
function openNewCard(){
|
|
4502
|
+
thread.innerHTML = ""; threadKey = "";
|
|
4503
|
+
renderQuestion(null); renderExtras(null);
|
|
4504
|
+
errEl.textContent = "";
|
|
4505
|
+
actionErrEl.textContent = "";
|
|
4506
|
+
clearFieldErrors();
|
|
4507
|
+
stopStart();
|
|
4508
|
+
sessionId = null; sessionLive = false; lastState = null; signInfo = null; signClickedOnce = false; busy = false; reviseOpen = false;
|
|
4509
|
+
stopPoll();
|
|
4510
|
+
progressRow.hidden = true;
|
|
4511
|
+
progressRow.innerHTML = "";
|
|
4512
|
+
refreshStartEnabled();
|
|
4513
|
+
}
|
|
4514
|
+
// back to a fresh empty card: every box, the inputs, the progress list, the ask box
|
|
4515
|
+
function resetCard(){
|
|
4516
|
+
if(mode === "resume"){ resumeCtx = null; setMode(modeBeforeResume === "resume" ? "new" : modeBeforeResume); }
|
|
4517
|
+
["jf-name", "jf-job", "jf-cap-money", "jf-dest-folder", "jf-inputs"].forEach(function(id){ byId(id).value = ""; });
|
|
4518
|
+
askWaitEl.value = "1h";
|
|
4519
|
+
refreshCapNote();
|
|
4520
|
+
openNewCard();
|
|
4521
|
+
loadFlows(mode === "run");
|
|
4522
|
+
fitCardBoxes();
|
|
4523
|
+
}
|
|
4524
|
+
function chatActionFailed(message){
|
|
4525
|
+
actionErrEl.textContent = message || "The request failed. Nothing was sent.";
|
|
4526
|
+
}
|
|
4527
|
+
function chatActionOk(){
|
|
4528
|
+
actionErrEl.textContent = "";
|
|
4529
|
+
}
|
|
4530
|
+
// a refused POST: field refusals next to their boxes, one sentence in the action line (and any red lines under it)
|
|
4531
|
+
function failFrom(r){
|
|
4532
|
+
var b = r && r.body;
|
|
4533
|
+
var unplaced = (b && Array.isArray(b.refusals)) ? showRefusals(b.refusals) : [];
|
|
4534
|
+
var text = refusalText(r);
|
|
4535
|
+
if(unplaced.length) text += " " + unplaced.join(" ");
|
|
4536
|
+
if(b && Array.isArray(b.reds) && b.reds.length) text += "\n" + b.reds.map(function(x){ return "> " + x; }).join("\n");
|
|
4537
|
+
chatActionFailed(text);
|
|
4538
|
+
}
|
|
4539
|
+
var NETWORK_SAY = "Could not reach the panel. Nothing was sent.";
|
|
4540
|
+
|
|
4541
|
+
function poll(){
|
|
4542
|
+
if(!sessionId) return;
|
|
4543
|
+
var polledId = sessionId;
|
|
4544
|
+
authorGet("/api/author/" + polledId).then(function(j){
|
|
4545
|
+
if(!j || j.ok !== true || polledId !== sessionId) return;
|
|
4546
|
+
if(CLIENT_TERMINAL_PHASES.indexOf(j.phase) !== -1){
|
|
4547
|
+
// abandoned or signed from elsewhere; a start of ours is being watched by pollStart instead
|
|
4548
|
+
if(startId === null) endSession();
|
|
4549
|
+
return;
|
|
4550
|
+
}
|
|
4551
|
+
renderThread(j);
|
|
4552
|
+
renderActions(j);
|
|
4553
|
+
}).catch(function(){ /* transient — next poll tries again */ });
|
|
4554
|
+
}
|
|
4555
|
+
|
|
4556
|
+
// a run start (after a sign, or Run a signed flow): the CLI child may refuse before its run exists, so ask until the start says
|
|
4557
|
+
function beginStart(id){
|
|
4558
|
+
stopStart();
|
|
4559
|
+
startId = id;
|
|
4560
|
+
refusedStartId = null;
|
|
4561
|
+
busy = false;
|
|
4562
|
+
startTimer = setInterval(pollStart, 1000);
|
|
4563
|
+
if(lastState){ renderActions(lastState); } else {
|
|
4564
|
+
renderProgress(stepsFor(null, {model: drafterModel, starting: true, signClicked: false}));
|
|
4565
|
+
refreshStartEnabled();
|
|
4566
|
+
}
|
|
4567
|
+
pollStart();
|
|
4568
|
+
}
|
|
4569
|
+
function pollStart(){
|
|
4570
|
+
var watching = startId;
|
|
4571
|
+
if(!watching) return;
|
|
4572
|
+
authorGet("/api/author/start/" + watching).then(function(j){
|
|
4573
|
+
if(watching !== startId) return;
|
|
4574
|
+
if(!j) return;
|
|
4575
|
+
if(j.ok === true && j.phase === "started"){
|
|
4576
|
+
// the run lives in Runs now; the card goes back to the empty card
|
|
4577
|
+
stopStart();
|
|
4578
|
+
resetCard();
|
|
4579
|
+
document.getElementById("tab-runs").click();
|
|
4580
|
+
reloadLists();
|
|
4581
|
+
return;
|
|
4582
|
+
}
|
|
4583
|
+
if(j.ok === true && j.phase === "refused"){
|
|
4584
|
+
// the CLI's own sentence ("Nothing spent." is in it); it STAYS until the next action
|
|
4585
|
+
var signed = j.kind === "sign";
|
|
4586
|
+
stopStart();
|
|
4587
|
+
window.fwdloopResuming = null; // a refused start leaves the run stopped: Resume is offered again
|
|
4588
|
+
refusedStartId = j.startId;
|
|
4589
|
+
chatActionFailed(signed ? j.say + " The flow is signed; start it from \"Run a signed flow\"." : j.say);
|
|
4590
|
+
if(signed){ endSession(); loadFlows(true); } else { progressRow.hidden = true; progressRow.innerHTML = ""; refreshStartEnabled(); }
|
|
4591
|
+
return;
|
|
4592
|
+
}
|
|
4593
|
+
if(j.ok === false && j.refused === "no-such-start"){
|
|
4594
|
+
stopStart();
|
|
4595
|
+
chatActionFailed("The panel could not find this start. Look in the Runs tab to see whether the run began.");
|
|
4596
|
+
refreshStartEnabled();
|
|
4597
|
+
}
|
|
4598
|
+
}).catch(function(){ /* transient — next tick tries again */ });
|
|
4599
|
+
}
|
|
4600
|
+
|
|
4601
|
+
// Send (amendments 24/25): the answer to the question now open. A blank answer is refused by the server in plain words and the question stays open.
|
|
4602
|
+
function doAnswer(){
|
|
4603
|
+
if(qBusy || !sessionId || !lastState || lastState.phase !== "questions-open") return;
|
|
4604
|
+
qBusy = true; qSend.disabled = true; qError.textContent = "";
|
|
4605
|
+
var id = sessionId;
|
|
4606
|
+
authorPost("/api/author/" + id + "/answer", {k: lastState.openK, answer: qAnswer.value}).then(function(r){
|
|
4607
|
+
qBusy = false; qSend.disabled = false;
|
|
4608
|
+
if(id !== sessionId) return;
|
|
4609
|
+
if(!(r.status >= 200 && r.status < 300 && r.body && r.body.ok === true)){ qError.textContent = refusalText(r); return; }
|
|
4610
|
+
qAnswer.value = "";
|
|
4611
|
+
poll();
|
|
4612
|
+
}).catch(function(){ qBusy = false; qSend.disabled = false; qError.textContent = NETWORK_SAY; });
|
|
4613
|
+
}
|
|
4614
|
+
function doDraft(startedOverFrom){
|
|
4615
|
+
clearFieldErrors();
|
|
4616
|
+
chatActionOk();
|
|
4617
|
+
// disabled from the click until the reply; unlocked below only if the draft is refused
|
|
4618
|
+
busy = true;
|
|
4619
|
+
refreshStartEnabled();
|
|
4620
|
+
var body = currentCard();
|
|
4621
|
+
if(startedOverFrom) body.startedOverFrom = startedOverFrom;
|
|
4622
|
+
authorPost("/api/author/draft", body).then(function(r){
|
|
4623
|
+
busy = false;
|
|
4624
|
+
var o = chatPostOutcome(r);
|
|
4625
|
+
if(!o.ok){ failFrom(r); refreshStartEnabled(); return; }
|
|
4626
|
+
sessionId = r.body.draftId;
|
|
4627
|
+
sessionLive = true;
|
|
4628
|
+
signInfo = null; signClickedOnce = false; reviseOpen = false;
|
|
4629
|
+
thread.innerHTML = ""; threadKey = "";
|
|
4630
|
+
renderActions({draftId: sessionId, phase: "drafting", card: {capUsd: body.capUsd}});
|
|
4631
|
+
startPoll();
|
|
4632
|
+
poll();
|
|
4633
|
+
}).catch(function(){ busy = false; chatActionFailed(NETWORK_SAY); refreshStartEnabled(); });
|
|
4634
|
+
}
|
|
4635
|
+
function doRun(){
|
|
4636
|
+
clearFieldErrors();
|
|
4637
|
+
chatActionOk();
|
|
4638
|
+
busy = true;
|
|
4639
|
+
refreshStartEnabled();
|
|
4640
|
+
authorPost("/api/author/run", currentRun()).then(function(r){
|
|
4641
|
+
var o = chatPostOutcome(r);
|
|
4642
|
+
if(!o.ok){ busy = false; failFrom(r); refreshStartEnabled(); return; }
|
|
4643
|
+
beginStart(r.body.startId);
|
|
4644
|
+
}).catch(function(){ busy = false; chatActionFailed(NETWORK_SAY); refreshStartEnabled(); });
|
|
4645
|
+
}
|
|
4646
|
+
// Run a signed flow with a Destination, Cap $ or ask wait that differs from the flow's (amendment 5 item 3): click 1 asks the server what
|
|
4647
|
+
// is about to be signed (a hash; signs nothing), click 2 is the ONLY call that signs and starts, carrying that hash.
|
|
4648
|
+
function doRunSign(){
|
|
4649
|
+
clearFieldErrors();
|
|
4650
|
+
chatActionOk();
|
|
4651
|
+
busy = true;
|
|
4652
|
+
refreshStartEnabled();
|
|
4653
|
+
if(!runSignInfo){
|
|
4654
|
+
authorPost("/api/author/run-prepare", currentRun()).then(function(r){
|
|
4655
|
+
busy = false;
|
|
4656
|
+
var o = chatPostOutcome(r);
|
|
4657
|
+
if(!o.ok){ failFrom(r); refreshStartEnabled(); return; }
|
|
4658
|
+
if(r.body.needsSign !== true){ doRun(); return; } // the server sees nothing to sign after all: a plain Run
|
|
4659
|
+
runSignInfo = {hash: r.body.hash};
|
|
4660
|
+
refreshStartEnabled();
|
|
4661
|
+
}).catch(function(){ busy = false; chatActionFailed(NETWORK_SAY); refreshStartEnabled(); });
|
|
4662
|
+
return;
|
|
4663
|
+
}
|
|
4664
|
+
var body = currentRun();
|
|
4665
|
+
body.hash = runSignInfo.hash;
|
|
4666
|
+
authorPost("/api/author/run", body).then(function(r){
|
|
4667
|
+
var o = chatPostOutcome(r);
|
|
4668
|
+
runSignInfo = null;
|
|
4669
|
+
if(!o.ok){ busy = false; failFrom(r); refreshStartEnabled(); return; }
|
|
4670
|
+
beginStart(r.body.startId);
|
|
4671
|
+
}).catch(function(){ busy = false; chatActionFailed(NETWORK_SAY); refreshStartEnabled(); });
|
|
4672
|
+
}
|
|
4673
|
+
// the Resume form (amendment 4 item 4, "Sign & resume"): the same two clicks; the cap is the only thing in the body besides the run
|
|
4674
|
+
function resumeBody(){ return {flow: resumeCtx.flow, runId: resumeCtx.runId, capUsd: resumeCapEl.value.trim()}; }
|
|
4675
|
+
function doResumeSign(){
|
|
4676
|
+
if(!resumeCtx) return;
|
|
4677
|
+
clearFieldErrors();
|
|
4678
|
+
chatActionOk();
|
|
4679
|
+
busy = true;
|
|
4680
|
+
refreshStartEnabled();
|
|
4681
|
+
if(!resumeSignInfo){
|
|
4682
|
+
authorPost("/api/author/resume-prepare", resumeBody()).then(function(r){
|
|
4683
|
+
busy = false;
|
|
4684
|
+
var o = chatPostOutcome(r);
|
|
4685
|
+
if(!o.ok){ failFrom(r); refreshStartEnabled(); return; }
|
|
4686
|
+
resumeSignInfo = {hash: r.body.hash};
|
|
4687
|
+
refreshStartEnabled();
|
|
4688
|
+
}).catch(function(){ busy = false; chatActionFailed(NETWORK_SAY); refreshStartEnabled(); });
|
|
4689
|
+
return;
|
|
4690
|
+
}
|
|
4691
|
+
var body = resumeBody();
|
|
4692
|
+
body.hash = resumeSignInfo.hash;
|
|
4693
|
+
var resumingKey = resumeCtx.flow + "/" + resumeCtx.runId;
|
|
4694
|
+
authorPost("/api/author/resume", body).then(function(r){
|
|
4695
|
+
var o = chatPostOutcome(r);
|
|
4696
|
+
resumeSignInfo = null;
|
|
4697
|
+
if(!o.ok){ busy = false; failFrom(r); refreshStartEnabled(); return; }
|
|
4698
|
+
window.fwdloopResuming = {key: resumingKey, at: Date.now()};
|
|
4699
|
+
beginStart(r.body.startId);
|
|
4700
|
+
}).catch(function(){ busy = false; chatActionFailed(NETWORK_SAY); refreshStartEnabled(); });
|
|
4701
|
+
}
|
|
4702
|
+
// the Run tab's Resume button: read the form's facts from the server (it refuses a run that is not stopped), then show the card in resume mode
|
|
4703
|
+
function openResume(detail){
|
|
4704
|
+
authorGet("/api/author/resume-form?flow=" + encodeURIComponent(detail.flow) + "&runId=" + encodeURIComponent(detail.runId)).then(function(j){
|
|
4705
|
+
document.getElementById("tab-chat").click();
|
|
4706
|
+
if(!j || j.ok !== true){ chatActionFailed((j && j.say) || "This run cannot be resumed."); return; }
|
|
4707
|
+
if(startId !== null || sessionLive){ chatActionFailed("Finish or clear what is on the card first, then Resume."); return; }
|
|
4708
|
+
if(mode !== "resume") modeBeforeResume = mode;
|
|
4709
|
+
resumeCtx = {flow: detail.flow, runId: detail.runId, form: j};
|
|
4710
|
+
chatActionOk();
|
|
4711
|
+
paintJobDim(byId("jf-resume-job"), j.jobLines);
|
|
4712
|
+
byId("jf-resume-dest").textContent = j.values.destination || "no send step";
|
|
4713
|
+
byId("jf-resume-inputs").innerHTML = "";
|
|
4714
|
+
(j.inputs || []).forEach(function(i){ var d = document.createElement("div"); d.className = "ro-line"; d.textContent = i.role + ": " + i.path; byId("jf-resume-inputs").appendChild(d); });
|
|
4715
|
+
byId("jf-resume-waits").textContent = Object.keys(j.values.askWaits || {}).map(function(k){ return "line " + k + ": " + j.values.askWaits[k]; }).join(" \u00b7 ") || "no ask";
|
|
4716
|
+
resumeCapEl.value = String(j.values.capUsd);
|
|
4717
|
+
byId("jf-resume-hint").textContent = "Already spent $" + Number(j.spentUsd).toFixed(4) + ". Same run, same steps, nothing is redrawn; a new cap is signed for this run. Other changes are a new run or a new job.";
|
|
4718
|
+
setMode("resume");
|
|
4719
|
+
}).catch(function(){ document.getElementById("tab-chat").click(); chatActionFailed(NETWORK_SAY); });
|
|
4720
|
+
}
|
|
4721
|
+
window.fwdloopOpenResume = openResume;
|
|
4722
|
+
// the Run tab's Run again button (amendment 7 item 6; bareloop's Reuse workflow): the server reads the run's flow and the run's own values
|
|
4723
|
+
// (any outcome), then the card opens in Run a signed flow with that flow picked and the boxes filled in. A flow the run's preflight
|
|
4724
|
+
// would refuse is refused here with its reason.
|
|
4725
|
+
function openRunAgain(detail){
|
|
4726
|
+
authorGet("/api/author/run-again?flow=" + encodeURIComponent(detail.flow) + "&runId=" + encodeURIComponent(detail.runId)).then(function(j){
|
|
4727
|
+
document.getElementById("tab-chat").click();
|
|
4728
|
+
if(!j || j.ok !== true){ chatActionFailed((j && j.say) || "This run cannot be run again."); return; }
|
|
4729
|
+
if(startId !== null || sessionLive || mode === "resume"){ chatActionFailed("Finish or clear what is on the card first, then Run again."); return; }
|
|
4730
|
+
chatActionOk();
|
|
4731
|
+
againEntry = j.flow; pickedFlow = j.flow.flow; pickedRun = j.pick; pickedLabel = j.flow.flow + " (" + j.pick.runId + ")";
|
|
4732
|
+
runFlowSel.value = pickedLabel;
|
|
4733
|
+
setMode("run");
|
|
4734
|
+
renderFlowSearch(); paintRunFlow(); refreshStartEnabled();
|
|
4735
|
+
}).catch(function(){ document.getElementById("tab-chat").click(); chatActionFailed(NETWORK_SAY); });
|
|
4736
|
+
}
|
|
4737
|
+
window.fwdloopRunAgain = openRunAgain;
|
|
4738
|
+
function doSign(){
|
|
4739
|
+
if(!sessionId) return;
|
|
4740
|
+
var id = sessionId;
|
|
4741
|
+
if(!signClickedOnce){
|
|
4742
|
+
// click 1: what is about to be signed (the hash, the cap). Signs nothing.
|
|
4743
|
+
busy = true;
|
|
4744
|
+
refreshStartEnabled();
|
|
4745
|
+
authorPost("/api/author/" + id + "/sign-prepare", {}).then(function(r){
|
|
4746
|
+
busy = false;
|
|
4747
|
+
var o = chatPostOutcome(r);
|
|
4748
|
+
if(!o.ok){ failFrom(r); refreshStartEnabled(); return; }
|
|
4749
|
+
chatActionOk();
|
|
4750
|
+
signInfo = {hash: r.body.hash, flowName: r.body.flowName, capUsd: r.body.capUsd, runId: r.body.runId};
|
|
4751
|
+
signClickedOnce = true;
|
|
4752
|
+
if(lastState) renderActions(lastState); else refreshStartEnabled();
|
|
4753
|
+
}).catch(function(){ busy = false; chatActionFailed(NETWORK_SAY); refreshStartEnabled(); });
|
|
4754
|
+
return;
|
|
4755
|
+
}
|
|
4756
|
+
// click 2: the ONLY call that signs. It carries the hash this page showed; the server signs only if it is still the draft's hash on disk.
|
|
4757
|
+
busy = true;
|
|
4758
|
+
refreshStartEnabled();
|
|
4759
|
+
authorPost("/api/author/" + id + "/sign", {hash: signInfo.hash}).then(function(r){
|
|
4760
|
+
var o = chatPostOutcome(r);
|
|
4761
|
+
if(!o.ok){
|
|
4762
|
+
busy = false;
|
|
4763
|
+
failFrom(r);
|
|
4764
|
+
if(r.body && r.body.signed === true){ endSession(); loadFlows(true); } else { refreshStartEnabled(); }
|
|
4765
|
+
return;
|
|
4766
|
+
}
|
|
4767
|
+
chatActionOk();
|
|
4768
|
+
stopPoll();
|
|
4769
|
+
signClickedOnce = false;
|
|
4770
|
+
beginStart(r.body.startId);
|
|
4771
|
+
}).catch(function(){ busy = false; chatActionFailed(NETWORK_SAY); refreshStartEnabled(); });
|
|
4772
|
+
}
|
|
4773
|
+
// amendment 14 item 2: Draft on an open card posts the card (the same shape as the draft call) to the revise route; the model gets the card only.
|
|
4774
|
+
// A refused revise leaves every field as typed (unsent input is never wiped). The new plan replaces the shown one when it comes back.
|
|
4775
|
+
function doRevise(){
|
|
4776
|
+
if(!sessionId) return;
|
|
4777
|
+
var id = sessionId;
|
|
4778
|
+
var body = currentCard();
|
|
4779
|
+
clearFieldErrors();
|
|
4780
|
+
chatActionOk();
|
|
4781
|
+
busy = true;
|
|
4782
|
+
refreshStartEnabled();
|
|
4783
|
+
authorPost("/api/author/" + id + "/revise", body).then(function(r){
|
|
4784
|
+
busy = false;
|
|
4785
|
+
var o = chatPostOutcome(r);
|
|
4786
|
+
if(!o.ok){ failFrom(r); refreshStartEnabled(); return; }
|
|
4787
|
+
reviseOpen = false;
|
|
4788
|
+
signInfo = null; signClickedOnce = false;
|
|
4789
|
+
renderActions(Object.assign({}, lastState, {phase: "revising"}));
|
|
4790
|
+
poll();
|
|
4791
|
+
}).catch(function(){ busy = false; chatActionFailed(NETWORK_SAY); refreshStartEnabled(); });
|
|
4792
|
+
}
|
|
4793
|
+
function doAbandon(){
|
|
4794
|
+
var id = sessionId;
|
|
4795
|
+
busy = true;
|
|
4796
|
+
refreshStartEnabled();
|
|
4797
|
+
authorPost("/api/author/" + id + "/abandon", {}).then(function(r){
|
|
4798
|
+
busy = false;
|
|
4799
|
+
var o = chatPostOutcome(r);
|
|
4800
|
+
if(!o.ok){ failFrom(r); refreshStartEnabled(); return; }
|
|
4801
|
+
resetCard();
|
|
4802
|
+
}).catch(function(){ busy = false; chatActionFailed(NETWORK_SAY); refreshStartEnabled(); });
|
|
4803
|
+
}
|
|
4804
|
+
|
|
4805
|
+
// Re-attach after a page load/refresh or a panel restart: the server reads the newest unsigned draft from its files, so ask it.
|
|
4806
|
+
// If one exists, this tab takes it over as if it had started it: the card filled from the draft's own copy, the poll loop, the
|
|
4807
|
+
// progress list, the readout and the main button. A signed or abandoned draft never comes back (empty card).
|
|
4808
|
+
function attachSession(d){
|
|
4809
|
+
var c = d.card || {};
|
|
4810
|
+
openNewCard();
|
|
4811
|
+
setMode("new");
|
|
4812
|
+
setVal("jf-name", c.flowName); setVal("jf-job", c.job); setVal("jf-cap-money", c.capUsd);
|
|
4813
|
+
refreshCapNote();
|
|
4814
|
+
setVal("jf-dest-folder", typeof c.destination === "string" ? c.destination : ""); setVal("jf-inputs", typeof c.inputs === "string" ? c.inputs : ""); setVal("jf-ask-wait", c.askWait || "1h");
|
|
4815
|
+
sessionId = d.draftId;
|
|
4816
|
+
sessionLive = CLIENT_TERMINAL_PHASES.indexOf(d.phase) === -1;
|
|
4817
|
+
renderThread(d);
|
|
4818
|
+
renderActions(d);
|
|
4819
|
+
startPoll();
|
|
4820
|
+
poll();
|
|
4821
|
+
}
|
|
4822
|
+
function reattachLive(){
|
|
4823
|
+
if(sessionId || sessionLive || startId !== null) return;
|
|
4824
|
+
authorGet("/api/author/live").then(function(j){
|
|
4825
|
+
if(sessionId || sessionLive || startId !== null || !j || j.ok !== true) return;
|
|
4826
|
+
if(j.draft){ attachSession(j.draft); return; }
|
|
4827
|
+
// no draft: the newest start the human has not cleared — still starting (watch it) or refused (show its sentence)
|
|
4828
|
+
var st = j.start;
|
|
4829
|
+
if(!st) return;
|
|
4830
|
+
if(st.phase === "starting"){ beginStart(st.startId); return; }
|
|
4831
|
+
if(st.phase === "refused"){
|
|
4832
|
+
refusedStartId = st.startId;
|
|
4833
|
+
chatActionFailed(st.kind === "sign" ? st.say + " The flow is signed; start it from \"Run a signed flow\"." : st.say);
|
|
4834
|
+
if(st.kind === "sign") loadFlows(true);
|
|
4835
|
+
}
|
|
4836
|
+
}).catch(function(){ /* nothing to attach to — the empty card stays */ });
|
|
4837
|
+
}
|
|
4838
|
+
|
|
4839
|
+
// ---- wiring ----
|
|
4840
|
+
clearBtn.addEventListener("click", function(){
|
|
4841
|
+
if(mode === "resume"){ resumeCtx = null; actionErrEl.textContent = ""; setMode(modeBeforeResume === "resume" ? "new" : modeBeforeResume); return; }
|
|
4842
|
+
if(clearBtn.textContent === "Abandon" && sessionId){ doAbandon(); return; }
|
|
4843
|
+
// a refused start's sentence is dismissed on the server too, or a reload would bring it back
|
|
4844
|
+
if(refusedStartId){ var rid = refusedStartId; refusedStartId = null; authorPost("/api/author/start/" + rid + "/clear", {}).catch(function(){}); }
|
|
4845
|
+
resetCard();
|
|
4846
|
+
});
|
|
4847
|
+
// Revise (amendment 14 item 2): opens every card field, filled as last submitted; nothing is sent
|
|
4848
|
+
reviseBtn.addEventListener("click", function(){ if(reviseBtn.disabled) return; reviseOpen = true; refreshStartEnabled(); });
|
|
4849
|
+
// Start over (amendment 14 item 3): the same draft call as Draft, from the card as it is now; the old draft's files stay (a new draft id, 2 new revises)
|
|
4850
|
+
startOverBtn.addEventListener("click", function(){ if(!startOverBtn.disabled) doDraft(sessionId); });
|
|
4851
|
+
qSend.addEventListener("click", doAnswer);
|
|
4852
|
+
qAnswer.addEventListener("keydown", function(e){ if(e.key === "Enter" && !e.shiftKey){ e.preventDefault(); doAnswer(); } });
|
|
4853
|
+
mainBtn.addEventListener("click", function(){
|
|
4854
|
+
if(mainBtn.disabled) return;
|
|
4855
|
+
if(mainAction === "draft") doDraft(mainStartOver ? sessionId : null);
|
|
4856
|
+
else if(mainAction === "run") doRun();
|
|
4857
|
+
else if(mainAction === "run-sign-prepare" || mainAction === "run-sign") doRunSign();
|
|
4858
|
+
else if(mainAction === "resume-sign-prepare" || mainAction === "resume-sign") doResumeSign();
|
|
4859
|
+
else if(mainAction === "revise") doRevise();
|
|
4860
|
+
else if(mainAction === "sign-prepare" || mainAction === "sign") doSign();
|
|
4861
|
+
});
|
|
4862
|
+
card.addEventListener("input", function(e){
|
|
4863
|
+
var grp = e.target && e.target.closest ? e.target.closest(".field, .cap-field, .jf-inrow") : null;
|
|
4864
|
+
if(grp) grp.querySelectorAll(".jf-err").forEach(function(x){ x.textContent = ""; });
|
|
4865
|
+
dropFixBoxesBanner();
|
|
4866
|
+
fitCardBoxes();
|
|
4867
|
+
if(e.target && (e.target.id === "jf-cap-money" || e.target.id === "jf-job" || e.target.id === "jf-run-cap" || e.target.id === "jf-resume-cap")) scheduleCapNote();
|
|
4868
|
+
// any edit voids the first Sign click of the Run / Resume form: what is shown must be what is signed
|
|
4869
|
+
runSignInfo = null; resumeSignInfo = null;
|
|
4870
|
+
refreshStartEnabled();
|
|
4871
|
+
});
|
|
4872
|
+
document.querySelectorAll('input[name="jf-mode"]').forEach(function(r){
|
|
4873
|
+
r.addEventListener("change", function(){ if(r.checked) setMode(r.value); });
|
|
4874
|
+
});
|
|
4875
|
+
runFlowSel.addEventListener("input", function(){ rwHl = 0; renderFlowSearch(); });
|
|
4876
|
+
runFlowSel.addEventListener("keydown", function(e){
|
|
4877
|
+
if(e.key === "ArrowDown"){ rwHl = Math.min(rwHl + 1, rwShown.length - 1); renderFlowSearch(); e.preventDefault(); }
|
|
4878
|
+
else if(e.key === "ArrowUp"){ rwHl = Math.max(rwHl - 1, 0); renderFlowSearch(); e.preventDefault(); }
|
|
4879
|
+
else if(e.key === "Enter" && rwShown[rwHl]){ e.preventDefault(); pickFlowChoice(rwShown[rwHl]); }
|
|
4880
|
+
});
|
|
4881
|
+
rwListEl.addEventListener("click", function(e){
|
|
4882
|
+
var li = e.target.closest ? e.target.closest("li") : null;
|
|
4883
|
+
if(li) pickFlowChoice(rwShown[Number(li.getAttribute("data-i"))]);
|
|
4884
|
+
});
|
|
4885
|
+
document.getElementById("rw-change").addEventListener("click", unpickFlow);
|
|
4886
|
+
document.getElementById("rw-change").addEventListener("keydown", function(e){ if(e.key === "Enter" || e.key === " "){ e.preventDefault(); unpickFlow(); } });
|
|
4887
|
+
window.addEventListener("resize", fitCardBoxes);
|
|
4888
|
+
document.getElementById("tab-chat").addEventListener("click", function(){ fitCardBoxes(); reattachLive(); loadFlows(); });
|
|
4889
|
+
// the monthly limit changed in Settings: re-read the note for whatever cap is on the card (no reload; the button follows)
|
|
4890
|
+
document.addEventListener("fwdloop-limit-changed", function(){ refreshCapNote(); });
|
|
4891
|
+
|
|
4892
|
+
loadModel();
|
|
4893
|
+
loadFlows();
|
|
4894
|
+
reattachLive();
|
|
4895
|
+
refreshStartEnabled();
|
|
4896
|
+
})();
|
|
4897
|
+
|
|
3228
4898
|
// ---- M4d piece 4: Settings. Nothing here is re-rendered by the page's refresh tick: the Settings DOM is
|
|
3229
4899
|
// painted only when it is opened, a tab is chosen, or a button here is pressed — and a price/limit box the
|
|
3230
4900
|
// person has typed in ("dirty") is never overwritten by a repaint. No key value ever reaches this page. ----
|
|
@@ -3281,10 +4951,9 @@
|
|
|
3281
4951
|
function sourceWord(src){
|
|
3282
4952
|
if(src === "table") return "default";
|
|
3283
4953
|
if(src === "ceiling") return "highest known rate, the model has no listed price";
|
|
3284
|
-
if(src === "default-multiplier") return "default, 0.1 x input";
|
|
3285
4954
|
return "set here";
|
|
3286
4955
|
}
|
|
3287
|
-
var PRICE_FIELDS = ["inPerM", "
|
|
4956
|
+
var PRICE_FIELDS = ["inPerM", "outPerM"];
|
|
3288
4957
|
// Name, API shape and Base URL are editable (M4d amendment 1), saved on change one field at a time.
|
|
3289
4958
|
var PROV_FIELDS = ["name", "shape", "baseUrl"];
|
|
3290
4959
|
function buildProviderRow(row){
|
|
@@ -3455,6 +5124,7 @@
|
|
|
3455
5124
|
mlLimit.removeAttribute("data-dirty");
|
|
3456
5125
|
loadMoney().then(function(){
|
|
3457
5126
|
setNote(msg, false, r.body.monthlyLimitUsd === null ? "saved — no monthly limit" : "saved — the limit is now $" + r.body.monthlyLimitUsd);
|
|
5127
|
+
document.dispatchEvent(new CustomEvent("fwdloop-limit-changed"));
|
|
3458
5128
|
});
|
|
3459
5129
|
} else setNote(msg, true, settingsRefusal(r));
|
|
3460
5130
|
}, function(){ setNote(msg, true, networkText()); });
|