fwdloop 0.26.2 → 0.28.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.
Files changed (73) hide show
  1. package/bin/fwdloop +46 -7
  2. package/package.json +2 -2
  3. package/src/authoring.js +21 -1
  4. package/src/canrun.js +23 -0
  5. package/src/config.js +18 -0
  6. package/src/declaration.js +129 -3
  7. package/src/drafter.js +38 -10
  8. package/src/flow.js +2 -1
  9. package/src/launcher.js +4 -2
  10. package/src/learnstore.js +3 -2
  11. package/src/mcp-checks.js +50 -0
  12. package/src/mcp-pick.js +33 -0
  13. package/src/mcp-sources.js +84 -0
  14. package/src/mcp-use.js +54 -0
  15. package/src/natural.js +23 -0
  16. package/src/panel/author.js +17 -1
  17. package/src/panel/authorcard.js +35 -0
  18. package/src/panel/authorflows.js +15 -6
  19. package/src/panel/authorstart.js +10 -6
  20. package/src/panel/authortrigger.js +263 -82
  21. package/src/panel/data.js +127 -9
  22. package/src/panel/index.html +945 -94
  23. package/src/panel/jobgrid.js +127 -0
  24. package/src/panel/scheduler.js +48 -6
  25. package/src/panel/server.js +33 -8
  26. package/src/panel/settings.js +119 -4
  27. package/src/panel/tickets.js +118 -0
  28. package/src/primitives.js +34 -5
  29. package/src/runner.js +129 -15
  30. package/src/schedule.js +5 -0
  31. package/src/summary-words.js +27 -7
  32. package/src/ticket-draft.js +85 -0
  33. package/src/ticket-labels.js +75 -0
  34. package/src/ticket-mcp.js +89 -0
  35. package/src/ticket-next.js +33 -0
  36. package/src/ticket-shape.js +33 -0
  37. package/src/trigger-clock.js +4 -4
  38. package/src/trigger-files.js +4 -4
  39. package/src/trigger-line.js +2 -1
  40. package/src/trigger-tickets.js +238 -0
  41. package/types/authoring.d.ts +5 -1
  42. package/types/canrun.d.ts +7 -0
  43. package/types/config.d.ts +6 -0
  44. package/types/declaration.d.ts +8 -0
  45. package/types/drafter.d.ts +552 -21
  46. package/types/mcp-checks.d.ts +8 -0
  47. package/types/mcp-pick.d.ts +23 -0
  48. package/types/mcp-sources.d.ts +51 -0
  49. package/types/mcp-use.d.ts +12 -0
  50. package/types/natural.d.ts +2 -0
  51. package/types/panel/author.d.ts +44 -0
  52. package/types/panel/authorcard.d.ts +11 -0
  53. package/types/panel/authorflows.d.ts +11 -1
  54. package/types/panel/authorstart.d.ts +3 -1
  55. package/types/panel/authortrigger.d.ts +83 -7
  56. package/types/panel/data.d.ts +78 -5
  57. package/types/panel/jobgrid.d.ts +109 -0
  58. package/types/panel/scheduler.d.ts +7 -2
  59. package/types/panel/server.d.ts +13 -2
  60. package/types/panel/settings.d.ts +3 -2
  61. package/types/panel/tickets.d.ts +103 -0
  62. package/types/primitives.d.ts +15 -2
  63. package/types/runner.d.ts +133 -75
  64. package/types/summary-words.d.ts +24 -4
  65. package/types/ticket-draft.d.ts +104 -0
  66. package/types/ticket-labels.d.ts +42 -0
  67. package/types/ticket-mcp.d.ts +57 -0
  68. package/types/ticket-next.d.ts +23 -0
  69. package/types/ticket-shape.d.ts +30 -0
  70. package/types/trigger-clock.d.ts +4 -3
  71. package/types/trigger-files.d.ts +3 -1
  72. package/types/trigger-line.d.ts +7 -0
  73. package/types/trigger-tickets.d.ts +105 -0
@@ -31,6 +31,11 @@
31
31
  --grey-dot:#878eac; --grey-bg:#20242f;
32
32
  --cyan:#7dcfff; --cyan-bg:#182634;
33
33
  --magenta:#bb9af7;
34
+ --cap-w:#b7791f; --cap-w-bg:#3a2e17; --cap-w-ink:#f0c987;
35
+ --cap-s:#3d59a1; --cap-s-bg:#1f2a4d; --cap-s-ink:#a9c1f5;
36
+ --cap-j:#6b7396; --cap-j-bg:#2a2f45; --cap-j-ink:#c0caf5;
37
+ --cap-r:#2b8a7e; --cap-r-bg:#17332f; --cap-r-ink:#8fdccf;
38
+ --req:#c9a85f;
34
39
  --accent:#7aa2f7;
35
40
  --btn-bg:#1f2335; --btn-text:#c0caf5;
36
41
  --field-bg:var(--bg); --field-soft-bg:var(--bg); --field-border:var(--text-dim);
@@ -53,7 +58,7 @@
53
58
  always-scrolling wrapper makes the header genuinely sticky on both
54
59
  breakpoints, and also owns the horizontal scroll for the Path column
55
60
  on narrow (390px) screens instead of leaving it to .pane-body. */
56
- .audit-table-scroll{overflow:auto;max-height:min(60vh,520px);}
61
+ .audit-table-scroll{overflow:auto;max-height:min(60vh,520px);max-width:100%;}
57
62
  [data-testid="audit-table"] td.am, .audit-group table td.am{display:none;}
58
63
  /* z-index keeps rows from showing through the solid th background as
59
64
  they scroll under it. */
@@ -73,6 +78,10 @@
73
78
  --grey-dot:#626887; --grey-bg:#e2e2e8;
74
79
  --cyan:#007197; --cyan-bg:#d6ecf1;
75
80
  --magenta:#9854f1;
81
+ --cap-w:#b7791f; --cap-w-bg:#f6e7c8; --cap-w-ink:#7a4c0c;
82
+ --cap-s:#2a4fa8; --cap-s-bg:#cfdaf3; --cap-s-ink:#1d3a80;
83
+ --cap-j:#5b6680; --cap-j-bg:#c7cddb; --cap-j-ink:#333c52;
84
+ --cap-r:#2b8a7e; --cap-r-bg:#cdeee8; --cap-r-ink:#14524a; --req:#8a6d2a;
76
85
  --accent:#2668c2;
77
86
  --btn-bg:#e9e9ed; --btn-text:#3760bf;
78
87
  --field-bg:#ffffff; --field-soft-bg:#f7f7f9;
@@ -88,6 +97,10 @@
88
97
  --grey-dot:#626887; --grey-bg:#e2e2e8;
89
98
  --cyan:#007197; --cyan-bg:#d6ecf1;
90
99
  --magenta:#9854f1;
100
+ --cap-w:#b7791f; --cap-w-bg:#f6e7c8; --cap-w-ink:#7a4c0c;
101
+ --cap-s:#2a4fa8; --cap-s-bg:#cfdaf3; --cap-s-ink:#1d3a80;
102
+ --cap-j:#5b6680; --cap-j-bg:#c7cddb; --cap-j-ink:#333c52;
103
+ --cap-r:#2b8a7e; --cap-r-bg:#cdeee8; --cap-r-ink:#14524a; --req:#8a6d2a;
91
104
  --accent:#2668c2;
92
105
  --btn-bg:#e9e9ed; --btn-text:#3760bf;
93
106
  --field-bg:#ffffff; --field-soft-bg:#f7f7f9;
@@ -128,19 +141,19 @@
128
141
  .topbar .tagline::before{content:"· ";color:var(--text-faint);}
129
142
  @media (max-width: 600px){ .topbar .tagline{display:none;} }
130
143
  .topbar-right{display:flex;align-items:center;gap:10px;flex-wrap:wrap;}
144
+ #online-dot{font-size:12px;white-space:nowrap;flex:none;}
145
+ #online-dot.on{color:var(--green);} #online-dot.off{color:var(--red);}
131
146
 
132
147
  [hidden]{display:none !important;}
133
148
  .main{display:flex;flex:1;min-height:0;}
134
149
  .left-pane{width:630px;flex:none;border-right:1px solid var(--border-strong);display:flex;flex-direction:column;background:var(--panel);}
135
150
  .right-pane{flex:1;min-width:0;display:flex;flex-direction:column;}
136
151
 
137
- .tabrow{display:flex;border-bottom:1px solid var(--border-strong);background:var(--panel2);counter-reset:tabnum;}
152
+ .tabrow{display:flex;border-bottom:1px solid var(--border-strong);background:var(--panel2);}
138
153
  .tabrow button{
139
154
  flex:1;padding:10px 6px;min-height:44px;background:transparent;border:none;
140
155
  border-right:1px dotted var(--border-strong);font-size:13px;color:var(--text-dim);
141
- counter-increment:tabnum;
142
156
  }
143
- .tabrow button::before{content:"[" counter(tabnum) "] ";color:var(--text-faint);font-weight:700;}
144
157
  .tabrow button:last-child{border-right:none;}
145
158
 
146
159
  .pane-body{padding:12px;overflow:auto;flex:1;min-height:0;}
@@ -167,6 +180,8 @@
167
180
  .dot.stuck::before{content:"[II]";color:var(--amber);}
168
181
  /* M4e amendment 4: stopped — by you, or at the money cap; Resume goes on. Grey like the other quiet end, never the red [✗]. */
169
182
  .dot.stopped::before{content:"[■]";color:var(--grey-dot);}
183
+ /* M12 p3: a skipped run (a ticket the signed labels do not match) wears [–], the sign the ticket list draws, grey like the other quiet end. */
184
+ .dot.skipped::before{content:"[–]";color:var(--grey-dot);}
170
185
  /* the Run tab's top action row (Stop, Resume) */
171
186
  .run-actions{display:flex;flex-wrap:wrap;gap:8px;align-items:center;margin-bottom:8px;}
172
187
  .run-actions .answer-msg{margin-top:0;flex:1 1 100%;}
@@ -185,6 +200,17 @@
185
200
  treatment; section 3 (answered/expired) is dimmed. Tokens only. */
186
201
  .rl-sect,.inbox-h{font-size:12px;color:var(--text-dim);font-weight:700;margin:12px 0 6px;}
187
202
  .rl-sect:first-child,.inbox-h:first-child{margin-top:0;}
203
+ /* Runs captions (hamr 2026-11-01, variant A, no caps): a full-width bar per section, colour tokens above. */
204
+ .rl-cap{display:flex;align-items:center;gap:8px;font-size:15px;margin:18px 0 8px;padding:7px 12px;border-left:5px solid var(--cap-c);background:var(--cap-bg);color:var(--cap-ink);}
205
+ .rl-cap.rl-cap-w{--cap-c:var(--cap-w);--cap-bg:var(--cap-w-bg);--cap-ink:var(--cap-w-ink);}
206
+ .rl-cap.rl-cap-s{--cap-c:var(--cap-s);--cap-bg:var(--cap-s-bg);--cap-ink:var(--cap-s-ink);}
207
+ .rl-cap.rl-cap-j{--cap-c:var(--cap-j);--cap-bg:var(--cap-j-bg);--cap-ink:var(--cap-j-ink);}
208
+ .rl-cap.rl-cap-r{--cap-c:var(--cap-r);--cap-bg:var(--cap-r-bg);--cap-ink:var(--cap-r-ink);}
209
+ .rl-cap .rl-n{font-size:12px;line-height:1.4;padding:1px 8px;border-radius:10px;background:var(--cap-c);color:#fff;}
210
+ .rl-cap .rl-p{font-size:0;}
211
+ .rl-cap .rl-note{font-size:11px;font-weight:400;}
212
+ .rl-jobcard{position:relative;margin:14px 0 0;padding:10px;}
213
+ .rl-jobcard::before{content:"";position:absolute;left:-1px;right:-1px;top:-9px;height:2px;background:var(--border-strong);}
188
214
  .inbox-row.s1{border-left:4px solid var(--amber);background:var(--amber-bg);}
189
215
  .inbox-row.s3{opacity:.6;}
190
216
  .inbox-row .wf-line1{min-width:0;}
@@ -300,11 +326,9 @@
300
326
  are already both on screen there, nothing to jump back to). */
301
327
  .back-to-list-link{display:none;font-size:12px;color:var(--accent);text-decoration:underline;background:none;border:none;padding:0;cursor:pointer;}
302
328
  @media (max-width: 899px){ .back-to-list-link{display:inline-block;} }
303
- .rp-tabrow{display:flex;border-bottom:1px solid var(--border-strong);background:var(--panel2);counter-reset:rtabnum;}
304
- .rp-tabrow button{padding:10px 14px;min-height:44px;background:transparent;border:none;border-right:1px dotted var(--border-strong);font-size:13px;color:var(--text-dim);counter-increment:rtabnum;}
305
- .rp-tabrow button::before{content:"[" counter(rtabnum) "] ";color:var(--text-faint);font-weight:700;}
329
+ .rp-tabrow{display:flex;border-bottom:1px solid var(--border-strong);background:var(--panel2);}
330
+ .rp-tabrow button{padding:10px 14px;min-height:44px;background:transparent;border:none;border-right:1px dotted var(--border-strong);font-size:13px;color:var(--text-dim);}
306
331
  .tabrow button[aria-selected="true"],.rp-tabrow button[aria-selected="true"]{background:var(--panel);color:var(--accent);font-weight:700;box-shadow:inset 0 -2px 0 var(--accent);}
307
- .tabrow button[aria-selected="true"]::before,.rp-tabrow button[aria-selected="true"]::before{color:var(--accent);}
308
332
 
309
333
  .counters{display:block;padding:9px 12px;border:none;border-bottom:2px solid var(--border-strong);background:var(--panel2);color:var(--text-dim);margin:-12px -12px 14px;font-size:12px;font-weight:700;white-space:normal;overflow-wrap:break-word;}
310
334
  .counters b,.counters span{color:var(--accent);}
@@ -314,8 +338,9 @@
314
338
  .ended-block.magenta{border-color:var(--magenta);}
315
339
  .ended-block.red{border-color:var(--red);}
316
340
  .ended-text.is-red,.ended-label.is-red{color:var(--red);}
341
+ .ended-text.is-grey{color:var(--grey-dot);}
317
342
  .ended-block.green{border-color:var(--green);}
318
- .ended-block.grey,.ended-block.stopped{border-color:var(--grey-dot);}
343
+ .ended-block.grey,.ended-block.stopped,.ended-block.skipped{border-color:var(--grey-dot);}
319
344
  .ended-block.amber,.ended-block.expired,.ended-block.stuck{border-color:var(--amber);}
320
345
  .ended-row{display:flex;gap:10px;align-items:baseline;flex-wrap:wrap;margin-bottom:6px;}
321
346
  .ended-row:last-child{margin-bottom:0;}
@@ -332,7 +357,7 @@
332
357
  .summary-box{position:relative;border:1px solid var(--border-strong);padding:16px 12px 12px;margin-top:16px;background:var(--panel2);font-size:12px;}
333
358
  .summary-box.red{border-color:var(--red);}
334
359
  .summary-box.green{border-color:var(--green);}
335
- .summary-box.grey,.summary-box.stopped{border-color:var(--grey-dot);}
360
+ .summary-box.grey,.summary-box.stopped,.summary-box.skipped{border-color:var(--grey-dot);}
336
361
  .summary-box.amber,.summary-box.expired,.summary-box.stuck{border-color:var(--amber);}
337
362
  .summary-box.magenta{border-color:var(--magenta);}
338
363
  .summary-box::before{content:"┤ SUMMARY ├";position:absolute;top:-10px;left:10px;background:var(--panel2);padding:0 6px;font-size:11px;color:var(--text-faint);letter-spacing:0.08em;}
@@ -474,15 +499,67 @@
474
499
  .audit-fold-who.model{color:var(--cyan);} .audit-fold-who.human{color:var(--magenta,#9854f1);}
475
500
  .audit-tally{color:var(--text-dim);margin:2px 0 4px;}
476
501
  .audit-try{margin:4px 0 2px;overflow-wrap:anywhere;}
477
- .audit-checks{margin:2px 0 6px 14px;}
478
- .audit-chk{overflow-wrap:anywhere;}
479
- .audit-chk > span{margin-right:6px;}
480
- .audit-chk .src,.audit-judged{color:var(--text-faint);}
502
+ .audit-judged{color:var(--text-faint);}
481
503
  .audit-fold-label{color:var(--text-faint);text-transform:uppercase;font-size:10px;letter-spacing:.05em;margin-top:8px;}
482
504
  .audit-fold-body table.rounds-table{width:100%;border-collapse:collapse;margin-top:4px;}
483
505
  .audit-fold-body table.rounds-table th{position:sticky;top:0;z-index:1;}
484
506
  .audit-fold-body table.rounds-table tr.trysep td{border-top:1px solid var(--border-strong);}
485
507
  .rounds-pager{color:var(--text-faint);font-size:11px;margin-top:4px;display:flex;gap:10px;align-items:center;flex-wrap:wrap;}
508
+ /* the Audit check grid (PRD: bareloop variant F), its errors list and the rounds folded per try.
509
+ borrowed-from: bareloop src/panel/index.html@c79d396 (the .grid/.cell/.fx-*/.rounds-fold rules); the pass/fail glyph colours are fwdloop's own `.mark` */
510
+ .glyph-q{color:var(--magenta);} .glyph-nr{color:var(--text-faint);}
511
+ .rounds-fold{margin:4px 0 6px 12px;font-size:12px;}
512
+ .rounds-fold>summary{cursor:pointer;color:var(--text-dim);min-height:28px;overflow-wrap:anywhere;}
513
+ .rounds-fold .rf-body{margin-top:4px;padding-left:8px;border-left:2px solid var(--border-strong);}
514
+ .grid-wrap{overflow:auto;max-width:100%;}
515
+ table.grid{width:100%;min-width:0;}
516
+ table.grid th.q,table.grid td.q{min-width:170px;max-width:340px;white-space:normal;overflow-wrap:anywhere;font-size:12px;}
517
+ table.grid th.t,table.grid td.c{text-align:center;width:64px;min-width:56px;white-space:nowrap;}
518
+ table.grid th.t .hint{display:block;text-transform:none;letter-spacing:0;font-weight:400;margin:0;}
519
+ table.grid td.c .tg-none{margin:0;}
520
+ table.grid td.c{padding:2px;}
521
+ .cell{border:1px solid transparent;background:none;min-width:44px;min-height:32px;color:var(--text-faint);font-size:14px;font-weight:700;}
522
+ .cell.fail{color:var(--red);border-color:var(--border-strong);background:var(--red-bg);}
523
+ .cell.pass{color:var(--green);cursor:default;}
524
+ .cell.notrun{color:var(--text-faint);cursor:default;}
525
+ .cell.unk{color:var(--magenta);cursor:default;}
526
+ .fold-list{margin-top:10px;}
527
+ .fgrid .cell.fail[aria-expanded="true"]{outline:2px solid var(--red);outline-offset:1px;}
528
+ .fx-errors{margin:8px 0 4px;min-width:0;}
529
+ .fx-label{font-size:11px;color:var(--text-faint);text-transform:uppercase;letter-spacing:0.06em;margin-bottom:2px;}
530
+ .fx-row{min-width:0;}
531
+ .fx-rowhead{display:flex;align-items:baseline;gap:8px;width:100%;min-width:0;min-height:32px;padding:3px 4px;border:0;background:none;color:var(--text);font:inherit;font-size:12px;text-align:left;}
532
+ button.fx-rowhead{cursor:pointer;}
533
+ button.fx-rowhead:hover{background:var(--panel2);}
534
+ button.fx-rowhead:focus-visible,.fx-more:focus-visible,.cell.fail:focus-visible{outline:2px solid var(--red);outline-offset:1px;}
535
+ .fx-caret{flex:none;width:12px;color:var(--text-faint);}
536
+ .fx-try{flex:none;font-weight:700;}
537
+ .fx-chk{flex:none;white-space:nowrap;}
538
+ .fx-first{flex:1 1 0;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--text-dim);}
539
+ .fx-faint,.fx-count{color:var(--text-faint);}
540
+ .fx-count{flex:none;white-space:nowrap;}
541
+ .fx-row.open>.fx-rowhead{background:var(--red-bg);}
542
+ .fx-body{margin:0 0 6px 20px;border-left:2px solid var(--red);padding:4px 10px;background:var(--red-bg);min-width:0;}
543
+ .fx-sub{font-size:12px;color:var(--text);font-weight:700;margin:6px 0 2px;overflow-wrap:anywhere;}
544
+ .fx-lines{font-size:12px;color:var(--text-dim);}
545
+ .fx-lines div{margin:1px 0;overflow-wrap:anywhere;}
546
+ .fx-judged{overflow-wrap:anywhere;}
547
+ .fx-more{margin-top:4px;min-height:28px;padding:2px 8px;border:1px solid var(--border-strong);background:var(--panel2);color:var(--text);font-size:12px;}
548
+ /* M4d am36: the hints row and its text, the folded every-step row (mock: fwd-audit-grid-mock.html, variant A) */
549
+ .btn.hints[aria-expanded="true"]{outline:2px solid var(--accent);outline-offset:1px;}
550
+ .btn.hints:focus-visible{outline:2px solid var(--accent);outline-offset:1px;}
551
+ .cell.none{color:var(--text-faint);cursor:default;font-weight:400;}
552
+ tr.hint-row td{color:var(--text-faint);}
553
+ .fx-row.hintrow.open>.fx-rowhead{background:var(--panel2);}
554
+ .fx-row.hintrow .fx-body{border-left-color:var(--accent);background:var(--panel2);}
555
+ .fx-row.hintrow .fx-try{flex:1 1 auto;min-width:0;overflow-wrap:anywhere;}
556
+ .fx-lines div.ind{margin-left:16px;}
557
+ button.q-fold{border:0;background:none;color:var(--text);font:inherit;font-size:12px;text-align:left;padding:0;min-height:32px;width:100%;overflow-wrap:anywhere;cursor:pointer;}
558
+ button.q-fold::before{content:"\25B8 ";color:var(--text-faint);white-space:pre;}
559
+ button.q-fold[aria-expanded="true"]::before{content:"\25BE ";}
560
+ tr.step-sub td{background:var(--panel2);font-size:12px;color:var(--text-dim);padding:4px 8px;}
561
+ .sub-line{display:flex;gap:8px;align-items:baseline;flex-wrap:wrap;}
562
+ .sub-line .marks{margin-left:auto;white-space:nowrap;}
486
563
  .step-card .step-head .who{font-weight:700;font-size:11px;}
487
564
  .step-card .step-head .who.model{color:var(--cyan);} .step-card .step-head .who.human{color:var(--magenta,#9854f1);}
488
565
  /* hamr's 2026-09-27 review: the group header's own state word (g.state,
@@ -516,6 +593,32 @@
516
593
  #result-body details>summary{cursor:pointer;color:var(--text-dim);min-height:28px;}
517
594
  .rs-warn{color:var(--amber);overflow-wrap:anywhere;}
518
595
  /* M10 am5 item 2: the Your-call card. borrowed-from: bareloop src/panel/index.html@2959217 :401-403 :407 */
596
+ /* M12 piece 3: the ticket list in the Result tab (mockup docs/product/m12-ticket-results-mock.html, variant E). Its boxes are the panel's own: .audit-group, .filterbar, .chips, .btn.small. */
597
+ /* M13 piece 6: the job's Result grid (mock docs/product/m13-setup-mock.html Part 3). The table, cells, q-fold and step-sub are the Audit grid's own; these are the bucket fold rows, the stats line and the run column. */
598
+ #result-body .tg-stats{font-size:13px;margin:0 0 8px;overflow-wrap:anywhere;}
599
+ table.grid.tg td.r,table.grid.tg th.r{position:sticky;left:0;background:var(--panel2);z-index:1;min-width:84px;white-space:nowrap;}
600
+ table.grid.tg td.c{min-width:84px;}
601
+ .tg-rowname{display:flex;align-items:center;max-width:min(240px,60vw);}
602
+ table.grid.tg button.tg-name{flex:0 1 auto;min-width:0;display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-align:left;border:0;background:none;padding:0;min-height:32px;font:inherit;font-size:12px;font-weight:700;color:var(--accent);cursor:pointer;}
603
+ table.grid.tg button.tg-name:hover{text-decoration:underline;}
604
+ table.grid.tg button.tg-name:focus-visible,table.grid.tg button.tg-arrow:focus-visible{outline:2px solid var(--accent);outline-offset:2px;}
605
+ table.grid.tg button.tg-arrow{flex:0 0 auto;width:auto;color:var(--accent);font-weight:700;}
606
+ .tg-unsure{flex:0 0 auto;margin-left:6px;}
607
+ .tg-val{font-size:11px;color:var(--text-faint);margin-left:4px;}
608
+ tr.tg-grp td{background:var(--panel);border-bottom:1px solid var(--border-strong);padding:0 8px;}
609
+ .tg-fold{display:block;width:100%;text-align:left;background:none;border:0;color:var(--text);font:inherit;font-size:13px;font-weight:700;min-height:34px;cursor:pointer;}
610
+ .tg-fold:hover{color:var(--accent);}
611
+ .tg-fold:focus-visible{outline:2px solid var(--accent);outline-offset:2px;}
612
+ .tg-foldin{position:sticky;left:8px;}
613
+ .tg-skipwhy{display:flex;gap:8px;align-items:center;flex-wrap:wrap;}
614
+ table.grid.tg tr.step-sub td{white-space:normal;overflow-wrap:anywhere;}
615
+ table.grid.tg tr.step-sub td>*{position:sticky;left:8px;width:min(560px,calc(100vw - 80px));max-width:100%;box-sizing:border-box;}
616
+ .tk-rl:focus-visible{outline:2px solid var(--accent);outline-offset:2px;}
617
+ .tk-rl{color:var(--accent);text-decoration:underline;cursor:pointer;background:none;border:0;padding:0;font:inherit;}
618
+ .tk-anyway{margin-top:6px;}
619
+ .tk-anyway button{display:block;width:100%;box-sizing:border-box;}
620
+ .tk-anyway textarea{width:100%;min-height:52px;margin:4px 0;background:var(--bg);color:var(--text);border:1px solid var(--text-dim);font:inherit;font-size:16px;padding:6px;box-sizing:border-box;}
621
+ .tk-msg{font-size:12px;overflow-wrap:anywhere;}
519
622
  #result-door-card{border-color:var(--amber);}
520
623
  #result-door-card .st-word{color:var(--amber);}
521
624
  #result-door-card textarea{width:100%;min-height:60px;margin:6px 0;background:var(--bg);color:var(--text);border:1px solid var(--text-dim);font:inherit;padding:6px;box-sizing:border-box;}
@@ -576,6 +679,9 @@
576
679
  @media (max-width:400px){.job-card .radio-row{padding-right:76px;}}
577
680
  .cap-row{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:6px;margin-bottom:6px;}
578
681
  .cap-field label{display:block;font-size:11px;font-weight:700;color:var(--text-dim);margin-bottom:1px;}
682
+ /* hamr 2026-11-01 (variant A): the Chat card's field captions are normal case, 14px bold, ink, with the Runs captions' blue left mark; `required` is small and grey */
683
+ #chat-job-card .field > label:not(.jf-thinking),#chat-job-card .cap-field > label,#chat-job-card .jf-waitrow > label{font-size:14px;font-weight:700;color:var(--cap-s-ink);text-transform:none;letter-spacing:0;margin:6px 0 6px;padding-left:8px;border-left:4px solid var(--cap-s);}
684
+ #chat-job-card .req{font-size:11px;font-weight:400;color:var(--req);margin-left:8px;}
579
685
  .cap-field input{width:100%;padding:5px 6px;box-sizing:border-box;}
580
686
  .btn.primary{background:var(--primary-bg);color:var(--primary-text);border-color:var(--primary-border);font-weight:700;}
581
687
  .btn.primary::before,.btn.primary::after{color:var(--primary-text);opacity:0.6;}
@@ -656,6 +762,7 @@
656
762
  #details-schedule{overflow-wrap:anywhere;} /* M10: a page input's full address in the Schedule field wraps, never spills */
657
763
  .jf-inrow .jf-path{text-overflow:ellipsis;} /* M10: a web page's address is cut with an ellipsis (the whole is the title) */
658
764
  .jf-inrow .jf-err{grid-column:1 / -1;}
765
+ .link{color:var(--text-faint);text-decoration:underline;font-size:11px;cursor:pointer;} /* M13 p4: from the setup mock */
659
766
  /* M4e amendment 4/5: what a Run or a Resume cannot change shows dimmed (the signature fixes it); only the open boxes are bright */
660
767
  .field.dimmed{opacity:.6;}
661
768
  /* borrowed-from: bareloop src/panel/index.html@b5e37b8 — the Reuse workflow picker (search box + list, then the picked box) */
@@ -760,6 +867,13 @@
760
867
  .audit-group table.rounds-table tbody{display:table-row-group;}
761
868
  .audit-group table.rounds-table tr{display:table-row;padding:0;overflow:visible;}
762
869
  .audit-group table.rounds-table td{display:table-cell;padding:4px 6px;white-space:normal;overflow-wrap:anywhere;border-right:1px dotted var(--border);}
870
+ /* the check grid keeps its real table layout on a phone and scrolls inside its own box (.grid-wrap), never the page */
871
+ .audit-group table.grid{display:table;width:100%;max-width:none;}
872
+ .audit-group table.grid thead{position:static;width:auto;height:auto;overflow:visible;clip:auto;white-space:normal;}
873
+ .audit-group table.grid tbody{display:table-row-group;}
874
+ .audit-group table.grid tr{display:table-row;padding:0;overflow:visible;}
875
+ .audit-group table.grid td{display:table-cell;white-space:normal;border-right:1px dotted var(--border);}
876
+ .audit-group table.grid td.c{white-space:nowrap;padding:2px;}
763
877
  /* M8 item 6: a hint's table fits the box and wraps (as bareloop's does at 320), it does not scroll sideways */
764
878
  .audit-part table.learn-hint{display:table;width:100%;min-width:0;max-width:100%;}
765
879
  .audit-part table.learn-hint tbody{display:table-row-group;}
@@ -824,7 +938,10 @@
824
938
  .pv-knote > .hint:empty{display:none;}
825
939
  .pv-key[data-open="0"] .pv-models{display:none;}
826
940
  .pv-mrow{border-top:1px dotted var(--border-strong);min-height:32px;}
827
- .pv-mrow:hover,.pv-mrow:focus-within{background:var(--panel2);}
941
+ /* borrowed-from: bareloop src/panel/index.html@357a482 (hamr: same exact change) — a clicked model row turns blue; tabindex -1 on the row makes a click on its name focusable */
942
+ .pv-mrow:hover{background:var(--panel2);}
943
+ .pv-mrow:focus-within,.pv-mrow:focus-within:hover{background:var(--rl-accent-bg-strong);box-shadow:inset 0 0 0 2px var(--accent);}
944
+ .pv-mrow:focus{outline:none;}
828
945
  .pv-um{grid-column:1;display:flex;align-items:center;gap:0;min-width:0;}
829
946
  .pv-uh,.pv-m-use{flex:0 0 44px;width:44px;display:flex;align-items:center;justify-content:center;}
830
947
  .pv-m-use{min-height:32px;}
@@ -871,6 +988,47 @@
871
988
  .pv-knote,.pv-more{padding-left:8px;}
872
989
  .pv-m-msg{padding-left:8px;}
873
990
  }
991
+ /* M13 piece 3: Settings > MCP, from docs/product/m13-settings-mcp-mock.html; reuses .pv-key/.pv-krow/.pv-mrow with other columns */
992
+ .mc-sect{font-size:12px;color:var(--text-dim);font-weight:700;margin:16px 0 6px;text-transform:uppercase;letter-spacing:.06em;}
993
+ .mc-sect:first-child{margin-top:0;}
994
+ .mc-row{display:flex;align-items:center;flex-wrap:wrap;gap:4px 8px;padding:6px 10px;border-top:1px solid var(--border-strong);min-height:40px;overflow-wrap:anywhere;}
995
+ .mc-row:first-child{border-top:none;}
996
+ .mc-row.faint{color:var(--text-faint);}
997
+ .mc-row .mc-grow{flex:1 1 220px;min-width:0;}
998
+ .mc-row .btn{margin-left:auto;}
999
+ .mc-add{padding:6px 10px;}
1000
+ .pv-head.mc-k,.pv-krow.mc-k{--pv-cols:minmax(0,1.6fr) minmax(0,1.5fr) minmax(0,.8fr) 150px;}
1001
+ .mc-grp{border-top:1px solid var(--border-strong);}
1002
+ .mc-grp:first-of-type{border-top:none;}
1003
+ .mc-prow{display:flex;align-items:center;flex-wrap:wrap;gap:4px 8px;padding:4px 8px;min-height:40px;background:var(--panel2);overflow-wrap:anywhere;}
1004
+ .mc-prow .mc-grow{flex:1 1 100px;min-width:0;}
1005
+ .mc-prow .btn{margin-left:auto;}
1006
+ .mc-prow.faint{color:var(--text-faint);}
1007
+ .mc-grp[data-open="0"] .mc-kids{display:none;}
1008
+ .mc-grp .pv-key:first-child{border-top:1px solid var(--border-strong);}
1009
+ .mc-k .pv-name{padding-left:26px;}
1010
+ .mc-grp .pv-more{padding-left:60px;}
1011
+ .mc-grp .mc-use{padding-left:60px;}
1012
+ .mc-use{padding:0 8px 6px 34px;margin:0;}
1013
+ .mc-use .bad{color:var(--red);}
1014
+ /* M13 piece 3: the tool rows use the SAME columns as the MCP row above them (the mock gave them their own, so HINT and USED sat under no header) */
1015
+ .pv-mrow.mc-t,.pv-mhead.mc-t{--pv-cols:minmax(0,1.6fr) minmax(0,1.5fr) minmax(0,.8fr) 150px;}
1016
+ .pv-mrow.mc-t{display:grid;padding:0 8px;}
1017
+ .mc-t .pv-m-name{padding-left:52px;}
1018
+ .mc-t .n{text-align:left;font-variant-numeric:tabular-nums;}
1019
+ .pv-key.faint{color:var(--text-faint);}
1020
+ @media (max-width:1279px){
1021
+ .pv-mhead.mc-t{display:grid;}
1022
+ .pv-mrow.mc-t{display:grid;padding:0 8px;}
1023
+ .mc-use{padding-left:8px;}
1024
+ .mc-kids{margin-left:14px;border-left:2px solid var(--border-strong);}
1025
+ .mc-k .pv-name{padding-left:0;}
1026
+ .mc-grp .pv-more,.mc-grp .mc-use{padding-left:8px;}
1027
+ .pv-mrow.mc-t,.pv-mhead.mc-t{--pv-cols:minmax(0,2fr) minmax(0,1fr) minmax(0,.6fr);}
1028
+ .mc-t .n{text-align:right;}
1029
+ .mc-t .pv-m-name{padding-left:0;}
1030
+ .pv-refcell:empty{display:none;}
1031
+ }
874
1032
  </style>
875
1033
  </head>
876
1034
  <body>
@@ -890,6 +1048,7 @@
890
1048
  </div>
891
1049
  <div class="topbar-right">
892
1050
  <span class="hint" id="host-line"></span>
1051
+ <span id="online-dot" class="on" data-testid="online-dot" role="status">&#9679; online</span>
893
1052
  <button class="btn small" id="settings-open" type="button" data-testid="settings-open">&#9881; Settings</button>
894
1053
  <button class="theme-toggle" id="theme-toggle" type="button" aria-label="Toggle light/dark theme">&#9789;</button>
895
1054
  </div>
@@ -903,6 +1062,7 @@
903
1062
  </div>
904
1063
  <div class="tabrow" role="tablist" aria-label="Settings views">
905
1064
  <button role="tab" id="stab-providers" aria-controls="spanel-providers" aria-selected="true" data-testid="settings-tab-providers">Providers</button>
1065
+ <button role="tab" id="stab-mcp" aria-controls="spanel-mcp" aria-selected="false" data-testid="settings-tab-mcp">MCP</button>
906
1066
  <button role="tab" id="stab-money" aria-controls="spanel-money" aria-selected="false" data-testid="settings-tab-money">Money &amp; limits</button>
907
1067
  </div>
908
1068
  <div class="pane-body">
@@ -926,6 +1086,20 @@
926
1086
  </div>
927
1087
  <div class="hint" id="pv-note" data-testid="pv-note" style="margin-top:6px;">⟳ refresh models (free) · old max_tokens: tick if the server wants the old field name</div>
928
1088
  </section>
1089
+ <section id="spanel-mcp" class="tabpanel" role="tabpanel" aria-labelledby="stab-mcp" hidden>
1090
+ <div class="mc-sect">Path and MCP</div>
1091
+ <div class="table-wrap" data-testid="mcp-table-wrap">
1092
+ <div id="mcp-paths" data-testid="mcp-paths"></div>
1093
+ <div class="pv-more" style="padding-left:10px;border-top:1px solid var(--border-strong)">
1094
+ <button class="btn small" type="button" id="mcp-add-open" data-testid="mcp-add-open">+ add a path</button>
1095
+ <div class="pv-typed" id="mcp-add-box" hidden></div>
1096
+ </div>
1097
+ </div>
1098
+ <div class="hint" id="mcp-problem" data-testid="mcp-problem"></div>
1099
+ <div class="hint" style="margin-top:6px;">Read only. fwdloop never edits these files and never shows keys. A project folder's .mcp.json is never read.</div>
1100
+ <div class="hint">check tools starts the server once, only when pressed.</div>
1101
+ <div class="hint">&mdash; = no hint; shown, not blocked. Hints are info only.</div>
1102
+ </section>
929
1103
  <section id="spanel-money" class="tabpanel" role="tabpanel" aria-labelledby="stab-money" hidden>
930
1104
  <div class="money-strip" data-testid="money-strip">
931
1105
  <div class="money-item">
@@ -991,12 +1165,12 @@
991
1165
  <div class="jf-err" id="jf-err-model" data-testid="jf-err-model"></div>
992
1166
  </div>
993
1167
  <div class="field">
994
- <label for="jf-name">Flow name</label>
1168
+ <label for="jf-name">Flow name <span class="req" data-testid="jf-req-name">required</span></label>
995
1169
  <input id="jf-name" type="text" placeholder="lowercase letters, digits, - or _" autocomplete="off" spellcheck="false" data-testid="jf-name">
996
1170
  <div class="jf-err" id="jf-err-flowName" data-testid="jf-err-flowName"></div>
997
1171
  </div>
998
1172
  <div class="field">
999
- <label for="jf-job">The job</label>
1173
+ <label for="jf-job">The job <span class="req" data-testid="jf-req-job">required</span></label>
1000
1174
  <div class="jf-gutbox">
1001
1175
  <div class="jf-gut" id="jf-job-gut" data-testid="jf-job-gut" aria-hidden="true"><div class="jf-gut-in"></div></div>
1002
1176
  <textarea class="jf-wrap" id="jf-job" rows="6" data-testid="jf-job" autocomplete="off" spellcheck="false" placeholder="Read my resume&#10;~keep it under 600 words&#10;Ask: check it with me&#10;Write it out"></textarea>
@@ -1005,14 +1179,43 @@
1005
1179
  <div class="jf-err" id="jf-err-job" data-testid="jf-err-job"></div>
1006
1180
  </div>
1007
1181
  <div class="field">
1008
- <label for="jf-inputs">Inputs</label>
1182
+ <label for="jf-inputs">Inputs <span class="req" id="jf-req-inputs" data-testid="jf-req-inputs">required</span></label>
1009
1183
  <div class="jf-gutbox">
1010
1184
  <div class="jf-gut" id="jf-inputs-gut" data-testid="jf-inputs-gut" aria-hidden="true"><div class="jf-gut-in"></div></div>
1011
1185
  <textarea class="jf-wrap" id="jf-inputs" rows="3" data-testid="jf-inputs" autocomplete="off" spellcheck="false" placeholder="resume: /full/path/to/resume.md"></textarea>
1012
1186
  </div>
1013
- <div class="hint">One line per file: a name, a colon, its full path starting with /, or a web address (http:// or https://). The page never reads the file.</div>
1187
+ <div class="hint" id="jf-inputs-hint" data-testid="jf-inputs-hint">One line per file: a name, a colon, its full path starting with /, or a web address (http:// or https://). The page never reads the file.</div>
1014
1188
  <div class="jf-err" id="jf-err-inputs" data-testid="jf-err-inputs"></div>
1015
1189
  </div>
1190
+ <div class="field" id="jf-flowtype-field" data-testid="jf-flowtype-field">
1191
+ <label for="jf-flowtype">Flow type</label>
1192
+ <select id="jf-flowtype" data-testid="jf-flowtype" aria-label="Flow type">
1193
+ <option value="plain">plain</option>
1194
+ <option value="mcp">MCP</option>
1195
+ <option value="tickets">Tickets MCP</option>
1196
+ </select>
1197
+ <div class="jf-err" id="jf-err-flowType" data-testid="jf-err-flowType"></div>
1198
+ </div>
1199
+ <div class="field" id="jf-mcp-field" data-testid="jf-mcp-field" hidden>
1200
+ <label for="jf-mcp">MCP</label>
1201
+ <select id="jf-mcp" data-testid="jf-mcp" aria-label="MCP"></select>
1202
+ <div class="hint"><a class="link" id="jf-mcp-manage" data-testid="jf-mcp-manage" href="#">manage in Settings &gt; MCP</a></div>
1203
+ <div class="jf-err" id="jf-err-mcp" data-testid="jf-err-mcp"></div>
1204
+ </div>
1205
+ <div class="field" id="jf-sched-field" data-testid="jf-sched-field">
1206
+ <label for="jf-sched">Schedule</label>
1207
+ <select id="jf-sched" data-testid="jf-sched" aria-label="Schedule">
1208
+ <option value="hand">By hand</option>
1209
+ <option value="new-ticket">When a new ticket arrives</option>
1210
+ <option value="daily">Every day at HH:MM</option>
1211
+ </select>
1212
+ <div class="when-sub" id="jf-sched-clock" hidden>
1213
+ <input id="jf-sched-time" type="time" value="09:00" data-testid="jf-sched-time" aria-label="Time, HH:MM">
1214
+ </div>
1215
+ <div class="hint" id="jf-sched-hint" data-testid="jf-sched-hint" hidden>off until the first green run, then turns on</div>
1216
+ <div class="hint" id="jf-sched-ticket-hint" data-testid="jf-sched-ticket-hint" hidden>the first run reads the newest ticket at the time it starts; older tickets never run</div>
1217
+ <div class="jf-err" id="jf-err-schedule" data-testid="jf-err-schedule"></div>
1218
+ </div>
1016
1219
  <div class="field">
1017
1220
  <label for="jf-dest-folder">Destination</label>
1018
1221
  <input id="jf-dest-folder" type="text" placeholder="/full/path/to/a/folder" autocomplete="off" spellcheck="false" data-testid="jf-dest-folder">
@@ -1021,7 +1224,7 @@
1021
1224
  </div>
1022
1225
  <div class="cap-row" data-testid="cap-row">
1023
1226
  <div class="cap-field">
1024
- <label for="jf-cap-money">Cap $</label>
1227
+ <label for="jf-cap-money">Cap $ <span class="req" data-testid="jf-req-cap">required</span></label>
1025
1228
  <input id="jf-cap-money" type="text" inputmode="decimal" placeholder="per run" data-testid="jf-cap-money">
1026
1229
  <div class="hint" id="jf-cap-note" data-testid="cap-note"></div>
1027
1230
  <div class="hint" id="jf-cap-job-note" data-testid="jf-cap-job-note"></div>
@@ -1061,6 +1264,19 @@
1061
1264
  <div class="jf-err" id="jf-err-run-job" data-testid="jf-err-run-job"></div>
1062
1265
  <div class="hint" id="jf-run-job-hint" data-testid="jf-run-job-hint">Change anything here. A changed job line, guardrail, ask or step drafts a new workflow; a changed destination, cap, wait or model signs a new run; new files just run.</div>
1063
1266
  </div>
1267
+ <div class="field" id="jf-run-flowtype-field" data-testid="jf-run-flowtype-field">
1268
+ <label for="jf-run-flowtype">Flow type</label>
1269
+ <select id="jf-run-flowtype" data-testid="jf-run-flowtype" aria-label="Flow type">
1270
+ <option value="plain">plain</option>
1271
+ <option value="mcp">MCP</option>
1272
+ <option value="tickets">Tickets MCP</option>
1273
+ </select>
1274
+ </div>
1275
+ <div class="field" id="jf-run-mcp-field" data-testid="jf-run-mcp-field" hidden>
1276
+ <label for="jf-run-mcp">MCP</label>
1277
+ <select id="jf-run-mcp" data-testid="jf-run-mcp" aria-label="MCP"></select>
1278
+ <div class="hint"><a class="link" id="jf-run-mcp-manage" data-testid="jf-run-mcp-manage" href="#">manage in Settings &gt; MCP</a></div>
1279
+ </div>
1064
1280
  <div class="field" id="jf-run-newname-field" data-testid="jf-run-newname-field" hidden>
1065
1281
  <label for="jf-run-newname">Name of the new workflow</label>
1066
1282
  <input id="jf-run-newname" type="text" autocomplete="off" spellcheck="false" data-testid="jf-run-newname">
@@ -1074,7 +1290,7 @@
1074
1290
  <div class="jf-err" id="jf-err-run-destination" data-testid="jf-err-run-destination"></div>
1075
1291
  </div>
1076
1292
  <div class="field">
1077
- <label>Inputs</label>
1293
+ <label>Inputs <span class="req" id="jf-run-req-inputs" data-testid="jf-run-req-inputs" hidden>required</span></label>
1078
1294
  <div id="jf-run-inputs" data-testid="jf-run-inputs"></div>
1079
1295
  <div class="jf-err" id="jf-err-run-inputs" data-testid="jf-err-run-inputs"></div>
1080
1296
  </div>
@@ -1087,6 +1303,7 @@
1087
1303
  <option value="weekly">Every &lt;day&gt; at HH:MM</option>
1088
1304
  <option value="file-updated">When &lt;file&gt; is updated</option>
1089
1305
  <option value="new-file">When a new file arrives in &lt;folder&gt;</option>
1306
+ <option value="new-ticket">When a new ticket arrives in &lt;input name&gt;</option>
1090
1307
  </select>
1091
1308
  <div class="when-sub" id="jf-when-clock" hidden>
1092
1309
  <select id="jf-when-day" data-testid="jf-when-day" aria-label="Day of the week">
@@ -1104,7 +1321,7 @@
1104
1321
  </div>
1105
1322
  <div class="cap-row">
1106
1323
  <div class="cap-field">
1107
- <label for="jf-run-cap">Cap $</label>
1324
+ <label for="jf-run-cap">Cap $ <span class="req" data-testid="jf-run-req-cap">required</span></label>
1108
1325
  <input id="jf-run-cap" type="text" inputmode="decimal" autocomplete="off" data-testid="jf-run-cap">
1109
1326
  <div class="hint" id="jf-run-left" data-testid="jf-run-left"></div>
1110
1327
  <div class="jf-err" id="jf-err-run-capUsd" data-testid="jf-err-run-capUsd"></div>
@@ -1324,6 +1541,7 @@
1324
1541
  <div id="job-grid" data-testid="job-grid">
1325
1542
  <div id="details-prose"></div>
1326
1543
  <div id="details-plan-tail"></div>
1544
+ <div class="field" id="details-mcp-field" data-testid="details-mcp-field" hidden><div id="details-mcp"></div></div>
1327
1545
  <div class="field"><label>Ask</label><div id="details-asks"></div></div>
1328
1546
  <div class="field"><label>Destination</label><div id="details-sends"></div></div>
1329
1547
  <div class="field"><label>$ cap</label><div class="ro-value" id="details-cap">—</div></div>
@@ -1717,6 +1935,7 @@
1717
1935
  if(g === "[!]") return "expired";
1718
1936
  if(g === "[II]") return "stuck";
1719
1937
  if(g === "[■]") return "stopped";
1938
+ if(g === "[–]") return "skipped";
1720
1939
  return "grey"; // "[·]" — waiting on a human, or answered-not-resumed
1721
1940
  }
1722
1941
 
@@ -1993,7 +2212,8 @@
1993
2212
  noRows: data.rows.length === 0,
1994
2213
  };
1995
2214
  }
1996
- function rlSectHtml(label, n, note){
2215
+ function rlSectHtml(label, n, note, cap){
2216
+ if(cap) return '<div class="rl-sect rl-cap rl-cap-' + cap + '" data-testid="rl-cap-' + cap + '">' + label + ' <span class="rl-p">(</span><span class="rl-n">' + n + '</span><span class="rl-p">)</span>' + (note ? ' <span class="rl-note">' + note + '</span>' : '') + '</div>';
1997
2217
  return '<div class="rl-sect">' + label + ' (' + n + ')' + (note ? ' ' + note : '') + '</div>';
1998
2218
  }
1999
2219
  // line 1 and 2 of a Running now / Needs you card; both jump to the run (rlJump). The tag is a label (a span), never a button.
@@ -2019,8 +2239,8 @@
2019
2239
  // M11 am20: Running now and Needs you only (never filtered); they sit above the search box. Scheduled is drawn by rlSchedHtml, below it.
2020
2240
  function rlTopHtml(m, filters){
2021
2241
  var h = "";
2022
- if(m.running.length) h += rlSectHtml("Running now", m.running.length) + m.running.map(function(r){ return rlJumpCardHtml(r, false); }).join("");
2023
- if(m.needs.length) h += rlSectHtml("Needs you", m.needs.length) + m.needs.map(function(r){ return rlJumpCardHtml(r, true); }).join("");
2242
+ if(m.running.length) h += rlSectHtml("Running now", m.running.length, "", "r") + m.running.map(function(r){ return rlJumpCardHtml(r, false); }).join("");
2243
+ if(m.needs.length) h += rlSectHtml("Needs you", m.needs.length, "", "w") + m.needs.map(function(r){ return rlJumpCardHtml(r, true); }).join("");
2024
2244
  return h;
2025
2245
  }
2026
2246
  // the Scheduled cards the search leaves (the ONE place that narrows them); the count line and rlSchedHtml both read it
@@ -2032,7 +2252,7 @@
2032
2252
  }
2033
2253
  function rlSchedHtml(m, filters){
2034
2254
  var shown = rlSchedShown(m.scheduled, filters && filters.search ? filters.search : "");
2035
- if(shown.length) return rlSectHtml("Scheduled", shown.length) + shown.map(rlScheduledCardHtml).join("");
2255
+ if(shown.length) return rlSectHtml("Scheduled", shown.length, "", "s") + shown.map(rlScheduledCardHtml).join("");
2036
2256
  if(filters && filters.scheduled === true) return '<div class="rl-hint">no scheduled job matches</div>';
2037
2257
  return "";
2038
2258
  }
@@ -2047,7 +2267,7 @@
2047
2267
  // a job card: `[sign] job k runs` / `word · why` of its newest run, highlighted when the selected run is one of its runs; not clickable. Inside: the newest run's card, then the older-runs fold.
2048
2268
  function rlJobCardHtml(c){
2049
2269
  var h = c.head;
2050
- var top = '<div class="rl-card' + (c.selected ? ' rl-sel' : '') + '" id="rl-job-' + escapeXml(c.flow) + '" data-testid="rl-job-' + escapeXml(c.flow) + '">';
2270
+ var top = '<div class="rl-card rl-jobcard' + (c.selected ? ' rl-sel' : '') + '" id="rl-job-' + escapeXml(c.flow) + '" data-testid="rl-job-' + escapeXml(c.flow) + '">';
2051
2271
  if(c.empty){
2052
2272
  return top + '<span class="rl-l1"><span class="dot grey"></span><span class="rl-nm" title="' + escapeXml(c.flow) + '">' + escapeXml(c.flow) + '</span></span><span class="rl-l2">' + escapeXml(h.why || "no runs yet") + '</span></div>';
2053
2273
  }
@@ -2090,7 +2310,7 @@
2090
2310
  }
2091
2311
  function rlJobsHtml(m){
2092
2312
  var h = "";
2093
- if(m.jobs.length) h += rlSectHtml("Jobs", m.jobs.length, "· run in the last " + m.limits.quietDays + " days") + m.jobs.map(rlJobCardHtml).join("");
2313
+ if(m.jobs.length) h += rlSectHtml("Jobs", m.jobs.length, "· run in the last " + m.limits.quietDays + " days", "j") + m.jobs.map(rlJobCardHtml).join("");
2094
2314
  if(m.quiet.length){
2095
2315
  h += '<button class="rl-fold" type="button" data-rl-fold="__quiet" data-testid="rl-fold-quiet" aria-expanded="' + (m.quietOpen ? 'true' : 'false') + '">' + (m.quietOpen ? '▾' : '▸') + ' quiet jobs (' + m.quiet.length + ') · no run in ' + m.limits.quietDays + ' days</button>';
2096
2316
  if(m.quietOpen) h += m.quiet.map(rlJobCardHtml).join("");
@@ -2407,16 +2627,20 @@
2407
2627
  document.getElementById("result-body").innerHTML = "";
2408
2628
  document.getElementById("result-empty").hidden = false;
2409
2629
  }
2410
- // called by renderRun for every detail it draws: shows or removes the tab button
2630
+ // called by renderRun for every detail it draws. M13 piece 6: the tab is there for every run (the job's grid); the run's own cards only when `detail.hasResult`.
2411
2631
  function syncResultTab(detail){
2412
2632
  var btn = document.getElementById("tab-result");
2413
- var show = detail.hasResult === true;
2633
+ var show = detail.resultTab === true;
2414
2634
  if(!show && resultTabShown()) document.getElementById("tab-run").click();
2415
2635
  btn.hidden = !show;
2416
2636
  var same = !!resultData && resultData.flow === detail.flow && resultData.runId === detail.runId;
2417
2637
  if(!show || !same) clearResult(); // another run's rows never stay on screen
2638
+ if(!show || detail.hasGrid !== true || (gridData && gridData.flow !== detail.flow)){ gridData = null; gridSeenGlyph = null; }
2418
2639
  resultDetail = show ? detail : null;
2419
- if(show && same) renderResult();
2640
+ if(show && (same || gridData)) renderResult();
2641
+ // a run that changed its sign (it ended, it asked) changes its row: the grid is read again, once per change
2642
+ if(show && detail.hasGrid === true && gridSeenGlyph !== null && gridSeenGlyph !== detail.runId + detail.glyph && resultTabShown()) loadGrid(detail.flow, detail.runId);
2643
+ gridSeenGlyph = detail.runId + detail.glyph;
2420
2644
  }
2421
2645
  function loadResult(flow, runId){
2422
2646
  return getJSON("/api/runs/" + encodeURIComponent(flow) + "/" + encodeURIComponent(runId) + "/result").then(function(data){
@@ -2425,7 +2649,11 @@
2425
2649
  renderResult();
2426
2650
  }).catch(function(){ /* the tab keeps what it last drew */ });
2427
2651
  }
2428
- document.getElementById("tab-result").addEventListener("click", function(){ if(currentRunId !== null) loadResult(currentFlow, currentRunId); });
2652
+ document.getElementById("tab-result").addEventListener("click", function(){
2653
+ if(currentRunId === null) return;
2654
+ if(resultDetail && resultDetail.hasGrid === true) loadGrid(currentFlow, currentRunId);
2655
+ if(resultDetail && resultDetail.hasResult === true) loadResult(currentFlow, currentRunId);
2656
+ });
2429
2657
 
2430
2658
  // a RED run's own file words (the last file its check judged: "the file is gone" / "the file changed after the check") and the one note that says
2431
2659
  // what those rows are. A DELIVERED file's gone/changed words are said once, in the Saved card, never here.
@@ -2551,18 +2779,136 @@
2551
2779
  (line.kind === "facts" ? resultFactsLine(line) : resultTextLine(line)) + (line.sheet ? resultSheetBlock(line.sheet) : resultChecksList(line)) +
2552
2780
  resultNotChecked("Not checked", line.notChecked, "result-line-notchecked") + '</div>';
2553
2781
  }
2782
+ // ---- M13 piece 6 (item 8): the job's ONE Result grid (mock docs/product/m13-setup-mock.html Part 3, variant B). It replaces M12's ticket list (the same four
2783
+ // buckets, now fold rows inside the grid). The server decides every bucket, mark, name, reason and number (src/panel/jobgrid.js); this only draws, folds, and posts
2784
+ // "Run it anyway" with its reason. The cells are the Audit grid's own (gridGlyph, .cell colours, q-fold, step-sub).
2785
+ var gridData = null;
2786
+ var gridSeenGlyph = null;
2787
+ var gridUi = { open: {}, rows: {}, anyway: null, msg: "" };
2788
+ function gridMarkOf(c){ return gridGlyph(c === "g" ? "✓" : (c === "r" ? "✗" : (c === "q" ? "?" : "·"))); }
2789
+ function tgCell(c){ return '<td class="c">' + gridMarkOf(c) + '</td>'; }
2790
+ function tgCellOJ(c){ return c === "none" ? '<td class="c"><span class="hint tg-none" data-testid="grid-none" title="this job has no output checks">none</span></td>' : tgCell(c); }
2791
+ function tgCellV(c, val){ return '<td class="c">' + gridMarkOf(c) + '<span class="tg-val">' + escapeXml(val) + '</span></td>'; }
2792
+ function tgRowHTML(r, g){
2793
+ var skip = r.bucket === "skip";
2794
+ var open = skip || !!gridUi.rows[r.runId];
2795
+ var label = r.title ? r.name + " \u00b7 " + r.title : r.name;
2796
+ var nameBtn = '<button class="tg-name" type="button" data-testid="grid-name" data-run="' + escapeXml(r.runId) + '" title="' + escapeXml(label) + '">' + escapeXml(label) + '</button>';
2797
+ var h = '<tr data-testid="grid-row" data-run="' + escapeXml(r.runId) + '"><td class="r"><div class="tg-rowname">' + (skip ? "" :
2798
+ '<button class="q-fold tg-arrow" type="button" data-testid="grid-open" data-run="' + escapeXml(r.runId) + '" aria-label="show the steps of ' + escapeXml(r.name) + '" aria-expanded="' + open + '"></button>') + nameBtn +
2799
+ (r.unsure ? '<span class="badge grey tg-unsure" data-testid="grid-unsure">unsure</span>' : "") + '</div></td>' +
2800
+ tgCell(r.ex) + tgCellOJ(r.oj) + tgCellV(r.cost.mark, r.cost.value) + tgCellV(r.time.mark, duration(r.time.value)) + '</tr>';
2801
+ if(skip){
2802
+ h += '<tr class="step-sub"><td colspan="5"><div class="tg-skipwhy"><span class="badge grey">skipped</span><span data-testid="ticket-reason">' + escapeXml((r.reason ? r.reason + " · " : "") + r.cost.value) + '</span>' +
2803
+ (r.anyway && !(gridUi.anyway && gridUi.anyway.number === r.number) ? '<button class="btn small" type="button" data-testid="ticket-anyway-open" data-number="' + r.number + '">Run it anyway</button>' : "") + '</div>';
2804
+ if(r.anyway && gridUi.anyway && gridUi.anyway.number === r.number){
2805
+ h += '<div class="tk-anyway" data-testid="ticket-anyway-box"><textarea data-testid="ticket-anyway-text" aria-label="reason (needed to run it anyway)" placeholder="reason (needed to run it anyway)">' + escapeXml(gridUi.anyway.text) + '</textarea>' +
2806
+ '<button class="btn small" type="button" data-testid="ticket-anyway-go"' + (gridUi.anyway.text.trim() === "" ? " disabled" : "") + '>Run it anyway</button></div>';
2807
+ }
2808
+ h += '</td></tr>';
2809
+ } else if(open){
2810
+ h += '<tr class="step-sub"><td colspan="5">' + r.lines.map(function(x){ return '<div class="sub-line">' + escapeXml(x) + '</div>'; }).join("") +
2811
+ '<div class="sub-line"><button class="tk-rl" type="button" data-testid="ticket-run" data-run="' + escapeXml(r.runId) + '">' + escapeXml(r.runId) + '</button></div></td></tr>';
2812
+ }
2813
+ return h;
2814
+ }
2815
+ function tgStatsHTML(st){
2816
+ var c = st.counts;
2817
+ return '<p class="tg-stats" data-testid="grid-stats"><b>' + c.wait + '</b> needs you · <b>' + c.stop + '</b> stopped · <b>' + c.done + '</b> passed · <b>' + c.skip + '</b> skipped · spent <b>' + escapeXml(st.spent === null ? "unknown" : st.spent) + '</b></p>';
2818
+ }
2819
+ function tgTableHTML(g){
2820
+ var h = '<div class="grid-wrap"><table class="grid tg" data-testid="grid-table"><thead><tr><th class="r">run</th><th class="t">every step<span class="hint">exists, done</span></th><th class="t">output judged</th><th class="t">cost</th><th class="t">time</th></tr></thead><tbody>';
2821
+ g.groups.forEach(function(b){
2822
+ var open = gridUi.open[b.key] === undefined ? b.open : gridUi.open[b.key];
2823
+ h += '<tr class="tg-grp"><td colspan="5"><button class="tg-fold" type="button" data-testid="grid-fold-' + b.key + '" data-group="' + b.key + '" aria-expanded="' + open + '"><span class="tg-foldin">' + (open ? "▾" : "▸") + " " + escapeXml(b.label) + " (" + b.rows.length + ")</span></button></td></tr>";
2824
+ if(open) h += b.rows.map(function(r){ return tgRowHTML(r, g); }).join("");
2825
+ });
2826
+ return h + '</tbody></table></div>';
2827
+ }
2828
+ function gridCardHTML(g, tickets){
2829
+ return '<div class="audit-group" data-testid="result-grid"><h4><span class="badge grey">' + escapeXml(tickets ? "tickets" : g.flow) + '</span></h4>' + tgStatsHTML(g.stats) +
2830
+ '<div id="grid-host" data-testid="grid-host">' + tgTableHTML(g) + '</div><div class="tk-msg" id="ticket-msg" data-testid="ticket-msg">' + escapeXml(gridUi.msg) + '</div>' +
2831
+ '<div class="hint">newest first inside each bucket</div></div>';
2832
+ }
2833
+ function wireGrid(body){
2834
+ var g = gridData;
2835
+ var host = body.querySelector("#grid-host");
2836
+ if(!g || !host) return;
2837
+ function repaint(){ host.innerHTML = tgTableHTML(g); var ta = host.querySelector("[data-testid=ticket-anyway-text]"); if(ta && gridUi.focusAnyway){ ta.focus(); ta.setSelectionRange(ta.value.length, ta.value.length); } }
2838
+ host.addEventListener("click", function(ev){
2839
+ var t = ev.target.closest("button");
2840
+ if(!t || !host.contains(t)) return;
2841
+ var tid = t.getAttribute("data-testid") || "";
2842
+ if(t.hasAttribute("data-group")){
2843
+ var k = t.getAttribute("data-group");
2844
+ var cur = g.groups.filter(function(x){ return x.key === k; })[0];
2845
+ gridUi.open[k] = !(gridUi.open[k] === undefined ? cur.open : gridUi.open[k]);
2846
+ repaint();
2847
+ } else if(tid === "grid-open"){
2848
+ var id = t.getAttribute("data-run");
2849
+ gridUi.rows[id] = !gridUi.rows[id];
2850
+ repaint();
2851
+ } else if(tid === "grid-name"){
2852
+ selectRun(g.flow, t.getAttribute("data-run"), null, ".hist-row"); document.getElementById("tab-run").click();
2853
+ } else if(tid === "ticket-run"){
2854
+ selectRun(g.flow, t.getAttribute("data-run"), null, ".hist-row"); document.getElementById("tab-run").click();
2855
+ } else if(tid === "ticket-anyway-open"){
2856
+ var n = Number(t.getAttribute("data-number"));
2857
+ gridUi.anyway = (gridUi.anyway && gridUi.anyway.number === n) ? null : { number: n, text: "" };
2858
+ gridUi.msg = ""; gridUi.focusAnyway = true; repaint();
2859
+ } else if(tid === "ticket-anyway-go"){
2860
+ var a = gridUi.anyway;
2861
+ var msg = document.getElementById("ticket-msg");
2862
+ if(!a || a.text.trim() === ""){ gridUi.msg = "Please write a reason to run it anyway."; msg.textContent = gridUi.msg; return; }
2863
+ t.disabled = true;
2864
+ postJSON("/api/author/ticket-anyway", { flow: g.flow, runId: g.anywayRunId, number: a.number, reason: a.text.trim() }).then(function(r){
2865
+ var ok = r.status >= 200 && r.status < 300 && r.body && r.body.ok === true;
2866
+ gridUi.msg = (r.body && r.body.say) || (ok ? "Queued." : "Not queued. Nothing started.");
2867
+ if(ok) gridUi.anyway = null;
2868
+ repaint(); document.getElementById("ticket-msg").textContent = gridUi.msg;
2869
+ }).catch(function(){ gridUi.msg = "Could not reach the panel. Nothing started."; document.getElementById("ticket-msg").textContent = gridUi.msg; t.disabled = false; });
2870
+ }
2871
+ });
2872
+ host.addEventListener("input", function(ev){
2873
+ var ta = ev.target;
2874
+ if(!ta || ta.getAttribute("data-testid") !== "ticket-anyway-text" || !gridUi.anyway) return;
2875
+ gridUi.anyway.text = ta.value;
2876
+ var go = host.querySelector("[data-testid=ticket-anyway-go]");
2877
+ if(go) go.disabled = ta.value.trim() === "";
2878
+ });
2879
+ host.addEventListener("keydown", function(ev){
2880
+ if(ev.key !== "Escape" || !ev.target || !ev.target.getAttribute || ev.target.getAttribute("data-testid") !== "ticket-anyway-text") return;
2881
+ gridUi.anyway = null; gridUi.focusAnyway = false; gridUi.msg = ""; repaint();
2882
+ });
2883
+ host.addEventListener("focusout", function(ev){ if(ev.target && ev.target.getAttribute && ev.target.getAttribute("data-testid") === "ticket-anyway-text") gridUi.focusAnyway = false; });
2884
+ host.addEventListener("focusin", function(ev){ if(ev.target && ev.target.getAttribute && ev.target.getAttribute("data-testid") === "ticket-anyway-text") gridUi.focusAnyway = true; });
2885
+ }
2886
+ function loadGrid(flow, runId){
2887
+ return getJSON("/api/runs/" + encodeURIComponent(flow) + "/" + encodeURIComponent(runId) + "/grid").then(function(g){
2888
+ if(currentFlow !== flow || currentRunId !== runId || !resultDetail) return;
2889
+ g.flow = flow;
2890
+ gridData = g;
2891
+ renderResult();
2892
+ }).catch(function(){ /* the tab keeps what it last drew */ });
2893
+ }
2554
2894
  function renderResult(){
2555
2895
  var detail = resultDetail, data = resultData;
2556
2896
  var body = document.getElementById("result-body");
2557
- if(!detail || !data || data.flow !== detail.flow || data.runId !== detail.runId){ return; }
2897
+ if(!detail){ return; }
2898
+ // M13 piece 6: the grid is for every job; the run's own cards below it only for a job that has them (detail.hasResult) and once they are loaded
2899
+ if(!data || data.flow !== detail.flow || data.runId !== detail.runId) data = null;
2900
+ if(!data && !gridData){ return; }
2558
2901
  document.getElementById("result-empty").hidden = true;
2559
2902
  body.hidden = false;
2903
+ var grid = gridData && gridData.flow === detail.flow ? gridData : null;
2904
+ var h = grid ? gridCardHTML(grid, grid.flowType === "tickets") : "";
2905
+ if(!data){ body.innerHTML = h; wireGrid(body); return; }
2560
2906
  // keep what the person is typing (and the box they opened) across a poll-driven redraw
2561
2907
  var keepText = body.querySelector("#result-rerun-text");
2562
2908
  var typed = keepText ? keepText.value : "";
2563
2909
  var rerunOpen = !!body.querySelector("#result-rerun-box:not([hidden])");
2564
2910
  var counters = document.getElementById("run-counters").textContent.split(" \u00b7 ");
2565
- var h = '<div class="job-card" data-testid="result-head"><h4>Result</h4>' +
2911
+ h += '<div class="job-card" data-testid="result-head"><h4>Result</h4>' +
2566
2912
  resultField("Status", '<div class="ro-value">' + stateDotHTML(glyphClass(detail.glyph), detail.word || "", "result-status") +
2567
2913
  ' \u00b7 ' + escapeXml(detail.checkType) + ' \u00b7 ' + escapeXml(detail.flow + " (" + detail.runId + ")") + '</div>') +
2568
2914
  '<div class="field-row">' + resultField("Money", '<div class="ro-value" data-testid="result-counters">' + escapeXml(counters[0] || "") + '</div>') +
@@ -2588,6 +2934,7 @@
2588
2934
  }).join("") + '</div>';
2589
2935
  }
2590
2936
  body.innerHTML = h;
2937
+ wireGrid(body);
2591
2938
  var ta = body.querySelector("#result-rerun-text");
2592
2939
  if(ta){
2593
2940
  ta.value = typed;
@@ -2633,8 +2980,8 @@
2633
2980
  // src/summary-words.js); this only paints them. ENDED / NEXT while a finished run; SCHEDULED / NEXT for a job with a trigger.
2634
2981
  // borrowed-from: bareloop src/panel/index.html@f845ee7 (renderEnded)
2635
2982
  // M9 am13: ONE framed box, rows `label | value`. Frame: red on a SCHEDULE problem (sm.schedule.red, the one owner is scheduleBlockOf), else the colour of the run's card (glyphClass; M9 am14). ENDED and NEXT text are never red; only a problem reddens SCHEDULE.
2636
- function summaryRow(label, value, testid, red){
2637
- var c = red ? ' is-red' : '';
2983
+ function summaryRow(label, value, testid, red, grey){
2984
+ var c = red ? ' is-red' : (grey ? ' is-grey' : '');
2638
2985
  return '<div class="ended-row"><span class="ended-label' + c + '">' + label + '</span><span class="ended-text' + c + '"' + (testid ? ' data-testid="' + testid + '"' : '') + '>' + escapeXml(value) + '</span></div>';
2639
2986
  }
2640
2987
  // M9 am24: `next` is one string; `rows` ([label, instruction] pairs, from summary-words.js) is there only when it holds several instructions
@@ -2654,7 +3001,7 @@
2654
3001
  box.hidden = false;
2655
3002
  box.className = "ended-block" + (tone ? " " + tone : "");
2656
3003
  box.innerHTML = (sm.ended ? summaryRow("ENDED", sm.ended.reason, "ended-reason") + nextRow(sm.ended) : "") +
2657
- (sc ? summaryRow("SCHEDULE", sc.line1, "sched-line1", sc.red === true) + (sc.line2 ? summaryRow("", sc.line2, "sched-line2", sc.red === true) : "") : "");
3004
+ (sc ? summaryRow("SCHEDULE", sc.line1, "sched-line1", sc.red === true) + (sc.line2 ? summaryRow("", sc.line2, "sched-line2", sc.red === true, sc.grey === true) : "") : "");
2658
3005
  } else { box.hidden = true; box.innerHTML = ""; }
2659
3006
  note.hidden = !sm.catchUp;
2660
3007
  note.textContent = sm.catchUp || "";
@@ -3237,46 +3584,14 @@
3237
3584
  if(testId) e.setAttribute("data-testid", testId);
3238
3585
  return e;
3239
3586
  }
3240
- function foldTryEl(t, human, stepKey){
3587
+ // an ask step's try: the answer and the file it was about (a model step's tries are the grid's columns)
3588
+ function foldTryEl(t){
3241
3589
  var wrap = document.createElement("div");
3242
3590
  var line = foldEl("div", "audit-try", null, "audit-try-line");
3243
3591
  line.appendChild(document.createTextNode("try " + t.n + " "));
3244
3592
  line.appendChild(foldEl("span", "mark " + auditMarkClass(t.mark), t.mark));
3245
- var rest = human
3246
- ? [t.answer, t.about ? "about " + t.about : null]
3247
- : [t.thinking, t.gap];
3248
- rest.forEach(function(x){ if(x) line.appendChild(document.createTextNode(" \u00b7 " + x)); });
3593
+ [t.answer, t.about ? "about " + t.about : null].forEach(function(x){ if(x) line.appendChild(document.createTextNode(" \u00b7 " + x)); });
3249
3594
  wrap.appendChild(line);
3250
- // M8 am7 item 4: this try was handed the earlier runs' block - one line, a click opens the exact text (the learnings box's own fold classes); hidden when nothing was handed
3251
- if(!human && t.hints && t.hints.text){
3252
- var hk = "\u0000hints:" + stepKey + ":" + t.n;
3253
- var hpart = foldEl("div", "audit-part", null, "audit-try-hints");
3254
- var hhead = foldEl("button", "btn audit-part-toggle", "told from earlier runs \u00B7 " + t.hints.n + (t.hints.n === 1 ? " hint" : " hints"), "audit-try-hints-head");
3255
- hhead.type = "button";
3256
- var hbody = foldEl("div", "audit-part-body", null, "audit-try-hints-text");
3257
- hbody.style.cssText = "white-space:pre-wrap;overflow-wrap:anywhere;margin:6px 0";
3258
- hbody.textContent = t.hints.text;
3259
- var paintHints = function(open){ hbody.hidden = !open; hhead.setAttribute("aria-expanded", open ? "true" : "false"); };
3260
- paintHints(auditExpanded[hk] === true);
3261
- hhead.addEventListener("click", function(ev){ ev.stopPropagation(); var open = hbody.hidden; auditExpanded[hk] = open; paintHints(open); });
3262
- hpart.appendChild(hhead); hpart.appendChild(hbody);
3263
- wrap.appendChild(hpart);
3264
- }
3265
- if(!human && t.checks && t.checks.length){
3266
- var box = foldEl("div", "audit-checks", null, "audit-checks");
3267
- t.checks.forEach(function(c){
3268
- var row = foldEl("div", "audit-chk", null, "audit-check");
3269
- row.appendChild(foldEl("span", "mark " + (c.ok ? "green" : "red"), c.ok ? "\u2713" : "\u2717"));
3270
- row.appendChild(foldEl("span", null, "#" + c.n + " " + c.text + (c.result ? " (" + c.result + ")" : "")));
3271
- row.appendChild(foldEl("span", "src", "\u00b7 from " + c.source));
3272
- box.appendChild(row);
3273
- });
3274
- if(t.output){
3275
- var sha = String(t.output.sha256);
3276
- box.appendChild(foldEl("div", "audit-judged", "output judged: " + t.output.file + " \u00b7 " + foldSize(t.output.bytes) + " \u00b7 sha256 " + sha.slice(0, 4) + "\u2026" + sha.slice(-2), "audit-judged"));
3277
- }
3278
- wrap.appendChild(box);
3279
- }
3280
3595
  return wrap;
3281
3596
  }
3282
3597
  var ROUNDS_PAGE = 20;
@@ -3290,13 +3605,17 @@
3290
3605
  }
3291
3606
  // the Round table, 20 rows at a time (bareloop's "showing A\u2013B of N" + load more), table scrolling inside its own box
3292
3607
  function foldRoundsEl(g){
3293
- var rows = g.fold.rows || [];
3294
3608
  var wrap = document.createElement("div");
3295
3609
  wrap.appendChild(foldEl("div", "audit-fold-label", "rounds"));
3610
+ wrap.appendChild(foldRoundsTableEl(g.step, g.fold.rows || []));
3611
+ return wrap;
3612
+ }
3613
+ function foldRoundsTableEl(stepKey, rows){
3614
+ var wrap = document.createElement("div");
3296
3615
  var scroll = foldEl("div", "audit-table-scroll");
3297
3616
  var table = document.createElement("table");
3298
3617
  table.className = "rounds-table";
3299
- table.setAttribute("data-testid", "rounds-table-" + g.step);
3618
+ table.setAttribute("data-testid", "rounds-table-" + stepKey);
3300
3619
  table.innerHTML = "<thead><tr><th>Round</th><th>Try</th><th>Action</th><th>Path</th><th>Decision</th><th>Time</th></tr></thead><tbody></tbody>";
3301
3620
  var tbody = table.querySelector("tbody");
3302
3621
  scroll.appendChild(table);
@@ -3320,12 +3639,279 @@
3320
3639
  more();
3321
3640
  return wrap;
3322
3641
  }
3642
+ // The Audit check grid: one grid per model step (rows = the step's checks by their number, columns = tries), under it an "errors" area (one line per red try, plus any hints text opened), then the rounds folded per try. Every word comes from the server's `fold` (src/audit-fold.js: `tries`, `rows`); the page
3643
+ // types none of them. A check is the same row in every try by its NUMBER (#1 output exists, #2 done, #3 and up the close's checks, src/try-checks.js).
3644
+ // borrowed-from: bareloop src/panel/index.html@c79d396 (gridGlyph, gridPlural, gridCellOf, gridFailsOf, gridDefaultOpen, gridTableHtml, gridErrorsHtml, gridRoundsHtml, renderGridErrors, the
3645
+ // click wiring), adapted: fwdloop's try/check shape (`fold.tries[].checks`), its `.mark` glyph colours, the failing lines are the try's gap, rounds come from the fold's own rows.
3646
+ function gridGlyph(g){
3647
+ if(g === "\u2713") return '<span class="mark green">' + g + '</span>';
3648
+ if(g === "\u2717") return '<span class="mark red">' + g + '</span>';
3649
+ if(g === "?") return '<span class="glyph-q">' + g + '</span>';
3650
+ if(g === "\u00b7") return '<span class="glyph-nr">' + g + '</span>';
3651
+ return escapeXml(g);
3652
+ }
3653
+ function gridPlural(n, w){ return n + " " + w + (n === 1 ? "" : "s"); }
3654
+ // the try's gap as error lines: one per non-blank line, as the audit row holds it
3655
+ function gridGapLines(gap){
3656
+ return typeof gap === "string" ? gap.split("\n").filter(function(l){ return l.trim() !== ""; }) : [];
3657
+ }
3658
+ // a graded try (`fold.tries[i]`) as one grid column. The lines of its gap belong to its first failing check (all of the close's lines are one text; none is guessed per check).
3659
+ // `red` = that first failing check with the try's error lines (the errors list's one line per red try); null when no check failed.
3660
+ function gridTryOf(t){
3661
+ var out = {
3662
+ n: t.n, glyph: t.mark, hint: t.thinking || "", noVerdict: null, known: Array.isArray(t.checks) && t.checks.length > 0, inflight: t.mark === "·",
3663
+ cells: {}, order: [], output: t.output || null, hints: t.hints && t.hints.text ? t.hints : null, red: null
3664
+ };
3665
+ if(out.known){
3666
+ t.checks.forEach(function(c){
3667
+ var cell = { name: String(c.n), n: c.n, question: c.text, source: c.source, status: c.ok ? "pass" : "fail", number: c.ok && c.result ? c.result : null };
3668
+ if(!c.ok && !out.red){
3669
+ var lines = gridGapLines(t.gap);
3670
+ out.red = { lines: lines.length ? lines : [c.text] };
3671
+ }
3672
+ out.cells[cell.name] = cell;
3673
+ out.order.push(cell.name);
3674
+ });
3675
+ } else if(t.mark === "✗"){
3676
+ // red with no check record: no check ran, so no verdict; its own gap words stay
3677
+ out.glyph = "?";
3678
+ out.noVerdict = gridGapLines(t.gap)[0] || "no verdict";
3679
+ }
3680
+ return out;
3681
+ }
3682
+ // rows: checks #1 and #2 are ONE row `every step: exists, done` (`parts` = the two checks, for its fold); #3 and up are one row each, by number
3683
+ function gridModelOf(f){
3684
+ var tries = (f.tries || []).map(gridTryOf);
3685
+ var byN = {};
3686
+ tries.forEach(function(t){ t.order.forEach(function(nm){ if(!byN[nm]) byN[nm] = t.cells[nm]; }); });
3687
+ var rows = Object.keys(byN).filter(function(nm){ return byN[nm].n > 2; }).map(function(nm){ return { n: byN[nm].n, name: nm, question: byN[nm].question, source: byN[nm].source }; }).sort(function(a, b){ return a.n - b.n; });
3688
+ var parts = [byN["1"], byN["2"]].filter(Boolean);
3689
+ if(parts.length) rows.unshift({ n: 1, every: true, parts: parts });
3690
+ var rounds = {};
3691
+ (f.rows || []).forEach(function(r){ (rounds[r.try] = rounds[r.try] || []).push(r); });
3692
+ tries.forEach(function(t){
3693
+ t.rows = rounds[t.n] || [];
3694
+ t.calls = t.rows.filter(function(r){ return r.action === "model call"; }).length;
3695
+ });
3696
+ return { tries: tries, rows: rows };
3697
+ }
3698
+ // one cell: pass, fail, not run (the done check halted before the rest) or no verdict. The every-step row fails when either of its two checks failed.
3699
+ function gridCellOf(t, row){
3700
+ if(t.noVerdict) return { s: "unk" };
3701
+ if(row.every){
3702
+ var cs = ["1", "2"].map(function(nm){ return t.cells[nm]; }).filter(Boolean);
3703
+ if(cs.some(function(c){ return c.status === "fail"; })) return { s: "fail" };
3704
+ if(cs.length === 2) return { s: "pass", number: cs.map(function(c){ return c.number; }).filter(Boolean).join(" · ") };
3705
+ if(cs.length === 0 && !t.known) return { s: t.inflight ? "notrun" : "unk" };
3706
+ return { s: "notrun" };
3707
+ }
3708
+ var c = t.cells[row.name];
3709
+ if(c) return { s: c.status, number: c.number };
3710
+ if(!t.known) return { s: t.inflight ? "notrun" : "unk" };
3711
+ return { s: "notrun" };
3712
+ }
3713
+ // default on load: only the LAST red try's row is open; no hints are
3714
+ function gridDefaultOpen(model){
3715
+ var open = {};
3716
+ var last = null;
3717
+ model.tries.forEach(function(t){ if(t.red) last = t.n; });
3718
+ if(last !== null) open[last] = true;
3719
+ return open;
3720
+ }
3721
+ function gridHintsWord(h){ return h.n + (h.n === 1 ? " hint" : " hints"); }
3722
+ function gridTableHtml(pid, model){
3723
+ if(model.rows.length === 0) return "";
3724
+ var head = '<tr><th class="q">check</th>' + model.tries.map(function(t){
3725
+ return '<th class="t">try ' + t.n + " " + gridGlyph(t.glyph) + (t.hint ? '<span class="hint">' + escapeXml(t.hint) + "</span>" : "") + "</th>";
3726
+ }).join("") + "</tr>";
3727
+ var hrow = "";
3728
+ if(model.tries.some(function(t){ return !!t.hints; })){
3729
+ hrow = '<tr class="hint-row"><td class="q">told from earlier runs</td>' + model.tries.map(function(t){
3730
+ return '<td class="c">' + (t.hints ? '<button type="button" class="btn small hints" data-hint="' + t.n + '" aria-expanded="false" aria-controls="fxerr-' + pid + '" title="try ' + t.n + ' · told from earlier runs">' + gridHintsWord(t.hints) + "</button>" : '<span class="cell none">—</span>') + "</td>";
3731
+ }).join("") + "</tr>";
3732
+ }
3733
+ var sub = "";
3734
+ var body = model.rows.map(function(r){
3735
+ var tds = model.tries.map(function(t){
3736
+ var c = gridCellOf(t, r);
3737
+ if(c.s === "unk") return '<td class="c"><span class="cell unk" title="try ' + t.n + ': no verdict">' + gridGlyph("?") + "</span></td>";
3738
+ if(c.s === "notrun") return '<td class="c"><span class="cell notrun" title="not run (first-red-wins stopped the close)">' + gridGlyph("·") + "</span></td>";
3739
+ if(c.s === "pass") return '<td class="c"><span class="cell pass" title="passed' + (c.number ? ": " + escapeXml(c.number) : "") + '">' + gridGlyph("✓") + "</span></td>";
3740
+ return '<td class="c"><button type="button" class="cell fail" aria-expanded="false" aria-controls="fxerr-' + pid + '" data-fx="' + t.n + ":" + r.n + '" title="try ' + t.n + ", " + (r.every ? "every step" : "check #" + r.n) + ': failed - click to read its errors">' + gridGlyph("✗") + "</button></td>";
3741
+ }).join("");
3742
+ if(r.every){
3743
+ sub = '<tr class="step-sub" id="fxev-' + pid + '" hidden><td colspan="' + (model.tries.length + 1) + '">' + r.parts.map(function(p){
3744
+ return '<div class="sub-line"><span>' + p.n + " " + escapeXml(p.question) + '</span><span class="marks">' + model.tries.map(function(t){
3745
+ var pc = t.noVerdict ? { s: "unk" } : t.cells[String(p.n)] ? { s: t.cells[String(p.n)].status } : { s: t.known ? "notrun" : "unk" };
3746
+ return gridGlyph(pc.s === "pass" ? "✓" : pc.s === "fail" ? "✗" : pc.s === "notrun" ? "·" : "?");
3747
+ }).join("") + "</span></div>";
3748
+ }).join("") + "</td></tr>";
3749
+ return '<tr><td class="q"><button type="button" class="q-fold" data-every aria-expanded="false" aria-controls="fxev-' + pid + '">every step: exists, done</button></td>' + tds + "</tr>" + sub;
3750
+ }
3751
+ return '<tr><td class="q"' + (r.source ? ' title="' + escapeXml(r.source) + '"' : "") + ">" + r.n + " " + escapeXml(r.question) + "</td>" + tds + "</tr>";
3752
+ }).join("");
3753
+ return '<div class="grid-wrap audit-table-scroll"><table class="grid fgrid" data-testid="audit-grid-table"><thead>' + head + "</thead><tbody>" + hrow + body + "</tbody></table></div>";
3754
+ }
3755
+ // up to 8 lines of a text, then a button for the rest; `key` names the button's data attribute
3756
+ var GRID_CAP = 8;
3757
+ function gridLinesHtml(lines, more, attr, key){
3758
+ var shown = more ? lines : lines.slice(0, GRID_CAP);
3759
+ return '<div class="fx-lines">' + shown.map(function(l){ return /^\s/.test(l) ? '<div class="ind">' + escapeXml(l.replace(/^\s+/, "")) + "</div>" : "<div>" + escapeXml(l) + "</div>"; }).join("") + "</div>" +
3760
+ (lines.length > GRID_CAP ? '<button type="button" class="fx-more" ' + attr + '="' + key + '">' + (more ? "show first " + GRID_CAP + " only" : "+" + (lines.length - GRID_CAP) + " more lines") + "</button>" : "");
3761
+ }
3762
+ // the exact hints text a try was handed, one div per line (trailing blank lines dropped)
3763
+ function gridHintLines(h){
3764
+ var lines = String(h.text).split("\n");
3765
+ while(lines.length && lines[lines.length - 1].trim() === "") lines.pop();
3766
+ return lines;
3767
+ }
3768
+ // the errors area: the hints texts opened by their buttons, then one line per red try (`try N ✗ <first error line>`).
3769
+ // `st` = {open: {tryN: true}, more: {tryN: true}, hint: {tryN: true}, hmore: {tryN: true}}
3770
+ function gridErrorsHtml(pid, model, st){
3771
+ var hrows = model.tries.filter(function(t){ return t.hints && st.hint[t.n]; }).map(function(t){
3772
+ return '<div class="fx-row hintrow open"><button type="button" class="fx-rowhead" id="fxhint-' + pid + "-" + t.n + '" data-hrow="' + t.n + '" aria-expanded="true"><span class="fx-caret">▾</span><span class="fx-try">try ' + t.n + " · told from earlier runs · " + gridHintsWord(t.hints) + '</span></button><div class="fx-body">' +
3773
+ gridLinesHtml(gridHintLines(t.hints), !!st.hmore[t.n], "data-hmore", t.n) + "</div></div>";
3774
+ }).join("");
3775
+ var rows = model.tries.map(function(t){
3776
+ if(t.noVerdict){
3777
+ return '<div class="fx-row fx-row-q"><span class="fx-rowhead"><span class="fx-caret"></span><span class="fx-try">try ' + t.n + '</span><span class="fx-chk">' + gridGlyph("?") + '</span><span class="fx-first fx-faint" title="' + escapeXml(t.noVerdict) + '">' + escapeXml(t.noVerdict) + "</span></span></div>";
3778
+ }
3779
+ if(!t.red) return "";
3780
+ var lines = t.red.lines;
3781
+ var rest = lines.length - 1;
3782
+ var open = !!st.open[t.n];
3783
+ var head = '<button type="button" class="fx-rowhead" id="fxrow-' + pid + "-" + t.n + '" data-fxrow="' + t.n + '" aria-expanded="' + (open ? "true" : "false") + '"><span class="fx-caret">' + (open ? "▾" : "▸") +
3784
+ '</span><span class="fx-try">try ' + t.n + '</span><span class="fx-chk">' + gridGlyph("✗") +
3785
+ '</span><span class="fx-first" title="' + escapeXml(lines[0]) + '">' + escapeXml(lines[0]) + "</span>" + (rest ? '<span class="fx-count">(+' + rest + " more)</span>" : "") + "</button>";
3786
+ // fwdloop's close reports ONE text for the try (its gap), not one per check: it is shown once, however many checks failed
3787
+ var body = open ? '<div class="fx-body">' + gridLinesHtml(lines, !!st.more[t.n], "data-fxmore", t.n) + "</div>" : "";
3788
+ return '<div class="fx-row' + (open ? " open" : "") + '">' + head + body + "</div>";
3789
+ }).join("");
3790
+ return hrows + rows ? '<div class="fx-label">errors</div>' + hrows + rows : "";
3791
+ }
3792
+ // the rounds, folded per try: each fold builds its own try's rows (20 a page) the first time it opens
3793
+ function gridRoundsHtml(model){
3794
+ return '<div class="audit-fold-label">rounds per try</div><div class="fold-list">' + model.tries.map(function(t){
3795
+ var line = '<div class="audit-try">try ' + t.n + " " + gridGlyph(t.glyph) + "</div>";
3796
+ if(t.rows.length === 0) return line + '<div class="hint">no rounds recorded</div>';
3797
+ return line + '<details class="rounds-fold" data-fxrounds="' + t.n + '"><summary>try ' + t.n + " rounds (" + gridPlural(t.calls, "call") + ")" +
3798
+ '</summary><div class="rf-body"></div></details>';
3799
+ }).join("") + "</div>";
3800
+ }
3801
+ // the file a try's checks read (its own `output judged` words): shown once, for the last try that has one; an `all tries` fold lists every try's
3802
+ function gridJudgedLine(t){
3803
+ var sha = String(t.output.sha256);
3804
+ return '<div class="hint fx-judged audit-judged" data-testid="audit-judged">try ' + t.n + " &middot; output judged: " + escapeXml(t.output.file) + " &middot; " + foldSize(t.output.bytes) + " &middot; sha256 " + escapeXml(sha.slice(0, 4)) + "…" + escapeXml(sha.slice(-2)) + "</div>";
3805
+ }
3806
+ function gridJudgedHtml(model){
3807
+ var withOut = model.tries.filter(function(t){ return !!t.output; });
3808
+ if(withOut.length === 0) return "";
3809
+ var html = gridJudgedLine(withOut[withOut.length - 1]);
3810
+ if(withOut.length > 1) html += '<details class="rounds-fold" style="margin-left:0" data-testid="judged-all"><summary>all tries</summary><div class="rf-body">' + withOut.map(gridJudgedLine).join("") + "</div></details>";
3811
+ return html;
3812
+ }
3813
+ function renderGridErrors(wrap, pid, model, st){
3814
+ var host = wrap.querySelector(".fx-errors");
3815
+ var html = gridErrorsHtml(pid, model, st);
3816
+ host.hidden = html === "";
3817
+ host.innerHTML = html;
3818
+ Array.prototype.forEach.call(wrap.querySelectorAll("[data-fx]"), function(b){
3819
+ b.setAttribute("aria-expanded", st.open[b.getAttribute("data-fx").split(":")[0]] ? "true" : "false");
3820
+ });
3821
+ Array.prototype.forEach.call(wrap.querySelectorAll("[data-hint]"), function(b){
3822
+ b.setAttribute("aria-expanded", st.hint[b.getAttribute("data-hint")] ? "true" : "false");
3823
+ });
3824
+ }
3825
+ // a model step's body below its tally: the grid (hints row, every-step row, the close's checks), the errors area, the judged line, then the rounds folds
3826
+ function buildGridEl(g){
3827
+ var pid = String(g.step).replace(/[^A-Za-z0-9_-]/g, "_");
3828
+ var model = gridModelOf(g.fold);
3829
+ var st = { open: gridDefaultOpen(model), more: {}, hint: {}, hmore: {} };
3830
+ var wrap = document.createElement("div");
3831
+ wrap.setAttribute("data-fxpart", pid);
3832
+ wrap.setAttribute("data-testid", "audit-grid-" + g.step);
3833
+ wrap.innerHTML = gridTableHtml(pid, model) + '<div class="fx-errors" id="fxerr-' + pid + '" hidden></div>' + gridJudgedHtml(model);
3834
+ wrap.insertAdjacentHTML("beforeend", gridRoundsHtml(model));
3835
+ renderGridErrors(wrap, pid, model, st);
3836
+ var toggle = function(tn, force, focusRow){
3837
+ st.open[tn] = force === undefined ? !st.open[tn] : force;
3838
+ renderGridErrors(wrap, pid, model, st);
3839
+ var el = document.getElementById("fxrow-" + pid + "-" + tn);
3840
+ if(el && focusRow){ el.scrollIntoView({ block: "nearest" }); el.focus(); } else if(el){ el.focus(); }
3841
+ };
3842
+ wrap.addEventListener("click", function(e){
3843
+ var hmore = e.target.closest("[data-hmore]");
3844
+ if(hmore){
3845
+ var hk = hmore.getAttribute("data-hmore");
3846
+ st.hmore[hk] = !st.hmore[hk];
3847
+ renderGridErrors(wrap, pid, model, st);
3848
+ var hagain = wrap.querySelector('[data-hmore="' + hk + '"]');
3849
+ if(hagain) hagain.focus();
3850
+ return;
3851
+ }
3852
+ var hrow = e.target.closest("[data-hrow]");
3853
+ if(hrow){
3854
+ var hn = hrow.getAttribute("data-hrow");
3855
+ st.hint[hn] = false;
3856
+ renderGridErrors(wrap, pid, model, st);
3857
+ var hb = wrap.querySelector('[data-hint="' + hn + '"]');
3858
+ if(hb) hb.focus();
3859
+ return;
3860
+ }
3861
+ var hint = e.target.closest("[data-hint]");
3862
+ if(hint){
3863
+ var tn2 = hint.getAttribute("data-hint");
3864
+ st.hint[tn2] = !st.hint[tn2];
3865
+ renderGridErrors(wrap, pid, model, st);
3866
+ var he = document.getElementById("fxhint-" + pid + "-" + tn2);
3867
+ if(he) he.scrollIntoView({ block: "nearest" });
3868
+ return;
3869
+ }
3870
+ var more = e.target.closest("[data-fxmore]");
3871
+ if(more){
3872
+ var key = more.getAttribute("data-fxmore");
3873
+ st.more[key] = !st.more[key];
3874
+ renderGridErrors(wrap, pid, model, st);
3875
+ var again = wrap.querySelector('[data-fxmore="' + key + '"]');
3876
+ if(again) again.focus();
3877
+ return;
3878
+ }
3879
+ var ev = e.target.closest("[data-every]");
3880
+ if(ev){
3881
+ var sub = document.getElementById("fxev-" + pid);
3882
+ sub.hidden = !sub.hidden;
3883
+ ev.setAttribute("aria-expanded", sub.hidden ? "false" : "true");
3884
+ return;
3885
+ }
3886
+ var row = e.target.closest("[data-fxrow]");
3887
+ if(row){ toggle(parseInt(row.getAttribute("data-fxrow"), 10), undefined, false); return; }
3888
+ var cell = e.target.closest("[data-fx]");
3889
+ if(cell){
3890
+ var tn = parseInt(cell.getAttribute("data-fx").split(":")[0], 10);
3891
+ toggle(tn, st.open[tn] ? false : true, true);
3892
+ }
3893
+ });
3894
+ Array.prototype.forEach.call(wrap.querySelectorAll("details[data-fxrounds]"), function(d){
3895
+ var t = model.tries.filter(function(x){ return x.n === parseInt(d.getAttribute("data-fxrounds"), 10); })[0];
3896
+ var built = false;
3897
+ d.addEventListener("toggle", function(){
3898
+ if(!d.open || built) return;
3899
+ built = true;
3900
+ d.querySelector(".rf-body").appendChild(foldRoundsTableEl(g.step + "-try-" + t.n, t.rows));
3901
+ });
3902
+ });
3903
+ return wrap;
3904
+ }
3323
3905
  function buildFoldBodyEl(g){
3324
3906
  var f = g.fold, human = f.who === "human";
3325
3907
  var body = foldEl("div", "audit-fold-body", null, "audit-fold-body-" + g.step);
3326
3908
  if(f.tally) body.appendChild(foldEl("div", "audit-tally", f.tally, "audit-tally"));
3327
- (f.tries || []).forEach(function(t){ body.appendChild(foldTryEl(t, human, g.step)); });
3328
- body.appendChild(foldRoundsEl(g));
3909
+ if(human){
3910
+ (f.tries || []).forEach(function(t){ body.appendChild(foldTryEl(t)); });
3911
+ body.appendChild(foldRoundsEl(g));
3912
+ } else {
3913
+ body.appendChild(buildGridEl(g));
3914
+ }
3329
3915
  return body;
3330
3916
  }
3331
3917
  var auditExpanded = {}; // step -> true/false once a human toggled it; reset when the run changes
@@ -3740,6 +4326,20 @@
3740
4326
  });
3741
4327
  }
3742
4328
  paintJobPlan(job, placed);
4329
+ // M13 am4 item 2: an MCP or Tickets MCP job also shows its flow type, MCP server, signed tools (name and hint), and for Tickets the ticket filter and watched field; a plain job shows none of it
4330
+ var mcpRows = [];
4331
+ if(job.flowType === "mcp" || job.flowType === "tickets"){
4332
+ mcpRows.push("flow type · " + (job.flowType === "tickets" ? "Tickets MCP" : "MCP"));
4333
+ mcpRows.push("MCP · " + job.mcp);
4334
+ (job.tools || []).forEach(function(t){ mcpRows.push("tools · " + t.name + (t.hint ? " (" + t.hint + ")" : "")); });
4335
+ if(job.flowType === "tickets"){
4336
+ mcpRows.push("ticket filter · " + JSON.stringify(job.ticketFilter));
4337
+ mcpRows.push("watched field · " + (Array.isArray(job.ticketWatch) ? job.ticketWatch.join(", ") : JSON.stringify(job.ticketWatch)));
4338
+ }
4339
+ }
4340
+ document.getElementById("details-mcp-field").hidden = mcpRows.length === 0;
4341
+ document.getElementById("details-mcp").innerHTML = "";
4342
+ if(mcpRows.length) renderRowsField("details-mcp", mcpRows, "", function(t){ return t; });
3743
4343
  // review #5: "Ask" — one row per signed ask line.
3744
4344
  renderRowsField("details-asks", job.asks, "no signed asks", function(ak){
3745
4345
  return "line " + ak.line + " · \"" + ak.question + "\" · waits " + plainWait(ak.waitMs);
@@ -3815,6 +4415,13 @@
3815
4415
  document.getElementById("update-bar").hidden = text === null;
3816
4416
  if(text !== null) document.getElementById("update-text").textContent = text;
3817
4417
  }
4418
+ // M4d am35: the Inbox poll (every LISTS_POLL_MS) is the panel's heartbeat. A reply of any kind (even an HTTP error) means node answered = online; only a
4419
+ // failed read with no HTTP status (the network, a dead panel) = offline. ONE painter writes the dot; the served page starts online.
4420
+ function paintOnline(isOnline){
4421
+ var el = document.getElementById("online-dot");
4422
+ el.className = isOnline ? "on" : "off";
4423
+ el.textContent = isOnline ? "\u25CF online" : "\u25CF offline";
4424
+ }
3818
4425
  document.getElementById("update-reload").addEventListener("click", function(){ location.reload(); });
3819
4426
  function tickLeft(){
3820
4427
  document.querySelectorAll(".live-left").forEach(function(el){ el._say(Math.max(0, el._endsAt - Date.now())); });
@@ -3865,7 +4472,7 @@
3865
4472
  // separately-fetched copy of the audit rows to cross-reference (fix #6).
3866
4473
  // same guard as reloadRun: a late reply for a run the user already left paints nothing and writes no polling flag
3867
4474
  var still = function(){ return currentFlow === flow && currentRunId === runId; };
3868
- getJSON(base).then(function(d){ if(still()){ paintRun(d); if(d.hasResult === true) loadResult(flow, runId); } }).catch(function(e){
4475
+ getJSON(base).then(function(d){ if(still()){ paintRun(d); if(d.hasGrid === true) loadGrid(flow, runId); if(d.hasResult === true) loadResult(flow, runId); } }).catch(function(e){
3869
4476
  if(!still()) return;
3870
4477
  openRunLive = false; // unreadable books: the list rate, not 2 s forever
3871
4478
  document.getElementById("run-empty").hidden = false;
@@ -3915,7 +4522,8 @@
3915
4522
  // Immediate (every user action that re-reads calls this); the tick uses `listsDue` to throttle.
3916
4523
  function reloadLists(){
3917
4524
  lastListsAt = Date.now();
3918
- getJSON("/api/inbox").then(function(r){ renderInbox(r.rows || [], r.openCount); paintUpdateBar(r.version); }).catch(function(){});
4525
+ getJSON("/api/inbox").then(function(r){ renderInbox(r.rows || [], r.openCount); paintUpdateBar(r.version); })
4526
+ .then(function(){ paintOnline(true); }, function(err){ paintOnline(!!(err && typeof err.status === "number")); }).catch(function(){});
3919
4527
  getJSON("/api/runs").then(function(r){
3920
4528
  var next = sig(r);
3921
4529
  if(next !== null && next === lastSig.runs) return;
@@ -4197,7 +4805,12 @@
4197
4805
  var into = row.section === 3 ? old : el;
4198
4806
  if(row.section !== lastSection){
4199
4807
  lastSection = row.section;
4200
- into.appendChild(textDiv("inbox-h", inboxHeadText(row.section, counts[row.section])));
4808
+ // captions ruling 2026-11-01: the same colour bars as Runs (waiting = Needs you amber, working = Running now teal, answered = Jobs grey), count in the pill
4809
+ var head = textDiv("inbox-h rl-cap rl-cap-" + { 1: "w", 2: "r", 3: "j" }[row.section], "");
4810
+ head.setAttribute("data-testid", "ib-cap-" + row.section);
4811
+ head.setAttribute("aria-label", inboxHeadText(row.section, counts[row.section]));
4812
+ head.innerHTML = INBOX_HEADS[row.section] + ' <span class="rl-p">(</span><span class="rl-n">' + counts[row.section] + '</span><span class="rl-p">)</span>';
4813
+ into.appendChild(head);
4201
4814
  }
4202
4815
  into.appendChild(renderStopRow(row));
4203
4816
  });
@@ -4716,6 +5329,7 @@
4716
5329
  body.hidden = !expanded;
4717
5330
  var statusBlock = askStatusBlock(ask);
4718
5331
  if(statusBlock) body.appendChild(statusBlock);
5332
+ if(ask.filterUnsure){ var fu = textDiv("hint", "the filter was unsure about this ticket"); fu.setAttribute("data-testid", "ask-filter-unsure"); body.appendChild(fu); }
4719
5333
  body.appendChild(renderAskEvidenceBlock(ask, ctx));
4720
5334
  body.appendChild(renderAnswersSoFar(block));
4721
5335
  // M4b piece 4: the answer doors (or the reason there are none) — for the CURRENT draft.
@@ -4819,6 +5433,17 @@
4819
5433
  var jobEl = document.getElementById("jf-job");
4820
5434
  var jobBoxEl = document.getElementById("jf-run-jobbox"); // the Reuse card's job box: the SAME component as #jf-job
4821
5435
  var inputsBox = document.getElementById("jf-inputs"); // the New-job inputs textarea (`name: path` per line)
5436
+ var flowTypeEl = document.getElementById("jf-flowtype"); // M13 p4: Flow type (plain | MCP | Tickets), signed with the job
5437
+ var schedEl = document.getElementById("jf-sched"); // M13 p5: Schedule (By hand | When a new ticket arrives | Every day at HH:MM), signed with the job; off until the first green run
5438
+ var schedTimeEl = document.getElementById("jf-sched-time");
5439
+ var mcpEl = document.getElementById("jf-mcp"); // M13 p4: the MCP pick, shown for the last two
5440
+ var mcpFieldEl = document.getElementById("jf-mcp-field");
5441
+ var runFlowTypeEl = document.getElementById("jf-run-flowtype"); // M13 am4: the Reuse box's own Flow type and MCP picks (new ids; same options and MCP list)
5442
+ var runMcpEl = document.getElementById("jf-run-mcp");
5443
+ var runMcpFieldEl = document.getElementById("jf-run-mcp-field");
5444
+ var inputsHintEl = document.getElementById("jf-inputs-hint");
5445
+ var INPUTS_HINT_PLAIN = inputsHintEl.textContent;
5446
+ var mcpServers = []; // the startable MCPs (Settings > MCP; winners only, remote left out)
4822
5447
  var destEl = document.getElementById("jf-dest-folder");
4823
5448
  var askWaitEl = document.getElementById("jf-ask-wait");
4824
5449
  var mainBtn = document.getElementById("chat-main-btn");
@@ -5214,6 +5839,67 @@
5214
5839
  return {role: role, path: row.querySelector(".jf-path").value.trim()};
5215
5840
  });
5216
5841
  }
5842
+ // M13 piece 4: Flow type and MCP (mock docs/product/m13-setup-mock.html, Part 1). The MCP list is Settings > MCP's winners; the page only READS it (never a command or a key).
5843
+ function paintMcpInto(el, want){
5844
+ var names = mcpServers.slice();
5845
+ if(want && names.indexOf(want) === -1) names.push(want); // a reused job's server that is no longer listed stays pickable by name; the card refuses it with the cause
5846
+ el.innerHTML = "";
5847
+ names.forEach(function(n){ var o = document.createElement("option"); o.value = n; o.textContent = n; el.appendChild(o); });
5848
+ if(want) el.value = want;
5849
+ }
5850
+ function paintMcpOptions(keep){
5851
+ paintMcpInto(mcpEl, keep === undefined ? mcpEl.value : keep);
5852
+ paintMcpInto(runMcpEl, runMcpEl.value); // M13 am4: the Reuse box lists the same MCPs
5853
+ }
5854
+ // M13 p5 (signed item 7, the mock's Schedule row): "When a new ticket arrives" only for Tickets; the time box and the two hints follow the pick
5855
+ function paintSchedule(){
5856
+ var tk = schedEl.querySelector('option[value="new-ticket"]');
5857
+ tk.hidden = tk.disabled = flowTypeEl.value !== "tickets";
5858
+ if(schedEl.value === "new-ticket" && tk.disabled) schedEl.value = "hand";
5859
+ byId("jf-sched-clock").hidden = schedEl.value !== "daily";
5860
+ byId("jf-sched-hint").hidden = schedEl.value === "hand";
5861
+ byId("jf-sched-ticket-hint").hidden = schedEl.value !== "new-ticket";
5862
+ }
5863
+ function scheduleOfCard(){
5864
+ if(schedEl.value === "new-ticket") return {kind: "new-ticket"};
5865
+ if(schedEl.value !== "daily") return null;
5866
+ var t = /^(\d{2}):(\d{2})$/.exec(schedTimeEl.value || "");
5867
+ return {kind: "daily", hour: t ? Number(t[1]) : NaN, minute: t ? Number(t[2]) : NaN};
5868
+ }
5869
+ function paintFlowType(){
5870
+ var generic = flowTypeEl.value === "mcp", tickets = flowTypeEl.value === "tickets";
5871
+ paintSchedule();
5872
+ mcpFieldEl.hidden = !(generic || tickets);
5873
+ paintRequired();
5874
+ inputsHintEl.textContent = (generic || tickets) ? "The Inputs line says what to read; it may be empty for a generic MCP job." : INPUTS_HINT_PLAIN;
5875
+ }
5876
+ // M13 am5: the one writer of the required marks. Inputs is optional only for an MCP job; the Run card's mark shows when the flow has input rows
5877
+ function paintRequired(){
5878
+ byId("jf-req-inputs").textContent = flowTypeEl.value === "mcp" ? "optional for MCP" : "required";
5879
+ byId("jf-run-req-inputs").hidden = runInputsEl.children.length === 0;
5880
+ }
5881
+ function setFlow(type, server, sched){
5882
+ flowTypeEl.value = (type === "mcp" || type === "tickets") ? type : "plain";
5883
+ paintMcpOptions(server || "");
5884
+ schedEl.value = sched && sched.kind === "daily" ? "daily" : (sched && sched.kind === "new-ticket" ? "new-ticket" : "hand");
5885
+ if(sched && sched.kind === "daily" && Number.isInteger(sched.hour) && Number.isInteger(sched.minute)) schedTimeEl.value = ("0" + sched.hour).slice(-2) + ":" + ("0" + sched.minute).slice(-2);
5886
+ paintFlowType();
5887
+ }
5888
+ function loadMcpServers(){
5889
+ return getJSON("/api/settings/mcp").then(function(d){
5890
+ var names = [];
5891
+ ((d && d.places) || []).forEach(function(p){ (p.servers || []).forEach(function(sv){ if(!sv.remote && !sv.shadowedBy && names.indexOf(sv.name) === -1) names.push(sv.name); }); });
5892
+ mcpServers = names; paintMcpOptions();
5893
+ }, function(){ /* the list stays as it was; a pick the server cannot start is refused with its cause */ });
5894
+ }
5895
+ flowTypeEl.addEventListener("change", function(){ paintFlowType(); byId("jf-err-flowType").textContent = ""; byId("jf-err-mcp").textContent = ""; refreshStartEnabled(); });
5896
+ mcpEl.addEventListener("change", function(){ byId("jf-err-mcp").textContent = ""; });
5897
+ schedEl.addEventListener("change", function(){ paintSchedule(); byId("jf-err-schedule").textContent = ""; });
5898
+ schedTimeEl.addEventListener("input", function(){ byId("jf-err-schedule").textContent = ""; });
5899
+ runFlowTypeEl.addEventListener("change", function(){ runMcpFieldEl.hidden = runFlowTypeEl.value === "plain"; });
5900
+ byId("jf-run-mcp-manage").addEventListener("click", function(ev){ ev.preventDefault(); document.getElementById("settings-open").click(); document.getElementById("stab-mcp").click(); });
5901
+ byId("jf-mcp-manage").addEventListener("click", function(ev){ ev.preventDefault(); document.getElementById("settings-open").click(); document.getElementById("stab-mcp").click(); });
5902
+ paintFlowType(); loadMcpServers();
5217
5903
  function currentCard(){
5218
5904
  return {
5219
5905
  flowName: byId("jf-name").value.trim(),
@@ -5225,6 +5911,8 @@
5225
5911
  provider: modelPick().provider,
5226
5912
  model: modelPick().model,
5227
5913
  thinking: thinkingEl.checked && !thinkingNone,
5914
+ ...(flowTypeEl.value !== "plain" ? {flowType: flowTypeEl.value, mcp: mcpEl.value} : {}),
5915
+ ...(scheduleOfCard() ? {schedule: scheduleOfCard()} : {}),
5228
5916
  ...(reuseOf !== null ? {reuseOf: reuseOf} : {})
5229
5917
  };
5230
5918
  }
@@ -5275,7 +5963,8 @@
5275
5963
  }
5276
5964
  var c = currentCard();
5277
5965
  var v = Number(c.capUsd);
5278
- return c.flowName !== "" && c.job.trim() !== "" && c.capUsd !== "" && isFinite(v) && v > 0;
5966
+ // M13 am5: Inputs is required except for an MCP job (item 4); the server still judges what is in it
5967
+ return c.flowName !== "" && c.job.trim() !== "" && (flowTypeEl.value === "mcp" || c.inputs.trim() !== "") && c.capUsd !== "" && isFinite(v) && v > 0;
5279
5968
  }
5280
5969
 
5281
5970
  // ---- the money note under Cap (M4e amendment 4 items 1-2) ----
@@ -5373,6 +6062,9 @@
5373
6062
  var on = cardLocked();
5374
6063
  whenSyncButton();
5375
6064
  card.querySelectorAll("input[type=text], textarea").forEach(function(el){ el.readOnly = on || el.hasAttribute("data-page"); el.classList.toggle("locked", on); }); // M10: a web-page row is always read-only
6065
+ flowTypeEl.disabled = on; mcpEl.disabled = on; schedEl.disabled = on; schedTimeEl.disabled = on;
6066
+ flowTypeEl.classList.toggle("locked", on); mcpEl.classList.toggle("locked", on); schedEl.classList.toggle("locked", on); schedTimeEl.classList.toggle("locked", on);
6067
+ runFlowTypeEl.disabled = on; runMcpEl.disabled = on;
5376
6068
  runFlowSel.disabled = on;
5377
6069
  runFlowSel.classList.toggle("locked", on);
5378
6070
  rwPickedEl.classList.toggle("locked", on);
@@ -5389,6 +6081,7 @@
5389
6081
  clearBtn.disabled = b.disabled;
5390
6082
  }
5391
6083
  function refreshStartEnabled(){
6084
+ paintRequired();
5392
6085
  startOk = startReady();
5393
6086
  syncCardLock();
5394
6087
  renderMain();
@@ -5424,6 +6117,9 @@
5424
6117
  delete b.runId;
5425
6118
  b.job = jobBoxEl.hidden ? undefined : jobBoxEl.value;
5426
6119
  b.fromRun = pickedRun ? pickedRun.runId : undefined;
6120
+ // M13 am4: the Reuse box's Flow type and MCP; the server compares them with the signed job
6121
+ b.flowType = runFlowTypeEl.value;
6122
+ b.mcp = runFlowTypeEl.value === "plain" ? "" : runMcpEl.value;
5427
6123
  return b;
5428
6124
  }
5429
6125
  function paintReuseKind(){
@@ -5462,6 +6158,7 @@
5462
6158
  setMode("new");
5463
6159
  setVal("jf-name", reuseRunOf ? f.flow : newNameEl.value.trim()); setVal("jf-job", jobBoxEl.value); setVal("jf-cap-money", runCapEl.value.trim());
5464
6160
  setVal("jf-dest-folder", runDestEl.value.trim()); setVal("jf-inputs", rows.map(function(r){ return r.role + ": " + r.path; }).join("\n")); setVal("jf-ask-wait", firstWait);
6161
+ setFlow(runFlowTypeEl.value, runFlowTypeEl.value === "plain" ? "" : runMcpEl.value); // M13 am4: the Reuse box's picks (unchanged = the job's own)
5465
6162
  if(pk.provider !== "") setModelPick(pk.provider, pk.model);
5466
6163
  editBannerEl.textContent = reuseRunOf
5467
6164
  ? "Reusing \u201c" + f.flow + "\u201d after a failed run. Draft a new plan, read it, then sign: it becomes the next run of \u201c" + f.flow + "\u201d, which is not changed."
@@ -5474,7 +6171,7 @@
5474
6171
  // the card stops reusing: the name box is free again. ONE owner: reuseOf and the boxes startReuseDraft filled go together, so a card that
5475
6172
  // left Reuse (a refused signed start too) can never be drafted as a plain new job carrying the old job and name
5476
6173
  function leaveReuse(){
5477
- if(reuseOf !== null){ ["jf-name", "jf-job", "jf-cap-money", "jf-dest-folder", "jf-inputs"].forEach(function(id){ byId(id).value = ""; }); askWaitEl.value = "1h"; }
6174
+ if(reuseOf !== null){ ["jf-name", "jf-job", "jf-cap-money", "jf-dest-folder", "jf-inputs"].forEach(function(id){ byId(id).value = ""; }); setFlow("plain", ""); askWaitEl.value = "1h"; }
5478
6175
  reuseOf = null;
5479
6176
  editBannerEl.hidden = true; editBannerEl.textContent = "";
5480
6177
  }
@@ -5489,6 +6186,9 @@
5489
6186
  jobBoxEl.hidden = !jobOpen; byId("jf-run-jobwrap").hidden = !jobOpen; byId("jf-run-job").hidden = jobOpen;
5490
6187
  jobBoxEl.value = jobOpen ? f.edit.card.job : "";
5491
6188
  fitCardBoxes();
6189
+ runFlowTypeEl.value = f && (f.flowType === "mcp" || f.flowType === "tickets") ? f.flowType : "plain";
6190
+ paintMcpInto(runMcpEl, f && f.mcp ? f.mcp : "");
6191
+ runMcpFieldEl.hidden = runFlowTypeEl.value === "plain";
5492
6192
  byId("jf-err-run-job").textContent = (f && f.edit && f.edit.ok === false) ? f.edit.say : "";
5493
6193
  byId("jf-run-job-hint").hidden = !jobOpen;
5494
6194
  byId("jf-run-model").textContent = f && f.model ? "Model: " + f.model.label + ". Pick another to run it with that model (signed with the run)." : (f ? "No model is recorded for this job. Pick the one to run it with; it is then remembered for this job." : "");
@@ -5530,7 +6230,10 @@
5530
6230
  var whenConfirmText = ""; // the words the button shows after click 1 ("every day at 13:15", "cancel schedule"); read only while whenHash is set
5531
6231
  var whenLocked = false; // ~1.5 s after a successful sign the main button is disabled, so a fast extra click cannot start a run
5532
6232
  var whenReady = false; // the lock sync can run before this block has
5533
- function whenCanon(t){ return t === null ? "null" : JSON.stringify(Object.keys(t).sort().map(function(k){ return [k, t[k]]; })); }
6233
+ function whenCanon(t){
6234
+ if(t !== null && t.kind === "new-ticket") t = {kind: t.kind, role: t.role}; // M12: the list, server and tool are filled by the server from the signed job
6235
+ return t === null ? "null" : JSON.stringify(Object.keys(t).sort().map(function(k){ return [k, t[k]]; }));
6236
+ }
5534
6237
  function whenTriggerFromBoxes(){
5535
6238
  var kind = byId("jf-when").value;
5536
6239
  if(kind === "hand") return null;
@@ -5540,6 +6243,7 @@
5540
6243
  if(kind === "weekly") o.day = byId("jf-when-day").value;
5541
6244
  return o;
5542
6245
  }
6246
+ if(kind === "new-ticket") return {kind: kind, role: byId("jf-when-role").value}; // M12: the person picks the input; the server fills the rest
5543
6247
  var q = {kind: kind, role: byId("jf-when-role").value};
5544
6248
  q[kind === "new-file" ? "folder" : "path"] = byId("jf-when-path").value.trim();
5545
6249
  return q;
@@ -5548,7 +6252,8 @@
5548
6252
  var kind = byId("jf-when").value;
5549
6253
  byId("jf-when-clock").hidden = !(kind === "daily" || kind === "weekdays" || kind === "weekly");
5550
6254
  byId("jf-when-day").hidden = kind !== "weekly";
5551
- byId("jf-when-filebox").hidden = !(kind === "file-updated" || kind === "new-file");
6255
+ byId("jf-when-filebox").hidden = !(kind === "file-updated" || kind === "new-file" || kind === "new-ticket");
6256
+ byId("jf-when-path").hidden = kind === "new-ticket";
5552
6257
  byId("jf-when-path").placeholder = kind === "new-file" ? "/full/path/to/folder" : "/full/path/to/file";
5553
6258
  }
5554
6259
  // M9 am4: is When changed from the signed value? The ONE reader; the main button turns into Sign schedule while it is.
@@ -5562,6 +6267,17 @@
5562
6267
  if(!whenReady) return;
5563
6268
  renderMain();
5564
6269
  }
6270
+ // M10: a file trigger watches a FILE; a web-page input is never offered. M12: a ticket trigger offers the page inputs that are a GitHub issues list.
6271
+ var TICKET_LIST = /^https:\/\/github\.com\/[^\/\s]+\/[^\/\s]+\/issues\/?$/;
6272
+ function whenFileRoles(f){ return ((f && f.roles) || []).filter(function(r){ return !(f.pages && f.pages[r]); }); }
6273
+ function whenTicketRoles(f){ return ((f && f.tickets) || []).filter(function(r){ return f.pages && f.pages[r] && TICKET_LIST.test(String(f.pages[r]).trim()); }); } // M13 p4: only a Tickets job has a ticket list
6274
+ function whenFillRoles(){
6275
+ var f = selectedFlow(), roleSel = byId("jf-when-role"), keep = roleSel.value;
6276
+ var roles = byId("jf-when").value === "new-ticket" ? whenTicketRoles(f) : whenFileRoles(f);
6277
+ roleSel.innerHTML = "";
6278
+ roles.forEach(function(r){ var o = document.createElement("option"); o.value = r; o.textContent = r; roleSel.appendChild(o); });
6279
+ if(roles.indexOf(keep) >= 0) roleSel.value = keep;
6280
+ }
5565
6281
  function paintWhen(){
5566
6282
  var f = selectedFlow();
5567
6283
  var c = f ? f.trigger : null;
@@ -5569,14 +6285,16 @@
5569
6285
  whenHash = null; whenBusy = false;
5570
6286
  byId("jf-err-when").textContent = "";
5571
6287
  var roleSel = byId("jf-when-role");
5572
- roleSel.innerHTML = "";
5573
- // M10: a file trigger watches a FILE; a web-page input is never offered (a job with only page inputs gets the clock options only)
5574
- var fileRoles = ((f && f.roles) || []).filter(function(r){ return !(f.pages && f.pages[r]); });
5575
- fileRoles.forEach(function(r){ var o = document.createElement("option"); o.value = r; o.textContent = r; roleSel.appendChild(o); });
5576
- ["file-updated", "new-file"].forEach(function(k){ var o = byId("jf-when").querySelector('option[value="' + k + '"]'); o.hidden = o.disabled = fileRoles.length === 0; });
6288
+ var fileRoles = whenFileRoles(f), ticketRoles = whenTicketRoles(f);
6289
+ // M13 p4 (signed item 5): MCP offers By hand and Every day at... only; Tickets adds "When a new ticket arrives" to today's options; plain keeps today's
6290
+ var generic = !!f && f.flowType === "mcp";
6291
+ ["file-updated", "new-file"].forEach(function(k){ var o = byId("jf-when").querySelector('option[value="' + k + '"]'); o.hidden = o.disabled = generic || fileRoles.length === 0; });
6292
+ ["weekdays", "weekly"].forEach(function(k){ var o = byId("jf-when").querySelector('option[value="' + k + '"]'); o.hidden = o.disabled = generic; });
6293
+ var tk = byId("jf-when").querySelector('option[value="new-ticket"]'); tk.hidden = tk.disabled = generic || ticketRoles.length === 0; // M12: only a Tickets job with a ticket-list input offers it
5577
6294
  var t = c ? c.trigger : null;
5578
6295
  sel.querySelector('option[value="hand"]').textContent = t ? "Cancel schedule" : "By hand"; // M9 am5: on a scheduled job, By hand reads Cancel schedule
5579
6296
  sel.value = t ? t.kind : "hand";
6297
+ whenFillRoles();
5580
6298
  if(t && t.hour !== undefined){ byId("jf-when-time").value = ("0" + t.hour).slice(-2) + ":" + ("0" + t.minute).slice(-2); }
5581
6299
  if(t && t.day) byId("jf-when-day").value = t.day;
5582
6300
  if(t && t.role) roleSel.value = t.role;
@@ -5584,10 +6302,10 @@
5584
6302
  var refused = !f || !c || !!c.refusal;
5585
6303
  sel.disabled = refused;
5586
6304
  byId("jf-when-day").disabled = byId("jf-when-time").disabled = roleSel.disabled = byId("jf-when-path").disabled = refused;
5587
- byId("jf-when-now").textContent = !c ? "" : (c.refusal ? c.refusal : (c.words ? "Now: " + c.words : ""));
6305
+ byId("jf-when-now").textContent = !c ? "" : (c.refusal ? c.refusal : (c.waitingSay ? c.waitingSay : (c.words ? "Now: " + c.words : ""))); // M13 p5: a schedule signed with the job says its grey words until the first green run
5588
6306
  whenShowSubs(); whenSyncButton();
5589
6307
  }
5590
- function whenEdited(){ whenHash = null; byId("jf-err-when").textContent = ""; whenShowSubs(); whenSyncButton(); }
6308
+ function whenEdited(){ whenHash = null; byId("jf-err-when").textContent = ""; if(this && this.id === "jf-when") whenFillRoles(); whenShowSubs(); whenSyncButton(); }
5591
6309
  ["jf-when", "jf-when-day", "jf-when-time", "jf-when-role"].forEach(function(id){ document.getElementById(id).addEventListener("change", whenEdited); });
5592
6310
  document.getElementById("jf-when-path").addEventListener("input", whenEdited);
5593
6311
  function doWhenSign(){
@@ -5949,6 +6667,7 @@
5949
6667
  if(mode === "resume"){ resumeCtx = null; setMode(modeBeforeResume === "resume" ? "new" : modeBeforeResume); }
5950
6668
  leaveReuse();
5951
6669
  ["jf-name", "jf-job", "jf-cap-money", "jf-dest-folder", "jf-inputs"].forEach(function(id){ byId(id).value = ""; });
6670
+ setFlow("plain", "");
5952
6671
  askWaitEl.value = "1h";
5953
6672
  thinkingEl.checked = false; // per job: unticked for the next one
5954
6673
  clearPick(); // a flow picked in Run a signed flow (Run again too) goes with the rest
@@ -6250,6 +6969,7 @@
6250
6969
  setModelPick(c.provider || "", c.model || ""); thinkingEl.checked = c.thinking === true && !thinkingNone;
6251
6970
  refreshCapNote();
6252
6971
  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");
6972
+ setFlow(c.flowType, c.mcp, c.schedule);
6253
6973
  sessionId = d.draftId;
6254
6974
  sessionLive = CLIENT_TERMINAL_PHASES.indexOf(d.phase) === -1;
6255
6975
  renderThread(d);
@@ -6378,12 +7098,11 @@
6378
7098
  var PV_NOTE_DEFAULT = pvNote.textContent;
6379
7099
  document.getElementById("settings-open").addEventListener("click", function(){
6380
7100
  mainView.hidden = true; settingsView.hidden = false;
6381
- loadProviders(true); loadMoney();
7101
+ loadProviders(true); loadMoney(); loadMcp();
6382
7102
  });
6383
7103
  document.getElementById("settings-back").addEventListener("click", function(){
6384
7104
  settingsView.hidden = true; mainView.hidden = false;
6385
7105
  });
6386
- wireTabs([document.getElementById("stab-providers"), document.getElementById("stab-money")]);
6387
7106
  document.getElementById("stab-money").addEventListener("click", function(){ loadMoney(); });
6388
7107
  document.getElementById("stab-providers").addEventListener("click", function(){ loadProviders(); });
6389
7108
 
@@ -6408,7 +7127,8 @@
6408
7127
  // M4d Providers layout F. One parent block per key (.pv-key): its key band (name, API shape select, Base URL box, the legacy tick, tokens,
6409
7128
  // the Refresh button), a folded summary, and its model lines as child rows (.pv-mrow). The key row owns shape, Base URL and the legacy
6410
7129
  // tick, so a model line can never drift from them. Shape and Base URL are always editable; a change of either saves both (judged together).
6411
- var folds = {}; // slot -> true (unfolded) / false (folded): set once, on first paint (a key with a ticked model starts unfolded), then only the person changes it
7130
+ // slot -> true (unfolded) / false (folded): set once, on first paint (every key starts folded; borrowed-from: bareloop src/panel/index.html@357a482), then only the person changes it
7131
+ var folds = {};
6412
7132
  var typedOpen = {}; // slot -> true while "+ type a model name" is open
6413
7133
  function buildProviderRow(row){
6414
7134
  var key = document.createElement("div");
@@ -6443,6 +7163,7 @@
6443
7163
  function buildModelLine(slot, m){
6444
7164
  var d = document.createElement("div");
6445
7165
  d.className = "pv-mrow";
7166
+ d.tabIndex = -1;
6446
7167
  d.setAttribute("data-model", m.model);
6447
7168
  d.setAttribute("data-testid", "model-line");
6448
7169
  d.innerHTML =
@@ -6554,7 +7275,7 @@
6554
7275
  data.rows.forEach(function(row){
6555
7276
  var key = pvRows.querySelector('.pv-key[data-slot="' + row.slot + '"]');
6556
7277
  if(!key){ key = buildProviderRow(row); pvRows.appendChild(key); }
6557
- if(folds[row.slot] === undefined) folds[row.slot] = row.models.some(function(m){ return m.use === true; });
7278
+ if(folds[row.slot] === undefined) folds[row.slot] = false;
6558
7279
  key.setAttribute("data-open", folds[row.slot] ? "1" : "0");
6559
7280
  var fold = key.querySelector("[data-act=fold]");
6560
7281
  fold.textContent = folds[row.slot] ? "▾" : "▸";
@@ -6726,6 +7447,136 @@
6726
7447
  }, function(){ setNote(msg, true, networkText()); });
6727
7448
  });
6728
7449
 
7450
+
7451
+ // ---- M13 piece 3: Settings > MCP (mock docs/product/m13-settings-mcp-mock.html). One list "Path and MCP": a path is a header, its MCPs sit under it.
7452
+ // The page only READS: GET /api/settings/mcp (names, flags, counts; never a command or a key) and, on a press, POST .../mcp-check for that one MCP.
7453
+ var mcpRoot = document.getElementById("mcp-paths");
7454
+ var mcpData = null;
7455
+ var mcpPathFold = {}; // path -> false when folded (paths start open)
7456
+ var mcpSrvOpen = {}; // path + tab + name -> true when open (MCPs start folded)
7457
+ var mcpMoreOpen = {};
7458
+ var mcpBusy = {};
7459
+ var mcpFail = {}; // path + tab + name -> the sentence of a press that was refused
7460
+ var MCP_TOOLS_SHOWN = 5;
7461
+ function loadMcp(){
7462
+ return getJSON("/api/settings/mcp").then(function(d){ mcpData = d; setNote(document.getElementById("mcp-problem"), true, d.problem || ""); paintMcp(); }, function(e){
7463
+ setNote(document.getElementById("mcp-problem"), true, loadFailureText(e));
7464
+ });
7465
+ }
7466
+ function mcpClock(iso){
7467
+ var d = new Date(iso);
7468
+ if(isNaN(d.getTime())) return "";
7469
+ var two = function(n){ return ("0" + n).slice(-2); };
7470
+ var hm = two(d.getHours()) + ":" + two(d.getMinutes());
7471
+ var now = new Date();
7472
+ if(d.getFullYear() === now.getFullYear() && d.getMonth() === now.getMonth() && d.getDate() === now.getDate()) return { today: true, text: hm };
7473
+ return { today: false, text: d.getFullYear() + "-" + two(d.getMonth() + 1) + "-" + two(d.getDate()) + " " + hm };
7474
+ }
7475
+ function mcpUseLine(u){
7476
+ if(!u || (u.calls === 0 && u.denied === 0)) return "never used";
7477
+ var t = "used " + u.calls + (u.calls === 1 ? " time" : " times") + (u.calls > 0 ? " in " + u.runs + (u.runs === 1 ? " run" : " runs") : "");
7478
+ var c = u.last ? mcpClock(u.last) : "";
7479
+ if(c) t += " · last used " + (c.today ? "today " : "") + c.text;
7480
+ return '<span>' + escapeXml(t) + ' · <span class="' + (u.denied > 0 ? "bad" : "") + '">' + u.denied + ' denied</span></span>';
7481
+ }
7482
+ function mcpSrvHtml(s, pi, si, place){
7483
+ var key = place.path + "\t" + s.name;
7484
+ var open = mcpSrvOpen[key] === true;
7485
+ var ok = s.check && s.check.ok === true;
7486
+ var idle = s.remote || s.shadowedBy !== null;
7487
+ var tools = s.remote ? '<span class="hint">remote server, not supported yet</span>' : s.shadowedBy !== null ? '<span class="hint">same name as above, not used</span>' : idle ? "—" : ok ? s.check.tools.length + (s.check.tools.length === 1 ? " tool" : " tools") : s.check ? "—" : "never checked";
7488
+ var at = s.check ? mcpClock(s.check.at) : "";
7489
+ var checked = idle ? "—" : s.check ? "checked " + (at ? at.text : "") : "never checked";
7490
+ var busy = mcpBusy[key] === true;
7491
+ var btn = idle ? "" : (busy ? '<button class="btn small pv-refbtn" type="button" disabled>checking…</button>' : '<button class="btn small pv-refbtn' + (s.check ? "" : " primary") + '" type="button" data-chk="' + pi + "-" + si + '" data-testid="mcp-check">check tools</button>');
7492
+ var use = idle ? "" : mcpUseLine(s.use);
7493
+ var list = "";
7494
+ if(ok){
7495
+ var more = mcpMoreOpen[key] === true;
7496
+ var shown = more ? s.check.tools : s.check.tools.slice(0, MCP_TOOLS_SHOWN);
7497
+ list = '<div class="pv-mhead mc-t" aria-hidden="true"><span>TOOL</span><span>HINT</span><span class="n">USED</span></div>' +
7498
+ shown.map(function(t){
7499
+ return '<div class="pv-mrow mc-t" tabindex="-1" data-testid="mcp-tool"><span class="pv-m-name"><code>' + escapeXml(t.name) + '</code></span><span>' + escapeXml(t.hint || "—") + '</span><span class="n">' + ((s.use && s.use.tools && s.use.tools[t.name]) || 0) + '</span></div>';
7500
+ }).join("") +
7501
+ (s.check.tools.length > shown.length ? '<div class="pv-more"><button class="pv-add" type="button" data-more="' + pi + "-" + si + '">+' + (s.check.tools.length - shown.length) + ' more</button></div>' : "");
7502
+ } else if(s.check) list = '<div class="pv-more"><span class="hint bad">' + escapeXml(s.check.error || "") + '</span></div>';
7503
+ else if(!idle) list = '<div class="pv-more"><span class="hint">Press check tools to list its tools.</span></div>';
7504
+ if(mcpFail[key]) list += '<div class="pv-more"><span class="hint bad">' + escapeXml(mcpFail[key]) + '</span></div>';
7505
+ return '<div class="pv-key' + (s.shadowedBy !== null ? " faint" : "") + '" data-open="' + (open ? 1 : 0) + '" data-testid="mcp-row">' +
7506
+ '<div class="pv-krow mc-k">' +
7507
+ '<div class="pv-cell pv-name nolbl"><button class="pv-fold" type="button" data-fold="' + pi + "-" + si + '" aria-expanded="' + open + '">' + (open ? "▾" : "▸") + '</button><code>' + escapeXml(s.name) + '</code></div>' +
7508
+ '<div class="pv-cell"><span class="pv-lbl">Tools</span><span>' + tools + (busy ? ' <span class="mc-spin">…</span>' : "") + '</span></div>' +
7509
+ '<div class="pv-cell"><span class="pv-lbl">Checked</span><span>' + escapeXml(checked) + '</span></div>' +
7510
+ '<div class="pv-cell pv-refcell nolbl">' + btn + '</div>' +
7511
+ '</div>' +
7512
+ (use ? '<div class="hint mc-use">' + use + '</div>' : "") +
7513
+ '<div class="pv-models">' + list + '</div>' +
7514
+ '</div>';
7515
+ }
7516
+ function paintMcp(){
7517
+ if(!mcpData) return;
7518
+ var h = '<div class="pv-head mc-k" aria-hidden="true"><span>PATH / MCP</span><span>TOOLS</span><span>CHECKED</span><span></span></div>';
7519
+ mcpData.places.forEach(function(g, pi){
7520
+ var found = g.status === "found", n = g.servers.length, open = mcpPathFold[g.path] !== false;
7521
+ var note = found ? " — " + (g.added ? "(added) — " : "") + n + " server" + (n === 1 ? "" : "s") : " — " + (g.added ? "(added) — " : "") + (g.status === "not-json" ? "can't be read" : "not found");
7522
+ h += '<div class="mc-grp" data-open="' + (open ? 1 : 0) + '" data-testid="mcp-path"><div class="mc-prow' + (found ? "" : " faint") + '">' +
7523
+ (found ? '<button class="pv-fold" type="button" data-pfold="' + pi + '" aria-expanded="' + open + '">' + (open ? "▾" : "▸") + '</button><span class="pv-ok">✓</span>' : '<span class="pv-fold" style="display:inline-block">&nbsp;</span><span>–</span>') +
7524
+ '<span class="mc-grow"><code>' + escapeXml(g.path) + '</code>' + escapeXml(note) + '</span>' +
7525
+ (g.added ? '<button class="btn small" type="button" data-rm="' + pi + '" data-testid="mcp-remove">remove</button>' : "") + '</div>' +
7526
+ (found ? '<div class="mc-kids">' + g.servers.map(function(s, si){ return mcpSrvHtml(s, pi, si, g); }).join("") + '</div>' : "") + '</div>';
7527
+ });
7528
+ mcpRoot.innerHTML = h;
7529
+ }
7530
+ function mcpAt(id){ var a = id.split("-"); var g = mcpData.places[+a[0]]; return { place: g, srv: g.servers[+a[1]] }; }
7531
+ mcpRoot.addEventListener("click", function(e){
7532
+ if(!mcpData) return;
7533
+ var pf = e.target.closest("[data-pfold]");
7534
+ if(pf){ var g = mcpData.places[+pf.getAttribute("data-pfold")]; mcpPathFold[g.path] = mcpPathFold[g.path] === false; paintMcp(); return; }
7535
+ var r = e.target.closest("[data-rm]");
7536
+ if(r){
7537
+ var path = mcpData.places[+r.getAttribute("data-rm")].path;
7538
+ postJSON("/api/settings/mcp-path-remove", { path: path }).then(function(res){
7539
+ if(res.body && res.body.ok) loadMcp(); else setNote(document.getElementById("mcp-problem"), true, settingsRefusal(res));
7540
+ }, function(){ setNote(document.getElementById("mcp-problem"), true, networkText()); });
7541
+ return;
7542
+ }
7543
+ var f = e.target.closest("[data-fold]");
7544
+ if(f){ var x = mcpAt(f.getAttribute("data-fold")); var k = x.place.path + "\t" + x.srv.name; mcpSrvOpen[k] = mcpSrvOpen[k] !== true; paintMcp(); return; }
7545
+ var m = e.target.closest("[data-more]");
7546
+ if(m){ var y = mcpAt(m.getAttribute("data-more")); mcpMoreOpen[y.place.path + "\t" + y.srv.name] = true; paintMcp(); return; }
7547
+ var c = e.target.closest("[data-chk]");
7548
+ if(c){
7549
+ var z = mcpAt(c.getAttribute("data-chk")); var key = z.place.path + "\t" + z.srv.name;
7550
+ mcpBusy[key] = true; delete mcpFail[key]; paintMcp();
7551
+ postJSON("/api/settings/mcp-check", { server: z.srv.name }).then(function(res){
7552
+ mcpBusy[key] = false;
7553
+ if(res.body && res.body.ok) mcpSrvOpen[key] = true; else mcpFail[key] = settingsRefusal(res);
7554
+ loadMcp();
7555
+ }, function(){ mcpBusy[key] = false; mcpFail[key] = networkText(); paintMcp(); });
7556
+ }
7557
+ });
7558
+ // the typed-path box is built on the first press of "+ add a path" (like the Providers tab's typed-model box: the page has no static input but the monthly limit)
7559
+ document.getElementById("mcp-add-open").addEventListener("click", function(){
7560
+ var b = document.getElementById("mcp-add-box");
7561
+ if(!b.firstChild){
7562
+ b.innerHTML = '<input type="text" id="mcp-add-in" data-testid="mcp-add-in" autocomplete="off" spellcheck="false" aria-label="path" placeholder="type a path to an MCP config file"> <button class="btn small" type="button" id="mcp-add-go" data-testid="mcp-add-go">Add</button><div class="hint pv-msg" id="mcp-add-msg" data-testid="mcp-add-msg"></div>';
7563
+ document.getElementById("mcp-add-go").addEventListener("click", mcpAddPath);
7564
+ }
7565
+ b.hidden = !b.hidden; if(!b.hidden) document.getElementById("mcp-add-in").focus();
7566
+ });
7567
+ function mcpAddPath(){
7568
+ var inp = document.getElementById("mcp-add-in"), msg = document.getElementById("mcp-add-msg");
7569
+ var v = inp.value.trim();
7570
+ var say = function(bad, text){ setNote(msg, bad, text); msg.className += " pv-msg"; };
7571
+ if(!v){ say(true, "Type a path first."); return; }
7572
+ postJSON("/api/settings/mcp-path", { path: v }).then(function(res){
7573
+ if(res.body && res.body.ok){ inp.value = ""; say(false, "added"); loadMcp(); }
7574
+ else say(true, settingsRefusal(res));
7575
+ }, function(){ say(true, networkText()); });
7576
+ }
7577
+ wireTabs([document.getElementById("stab-providers"), document.getElementById("stab-mcp"), document.getElementById("stab-money")]);
7578
+ document.getElementById("stab-mcp").addEventListener("click", function(){ loadMcp(); });
7579
+
6729
7580
  // theme toggle
6730
7581
  (function(){
6731
7582
  var root = document.documentElement;