fwdloop 0.13.0 → 0.15.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 +25 -12
- package/package.json +2 -2
- package/src/authoring.js +73 -39
- package/src/canrun.js +71 -1
- package/src/catalogue.json +2 -2
- package/src/checked.js +54 -0
- package/src/closers.js +112 -91
- package/src/declaration.js +115 -11
- package/src/drafter.js +139 -39
- package/src/flow.js +220 -5
- package/src/keysfile.js +4 -2
- package/src/model-step.js +1 -1
- package/src/monthly.js +139 -17
- package/src/panel/author.js +226 -64
- package/src/panel/authorcard.js +99 -4
- package/src/panel/authorflows.js +51 -10
- package/src/panel/authorresume.js +2 -2
- package/src/panel/authorstart.js +18 -10
- package/src/panel/data.js +147 -81
- package/src/panel/index.html +497 -338
- package/src/panel/server.js +5 -2
- package/src/panel/settings.js +1 -1
- package/src/runner.js +105 -48
- package/src/setup.js +21 -14
- package/src/signed-diff.js +71 -0
- package/types/authoring.d.ts +52 -14
- package/types/canrun.d.ts +33 -1
- package/types/checked.d.ts +25 -0
- package/types/closers.d.ts +47 -28
- package/types/declaration.d.ts +16 -2
- package/types/drafter.d.ts +146 -11
- package/types/flow.d.ts +42 -2
- package/types/model-step.d.ts +1 -6
- package/types/monthly.d.ts +25 -1
- package/types/panel/author.d.ts +55 -40
- package/types/panel/authorcard.d.ts +54 -0
- package/types/panel/authorflows.d.ts +39 -0
- package/types/panel/authorstart.d.ts +1 -0
- package/types/panel/data.d.ts +11 -56
- package/types/runner.d.ts +11 -3
- package/types/setup.d.ts +6 -12
- package/types/signed-diff.d.ts +10 -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;
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
@media (prefers-color-scheme: light){
|
|
67
67
|
:root:not([data-theme="dark"]){
|
|
68
68
|
--bg:#e1e2e7; --panel:#d0d5e3; --panel2:#e9e9ed; --border:#c4c8da; --border-strong:#a8b0cc;
|
|
69
|
-
--text:#3760bf; --text-dim:#58679f; --text-faint:#848cb5;
|
|
69
|
+
--text:#3760bf; --text-dim:#58679f; --text-faint:#848cb5; --plan:#2668c2;
|
|
70
70
|
--green:#567238; --green-bg:#dfe7d4;
|
|
71
71
|
--red:#c92353; --red-bg:#fbe0e8;
|
|
72
72
|
--amber:#82643a; --amber-bg:#f0e6d3;
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
}
|
|
82
82
|
:root[data-theme="light"]{
|
|
83
83
|
--bg:#e1e2e7; --panel:#d0d5e3; --panel2:#e9e9ed; --border:#c4c8da; --border-strong:#a8b0cc;
|
|
84
|
-
--text:#3760bf; --text-dim:#58679f; --text-faint:#848cb5;
|
|
84
|
+
--text:#3760bf; --text-dim:#58679f; --text-faint:#848cb5; --plan:#2668c2;
|
|
85
85
|
--green:#567238; --green-bg:#dfe7d4;
|
|
86
86
|
--red:#c92353; --red-bg:#fbe0e8;
|
|
87
87
|
--amber:#82643a; --amber-bg:#f0e6d3;
|
|
@@ -126,7 +126,7 @@
|
|
|
126
126
|
|
|
127
127
|
[hidden]{display:none !important;}
|
|
128
128
|
.main{display:flex;flex:1;min-height:0;}
|
|
129
|
-
.left-pane{width:
|
|
129
|
+
.left-pane{width:630px;flex:none;border-right:1px solid var(--border-strong);display:flex;flex-direction:column;background:var(--panel);}
|
|
130
130
|
.right-pane{flex:1;min-width:0;display:flex;flex-direction:column;}
|
|
131
131
|
|
|
132
132
|
.tabrow{display:flex;border-bottom:1px solid var(--border-strong);background:var(--panel2);counter-reset:tabnum;}
|
|
@@ -289,13 +289,24 @@
|
|
|
289
289
|
.sum-val{color:var(--text);}
|
|
290
290
|
.summary-box .num{color:var(--accent);font-weight:700;}
|
|
291
291
|
|
|
292
|
-
/*
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
.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);}
|
|
297
296
|
.map-box::before{content:"┤ MAP ├";display:block;font-size:11px;color:var(--text-faint);letter-spacing:0.08em;margin:-2px 0 8px 0;}
|
|
298
|
-
.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 */
|
|
299
310
|
|
|
300
311
|
.step-card{position:relative;border:1px solid var(--border);padding:10px;margin-bottom:8px;background:var(--panel2);}
|
|
301
312
|
.step-card.running{border:1px double var(--amber);}
|
|
@@ -428,6 +439,20 @@
|
|
|
428
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);}
|
|
429
440
|
.art-head{color:var(--accent);}
|
|
430
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;}
|
|
431
456
|
.ro-value.scroll{max-height:160px;overflow-y:auto;white-space:pre-wrap;word-break:break-word;}
|
|
432
457
|
.field-row{display:flex;flex-wrap:wrap;gap:10px;}
|
|
433
458
|
.field-row .field{flex:1 1 140px;margin-bottom:10px;}
|
|
@@ -474,6 +499,8 @@
|
|
|
474
499
|
.chat-steps .step.wait .step-label{color:var(--amber);}
|
|
475
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;}
|
|
476
501
|
.chat-steps .step.bad .step-detail{color:var(--red);}
|
|
502
|
+
.chat-steps .step-raw{margin-top:2px;color:var(--text-faint);}
|
|
503
|
+
.chat-steps .step-raw summary{cursor:pointer;}
|
|
477
504
|
.chat-steps .step.run .step-sign::after{content:"\2026";}
|
|
478
505
|
@keyframes step-dots{0%{content:"";}25%{content:".";}50%{content:"..";}75%{content:"...";}}
|
|
479
506
|
@media (prefers-reduced-motion: no-preference){
|
|
@@ -484,21 +511,22 @@
|
|
|
484
511
|
.chat-thread:empty{display:none;}
|
|
485
512
|
.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;}
|
|
486
513
|
.msg.bot{border-left:3px solid var(--border-strong);}
|
|
514
|
+
/* M4e amendments 24/25: the question the plan raised (one at a time), then Your answers / Checked / Not checked beside the plan */
|
|
515
|
+
.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;}
|
|
516
|
+
.chat-question .q-head{font-size:11px;color:var(--text-faint);}
|
|
517
|
+
.chat-question .q-line{font-size:12px;color:var(--text-faint);margin-top:4px;overflow-wrap:anywhere;}
|
|
518
|
+
.chat-question .q-text{font-size:13px;margin-top:4px;overflow-wrap:anywhere;white-space:pre-wrap;}
|
|
519
|
+
.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;}
|
|
520
|
+
.chat-question .q-err{color:var(--red);}
|
|
521
|
+
.chat-extras{display:flex;flex-direction:column;gap:10px;margin-bottom:10px;}
|
|
522
|
+
.chat-extras:empty{display:none;}
|
|
487
523
|
.msg.bot .who::before{content:"$ ";}
|
|
488
524
|
.msg .who{font-size:11px;color:var(--text-faint);margin-bottom:3px;text-transform:none;font-weight:400;}
|
|
489
|
-
/* borrowed-from: bareloop src/panel/index.html@c1d87ce (the "you" bubble: indented, accent left border) */
|
|
490
|
-
.msg.you{background:var(--bg);margin-left:20px;border-left:3px solid var(--accent);}
|
|
491
|
-
.msg.you .who::before{content:"> ";}
|
|
492
|
-
.chat-input-row{margin-top:10px;border-top:1px dotted var(--border-strong);padding-top:10px;}
|
|
493
|
-
.chat-input-row input{width:100%;box-sizing:border-box;}
|
|
494
|
-
/* borrowed-from: bareloop src/panel/index.html@d151ec7 (the ask box: a wrapping textarea, 2x height, thick border, dimmed while it cannot be used).
|
|
495
|
-
M4e amendment 3 item 3: it opens only on a green plan ("Ask for a change to the plan"); `hidden` closes it. */
|
|
496
|
-
.chat-input-row[hidden]{display:none;}
|
|
497
|
-
textarea[data-testid="chat-msg"]{width:100%;box-sizing:border-box;font:inherit;color:var(--text);resize:vertical;overflow-y:auto;max-height:200px;}
|
|
498
|
-
#chat-msg{min-height:64px;padding:8px 12px;border:2px solid var(--field-border);background:var(--field-bg);}
|
|
499
|
-
#chat-msg:read-only{background:var(--bg);opacity:.55;cursor:not-allowed;}
|
|
500
525
|
/* the card's free-text boxes wrap (textarea): grow a few rows (fitBox), then scroll inside */
|
|
501
|
-
.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;
|
|
526
|
+
.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;}
|
|
527
|
+
/* M6 am2: every job box (the textarea and the read-only lines) grows with its text up to 8 lines, then scrolls inside:
|
|
528
|
+
8 x 1.5em + 6px padding x2 + 1px border x2; ONE rule, fitBox reads this cap */
|
|
529
|
+
.job-card textarea.jf-wrap, .job-card .ro-lines{line-height:1.5;max-height:calc(12em + 14px);}
|
|
502
530
|
/* the focused/selected Chat-card field gets a blue border (the accent), no outline ring */
|
|
503
531
|
#panel-chat :is(input,select,textarea):focus{border-color:var(--accent);outline:none;}
|
|
504
532
|
/* amendment 2: the job and inputs boxes have a gutter OUTSIDE them on the left (`N >` per step, `~` per guardrail; a number per input
|
|
@@ -511,9 +539,9 @@
|
|
|
511
539
|
.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;}
|
|
512
540
|
.jf-mirror div{margin:0;padding:0;}
|
|
513
541
|
/* editable Chat-card fields get the standard soft white (a step below the ask box); disabled/readonly keep the base colour */
|
|
514
|
-
#panel-chat input:not(:disabled):not([readonly]):not(
|
|
542
|
+
#panel-chat input:not(:disabled):not([readonly]):not([type="radio"]):not([type="checkbox"]),
|
|
515
543
|
#panel-chat select:not(:disabled),
|
|
516
|
-
#panel-chat textarea:not(:disabled):not([readonly])
|
|
544
|
+
#panel-chat textarea:not(:disabled):not([readonly]){background:var(--field-soft-bg);}
|
|
517
545
|
/* ONE wide button below the message box; its wording comes from mainButtonFor */
|
|
518
546
|
.btn.wide{width:100%;margin-top:10px;white-space:normal;}
|
|
519
547
|
/* amendment 2 item 7: the main button's label ("Sign <hash8> & run · $<cap>") stays on ONE line inside the card */
|
|
@@ -537,7 +565,7 @@
|
|
|
537
565
|
.rw-picked{display:flex;justify-content:space-between;align-items:center;gap:8px;margin-top:6px;padding:6px 8px;border:1px solid var(--accent);}
|
|
538
566
|
.rw-picked span{overflow-wrap:anywhere;}
|
|
539
567
|
.rw-picked a{font-size:12px;cursor:pointer;flex:none;}
|
|
540
|
-
.ro-lines{padding:6px 8px;border:1px solid var(--border);background:var(--bg);color:var(--text-dim);font-size:12px;overflow-wrap:anywhere;
|
|
568
|
+
.ro-lines{padding:6px 8px;border:1px solid var(--border);background:var(--bg);color:var(--text-dim);font-size:12px;overflow-wrap:anywhere;overflow-y:auto;}
|
|
541
569
|
.ro-lines .ro-line{display:flex;gap:8px;}
|
|
542
570
|
.ro-lines .ro-n{flex:none;min-width:1.4em;color:var(--text-faint);}
|
|
543
571
|
.jf-waitrow{margin-bottom:4px;}
|
|
@@ -760,6 +788,7 @@
|
|
|
760
788
|
</div>
|
|
761
789
|
|
|
762
790
|
<div id="jf-new" data-testid="jf-new">
|
|
791
|
+
<div class="hint edit-banner" id="jf-edit-banner" data-testid="jf-edit-banner" hidden></div>
|
|
763
792
|
<div class="field">
|
|
764
793
|
<label for="jf-name">Flow name</label>
|
|
765
794
|
<input id="jf-name" type="text" placeholder="lowercase letters, digits, - or _" autocomplete="off" spellcheck="false" data-testid="jf-name">
|
|
@@ -820,7 +849,9 @@
|
|
|
820
849
|
<div class="field dimmed" data-testid="jf-run-job-field">
|
|
821
850
|
<label>The job</label>
|
|
822
851
|
<div class="ro-lines" id="jf-run-job" data-testid="jf-run-job"></div>
|
|
823
|
-
<div class="hint">Fixed by the signature (the steps, the job lines and the asks). To change
|
|
852
|
+
<div class="hint">Fixed by the signature (the steps, the job lines and the asks). To change them, edit the job: the AI drafts a new plan, and signing it replaces this job.</div>
|
|
853
|
+
<button class="btn" type="button" id="jf-run-edit" data-testid="jf-run-edit">Edit this job</button>
|
|
854
|
+
<div class="hint" id="jf-run-edit-why" data-testid="jf-run-edit-why"></div>
|
|
824
855
|
</div>
|
|
825
856
|
<div class="field">
|
|
826
857
|
<label for="jf-run-dest">Destination</label>
|
|
@@ -885,21 +916,31 @@
|
|
|
885
916
|
<!-- ONE progress list: every step is one line that updates in place; a waiting step has no check -->
|
|
886
917
|
<ol class="chat-steps" id="chat-progress-row" data-testid="chat-steps" aria-live="polite" hidden></ol>
|
|
887
918
|
|
|
888
|
-
<!-- M4e amendment
|
|
919
|
+
<!-- M4e amendment 14: the plan, then the main button (no bubbles, no note box): the plan sits next to Sign & run -->
|
|
889
920
|
<div class="chat-thread" id="chat-thread" data-testid="chat-thread"></div>
|
|
890
921
|
|
|
922
|
+
<!-- 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 -->
|
|
923
|
+
<div class="chat-question" id="chat-question" data-testid="chat-question" hidden>
|
|
924
|
+
<div class="q-head" id="chat-q-head" data-testid="chat-q-head"></div>
|
|
925
|
+
<div class="q-line" id="chat-q-line" data-testid="chat-q-line"></div>
|
|
926
|
+
<div class="q-text" id="chat-q-text" data-testid="chat-q-text"></div>
|
|
927
|
+
<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>
|
|
928
|
+
<div class="hint q-err" id="chat-q-error" data-testid="chat-q-error" role="alert"></div>
|
|
929
|
+
<button class="btn primary wide" type="button" id="chat-q-send" data-testid="chat-q-send">Send</button>
|
|
930
|
+
</div>
|
|
931
|
+
|
|
932
|
+
<!-- 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 (labelled, from src/checked.js) -->
|
|
933
|
+
<div class="chat-extras" id="chat-extras" data-testid="chat-extras"></div>
|
|
934
|
+
|
|
891
935
|
<!-- a refused draft / run / sign / abandon POST (or a refused start) shows here and STAYS: set only by this tab's own
|
|
892
936
|
action handlers, never cleared by the poll (the poll owns #chat-card-error instead) -->
|
|
893
937
|
<div class="hint" id="chat-action-error" data-testid="chat-action-error"></div>
|
|
894
938
|
|
|
895
|
-
<!-- M4e amendment 3 item 3: opens when a green plan shows (bareloop's ask box); a typed note turns the main button into Send -->
|
|
896
|
-
<div class="chat-input-row" id="chat-msg-row" data-testid="chat-msg-row" hidden>
|
|
897
|
-
<label for="chat-msg" style="display:none">Message</label>
|
|
898
|
-
<textarea id="chat-msg" rows="2" placeholder="Ask for a change to the plan" autocomplete="off" data-testid="chat-msg"></textarea>
|
|
899
|
-
</div>
|
|
900
939
|
<button class="btn primary wide" type="button" id="chat-main-btn" data-testid="chat-main" disabled>Draft</button>
|
|
901
940
|
<div class="hint" id="chat-main-hint" data-testid="chat-main-hint"></div>
|
|
902
|
-
<!-- M4e amendment
|
|
941
|
+
<!-- M4e amendment 14 item 2: on a green plan, Revise opens every card field (the main button then reads Draft) -->
|
|
942
|
+
<button class="btn wide" type="button" id="chat-revise-btn" data-testid="chat-revise" hidden>Revise</button>
|
|
943
|
+
<!-- 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 -->
|
|
903
944
|
<button class="btn wide" type="button" id="chat-startover-btn" data-testid="chat-startover" hidden>Start over</button>
|
|
904
945
|
<div class="hint">Only your click signs.</div>
|
|
905
946
|
</section>
|
|
@@ -1009,21 +1050,29 @@
|
|
|
1009
1050
|
piece within a field — replaces the old split asks/sends/
|
|
1010
1051
|
sources/signed-lines blocks. Field order (signed): Job
|
|
1011
1052
|
(prose) · Ask · Model · $ cap (+ redo cap) · Source ·
|
|
1012
|
-
Destination · Success
|
|
1053
|
+
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
|
|
1013
1054
|
field's own `label` already sits above its value (the
|
|
1014
1055
|
existing global `label{display:block}` rule — no separate
|
|
1015
1056
|
narrow-width override needed). -->
|
|
1016
1057
|
<div id="job-empty" class="hint" style="font-size:13px;padding:24px 0;">select a run first</div>
|
|
1017
1058
|
<div class="job-card" id="job-card" hidden data-testid="job-card-readonly">
|
|
1018
1059
|
<h4 id="details-title">Job card — signed</h4>
|
|
1060
|
+
<div class="hint" id="details-jobfrom" data-testid="details-jobfrom"></div>
|
|
1019
1061
|
<div class="field"><label>Model</label><div class="ro-value" id="details-model">—</div></div>
|
|
1020
|
-
|
|
1021
|
-
<div class="field"><label
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
<div
|
|
1025
|
-
|
|
1026
|
-
|
|
1062
|
+
<!-- am41 item 6: the same "The job" label the Chat card carries, over the signed lines -->
|
|
1063
|
+
<div class="field" style="margin-bottom:0"><label id="details-job-title">The job</label></div>
|
|
1064
|
+
<!-- M4e amendment 37: ONE column. #details-prose holds one wrapper per signed line (the line, its ~ rows, its steps folded under it);
|
|
1065
|
+
#details-plan-tail holds any step from no listed line, then the folded "not checked" line; then Ask, Destination, $ cap, Source, Signed. -->
|
|
1066
|
+
<div id="job-grid" data-testid="job-grid">
|
|
1067
|
+
<div id="details-prose"></div>
|
|
1068
|
+
<div id="details-plan-tail"></div>
|
|
1069
|
+
<div class="field"><label>Ask</label><div id="details-asks"></div></div>
|
|
1070
|
+
<div class="field"><label>Destination</label><div id="details-sends"></div></div>
|
|
1071
|
+
<div class="field"><label>$ cap</label><div class="ro-value" id="details-cap">—</div></div>
|
|
1072
|
+
<div class="field"><label>Source</label><div id="details-sources"></div></div>
|
|
1073
|
+
<div class="field"><label>Signed</label><div class="ro-value" id="details-signature">—</div></div>
|
|
1074
|
+
<div class="plan-legend" data-testid="plan-legend"><span class="plan-mark">›</span> = the approved plan</div>
|
|
1075
|
+
</div>
|
|
1027
1076
|
</div>
|
|
1028
1077
|
</section>
|
|
1029
1078
|
|
|
@@ -1086,7 +1135,14 @@
|
|
|
1086
1135
|
// Origin). Same-origin. ----
|
|
1087
1136
|
function getJSON(path){
|
|
1088
1137
|
return fetch(path, { method: "GET", headers: { accept: "application/json" } }).then(function(r){
|
|
1089
|
-
if(!r.ok){
|
|
1138
|
+
if(!r.ok){
|
|
1139
|
+
// the refusal's own name rides on the error (C1): the one load-failure sentence tells "outside the folder" from the other 403
|
|
1140
|
+
return r.json().then(function(b){ return b; }, function(){ return null; }).then(function(b){
|
|
1141
|
+
var err = new Error(path + ": HTTP " + r.status); err.status = r.status;
|
|
1142
|
+
if(b && typeof b.refused === "string") err.refused = b.refused;
|
|
1143
|
+
throw err;
|
|
1144
|
+
});
|
|
1145
|
+
}
|
|
1090
1146
|
return r.json();
|
|
1091
1147
|
});
|
|
1092
1148
|
}
|
|
@@ -1094,6 +1150,7 @@
|
|
|
1094
1150
|
// message (it carries the path and the HTTP code), never a status number.
|
|
1095
1151
|
function loadFailureText(e){
|
|
1096
1152
|
var status = e && e.status;
|
|
1153
|
+
if(status === 403 && e.refused === "flow-outside-root") return "This flow is outside the panel's folder.";
|
|
1097
1154
|
if(status === 403) return "The panel does not recognise this page. Reload it.";
|
|
1098
1155
|
if(status === 404) return "This run is no longer there.";
|
|
1099
1156
|
return "Could not load this; reload the page.";
|
|
@@ -1400,52 +1457,18 @@
|
|
|
1400
1457
|
}
|
|
1401
1458
|
|
|
1402
1459
|
// ---- step map renderer (box-drawing geometry kept from the borrowed
|
|
1403
|
-
// page's
|
|
1460
|
+
// page's step-map builder; the DATA it draws is fwdloop's own: one box per
|
|
1404
1461
|
// `declaration.steps` entry, no scout/plan/judge/fix-loop/rounds — ruling
|
|
1405
1462
|
// A, "no per-round parts"). ----
|
|
1406
|
-
function stepMapColors(state){
|
|
1407
|
-
if(state === "done") return {stroke:"var(--green)", textFill:"#2e7d32"};
|
|
1408
|
-
if(state === "stopped") return {stroke:"var(--red)", textFill:"var(--red)"};
|
|
1409
|
-
if(state === "waiting") return {stroke:"var(--amber)", textFill:"#b8860b"};
|
|
1410
|
-
if(state === "user-stopped") return {stroke:"var(--grey-dot)", textFill:"var(--grey-dot)"}; // a Stop the human asked: grey, never red
|
|
1411
|
-
return {stroke:"var(--border-strong)", textFill:"var(--text-faint)"}; // not started yet
|
|
1412
|
-
}
|
|
1413
|
-
var stepMapUidCounter = 0;
|
|
1414
|
-
var MAP_MARGIN = 10, MAP_GAP = 28;
|
|
1415
|
-
var CHAR_W = 7.2;
|
|
1416
|
-
var TITLE_HPAD = 16;
|
|
1417
|
-
var MIN_BOX_W = 100;
|
|
1418
|
-
var BOX_H = 60, BOX_H_2LINE = 78;
|
|
1419
|
-
var ROW_GAP = 70;
|
|
1420
|
-
// hamr review #2: "map cards missing try 2 if multiple attempts/iteration"
|
|
1421
|
-
// — a plain "try N" count whenever a step has been attempted more than
|
|
1422
|
-
// once, plus a mark when the LATEST attempt followed a human redo (the
|
|
1423
|
-
// same `afterReject` boundary src/panel/data.js already worked out —
|
|
1424
|
-
// never re-derived here). One attempt (the common case) shows no "try"
|
|
1425
|
-
// text at all, matching bareloop's own "only say it when it's true" shape.
|
|
1426
|
-
// `tryCount` is server-derived (src/panel/data.js's computeTryCount) —
|
|
1427
|
-
// for an ask (hitl) step it counts asks shown to the human (a pause row
|
|
1428
|
-
// + its answer row are the SAME try), for a model step it counts model
|
|
1429
|
-
// attempts. Never re-derived here from `attempts.length` (browser
|
|
1430
|
-
// re-walk bug #2: that over-counted an ask step's pause/answer pairs).
|
|
1431
|
-
function tryCountText(tryCount, attempts){
|
|
1432
|
-
if(!tryCount || tryCount <= 1) return "";
|
|
1433
|
-
var last = attempts && attempts.length ? attempts[attempts.length - 1] : null;
|
|
1434
|
-
var txt = "try " + tryCount;
|
|
1435
|
-
if(last && last.afterReject) txt += " (re-attempt after redo)";
|
|
1436
|
-
return txt;
|
|
1437
|
-
}
|
|
1438
1463
|
// hamr review (browser re-walk #1): the per-attempt list ("attempt 1
|
|
1439
1464
|
// failed · attempt 2 passed · …") is a map node's single biggest source of
|
|
1440
1465
|
// width — that level of detail belongs in the Audit tab, never on the
|
|
1441
1466
|
// node. A node's title is just
|
|
1442
|
-
// step number + name +
|
|
1467
|
+
// step number + name + state, kept short so naturalBoxWidth stays
|
|
1443
1468
|
// small and the map stays compact instead of stretching to the pane width.
|
|
1444
1469
|
function stepTitleText(idx, s){
|
|
1445
1470
|
if(s.draft) return "drafting";
|
|
1446
1471
|
var base = (s.n || idx + 1) + ' ' + s.emits;
|
|
1447
|
-
var tryText = tryCountText(s.tryCount, s.attempts);
|
|
1448
|
-
if(tryText) base += ' — ' + tryText;
|
|
1449
1472
|
return base;
|
|
1450
1473
|
}
|
|
1451
1474
|
// 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,151 +1505,36 @@
|
|
|
1482
1505
|
};
|
|
1483
1506
|
});
|
|
1484
1507
|
}
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1508
|
+
// borrowed-from: bareloop src/panel/index.html@9edb3e1 (on d25e52a). The map is plain HTML + CSS (.map-chips / .map-item /
|
|
1509
|
+
// .map-chip): the browser wraps it, so no width arithmetic and no sideways scroll. Each box keeps its two lines — the name
|
|
1510
|
+
// (stepTitleText) then the status word (stateWord); a retried box (am35) is dashed and its status line starts with "↻N".
|
|
1511
|
+
function buildStepMapHTML(steps){
|
|
1512
|
+
var last = steps.length - 1;
|
|
1513
|
+
var body = steps.map(function(s, idx){
|
|
1514
|
+
var tries = boxRetryTry(s);
|
|
1515
|
+
var cls = "map-chip s-" + String(s.state).replace(/[^a-z-]/g, "") + (tries ? " retry" : "");
|
|
1516
|
+
var name = escapeXml(stepTitleText(idx, s));
|
|
1517
|
+
var state = escapeXml(s.noRecord ? "no draft record" : stateWord(s.state));
|
|
1518
|
+
// hamr review #4: each box is a clickable button tagged with the step's own `emits` id — the click listener that
|
|
1519
|
+
// jumps to the Audit tab's matching group is wired AFTER insertion (wireMapClicks), never inline here.
|
|
1520
|
+
var chip = '<button type="button" class="' + cls + ' map-step" data-emits="' + escapeXml(s.emits) + '"' + (tries ? ' data-retry="' + tries + '"' : '') +
|
|
1521
|
+
' title="' + name + '" aria-label="open ' + escapeXml(s.emits) + ' in Audit">' +
|
|
1522
|
+
'<span class="chip-name">' + name + '</span><span class="chip-state">' +
|
|
1523
|
+
(tries ? '<span class="chip-retry">\u21bb' + tries + '</span> ' : '') + state + '</span></button>';
|
|
1524
|
+
return '<span class="map-item" role="listitem">' +
|
|
1525
|
+
(idx > 0 ? '<span class="map-lead" aria-hidden="true">\u2192</span>' : '') +
|
|
1526
|
+
chip + (idx < last ? '<span class="map-arrow" aria-hidden="true">\u2192</span>' : '') + '</span>';
|
|
1527
|
+
}).join("");
|
|
1528
|
+
return '<div class="map-chips" role="list" aria-label="step map">' + body + '</div>';
|
|
1529
|
+
}
|
|
1530
|
+
// The first box of each WRAPPED line shows a leading arrow. CSS cannot know which box starts a line, so after render/resize
|
|
1531
|
+
// this compares each item's offsetTop with the previous item's (same line = same top). Takes anything with offsetTop +
|
|
1532
|
+
// classList (real elements, or stubs in tests). The lead arrow is absolute, so toggling never reflows a box — no loop.
|
|
1533
|
+
function markLineStarts(items){
|
|
1534
|
+
for(var i = 0; i < items.length; i++){
|
|
1535
|
+
var starts = i > 0 && items[i].offsetTop > items[i - 1].offsetTop;
|
|
1536
|
+
if(starts) items[i].classList.add("line-start"); else items[i].classList.remove("line-start");
|
|
1504
1537
|
}
|
|
1505
|
-
return {perRow:1, boxW:Math.max(MIN_BOX_W, Math.min(usableW, ceiling))};
|
|
1506
|
-
}
|
|
1507
|
-
// M4c-fix amendment 2 (l): a line longer than the box is cut with … (the whole name stays in the node's <title>
|
|
1508
|
-
// and on its step card below the map).
|
|
1509
|
-
function mapLabel(line, maxChars){
|
|
1510
|
-
return line.length <= maxChars ? line : line.slice(0, Math.max(1, maxChars - 1)) + "\u2026";
|
|
1511
|
-
}
|
|
1512
|
-
function wrapTitleLines(text, maxWidth){
|
|
1513
|
-
var maxChars = Math.max(1, Math.floor((maxWidth - TITLE_HPAD) / CHAR_W));
|
|
1514
|
-
return wrapTitleLinesRaw(text, maxChars).map(function(l){ return mapLabel(l, maxChars); });
|
|
1515
|
-
}
|
|
1516
|
-
function wrapTitleLinesRaw(text, maxChars){
|
|
1517
|
-
if(text.length <= maxChars) return [text];
|
|
1518
|
-
var words = text.split(' ');
|
|
1519
|
-
var line1 = '', i = 0;
|
|
1520
|
-
for(; i < words.length; i++){
|
|
1521
|
-
var cand = line1 ? line1 + ' ' + words[i] : words[i];
|
|
1522
|
-
if(line1 && cand.length > maxChars) break;
|
|
1523
|
-
line1 = cand;
|
|
1524
|
-
}
|
|
1525
|
-
if(!line1) return [text.slice(0, maxChars), text.slice(maxChars)];
|
|
1526
|
-
var line2 = words.slice(i).join(' ');
|
|
1527
|
-
return line2 ? [line1, line2] : [line1];
|
|
1528
|
-
}
|
|
1529
|
-
function buildStepMapSVG(steps, availWidth){
|
|
1530
|
-
var n = steps.length;
|
|
1531
|
-
var naturalW = naturalBoxWidth(steps);
|
|
1532
|
-
var layout = computeMapLayout(n, availWidth, naturalW);
|
|
1533
|
-
var perRow = layout.perRow, boxW = layout.boxW, gap = MAP_GAP;
|
|
1534
|
-
var rows = Math.ceil(n / perRow);
|
|
1535
|
-
var margin = MAP_MARGIN;
|
|
1536
|
-
var titleLines = steps.map(function(s, idx){ return wrapTitleLines(stepTitleText(idx, s), boxW); });
|
|
1537
|
-
var maxLines = titleLines.reduce(function(m, l){ return Math.max(m, l.length); }, 1);
|
|
1538
|
-
var boxH = maxLines > 1 ? BOX_H_2LINE : BOX_H;
|
|
1539
|
-
var rowH = boxH + ROW_GAP;
|
|
1540
|
-
var totalW = margin * 2 + perRow * boxW + (perRow - 1) * gap;
|
|
1541
|
-
var totalH = rows * rowH;
|
|
1542
|
-
var uid = "sm" + (stepMapUidCounter++);
|
|
1543
|
-
var body =
|
|
1544
|
-
'<defs>' +
|
|
1545
|
-
'<marker id="' + uid + '-arrow" markerWidth="8" markerHeight="8" refX="6" refY="3" orient="auto">' +
|
|
1546
|
-
'<path d="M0,0 L6,3 L0,6 z" fill="var(--text-dim)"></path></marker>' +
|
|
1547
|
-
'<marker id="' + uid + '-arrow-grey" markerWidth="8" markerHeight="8" refX="6" refY="3" orient="auto">' +
|
|
1548
|
-
'<path d="M0,0 L6,3 L0,6 z" fill="var(--text-faint)"></path></marker>' +
|
|
1549
|
-
'</defs>';
|
|
1550
|
-
steps.forEach(function(s, idx){
|
|
1551
|
-
var row = Math.floor(idx / perRow);
|
|
1552
|
-
var col = idx % perRow;
|
|
1553
|
-
var rtl = (row % 2) === 1;
|
|
1554
|
-
var slotCol = rtl ? (perRow - 1 - col) : col;
|
|
1555
|
-
var x = margin + slotCol * (boxW + gap);
|
|
1556
|
-
var y = 30 + row * rowH;
|
|
1557
|
-
var colors = stepMapColors(s.state);
|
|
1558
|
-
var lines = titleLines[idx];
|
|
1559
|
-
var nextRowIdx = idx < n - 1 ? Math.floor((idx + 1) / perRow) : null;
|
|
1560
|
-
var hasDrop = nextRowIdx !== null && nextRowIdx !== row;
|
|
1561
|
-
var stateY = y + boxH - 18;
|
|
1562
|
-
// hamr review #4: each node is a clickable group ("map-step", tagged
|
|
1563
|
-
// with the step's own `emits` id) — the click listener that turns this
|
|
1564
|
-
// into a jump to the Audit tab's matching group is wired AFTER
|
|
1565
|
-
// insertion (renderStepMap, below), never inline here (this function
|
|
1566
|
-
// only ever builds a markup string).
|
|
1567
|
-
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>';
|
|
1568
|
-
body += '<rect x="' + x + '" y="' + y + '" width="' + boxW + '" height="' + boxH +
|
|
1569
|
-
'" rx="0" fill="var(--panel2)" stroke="' + colors.stroke + '" stroke-width="2"></rect>';
|
|
1570
|
-
if(lines.length === 1){
|
|
1571
|
-
body += '<text x="' + (x + boxW / 2) + '" y="' + (y + 25) +
|
|
1572
|
-
'" text-anchor="middle" font-size="12" fill="var(--text)">' + escapeXml(lines[0]) + '</text>';
|
|
1573
|
-
} else {
|
|
1574
|
-
body += '<text x="' + (x + boxW / 2) + '" y="' + (y + 17) +
|
|
1575
|
-
'" text-anchor="middle" font-size="12" fill="var(--text)">' + escapeXml(lines[0]) + '</text>';
|
|
1576
|
-
body += '<text x="' + (x + boxW / 2) + '" y="' + (y + 29) +
|
|
1577
|
-
'" text-anchor="middle" font-size="12" fill="var(--text)">' + escapeXml(lines[1]) + '</text>';
|
|
1578
|
-
}
|
|
1579
|
-
body += '<text x="' + (x + boxW / 2) + '" y="' + stateY +
|
|
1580
|
-
'" text-anchor="middle" font-size="10" fill="' + colors.textFill + '">' + escapeXml(s.noRecord ? "no draft record" : stateWord(s.state)) + '</text>';
|
|
1581
|
-
body += '</g>';
|
|
1582
|
-
// hamr's 2026-09-27 retry-loop review: a step whose server-computed
|
|
1583
|
-
// tryCount is >1 gets a dashed grey self-loop under its box, labelled
|
|
1584
|
-
// "try N" — ported from bareloop commit 16825a7's own curve (same
|
|
1585
|
-
// control-point proportions, scaled to THIS box's own width). When the
|
|
1586
|
-
// same box also carries the row-to-row snake drop below (which leaves
|
|
1587
|
-
// from dead-center, x=cx), the loop's start is shifted off-center by a
|
|
1588
|
-
// fixed pixel offset so the two paths never begin at the same point.
|
|
1589
|
-
var retryTry = boxRetryTry(s);
|
|
1590
|
-
if(retryTry){
|
|
1591
|
-
var retryShift = hasDrop ? 14 : 0;
|
|
1592
|
-
var bottom = y + boxH;
|
|
1593
|
-
var sx = x + boxW * 0.50 - retryShift, sy = bottom + 5;
|
|
1594
|
-
var c1x = x + boxW * 0.278 - retryShift, c1y = bottom + 30;
|
|
1595
|
-
var c2x = x + boxW * 0.167 - retryShift, c2y = bottom + 30;
|
|
1596
|
-
var ex = x + boxW * 0.028 - retryShift, ey = bottom + 2;
|
|
1597
|
-
body += '<path d="M ' + sx + ' ' + sy + ' C ' + c1x + ' ' + c1y + ', ' + c2x + ' ' + c2y + ', ' + ex + ' ' + ey +
|
|
1598
|
-
'" fill="none" stroke="var(--text-faint)" stroke-width="1.5" stroke-dasharray="3,3" marker-end="url(#' + uid + '-arrow-grey)"></path>';
|
|
1599
|
-
body += '<text x="' + (x + boxW * 0.267 - retryShift) + '" y="' + (bottom + 32) +
|
|
1600
|
-
'" text-anchor="middle" font-size="10" fill="var(--text-faint)">try ' + retryTry + '</text>';
|
|
1601
|
-
}
|
|
1602
|
-
if(idx < n - 1){
|
|
1603
|
-
if(nextRowIdx === row){
|
|
1604
|
-
var midY = y + boxH / 2;
|
|
1605
|
-
if(!rtl){
|
|
1606
|
-
var nx = x + boxW + gap;
|
|
1607
|
-
body += '<line x1="' + (x + boxW) + '" y1="' + midY + '" x2="' + (nx - 2) + '" y2="' + midY +
|
|
1608
|
-
'" stroke="var(--text-dim)" stroke-width="2" marker-end="url(#' + uid + '-arrow)"></line>';
|
|
1609
|
-
} else {
|
|
1610
|
-
var px = x - gap - boxW;
|
|
1611
|
-
body += '<line x1="' + x + '" y1="' + midY + '" x2="' + (px + boxW + 2) + '" y2="' + midY +
|
|
1612
|
-
'" stroke="var(--text-dim)" stroke-width="2" marker-end="url(#' + uid + '-arrow)"></line>';
|
|
1613
|
-
}
|
|
1614
|
-
} else {
|
|
1615
|
-
var cx = x + boxW / 2;
|
|
1616
|
-
body += '<line x1="' + cx + '" y1="' + (y + boxH) + '" x2="' + cx + '" y2="' + (y + rowH - 2) +
|
|
1617
|
-
'" stroke="var(--text-dim)" stroke-width="2" marker-end="url(#' + uid + '-arrow)"></line>';
|
|
1618
|
-
}
|
|
1619
|
-
}
|
|
1620
|
-
});
|
|
1621
|
-
return '<svg width="' + totalW + '" height="' + totalH + '" viewBox="0 0 ' + totalW + ' ' + totalH + '" role="img" aria-label="step map">' + body + '</svg>';
|
|
1622
|
-
}
|
|
1623
|
-
var lastSteps = null;
|
|
1624
|
-
var lastWidth = null;
|
|
1625
|
-
function mapAvailWidth(wrapper){
|
|
1626
|
-
if(!wrapper) return null;
|
|
1627
|
-
var w = wrapper.getBoundingClientRect().width;
|
|
1628
|
-
if(!w) return null;
|
|
1629
|
-
return Math.max(0, w - 20);
|
|
1630
1538
|
}
|
|
1631
1539
|
// hamr review #4: "clicking on cards below codegraph maps should take you
|
|
1632
1540
|
// to audit trail" — a map node's click (or Enter/Space, since the node
|
|
@@ -1644,34 +1552,32 @@
|
|
|
1644
1552
|
function renderStepMap(steps){
|
|
1645
1553
|
var mount = document.getElementById("map-mount");
|
|
1646
1554
|
var wrapper = document.getElementById("map-box");
|
|
1647
|
-
lastSteps = steps;
|
|
1648
1555
|
if(!steps || !steps.length){
|
|
1649
1556
|
mount.innerHTML = "";
|
|
1650
1557
|
wrapper.hidden = true;
|
|
1651
1558
|
return;
|
|
1652
1559
|
}
|
|
1653
1560
|
wrapper.hidden = false;
|
|
1654
|
-
|
|
1655
|
-
lastWidth = w;
|
|
1656
|
-
mount.innerHTML = buildStepMapSVG(steps, w);
|
|
1561
|
+
mount.innerHTML = buildStepMapHTML(steps);
|
|
1657
1562
|
wireMapClicks(mount);
|
|
1563
|
+
reflowMap();
|
|
1658
1564
|
}
|
|
1659
1565
|
function reflowMap(){
|
|
1660
|
-
var
|
|
1661
|
-
if(!
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1566
|
+
var box = document.getElementById("map-box");
|
|
1567
|
+
if(!box || box.hidden) return;
|
|
1568
|
+
markLineStarts(Array.prototype.slice.call(box.querySelectorAll(".map-item")));
|
|
1569
|
+
}
|
|
1570
|
+
var reflowTimer = null;
|
|
1571
|
+
function reflowMapSoon(){
|
|
1572
|
+
if(reflowTimer) clearTimeout(reflowTimer);
|
|
1573
|
+
reflowTimer = setTimeout(function(){ reflowTimer = null; reflowMap(); }, 60);
|
|
1668
1574
|
}
|
|
1669
1575
|
if(typeof ResizeObserver !== "undefined"){
|
|
1670
|
-
var
|
|
1671
|
-
var
|
|
1672
|
-
if(
|
|
1576
|
+
var mapRo = new ResizeObserver(reflowMapSoon);
|
|
1577
|
+
var mapBoxEl = document.getElementById("map-box");
|
|
1578
|
+
if(mapBoxEl) mapRo.observe(mapBoxEl);
|
|
1673
1579
|
} else {
|
|
1674
|
-
window.addEventListener("resize",
|
|
1580
|
+
window.addEventListener("resize", reflowMapSoon);
|
|
1675
1581
|
}
|
|
1676
1582
|
|
|
1677
1583
|
// ---- Runs tab: ONE run-row builder shared by History (flat) and the
|
|
@@ -1868,6 +1774,11 @@
|
|
|
1868
1774
|
// selection on the next render.
|
|
1869
1775
|
var wfExpanded = {};
|
|
1870
1776
|
|
|
1777
|
+
// am41 item 5: a job card shows its latest 7 sub-cards (`runs` is newest first); the rest are reached by search.
|
|
1778
|
+
function capChildRuns(runs){
|
|
1779
|
+
return {shown: runs.slice(0, 7), hidden: Math.max(0, runs.length - 7)};
|
|
1780
|
+
}
|
|
1781
|
+
|
|
1871
1782
|
function renderWorkflows(flows){
|
|
1872
1783
|
var el = document.getElementById("wf-list");
|
|
1873
1784
|
el.innerHTML = "";
|
|
@@ -1924,7 +1835,9 @@
|
|
|
1924
1835
|
if(expanded){
|
|
1925
1836
|
var runsWrap = document.createElement("div");
|
|
1926
1837
|
runsWrap.className = "wf-runs";
|
|
1927
|
-
|
|
1838
|
+
var capped = capChildRuns(childRuns);
|
|
1839
|
+
capped.shown.forEach(function(r){ runsWrap.appendChild(buildRunRowEl(r, { sub: true })); });
|
|
1840
|
+
if(capped.hidden > 0) runsWrap.appendChild(textDiv("hint wf-older", "older runs: use search"));
|
|
1928
1841
|
wrap.appendChild(runsWrap);
|
|
1929
1842
|
}
|
|
1930
1843
|
el.appendChild(wrap);
|
|
@@ -2815,8 +2728,7 @@
|
|
|
2815
2728
|
return [h ? h + "h" : "", m ? m + "m" : "", sec ? sec + "s" : ""].filter(Boolean).join(" ");
|
|
2816
2729
|
}
|
|
2817
2730
|
// hamr's 2026-09-27 exit-check review #5: ONE row-per-piece renderer,
|
|
2818
|
-
// shared by
|
|
2819
|
-
// 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
|
|
2820
2732
|
// " · "-joined line, which used to hide a book text value if it happened
|
|
2821
2733
|
// to contain " · " itself), an explicit "none signed" hint for an empty
|
|
2822
2734
|
// list, book text always via `.textContent`.
|
|
@@ -2831,6 +2743,57 @@
|
|
|
2831
2743
|
el.appendChild(textDiv("ro-value", rowTextFn(item)));
|
|
2832
2744
|
});
|
|
2833
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
|
+
if(st.checkClass === "green" || st.checkClass === "softgreen") return head + out + " · machine check";
|
|
2759
|
+
// am41 item 2: after the last ask step the human's part is the accept, not a check.
|
|
2760
|
+
var lastAsk = 0;
|
|
2761
|
+
((job.plan && job.plan.steps) || []).forEach(function(p){ if(p.ask && p.step > lastAsk) lastAsk = p.step; });
|
|
2762
|
+
return head + out + " · " + (lastAsk > 0 && st.step > lastAsk ? "after you accept" : "you check");
|
|
2763
|
+
}
|
|
2764
|
+
function jobStepFold(st, job){
|
|
2765
|
+
var fold = document.createElement("details");
|
|
2766
|
+
fold.className = "plan-fold";
|
|
2767
|
+
var sum = document.createElement("summary");
|
|
2768
|
+
sum.className = "plan-sum";
|
|
2769
|
+
sum.textContent = stepSummaryText(st, job);
|
|
2770
|
+
fold.appendChild(sum);
|
|
2771
|
+
fold.appendChild(textDiv("plan-head", "step " + st.step + " · from line " + (st.line === null || st.line === undefined ? "none" : st.line)));
|
|
2772
|
+
fold.appendChild(textDiv("plan-row", "reads: " + ((st.reads || []).length ? st.reads.join(", ") : "nothing")));
|
|
2773
|
+
fold.appendChild(textDiv("plan-row", "makes: " + (st.makes || "unknown")));
|
|
2774
|
+
fold.appendChild(textDiv("plan-row", "may do: " + ((st.mayDo || []).length ? st.mayDo.join(", ") : "nothing (pure stop)")));
|
|
2775
|
+
fold.appendChild(textDiv("plan-row", "check: " + (st.ask ? "ASK · waits " + plainWait(st.waitMs) : (st.check || []).join(" "))));
|
|
2776
|
+
return fold;
|
|
2777
|
+
}
|
|
2778
|
+
// The tail: any step that came from no listed line, then the folded Not-checked summary (its label comes from the payload, src/checked.js; always shown).
|
|
2779
|
+
// `placed` (step numbers already folded under a line) is filled by renderJob's line loop before this runs.
|
|
2780
|
+
function paintJobPlan(job, placed){
|
|
2781
|
+
var plan = job.plan || {steps: [], notChecked: {recorded: false, items: []}};
|
|
2782
|
+
var tail = document.getElementById("details-plan-tail");
|
|
2783
|
+
tail.innerHTML = "";
|
|
2784
|
+
(plan.steps || []).filter(function(st){ return !placed[st.step]; }).forEach(function(st){ tail.appendChild(jobStepFold(st, job)); });
|
|
2785
|
+
var nc = plan.notChecked || {};
|
|
2786
|
+
var fold = document.createElement("details");
|
|
2787
|
+
fold.className = "plan-fold plan-notchecked";
|
|
2788
|
+
var sum = document.createElement("summary");
|
|
2789
|
+
sum.className = "plan-sum";
|
|
2790
|
+
sum.textContent = nc.label || "";
|
|
2791
|
+
fold.appendChild(sum);
|
|
2792
|
+
if(!nc.recorded) fold.appendChild(textDiv("plan-row", "not recorded (signed before amendment 34)"));
|
|
2793
|
+
else if(!(nc.items || []).length) fold.appendChild(textDiv("plan-row", "the AI listed nothing"));
|
|
2794
|
+
else nc.items.forEach(function(it){ fold.appendChild(textDiv("plan-row", it)); });
|
|
2795
|
+
tail.appendChild(fold);
|
|
2796
|
+
}
|
|
2834
2797
|
function renderJob(job){
|
|
2835
2798
|
var empty = document.getElementById("job-empty");
|
|
2836
2799
|
var card = document.getElementById("job-card");
|
|
@@ -2839,28 +2802,40 @@
|
|
|
2839
2802
|
empty.hidden = true;
|
|
2840
2803
|
card.hidden = false;
|
|
2841
2804
|
document.getElementById("details-title").textContent = "Job — " + job.flow + " (signed)";
|
|
2805
|
+
// M6: which job this is: the copy the run saved when it started, or (a run from before M6) the flow's job as it is now
|
|
2806
|
+
document.getElementById("details-jobfrom").textContent = job.jobFrom === "run" ? "This is the job as this run started it." : (job.jobFromWhy || "");
|
|
2842
2807
|
// review #5: "Job (prose)" — the signed lines, numbered, WITHOUT their
|
|
2843
2808
|
// guardrail mixed in (guardrails get their own field below).
|
|
2844
2809
|
// 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
|
|
2845
2810
|
// wait, a send line's destination. (The separate Guardrails field is gone.) `job` already carries the values in force for this run.
|
|
2846
2811
|
var jobEl = document.getElementById("details-prose");
|
|
2847
2812
|
jobEl.innerHTML = "";
|
|
2813
|
+
// 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).
|
|
2814
|
+
var placed = {};
|
|
2848
2815
|
if(!job.prose || !job.prose.length){
|
|
2849
2816
|
jobEl.appendChild(textDiv("hint", "no signed prose lines"));
|
|
2850
2817
|
} else {
|
|
2851
2818
|
job.prose.forEach(function(l){
|
|
2852
|
-
|
|
2819
|
+
var cell = document.createElement("div");
|
|
2820
|
+
cell.className = "job-line";
|
|
2821
|
+
cell.appendChild(textDiv("ro-value", l.line + ". " + l.text));
|
|
2853
2822
|
(job.guardrails || []).filter(function(g){ return g.line === l.line; }).forEach(function(g){
|
|
2854
|
-
|
|
2823
|
+
cell.appendChild(textDiv("ro-value sub", "~ " + g.guardrail));
|
|
2855
2824
|
});
|
|
2856
2825
|
(job.asks || []).filter(function(ak){ return ak.line === l.line; }).forEach(function(ak){
|
|
2857
|
-
|
|
2826
|
+
cell.appendChild(textDiv("ro-value sub", "~ waits " + plainWait(ak.waitMs)));
|
|
2858
2827
|
});
|
|
2859
2828
|
(job.sends || []).filter(function(sd){ return sd.line === l.line; }).forEach(function(sd){
|
|
2860
|
-
|
|
2829
|
+
cell.appendChild(textDiv("ro-value sub", "~ writes out to " + (sd.target || "unknown")));
|
|
2861
2830
|
});
|
|
2831
|
+
((job.plan && job.plan.steps) || []).filter(function(st){ return st.line === l.line; }).forEach(function(st){
|
|
2832
|
+
placed[st.step] = true;
|
|
2833
|
+
cell.appendChild(jobStepFold(st, job));
|
|
2834
|
+
});
|
|
2835
|
+
jobEl.appendChild(cell);
|
|
2862
2836
|
});
|
|
2863
2837
|
}
|
|
2838
|
+
paintJobPlan(job, placed);
|
|
2864
2839
|
// review #5: "Ask" — one row per signed ask line.
|
|
2865
2840
|
renderRowsField("details-asks", job.asks, "no signed asks", function(ak){
|
|
2866
2841
|
return "line " + ak.line + " · \"" + ak.question + "\" · waits " + plainWait(ak.waitMs);
|
|
@@ -2887,11 +2862,6 @@
|
|
|
2887
2862
|
renderRowsField("details-sends", job.sends, "no signed sends", function(s){
|
|
2888
2863
|
return "line " + s.line + " · " + (s.kind || "unknown") + " → " + (s.target || "unknown");
|
|
2889
2864
|
});
|
|
2890
|
-
// review #5: "Success" — one row per declared step, off data.js's own
|
|
2891
|
-
// deriveStepSuccessText (never re-derived client-side).
|
|
2892
|
-
renderRowsField("details-success", job.success, "no declared steps", function(s){
|
|
2893
|
-
return s.step + " · " + s.text;
|
|
2894
|
-
});
|
|
2895
2865
|
var sig = job.signature;
|
|
2896
2866
|
// hamr's 2026-09-27 final tweak #2: `sig.signedAt` is the raw signed ISO
|
|
2897
2867
|
// stamp (e.g. "2026-09-24T13:22:40.950Z") — rendered readable/local via
|
|
@@ -3160,7 +3130,7 @@
|
|
|
3160
3130
|
if(row.stuck) return row.stuckLine || row.stuckLabel;
|
|
3161
3131
|
if(row.working) return "working on your " + row.working + "…";
|
|
3162
3132
|
if(row.open && row.resume) return row.resume.label;
|
|
3163
|
-
var bits = [row.status];
|
|
3133
|
+
var bits = [row.statusText || row.status];
|
|
3164
3134
|
if(row.reason) bits.push("reason: " + row.reason);
|
|
3165
3135
|
if(row.answeredAt) bits.push("answered " + (readableDateTime(row.answeredAt) || row.answeredAt));
|
|
3166
3136
|
if(row.why) bits.push(row.why);
|
|
@@ -3257,7 +3227,7 @@
|
|
|
3257
3227
|
if(ask.waiting) return textDiv("wf-meta", "time left: " + duration(ask.timeLeftMs));
|
|
3258
3228
|
// an open ask with a saved answer: the header meta line already says the resume label (stuck or starting) — once.
|
|
3259
3229
|
if(ask.open && ask.resume) return null;
|
|
3260
|
-
var bits = [ask.status];
|
|
3230
|
+
var bits = [ask.statusText || ask.status];
|
|
3261
3231
|
if(ask.reason) bits.push("reason: " + ask.reason);
|
|
3262
3232
|
if(ask.answeredAt) bits.push("answered " + (readableDateTime(ask.answeredAt) || ask.answeredAt));
|
|
3263
3233
|
if(ask.why) bits.push(ask.why);
|
|
@@ -3668,7 +3638,7 @@
|
|
|
3668
3638
|
bits.push(stepBit);
|
|
3669
3639
|
bits.push("draft " + block.draftNo);
|
|
3670
3640
|
bits.push(typeof ask.askedAt === "string" ? "asked " + (readableDateTime(ask.askedAt) || ask.askedAt) : "asked: unknown");
|
|
3671
|
-
bits.push(ask.waiting ? "waiting on you" : (ask.open && ask.resume ? ask.resume.label : ask.status));
|
|
3641
|
+
bits.push(ask.waiting ? "waiting on you" : (ask.open && ask.resume ? ask.resume.label : (ask.statusText || ask.status)));
|
|
3672
3642
|
return bits.join(" · ");
|
|
3673
3643
|
}
|
|
3674
3644
|
// One block per signed ask line (M4c item 5), drawn from the server's `blocks`.
|
|
@@ -3791,7 +3761,7 @@
|
|
|
3791
3761
|
// borrowed-from: bareloop src/panel/index.html@ca7195e — `mainButtonFor`, `renderMain`, `renderProgress`, the
|
|
3792
3762
|
// scroll-on-change block in `renderActions`, `attachSession`/`reattachLive` (without the reuse/auto-sign branch), `syncCardLock`,
|
|
3793
3763
|
// `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
|
|
3794
|
-
// 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);
|
|
3764
|
+
// 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).
|
|
3795
3765
|
(function(){
|
|
3796
3766
|
var card = document.getElementById("chat-job-card");
|
|
3797
3767
|
var clearBtn = document.getElementById("chat-clear-btn");
|
|
@@ -3803,11 +3773,18 @@
|
|
|
3803
3773
|
var mainBtn = document.getElementById("chat-main-btn");
|
|
3804
3774
|
var mainHint = document.getElementById("chat-main-hint");
|
|
3805
3775
|
var startOverBtn = document.getElementById("chat-startover-btn");
|
|
3806
|
-
var
|
|
3807
|
-
var msgRow = document.getElementById("chat-msg-row");
|
|
3776
|
+
var reviseBtn = document.getElementById("chat-revise-btn");
|
|
3808
3777
|
var errEl = document.getElementById("chat-card-error"); // POLL-OWNED: the draft's own sentence (red / stopped)
|
|
3809
3778
|
var actionErrEl = document.getElementById("chat-action-error"); // ACTION-OWNED: only a click's refusal; the poll never wipes it
|
|
3810
3779
|
var progressRow = document.getElementById("chat-progress-row");
|
|
3780
|
+
var questionBox = document.getElementById("chat-question");
|
|
3781
|
+
var qHead = document.getElementById("chat-q-head");
|
|
3782
|
+
var qLine = document.getElementById("chat-q-line");
|
|
3783
|
+
var qText = document.getElementById("chat-q-text");
|
|
3784
|
+
var qAnswer = document.getElementById("chat-q-answer");
|
|
3785
|
+
var qError = document.getElementById("chat-q-error");
|
|
3786
|
+
var qSend = document.getElementById("chat-q-send");
|
|
3787
|
+
var extrasEl = document.getElementById("chat-extras");
|
|
3811
3788
|
var newBox = document.getElementById("jf-new");
|
|
3812
3789
|
var runBox = document.getElementById("jf-run");
|
|
3813
3790
|
var runInputsEl = document.getElementById("jf-run-inputs");
|
|
@@ -3825,18 +3802,24 @@
|
|
|
3825
3802
|
var modeRow = document.getElementById("jf-mode-row");
|
|
3826
3803
|
var titleEl = document.getElementById("job-card-title");
|
|
3827
3804
|
|
|
3805
|
+
var editOf = null; // M6: the signed job this card EDITS: { flow, flowHash } (ONE writer each: startEdit sets it, leaveEdit clears it); null = a new job
|
|
3828
3806
|
var mode = "new"; // "new" | "run" | "resume"
|
|
3829
3807
|
var runSignInfo = null; // Run form, first Sign & run click: { hash } (cleared by any edit)
|
|
3830
3808
|
var resumeCtx = null; // the run being resumed: { flow, runId, form }
|
|
3831
3809
|
var resumeSignInfo = null; // Resume form, first Sign & resume click: { hash }
|
|
3832
3810
|
var modeBeforeResume = "new";
|
|
3833
3811
|
var mainAction = "none";
|
|
3812
|
+
var mainStartOver = false; // the main button reads Start over (amendment 14 item 6: that draft names the one it started over from)
|
|
3834
3813
|
var startOk = false;
|
|
3835
3814
|
var sessionId = null; // the draft's id (GET /api/author/<id>)
|
|
3836
3815
|
var sessionLive = false; // a draft exists that is not abandoned or signed
|
|
3837
3816
|
var lastState = null; // the draft as the server last described it
|
|
3838
3817
|
var signInfo = null; // the first Sign click's reply: { hash, flowName, capUsd, runId }
|
|
3839
3818
|
var signClickedOnce = false;
|
|
3819
|
+
var reviseOpen = false; // amendment 14 item 2: Revise was pressed on a green plan, so every card field is open (ONE writer: setReviseOpen)
|
|
3820
|
+
var qKey = ""; // which question the box is showing (draft id + k): the answer box is rewritten only when this changes
|
|
3821
|
+
var qBusy = false; // an answer POST is in flight
|
|
3822
|
+
var extrasKey = "";
|
|
3840
3823
|
var busy = false; // a POST is in flight (disabled from the click until the reply)
|
|
3841
3824
|
var startId = null; // the run start being watched (GET /api/author/start/<id>)
|
|
3842
3825
|
var refusedStartId = null; // a refused start whose sentence is on the card; Clear dismisses it on the server (cleared.json)
|
|
@@ -3892,19 +3875,27 @@
|
|
|
3892
3875
|
if(st.phase === "drafting"){
|
|
3893
3876
|
return {text: "Draft", action: "none", disabled: true};
|
|
3894
3877
|
}
|
|
3878
|
+
if((st.phase === "red" || st.phase === "stopped") && st.revisable){
|
|
3879
|
+
// amendment 14 items 3-4: a red revise keeps the edits; Draft is another revise, Start over (no revises left) a fresh draft
|
|
3880
|
+
return (st.left || 0) > 0 ? {text: "Draft", action: "revise", disabled: blocked} : {text: "Start over", action: "draft", startOver: true, disabled: blocked};
|
|
3881
|
+
}
|
|
3895
3882
|
if(st.phase === "red"){
|
|
3896
3883
|
return {text: "Fix and draft again", action: "draft", disabled: blocked};
|
|
3897
3884
|
}
|
|
3898
3885
|
if(st.phase === "stopped"){
|
|
3899
3886
|
return {text: "Draft again", action: "draft", disabled: blocked};
|
|
3900
3887
|
}
|
|
3901
|
-
if(st.phase === "revising"){
|
|
3888
|
+
if(st.phase === "revising" || st.phase === "redrafting"){
|
|
3889
|
+
return {text: "Sign & run", action: "none", disabled: true};
|
|
3890
|
+
}
|
|
3891
|
+
if(st.phase === "questions-open"){
|
|
3892
|
+
// amendments 24/25: nothing is signable, and a revise is no way round it: the question is answered first
|
|
3902
3893
|
return {text: "Sign & run", action: "none", disabled: true};
|
|
3903
3894
|
}
|
|
3904
3895
|
if(st.phase === "green"){
|
|
3905
|
-
// amendment
|
|
3906
|
-
if(st.
|
|
3907
|
-
return {text: "
|
|
3896
|
+
// amendment 14 item 2: Revise opened the card, so the one button is Draft (the card posted to the revise route)
|
|
3897
|
+
if(st.reviseOpen && st.revisable && (st.left || 0) > 0){
|
|
3898
|
+
return {text: "Draft", action: "revise", disabled: blocked};
|
|
3908
3899
|
}
|
|
3909
3900
|
if(st.signClicked){
|
|
3910
3901
|
var signCap = (cap !== undefined && cap !== null && cap !== "") ? " \u00b7 $" + cap : "";
|
|
@@ -3914,28 +3905,20 @@
|
|
|
3914
3905
|
}
|
|
3915
3906
|
return {text: "Draft", action: "none", disabled: true};
|
|
3916
3907
|
}
|
|
3917
|
-
// pure: the
|
|
3918
|
-
function
|
|
3919
|
-
return st.mode === "new" && !!st.session && st.phase === "green" && (st.left || 0) > 0;
|
|
3908
|
+
// pure: the green plan's Revise button (amendment 14 item 2): on a green plan with revises left, before Revise is pressed
|
|
3909
|
+
function reviseShownFor(st){
|
|
3910
|
+
return st.mode === "new" && !!st.session && st.phase === "green" && !!st.revisable && (st.left || 0) > 0 && !st.reviseOpen;
|
|
3920
3911
|
}
|
|
3921
|
-
// pure: Start over
|
|
3912
|
+
// 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.)
|
|
3922
3913
|
function startOverShownFor(st){
|
|
3923
|
-
return st.mode === "new" && !!st.session && st.phase === "green" && st.left === 0;
|
|
3914
|
+
return st.mode === "new" && !!st.session && st.phase === "green" && !!st.revisable && st.left === 0;
|
|
3924
3915
|
}
|
|
3925
|
-
//
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
function bubblesFor(state){
|
|
3929
|
-
var out = [];
|
|
3930
|
-
if(!state || (state.phase !== "green" && state.phase !== "revising")) return out;
|
|
3931
|
-
(state.notes || []).forEach(function(nt){
|
|
3932
|
-
out.push({role: "you", who: "you", text: String(nt.text || "").replace(/\s+$/, "")});
|
|
3933
|
-
if(nt.phase === "green") out.push({role: "bot", who: "fwdloop", text: "New plan, hash " + String(nt.hash || "").slice(0, 8) + ". " + changesLeftText(nt.left) + "."});
|
|
3934
|
-
});
|
|
3935
|
-
return out;
|
|
3916
|
+
// 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)
|
|
3917
|
+
function greenFieldsOpenFor(st){
|
|
3918
|
+
return !!st.revisable && (!!st.reviseOpen || st.left === 0);
|
|
3936
3919
|
}
|
|
3937
|
-
function
|
|
3938
|
-
return left + (left === 1 ? "
|
|
3920
|
+
function revisesLeftText(left){
|
|
3921
|
+
return left + (left === 1 ? " revise left" : " revises left");
|
|
3939
3922
|
}
|
|
3940
3923
|
// 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
|
|
3941
3924
|
// guardrail line, nothing on an empty line. The inputs: a number per non-empty line.
|
|
@@ -3949,6 +3932,44 @@
|
|
|
3949
3932
|
return String(n);
|
|
3950
3933
|
});
|
|
3951
3934
|
}
|
|
3935
|
+
// am41 item 7: ONE function turns a checker's red (the text src/declaration.js writes) into one plain sentence for the card. The raw text rides
|
|
3936
|
+
// along unchanged and is folded under "details"; a red no rule below knows gets the generic sentence and still shows its raw text. This reads
|
|
3937
|
+
// the checker's own fixed wording, never the model's prose.
|
|
3938
|
+
function plainPlanCheck(raw){
|
|
3939
|
+
var PLAN_CHECK_RULES = [
|
|
3940
|
+
[/which is not in the job line's words/, "A section name in the plan's check is not in your job line. Change the job line to use the section words you want."],
|
|
3941
|
+
[/the job line says .*; the check says/, "The sections in the plan's check come in a different order than your job line. Change the job line to change the order."],
|
|
3942
|
+
[/the guardrail says \d+ sections; the check has/, "The number of sections in your guardrail is not the number in the plan's check."],
|
|
3943
|
+
[/section name is a short phrase|which is the job line or most of it/, "A section name in the plan's check is too long; it must be a short phrase from your job line."],
|
|
3944
|
+
[/one section name may not contain another/, "One section name in the plan's check contains another, which cannot be checked."],
|
|
3945
|
+
[/wordsPerSection/, "The words for each section in your guardrail and in the plan's check do not match."],
|
|
3946
|
+
[/work as a pair/, "The plan's check has one part of a pair without the other, so it cannot be checked."],
|
|
3947
|
+
[/is blank|characters; the most one entry|ends in ":"/, "A name in the plan's check is empty, too long or ends in a colon, so it cannot be matched."],
|
|
3948
|
+
[/cannot be built into a check/, "The plan's check cannot be built from what the AI wrote."],
|
|
3949
|
+
[/is not its signed line/, "A step does not use your job line word for word as its goal."],
|
|
3950
|
+
[/not in the catalogue|not wired|which is not signed|checkpoint/, "A step uses a tool that is not available for this job."],
|
|
3951
|
+
[/reads artifact|is a duplicate|\.reads must|\.emits must/, "The steps do not pass their results to each other in a workable order."],
|
|
3952
|
+
[/ask at line \d+|signed ask at line|ask slot/, "The ask on one of your lines is not set up as a plain stop where you decide."],
|
|
3953
|
+
[/send at line \d+|signed send at line|send slot/, "The send step is not set up to follow your accept and write only to your destination."],
|
|
3954
|
+
[/hitl after the last signed ask/, "A step after your last ask would leave without your seeing it, so it is refused."],
|
|
3955
|
+
[/is a pause .* unsigned line/, "A step pauses at a line you did not sign as an ask."],
|
|
3956
|
+
[/neither served by any step/, "A line of your job is not covered by any step."],
|
|
3957
|
+
[/picks|inputFacts|invented name/, "The plan names a field that is not in your input."],
|
|
3958
|
+
[/guardrailClasses|unjudgeable|refused/, "The AI's notes on which lines it can check are not in a form the checker accepts."],
|
|
3959
|
+
[/^line \d+'s (guardrail|check)|can't write files/, null],
|
|
3960
|
+
[/must be an? |is required|must name|does not name/, "The plan the AI wrote is not in the shape the checker needs."]
|
|
3961
|
+
];
|
|
3962
|
+
var text = typeof raw === "string" ? raw : "";
|
|
3963
|
+
for(var i = 0; i < PLAN_CHECK_RULES.length; i++){
|
|
3964
|
+
if(PLAN_CHECK_RULES[i][0].test(text)) return {say: PLAN_CHECK_RULES[i][1] === null ? text.replace(/^declaration: /, "") : PLAN_CHECK_RULES[i][1], raw: text};
|
|
3965
|
+
}
|
|
3966
|
+
return {say: "One of the checks on the plan failed.", raw: text};
|
|
3967
|
+
}
|
|
3968
|
+
// a failed step's details: the plain sentences, with the raw checker texts beside them in `raw`
|
|
3969
|
+
function failedDetails(reds){
|
|
3970
|
+
var rows = (reds || []).map(plainPlanCheck);
|
|
3971
|
+
return {details: rows.map(function(r){ return r.say; }), raw: rows.map(function(r){ return r.raw; })};
|
|
3972
|
+
}
|
|
3952
3973
|
// pure: the progress list for a draft. Chronological; a waiting step has no check; a step's detail lines sit under it; no two
|
|
3953
3974
|
// identical lines in a row. `ctx` = { model, starting }.
|
|
3954
3975
|
function stepsFor(state, ctx){
|
|
@@ -3959,26 +3980,33 @@
|
|
|
3959
3980
|
if(state){
|
|
3960
3981
|
if(state.phase === "drafting"){
|
|
3961
3982
|
out.push({id: "drafting", label: "drafting with " + who + capPart, status: "running", details: []});
|
|
3983
|
+
} else if(Array.isArray(state.revises)){
|
|
3984
|
+
// 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).
|
|
3985
|
+
out.push({id: "drafted", label: "drafted with " + who, status: "done", details: []});
|
|
3986
|
+
var reviseNo = 0;
|
|
3987
|
+
state.revises.forEach(function(rv){
|
|
3988
|
+
// an answer redraft (amendment 24 item 4) is not a revise and is not counted as one
|
|
3989
|
+
var label = rv.kind === "answers" ? "drafted again with your answers" : "revise " + (reviseNo += 1);
|
|
3990
|
+
if(rv.phase === "running") out.push({id: "revise-" + rv.n, label: label, status: "running", details: []});
|
|
3991
|
+
else if(rv.phase === "green") out.push({id: "revise-" + rv.n, label: label, status: "done", details: []});
|
|
3992
|
+
else { var rf = failedDetails(rv.reds); out.push({id: "revise-" + rv.n, label: label, status: "failed", details: rf.details, raw: rf.raw}); }
|
|
3993
|
+
});
|
|
3994
|
+
if(state.phase === "green"){
|
|
3995
|
+
if(ctx.starting) out.push({id: "signed", label: "signed", status: "done", details: []});
|
|
3996
|
+
else out.push({id: "sign", label: ctx.signClicked ? "waiting for your second click" : "waiting for your signature", status: "waiting", details: []});
|
|
3997
|
+
}
|
|
3998
|
+
if(state.phase === "questions-open") out.push({id: "question", label: "waiting for your answer (" + state.openK + " of " + state.total + ")", status: "waiting", details: []});
|
|
3962
3999
|
} else if(state.phase === "red"){
|
|
3963
4000
|
out.push({id: "drafted", label: "drafted with " + who, status: "done", details: []});
|
|
3964
|
-
|
|
4001
|
+
var cf = failedDetails(state.reds);
|
|
4002
|
+
out.push({id: "checks", label: "plan checks", status: "failed", details: cf.details, raw: cf.raw});
|
|
3965
4003
|
} else if(state.phase === "stopped"){
|
|
3966
4004
|
out.push({id: "drafting", label: "drafting with " + who + capPart, status: "failed", details: []});
|
|
3967
4005
|
} else if(state.phase === "green" || state.phase === "revising"){
|
|
3968
4006
|
out.push({id: "drafted", label: "drafted with " + who, status: "done", details: []});
|
|
3969
|
-
|
|
3970
|
-
(state.notes || []).forEach(function(nt){
|
|
3971
|
-
var body = String(nt.text || "").replace(/\s+$/, "");
|
|
3972
|
-
var label = "change " + nt.n + ": " + body;
|
|
3973
|
-
if(nt.phase === "running") out.push({id: "change-" + nt.n, label: label, status: "running", details: []});
|
|
3974
|
-
else if(nt.phase === "green") out.push({id: "change-" + nt.n, label: label, status: "done", details: []});
|
|
3975
|
-
else out.push({id: "change-" + nt.n, label: label, status: "failed", details: (nt.reds && nt.reds.length ? nt.reds.slice() : []).concat(nt.say ? [nt.say] : [])});
|
|
3976
|
-
});
|
|
3977
|
-
if(state.phase === "revising"){
|
|
3978
|
-
// the last green plan stays on show; nothing to sign until the change comes back
|
|
3979
|
-
} else if(ctx.starting){
|
|
4007
|
+
if(ctx.starting){
|
|
3980
4008
|
out.push({id: "signed", label: "signed", status: "done", details: []});
|
|
3981
|
-
} else {
|
|
4009
|
+
} else if(state.phase !== "revising"){
|
|
3982
4010
|
out.push({id: "sign", label: ctx.signClicked ? "waiting for your second click" : "waiting for your signature", status: "waiting", details: []});
|
|
3983
4011
|
}
|
|
3984
4012
|
}
|
|
@@ -3986,6 +4014,35 @@
|
|
|
3986
4014
|
if(ctx.starting) out.push({id: "starting", label: "starting the run", status: "running", details: []});
|
|
3987
4015
|
return out.filter(function(s, i){ return i === 0 || JSON.stringify(s) !== JSON.stringify(out[i - 1]); });
|
|
3988
4016
|
}
|
|
4017
|
+
// pure: the question box's content (amendments 24/25), or null when no question is open. One question at a time: `openK` of `total`.
|
|
4018
|
+
function questionViewFor(state){
|
|
4019
|
+
if(!state || state.phase !== "questions-open" || !Array.isArray(state.questions)) return null;
|
|
4020
|
+
var q = state.questions.filter(function(x){ return x.k === state.openK; })[0];
|
|
4021
|
+
if(!q) return null;
|
|
4022
|
+
return {
|
|
4023
|
+
key: String(state.draftId) + ":" + q.k, k: q.k,
|
|
4024
|
+
head: "A question the plan raised (" + q.k + " of " + state.total + ")",
|
|
4025
|
+
line: q.lineText ? "About job line " + q.line + ": " + q.lineText : "About job line " + q.line,
|
|
4026
|
+
question: q.question
|
|
4027
|
+
};
|
|
4028
|
+
}
|
|
4029
|
+
// pure: what sits beside a green plan: Your answers (only when the plan was drafted with some), Checked (the machine's sentences from the
|
|
4030
|
+
// typed checks) and Not checked (the drafter's own list, ALWAYS with its label), or null when there is no plan to show
|
|
4031
|
+
function extrasFor(state){
|
|
4032
|
+
if(!state || state.phase !== "green" || !Array.isArray(state.checked)) return null;
|
|
4033
|
+
var blocks = [];
|
|
4034
|
+
if(Array.isArray(state.answers) && state.answers.length){
|
|
4035
|
+
blocks.push({id: "chat-answers", head: "Your answers", sub: "", lines: state.answers.map(function(a){
|
|
4036
|
+
return "line " + a.line + (a.lineText ? ": " + a.lineText : "") + "\n > " + a.answer;
|
|
4037
|
+
})});
|
|
4038
|
+
}
|
|
4039
|
+
blocks.push({id: "chat-checked", head: "Checked", sub: "built by the machine from the plan's checks", lines: state.checked.map(function(c){
|
|
4040
|
+
return (c.line !== null && c.line !== undefined ? "line " + c.line : "step " + c.step) + ": " + c.sentences.join(" ");
|
|
4041
|
+
})});
|
|
4042
|
+
var nc = state.notChecked || {};
|
|
4043
|
+
blocks.push({id: "chat-notchecked", head: nc.label || "", sub: "", lines: (nc.items && nc.items.length) ? nc.items.map(function(x){ return "- " + x; }) : ["The drafter listed nothing."]});
|
|
4044
|
+
return {blocks: blocks};
|
|
4045
|
+
}
|
|
3989
4046
|
// pure: did this POST succeed (one decision for every handler)
|
|
3990
4047
|
function chatPostOutcome(r){
|
|
3991
4048
|
var ok = !!(r && r.status >= 200 && r.status < 300 && r.body && r.body.ok === true);
|
|
@@ -4013,7 +4070,8 @@
|
|
|
4013
4070
|
el.style.height = "auto";
|
|
4014
4071
|
if(!el.scrollHeight){ el.style.height = ""; return; }
|
|
4015
4072
|
var border = el.offsetHeight - el.clientHeight;
|
|
4016
|
-
|
|
4073
|
+
var cap = parseFloat(window.getComputedStyle(el).maxHeight);
|
|
4074
|
+
el.style.height = Math.min(el.scrollHeight + border, cap > 0 ? cap : 200) + "px";
|
|
4017
4075
|
}
|
|
4018
4076
|
// Paint a gutter: a hidden mirror of the textarea (same font, same content width, same wrapping) measures each logical line's height;
|
|
4019
4077
|
// the gutter gets one entry of exactly that height, its mark on the first visual line. Re-run on every input, resize and fit.
|
|
@@ -4088,7 +4146,8 @@
|
|
|
4088
4146
|
destination: destEl.value.trim(),
|
|
4089
4147
|
inputs: inputsBox.value,
|
|
4090
4148
|
capUsd: byId("jf-cap-money").value.trim(),
|
|
4091
|
-
askWait: askWaitEl.value.trim()
|
|
4149
|
+
askWait: askWaitEl.value.trim(),
|
|
4150
|
+
editOf: editOf
|
|
4092
4151
|
};
|
|
4093
4152
|
}
|
|
4094
4153
|
function runWaits(){
|
|
@@ -4211,13 +4270,17 @@
|
|
|
4211
4270
|
// is editable (the draft was made from these values). ONE function owns it. A red or stopped draft unlocks the card (fix, draft again).
|
|
4212
4271
|
function cardLocked(){
|
|
4213
4272
|
var ph = (sessionLive && lastState) ? lastState.phase : null;
|
|
4214
|
-
|
|
4273
|
+
// amendment 14: a green plan locks the card until Revise opens it (or no revise is left); a red or stopped one is open
|
|
4274
|
+
var greenOpen = ph === "green" && greenFieldsOpenFor({revisable: Array.isArray(lastState.revises), reviseOpen: reviseOpen, left: lastState.revisesLeft});
|
|
4275
|
+
return busy || startId !== null || (mode === "new" && (ph === "drafting" || ph === "revising" || ph === "redrafting" || ph === "questions-open" || (ph === "green" && !greenOpen)));
|
|
4215
4276
|
}
|
|
4216
4277
|
function syncCardLock(){
|
|
4217
4278
|
var on = cardLocked();
|
|
4218
4279
|
card.querySelectorAll("input[type=text], textarea").forEach(function(el){ el.readOnly = on; el.classList.toggle("locked", on); });
|
|
4280
|
+
if(editOf !== null){ byId("jf-name").readOnly = true; byId("jf-name").classList.add("locked"); } // M6: an edit keeps its job's name
|
|
4219
4281
|
runFlowSel.disabled = on;
|
|
4220
4282
|
runFlowSel.classList.toggle("locked", on);
|
|
4283
|
+
syncEditBtn();
|
|
4221
4284
|
rwPickedEl.classList.toggle("locked", on);
|
|
4222
4285
|
card.querySelectorAll('input[name="jf-mode"]').forEach(function(r){ r.disabled = on || sessionLive; });
|
|
4223
4286
|
}
|
|
@@ -4255,6 +4318,38 @@
|
|
|
4255
4318
|
el.appendChild(row);
|
|
4256
4319
|
});
|
|
4257
4320
|
}
|
|
4321
|
+
// ---- M6: Edit a signed job. The list entry carries the job as a card (`edit`); Edit fills the New-job boxes from it and keeps the job's name and
|
|
4322
|
+
// the signature hash it was opened at. Nothing is written until the normal Draft -> Sign. Clear / Abandon leave the job exactly as it was.
|
|
4323
|
+
var editBtn = document.getElementById("jf-run-edit");
|
|
4324
|
+
var editWhyEl = document.getElementById("jf-run-edit-why");
|
|
4325
|
+
var editBannerEl = document.getElementById("jf-edit-banner");
|
|
4326
|
+
function syncEditBtn(){
|
|
4327
|
+
if(!editBtn) return; // called by the first lock sync, before this block has run
|
|
4328
|
+
var f = selectedFlow();
|
|
4329
|
+
var can = !!(f && f.edit && f.edit.ok === true);
|
|
4330
|
+
editBtn.disabled = !can || cardLocked() || sessionLive || startId !== null;
|
|
4331
|
+
editWhyEl.textContent = (f && f.edit && f.edit.ok === false) ? f.edit.say : "";
|
|
4332
|
+
}
|
|
4333
|
+
function startEdit(){
|
|
4334
|
+
var f = selectedFlow();
|
|
4335
|
+
if(!f || !f.edit || f.edit.ok !== true || cardLocked() || sessionLive) return;
|
|
4336
|
+
var c = f.edit.card;
|
|
4337
|
+
editOf = {flow: f.flow, flowHash: f.edit.flowHash};
|
|
4338
|
+
setMode("new");
|
|
4339
|
+
setVal("jf-name", f.flow); setVal("jf-job", c.job); setVal("jf-cap-money", c.capUsd);
|
|
4340
|
+
setVal("jf-dest-folder", c.destination); setVal("jf-inputs", c.inputs); setVal("jf-ask-wait", c.askWait || "1h");
|
|
4341
|
+
editBannerEl.textContent = "Editing \u201c" + f.flow + "\u201d. Draft it, read the new plan, then sign: signing replaces this job. Clear leaves it exactly as it was.";
|
|
4342
|
+
editBannerEl.hidden = false;
|
|
4343
|
+
chatActionOk();
|
|
4344
|
+
refreshCapNote(); fitCardBoxes(); refreshStartEnabled();
|
|
4345
|
+
}
|
|
4346
|
+
// the card stops editing a job: the name box is free again
|
|
4347
|
+
function leaveEdit(){
|
|
4348
|
+
editOf = null;
|
|
4349
|
+
editBannerEl.hidden = true; editBannerEl.textContent = "";
|
|
4350
|
+
var nm = byId("jf-name"); nm.readOnly = false; nm.classList.remove("locked");
|
|
4351
|
+
}
|
|
4352
|
+
editBtn.addEventListener("click", startEdit);
|
|
4258
4353
|
function paintRunFlow(){
|
|
4259
4354
|
var f = selectedFlow();
|
|
4260
4355
|
var v = f ? (pickedRun ? pickedRun.values : f.values) : null; // a picked run's own values, else the flow's own
|
|
@@ -4283,6 +4378,7 @@
|
|
|
4283
4378
|
byId("jf-run-id").value = autoRunId;
|
|
4284
4379
|
clearFieldErrors();
|
|
4285
4380
|
refreshCapNote();
|
|
4381
|
+
syncEditBtn();
|
|
4286
4382
|
}
|
|
4287
4383
|
// borrowed-from: bareloop src/panel/index.html@b5e37b8 — the Reuse workflow picker: ONE function shows the search box + list before a pick and the
|
|
4288
4384
|
// picked box after; a row is the name (the typed part marked) over the flow's track record line.
|
|
@@ -4360,17 +4456,32 @@
|
|
|
4360
4456
|
// ---- render: the progress list, the readout and the one main button ----
|
|
4361
4457
|
// Returns true when the list's content actually changed (a new line, or the latest line changed) so the caller can scroll only
|
|
4362
4458
|
// then; an identical poll tick returns false and leaves the person's scroll position alone.
|
|
4459
|
+
// A fold the person opened stays open: the list is rewritten only when its markup changed, and a rewrite draws each fold open again
|
|
4460
|
+
// from progressOpen (keyed step id : detail index, set by the toggle listener) until the person closes it.
|
|
4461
|
+
var progressHtml = "";
|
|
4462
|
+
var progressOpen = {};
|
|
4463
|
+
progressRow.addEventListener("toggle", function(e){
|
|
4464
|
+
var key = e.target && e.target.getAttribute ? e.target.getAttribute("data-fold") : null;
|
|
4465
|
+
if(key) progressOpen[key] = e.target.open === true;
|
|
4466
|
+
}, true);
|
|
4363
4467
|
function renderProgress(steps){
|
|
4364
|
-
var before = progressRow.innerHTML;
|
|
4365
4468
|
progressRow.hidden = steps.length === 0;
|
|
4366
|
-
|
|
4469
|
+
var html = steps.map(function(st){
|
|
4367
4470
|
var cls = st.status === "waiting" ? "wait" : (st.status === "running" ? "run" : (st.status === "failed" ? "bad" : "ok"));
|
|
4368
4471
|
var sign = cls === "ok" ? "✓" : (cls === "bad" ? "✗" : "");
|
|
4369
4472
|
return '<li class="step ' + cls + '" data-step="' + escapeXml(st.id) + '"><div class="step-line"><span class="step-label">' + escapeXml(st.label) + '</span>' +
|
|
4370
4473
|
'<span class="step-sign">' + sign + '</span></div>' +
|
|
4371
|
-
(st.details || []).map(function(d){
|
|
4474
|
+
(st.details || []).map(function(d, k){
|
|
4475
|
+
var raw = st.raw || [];
|
|
4476
|
+
var key = st.id + ":" + k;
|
|
4477
|
+
var fold = typeof raw[k] === "string" && raw[k] !== "" ? '<details class="step-raw" data-fold="' + escapeXml(key) + '"' + (progressOpen[key] ? " open" : "") + '><summary>details</summary>' + escapeXml(raw[k]) + '</details>' : "";
|
|
4478
|
+
return '<div class="step-detail">' + escapeXml("> " + d) + fold + '</div>';
|
|
4479
|
+
}).join("") + '</li>';
|
|
4372
4480
|
}).join("");
|
|
4373
|
-
|
|
4481
|
+
if(html === progressHtml) return false;
|
|
4482
|
+
progressHtml = html;
|
|
4483
|
+
progressRow.innerHTML = html;
|
|
4484
|
+
return true;
|
|
4374
4485
|
}
|
|
4375
4486
|
// the plan the human is about to sign: the drafter's readout and the hash; nothing else goes in the thread
|
|
4376
4487
|
var threadKey = "";
|
|
@@ -4382,25 +4493,49 @@
|
|
|
4382
4493
|
}).join("\n");
|
|
4383
4494
|
}
|
|
4384
4495
|
function renderThread(state){
|
|
4496
|
+
// a revise being drafted leaves the plan on show until the new one replaces it (the view carries no plan meanwhile)
|
|
4497
|
+
if(state && (state.phase === "revising" || state.phase === "redrafting")) return;
|
|
4385
4498
|
var html = "";
|
|
4386
|
-
if(state &&
|
|
4387
|
-
|
|
4388
|
-
html = bubblesFor(state).map(function(m){
|
|
4389
|
-
return '<div class="msg ' + m.role + '"><div class="who">' + escapeXml(m.who) + '</div>' + escapeXml(m.text) + '</div>';
|
|
4390
|
-
}).join("") +
|
|
4391
|
-
'<div class="msg bot" data-testid="chat-plan"><div class="who">fwdloop</div>' + readoutHtml(state) +
|
|
4499
|
+
if(state && state.phase === "green" && state.readout){
|
|
4500
|
+
html = '<div class="msg bot" data-testid="chat-plan"><div class="who">fwdloop</div>' + readoutHtml(state) +
|
|
4392
4501
|
'\n\nPlan hash: ' + escapeXml(state.hash || "") + '</div>';
|
|
4393
4502
|
}
|
|
4394
4503
|
if(html !== threadKey){ threadKey = html; thread.innerHTML = html; }
|
|
4395
4504
|
}
|
|
4505
|
+
// 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
|
|
4506
|
+
// when the QUESTION changes (a new key); the same question on the next tick touches nothing.
|
|
4507
|
+
function renderQuestion(state){
|
|
4508
|
+
var v = questionViewFor(state);
|
|
4509
|
+
if(!v){
|
|
4510
|
+
if(qKey !== ""){ qKey = ""; qAnswer.value = ""; qError.textContent = ""; }
|
|
4511
|
+
questionBox.hidden = true;
|
|
4512
|
+
return;
|
|
4513
|
+
}
|
|
4514
|
+
questionBox.hidden = false;
|
|
4515
|
+
if(v.key !== qKey){
|
|
4516
|
+
qKey = v.key;
|
|
4517
|
+
qHead.textContent = v.head; qLine.textContent = v.line; qText.textContent = v.question;
|
|
4518
|
+
qAnswer.value = ""; qError.textContent = "";
|
|
4519
|
+
}
|
|
4520
|
+
}
|
|
4521
|
+
// 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
|
|
4522
|
+
function renderExtras(state){
|
|
4523
|
+
if(state && (state.phase === "revising" || state.phase === "redrafting")) return;
|
|
4524
|
+
var v = extrasFor(state);
|
|
4525
|
+
var html = v ? v.blocks.map(function(b){
|
|
4526
|
+
return '<div class="msg" id="' + b.id + '" data-testid="' + b.id + '"><b class="readout-head">' + escapeXml(b.head) + '</b>' +
|
|
4527
|
+
(b.sub ? ' <span class="hint">(' + escapeXml(b.sub) + ')</span>' : '') + '\n' + b.lines.map(escapeXml).join("\n") + '</div>';
|
|
4528
|
+
}).join("") : "";
|
|
4529
|
+
if(html !== extrasKey){ extrasKey = html; extrasEl.innerHTML = html; }
|
|
4530
|
+
}
|
|
4396
4531
|
function renderMain(){
|
|
4397
|
-
var st = {mode: mode, session: sessionLive, startOk: startOk, busy: busy || startId !== null, signClicked: signClickedOnce,
|
|
4532
|
+
var st = {mode: mode, session: sessionLive, startOk: startOk, busy: busy || startId !== null, signClicked: signClickedOnce, reviseOpen: reviseOpen};
|
|
4398
4533
|
if(sessionLive && lastState){
|
|
4399
4534
|
st.phase = lastState.phase;
|
|
4400
4535
|
st.hash = signInfo ? signInfo.hash : lastState.hash;
|
|
4401
|
-
st.
|
|
4536
|
+
st.revisable = Array.isArray(lastState.revises);
|
|
4537
|
+
st.left = lastState.revisesLeft;
|
|
4402
4538
|
}
|
|
4403
|
-
st.boxOpen = askBoxOpenFor(st);
|
|
4404
4539
|
if(mode === "run"){
|
|
4405
4540
|
st.capUsd = runCapEl.value.trim();
|
|
4406
4541
|
st.runDiffers = runDiffers();
|
|
@@ -4418,19 +4553,19 @@
|
|
|
4418
4553
|
var b = mainButtonFor(st);
|
|
4419
4554
|
mainBtn.textContent = b.text;
|
|
4420
4555
|
mainBtn.disabled = b.disabled;
|
|
4421
|
-
mainAction = b.action;
|
|
4422
|
-
//
|
|
4423
|
-
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
mainHint.textContent = st.boxOpen ? changesLeftText(st.left) : "";
|
|
4556
|
+
mainAction = b.action; mainStartOver = !!b.startOver;
|
|
4557
|
+
// amendment 14 item 3: the count shows while a draft has revises to count; at 0 the way on is Start over
|
|
4558
|
+
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.") : "";
|
|
4559
|
+
reviseBtn.hidden = !reviseShownFor(st);
|
|
4560
|
+
reviseBtn.disabled = !!st.busy;
|
|
4427
4561
|
startOverBtn.hidden = !startOverShownFor(st);
|
|
4428
4562
|
startOverBtn.disabled = !!st.busy;
|
|
4429
4563
|
fitCardBoxes();
|
|
4430
|
-
if(boxShown) fitBox(msgEl);
|
|
4431
4564
|
}
|
|
4432
4565
|
function renderActions(state){
|
|
4433
4566
|
lastState = state;
|
|
4567
|
+
renderQuestion(state);
|
|
4568
|
+
renderExtras(state);
|
|
4434
4569
|
// 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
|
|
4435
4570
|
if(signInfo && state.hash && state.hash !== signInfo.hash){ signInfo = null; signClickedOnce = false; }
|
|
4436
4571
|
// #chat-card-error is POLL-OWNED: it carries only the draft's own sentence (a red plan or a stopped child), written here and
|
|
@@ -4454,28 +4589,30 @@
|
|
|
4454
4589
|
// the boxes. Touches neither error line, so a refusal on screen stays on screen.
|
|
4455
4590
|
function endSession(){
|
|
4456
4591
|
stopPoll();
|
|
4457
|
-
sessionId = null; sessionLive = false; lastState = null; signInfo = null; signClickedOnce = false;
|
|
4592
|
+
sessionId = null; sessionLive = false; lastState = null; signInfo = null; signClickedOnce = false; reviseOpen = false;
|
|
4458
4593
|
threadKey = ""; thread.innerHTML = "";
|
|
4594
|
+
renderQuestion(null); renderExtras(null);
|
|
4459
4595
|
errEl.textContent = "";
|
|
4460
|
-
progressRow.hidden = true; progressRow.innerHTML = "";
|
|
4596
|
+
progressRow.hidden = true; progressRow.innerHTML = ""; progressHtml = "";
|
|
4461
4597
|
refreshStartEnabled();
|
|
4462
4598
|
}
|
|
4463
4599
|
function openNewCard(){
|
|
4464
4600
|
thread.innerHTML = ""; threadKey = "";
|
|
4465
|
-
|
|
4601
|
+
renderQuestion(null); renderExtras(null);
|
|
4466
4602
|
errEl.textContent = "";
|
|
4467
4603
|
actionErrEl.textContent = "";
|
|
4468
4604
|
clearFieldErrors();
|
|
4469
4605
|
stopStart();
|
|
4470
|
-
sessionId = null; sessionLive = false; lastState = null; signInfo = null; signClickedOnce = false; busy = false;
|
|
4606
|
+
sessionId = null; sessionLive = false; lastState = null; signInfo = null; signClickedOnce = false; busy = false; reviseOpen = false;
|
|
4471
4607
|
stopPoll();
|
|
4472
4608
|
progressRow.hidden = true;
|
|
4473
|
-
progressRow.innerHTML = "";
|
|
4609
|
+
progressRow.innerHTML = ""; progressHtml = "";
|
|
4474
4610
|
refreshStartEnabled();
|
|
4475
4611
|
}
|
|
4476
4612
|
// back to a fresh empty card: every box, the inputs, the progress list, the ask box
|
|
4477
4613
|
function resetCard(){
|
|
4478
4614
|
if(mode === "resume"){ resumeCtx = null; setMode(modeBeforeResume === "resume" ? "new" : modeBeforeResume); }
|
|
4615
|
+
leaveEdit();
|
|
4479
4616
|
["jf-name", "jf-job", "jf-cap-money", "jf-dest-folder", "jf-inputs"].forEach(function(id){ byId(id).value = ""; });
|
|
4480
4617
|
askWaitEl.value = "1h";
|
|
4481
4618
|
refreshCapNote();
|
|
@@ -4549,7 +4686,7 @@
|
|
|
4549
4686
|
window.fwdloopResuming = null; // a refused start leaves the run stopped: Resume is offered again
|
|
4550
4687
|
refusedStartId = j.startId;
|
|
4551
4688
|
chatActionFailed(signed ? j.say + " The flow is signed; start it from \"Run a signed flow\"." : j.say);
|
|
4552
|
-
if(signed){ endSession(); loadFlows(true); } else { progressRow.hidden = true; progressRow.innerHTML = ""; refreshStartEnabled(); }
|
|
4689
|
+
if(signed){ leaveEdit(); endSession(); loadFlows(true); } else { progressRow.hidden = true; progressRow.innerHTML = ""; progressHtml = ""; refreshStartEnabled(); }
|
|
4553
4690
|
return;
|
|
4554
4691
|
}
|
|
4555
4692
|
if(j.ok === false && j.refused === "no-such-start"){
|
|
@@ -4560,20 +4697,34 @@
|
|
|
4560
4697
|
}).catch(function(){ /* transient — next tick tries again */ });
|
|
4561
4698
|
}
|
|
4562
4699
|
|
|
4563
|
-
|
|
4700
|
+
// 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.
|
|
4701
|
+
function doAnswer(){
|
|
4702
|
+
if(qBusy || !sessionId || !lastState || lastState.phase !== "questions-open") return;
|
|
4703
|
+
qBusy = true; qSend.disabled = true; qError.textContent = "";
|
|
4704
|
+
var id = sessionId;
|
|
4705
|
+
authorPost("/api/author/" + id + "/answer", {k: lastState.openK, answer: qAnswer.value}).then(function(r){
|
|
4706
|
+
qBusy = false; qSend.disabled = false;
|
|
4707
|
+
if(id !== sessionId) return;
|
|
4708
|
+
if(!(r.status >= 200 && r.status < 300 && r.body && r.body.ok === true)){ qError.textContent = refusalText(r); return; }
|
|
4709
|
+
qAnswer.value = "";
|
|
4710
|
+
poll();
|
|
4711
|
+
}).catch(function(){ qBusy = false; qSend.disabled = false; qError.textContent = NETWORK_SAY; });
|
|
4712
|
+
}
|
|
4713
|
+
function doDraft(startedOverFrom){
|
|
4564
4714
|
clearFieldErrors();
|
|
4565
4715
|
chatActionOk();
|
|
4566
4716
|
// disabled from the click until the reply; unlocked below only if the draft is refused
|
|
4567
4717
|
busy = true;
|
|
4568
4718
|
refreshStartEnabled();
|
|
4569
4719
|
var body = currentCard();
|
|
4720
|
+
if(startedOverFrom) body.startedOverFrom = startedOverFrom;
|
|
4570
4721
|
authorPost("/api/author/draft", body).then(function(r){
|
|
4571
4722
|
busy = false;
|
|
4572
4723
|
var o = chatPostOutcome(r);
|
|
4573
4724
|
if(!o.ok){ failFrom(r); refreshStartEnabled(); return; }
|
|
4574
4725
|
sessionId = r.body.draftId;
|
|
4575
4726
|
sessionLive = true;
|
|
4576
|
-
signInfo = null; signClickedOnce = false;
|
|
4727
|
+
signInfo = null; signClickedOnce = false; reviseOpen = false;
|
|
4577
4728
|
thread.innerHTML = ""; threadKey = "";
|
|
4578
4729
|
renderActions({draftId: sessionId, phase: "drafting", card: {capUsd: body.capUsd}});
|
|
4579
4730
|
startPoll();
|
|
@@ -4709,7 +4860,7 @@
|
|
|
4709
4860
|
if(!o.ok){
|
|
4710
4861
|
busy = false;
|
|
4711
4862
|
failFrom(r);
|
|
4712
|
-
if(r.body && r.body.signed === true){ endSession(); loadFlows(true); } else { refreshStartEnabled(); }
|
|
4863
|
+
if(r.body && r.body.signed === true){ leaveEdit(); endSession(); loadFlows(true); } else { refreshStartEnabled(); }
|
|
4713
4864
|
return;
|
|
4714
4865
|
}
|
|
4715
4866
|
chatActionOk();
|
|
@@ -4718,22 +4869,23 @@
|
|
|
4718
4869
|
beginStart(r.body.startId);
|
|
4719
4870
|
}).catch(function(){ busy = false; chatActionFailed(NETWORK_SAY); refreshStartEnabled(); });
|
|
4720
4871
|
}
|
|
4721
|
-
// amendment
|
|
4722
|
-
// A refused
|
|
4872
|
+
// 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.
|
|
4873
|
+
// A refused revise leaves every field as typed (unsent input is never wiped). The new plan replaces the shown one when it comes back.
|
|
4723
4874
|
function doRevise(){
|
|
4724
4875
|
if(!sessionId) return;
|
|
4725
4876
|
var id = sessionId;
|
|
4726
|
-
var
|
|
4877
|
+
var body = currentCard();
|
|
4878
|
+
clearFieldErrors();
|
|
4727
4879
|
chatActionOk();
|
|
4728
4880
|
busy = true;
|
|
4729
4881
|
refreshStartEnabled();
|
|
4730
|
-
authorPost("/api/author/" + id + "/revise",
|
|
4882
|
+
authorPost("/api/author/" + id + "/revise", body).then(function(r){
|
|
4731
4883
|
busy = false;
|
|
4732
4884
|
var o = chatPostOutcome(r);
|
|
4733
4885
|
if(!o.ok){ failFrom(r); refreshStartEnabled(); return; }
|
|
4734
|
-
|
|
4886
|
+
reviseOpen = false;
|
|
4735
4887
|
signInfo = null; signClickedOnce = false;
|
|
4736
|
-
|
|
4888
|
+
renderActions(Object.assign({}, lastState, {phase: "revising"}));
|
|
4737
4889
|
poll();
|
|
4738
4890
|
}).catch(function(){ busy = false; chatActionFailed(NETWORK_SAY); refreshStartEnabled(); });
|
|
4739
4891
|
}
|
|
@@ -4759,6 +4911,11 @@
|
|
|
4759
4911
|
setVal("jf-name", c.flowName); setVal("jf-job", c.job); setVal("jf-cap-money", c.capUsd);
|
|
4760
4912
|
refreshCapNote();
|
|
4761
4913
|
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");
|
|
4914
|
+
if(c.editOf && typeof c.editOf.flow === "string"){
|
|
4915
|
+
editOf = {flow: c.editOf.flow, flowHash: c.editOf.flowHash};
|
|
4916
|
+
editBannerEl.textContent = "Editing \u201c" + c.editOf.flow + "\u201d. Draft it, read the new plan, then sign: signing replaces this job. Clear leaves it exactly as it was.";
|
|
4917
|
+
editBannerEl.hidden = false;
|
|
4918
|
+
}
|
|
4762
4919
|
sessionId = d.draftId;
|
|
4763
4920
|
sessionLive = CLIENT_TERMINAL_PHASES.indexOf(d.phase) === -1;
|
|
4764
4921
|
renderThread(d);
|
|
@@ -4791,22 +4948,21 @@
|
|
|
4791
4948
|
if(refusedStartId){ var rid = refusedStartId; refusedStartId = null; authorPost("/api/author/start/" + rid + "/clear", {}).catch(function(){}); }
|
|
4792
4949
|
resetCard();
|
|
4793
4950
|
});
|
|
4794
|
-
//
|
|
4795
|
-
|
|
4951
|
+
// Revise (amendment 14 item 2): opens every card field, filled as last submitted; nothing is sent
|
|
4952
|
+
reviseBtn.addEventListener("click", function(){ if(reviseBtn.disabled) return; reviseOpen = true; refreshStartEnabled(); });
|
|
4953
|
+
// 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)
|
|
4954
|
+
startOverBtn.addEventListener("click", function(){ if(!startOverBtn.disabled) doDraft(sessionId); });
|
|
4955
|
+
qSend.addEventListener("click", doAnswer);
|
|
4956
|
+
qAnswer.addEventListener("keydown", function(e){ if(e.key === "Enter" && !e.shiftKey){ e.preventDefault(); doAnswer(); } });
|
|
4796
4957
|
mainBtn.addEventListener("click", function(){
|
|
4797
4958
|
if(mainBtn.disabled) return;
|
|
4798
|
-
if(mainAction === "draft") doDraft();
|
|
4959
|
+
if(mainAction === "draft") doDraft(mainStartOver ? sessionId : null);
|
|
4799
4960
|
else if(mainAction === "run") doRun();
|
|
4800
4961
|
else if(mainAction === "run-sign-prepare" || mainAction === "run-sign") doRunSign();
|
|
4801
4962
|
else if(mainAction === "resume-sign-prepare" || mainAction === "resume-sign") doResumeSign();
|
|
4802
4963
|
else if(mainAction === "revise") doRevise();
|
|
4803
4964
|
else if(mainAction === "sign-prepare" || mainAction === "sign") doSign();
|
|
4804
4965
|
});
|
|
4805
|
-
msgEl.addEventListener("input", function(){ fitBox(msgEl); renderMain(); });
|
|
4806
|
-
// Enter sends the note, Shift+Enter is a newline (bareloop's ask box)
|
|
4807
|
-
msgEl.addEventListener("keydown", function(e){
|
|
4808
|
-
if(e.key === "Enter" && !e.shiftKey && mainAction === "revise"){ e.preventDefault(); if(!mainBtn.disabled) doRevise(); }
|
|
4809
|
-
});
|
|
4810
4966
|
card.addEventListener("input", function(e){
|
|
4811
4967
|
var grp = e.target && e.target.closest ? e.target.closest(".field, .cap-field, .jf-inrow") : null;
|
|
4812
4968
|
if(grp) grp.querySelectorAll(".jf-err").forEach(function(x){ x.textContent = ""; });
|
|
@@ -4818,7 +4974,10 @@
|
|
|
4818
4974
|
refreshStartEnabled();
|
|
4819
4975
|
});
|
|
4820
4976
|
document.querySelectorAll('input[name="jf-mode"]').forEach(function(r){
|
|
4821
|
-
r.addEventListener("change", function(){
|
|
4977
|
+
r.addEventListener("change", function(){
|
|
4978
|
+
if(r.checked && editOf !== null && r.value !== "new" && !sessionLive){ leaveEdit(); ["jf-name", "jf-job", "jf-cap-money", "jf-dest-folder", "jf-inputs"].forEach(function(id){ byId(id).value = ""; }); }
|
|
4979
|
+
if(r.checked) setMode(r.value);
|
|
4980
|
+
});
|
|
4822
4981
|
});
|
|
4823
4982
|
runFlowSel.addEventListener("input", function(){ rwHl = 0; renderFlowSearch(); });
|
|
4824
4983
|
runFlowSel.addEventListener("keydown", function(e){
|