fwdloop 0.10.0 → 0.12.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.
@@ -53,6 +53,7 @@
53
53
  breakpoints, and also owns the horizontal scroll for the Path column
54
54
  on narrow (390px) screens instead of leaving it to .pane-body. */
55
55
  .audit-table-scroll{overflow:auto;max-height:min(60vh,520px);}
56
+ [data-testid="audit-table"] td.am, .audit-group table td.am{display:none;}
56
57
  /* z-index keeps rows from showing through the solid th background as
57
58
  they scroll under it. */
58
59
  [data-testid="audit-table"] th{position:sticky;top:0;z-index:1;}
@@ -225,6 +226,10 @@
225
226
  applies everywhere, so this wraps onto more lines instead of clipping,
226
227
  the same behavior fix #7 already gave phone width alone. */
227
228
  .wf-meta-line{white-space:normal;overflow:visible;text-overflow:clip;min-width:0;}
229
+ /* M4c-fix amendment 2 (g), line 2 of a run row: **word** — plain why. Wraps, never clips. */
230
+ .wf-sign-line{font-size:12px;color:var(--text-dim);white-space:normal;overflow-wrap:anywhere;min-width:0;}
231
+ .wf-sign-line .sign-word,.hdr-verdict .sign-word{color:var(--text);}
232
+ .hdr-verdict{font-size:12px;color:var(--text-dim);min-width:0;overflow-wrap:anywhere;}
228
233
  .wf-meta{font-size:12px;color:var(--text-dim);}
229
234
  .wf-meta + .wf-meta::before{content:" · ";color:var(--text-faint);}
230
235
  .wf-row.selected,.hist-row.selected{border:2px solid var(--accent);border-radius:4px;}
@@ -238,10 +243,19 @@
238
243
  .wf-runs .hist-row{margin-bottom:4px;}
239
244
 
240
245
  .rp-header{display:flex;align-items:center;justify-content:space-between;padding:10px 16px;border-bottom:2px solid var(--border-strong);background:var(--panel);flex-wrap:wrap;gap:8px;}
241
- .rp-header h2{margin:0;font-size:15px;}
242
- .rp-header h2::before{content:"┤ ";color:var(--text-faint);}
243
- .rp-header h2::after{content:" ├";color:var(--text-faint);}
244
- .rp-header-title{display:flex;align-items:center;gap:8px;flex-wrap:wrap;}
246
+ .rp-header h2{margin:0;font-size:15px;min-width:0;overflow-wrap:anywhere;text-transform:none;letter-spacing:normal;}
247
+ /* M4c-fix amendment 2 (k): the header reads like its Runs row — sign + name │ word — why · time; no frame, no capitals. */
248
+ .hdr-name-line{display:inline-flex;align-items:center;gap:8px;min-width:0;max-width:100%;}
249
+ .hdr-sep{color:var(--text-faint);}
250
+ .hdr-time{font-size:11px;color:var(--text-dim);min-width:0;overflow-wrap:anywhere;}
251
+ .hdr-verdict:has(+ .hdr-time:not(:empty))::after{content:" \00B7";}
252
+ .rp-header-title{display:flex;align-items:center;gap:8px;flex-wrap:wrap;min-width:0;max-width:100%;}
253
+ @media (max-width: 640px){
254
+ /* (k) a phone: the same three parts on three lines — sign + name / word — why / time */
255
+ .rp-header-title{flex-direction:column;align-items:flex-start;gap:2px;}
256
+ .rp-header-title .hdr-sep{display:none;}
257
+ .hdr-verdict:has(+ .hdr-time:not(:empty))::after{content:none;}
258
+ }
245
259
  /* item 4: phone-only jump-back link — hidden on desktop (the two panes
246
260
  are already both on screen there, nothing to jump back to). */
247
261
  .back-to-list-link{display:none;font-size:12px;color:var(--accent);text-decoration:underline;background:none;border:none;padding:0;cursor:pointer;}
@@ -273,16 +287,16 @@
273
287
  .map-box{border:1px solid var(--border-strong);padding:10px;overflow-x:auto;margin-top:16px;margin-bottom:14px;background:var(--panel2);text-align:center;}
274
288
  .map-box::before{content:"┤ MAP ├";display:block;font-size:11px;color:var(--text-faint);letter-spacing:0.08em;margin:-2px 0 8px 0;}
275
289
  .map-box svg{display:block;max-width:100%;height:auto;margin:0 auto;}
276
- .map-legend{display:flex;gap:14px;font-size:11px;color:var(--text-dim);margin-top:6px;flex-wrap:wrap;}
277
290
 
278
291
  .step-card{position:relative;border:1px solid var(--border);padding:10px;margin-bottom:8px;background:var(--panel2);}
279
292
  .step-card.running{border:1px double var(--amber);}
280
- /* hamr's 2026-09-27 styling ruling: the card's HEADER line (number, step
281
- name, state chip, close-class chip) is upper case and bold; the state/
282
- close chips keep their own color from `.badge`'s existing classes —
283
- text-transform never touches color. */
284
- .step-card .step-head{display:flex;align-items:center;justify-content:space-between;gap:8px;flex-wrap:wrap;text-transform:uppercase;font-weight:700;}
285
- .step-card h4{margin:0;font-size:13px;}
293
+ /* hamr's 2026-09-27 ruling made the card header bold; his 2026-10-04 ruling (amendment 4) put it in its
294
+ real case — `1 · resume-text [✓] passed [human check]`. The global `h2,h4` uppercase is turned off
295
+ for the card's h4. The chips keep their color from `.badge`. A signed state chip already carries its own
296
+ `[✓]`, so it draws no second pair of brackets (`.sign-badge`). */
297
+ .step-card .step-head{display:flex;align-items:center;justify-content:space-between;gap:8px;flex-wrap:wrap;text-transform:none;font-weight:700;}
298
+ .step-card h4{margin:0;font-size:13px;text-transform:none;letter-spacing:normal;}
299
+ .step-card .sign-badge::before,.step-card .sign-badge::after{content:none;}
286
300
  /* Every OTHER line on the card (goal, actions, granted, stopped reason) —
287
301
  lower case exactly as the data reads, normal weight; never inherits the
288
302
  header's uppercase/bold (same ruling, the non-header half of it). */
@@ -336,6 +350,30 @@
336
350
  `.audit-group h4` (0,1,1) and `.ask-question-heading` (0,1,0) alone, so
337
351
  this never un-bolds the ask question heading. */
338
352
  .audit-group h4.audit-status-header{font-weight:400;}
353
+ /* M4c-fix amendment 2 (f): a foldable step group. The header sits IN the box (not pinned over its top edge),
354
+ so a long header wraps inside its own box and never lands on the next group; a closed group is that one
355
+ header line with a caret and no empty table under it. */
356
+ .audit-group.audit-fold{padding:6px 10px;margin-top:6px;margin-bottom:6px;min-width:0;max-width:100%;box-sizing:border-box;}
357
+ .audit-group.audit-fold h4.audit-status-header{position:static;margin:0;padding:0;background:none;min-width:0;max-width:100%;overflow-wrap:anywhere;word-break:break-word;}
358
+ .audit-group.audit-fold h4.audit-status-header{display:flex;align-items:baseline;gap:6px;overflow:hidden;}
359
+ .audit-group.audit-fold h4.audit-status-header > .badge,.audit-group.audit-fold h4.audit-status-header::before{flex:none;white-space:pre;}
360
+ .audit-fold-name{flex:0 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
361
+ .audit-fold-tail{flex:none;white-space:nowrap;}
362
+ .audit-group.audit-fold h4.audit-status-header::before{content:"\25B6 ";color:var(--text-faint);}
363
+ .audit-group.audit-fold h4.audit-status-header[aria-expanded="true"]::before{content:"\25BC ";}
364
+ .audit-group.audit-fold h4.audit-status-header::after{content:none;}
365
+ @media (max-width: 640px){
366
+ /* (l) a phone: the name is the only thing that shrinks — drop the dots and the word "try", tighten the gaps */
367
+ .audit-group.audit-fold{padding-left:8px;padding-right:8px;}
368
+ .audit-group.audit-fold h4.audit-status-header{gap:3px;font-size:12px;}
369
+ .audit-group.audit-fold h4.audit-status-header > .badge{padding-left:0;padding-right:0;font-size:10px;}
370
+ .audit-group.audit-fold h4.audit-status-header::before{content:"\25B6";}
371
+ .audit-group.audit-fold h4.audit-status-header[aria-expanded="true"]::before{content:"\25BC";}
372
+ .audit-fold-sep,.audit-fold-try{display:none;}
373
+ .audit-fold-n{margin-left:.4em;}
374
+ }
375
+ .audit-group.audit-fold table{margin-top:8px;}
376
+ .audit-group.audit-fold table[hidden]{display:none !important;}
339
377
  /* hamr's 2026-09-27 review: the group header's own state word (g.state,
340
378
  rendered as a <span class="badge STATE">) and its per-try marks
341
379
  (<span class="mark STATE">) reuse the SAME color vocabulary the runs
@@ -401,28 +439,85 @@
401
439
  `buildAuditRowEl` already sets on every cell (never a second, separate
402
440
  label list to keep in sync). No horizontal scroll is possible once
403
441
  every cell is a full-width block. */
404
- @media (max-width: 480px){
405
- [data-testid="audit-table"], .audit-group table{width:100%;}
442
+ /* hamr's exit walk: ONE ROW PER LINE on a phone. Each audit entry is a single flex line — glyph, #attempt,
443
+ step (flat view only), verdict word, short cost, HH:MM — built from the `.am-*` cells `buildAuditRowEl`
444
+ adds (hidden on desktop, where the table is unchanged). Everything the line cut short hides behind a tap: the
445
+ row toggles `.open` and its full step, verdict, gap, refused list and tools show as wrapped lines under it. Every other cell hides. Nothing is wider
446
+ than the viewport: the step cell shrinks and ellipsizes, the rest are nowrap and short. The line never wraps
447
+ (flex-wrap:nowrap, overflow hidden), so a larger system font or a long verdict word shrinks the step and
448
+ ellipsizes rather than pushing cost and time onto a second line. It applies up to 640px — the whole
449
+ phone/narrow-window range, not only 480 (a 500 px window showed the wide table, rows 49-607 px tall). */
450
+ @media (max-width: 640px){
451
+ /* display:block: a table would size itself to its nowrap cells' content and run wider than the screen */
452
+ [data-testid="audit-table"], .audit-group table{display:block;width:100%;max-width:100%;}
406
453
  [data-testid="audit-table"] thead, .audit-group table thead{
407
454
  position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;
408
455
  }
409
456
  [data-testid="audit-table"] tbody, .audit-group table tbody{display:block;}
410
457
  [data-testid="audit-table"] tr, .audit-group table tr{
411
- display:block;border:1px solid var(--border-strong);margin-bottom:8px;padding:4px 0;
458
+ display:flex;flex-wrap:nowrap;align-items:center;column-gap:8px;border-bottom:1px solid var(--border);padding:4px 6px;box-sizing:border-box;max-width:100%;overflow:hidden;
412
459
  }
413
460
  [data-testid="audit-table"] td, .audit-group table td{
414
- display:block;border:none;border-bottom:1px dotted var(--border);padding:4px 8px;
415
- /* fix (2026-09-28): a pre-M4a-2 row's Time cell shows the longer
416
- `atWhy` text ("not recorded (before M4a-2)") instead of a
417
- timestamp — overflow-wrap:anywhere (on top of the existing
418
- break-word/word-break) makes sure that text wraps inside the
419
- cell's own border at 390px instead of spilling past it. */
420
- white-space:normal;overflow-wrap:anywhere;word-break:break-word;max-width:100%;box-sizing:border-box;
461
+ display:none;border:none;padding:0;min-width:0;box-sizing:border-box;white-space:nowrap;
421
462
  }
422
- [data-testid="audit-table"] td:last-child, .audit-group table td:last-child{border-bottom:none;}
423
- [data-testid="audit-table"] td::before, .audit-group table td::before{
424
- content:attr(data-label) ": ";font-weight:700;color:var(--text-dim);
463
+ [data-testid="audit-table"] td.am, .audit-group table td.am,
464
+ [data-testid="audit-table"] td[data-label="Attempt"], .audit-group table td[data-label="Attempt"],
465
+ [data-testid="audit-table"] td[data-label="Step"], .audit-group table td[data-label="Step"],
466
+ [data-testid="audit-table"] td[data-label="Verdict"], .audit-group table td[data-label="Verdict"]{display:block;}
467
+ [data-testid="audit-table"] td[data-label="Attempt"]::before, .audit-group table td[data-label="Attempt"]::before{content:"#";}
468
+ [data-testid="audit-table"] td.am-glyph, .audit-group table td.am-glyph{order:1;flex:0 0 auto;}
469
+ [data-testid="audit-table"] td[data-label="Attempt"], .audit-group table td[data-label="Attempt"]{order:2;flex:0 0 auto;color:var(--text-dim);}
470
+ [data-testid="audit-table"] td[data-label="Step"], .audit-group table td[data-label="Step"]{order:3;flex:1 1 0;overflow:hidden;text-overflow:ellipsis;}
471
+ [data-testid="audit-table"] td[data-label="Verdict"], .audit-group table td[data-label="Verdict"]{order:4;flex:0 1 auto;max-width:9em;overflow:hidden;text-overflow:ellipsis;}
472
+ [data-testid="audit-table"] td.am-cost, .audit-group table td.am-cost{order:5;flex:0 0 auto;}
473
+ [data-testid="audit-table"] td.am-time, .audit-group table td.am-time{order:6;flex:0 0 auto;color:var(--text-dim);}
474
+ /* no step cell (grouped view): the verdict takes the slack so cost and time sit at the right */
475
+ .audit-group table td[data-label="Verdict"]{flex:1 1 0;}
476
+ /* EVERY entry opens on a tap (not only one with a gap): the line above shortens the step and verdict with an
477
+ ellipsis, so the tap is the one way to read all of it. The open block is wrapped lines under the one line. */
478
+ tr.audit-tap{cursor:pointer;}
479
+ tr.audit-tap td.am-glyph::after{content:"\25B8";margin-left:2px;color:var(--text-faint);}
480
+ tr.audit-tap.open td.am-glyph::after{content:"\25BE";}
481
+ [data-testid="audit-table"] td.am.am-detail, .audit-group table td.am.am-detail{display:none;}
482
+ [data-testid="audit-table"] tr.open, .audit-group table tr.open{flex-wrap:wrap;}
483
+ [data-testid="audit-table"] tr.open td.am-detail, .audit-group table tr.open td.am-detail{
484
+ display:block;order:7;flex:0 0 100%;min-width:0;white-space:normal;overflow-wrap:anywhere;padding:4px 0 2px;color:var(--text-dim);
425
485
  }
486
+ td.am-detail .am-d{margin:0 0 3px;}
487
+ td.am-detail .am-d b{color:var(--text);font-weight:600;}
488
+ }
489
+
490
+ /* M4d piece 4: the Settings view (a sibling of #main-view, opened from the header). Layout borrowed from bareloop:
491
+ one provider table inside a scrolling .table-wrap, a KEYS strip, a money strip. Inputs are 16px so a phone does not zoom. */
492
+ /* borrowed-from: bareloop src/panel/index.html@5a5a811 */
493
+ .settings-view{flex:1;min-height:0;overflow:auto;display:flex;flex-direction:column;min-width:0;}
494
+ .settings-view .pane-body{flex:none;overflow:visible;}
495
+ .settings-header{display:flex;align-items:center;gap:12px;padding:10px 16px;border-bottom:2px solid var(--border-strong);background:var(--panel);}
496
+ .settings-header h2{margin:0;font-size:15px;display:inline;}
497
+ .settings-header h2::before{content:"┤ ";color:var(--text-faint);}
498
+ .settings-header h2::after{content:" ├";color:var(--text-faint);}
499
+ .money-strip{display:grid;grid-template-columns:repeat(3, 1fr);gap:12px;align-items:end;padding:10px;border:1px solid var(--border-strong);background:var(--panel2);}
500
+ .money-item{min-width:0;}
501
+ .money-item label{display:block;font-size:11px;font-weight:700;color:var(--text-dim);margin-bottom:2px;}
502
+ .money-value{font-size:16px;font-weight:700;padding:6px 0;overflow-wrap:anywhere;}
503
+ .money-item input{width:100%;height:44px;box-sizing:border-box;}
504
+ .keyfile-strip{position:relative;border:1px solid var(--border-strong);padding:12px 12px 8px;background:var(--panel2);margin:14px 0;font-size:12px;display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap;}
505
+ .keyfile-strip::before{content:"┤ KEYS ├";position:absolute;top:-9px;left:10px;background:var(--panel2);padding:0 4px;font-size:11px;color:var(--text-faint);letter-spacing:0.08em;}
506
+ .keyfile-strip-main{display:flex;flex-direction:column;gap:3px;flex:1;min-width:0;overflow-wrap:anywhere;}
507
+ .keyfile-strip-actions{display:flex;gap:6px;flex:none;}
508
+ .keyfile-strip code{background:var(--bg);border:1px solid var(--border-strong);padding:1px 5px;font-size:11px;color:var(--amber);overflow-wrap:anywhere;}
509
+ .settings-view input,.settings-view select{font:inherit;padding:6px 8px;border:1px solid var(--border-strong);border-radius:0;background:var(--bg);color:var(--text);}
510
+ .pv-table td,.pv-table th{white-space:nowrap;vertical-align:top;}
511
+ .pv-table select,.pv-table input{min-height:32px;max-width:190px;box-sizing:border-box;}
512
+ .pv-table .hint{display:block;margin-top:3px;}
513
+ /* the Test cell keeps ONE width whatever the result says ("testing…", "OK · 312 ms", a long failure note) */
514
+ .pv-table td.pv-test-cell{width:180px;min-width:180px;max-width:180px;}
515
+ .pv-table .pv-test-result,.pv-table .pv-msg,.pv-table .pv-balance-result{white-space:normal;overflow-wrap:anywhere;}
516
+ .pv-table td.pv-price-cell{width:170px;min-width:170px;max-width:170px;}
517
+ .hint.bad{color:var(--red);}
518
+ .table-wrap{overflow-x:auto;border:1px solid var(--border-strong);background:var(--panel2);max-width:100%;}
519
+ @media (max-width: 899px){
520
+ .money-strip{grid-template-columns:1fr 1fr;}
426
521
  }
427
522
  </style>
428
523
  </head>
@@ -437,10 +532,73 @@
437
532
  </div>
438
533
  <div class="topbar-right">
439
534
  <span class="hint" id="host-line"></span>
535
+ <button class="btn small" id="settings-open" type="button" data-testid="settings-open">&#9881; Settings</button>
440
536
  <button class="theme-toggle" id="theme-toggle" type="button" aria-label="Toggle light/dark theme">&#9789;</button>
441
537
  </div>
442
538
  </header>
443
539
 
540
+ <!-- borrowed-from: bareloop src/panel/index.html@5a5a811 -->
541
+ <div class="settings-view" id="settings-view" data-testid="settings-view" hidden>
542
+ <div class="settings-header">
543
+ <button class="btn small" id="settings-back" type="button" data-testid="settings-back">&larr; Back</button>
544
+ <h2>Settings</h2>
545
+ </div>
546
+ <div class="tabrow" role="tablist" aria-label="Settings views">
547
+ <button role="tab" id="stab-providers" aria-controls="spanel-providers" aria-selected="true" data-testid="settings-tab-providers">Providers</button>
548
+ <button role="tab" id="stab-money" aria-controls="spanel-money" aria-selected="false" data-testid="settings-tab-money">Money &amp; limits</button>
549
+ </div>
550
+ <div class="pane-body">
551
+ <section id="spanel-providers" class="tabpanel active" role="tabpanel" aria-labelledby="stab-providers">
552
+ <div class="keyfile-strip" data-testid="keys-strip">
553
+ <div class="keyfile-strip-main">
554
+ <span>Put <code>NAME=key</code> lines in <code id="keys-path" data-testid="keys-path">~/.config/fwdloop/.env</code>, then Reload keys &mdash; each row below says whether its key is set. Only names are listed; keys never reach this page.</span>
555
+ <span class="hint bad" id="keys-refusal" data-testid="keys-refusal"></span>
556
+ </div>
557
+ <div class="keyfile-strip-actions">
558
+ <button class="btn small" id="reload-keys" type="button" data-testid="reload-keys">Reload keys</button>
559
+ </div>
560
+ </div>
561
+ <div class="table-wrap" data-testid="provider-table-wrap">
562
+ <table class="pv-table" data-testid="provider-table">
563
+ <thead>
564
+ <tr><th>Key</th><th>Name</th><th>API shape</th><th>Base URL</th><th>Test</th><th>Tokens used</th><th>Balance</th><th>In $/1M</th><th>Cached in $/1M</th><th>Out $/1M</th></tr>
565
+ </thead>
566
+ <tbody id="pv-rows"></tbody>
567
+ </table>
568
+ </div>
569
+ <div class="hint" id="pv-note" data-testid="pv-note" style="margin-top:6px;">Test asks the provider for its model list &mdash; it costs nothing. A price left empty uses the default; a typed price applies from the next model call on.</div>
570
+ </section>
571
+ <section id="spanel-money" class="tabpanel" role="tabpanel" aria-labelledby="stab-money" hidden>
572
+ <div class="money-strip" data-testid="money-strip">
573
+ <div class="money-item">
574
+ <label>$ month / to date</label>
575
+ <div class="money-value" id="ml-usd" data-testid="ml-usd">&hellip;</div>
576
+ </div>
577
+ <div class="money-item">
578
+ <label>Tokens month / to date</label>
579
+ <div class="money-value" id="ml-tokens" data-testid="ml-tokens">&hellip;</div>
580
+ </div>
581
+ <div class="money-item">
582
+ <label for="ml-money">Monthly money limit ($)</label>
583
+ <input id="ml-money" type="text" inputmode="decimal" placeholder="blank = no limit" data-testid="ml-money">
584
+ </div>
585
+ </div>
586
+ <div class="hint" id="ml-note" data-testid="ml-note" style="margin-top:6px;">Limits are yours. The agent can never change them. A run whose cap is more than what is left this month does not start.</div>
587
+ <div class="hint" id="ml-extra" data-testid="ml-extra"></div>
588
+ <div class="hint" id="ml-msg" data-testid="ml-msg"></div>
589
+ <h4 style="margin-top:20px;font-size:13px;">Per-provider breakdown</h4>
590
+ <div class="table-wrap">
591
+ <table data-testid="provider-breakdown-table">
592
+ <thead>
593
+ <tr><th>Provider</th><th>$ month / to date</th><th>minutes month / to date</th><th>tokens</th></tr>
594
+ </thead>
595
+ <tbody id="ml-breakdown"></tbody>
596
+ </table>
597
+ </div>
598
+ </section>
599
+ </div>
600
+ </div>
601
+
444
602
  <div class="main" id="main-view">
445
603
 
446
604
  <nav class="left-pane" aria-label="Job navigation" id="left-pane-anchor">
@@ -491,10 +649,10 @@
491
649
  <div class="rp-header">
492
650
  <button type="button" class="back-to-list-link" id="back-to-list" data-testid="back-to-list">&#8593; list</button>
493
651
  <div class="rp-header-title">
494
- <span class="dot grey" id="active-wf-dot"></span>
495
- <h2 id="active-wf-name">(none selected)</h2>
496
- <span class="badge" id="active-wf-verdict">—</span>
497
- <span class="badge" id="active-wf-date">—</span>
652
+ <span class="hdr-name-line"><span class="dot grey" id="active-wf-dot"></span><h2 id="active-wf-name">(none selected)</h2></span>
653
+ <span class="hdr-sep" aria-hidden="true">&#9474;</span>
654
+ <span class="hdr-verdict" id="active-wf-verdict">—</span>
655
+ <span class="hdr-time" id="active-wf-date">—</span>
498
656
  </div>
499
657
  </div>
500
658
 
@@ -617,9 +775,8 @@
617
775
  "use strict";
618
776
 
619
777
  var PORT = "__FWDLOOP_PANEL_PORT__";
620
- // M4b piece 1: per-process answer token, replaced at serve time; sent only as
621
- // the x-fwdloop-token header of the two POSTs (postJSON below).
622
- var TOKEN = "__FWDLOOP_PANEL_TOKEN__";
778
+ // M4c-fix item 2: the page carries NO token. The panel link sets an HttpOnly cookie; every
779
+ // request (reads and the two POSTs) is authenticated by that cookie, sent by the browser itself.
623
780
  document.getElementById("host-line").textContent = "127.0.0.1:" + PORT;
624
781
 
625
782
  function wireTabs(tabButtons){
@@ -642,20 +799,28 @@
642
799
 
643
800
  // ---- fetch helpers. Reads are GET. The ONLY non-GET requests on this page are
644
801
  // the two POSTs below (M4b): /api/answer (a human clicking a door) and
645
- // /api/resume ("try the resume again"). The token goes in the request header
646
- // and nowhere else — never the DOM, a URL, storage or a log. Same-origin. ----
802
+ // /api/resume ("try the resume again"). Auth is the HttpOnly cookie
803
+ // (never the DOM, a URL, storage or a log). Same-origin. ----
647
804
  function getJSON(path){
648
805
  return fetch(path, { method: "GET", headers: { accept: "application/json" } }).then(function(r){
649
- if(!r.ok) throw new Error(path + ": HTTP " + r.status);
806
+ if(!r.ok){ var err = new Error(path + ": HTTP " + r.status); err.status = r.status; throw err; }
650
807
  return r.json();
651
808
  });
652
809
  }
810
+ // The ONE place a failed load becomes words (amendment 2 (b)): a plain sentence, never the thrown
811
+ // message (it carries the path and the HTTP code), never a status number.
812
+ function loadFailureText(e){
813
+ var status = e && e.status;
814
+ if(status === 403) return "The panel does not recognise this page. Open the link the terminal printed.";
815
+ if(status === 404) return "This run is no longer there.";
816
+ return "Could not load this; reload the page.";
817
+ }
653
818
  // Resolves { status, body } for ANY HTTP status (a refusal is data to show by
654
819
  // name, never an exception); rejects only on a network failure.
655
820
  function postJSON(path, payload){
656
821
  return fetch(path, {
657
822
  method: "POST",
658
- headers: { "content-type": "application/json", accept: "application/json", "x-fwdloop-token": TOKEN },
823
+ headers: { "content-type": "application/json", accept: "application/json" },
659
824
  body: JSON.stringify(payload),
660
825
  credentials: "same-origin"
661
826
  }).then(function(r){
@@ -718,6 +883,12 @@
718
883
  var short = d.toLocaleTimeString();
719
884
  return '<span title="' + escapeXml(full) + '">' + escapeXml(short) + '</span>';
720
885
  }
886
+ // phone one-liner: local HH:MM only; a row with no recorded time reads a dash (never a made-up time).
887
+ function auditShortTime(r){
888
+ var d = new Date(r.at);
889
+ if(typeof r.at !== "string" || isNaN(d.getTime())) return "—";
890
+ return ("0" + d.getHours()).slice(-2) + ":" + ("0" + d.getMinutes()).slice(-2);
891
+ }
721
892
  function duration(ms){
722
893
  if(typeof ms !== "number" || ms < 0) return "unknown";
723
894
  var s = ms / 1000;
@@ -726,6 +897,14 @@
726
897
  if(rem === 60){ m += 1; rem = 0; }
727
898
  return m + "m" + String(rem).padStart(2, "0") + "s";
728
899
  }
900
+ // A signed wait in words: "30 min", "2 h"; anything not a whole minute falls back to `duration`.
901
+ function waitText(ms){
902
+ if(typeof ms !== "number" || !(ms > 0)) return "unknown";
903
+ var m = ms / 60000;
904
+ if(m >= 60 && m % 60 === 0) return (m / 60) + " h";
905
+ if(m >= 1 && Number.isInteger(m)) return m + " min";
906
+ return duration(ms);
907
+ }
729
908
  // A readable local date/time instead of a raw ISO timestamp (fix #5) — an
730
909
  // unparseable value still shows the raw string (never blank/nothing), so
731
910
  // a books bug is visible rather than silently swallowed.
@@ -741,10 +920,14 @@
741
920
  // parked on a human) reads "waiting on you", matching the SAME words the
742
921
  // run-row `[·]` glyph already uses (src/panel/data.js's computeGlyph) —
743
922
  // never the bracket glyph `[▶]`, which the scope reserves for "running".
923
+ // M4c-fix amendment 2 (g): a step's own sign + word come from the SAME one table the run rows use (the server's
924
+ // SIGN_WORDS, sent on the run detail as `signWords`); the page keeps no table of its own. Not started: no sign.
925
+ var signWords = {};
926
+ var STEP_SIGN = { done: "[\u2713]", stopped: "[\u2717]", waiting: "[\u00b7]" };
744
927
  function stateWord(state){
745
928
  if(state === "pending") return "not started";
746
- if(state === "waiting") return "waiting on you";
747
- return state; // "done" / "stopped"
929
+ var g = STEP_SIGN[state];
930
+ return g && signWords[g] ? g + " " + signWords[g] : state;
748
931
  }
749
932
  // fwdloop's close-class vocabulary (M4a scope item 4): `green` -> "cited"
750
933
  // (a mechanical, exact-match close), `softgreen` -> "shape" (a shape/
@@ -805,6 +988,8 @@
805
988
  if(verdict === "paused") return "paused for you";
806
989
  if(verdict === "refused") return "refused — no reason given";
807
990
  if(verdict === "ask-timeout" || verdict === "ask-expired") return "expired waiting for you";
991
+ if(verdict === "ask-reopened") return "reopened by you";
992
+ if(verdict === "lock-removed") return "old lock removed by you";
808
993
  if(verdict === "green") return "passed";
809
994
  if(verdict === "hitl") return "human check";
810
995
  if(verdict === "not-done") return "not done";
@@ -817,7 +1002,7 @@
817
1002
  // would misread a pause as a failure (fix #3).
818
1003
  function verdictGlyph(verdict, closeClass){
819
1004
  if(closeClass === "hitl" && verdict === "red") return null;
820
- if(verdict === "paused" || verdict === "refused" || verdict === "ask-timeout" || verdict === "ask-expired") return null;
1005
+ if(verdict === "paused" || verdict === "refused" || verdict === "ask-timeout" || verdict === "ask-expired" || verdict === "ask-reopened" || verdict === "lock-removed") return null;
821
1006
  return verdictPassed(verdict) ? "✓" : "✗";
822
1007
  }
823
1008
  // The run-row glyph strings src/panel/data.js's computeGlyph emits are
@@ -825,6 +1010,12 @@
825
1010
  // CSS color class off them, never re-derives the glyph itself.
826
1011
  // the dot's class list: colour from the glyph, `pulse` only when the server
827
1012
  // says this sign is [▶] running or [·] waiting on you (data.js glyphPulses).
1013
+ // M4c-fix amendment 2 (g): one bold word after every sign, then " — " and the plain line. The word comes from the
1014
+ // server's one sign->word table (data.js SIGN_WORDS) on `word`; this only draws it, the same in Runs, Inbox and the header.
1015
+ function signHtml(word, line, fallback){
1016
+ if(!word) return escapeXml(fallback || "unknown");
1017
+ return '<b class="sign-word">' + escapeXml(word) + '</b>' + (line ? " &mdash; " + escapeXml(line) : "");
1018
+ }
828
1019
  function dotClass(g, pulse){ return "dot " + glyphClass(g) + (pulse ? " pulse" : ""); }
829
1020
  function glyphClass(g){
830
1021
  if(g === "[✓]") return "green";
@@ -956,8 +1147,16 @@
956
1147
  }
957
1148
  return {perRow:1, boxW:Math.max(MIN_BOX_W, Math.min(usableW, ceiling))};
958
1149
  }
1150
+ // M4c-fix amendment 2 (l): a line longer than the box is cut with … (the whole name stays in the node's <title>
1151
+ // and on its step card below the map).
1152
+ function mapLabel(line, maxChars){
1153
+ return line.length <= maxChars ? line : line.slice(0, Math.max(1, maxChars - 1)) + "\u2026";
1154
+ }
959
1155
  function wrapTitleLines(text, maxWidth){
960
1156
  var maxChars = Math.max(1, Math.floor((maxWidth - TITLE_HPAD) / CHAR_W));
1157
+ return wrapTitleLinesRaw(text, maxChars).map(function(l){ return mapLabel(l, maxChars); });
1158
+ }
1159
+ function wrapTitleLinesRaw(text, maxChars){
961
1160
  if(text.length <= maxChars) return [text];
962
1161
  var words = text.split(' ');
963
1162
  var line1 = '', i = 0;
@@ -1008,7 +1207,7 @@
1008
1207
  // into a jump to the Audit tab's matching group is wired AFTER
1009
1208
  // insertion (renderStepMap, below), never inline here (this function
1010
1209
  // only ever builds a markup string).
1011
- body += '<g class="map-step" data-emits="' + escapeXml(s.emits) + '" tabindex="0" role="button" aria-label="open ' + escapeXml(s.emits) + ' in Audit">';
1210
+ body += '<g class="map-step" data-emits="' + escapeXml(s.emits) + '" tabindex="0" role="button" aria-label="open ' + escapeXml(s.emits) + ' in Audit"><title>' + escapeXml(stepTitleText(idx, s)) + '</title>';
1012
1211
  body += '<rect x="' + x + '" y="' + y + '" width="' + boxW + '" height="' + boxH +
1013
1212
  '" rx="0" fill="var(--panel2)" stroke="' + colors.stroke + '" stroke-width="2"></rect>';
1014
1213
  if(lines.length === 1){
@@ -1064,21 +1263,6 @@
1064
1263
  });
1065
1264
  return '<svg width="' + totalW + '" height="' + totalH + '" viewBox="0 0 ' + totalW + ' ' + totalH + '" role="img" aria-label="step map">' + body + '</svg>';
1066
1265
  }
1067
- // Legend glyphs match the scope's own vocabulary (fix #4): `[✓]` done,
1068
- // `[✗]` stopped, `[·]` waiting on you (the default/grey dot — never the
1069
- // amber `[▶]`, which the scope reserves for "running", a state this panel
1070
- // cannot tell apart from "died" at all today — M4a's own open POC
1071
- // question). "not started" gets no dot/glyph at all, so it can never be
1072
- // confused with a reserved one.
1073
- function stepMapLegendHTML(){
1074
- return '<div class="map-legend">' +
1075
- '<span><span class="dot green"></span>done</span>' +
1076
- '<span><span class="dot red"></span>stopped</span>' +
1077
- '<span><span class="dot"></span>waiting on you</span>' +
1078
- '<span>not started</span>' +
1079
- '<span>⤾ dashed = retry</span>' +
1080
- '</div>';
1081
- }
1082
1266
  var lastSteps = null;
1083
1267
  var lastWidth = null;
1084
1268
  function mapAvailWidth(wrapper){
@@ -1112,7 +1296,7 @@
1112
1296
  wrapper.hidden = false;
1113
1297
  var w = mapAvailWidth(wrapper);
1114
1298
  lastWidth = w;
1115
- mount.innerHTML = buildStepMapSVG(steps, w) + stepMapLegendHTML();
1299
+ mount.innerHTML = buildStepMapSVG(steps, w);
1116
1300
  wireMapClicks(mount);
1117
1301
  }
1118
1302
  function reflowMap(){
@@ -1122,7 +1306,7 @@
1122
1306
  if(w === null || w === lastWidth) return;
1123
1307
  lastWidth = w;
1124
1308
  var mount = document.getElementById("map-mount");
1125
- mount.innerHTML = buildStepMapSVG(lastSteps, w) + stepMapLegendHTML();
1309
+ mount.innerHTML = buildStepMapSVG(lastSteps, w);
1126
1310
  wireMapClicks(mount);
1127
1311
  }
1128
1312
  if(typeof ResizeObserver !== "undefined"){
@@ -1165,8 +1349,8 @@
1165
1349
  row.innerHTML =
1166
1350
  '<span class="wf-line1"><span class="' + dotClass(r.glyph, r.pulse) + '"></span>' +
1167
1351
  '<span class="wf-name" title="' + escapeXml(fullName) + '">' + escapeXml(fullName) + '</span></span>' +
1352
+ '<span class="wf-sign-line" data-testid="run-sign-word">' + signHtml(r.word, r.line, r.label) + '</span>' +
1168
1353
  '<span class="wf-meta-line">' +
1169
- '<span class="wf-meta">' + escapeXml(r.label || "unknown") + '</span>' +
1170
1354
  '<span class="wf-meta">' + escapeXml(runSpendText(r)) + '</span>' +
1171
1355
  '<span class="wf-meta">' + escapeXml(runAtText(r)) + '</span>' +
1172
1356
  '</span>';
@@ -1176,20 +1360,34 @@
1176
1360
  }
1177
1361
 
1178
1362
  // M4c amendment 1 (a): the ONE place a click on a run in Runs decides where it lands.
1179
- // Right side: that run, on the Run tab. A run with an ask waiting on the human also
1180
- // moves the left side to the Inbox with that ask's row selected; any other run leaves
1181
- // the left side on Runs.
1363
+ // Right side: that run, on the Run tab, at once. Whether the run has an ask waiting on the human (or is
1364
+ // stuck, which counts as waiting: M4c amendment 2 (b)) is decided from THAT RUN's own asks, fetched on
1365
+ // the click — never from the cached list row, which can be up to LISTS_POLL_MS old (a run that has just
1366
+ // parked, been reopened or answered would read wrong). If it does, the left side moves to the Inbox with
1367
+ // that ask's row selected (the Inbox is refreshed first) and the right side moves to the Ask tab, where its
1368
+ // buttons are (M4c-fix amendment 2 (i)). "Needs you" = waiting, stuck, or expired with the Reopen offer (the
1369
+ // same `!open && reopen` test answerControls uses); any other run leaves the left side on Runs, right on Run.
1370
+ function askNeedingYou(result){
1371
+ var found = null;
1372
+ ((result && result.asks) || []).forEach(function(a){ if(a.waiting || a.stuck || (!a.open && a.reopen)) found = a; });
1373
+ return found;
1374
+ }
1182
1375
  function openRunFromRuns(r, rowEl){
1183
- if(r.waiting){
1184
- var inboxId = "inbox-row-" + r.flow + "-" + r.runId + "-" + r.waitingAskId;
1185
- var inboxRow = Array.prototype.find.call(document.querySelectorAll(".inbox-row"), function(el){ return el.getAttribute("data-testid") === inboxId; }) || null;
1186
- selectRun(r.flow, r.runId, inboxRow, ".inbox-row", r.waitingAskId);
1187
- document.getElementById("tab-inbox").click();
1188
- } else {
1189
- selectRun(r.flow, r.runId, rowEl, ".hist-row");
1190
- }
1376
+ selectRun(r.flow, r.runId, rowEl, ".hist-row");
1191
1377
  document.getElementById("tab-run").click();
1192
1378
  scrollRunIntoViewMobile();
1379
+ getJSON("/api/runs/" + encodeURIComponent(r.flow) + "/" + encodeURIComponent(r.runId) + "/asks").then(function(result){
1380
+ // the user already clicked another run: this answer is for a run they left
1381
+ if(currentFlow !== r.flow || currentRunId !== r.runId) return;
1382
+ var ask = askNeedingYou(result);
1383
+ if(!ask) return;
1384
+ reloadLists();
1385
+ var inboxId = "inbox-row-" + r.flow + "-" + r.runId + "-" + ask.askId;
1386
+ var inboxRow = Array.prototype.find.call(document.querySelectorAll(".inbox-row"), function(el){ return el.getAttribute("data-testid") === inboxId; }) || null;
1387
+ selectRun(r.flow, r.runId, inboxRow, ".inbox-row", ask.askId);
1388
+ document.getElementById("tab-inbox").click();
1389
+ document.getElementById("tab-ask").click();
1390
+ }).catch(function(){ /* unreadable books: the run stays open on the Run tab, the left side stays on Runs */ });
1193
1391
  }
1194
1392
 
1195
1393
  // ---- History view: every row exactly as /api/runs returned it. ----
@@ -1336,8 +1534,8 @@
1336
1534
  row.innerHTML =
1337
1535
  '<span class="wf-line1"><span class="wf-caret">' + (hasOtherRuns ? (expanded ? "▼" : "▶") : "") + '</span><span class="' + dotClass(g.lastGlyph, g.lastRow.pulse) + '"></span>' +
1338
1536
  '<span class="wf-name" title="' + escapeXml(wfFullName) + '">' + escapeXml(wfFullName) + '</span></span>' +
1537
+ '<span class="wf-sign-line" data-testid="run-sign-word">' + signHtml(g.lastRow.word, g.lastRow.line, g.lastLabel) + '</span>' +
1339
1538
  '<span class="wf-meta-line">' +
1340
- '<span class="wf-meta">' + escapeXml(g.lastLabel || "unknown") + '</span>' +
1341
1539
  '<span class="wf-meta">' + escapeXml(runSpendText(g.lastRow)) + '</span>' +
1342
1540
  '<span class="wf-meta">' + escapeXml(runAtText(g.lastRow)) + '</span>' +
1343
1541
  '<span class="wf-meta">' + g.runCount + ' run' + (g.runCount === 1 ? '' : 's') + '</span>' +
@@ -1601,9 +1799,10 @@
1601
1799
  var verdict = document.getElementById("active-wf-verdict");
1602
1800
  var date = document.getElementById("active-wf-date");
1603
1801
 
1802
+ if(detail.signWords) signWords = detail.signWords;
1604
1803
  name.textContent = detail.flow + " (" + detail.runId + ")";
1605
1804
  dot.className = dotClass(detail.glyph, detail.pulse);
1606
- verdict.textContent = detail.label || "unknown";
1805
+ verdict.innerHTML = signHtml(detail.word, detail.line, detail.label);
1607
1806
  // browser re-walk bug #4: this is the DATE field — it must use its own
1608
1807
  // why (`detail.atWhy`), never `detail.outcomeWhy` (a different book
1609
1808
  // fact borrowed by mistake). A parked run's ask.json `askedAt` is a
@@ -1640,7 +1839,7 @@
1640
1839
  var modelText = detail.model || (detail.modelWhy || "no model call recorded yet");
1641
1840
  var closeText = closeClassSummaryText(detail.steps) || (detail.stepsWhy || "no steps recorded");
1642
1841
  box.innerHTML =
1643
- '<div class="summary-headline"><span class="' + dotClass(detail.glyph, detail.pulse) + '"></span><b>' + escapeXml(detail.label || "unknown") + '</b> &middot; <span class="num">' + escapeXml(spendText) + '</span></div>' +
1842
+ '<div class="summary-headline"><span class="' + dotClass(detail.glyph, detail.pulse) + '"></span>' + signHtml(detail.word, detail.line, detail.label) + ' &middot; <span class="num">' + escapeXml(spendText) + '</span></div>' +
1644
1843
  '<div class="summary-row" data-testid="summary-model"><span class="sum-label">model:</span><span class="sum-val">' + escapeXml(modelText) + '</span></div>' +
1645
1844
  '<div class="summary-row"><span class="sum-label">steps:</span><span class="sum-val">' + stepsText + '</span></div>' +
1646
1845
  '<div class="summary-row" data-testid="summary-why"><span class="sum-label">why:</span><span class="sum-val">' + escapeXml(detail.stopReason || detail.stopReasonWhy || "not recorded") + '</span></div>' +
@@ -1695,8 +1894,8 @@
1695
1894
  div.textContent = text;
1696
1895
  return div;
1697
1896
  }
1698
- // The card's HEADER line: "N · step-name [state] [close class]" — upper
1699
- // case/bold from CSS (`.step-card .step-head`), the state/close chips
1897
+ // The card's HEADER line: "N · step-name [state] [close class]" — real
1898
+ // case, bold from CSS (`.step-card .step-head`), the state/close chips
1700
1899
  // keeping their own `.badge` color. `auditStateClass` is the SAME
1701
1900
  // function the Audit tab's group headers use to color their own state
1702
1901
  // word — never a second color scheme for the Run tab's cards.
@@ -1707,7 +1906,7 @@
1707
1906
  h4.textContent = (idx + 1) + " · " + box.emits;
1708
1907
  head.appendChild(h4);
1709
1908
  var stateBadge = document.createElement("span");
1710
- stateBadge.className = "badge " + auditStateClass(box.state);
1909
+ stateBadge.className = "badge " + auditStateClass(box.state) + (STEP_SIGN[box.state] ? " sign-badge" : "");
1711
1910
  stateBadge.setAttribute("data-testid", "step-card-state-" + idx);
1712
1911
  stateBadge.textContent = stateWord(box.state);
1713
1912
  head.appendChild(stateBadge);
@@ -1809,12 +2008,28 @@
1809
2008
  var header = row.querySelector("h4");
1810
2009
  if(table && table.hidden){
1811
2010
  table.hidden = false;
2011
+ row.classList.remove("closed");
2012
+ auditExpanded[step] = true;
1812
2013
  if(header) header.setAttribute("aria-expanded", "true");
1813
2014
  }
1814
2015
  if(typeof row.scrollIntoView === "function") row.scrollIntoView({ block: "center" });
1815
2016
  row.classList.add("audit-group-highlight");
1816
2017
  setTimeout(function(){ row.classList.remove("audit-group-highlight"); }, 1600);
1817
2018
  }
2019
+ // What a phone tap shows under the one-line entry: everything the line cut short, in full, as wrapped lines.
2020
+ // Only fields the row actually has — a line with nothing to say is left out, never filled with a made-up value.
2021
+ function auditDetailHtml(r, word, actionText, isRejectRow){
2022
+ var lines = [["step", r.step], ["result", word], ["action", actionText]];
2023
+ if(!isRejectRow && r.gap) lines.push(["gap", r.gap]);
2024
+ if(Array.isArray(r.refused) && r.refused.length > 0){
2025
+ lines.push(["refused", r.refused.map(function(x){ return x.verb + " " + x.path + " (" + x.rule + ")"; }).join("; ")]);
2026
+ }
2027
+ if(Array.isArray(r.ungranted) && r.ungranted.length > 0) lines.push(["not granted, called anyway", r.ungranted.join(", ")]);
2028
+ lines.push(["close", closeClassLabel(r.class)], ["cost", auditCostCellText(r)]);
2029
+ var when = readableDateTime(r.at);
2030
+ lines.push(["time", (typeof r.atWhy === "string" && r.atWhy.length > 0) ? r.atWhy : (when || "unknown")]);
2031
+ return lines.map(function(l){ return "<div class=\"am-d\"><b>" + escapeXml(l[0]) + ":</b> " + escapeXml(l[1]) + "</div>"; }).join("");
2032
+ }
1818
2033
  // ONE row-cell builder for both views — `includeStep` controls only
1819
2034
  // whether the Step cell is rendered (Grouped drops it; the group's own
1820
2035
  // header already names the step). Column order: Attempt, [Step], Action,
@@ -1842,8 +2057,20 @@
1842
2057
  "<td data-label=\"Cost\">" + escapeXml(auditCostCellText(r)) + "</td>" +
1843
2058
  "<td data-label=\"Verdict\"><span class=\"badge " + badgeClass + "\">" + escapeXml(word) + "</span></td>" +
1844
2059
  "<td data-label=\"Close\">" + escapeXml(closeClassLabel(r.class)) + "</td>" +
1845
- "<td data-label=\"Time\">" + auditTimeCellHtml(r) + "</td>";
2060
+ "<td data-label=\"Time\">" + auditTimeCellHtml(r) + "</td>" +
2061
+ // phone-only one-line cells (CSS shows these and hides the rest below 640px; hidden on desktop)
2062
+ "<td class=\"am am-glyph\" aria-hidden=\"true\">" + escapeXml(glyph || "·") + "</td>" +
2063
+ "<td class=\"am am-cost\">" + escapeXml(money(r.usd, r.spendComplete)) + "</td>" +
2064
+ "<td class=\"am am-time\">" + escapeXml(auditShortTime(r)) + "</td>" +
2065
+ "<td class=\"am am-detail\">" + auditDetailHtml(r, word, actionText, isRejectRow) + "</td>";
1846
2066
  tr.innerHTML = cells;
2067
+ // every entry opens on a tap, by finger or keyboard; only the phone layout shows what opening reveals
2068
+ tr.className = "audit-tap";
2069
+ tr.tabIndex = 0;
2070
+ tr.setAttribute("aria-expanded", "false");
2071
+ var toggle = function(){ tr.setAttribute("aria-expanded", tr.classList.toggle("open") ? "true" : "false"); };
2072
+ tr.addEventListener("click", toggle);
2073
+ tr.addEventListener("keydown", function(ev){ if(ev.key === "Enter" || ev.key === " "){ ev.preventDefault(); toggle(); } });
1847
2074
  return tr;
1848
2075
  }
1849
2076
  // ---- hamr's 2026-09-27 exit-check review #2: the Audit tab's All/Human/
@@ -1915,22 +2142,41 @@
1915
2142
  stateSpan.setAttribute("data-testid", "audit-group-state");
1916
2143
  stateSpan.textContent = g.state;
1917
2144
  h4.appendChild(stateSpan);
1918
- h4.appendChild(document.createTextNode(" · " + g.step + " · " + duration(g.timeMs) + " · " + (g.cost || "cost unknown")));
1919
- if(typeof g.tokensTotal === "number") h4.appendChild(document.createTextNode(" · " + g.tokensTotal + " tokens"));
1920
- h4.appendChild(document.createTextNode(" · try " + g.tryCount + " "));
2145
+ // M4c-fix amendment 2 (l): the title is `[sign] name · cost · try N ✗✓` — the name alone is cut with … (own flex child),
2146
+ // cost and tries never; time and tokens live in each try's detail. The whole name is in the title attribute and aria-label.
2147
+ var nameSpan = document.createElement("span");
2148
+ nameSpan.className = "audit-fold-name";
2149
+ nameSpan.setAttribute("data-testid", "audit-group-name");
2150
+ nameSpan.title = g.step;
2151
+ nameSpan.textContent = g.step;
2152
+ h4.appendChild(nameSpan);
2153
+ var tail = document.createElement("span");
2154
+ tail.className = "audit-fold-tail";
2155
+ // the dots and the word "try" are their own spans so a phone can drop them (keeping cost, N and the marks)
2156
+ function tailPart(cls, text){ var sp = document.createElement("span"); sp.className = cls; sp.textContent = text; tail.appendChild(sp); }
2157
+ tailPart("audit-fold-sep", "· ");
2158
+ tail.appendChild(document.createTextNode(g.cost || "cost unknown"));
2159
+ tailPart("audit-fold-sep", " · ");
2160
+ tailPart("audit-fold-try", "try ");
2161
+ tailPart("audit-fold-n", g.tryCount + " ");
1921
2162
  g.tryMarks.forEach(function(mark){
1922
2163
  var markSpan = document.createElement("span");
1923
2164
  markSpan.className = "mark " + auditMarkClass(mark);
1924
2165
  markSpan.textContent = mark;
1925
- h4.appendChild(markSpan);
2166
+ tail.appendChild(markSpan);
1926
2167
  });
2168
+ h4.appendChild(tail);
1927
2169
  return h4;
1928
2170
  }
1929
2171
  // Grouped view: one section per step, server order preserved (first-seen
1930
2172
  // order of `r.step` across this run's own rows — never re-sorted).
1931
2173
  // review item #1: COLLAPSED by default — a map/step-card click
1932
2174
  // (`openAuditGroup`) is the only thing that force-expands one.
2175
+ var auditExpanded = {}; // step -> true/false once a human toggled it; reset when the run changes
2176
+ var auditExpandedRun = null;
1933
2177
  function renderAuditGroups(result){
2178
+ var runKey = currentFlow + "/" + currentRunId;
2179
+ if(auditExpandedRun !== runKey){ auditExpanded = {}; auditExpandedRun = runKey; }
1934
2180
  var container = document.getElementById("audit-groups");
1935
2181
  container.innerHTML = "";
1936
2182
  if(!result || result.empty) return;
@@ -1949,24 +2195,42 @@
1949
2195
  // COLLAPSED by default now (`aria-expanded` starts "false", the
1950
2196
  // table starts `hidden`) — expanding is something a human (or a
1951
2197
  // map/step-card jump) does, never the initial state.
2198
+ // M4c-fix amendment 2 (f): a step with any failed try (a row with a gap) starts OPEN so its gap is
2199
+ // seen without a click; the rest start closed. A manual toggle wins on re-render (auditExpanded).
2200
+ var failed = (g.rows || []).some(function(r){ return !!r.gap; });
2201
+ var isOpen = Object.prototype.hasOwnProperty.call(auditExpanded, g.step) ? auditExpanded[g.step] : failed;
2202
+ wrap.classList.add("audit-fold");
2203
+ if(!isOpen) wrap.classList.add("closed");
1952
2204
  var header = buildAuditGroupHeaderEl(g);
1953
2205
  header.setAttribute("role", "button");
1954
2206
  header.setAttribute("tabindex", "0");
1955
- header.setAttribute("aria-expanded", "false");
2207
+ header.setAttribute("aria-expanded", isOpen ? "true" : "false");
1956
2208
  header.setAttribute("aria-label", auditGroupHeaderText(g));
1957
2209
  header.style.cursor = "pointer";
1958
2210
  wrap.appendChild(header);
1959
2211
  var table = document.createElement("table");
1960
- table.hidden = true;
2212
+ table.hidden = !isOpen;
1961
2213
  table.innerHTML = "<thead><tr><th>Attempt</th><th>Action</th><th>Gap</th><th>Cost</th><th>Verdict</th><th>Close</th><th>Time</th></tr></thead><tbody></tbody>";
1962
2214
  var tbody = table.querySelector("tbody");
1963
2215
  rows.forEach(function(r){ tbody.appendChild(buildAuditRowEl(r, false)); });
1964
2216
  table.setAttribute("data-testid", "audit-table-grouped-" + g.step);
1965
2217
  wrap.appendChild(table);
2218
+ // M4c-fix amendment 2 (j): a step with exactly one try opens that try's detail with the group, closes with it
2219
+ // (the same `.open` tap-detail the row's own tap toggles; only the phone layout shows it).
2220
+ function syncSingleRow(open){
2221
+ if(rows.length !== 1) return;
2222
+ var only = tbody.firstChild;
2223
+ only.classList.toggle("open", open);
2224
+ only.setAttribute("aria-expanded", open ? "true" : "false");
2225
+ }
2226
+ syncSingleRow(isOpen);
1966
2227
  function toggleAuditGroup(){
1967
2228
  var next = table.hidden;
1968
2229
  table.hidden = !next;
2230
+ wrap.classList.toggle("closed", !next);
2231
+ auditExpanded[g.step] = next;
1969
2232
  header.setAttribute("aria-expanded", next ? "true" : "false");
2233
+ syncSingleRow(next);
1970
2234
  }
1971
2235
  header.addEventListener("click", toggleAuditGroup);
1972
2236
  header.addEventListener("keydown", function(e){
@@ -2176,15 +2440,20 @@
2176
2440
  // src/panel/data.js works out the boundary server-side, off the run's
2177
2441
  // full audit-row order, so the client no longer needs a second,
2178
2442
  // separately-fetched copy of the audit rows to cross-reference (fix #6).
2179
- getJSON(base).then(paintRun).catch(function(e){
2443
+ // same guard as reloadRun: a late reply for a run the user already left paints nothing and writes no polling flag
2444
+ var still = function(){ return currentFlow === flow && currentRunId === runId; };
2445
+ getJSON(base).then(function(d){ if(still()) paintRun(d); }).catch(function(e){
2446
+ if(!still()) return;
2447
+ openRunLive = false; // unreadable books: the list rate, not 2 s forever
2180
2448
  document.getElementById("run-empty").hidden = false;
2181
- document.getElementById("run-empty").textContent = "failed to load run: " + e.message;
2449
+ document.getElementById("run-empty").textContent = loadFailureText(e);
2182
2450
  document.getElementById("run-content").hidden = true;
2183
2451
  });
2184
- getJSON(base + "/audit").then(renderAudit).catch(function(){ renderAudit(null); });
2185
- getJSON(base + "/job").then(renderJob).catch(function(){ renderJob(null); });
2186
- getJSON(base + "/asks").then(function(result){ renderAsk(result, focusAskId || null); }).catch(function(e){
2187
- renderAsk(null, null, e.message);
2452
+ // the same late-reply guard on audit, job and asks: a reply for a run the user already left paints nothing
2453
+ getJSON(base + "/audit").then(function(a){ if(still()) renderAudit(a); }).catch(function(){ if(still()) renderAudit(null); });
2454
+ getJSON(base + "/job").then(function(j){ if(still()) renderJob(j); }).catch(function(){ if(still()) renderJob(null); });
2455
+ getJSON(base + "/asks").then(function(result){ if(still()) renderAsk(result, focusAskId || null); }).catch(function(e){
2456
+ if(still()) renderAsk(null, null, loadFailureText(e));
2188
2457
  });
2189
2458
  }
2190
2459
 
@@ -2231,7 +2500,7 @@
2231
2500
  function reloadRun(flow, runId, skipLists){
2232
2501
  var base = "/api/runs/" + encodeURIComponent(flow) + "/" + encodeURIComponent(runId);
2233
2502
  var still = function(){ return currentFlow === flow && currentRunId === runId; };
2234
- var detailP = getJSON(base).then(function(d){ if(still()) paintRun(d); return d; }).catch(function(){ return null; });
2503
+ var detailP = getJSON(base).then(function(d){ if(still()) paintRun(d); return d; }).catch(function(){ if(still()) openRunLive = false; return null; }); // unreadable books: the list rate, not 2 s forever
2235
2504
  var asksP = getJSON(base + "/asks").then(function(a){
2236
2505
  if(still()){
2237
2506
  // the Ask tab is drawn from the books AND the page's own pending answer ("working…" block)
@@ -2241,7 +2510,7 @@
2241
2510
  if(next === null || next !== lastSig.asks){ lastSig.asks = renderAsk(a, null) ? next : null; }
2242
2511
  }
2243
2512
  return a;
2244
- }).catch(function(e){ if(still()){ lastSig.asks = null; renderAsk(null, null, e.message); } return null; });
2513
+ }).catch(function(e){ if(still()){ lastSig.asks = null; renderAsk(null, null, loadFailureText(e)); } return null; });
2245
2514
  getJSON(base + "/audit").then(function(a){
2246
2515
  if(!still()) return;
2247
2516
  var next = sig(a);
@@ -2264,8 +2533,9 @@
2264
2533
  var listsDue = catchUp || (Date.now() - lastListsAt) >= LISTS_POLL_MS;
2265
2534
  var wasLive = openRunLive;
2266
2535
  var selP;
2267
- // the open run's own panes: every tick, but only while it is live (or being watched), or on catch-up
2268
- if(sel && (openRunLive || watchIsSelected || catchUp)) selP = reloadRun(currentFlow, currentRunId, true);
2536
+ // the open run's own panes: every tick while it is live (or being watched); a finished run (or one whose
2537
+ // books can't be read) at the list rate, so a late change shows without a re-click; or on catch-up
2538
+ if(sel && (openRunLive || watchIsSelected || catchUp || listsDue)) selP = reloadRun(currentFlow, currentRunId, true);
2269
2539
  else selP = Promise.resolve([null, null]);
2270
2540
  if(listsDue) reloadLists();
2271
2541
  // the watched run, when it is not the one on screen: read it for its outcome only (no paint — `still()` is false)
@@ -2281,6 +2551,8 @@
2281
2551
  function stopLive(){ live = null; }
2282
2552
  // What the books say now, in words (pure; `null` = keep waiting).
2283
2553
  function liveOutcome(askId, detail, asks){
2554
+ // amendment 1 (a): within the watch the saved answer turned out to have no readable time — say why; the doors come back
2555
+ if(asks && asks.resume && asks.resume.state === "broken") return { done: true, cls: "refused", text: asks.resume.label + ": " + (asks.resume.reason || "") };
2284
2556
  if(asks && asks.resume && asks.resume.state === "not-started") return { done: true, cls: null, text: null };
2285
2557
  var list = (asks && asks.asks) || [];
2286
2558
  var fresh = list.find(function(a){ return a.waiting && a.askId !== askId; });
@@ -2339,8 +2611,8 @@
2339
2611
  runsFilterBar.refresh();
2340
2612
  }
2341
2613
  }).catch(function(e){
2342
- document.getElementById("wf-list").innerHTML = '<div class="hint">failed to load: ' + escapeXml(e.message) + '</div>';
2343
- document.getElementById("history-list").innerHTML = '<div class="hint">failed to load: ' + escapeXml(e.message) + '</div>';
2614
+ document.getElementById("wf-list").innerHTML = '<div class="hint">' + escapeXml(loadFailureText(e)) + '</div>';
2615
+ document.getElementById("history-list").innerHTML = '<div class="hint">' + escapeXml(loadFailureText(e)) + '</div>';
2344
2616
  });
2345
2617
 
2346
2618
  // ---- shared text-node helper — book text (question/draft/artifact
@@ -2365,7 +2637,7 @@
2365
2637
  // Ask tab, focused on that one ask. The answer doors live in the Ask tab. --
2366
2638
  function stopStatusLine(row){
2367
2639
  if(row.waiting) return "time left: " + duration(row.timeLeftMs);
2368
- if(row.stuck) return row.stuckLabel;
2640
+ if(row.stuck) return row.stuckLine || row.stuckLabel;
2369
2641
  if(row.working) return "working on your " + row.working + "…";
2370
2642
  if(row.open && row.resume) return row.resume.label;
2371
2643
  var bits = [row.status];
@@ -2403,7 +2675,10 @@
2403
2675
  flowName.className = "wf-name";
2404
2676
  head.appendChild(flowName);
2405
2677
  wrap.appendChild(head);
2406
- wrap.appendChild(textDiv("wf-meta", stopStatusLine(row)));
2678
+ var meta = textDiv("wf-sign-line", "");
2679
+ meta.setAttribute("data-testid", "inbox-sign-word");
2680
+ meta.innerHTML = signHtml(row.word, stopStatusLine(row), stopStatusLine(row));
2681
+ wrap.appendChild(meta);
2407
2682
  if(typeof row.question === "string"){
2408
2683
  wrap.appendChild(textDiv("step-meta", "question: " + row.question));
2409
2684
  } else if(row.questionWhy){
@@ -2446,7 +2721,7 @@
2446
2721
  }
2447
2722
  getJSON("/api/inbox").then(function(result){ renderInbox(result.rows || [], result.openCount); }).catch(function(e){
2448
2723
  lastSig.inbox = null;
2449
- document.getElementById("inbox-list").innerHTML = '<div class="hint">failed to load: ' + escapeXml(e.message) + '</div>';
2724
+ document.getElementById("inbox-list").innerHTML = '<div class="hint">' + escapeXml(loadFailureText(e)) + '</div>';
2450
2725
  });
2451
2726
 
2452
2727
  // ---- Ask tab (M4a-1): every ask of the SELECTED run, collapsed by
@@ -2465,6 +2740,7 @@
2465
2740
  var bits = [ask.status];
2466
2741
  if(ask.reason) bits.push("reason: " + ask.reason);
2467
2742
  if(ask.answeredAt) bits.push("answered " + (readableDateTime(ask.answeredAt) || ask.answeredAt));
2743
+ if(ask.why) bits.push(ask.why);
2468
2744
  return textDiv("wf-meta", bits.join(" · "));
2469
2745
  }
2470
2746
  // ---- M4b piece 4: answer doors. The panel is a CLIENT of the arbiter: it sends
@@ -2482,19 +2758,27 @@
2482
2758
  }
2483
2759
  function answerControls(ask, resume, pending){
2484
2760
  if(pending && ask && pending.askId === ask.askId){
2485
- return { kind: "working", text: pendingText(pending), why: "no answer doors: the answer was sent" };
2761
+ return { kind: "working", text: pendingText(pending) };
2762
+ }
2763
+ // amendment 1 (b): an expired ask offers one human action, the reopen (never an answer word)
2764
+ if(ask && !ask.open && ask.reopen){
2765
+ return { kind: "expired", waitMs: ask.reopen.waitMs, late: !!ask.reopen.late, line: ask.reopen.why, why: "no answer doors: this ask expired — reopen it to answer" };
2486
2766
  }
2487
2767
  if(!ask || !ask.open){
2488
- return { kind: "none", why: "no answer doors: this ask is " + ((ask && ask.status) || "closed") + " — there is nothing left to answer" };
2768
+ return { kind: "none", why: "This ask is " + ((ask && ask.status) || "closed") + ". There is nothing left to answer." };
2489
2769
  }
2490
2770
  if(resume && resume.askId === ask.askId){
2771
+ // amendment 1 (a): a saved answer with no readable time gives the doors back, with a note saying why
2772
+ if(resume.state === "broken"){
2773
+ return { kind: "doors", note: resume.label + (resume.reason ? " " + resume.reason : "") };
2774
+ }
2491
2775
  if(resume.state === "starting"){
2492
- return { kind: "starting", label: resume.label, why: "no answer doors: this ask already has a saved answer" };
2776
+ return { kind: "starting", text: "Your answer is saved; the run is starting up." };
2493
2777
  }
2494
2778
  if(resume.state === "not-started"){
2495
- return { kind: "stuck", label: resume.label, lockPath: resume.lockPath || null, reason: resume.reason || "no reason recorded", why: "no answer doors: this ask already has a saved answer" };
2779
+ return { kind: "stuck", lockPath: resume.lockPath || null };
2496
2780
  }
2497
- return { kind: "none", why: "no answer doors: " + resume.label };
2781
+ return { kind: "none", why: resume.label + "." };
2498
2782
  }
2499
2783
  return { kind: "doors" };
2500
2784
  }
@@ -2525,10 +2809,53 @@
2525
2809
  el.textContent = mine ? m.text : "";
2526
2810
  });
2527
2811
  }
2528
- function refusalText(r){
2529
- var b = r.body;
2530
- var name = b && typeof b.red === "string" ? b.red : (r.text || "no detail");
2531
- return "HTTP " + r.status + " — " + name;
2812
+ // Every refusal the page shows is a plain sentence — never an HTTP status, a refusal code, an askId or a path.
2813
+ // `r` is { status, body, text } from postJSON; `decision` is the answer word of an answer click (else null).
2814
+ // The server's own refusal name (`refused`) is matched first; a library refusal is matched by what it says.
2815
+ function networkText(){ return "Could not reach the panel, so nothing is confirmed. Check it is still running; the header above shows what the books say."; }
2816
+ // A redo or rerun needs a reason. The page only saves the round trip: the library still judges every answer.
2817
+ function reasonMissing(decision, value){ return (decision === "redo" || decision === "rerun") && String(value).trim() === ""; }
2818
+ function blankReasonText(decision){ return "Please write a reason for the " + (decision === "rerun" ? "rerun" : "redo") + "."; }
2819
+ function refusalText(r, decision){
2820
+ var byName = {
2821
+ "already-resuming": "This run is already carrying on. Wait a moment, then look again.",
2822
+ "no-saved-answer": "There is no saved answer to continue from.",
2823
+ "run-ended": "This run has already ended.",
2824
+ "lock-has-holder": "Something is working on this run now, so the old lock was left alone. Look again in a moment.",
2825
+ "no-lock": "The old lock is already gone. Continue the run instead.",
2826
+ "lock-outside-run": "That run can't be found.",
2827
+ "flow-outside-root": "That run can't be found.",
2828
+ "bad-flow": "That run can't be found.",
2829
+ "bad-runId": "That run can't be found.",
2830
+ "askid-required": "That click was not understood. Reload the page and try again.",
2831
+ "body-not-json": "That click was not understood. Reload the page and try again.",
2832
+ "body-too-large": "That is too long to send. Please shorten your reason.",
2833
+ "cookie-missing-or-wrong": "The panel does not recognise this page. Open the link the terminal printed.",
2834
+ "origin-not-own": "The panel does not recognise this page. Open the link the terminal printed.",
2835
+ "host-not-own-address": "The panel does not recognise this page. Open the link the terminal printed.",
2836
+ "internal": "Something went wrong inside the panel. Nothing was changed."
2837
+ };
2838
+ var byWords = [
2839
+ [/needs a non-blank reason/, null],
2840
+ [/expired at/, "The time to answer ran out. Reopen it to give it more time."],
2841
+ [/already answered/, "This ask was already answered."],
2842
+ [/answer saved in time|has an answer saved/, "Your answer is saved. Continue the run instead."],
2843
+ [/has not expired/, "This ask has not run out of time yet."],
2844
+ [/already reopened/, "This ask was already reopened."],
2845
+ [/unrecognised decision/, "That answer is not recognised."],
2846
+ [/no readable artifact/, "There is no draft to accept."],
2847
+ [/no open ask|is unknown for run/, "This ask is no longer open."],
2848
+ [/nothing was reopened/, "Could not clear the late answer; nothing was reopened."],
2849
+ [/could not write|set aside/, "Your answer could not be saved. Nothing was changed."]
2850
+ ];
2851
+ var b = r && r.body;
2852
+ var name = b && typeof b.refused === "string" ? b.refused : "";
2853
+ var red = b && typeof b.red === "string" ? b.red : "";
2854
+ if(Object.prototype.hasOwnProperty.call(byName, name)) return byName[name];
2855
+ for(var i = 0; i < byWords.length; i++){
2856
+ if(byWords[i][0].test(red)) return byWords[i][1] === null ? blankReasonText(decision) : byWords[i][1];
2857
+ }
2858
+ return "That did not go through. Reload the page to see where this run stands.";
2532
2859
  }
2533
2860
  // While a POST is out the buttons are disabled (stops a double click) — nothing else is ever disabled.
2534
2861
  function setBusy(root, busy){
@@ -2539,6 +2866,12 @@
2539
2866
  function sendAnswer(root, ask, ctx, decision){
2540
2867
  var ta = root.querySelector("textarea");
2541
2868
  var payload = { flow: ctx.flow, runId: ctx.runId, askId: ask.askId, decision: decision, reason: ta ? ta.value : "" };
2869
+ var hintEl = root.querySelector("[data-testid='reason-hint']");
2870
+ if(hintEl){ hintEl.hidden = true; hintEl.textContent = ""; }
2871
+ if(reasonMissing(decision, payload.reason)){
2872
+ if(hintEl){ hintEl.textContent = blankReasonText(decision); hintEl.hidden = false; }
2873
+ return;
2874
+ }
2542
2875
  say(ctx.flow, ctx.runId, "info", "sending " + decision + "…");
2543
2876
  setBusy(root, true);
2544
2877
  postJSON("/api/answer", payload).then(function(r){
@@ -2546,29 +2879,67 @@
2546
2879
  delete reasonDrafts[ask.askId];
2547
2880
  pendingAnswer = { flow: ctx.flow, runId: ctx.runId, askId: ask.askId, decision: decision, draftNo: ctx.draftNo };
2548
2881
  answerMsg = null; paintAnswerMsg();
2882
+ // a broken earlier answer was moved aside to make room: say so, once
2883
+ if(r.body.setAside) say(ctx.flow, ctx.runId, "info", "your earlier saved answer was broken; it is kept aside. This answer is saved.");
2549
2884
  startLive(ctx.flow, ctx.runId, ask.askId);
2550
2885
  } else {
2551
- say(ctx.flow, ctx.runId, "refused", refusalText(r));
2886
+ say(ctx.flow, ctx.runId, "refused", refusalText(r, decision));
2552
2887
  }
2553
2888
  return reloadRun(ctx.flow, ctx.runId);
2554
2889
  }).catch(function(e){
2555
- say(ctx.flow, ctx.runId, "refused", "network failure: " + e.message + " — nothing is confirmed; what the books say is shown in the ask header above");
2890
+ say(ctx.flow, ctx.runId, "refused", networkText());
2556
2891
  return reloadRun(ctx.flow, ctx.runId);
2557
2892
  }).then(function(){ if(root.isConnected) setBusy(root, false); });
2558
2893
  }
2559
2894
  function sendResumeAgain(root, ctx, askId){
2560
- say(ctx.flow, ctx.runId, "info", "asking for the resume again…");
2895
+ say(ctx.flow, ctx.runId, "info", "continuing the run…");
2561
2896
  setBusy(root, true);
2562
2897
  postJSON("/api/resume", { flow: ctx.flow, runId: ctx.runId }).then(function(r){
2563
2898
  if(r.status === 202 && r.body && r.body.ok){
2564
- say(ctx.flow, ctx.runId, "info", "resume requested — waiting for the run's books to show whether it took over");
2899
+ say(ctx.flow, ctx.runId, "info", "asked the run to continue — waiting to see that it picked up your answer");
2565
2900
  startLive(ctx.flow, ctx.runId, askId);
2566
2901
  } else {
2567
2902
  say(ctx.flow, ctx.runId, "refused", refusalText(r));
2568
2903
  }
2569
2904
  return reloadRun(ctx.flow, ctx.runId);
2570
2905
  }).catch(function(e){
2571
- say(ctx.flow, ctx.runId, "refused", "network failure: " + e.message + " — nothing is confirmed; what the books say is shown in the ask header above");
2906
+ say(ctx.flow, ctx.runId, "refused", networkText());
2907
+ return reloadRun(ctx.flow, ctx.runId);
2908
+ }).then(function(){ if(root.isConnected) setBusy(root, false); });
2909
+ }
2910
+ // M4c-fix amendment 2 (h): the human's one button for a lock with no recorded holder. One confirm, then a gated POST;
2911
+ // the server re-checks the lock at that moment, removes it, records it in the audit and continues the run. Cancel = nothing.
2912
+ var REMOVE_LOCK_CONFIRM = "Only do this if nothing else is working on this run. Remove it?";
2913
+ function sendRemoveLock(root, ctx, askId){
2914
+ if(!window.confirm(REMOVE_LOCK_CONFIRM)) return;
2915
+ say(ctx.flow, ctx.runId, "info", "removing the old lock…");
2916
+ setBusy(root, true);
2917
+ postJSON("/api/remove-lock", { flow: ctx.flow, runId: ctx.runId }).then(function(r){
2918
+ if(r.status === 202 && r.body && r.body.ok){
2919
+ say(ctx.flow, ctx.runId, "info", "old lock removed; asked the run to continue — waiting to see that it picked up your answer");
2920
+ startLive(ctx.flow, ctx.runId, askId);
2921
+ } else {
2922
+ say(ctx.flow, ctx.runId, "refused", refusalText(r));
2923
+ }
2924
+ return reloadRun(ctx.flow, ctx.runId);
2925
+ }).catch(function(e){
2926
+ say(ctx.flow, ctx.runId, "refused", networkText());
2927
+ return reloadRun(ctx.flow, ctx.runId);
2928
+ }).then(function(){ if(root.isConnected) setBusy(root, false); });
2929
+ }
2930
+ function sendReopen(root, ctx, askId){
2931
+ say(ctx.flow, ctx.runId, "info", "reopening…");
2932
+ setBusy(root, true);
2933
+ postJSON("/api/reopen", { flow: ctx.flow, runId: ctx.runId, askId: askId }).then(function(r){
2934
+ if(r.status === 200 && r.body && r.body.ok){
2935
+ say(ctx.flow, ctx.runId, "info", "reopened until " + (readableDateTime(r.body.expiresAt) || r.body.expiresAt)
2936
+ + (r.body.setAside ? "; your late answer is kept aside" : ""));
2937
+ } else {
2938
+ say(ctx.flow, ctx.runId, "refused", refusalText(r));
2939
+ }
2940
+ return reloadRun(ctx.flow, ctx.runId);
2941
+ }).catch(function(e){
2942
+ say(ctx.flow, ctx.runId, "refused", networkText());
2572
2943
  return reloadRun(ctx.flow, ctx.runId);
2573
2944
  }).then(function(){ if(root.isConnected) setBusy(root, false); });
2574
2945
  }
@@ -2587,6 +2958,11 @@
2587
2958
  root.className = "answer-doors";
2588
2959
  root.setAttribute("data-testid", "answer-doors");
2589
2960
  if(model.kind === "doors"){
2961
+ if(model.note){
2962
+ var note = textDiv("answer-msg refused", model.note);
2963
+ note.setAttribute("data-testid", "answer-note");
2964
+ root.appendChild(note);
2965
+ }
2590
2966
  var idSafe = "reason-" + String(ask.askId).replace(/[^A-Za-z0-9_-]/g, "_");
2591
2967
  var lab = document.createElement("label");
2592
2968
  lab.setAttribute("for", idSafe);
@@ -2597,9 +2973,14 @@
2597
2973
  ta.setAttribute("data-testid", "answer-reason");
2598
2974
  ta.setAttribute("data-askid", ask.askId);
2599
2975
  ta.value = reasonDrafts[ask.askId] || "";
2600
- ta.addEventListener("input", function(){ reasonDrafts[ask.askId] = ta.value; });
2976
+ ta.addEventListener("input", function(){ reasonDrafts[ask.askId] = ta.value; reasonHint.hidden = true; });
2601
2977
  root.appendChild(lab);
2602
2978
  root.appendChild(ta);
2979
+ // shown next to the box when a redo or rerun is clicked with no reason (page-side check, before anything is sent)
2980
+ var reasonHint = textDiv("answer-msg refused", "");
2981
+ reasonHint.hidden = true;
2982
+ reasonHint.setAttribute("data-testid", "reason-hint");
2983
+ root.appendChild(reasonHint);
2603
2984
  var bar = document.createElement("div");
2604
2985
  bar.className = "actions-row";
2605
2986
  bar.setAttribute("data-testid", "action-bar");
@@ -2618,15 +2999,28 @@
2618
2999
  wk.appendChild(document.createTextNode(model.text));
2619
3000
  root.appendChild(wk);
2620
3001
  } else if(model.kind === "starting"){
2621
- root.appendChild(textDiv("hint", model.label + " — " + model.why));
3002
+ root.appendChild(textDiv("hint", model.text));
3003
+ } else if(model.kind === "expired"){
3004
+ // [!] expired: the time ran out. One button, the human's: a fresh window of the same signed length on the same draft.
3005
+ var bar3 = document.createElement("div");
3006
+ bar3.className = "actions-row";
3007
+ bar3.appendChild(makeButton("Reopen for another " + waitText(model.waitMs), "btn-reopen", function(){ sendReopen(root, ctx, ask.askId); }));
3008
+ root.appendChild(bar3);
3009
+ root.appendChild(textDiv("hint", model.line));
2622
3010
  } else if(model.kind === "stuck"){
2623
- root.appendChild(textDiv("answer-msg stuck", model.label + ": " + model.reason));
2624
- if(model.lockPath) root.appendChild(textDiv("hint", "lock file: " + model.lockPath));
2625
- root.appendChild(textDiv("hint", model.why + ". Trying again starts a resume only; it cannot answer."));
3011
+ // stuck: an answer is saved and no resume took it. One button, one line under it saying why.
2626
3012
  var bar2 = document.createElement("div");
2627
3013
  bar2.className = "actions-row";
2628
- bar2.appendChild(makeButton("Try the resume again", "btn-resume-again", function(){ sendResumeAgain(root, ctx, ask.askId); }));
3014
+ if(model.lockPath){
3015
+ // the lock has no recorded holder, so "Continue the run" could only be refused: the one button removes it, then continues
3016
+ bar2.appendChild(makeButton("Remove the old lock", "btn-remove-lock", function(){ sendRemoveLock(root, ctx, ask.askId); }));
3017
+ } else {
3018
+ bar2.appendChild(makeButton("Continue the run", "btn-resume-again", function(){ sendResumeAgain(root, ctx, ask.askId); }));
3019
+ }
2629
3020
  root.appendChild(bar2);
3021
+ root.appendChild(textDiv("hint", model.lockPath
3022
+ ? "An old resume lock is in the way."
3023
+ : "Your answer is saved; the run stopped before using it."));
2630
3024
  } else {
2631
3025
  root.appendChild(textDiv("hint", model.why));
2632
3026
  }
@@ -2702,9 +3096,10 @@
2702
3096
  // never re-derived here), when it was asked, and its status. `stepWhy` is
2703
3097
  // shown verbatim (never a guessed step name) when the books can't name
2704
3098
  // one — the honest word "before" a real value never invents.
2705
- function blockMetaText(block){
3099
+ function blockMetaText(block, ctx){
2706
3100
  var ask = block.current;
2707
- var bits = [];
3101
+ // every ask says which run it belongs to: the buttons below act on THIS run only
3102
+ var bits = [ctx.flow + " (" + ctx.runId + ")"];
2708
3103
  var stepBit = typeof block.stepName === "string" && block.stepName.length > 0
2709
3104
  ? block.stepName + (typeof block.stepLine === "number" ? " (line " + block.stepLine + ")" : "")
2710
3105
  : (ask.stepWhy || "step not determinable");
@@ -2738,7 +3133,7 @@
2738
3133
  badge.textContent = ask.open ? "·" : ask.status;
2739
3134
  }
2740
3135
  metaLine.appendChild(badge);
2741
- metaLine.appendChild(textDiv("wf-meta", blockMetaText(block)));
3136
+ metaLine.appendChild(textDiv("wf-meta", blockMetaText(block, ctx)));
2742
3137
  head.appendChild(metaLine);
2743
3138
  // The question itself — a real, bold heading (review #3: "the question
2744
3139
  // as a clear heading"), never folded into the same small meta line.
@@ -2772,7 +3167,7 @@
2772
3167
  function renderAsk(result, focusAskId, loadError){
2773
3168
  var empty = document.getElementById("ask-empty");
2774
3169
  var list = document.getElementById("ask-list");
2775
- if(loadError){ empty.hidden = false; empty.textContent = "failed to load asks: " + loadError; list.hidden = true; list.innerHTML = ""; return true; }
3170
+ if(loadError){ empty.hidden = false; empty.textContent = loadError; list.hidden = true; list.innerHTML = ""; return true; }
2776
3171
  if(!result){ empty.hidden = false; empty.textContent = "select a run first"; list.hidden = true; list.innerHTML = ""; return true; }
2777
3172
  var blocks = result.blocks || [];
2778
3173
  if(!blocks.length){
@@ -2830,6 +3225,241 @@
2830
3225
  return true;
2831
3226
  }
2832
3227
 
3228
+ // ---- M4d piece 4: Settings. Nothing here is re-rendered by the page's refresh tick: the Settings DOM is
3229
+ // painted only when it is opened, a tab is chosen, or a button here is pressed — and a price/limit box the
3230
+ // person has typed in ("dirty") is never overwritten by a repaint. No key value ever reaches this page. ----
3231
+ function fmtUsd(n, atLeast){
3232
+ if(typeof n !== "number" || !isFinite(n)) return "unknown";
3233
+ return (atLeast ? "≥" : "") + "$" + n.toFixed(4);
3234
+ }
3235
+ function fmtMinutes(m, atLeast){
3236
+ if(typeof m !== "number" || !isFinite(m)) return "not recorded";
3237
+ return (atLeast ? "≥" : "") + (m < 10 ? m.toFixed(1) : String(Math.round(m))) + " min";
3238
+ }
3239
+ // borrowed-from: bareloop src/panel/index.html@5a5a811 (tokensText)
3240
+ function tokensText(n){
3241
+ if(!n) return "0";
3242
+ if(n >= 1e6) return (n / 1e6).toFixed(1) + "M";
3243
+ if(n >= 1e3) return (n / 1e3).toFixed(1) + "k";
3244
+ return String(n);
3245
+ }
3246
+ // The server's own plain sentence (`say`) when it sent one; else the same words every other refusal uses.
3247
+ function settingsRefusal(r){
3248
+ var b = r && r.body;
3249
+ if(b && typeof b.say === "string" && b.say) return b.say;
3250
+ return refusalText(r, null);
3251
+ }
3252
+ // borrowed-from: bareloop src/panel/index.html@5a5a811 (Settings: one provider table, a money strip)
3253
+ // A hint line: plain text, red when it is a refusal. Empty text hides nothing and shows nothing.
3254
+ function setNote(el, bad, text){
3255
+ el.className = "hint" + (bad ? " bad" : "");
3256
+ el.textContent = text || "";
3257
+ }
3258
+ var settingsView = document.getElementById("settings-view");
3259
+ var mainView = document.getElementById("main-view");
3260
+ var pvRows = document.getElementById("pv-rows");
3261
+ var pvNote = document.getElementById("pv-note");
3262
+ var PV_NOTE_DEFAULT = pvNote.textContent;
3263
+ document.getElementById("settings-open").addEventListener("click", function(){
3264
+ mainView.hidden = true; settingsView.hidden = false;
3265
+ loadProviders(); loadMoney();
3266
+ });
3267
+ document.getElementById("settings-back").addEventListener("click", function(){
3268
+ settingsView.hidden = true; mainView.hidden = false;
3269
+ });
3270
+ wireTabs([document.getElementById("stab-providers"), document.getElementById("stab-money")]);
3271
+ document.getElementById("stab-money").addEventListener("click", function(){ loadMoney(); });
3272
+ document.getElementById("stab-providers").addEventListener("click", function(){ loadProviders(); });
3273
+
3274
+ function loadProviders(){
3275
+ return getJSON("/api/settings/providers").then(paintProviders, function(e){
3276
+ setNote(document.getElementById("keys-refusal"), true, loadFailureText(e));
3277
+ });
3278
+ }
3279
+ document.getElementById("reload-keys").addEventListener("click", function(){ loadProviders(); });
3280
+
3281
+ function sourceWord(src){
3282
+ if(src === "table") return "default";
3283
+ if(src === "ceiling") return "highest known rate, the model has no listed price";
3284
+ if(src === "default-multiplier") return "default, 0.1 x input";
3285
+ return "set here";
3286
+ }
3287
+ var PRICE_FIELDS = ["inPerM", "cachedInPerM", "outPerM"];
3288
+ // Name, API shape and Base URL are editable (M4d amendment 1), saved on change one field at a time.
3289
+ var PROV_FIELDS = ["name", "shape", "baseUrl"];
3290
+ function buildProviderRow(row){
3291
+ var tr = document.createElement("tr");
3292
+ tr.setAttribute("data-slot", row.slot);
3293
+ tr.setAttribute("data-testid", "provider-row-" + row.slot);
3294
+ var balance = row.canBalance
3295
+ ? '<button class="btn small" type="button" data-act="balance" data-testid="prov-balance">Check</button><div class="hint pv-balance-result" data-f="balance-result"></div>'
3296
+ : '<span class="hint">not offered by this provider</span>';
3297
+ var prices = PRICE_FIELDS.map(function(f){
3298
+ return '<td class="pv-price-cell"><input type="text" inputmode="decimal" data-field="' + f + '" data-testid="price-' + f + '" aria-label="' + escapeXml(row.label + " " + f) + '">' +
3299
+ '<div class="hint pv-msg" data-f="msg-' + f + '" data-testid="price-msg-' + f + '"></div></td>';
3300
+ }).join("");
3301
+ tr.innerHTML =
3302
+ '<td><code>' + escapeXml(row.envVar) + '</code><div class="hint" data-f="status" data-testid="pv-status-' + escapeXml(row.slot) + '"></div></td>' +
3303
+ '<td class="pv-price-cell"><input type="text" data-prov="name" data-testid="prov-name" aria-label="' + escapeXml(row.label + " name") + '" autocomplete="off" spellcheck="false"><div class="hint pv-msg" data-f="msg-name" data-testid="prov-msg-name"></div></td>' +
3304
+ '<td class="pv-price-cell"><select data-prov="shape" data-testid="prov-shape" aria-label="' + escapeXml(row.label + " API shape") + '"></select><div class="hint pv-msg" data-f="msg-shape" data-testid="prov-msg-shape"></div></td>' +
3305
+ '<td class="pv-price-cell"><input type="text" data-prov="baseUrl" data-testid="prov-baseurl" aria-label="' + escapeXml(row.label + " Base URL") + '" autocomplete="off" spellcheck="false"><div class="hint pv-msg" data-f="msg-baseUrl" data-testid="prov-msg-baseUrl"></div></td>' +
3306
+ '<td class="pv-test-cell"><button class="btn small" type="button" data-act="test" data-testid="prov-test">Test</button><div class="hint pv-test-result" data-f="test" data-testid="prov-test-result"></div></td>' +
3307
+ '<td data-f="tokens" data-testid="pv-tokens-' + escapeXml(row.slot) + '"></td>' +
3308
+ '<td>' + balance + '</td>' + prices;
3309
+ tr.querySelectorAll("input").forEach(function(inp){
3310
+ inp.addEventListener("input", function(){ inp.setAttribute("data-dirty", "1"); });
3311
+ });
3312
+ return tr;
3313
+ }
3314
+ var STATUS_WORD = { "set in file": "set in file", "found in shell": "found in shell", "not set": "not set", "refused": "refused — see above" };
3315
+ function paintProviders(data){
3316
+ var path = data.keysFile && data.keysFile.path ? data.keysFile.path : "~/.config/fwdloop/.env";
3317
+ document.getElementById("keys-path").textContent = path;
3318
+ setNote(document.getElementById("keys-refusal"), true, data.keysFile && data.keysFile.refusal);
3319
+ setNote(pvNote, !!data.configProblem, data.configProblem || PV_NOTE_DEFAULT);
3320
+ data.rows.forEach(function(row){
3321
+ var tr = pvRows.querySelector('[data-slot="' + row.slot + '"]');
3322
+ if(!tr){ tr = buildProviderRow(row); pvRows.appendChild(tr); }
3323
+ tr.querySelector("[data-f=status]").textContent = STATUS_WORD[row.keyStatus] || row.keyStatus;
3324
+ var nameIn = tr.querySelector('[data-prov=name]');
3325
+ var shapeSel = tr.querySelector('[data-prov=shape]');
3326
+ var urlIn = tr.querySelector('[data-prov=baseUrl]');
3327
+ if(shapeSel.options.length !== data.shapes.length){
3328
+ shapeSel.innerHTML = "";
3329
+ data.shapes.forEach(function(sh){
3330
+ var o = document.createElement("option");
3331
+ o.value = sh.id; o.textContent = sh.label; shapeSel.appendChild(o);
3332
+ });
3333
+ }
3334
+ nameIn.placeholder = row.defaults.model;
3335
+ urlIn.placeholder = row.defaults.baseUrl !== "" ? row.defaults.baseUrl : "the vendor's own address";
3336
+ // a box the person is typing in is never overwritten by a repaint
3337
+ if(nameIn.getAttribute("data-dirty") !== "1") nameIn.value = row.model;
3338
+ if(urlIn.getAttribute("data-dirty") !== "1") urlIn.value = row.savedBaseUrl;
3339
+ if(document.activeElement !== shapeSel) shapeSel.value = row.shape;
3340
+ tr.querySelector("[data-f=tokens]").textContent = tokensText(row.tokens);
3341
+ PRICE_FIELDS.forEach(function(f){
3342
+ var inp = tr.querySelector('input[data-field="' + f + '"]');
3343
+ var pr = row.price[f];
3344
+ inp.placeholder = String(pr.value) + " (" + sourceWord(pr.source) + ")";
3345
+ inp.title = inp.placeholder;
3346
+ // a box the person has typed in is never overwritten by a repaint
3347
+ if(inp.getAttribute("data-dirty") !== "1") inp.value = pr.source === "settings" ? String(pr.value) : "";
3348
+ });
3349
+ });
3350
+ }
3351
+ pvRows.addEventListener("click", function(ev){
3352
+ var b = ev.target.closest && ev.target.closest("button[data-act]");
3353
+ if(!b) return;
3354
+ var tr = b.closest("tr");
3355
+ if(b.getAttribute("data-act") === "test") runTest(tr, tr.getAttribute("data-slot"));
3356
+ else if(b.getAttribute("data-act") === "balance") runBalance(tr, tr.getAttribute("data-slot"));
3357
+ });
3358
+ // Saved like bareloop saves a row field: on change (blur or Enter), no Save button.
3359
+ pvRows.addEventListener("change", function(ev){
3360
+ var inp = ev.target;
3361
+ if(!inp.getAttribute) return;
3362
+ if(inp.getAttribute("data-prov")){ saveProvider(inp.closest("tr"), inp); return; }
3363
+ if(!inp.getAttribute("data-field")) return;
3364
+ savePrice(inp.closest("tr"), inp.getAttribute("data-field"));
3365
+ });
3366
+ function runTest(tr, slot){
3367
+ var out = tr.querySelector("[data-f=test]");
3368
+ out.textContent = "testing…";
3369
+ postJSON("/api/settings/test", { slot: slot }).then(function(r){
3370
+ var b = r.body;
3371
+ out.textContent = b && b.ok ? "OK · " + b.ms + " ms" : (b && b.why ? b.why : settingsRefusal(r));
3372
+ }, function(){ out.textContent = networkText(); });
3373
+ }
3374
+ // Balance is read on a click, never on render (signed M4d: "read on a click").
3375
+ function runBalance(tr, slot){
3376
+ var out = tr.querySelector("[data-f=balance-result]");
3377
+ out.textContent = "checking…";
3378
+ getJSON("/api/settings/balance?slot=" + encodeURIComponent(slot)).then(function(b){
3379
+ if(b.ok) out.textContent = b.balances.map(function(x){ return x.total + " " + x.currency; }).join(" + ");
3380
+ else out.textContent = b.why || "Could not check the balance.";
3381
+ }, function(e){ out.textContent = loadFailureText(e); });
3382
+ }
3383
+ // A box the person typed: empty = back to the default (null); a number is sent as a number; anything else is
3384
+ // sent as the text typed, so the server refuses it by naming the box.
3385
+ function priceValue(text){
3386
+ var t = String(text).trim();
3387
+ if(t === "") return null;
3388
+ var n = Number(t);
3389
+ return isFinite(n) ? n : t;
3390
+ }
3391
+ function savePrice(tr, changed){
3392
+ var msg = tr.querySelector("[data-f=msg-" + changed + "]");
3393
+ var payload = { slot: tr.getAttribute("data-slot") };
3394
+ tr.querySelectorAll("input[data-field]").forEach(function(inp){ payload[inp.getAttribute("data-field")] = priceValue(inp.value); });
3395
+ postJSON("/api/settings/price", payload).then(function(r){
3396
+ if(r.body && r.body.ok){
3397
+ tr.querySelectorAll("input[data-field]").forEach(function(inp){ inp.removeAttribute("data-dirty"); });
3398
+ loadProviders();
3399
+ setNote(msg, false, "saved — applies from the next model call");
3400
+ } else setNote(msg, true, settingsRefusal(r));
3401
+ }, function(){ setNote(msg, true, networkText()); });
3402
+ }
3403
+
3404
+ // One field per save: {slot, name|shape|baseUrl}. An empty Base URL means the default; a refusal is the cell's hint line.
3405
+ function saveProvider(tr, inp){
3406
+ var key = inp.getAttribute("data-prov");
3407
+ var msg = tr.querySelector("[data-f=msg-" + key + "]");
3408
+ var payload = { slot: tr.getAttribute("data-slot") };
3409
+ payload[key] = inp.value.trim();
3410
+ postJSON("/api/settings/provider", payload).then(function(r){
3411
+ if(r.body && r.body.ok){
3412
+ inp.removeAttribute("data-dirty");
3413
+ loadProviders();
3414
+ setNote(msg, false, "saved — applies from the next model call");
3415
+ } else setNote(msg, true, settingsRefusal(r));
3416
+ }, function(){ setNote(msg, true, networkText()); });
3417
+ }
3418
+
3419
+ function loadMoney(){
3420
+ return getJSON("/api/settings/money").then(paintMoney, function(e){
3421
+ setNote(document.getElementById("ml-msg"), true, loadFailureText(e));
3422
+ });
3423
+ }
3424
+ var mlLimit = document.getElementById("ml-money");
3425
+ function paintMoney(d){
3426
+ var m = d.month, t = d.total;
3427
+ document.getElementById("ml-usd").textContent = fmtUsd(m.usd, m.atLeast) + " / " + fmtUsd(t.usd, t.atLeast);
3428
+ document.getElementById("ml-tokens").textContent = tokensText(m.tokens) + " / " + tokensText(t.tokens);
3429
+ var notes = [];
3430
+ if(d.preM4dRunsNotCounted) notes.push("Runs from before Settings existed are not counted here.");
3431
+ if(d.undatedRows > 0) notes.push(d.undatedRows + (d.undatedRows === 1 ? " older spend row has no date; it counts in to date only." : " older spend rows have no date; they count in to date only."));
3432
+ document.getElementById("ml-extra").textContent = notes.join(" ");
3433
+ if(document.activeElement !== mlLimit && mlLimit.getAttribute("data-dirty") !== "1") mlLimit.value = typeof d.monthlyLimitUsd === "number" ? String(d.monthlyLimitUsd) : "";
3434
+ if(d.configProblem) setNote(document.getElementById("ml-msg"), true, d.configProblem);
3435
+ var names = Object.keys(d.byProvider || {});
3436
+ document.getElementById("ml-breakdown").innerHTML = names.length ? names.map(function(k){
3437
+ var p = d.byProvider[k];
3438
+ return '<tr data-testid="break-row"><td>' + escapeXml(p.label) + '</td>' +
3439
+ '<td>' + escapeXml(fmtUsd(p.month.usd, p.month.atLeast) + " / " + fmtUsd(p.total.usd, p.total.atLeast)) + '</td>' +
3440
+ '<td>' + escapeXml(breakMinutes(p.month) + " / " + breakMinutes(p.total)) + '</td>' +
3441
+ '<td>' + escapeXml(tokensText(p.total.tokens)) + '</td></tr>';
3442
+ }).join("") : '<tr><td colspan="4" class="hint">no spend yet</td></tr>';
3443
+ }
3444
+ // "not recorded" only when there was spend but no minutes; a period with no spend at all is "0 min".
3445
+ function breakMinutes(b){
3446
+ if(b.modelMinutes === null && b.usd === 0 && !b.atLeast && b.tokens === 0) return "0 min";
3447
+ return fmtMinutes(b.modelMinutes, b.modelMinutesAtLeast);
3448
+ }
3449
+ mlLimit.addEventListener("input", function(){ this.setAttribute("data-dirty", "1"); });
3450
+ // Saved like bareloop saves it: on change (blur or Enter).
3451
+ mlLimit.addEventListener("change", function(){
3452
+ var msg = document.getElementById("ml-msg");
3453
+ postJSON("/api/settings/money", { monthlyLimitUsd: priceValue(mlLimit.value) }).then(function(r){
3454
+ if(r.body && r.body.ok){
3455
+ mlLimit.removeAttribute("data-dirty");
3456
+ loadMoney().then(function(){
3457
+ setNote(msg, false, r.body.monthlyLimitUsd === null ? "saved — no monthly limit" : "saved — the limit is now $" + r.body.monthlyLimitUsd);
3458
+ });
3459
+ } else setNote(msg, true, settingsRefusal(r));
3460
+ }, function(){ setNote(msg, true, networkText()); });
3461
+ });
3462
+
2833
3463
  // theme toggle
2834
3464
  (function(){
2835
3465
  var root = document.documentElement;