fwdloop 0.6.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/fwdloop +221 -64
- package/package.json +5 -5
- package/src/ask.js +260 -6
- package/src/authoring.js +313 -0
- package/src/books.js +209 -2
- package/src/catalogue.json +1 -1
- package/src/declaration.js +16 -2
- package/src/docx.js +33 -4
- package/src/drafter.js +324 -0
- package/src/flow.js +247 -2
- package/src/index.js +9 -3
- package/src/input-facts.js +45 -0
- package/src/model-step.js +151 -12
- package/src/panel/data.js +1589 -0
- package/src/panel/index.html +2377 -0
- package/src/panel/server.js +268 -0
- package/src/primitives.js +146 -42
- package/src/provider.js +61 -43
- package/src/runner.js +393 -54
- package/src/send.js +20 -1
- package/src/sign-confirm.js +27 -0
- package/src/signed-text.js +19 -5
- package/src/types.js +19 -0
- package/types/ask.d.ts +77 -0
- package/types/authoring.d.ts +132 -0
- package/types/books.d.ts +70 -2
- package/types/declaration.d.ts +7 -1
- package/types/docx.d.ts +8 -0
- package/types/drafter.d.ts +164 -0
- package/types/flow.d.ts +135 -0
- package/types/index.d.ts +5 -3
- package/types/input-facts.d.ts +14 -0
- package/types/panel/data.d.ts +433 -0
- package/types/panel/server.d.ts +45 -0
- package/types/primitives.d.ts +33 -0
- package/types/provider.d.ts +14 -1
- package/types/runner.d.ts +66 -5
- package/types/sign-confirm.d.ts +18 -0
- package/types/signed-text.d.ts +14 -0
- package/types/types.d.ts +45 -0
|
@@ -0,0 +1,2377 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<!-- borrowed-from: bareloop src/panel/index.html@a30bbef — ADAPTED for fwdloop.
|
|
3
|
+
M4a piece 3+ (docs/wiki/the-module-ladder.md, "M4a — read-only panel —
|
|
4
|
+
SIGNED"): the Tokyo Night box-drawing visual design (CSS tokens, tab
|
|
5
|
+
layout, glyph/badge styling, responsive 390px breakpoint) is kept from
|
|
6
|
+
the borrowed page; every data-bearing script (fetches, run rendering,
|
|
7
|
+
step map, audit, job, run grouping) is rewired for fwdloop's own book
|
|
8
|
+
shapes (src/panel/data.js) — fwdloop has one flow shape (linear,
|
|
9
|
+
human-authored, signed steps) and one book granularity (one audit row
|
|
10
|
+
per step ATTEMPT), not bareloop's rounds/parts/scout/plan/judge/fix-loop
|
|
11
|
+
model, so that whole layer is replaced rather than adapted. -->
|
|
12
|
+
<html lang="en">
|
|
13
|
+
<head>
|
|
14
|
+
<meta charset="UTF-8">
|
|
15
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
16
|
+
<title>fwdloop panel</title>
|
|
17
|
+
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
18
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
19
|
+
<link href="https://fonts.googleapis.com/css2?family=Courier+Prime:wght@400;700&display=swap" rel="stylesheet">
|
|
20
|
+
<style>
|
|
21
|
+
/* Reused verbatim from design/panel-mockup.html (the visual contract, PANEL-BUILD.md §6) —
|
|
22
|
+
Tokyo Night box-drawing TUI look, same tokens, same responsive breakpoint. Fake-data rows
|
|
23
|
+
and the Settings/Chat-authoring styling are kept (Settings/Chat are out of P1's scope but
|
|
24
|
+
the CSS is harmless dead weight rather than a second stylesheet to maintain). */
|
|
25
|
+
:root{
|
|
26
|
+
--bg:#1a1b26; --panel:#1f2335; --panel2:#24283b; --border:#292e42; --border-strong:#3b4261;
|
|
27
|
+
--text:#c0caf5; --text-dim:#a9b1d6; --text-faint:#565f89;
|
|
28
|
+
--green:#9ece6a; --green-bg:#1c2b23;
|
|
29
|
+
--red:#f7768e; --red-bg:#2b1822;
|
|
30
|
+
--amber:#e0af68; --amber-bg:#2b2416;
|
|
31
|
+
--grey-dot:#878eac; --grey-bg:#20242f;
|
|
32
|
+
--cyan:#7dcfff; --cyan-bg:#182634;
|
|
33
|
+
--magenta:#bb9af7;
|
|
34
|
+
--accent:#7aa2f7;
|
|
35
|
+
--btn-bg:#1f2335; --btn-text:#c0caf5;
|
|
36
|
+
--primary-bg:#7aa2f7; --primary-text:#1a1b26; --primary-border:#7aa2f7;
|
|
37
|
+
font: 14px/1.5 "Courier Prime", "Courier New", Courier, ui-monospace, monospace;
|
|
38
|
+
}
|
|
39
|
+
*{box-sizing:border-box;}
|
|
40
|
+
html,body{margin:0;padding:0;background:var(--bg);color:var(--text);}
|
|
41
|
+
body{overflow-x:hidden;}
|
|
42
|
+
button{font:inherit;cursor:pointer;}
|
|
43
|
+
table{border-collapse:collapse;width:100%;}
|
|
44
|
+
th,td{text-align:left;padding:6px 8px;border-bottom:1px dotted var(--border-strong);font-size:12px;}
|
|
45
|
+
th{color:var(--text-dim);font-weight:700;background:var(--panel2);text-transform:uppercase;letter-spacing:0.04em;font-size:11px;border-bottom:1px solid var(--border-strong);}
|
|
46
|
+
/* item: Audit tab header stays visible while the row list scrolls. On
|
|
47
|
+
desktop >=900px .pane-body itself is height-bound and scrolls (see the
|
|
48
|
+
@media(min-width:900px) block above); on mobile #FwdloopPanel/.main
|
|
49
|
+
are unbound and the PAGE scrolls instead, so .pane-body never actually
|
|
50
|
+
develops its own scroll offset there and a sticky th anchored to it
|
|
51
|
+
would scroll away with the page. Giving the table its own bounded,
|
|
52
|
+
always-scrolling wrapper makes the header genuinely sticky on both
|
|
53
|
+
breakpoints, and also owns the horizontal scroll for the Path column
|
|
54
|
+
on narrow (390px) screens instead of leaving it to .pane-body. */
|
|
55
|
+
.audit-table-scroll{overflow:auto;max-height:min(60vh,520px);}
|
|
56
|
+
/* z-index keeps rows from showing through the solid th background as
|
|
57
|
+
they scroll under it. */
|
|
58
|
+
[data-testid="audit-table"] th{position:sticky;top:0;z-index:1;}
|
|
59
|
+
td{border-right:1px dotted var(--border);}
|
|
60
|
+
td:last-child{border-right:none;}
|
|
61
|
+
a{color:var(--accent);text-decoration:underline;}
|
|
62
|
+
:focus-visible{outline:2px solid var(--accent);outline-offset:2px;}
|
|
63
|
+
|
|
64
|
+
@media (prefers-color-scheme: light){
|
|
65
|
+
:root:not([data-theme="dark"]){
|
|
66
|
+
--bg:#e1e2e7; --panel:#d0d5e3; --panel2:#e9e9ed; --border:#c4c8da; --border-strong:#a8b0cc;
|
|
67
|
+
--text:#3760bf; --text-dim:#58679f; --text-faint:#848cb5;
|
|
68
|
+
--green:#567238; --green-bg:#dfe7d4;
|
|
69
|
+
--red:#c92353; --red-bg:#fbe0e8;
|
|
70
|
+
--amber:#82643a; --amber-bg:#f0e6d3;
|
|
71
|
+
--grey-dot:#626887; --grey-bg:#e2e2e8;
|
|
72
|
+
--cyan:#007197; --cyan-bg:#d6ecf1;
|
|
73
|
+
--magenta:#9854f1;
|
|
74
|
+
--accent:#2668c2;
|
|
75
|
+
--btn-bg:#e9e9ed; --btn-text:#3760bf;
|
|
76
|
+
--primary-bg:#2668c2; --primary-text:#e1e2e7; --primary-border:#2668c2;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
:root[data-theme="light"]{
|
|
80
|
+
--bg:#e1e2e7; --panel:#d0d5e3; --panel2:#e9e9ed; --border:#c4c8da; --border-strong:#a8b0cc;
|
|
81
|
+
--text:#3760bf; --text-dim:#58679f; --text-faint:#848cb5;
|
|
82
|
+
--green:#567238; --green-bg:#dfe7d4;
|
|
83
|
+
--red:#c92353; --red-bg:#fbe0e8;
|
|
84
|
+
--amber:#82643a; --amber-bg:#f0e6d3;
|
|
85
|
+
--grey-dot:#626887; --grey-bg:#e2e2e8;
|
|
86
|
+
--cyan:#007197; --cyan-bg:#d6ecf1;
|
|
87
|
+
--magenta:#9854f1;
|
|
88
|
+
--accent:#2668c2;
|
|
89
|
+
--btn-bg:#e9e9ed; --btn-text:#3760bf;
|
|
90
|
+
--primary-bg:#2668c2; --primary-text:#e1e2e7; --primary-border:#2668c2;
|
|
91
|
+
}
|
|
92
|
+
.theme-toggle{padding:4px 9px;min-height:32px;border:1px solid var(--border-strong);background:var(--btn-bg);color:var(--text);}
|
|
93
|
+
|
|
94
|
+
h2,h4{text-transform:uppercase;letter-spacing:0.06em;font-weight:700;}
|
|
95
|
+
|
|
96
|
+
#FwdloopPanel{display:flex;flex-direction:column;min-height:100vh;}
|
|
97
|
+
/* item 4 (2026-09-25): on desktop the left list scrolls inside its own
|
|
98
|
+
pane and the right pane stays in view — the PAGE itself never scrolls
|
|
99
|
+
the list away. Bounding #FwdloopPanel/.main to the viewport height
|
|
100
|
+
(desktop only — phone keeps its natural stacked-page scroll, see the
|
|
101
|
+
max-width:899px block below) is what lets each .pane-body's own
|
|
102
|
+
`overflow:auto` actually take effect instead of the whole document
|
|
103
|
+
growing taller than 100vh and dragging everything, list included, up
|
|
104
|
+
off screen together. */
|
|
105
|
+
@media (min-width: 900px){
|
|
106
|
+
html, body{height:100%;}
|
|
107
|
+
#FwdloopPanel{height:100vh;min-height:0;overflow:hidden;}
|
|
108
|
+
.main{overflow:hidden;}
|
|
109
|
+
}
|
|
110
|
+
.topbar{
|
|
111
|
+
display:flex;align-items:center;justify-content:space-between;
|
|
112
|
+
padding:10px 16px;border-bottom:2px solid var(--border-strong);
|
|
113
|
+
background:var(--panel);flex-wrap:wrap;gap:8px;
|
|
114
|
+
}
|
|
115
|
+
.topbar > div:first-child{display:flex;align-items:baseline;gap:0;white-space:nowrap;overflow:hidden;}
|
|
116
|
+
.topbar .brand{font-weight:700;font-size:17px;letter-spacing:0.06em;flex:none;}
|
|
117
|
+
.topbar .brand::before{content:"■ ";}
|
|
118
|
+
.topbar .tagline{font-size:12px;color:var(--text-dim);margin-left:8px;overflow:hidden;text-overflow:ellipsis;}
|
|
119
|
+
.topbar .tagline::before{content:"· ";color:var(--text-faint);}
|
|
120
|
+
@media (max-width: 600px){ .topbar .tagline{display:none;} }
|
|
121
|
+
.topbar-right{display:flex;align-items:center;gap:10px;flex-wrap:wrap;}
|
|
122
|
+
|
|
123
|
+
[hidden]{display:none !important;}
|
|
124
|
+
.main{display:flex;flex:1;min-height:0;}
|
|
125
|
+
.left-pane{width:420px;flex:none;border-right:1px solid var(--border-strong);display:flex;flex-direction:column;background:var(--panel);}
|
|
126
|
+
.right-pane{flex:1;min-width:0;display:flex;flex-direction:column;}
|
|
127
|
+
|
|
128
|
+
.tabrow{display:flex;border-bottom:1px solid var(--border-strong);background:var(--panel2);counter-reset:tabnum;}
|
|
129
|
+
.tabrow button{
|
|
130
|
+
flex:1;padding:10px 6px;min-height:44px;background:transparent;border:none;
|
|
131
|
+
border-right:1px dotted var(--border-strong);font-size:13px;color:var(--text-dim);
|
|
132
|
+
counter-increment:tabnum;
|
|
133
|
+
}
|
|
134
|
+
.tabrow button::before{content:"[" counter(tabnum) "] ";color:var(--text-faint);font-weight:700;}
|
|
135
|
+
.tabrow button:last-child{border-right:none;}
|
|
136
|
+
|
|
137
|
+
.pane-body{padding:12px;overflow:auto;flex:1;min-height:0;}
|
|
138
|
+
.tabpanel{display:none;}
|
|
139
|
+
.tabpanel.active{display:block;}
|
|
140
|
+
|
|
141
|
+
.dot{display:inline-flex;align-items:center;justify-content:center;margin-right:6px;vertical-align:middle;font-weight:700;font-size:12px;}
|
|
142
|
+
.dot::before{content:"[·]";color:var(--grey-dot);}
|
|
143
|
+
.dot.green::before{content:"[✓]";color:var(--green);}
|
|
144
|
+
.dot.red::before{content:"[✗]";color:var(--red);}
|
|
145
|
+
.dot.amber::before{content:"[▶]";color:var(--amber);}
|
|
146
|
+
.dot.grey::before{content:"[·]";color:var(--grey-dot);}
|
|
147
|
+
/* died (hamr's ruling B, 2026-09-25): no ending was ever recorded — a
|
|
148
|
+
DIFFERENT fact from a real [✗] close/arbiter "no", so it gets its own
|
|
149
|
+
glyph and its own color (magenta), never red or amber. */
|
|
150
|
+
.dot.magenta::before{content:"[?]";color:var(--magenta);}
|
|
151
|
+
/* expired, unresumed ask (hamr's ruling, 2026-09-27): same "needs
|
|
152
|
+
attention" amber as running, but a DIFFERENT glyph — never the running
|
|
153
|
+
arrow [▶], which this reserves for "running" alone. Its own class so
|
|
154
|
+
the two states never share a ::before rule. */
|
|
155
|
+
.dot.expired::before{content:"[!]";color:var(--amber);}
|
|
156
|
+
|
|
157
|
+
.badge{display:inline-block;font-size:11px;padding:1px 4px;color:var(--text-dim);background:none;font-weight:700;}
|
|
158
|
+
.badge::before{content:"[";color:var(--text-faint);}
|
|
159
|
+
.badge::after{content:"]";color:var(--text-faint);}
|
|
160
|
+
.badge.green{color:var(--green);}
|
|
161
|
+
.badge.red{color:var(--red);}
|
|
162
|
+
.badge.amber{color:var(--amber);}
|
|
163
|
+
.badge.grey{color:var(--grey-dot);}
|
|
164
|
+
.badge.magenta{color:var(--magenta);}
|
|
165
|
+
.badge.cyan{color:var(--cyan);}
|
|
166
|
+
|
|
167
|
+
.hint{font-size:11px;color:var(--text-faint);margin-top:4px;}
|
|
168
|
+
.btn{padding:8px 14px;min-height:44px;border:1px solid var(--border-strong);background:var(--panel2);color:var(--text);white-space:nowrap;flex:none;position:relative;}
|
|
169
|
+
.btn::before{content:"[ ";color:var(--text-faint);}
|
|
170
|
+
.btn::after{content:" ]";color:var(--text-faint);}
|
|
171
|
+
.btn:disabled{color:var(--text-faint);border-color:var(--border);cursor:not-allowed;}
|
|
172
|
+
.btn:disabled::before,.btn:disabled::after{color:var(--text-faint);opacity:0.4;}
|
|
173
|
+
.btn.small{padding:0 9px;height:32px;min-height:0;font-size:12px;}
|
|
174
|
+
|
|
175
|
+
.wf-row,.hist-row{
|
|
176
|
+
display:flex;flex-direction:column;row-gap:4px;min-width:0;
|
|
177
|
+
padding:8px 8px 8px 18px;position:relative;border:1px solid var(--border);margin-bottom:6px;background:var(--panel2);cursor:pointer;
|
|
178
|
+
}
|
|
179
|
+
.wf-row::before{content:" ";position:absolute;left:6px;top:8px;color:var(--accent);font-weight:700;}
|
|
180
|
+
.wf-row:hover,.hist-row:hover{border-color:var(--border-strong);}
|
|
181
|
+
.wf-row.selected::before{content:">";}
|
|
182
|
+
/* line 1: glyph + name, kept on ONE line — truncated with an ellipsis
|
|
183
|
+
(never wrapped) when the job/runid text is longer than the row; the
|
|
184
|
+
full text is still reachable via the span's own title attribute. */
|
|
185
|
+
.wf-line1{display:flex;align-items:center;column-gap:6px;min-width:0;}
|
|
186
|
+
.wf-name{font-weight:700;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0;}
|
|
187
|
+
/* line 2: the meta bits. hamr's 2026-09-27 browser-walk bug #2: the old
|
|
188
|
+
one-line ellipsis silently truncated real content ("waiting on you
|
|
189
|
+
(parked, unanswered) · at least $0…") at DESKTOP width too, not just
|
|
190
|
+
phone width — the project rule ("no list is truncated silently")
|
|
191
|
+
applies everywhere, so this wraps onto more lines instead of clipping,
|
|
192
|
+
the same behavior fix #7 already gave phone width alone. */
|
|
193
|
+
.wf-meta-line{white-space:normal;overflow:visible;text-overflow:clip;min-width:0;}
|
|
194
|
+
.wf-meta{font-size:12px;color:var(--text-dim);}
|
|
195
|
+
.wf-meta + .wf-meta::before{content:" · ";color:var(--text-faint);}
|
|
196
|
+
.wf-row.selected,.hist-row.selected{border:2px solid var(--accent);border-radius:4px;}
|
|
197
|
+
/* item 2 (2026-09-26 merge): a Workflows-view job row expands inline to
|
|
198
|
+
list ALL its runs (build spec's own design) — the caret glyph on the
|
|
199
|
+
job row, and the indent wrapper the expanded runs render into. */
|
|
200
|
+
.wf-job{margin-bottom:6px;}
|
|
201
|
+
.wf-job .wf-row{margin-bottom:0;}
|
|
202
|
+
.wf-caret{display:inline-block;width:11px;flex:none;color:var(--text-faint);font-size:10px;}
|
|
203
|
+
.wf-runs{margin:4px 0 8px 16px;padding-left:8px;border-left:2px solid var(--border);}
|
|
204
|
+
.wf-runs .hist-row{margin-bottom:4px;}
|
|
205
|
+
|
|
206
|
+
.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;}
|
|
207
|
+
.rp-header h2{margin:0;font-size:15px;}
|
|
208
|
+
.rp-header h2::before{content:"┤ ";color:var(--text-faint);}
|
|
209
|
+
.rp-header h2::after{content:" ├";color:var(--text-faint);}
|
|
210
|
+
.rp-header-title{display:flex;align-items:center;gap:8px;flex-wrap:wrap;}
|
|
211
|
+
/* item 4: phone-only jump-back link — hidden on desktop (the two panes
|
|
212
|
+
are already both on screen there, nothing to jump back to). */
|
|
213
|
+
.back-to-list-link{display:none;font-size:12px;color:var(--accent);text-decoration:underline;background:none;border:none;padding:0;cursor:pointer;}
|
|
214
|
+
@media (max-width: 899px){ .back-to-list-link{display:inline-block;} }
|
|
215
|
+
.rp-tabrow{display:flex;border-bottom:1px solid var(--border-strong);background:var(--panel2);counter-reset:rtabnum;}
|
|
216
|
+
.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;}
|
|
217
|
+
.rp-tabrow button::before{content:"[" counter(rtabnum) "] ";color:var(--text-faint);font-weight:700;}
|
|
218
|
+
.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);}
|
|
219
|
+
.tabrow button[aria-selected="true"]::before,.rp-tabrow button[aria-selected="true"]::before{color:var(--accent);}
|
|
220
|
+
|
|
221
|
+
.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;}
|
|
222
|
+
.counters b,.counters span{color:var(--accent);}
|
|
223
|
+
|
|
224
|
+
.summary-box{position:relative;border:1px solid var(--border-strong);padding:16px 12px 12px;margin-top:16px;background:var(--panel2);font-size:12px;}
|
|
225
|
+
.summary-box.red{border-color:var(--red);}
|
|
226
|
+
.summary-box.amber{border-color:var(--amber);}
|
|
227
|
+
.summary-box.magenta{border-color:var(--magenta);}
|
|
228
|
+
.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;}
|
|
229
|
+
.summary-headline{font-weight:700;margin-bottom:8px;font-size:13px;}
|
|
230
|
+
.summary-row{display:flex;gap:0;padding:2px 0;}
|
|
231
|
+
.sum-label{flex:none;width:66px;color:var(--text-faint);}
|
|
232
|
+
.sum-val{color:var(--text);}
|
|
233
|
+
.summary-box .num{color:var(--accent);font-weight:700;}
|
|
234
|
+
|
|
235
|
+
/* hamr review #3: "map cards taking page full width, should be smaller" —
|
|
236
|
+
the SVG's own natural width is centered in the box rather than the box
|
|
237
|
+
stretching each node to fill the pane (computeMapLayout below is also
|
|
238
|
+
capped to stop a node from stretching past a modest ceiling). */
|
|
239
|
+
.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;}
|
|
240
|
+
.map-box::before{content:"┤ MAP ├";display:block;font-size:11px;color:var(--text-faint);letter-spacing:0.08em;margin:-2px 0 8px 0;}
|
|
241
|
+
.map-box svg{display:block;max-width:100%;height:auto;margin:0 auto;}
|
|
242
|
+
.map-legend{display:flex;gap:14px;font-size:11px;color:var(--text-dim);margin-top:6px;flex-wrap:wrap;}
|
|
243
|
+
|
|
244
|
+
.step-card{position:relative;border:1px solid var(--border);padding:10px;margin-bottom:8px;background:var(--panel2);}
|
|
245
|
+
.step-card.running{border:1px double var(--amber);}
|
|
246
|
+
/* hamr's 2026-09-27 styling ruling: the card's HEADER line (number, step
|
|
247
|
+
name, state chip, close-class chip) is upper case and bold; the state/
|
|
248
|
+
close chips keep their own color from `.badge`'s existing classes —
|
|
249
|
+
text-transform never touches color. */
|
|
250
|
+
.step-card .step-head{display:flex;align-items:center;justify-content:space-between;gap:8px;flex-wrap:wrap;text-transform:uppercase;font-weight:700;}
|
|
251
|
+
.step-card h4{margin:0;font-size:13px;}
|
|
252
|
+
/* Every OTHER line on the card (goal, actions, granted, stopped reason) —
|
|
253
|
+
lower case exactly as the data reads, normal weight; never inherits the
|
|
254
|
+
header's uppercase/bold (same ruling, the non-header half of it). */
|
|
255
|
+
.step-card .step-line{text-transform:none;font-weight:400;}
|
|
256
|
+
.step-meta{font-size:12px;color:var(--text-dim);margin-top:4px;}
|
|
257
|
+
/* `.attempts-list` stays — no longer used by the Run tab's own step cards
|
|
258
|
+
(hamr's 2026-09-27 review: per-attempt rows dropped, summarized cards
|
|
259
|
+
only; that detail stays in the Audit tab), but the Job tab's
|
|
260
|
+
unjudged-artifacts list still uses it for its own, unrelated rows.
|
|
261
|
+
`.attempt-row` (the Run tab's own OLD per-attempt row, now nowhere on
|
|
262
|
+
the page) is dropped — dead weight, not carried forward. */
|
|
263
|
+
.attempts-list{margin-top:8px;border-top:1px dotted var(--border-strong);padding-top:8px;}
|
|
264
|
+
|
|
265
|
+
.chips{display:flex;gap:6px;margin-bottom:10px;flex-wrap:wrap;}
|
|
266
|
+
.chip{padding:5px 10px;min-height:32px;border:1px solid var(--border-strong);background:var(--panel2);font-size:12px;color:var(--text-dim);}
|
|
267
|
+
.chip::before{content:"[ ";color:var(--text-faint);}
|
|
268
|
+
.chip::after{content:" ]";color:var(--text-faint);}
|
|
269
|
+
.chip[aria-pressed="true"]{background:var(--panel);color:var(--accent);border-color:var(--accent);font-weight:700;}
|
|
270
|
+
/* Compact filter-bar chips (History + Workflows, shared component): single
|
|
271
|
+
letters/bare glyphs, no "[ ]" brackets — hamr's 2026-09-25 feedback on
|
|
272
|
+
the live panel ("icons are taking too much space", "one letter without
|
|
273
|
+
brackets"). */
|
|
274
|
+
.filterbar{margin-bottom:8px;}
|
|
275
|
+
.search-input{
|
|
276
|
+
display:block;width:100%;box-sizing:border-box;padding:6px 8px;min-height:32px;margin-bottom:6px;
|
|
277
|
+
border:1px solid var(--border-strong);background:var(--bg);color:var(--text);font:inherit;
|
|
278
|
+
}
|
|
279
|
+
.search-input::placeholder{color:var(--text-faint);}
|
|
280
|
+
.filterbar .chips{gap:4px;margin-bottom:4px;}
|
|
281
|
+
.chip.fchip{padding:3px 7px;min-height:28px;min-width:28px;font-size:12px;text-align:center;}
|
|
282
|
+
.chip.fchip::before,.chip.fchip::after{content:"";}
|
|
283
|
+
.row-blocked{background:var(--red-bg);}
|
|
284
|
+
|
|
285
|
+
/* hamr review #5/#6: Audit tab grouped-by-step sections. */
|
|
286
|
+
.audit-group{position:relative;border:1px solid var(--border-strong);padding:14px 10px 10px;background:var(--panel2);margin-top:10px;margin-bottom:10px;}
|
|
287
|
+
/* hamr's 2026-09-27 final tweak #3: the global `h2,h4{text-transform:
|
|
288
|
+
uppercase}` rule (above) would otherwise shout every collapsible audit
|
|
289
|
+
header ("[done] · resume-text · 7.9s · $0.0026 · try 1 [checkmark]") —
|
|
290
|
+
these headers render the book's own text as-is, lower case, so this
|
|
291
|
+
overrides it back to none for this ONE h4 class. Checked: no other CSS
|
|
292
|
+
rule in this file re-uppercases `.audit-group h4` after this. */
|
|
293
|
+
.audit-group h4{margin:0 0 8px;font-size:13px;position:absolute;top:-10px;left:10px;background:var(--panel2);padding:0 6px;text-transform:none;}
|
|
294
|
+
.audit-group h4::before{content:"┤ ";color:var(--text-faint);}
|
|
295
|
+
.audit-group h4::after{content:" ├";color:var(--text-faint);}
|
|
296
|
+
/* hamr's 2026-09-27 review: the Audit-group's own state header ("[done] ·
|
|
297
|
+
step · ...", built by buildAuditGroupHeaderEl) is NOT bold — a plain h4
|
|
298
|
+
is bold by default, so its own class (`.audit-status-header`, NOT the
|
|
299
|
+
shared `.audit-group h4`, which the Ask tab's `.ask-question-heading`
|
|
300
|
+
h4 also matches and must stay bold per review #3) overrides it back to
|
|
301
|
+
normal. Specificity: two classes + type (0,2,1) beats both
|
|
302
|
+
`.audit-group h4` (0,1,1) and `.ask-question-heading` (0,1,0) alone, so
|
|
303
|
+
this never un-bolds the ask question heading. */
|
|
304
|
+
.audit-group h4.audit-status-header{font-weight:400;}
|
|
305
|
+
/* hamr's 2026-09-27 review: the group header's own state word (g.state,
|
|
306
|
+
rendered as a <span class="badge STATE">) and its per-try marks
|
|
307
|
+
(<span class="mark STATE">) reuse the SAME color vocabulary the runs
|
|
308
|
+
list already uses (glyphClass/.badge) — one color vocabulary, not a
|
|
309
|
+
second one invented for the Audit tab. `.badge` already draws the
|
|
310
|
+
"[" "]" brackets and the color; `.mark` is the bare-text equivalent for
|
|
311
|
+
a try mark, which never carries brackets. */
|
|
312
|
+
.mark.green{color:var(--green);}
|
|
313
|
+
.mark.red{color:var(--red);}
|
|
314
|
+
.mark.grey{color:var(--grey-dot);}
|
|
315
|
+
/* review #4: a momentary highlight on the group a map/step-card click just
|
|
316
|
+
jumped to — never a permanent style change. */
|
|
317
|
+
.audit-group.audit-group-highlight{border-color:var(--accent);box-shadow:0 0 0 2px var(--accent);}
|
|
318
|
+
.map-step{cursor:pointer;}
|
|
319
|
+
.step-card{cursor:pointer;}
|
|
320
|
+
|
|
321
|
+
.job-card{position:relative;border:1px solid var(--border-strong);padding:14px 10px 10px;background:var(--panel2);margin-top:10px;margin-bottom:10px;}
|
|
322
|
+
.job-card h4{margin:0 0 8px;font-size:13px;position:absolute;top:-10px;left:10px;background:var(--panel2);padding:0 6px;}
|
|
323
|
+
.job-card h4::before{content:"┤ ";color:var(--text-faint);}
|
|
324
|
+
.job-card h4::after{content:" ├";color:var(--text-faint);}
|
|
325
|
+
.field{margin-bottom:10px;}
|
|
326
|
+
label{display:block;font-size:11px;font-weight:700;color:var(--text-dim);margin-bottom:2px;text-transform:uppercase;letter-spacing:0.04em;}
|
|
327
|
+
/* hamr's 2026-09-27 exit-check review #3: Ask tab box headers — same
|
|
328
|
+
bold/uppercase weight `label` already gives the Job tab's own fields,
|
|
329
|
+
applied to "draft under review" and each unjudged input's own label
|
|
330
|
+
("resume-text"/"jd-text" etc.), never the faint `.hint` style. */
|
|
331
|
+
.evidence-heading{font-size:11px;font-weight:700;color:var(--text-dim);margin:8px 0 3px;text-transform:uppercase;letter-spacing:0.04em;}
|
|
332
|
+
.evidence-heading:first-child{margin-top:0;}
|
|
333
|
+
/* review #3: the ask's own question, a real heading under the "Ask i of
|
|
334
|
+
n · step · asked · status" meta line — reuses the box-drawing h4 look
|
|
335
|
+
the Audit/Job group headers already use, but inline (no absolute
|
|
336
|
+
┤ ├ pips — those are reserved for a whole-box title, not an in-flow
|
|
337
|
+
line) so it reads as a clear, bold heading without a second border. */
|
|
338
|
+
.ask-question-heading{margin:6px 0 0;font-size:13px;font-weight:700;color:var(--text);}
|
|
339
|
+
.ro-value{padding:6px 8px;min-height:32px;box-sizing:border-box;border:1px solid var(--border);background:var(--bg);color:var(--text-dim);}
|
|
340
|
+
.ro-value.scroll{max-height:160px;overflow-y:auto;white-space:pre-wrap;word-break:break-word;}
|
|
341
|
+
.field-row{display:flex;flex-wrap:wrap;gap:10px;}
|
|
342
|
+
.field-row .field{flex:1 1 140px;margin-bottom:10px;}
|
|
343
|
+
|
|
344
|
+
.chat-thread{padding:20px 8px;color:var(--text-faint);font-size:13px;}
|
|
345
|
+
|
|
346
|
+
@media (max-width: 899px){
|
|
347
|
+
.main{flex-direction:column;}
|
|
348
|
+
.left-pane{width:100%;border-right:none;border-bottom:1px solid var(--border-strong);}
|
|
349
|
+
.right-pane{width:100%;}
|
|
350
|
+
.topbar{flex-direction:column;align-items:flex-start;}
|
|
351
|
+
.topbar-right{width:100%;justify-content:space-between;}
|
|
352
|
+
.btn.small{height:44px;min-height:44px;padding:0 12px;}
|
|
353
|
+
.chip{min-height:44px;}
|
|
354
|
+
.chip.fchip{min-height:40px;min-width:40px;}
|
|
355
|
+
.rp-header{margin:8px 8px 0;}
|
|
356
|
+
.rp-tabrow{margin:0 8px;}
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/* hamr's 2026-09-27 exit-check review #4: at 390px the Audit page scrolls
|
|
360
|
+
sideways and the Time column overflows the table's own border — a wide
|
|
361
|
+
multi-column table (Attempt/Action/Gap/Cost/Verdict/Close/Time) simply
|
|
362
|
+
cannot fit a 390px viewport no matter how each cell wraps. Both audit
|
|
363
|
+
tables (the flat one and every per-step grouped one) switch to a
|
|
364
|
+
stacked "mini-card" layout instead: the header row hides, each `<tr>`
|
|
365
|
+
becomes its own bordered block, and each `<td>` becomes a `label:
|
|
366
|
+
value` line, the label read from the SAME `data-label` attribute
|
|
367
|
+
`buildAuditRowEl` already sets on every cell (never a second, separate
|
|
368
|
+
label list to keep in sync). No horizontal scroll is possible once
|
|
369
|
+
every cell is a full-width block. */
|
|
370
|
+
@media (max-width: 480px){
|
|
371
|
+
[data-testid="audit-table"], .audit-group table{width:100%;}
|
|
372
|
+
[data-testid="audit-table"] thead, .audit-group table thead{
|
|
373
|
+
position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;
|
|
374
|
+
}
|
|
375
|
+
[data-testid="audit-table"] tbody, .audit-group table tbody{display:block;}
|
|
376
|
+
[data-testid="audit-table"] tr, .audit-group table tr{
|
|
377
|
+
display:block;border:1px solid var(--border-strong);margin-bottom:8px;padding:4px 0;
|
|
378
|
+
}
|
|
379
|
+
[data-testid="audit-table"] td, .audit-group table td{
|
|
380
|
+
display:block;border:none;border-bottom:1px dotted var(--border);padding:4px 8px;
|
|
381
|
+
/* fix (2026-09-28): a pre-M4a-2 row's Time cell shows the longer
|
|
382
|
+
`atWhy` text ("not recorded (before M4a-2)") instead of a
|
|
383
|
+
timestamp — overflow-wrap:anywhere (on top of the existing
|
|
384
|
+
break-word/word-break) makes sure that text wraps inside the
|
|
385
|
+
cell's own border at 390px instead of spilling past it. */
|
|
386
|
+
white-space:normal;overflow-wrap:anywhere;word-break:break-word;max-width:100%;box-sizing:border-box;
|
|
387
|
+
}
|
|
388
|
+
[data-testid="audit-table"] td:last-child, .audit-group table td:last-child{border-bottom:none;}
|
|
389
|
+
[data-testid="audit-table"] td::before, .audit-group table td::before{
|
|
390
|
+
content:attr(data-label) ": ";font-weight:700;color:var(--text-dim);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
</style>
|
|
394
|
+
</head>
|
|
395
|
+
<body>
|
|
396
|
+
|
|
397
|
+
<div id="FwdloopPanel">
|
|
398
|
+
|
|
399
|
+
<header class="topbar">
|
|
400
|
+
<div>
|
|
401
|
+
<span class="brand">fwdloop</span>
|
|
402
|
+
<span class="tagline">automate a job — it has humans in it</span>
|
|
403
|
+
</div>
|
|
404
|
+
<div class="topbar-right">
|
|
405
|
+
<span class="hint" id="host-line"></span>
|
|
406
|
+
<button class="theme-toggle" id="theme-toggle" type="button" aria-label="Toggle light/dark theme">☽</button>
|
|
407
|
+
</div>
|
|
408
|
+
</header>
|
|
409
|
+
|
|
410
|
+
<div class="main" id="main-view">
|
|
411
|
+
|
|
412
|
+
<nav class="left-pane" aria-label="Job navigation" id="left-pane-anchor">
|
|
413
|
+
<div class="tabrow" role="tablist" aria-label="Left panel views">
|
|
414
|
+
<button role="tab" id="tab-chat" aria-controls="panel-chat" aria-selected="true" data-testid="left-tab-chat">Chat</button>
|
|
415
|
+
<button role="tab" id="tab-runs" aria-controls="panel-runs" aria-selected="false" data-testid="left-tab-runs">Runs</button>
|
|
416
|
+
<button role="tab" id="tab-inbox" aria-controls="panel-inbox" aria-selected="false" data-testid="left-tab-inbox">Inbox<span id="inbox-count-label"></span></button>
|
|
417
|
+
</div>
|
|
418
|
+
|
|
419
|
+
<div class="pane-body">
|
|
420
|
+
|
|
421
|
+
<section id="panel-chat" class="tabpanel active" role="tabpanel" aria-labelledby="tab-chat">
|
|
422
|
+
<div class="chat-thread">
|
|
423
|
+
Authoring a flow from this page isn't built yet — the drafter is a POC. This
|
|
424
|
+
panel is read-only: it shows flows and runs already started from the
|
|
425
|
+
<code>fwdloop</code> CLI. Use the Runs tab to open one, or the Inbox tab for
|
|
426
|
+
anything waiting on you.
|
|
427
|
+
</div>
|
|
428
|
+
</section>
|
|
429
|
+
|
|
430
|
+
<section id="panel-inbox" class="tabpanel" role="tabpanel" aria-labelledby="tab-inbox" hidden>
|
|
431
|
+
<!-- M4a-1: a list of STOPS, like History — open ones first with
|
|
432
|
+
[.] and time left, then past ones newest first with a short
|
|
433
|
+
status word ([accepted]/[rejected: reason]/[reran: reason]/
|
|
434
|
+
[expired]/[unanswered]). No evidence is rendered here any
|
|
435
|
+
more (M4a-1 review): clicking a stop selects its run, switches
|
|
436
|
+
the right pane to the Ask tab, and expands that ONE ask there
|
|
437
|
+
— the wide right pane is where the evidence lives now. No
|
|
438
|
+
answer controls — those are M4b. -->
|
|
439
|
+
<div id="inbox-list" data-testid="inbox-list"></div>
|
|
440
|
+
</section>
|
|
441
|
+
|
|
442
|
+
<section id="panel-runs" class="tabpanel" role="tabpanel" aria-labelledby="tab-runs" hidden>
|
|
443
|
+
<div class="chips" role="group" aria-label="Runs view" style="margin-bottom:8px;">
|
|
444
|
+
<button class="chip" type="button" aria-pressed="true" data-runs-view="workflows" data-testid="runs-view-workflows">Workflows</button>
|
|
445
|
+
<button class="chip" type="button" aria-pressed="false" data-runs-view="history" data-testid="runs-view-history">History</button>
|
|
446
|
+
</div>
|
|
447
|
+
<div id="runs-filterbar-anchor"></div>
|
|
448
|
+
<div id="wf-list" data-testid="wf-list"></div>
|
|
449
|
+
<div id="history-list" data-testid="history-list" hidden></div>
|
|
450
|
+
</section>
|
|
451
|
+
|
|
452
|
+
</div>
|
|
453
|
+
</nav>
|
|
454
|
+
|
|
455
|
+
<section class="right-pane" aria-label="Active workflow" id="right-pane-anchor">
|
|
456
|
+
<div class="rp-header">
|
|
457
|
+
<button type="button" class="back-to-list-link" id="back-to-list" data-testid="back-to-list">↑ list</button>
|
|
458
|
+
<div class="rp-header-title">
|
|
459
|
+
<span class="dot grey" id="active-wf-dot"></span>
|
|
460
|
+
<h2 id="active-wf-name">(none selected)</h2>
|
|
461
|
+
<span class="badge" id="active-wf-verdict">—</span>
|
|
462
|
+
<span class="badge" id="active-wf-date">—</span>
|
|
463
|
+
</div>
|
|
464
|
+
</div>
|
|
465
|
+
|
|
466
|
+
<div class="rp-tabrow" role="tablist" aria-label="Workflow views">
|
|
467
|
+
<button role="tab" id="tab-run" aria-controls="panel-run" aria-selected="true" data-testid="right-tab-run">Run</button>
|
|
468
|
+
<button role="tab" id="tab-audit" aria-controls="panel-audit" aria-selected="false" data-testid="right-tab-audit">Audit / logs</button>
|
|
469
|
+
<button role="tab" id="tab-details" aria-controls="panel-details" aria-selected="false" data-testid="right-tab-details">Job</button>
|
|
470
|
+
<button role="tab" id="tab-ask" aria-controls="panel-ask" aria-selected="false" data-testid="right-tab-ask">Ask</button>
|
|
471
|
+
</div>
|
|
472
|
+
|
|
473
|
+
<div class="pane-body">
|
|
474
|
+
|
|
475
|
+
<section id="panel-run" class="tabpanel active" role="tabpanel" aria-labelledby="tab-run">
|
|
476
|
+
<div id="run-empty" class="hint" style="font-size:13px;padding:24px 0;">select a run from Workflows or History</div>
|
|
477
|
+
<div id="run-content" hidden>
|
|
478
|
+
<div class="counters" id="run-counters" data-testid="live-counters"></div>
|
|
479
|
+
<div class="summary-box" id="run-summary" data-testid="run-summary"></div>
|
|
480
|
+
<div class="map-box" data-testid="step-map" id="map-box"><div id="map-mount"></div></div>
|
|
481
|
+
<div id="step-list"></div>
|
|
482
|
+
</div>
|
|
483
|
+
</section>
|
|
484
|
+
|
|
485
|
+
<section id="panel-audit" class="tabpanel" role="tabpanel" aria-labelledby="tab-audit" hidden>
|
|
486
|
+
<!-- This run's own audit.jsonl rows only, one row per step ATTEMPT
|
|
487
|
+
(M4a scope item 2). bareloop's All/Writes/Blocked filters and
|
|
488
|
+
per-round/tool-call rows are dropped: there is no such book in
|
|
489
|
+
fwdloop to fill them from (ladder ruling A) — unwired, never
|
|
490
|
+
faked. hamr review #5/#6 (2026-09-27): grouped-by-step is the
|
|
491
|
+
default view (one section per step, a header naming the step,
|
|
492
|
+
close class, attempt count and cost), with a Grouped/Flat
|
|
493
|
+
toggle; column order everywhere is Attempt, Step (dropped in
|
|
494
|
+
Grouped — the header already names it), Action, Gap, Cost,
|
|
495
|
+
Verdict, Close. -->
|
|
496
|
+
<div id="audit-empty" class="hint" data-testid="audit-empty" style="font-size:13px;padding:24px 0;">select a run first</div>
|
|
497
|
+
<div id="audit-content" data-testid="audit-content" hidden>
|
|
498
|
+
<!-- hamr's 2026-09-27 exit-check review #2: All/Human/Blocked on
|
|
499
|
+
the left, the existing Grouped/Flat toggle on the right —
|
|
500
|
+
both filters apply to both views. Human = a row whose
|
|
501
|
+
server-derived `action` is "human" (src/panel/data.js's
|
|
502
|
+
deriveAuditAction); Blocked = `row.blocked`
|
|
503
|
+
(isBlockedVerdict) — neither is re-derived here. -->
|
|
504
|
+
<div style="display:flex;justify-content:space-between;align-items:center;flex-wrap:wrap;gap:8px;margin-bottom:8px;">
|
|
505
|
+
<div class="chips" role="group" aria-label="Audit filter" style="margin-bottom:0;">
|
|
506
|
+
<button class="chip" type="button" aria-pressed="true" data-audit-filter="all" data-testid="audit-filter-all">All</button>
|
|
507
|
+
<button class="chip" type="button" aria-pressed="false" data-audit-filter="human" data-testid="audit-filter-human">Human</button>
|
|
508
|
+
<button class="chip" type="button" aria-pressed="false" data-audit-filter="blocked" data-testid="audit-filter-blocked">Blocked</button>
|
|
509
|
+
</div>
|
|
510
|
+
<div class="chips" role="group" aria-label="Audit view" style="margin-bottom:0;">
|
|
511
|
+
<button class="chip" type="button" aria-pressed="true" data-view="grouped" data-testid="audit-view-grouped">Grouped</button>
|
|
512
|
+
<button class="chip" type="button" aria-pressed="false" data-view="flat" data-testid="audit-view-flat">Flat</button>
|
|
513
|
+
</div>
|
|
514
|
+
</div>
|
|
515
|
+
<div id="audit-filter-empty" class="hint" data-testid="audit-filter-empty" hidden style="padding:12px 0;"></div>
|
|
516
|
+
<div id="audit-groups" data-testid="audit-groups"></div>
|
|
517
|
+
<div class="audit-table-scroll" id="audit-flat-wrap" hidden>
|
|
518
|
+
<table data-testid="audit-table">
|
|
519
|
+
<thead><tr><th>Attempt</th><th>Step</th><th>Action</th><th>Gap</th><th>Cost</th><th>Verdict</th><th>Close</th><th>Time</th></tr></thead>
|
|
520
|
+
<tbody id="audit-tbody"></tbody>
|
|
521
|
+
</table>
|
|
522
|
+
</div>
|
|
523
|
+
</div>
|
|
524
|
+
</section>
|
|
525
|
+
|
|
526
|
+
<section id="panel-details" class="tabpanel" role="tabpanel" aria-labelledby="tab-details" hidden data-testid="panel-details">
|
|
527
|
+
<!-- The signed prose, the arbiter block, and the signature — the
|
|
528
|
+
ONE signed declaration.json + signature.json per flow
|
|
529
|
+
(M4a scope item 2). hamr's 2026-09-27 exit-check review #5:
|
|
530
|
+
a bareloop-style one-field-per-piece layout, one row per
|
|
531
|
+
piece within a field — replaces the old split asks/sends/
|
|
532
|
+
sources/signed-lines blocks. Field order (signed): Job
|
|
533
|
+
(prose) · Ask · Model · $ cap (+ redo cap) · Source ·
|
|
534
|
+
Destination · Guardrails · Success · Signed. At 390px every
|
|
535
|
+
field's own `label` already sits above its value (the
|
|
536
|
+
existing global `label{display:block}` rule — no separate
|
|
537
|
+
narrow-width override needed). -->
|
|
538
|
+
<div id="job-empty" class="hint" style="font-size:13px;padding:24px 0;">select a run first</div>
|
|
539
|
+
<div class="job-card" id="job-card" hidden data-testid="job-card-readonly">
|
|
540
|
+
<h4 id="details-title">Job card — signed</h4>
|
|
541
|
+
<div class="field"><label>Model</label><div class="ro-value" id="details-model">—</div></div>
|
|
542
|
+
<div class="field"><label>$ cap</label><div class="ro-value" id="details-cap">—</div></div>
|
|
543
|
+
<div class="field"><label>Job (prose)</label><div id="details-prose"></div></div>
|
|
544
|
+
<div class="field"><label>Ask</label><div id="details-asks"></div></div>
|
|
545
|
+
<div class="field"><label>Source</label><div id="details-sources"></div></div>
|
|
546
|
+
<div class="field"><label>Destination</label><div id="details-sends"></div></div>
|
|
547
|
+
<div class="field"><label>Guardrails</label><div id="details-guardrails"></div></div>
|
|
548
|
+
<div class="field"><label>Success</label><div id="details-success"></div></div>
|
|
549
|
+
<div class="field"><label>Signed</label><div class="ro-value" id="details-signature">—</div></div>
|
|
550
|
+
</div>
|
|
551
|
+
</section>
|
|
552
|
+
|
|
553
|
+
<section id="panel-ask" class="tabpanel" role="tabpanel" aria-labelledby="tab-ask" hidden data-testid="panel-ask">
|
|
554
|
+
<!-- M4a-1: every ask of the selected run, COLLAPSED by default
|
|
555
|
+
(header: question, asked time, status). Clicking a stop in
|
|
556
|
+
the left Inbox tab selects that run, switches here, and
|
|
557
|
+
expands exactly that one ask — when a run with an open ask is
|
|
558
|
+
selected directly, the open one expands by default. Expanded:
|
|
559
|
+
question, time left (open) or decision+reason+answered time
|
|
560
|
+
(past), the draft under review (scrollable), then each
|
|
561
|
+
unjudged input labelled by step (goal as subtitle). A
|
|
562
|
+
pre-M4a-1 ask shows "draft not kept (before M4a-1)" in place
|
|
563
|
+
of the draft. Read-only: no answer controls here (M4b) — a
|
|
564
|
+
clearly marked EMPTY slot stands in their place. Nothing in
|
|
565
|
+
this panel is a real <button>/<input> — even the
|
|
566
|
+
collapse/expand toggle is a div with role="button"
|
|
567
|
+
tabindex="0" (the SAME pattern the step-map's own SVG nodes
|
|
568
|
+
already use elsewhere on this page), so "no controls yet"
|
|
569
|
+
holds by construction. -->
|
|
570
|
+
<div id="ask-empty" class="hint" style="font-size:13px;padding:24px 0;">select a run first</div>
|
|
571
|
+
<div id="ask-list" data-testid="ask-list" hidden></div>
|
|
572
|
+
</section>
|
|
573
|
+
|
|
574
|
+
</div>
|
|
575
|
+
</section>
|
|
576
|
+
|
|
577
|
+
</div>
|
|
578
|
+
|
|
579
|
+
</div>
|
|
580
|
+
|
|
581
|
+
<script>
|
|
582
|
+
(function(){
|
|
583
|
+
"use strict";
|
|
584
|
+
|
|
585
|
+
var PORT = "__FWDLOOP_PANEL_PORT__";
|
|
586
|
+
document.getElementById("host-line").textContent = "127.0.0.1:" + PORT;
|
|
587
|
+
|
|
588
|
+
function wireTabs(tabButtons){
|
|
589
|
+
tabButtons.forEach(function(btn){
|
|
590
|
+
btn.addEventListener("click", function(){
|
|
591
|
+
tabButtons.forEach(function(b){
|
|
592
|
+
b.setAttribute("aria-selected", "false");
|
|
593
|
+
var p = document.getElementById(b.getAttribute("aria-controls"));
|
|
594
|
+
if(p){ p.hidden = true; p.classList.remove("active"); }
|
|
595
|
+
});
|
|
596
|
+
btn.setAttribute("aria-selected", "true");
|
|
597
|
+
var panel = document.getElementById(btn.getAttribute("aria-controls"));
|
|
598
|
+
if(panel){ panel.hidden = false; panel.classList.add("active"); }
|
|
599
|
+
if(btn.id === "tab-run"){ reflowMap(); }
|
|
600
|
+
});
|
|
601
|
+
});
|
|
602
|
+
}
|
|
603
|
+
wireTabs([document.getElementById("tab-chat"), document.getElementById("tab-runs"), document.getElementById("tab-inbox")]);
|
|
604
|
+
wireTabs([document.getElementById("tab-run"), document.getElementById("tab-audit"), document.getElementById("tab-details"), document.getElementById("tab-ask")]);
|
|
605
|
+
|
|
606
|
+
// ---- fetch helpers — GET only, this panel is read-only by construction
|
|
607
|
+
// (src/panel/server.js is GET/HEAD-only too; nothing on this page ever
|
|
608
|
+
// sends a non-GET request or a request body). ----
|
|
609
|
+
function getJSON(path){
|
|
610
|
+
return fetch(path, { method: "GET", headers: { accept: "application/json" } }).then(function(r){
|
|
611
|
+
if(!r.ok) throw new Error(path + ": HTTP " + r.status);
|
|
612
|
+
return r.json();
|
|
613
|
+
});
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
function escapeXml(s){
|
|
617
|
+
return String(s).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""");
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
// ---- money/close-class/glyph helpers — the SAME display rules as
|
|
621
|
+
// src/panel/data.js's costDisplay (never $0 for an unknown spend, "at
|
|
622
|
+
// least $X" for a floor) — reimplemented here (a pure, <15-line vanilla
|
|
623
|
+
// formatter) because this is browser script, which cannot import a
|
|
624
|
+
// node:fs-using ESM module. ----
|
|
625
|
+
function money(n, spendComplete){
|
|
626
|
+
if(typeof n !== "number") return "unknown";
|
|
627
|
+
var text = "$" + n.toFixed(4);
|
|
628
|
+
return spendComplete === false ? "at least " + text : text;
|
|
629
|
+
}
|
|
630
|
+
// hamr's 2026-09-27 review item (c): the Audit tab's Cost cell reads
|
|
631
|
+
// "$0.0086 · 2448 tokens · 1.6s" — cost (money), a token
|
|
632
|
+
// total (server-derived, `r.tokensDisplay` from src/panel/data.js's
|
|
633
|
+
// deriveAuditTokensDisplay — never re-summed here), then wall time (this
|
|
634
|
+
// row's own `wallMs`, never invented). A pre-M4a-2 row shows "tokens not
|
|
635
|
+
// recorded" in that middle slot instead of a number; a row with no model
|
|
636
|
+
// call at all (an ask/hitl row) drops the tokens slot entirely — never a
|
|
637
|
+
// fake "0 tokens".
|
|
638
|
+
function auditCostCellText(r){
|
|
639
|
+
var bits = [money(r.usd, r.spendComplete)];
|
|
640
|
+
var td = r.tokensDisplay;
|
|
641
|
+
if(td && td.kind === "total") bits.push(td.total + " tokens");
|
|
642
|
+
else if(td && td.kind === "not-recorded") bits.push("tokens not recorded");
|
|
643
|
+
// td.kind === "no-model": no tokens slot at all.
|
|
644
|
+
bits.push(duration(r.wallMs));
|
|
645
|
+
return bits.join(" · ");
|
|
646
|
+
}
|
|
647
|
+
// hamr's 2026-09-27 review item (d): the new Time column — this row's own
|
|
648
|
+
// `at`, read locally (`readableDateTime`, same formatter every other
|
|
649
|
+
// timestamp on this page already uses); a pre-M4a-2 row (server-derived
|
|
650
|
+
// `r.atWhy`) shows its own why instead of guessing a date.
|
|
651
|
+
function auditTimeCellText(r){
|
|
652
|
+
if(typeof r.atWhy === "string" && r.atWhy.length > 0) return r.atWhy;
|
|
653
|
+
return readableDateTime(r.at) || "unknown";
|
|
654
|
+
}
|
|
655
|
+
// fix (2026-09-28, borrowed-from: bareloop src/panel/index.html@2711b1b):
|
|
656
|
+
// hamr's UI review found the Time cell's full date+time string overflowed
|
|
657
|
+
// the Audit tab's mobile stacked-card cell sideways at 390px. bareloop's
|
|
658
|
+
// fix slices the raw ISO string's UTC HH:MM:SS as-is, with the full ISO
|
|
659
|
+
// kept in `title`; fwdloop differs on purpose because every OTHER
|
|
660
|
+
// timestamp on this page already reads in LOCAL time (`readableDateTime`,
|
|
661
|
+
// `toLocaleString()`) — so here the short text is local time-only
|
|
662
|
+
// (`toLocaleTimeString()`), not a raw UTC slice, and the full string kept
|
|
663
|
+
// in `title` is the same local `readableDateTime` string used everywhere
|
|
664
|
+
// else, not the raw ISO. A pre-M4a-2 row's `atWhy` (or a genuinely
|
|
665
|
+
// unparseable/missing `at`) is unaffected: that text renders plain, never
|
|
666
|
+
// wrapped in a <span title>, so `auditTimeCellText`'s own fallback text
|
|
667
|
+
// stays exactly what it was.
|
|
668
|
+
function auditTimeCellHtml(r){
|
|
669
|
+
if(typeof r.atWhy === "string" && r.atWhy.length > 0) return escapeXml(r.atWhy);
|
|
670
|
+
var full = readableDateTime(r.at);
|
|
671
|
+
var d = new Date(r.at);
|
|
672
|
+
if(!full || isNaN(d.getTime())) return escapeXml(full || "unknown");
|
|
673
|
+
var short = d.toLocaleTimeString();
|
|
674
|
+
return '<span title="' + escapeXml(full) + '">' + escapeXml(short) + '</span>';
|
|
675
|
+
}
|
|
676
|
+
function duration(ms){
|
|
677
|
+
if(typeof ms !== "number" || ms < 0) return "unknown";
|
|
678
|
+
var s = ms / 1000;
|
|
679
|
+
if(s < 60) return s.toFixed(1) + "s";
|
|
680
|
+
var m = Math.floor(s / 60), rem = Math.round(s - m * 60);
|
|
681
|
+
if(rem === 60){ m += 1; rem = 0; }
|
|
682
|
+
return m + "m" + String(rem).padStart(2, "0") + "s";
|
|
683
|
+
}
|
|
684
|
+
// A readable local date/time instead of a raw ISO timestamp (fix #5) — an
|
|
685
|
+
// unparseable value still shows the raw string (never blank/nothing), so
|
|
686
|
+
// a books bug is visible rather than silently swallowed.
|
|
687
|
+
function readableDateTime(iso){
|
|
688
|
+
if(typeof iso !== "string") return null;
|
|
689
|
+
var d = new Date(iso);
|
|
690
|
+
return isNaN(d.getTime()) ? iso : d.toLocaleString();
|
|
691
|
+
}
|
|
692
|
+
// A step box's internal state word ("pending"/"waiting") is never shown
|
|
693
|
+
// as-is (fix #4): "pending" (not attempted yet) reads "not started" —
|
|
694
|
+
// plain text, no dot/glyph at all, so it can never be mistaken for one of
|
|
695
|
+
// the reserved glyphs; "waiting" (this step is where the run is currently
|
|
696
|
+
// parked on a human) reads "waiting on you", matching the SAME words the
|
|
697
|
+
// run-row `[·]` glyph already uses (src/panel/data.js's computeGlyph) —
|
|
698
|
+
// never the bracket glyph `[▶]`, which the scope reserves for "running".
|
|
699
|
+
function stateWord(state){
|
|
700
|
+
if(state === "pending") return "not started";
|
|
701
|
+
if(state === "waiting") return "waiting on you";
|
|
702
|
+
return state; // "done" / "stopped"
|
|
703
|
+
}
|
|
704
|
+
// fwdloop's close-class vocabulary (M4a scope item 4): `green` -> "cited"
|
|
705
|
+
// (a mechanical, exact-match close), `softgreen` -> "shape" (a shape/
|
|
706
|
+
// section check), `hitl` -> "human check" (no mechanical verdict — the
|
|
707
|
+
// step hands off to a human ask). Never the raw words green/softgreen.
|
|
708
|
+
function closeClassLabel(cls){
|
|
709
|
+
if(cls === "green") return "cited";
|
|
710
|
+
if(cls === "softgreen") return "shape";
|
|
711
|
+
if(cls === "hitl") return "human check";
|
|
712
|
+
return "unknown";
|
|
713
|
+
}
|
|
714
|
+
// hamr review #1 (Summary tab): "close class(es), per step or summarized"
|
|
715
|
+
// — one count per close class actually present on this run's OWN declared
|
|
716
|
+
// steps (declaration.steps, joined server-side into detail.steps), fwdloop
|
|
717
|
+
// words only, never the raw green/softgreen/hitl strings.
|
|
718
|
+
function closeClassSummaryText(steps){
|
|
719
|
+
if(!steps || !steps.length) return null;
|
|
720
|
+
var counts = {};
|
|
721
|
+
var order = [];
|
|
722
|
+
steps.forEach(function(s){
|
|
723
|
+
var label = closeClassLabel(s.closeClass);
|
|
724
|
+
if(!Object.prototype.hasOwnProperty.call(counts, label)){ counts[label] = 0; order.push(label); }
|
|
725
|
+
counts[label] += 1;
|
|
726
|
+
});
|
|
727
|
+
return order.map(function(label){ return counts[label] + " " + label; }).join(", ");
|
|
728
|
+
}
|
|
729
|
+
// hamr review #1 (Summary tab): "from spend.jsonl what exists (rounds
|
|
730
|
+
// total, tokens in/out, cache-read tokens) — ONLY if each spend row can be
|
|
731
|
+
// tied to its run honestly" — run-level totals only (src/panel/data.js's
|
|
732
|
+
// summarizeSpendRows already does the honest per-field null-with-why), no
|
|
733
|
+
// per-step attribution invented here. Tool-call counts are never shown —
|
|
734
|
+
// no fwdloop book holds them (hamr's own instruction: omit, don't fake 0).
|
|
735
|
+
function spendSummaryText(spendSummary){
|
|
736
|
+
if(!spendSummary || spendSummary.empty) return (spendSummary && spendSummary.why) || "no spend.jsonl rows yet";
|
|
737
|
+
var bits = [spendSummary.rounds + " round" + (spendSummary.rounds === 1 ? "" : "s")];
|
|
738
|
+
bits.push("tokens in " + (typeof spendSummary.tokensIn === "number" ? spendSummary.tokensIn : "unknown"));
|
|
739
|
+
bits.push("tokens out " + (typeof spendSummary.tokensOut === "number" ? spendSummary.tokensOut : "unknown"));
|
|
740
|
+
bits.push("cache-read " + (typeof spendSummary.cacheReadTokens === "number" ? spendSummary.cacheReadTokens : "unknown"));
|
|
741
|
+
return bits.join(" · ");
|
|
742
|
+
}
|
|
743
|
+
// An attempt's real verdict vocabulary is wider than green/hitl/not-done
|
|
744
|
+
// (src/runner.js also writes `paused`, `refused`, `ask-timeout`,
|
|
745
|
+
// `ask-expired`, `red`, `crash`-like stops) — and the scope forbids
|
|
746
|
+
// rendering the raw words green/red/softgreen anywhere (coordinator's
|
|
747
|
+
// browser-walk fix #2). `verdictWord`/`verdictGlyph` are the ONE place
|
|
748
|
+
// that turns a verdict (plus the step's own close class, for telling a
|
|
749
|
+
// human's reject apart from a mechanical red) into plain words and a
|
|
750
|
+
// pass/fail glyph — used by the step cards, the map's inline attempt
|
|
751
|
+
// text, and the flat Audit table alike, so they can never say something
|
|
752
|
+
// different for the same row.
|
|
753
|
+
// - `paused`/`refused`/an ask timeout/expiry are NOT failures (fix #3) —
|
|
754
|
+
// no ✗, a plain word instead.
|
|
755
|
+
// - a `red` verdict on a `hitl`-classed step is the human's own reject
|
|
756
|
+
// (src/runner.js's redo path), not a mechanical stop — "rejected by
|
|
757
|
+
// you: <reason>", never "verdict red" / a fail glyph (fix #3).
|
|
758
|
+
function verdictWord(verdict, closeClass, gap){
|
|
759
|
+
if(closeClass === "hitl" && verdict === "red") return "rejected by you" + (gap ? ": " + gap : "");
|
|
760
|
+
if(verdict === "paused") return "paused for you";
|
|
761
|
+
if(verdict === "refused") return "refused — no reason given";
|
|
762
|
+
if(verdict === "ask-timeout" || verdict === "ask-expired") return "expired waiting for you";
|
|
763
|
+
if(verdict === "green") return "passed";
|
|
764
|
+
if(verdict === "hitl") return "human check";
|
|
765
|
+
if(verdict === "not-done") return "not done";
|
|
766
|
+
if(typeof verdict !== "string") return "unknown";
|
|
767
|
+
return "failed"; // red (non-hitl), crash-like, cap-halt, pricing/provider-red, unparseable, ...
|
|
768
|
+
}
|
|
769
|
+
function verdictPassed(verdict){ return verdict === "green" || verdict === "hitl"; }
|
|
770
|
+
// `null` — no glyph at all — for a verdict that is neither a pass nor a
|
|
771
|
+
// fail (paused/refused/expired/a human reject); a bare attempt glyph
|
|
772
|
+
// would misread a pause as a failure (fix #3).
|
|
773
|
+
function verdictGlyph(verdict, closeClass){
|
|
774
|
+
if(closeClass === "hitl" && verdict === "red") return null;
|
|
775
|
+
if(verdict === "paused" || verdict === "refused" || verdict === "ask-timeout" || verdict === "ask-expired") return null;
|
|
776
|
+
return verdictPassed(verdict) ? "✓" : "✗";
|
|
777
|
+
}
|
|
778
|
+
// The run-row glyph strings src/panel/data.js's computeGlyph emits are
|
|
779
|
+
// already bracketed ("[✓]", "[✗]", "[·]", "[?]") — this only ever picks a
|
|
780
|
+
// CSS color class off them, never re-derives the glyph itself.
|
|
781
|
+
function glyphClass(g){
|
|
782
|
+
if(g === "[✓]") return "green";
|
|
783
|
+
if(g === "[✗]") return "red";
|
|
784
|
+
if(g === "[▶]") return "amber";
|
|
785
|
+
if(g === "[?]") return "magenta";
|
|
786
|
+
// hamr's 2026-09-27 browser-walk bug #3: an expired, unresumed ask is
|
|
787
|
+
// its own state — never grey ("waiting"/"answered", still actionable)
|
|
788
|
+
// and never red/magenta (the run itself didn't fail, and the books DO
|
|
789
|
+
// know what happened) — amber, same "needs attention" color family as
|
|
790
|
+
// "running", but a different glyph, so it gets its own dot class
|
|
791
|
+
// (never "amber", which draws the reserved running arrow [▶]).
|
|
792
|
+
if(g === "[!]") return "expired";
|
|
793
|
+
return "grey"; // "[·]" — waiting on a human, or answered-not-resumed
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
// ---- step map renderer (box-drawing geometry kept from the borrowed
|
|
797
|
+
// page's buildStepMapSVG; the DATA it draws is fwdloop's own: one box per
|
|
798
|
+
// `declaration.steps` entry, no scout/plan/judge/fix-loop/rounds — ruling
|
|
799
|
+
// A, "no per-round parts"). ----
|
|
800
|
+
function stepMapColors(state){
|
|
801
|
+
if(state === "done") return {stroke:"var(--green)", textFill:"#2e7d32"};
|
|
802
|
+
if(state === "stopped") return {stroke:"var(--red)", textFill:"var(--red)"};
|
|
803
|
+
if(state === "waiting") return {stroke:"var(--amber)", textFill:"#b8860b"};
|
|
804
|
+
return {stroke:"var(--border-strong)", textFill:"var(--text-faint)"}; // not started yet
|
|
805
|
+
}
|
|
806
|
+
var stepMapUidCounter = 0;
|
|
807
|
+
var MAP_MARGIN = 10, MAP_GAP = 28;
|
|
808
|
+
var CHAR_W = 7.2;
|
|
809
|
+
var TITLE_HPAD = 16;
|
|
810
|
+
var MIN_BOX_W = 100;
|
|
811
|
+
var BOX_H = 60, BOX_H_2LINE = 78;
|
|
812
|
+
var ROW_GAP = 70;
|
|
813
|
+
// hamr review #2: "map cards missing try 2 if multiple attempts/iteration"
|
|
814
|
+
// — a plain "try N" count whenever a step has been attempted more than
|
|
815
|
+
// once, plus a mark when the LATEST attempt followed a human reject (the
|
|
816
|
+
// same `afterReject` boundary src/panel/data.js already worked out —
|
|
817
|
+
// never re-derived here). One attempt (the common case) shows no "try"
|
|
818
|
+
// text at all, matching bareloop's own "only say it when it's true" shape.
|
|
819
|
+
// `tryCount` is server-derived (src/panel/data.js's computeTryCount) —
|
|
820
|
+
// for an ask (hitl) step it counts asks shown to the human (a pause row
|
|
821
|
+
// + its answer row are the SAME try), for a model step it counts model
|
|
822
|
+
// attempts. Never re-derived here from `attempts.length` (browser
|
|
823
|
+
// re-walk bug #2: that over-counted an ask step's pause/answer pairs).
|
|
824
|
+
function tryCountText(tryCount, attempts){
|
|
825
|
+
if(!tryCount || tryCount <= 1) return "";
|
|
826
|
+
var last = attempts && attempts.length ? attempts[attempts.length - 1] : null;
|
|
827
|
+
var txt = "try " + tryCount;
|
|
828
|
+
if(last && last.afterReject) txt += " (re-attempt after reject)";
|
|
829
|
+
return txt;
|
|
830
|
+
}
|
|
831
|
+
// hamr review (browser re-walk #1): the per-attempt list ("attempt 1
|
|
832
|
+
// failed · attempt 2 passed · …") is a map node's single biggest source of
|
|
833
|
+
// width — that level of detail belongs in the Audit tab, never on the
|
|
834
|
+
// node. A node's title is just
|
|
835
|
+
// step number + name + try N + state, kept short so naturalBoxWidth stays
|
|
836
|
+
// small and the map stays compact instead of stretching to the pane width.
|
|
837
|
+
function stepTitleText(idx, s){
|
|
838
|
+
var base = (idx + 1) + ' ' + s.emits;
|
|
839
|
+
var tryText = tryCountText(s.tryCount, s.attempts);
|
|
840
|
+
if(tryText) base += ' — ' + tryText;
|
|
841
|
+
return base;
|
|
842
|
+
}
|
|
843
|
+
// The declared step's own run-state, for the map box and the summary's
|
|
844
|
+
// "which step stopped and why" (M4a exit: "say which step stopped it and
|
|
845
|
+
// why, from one screen"): `pending` (no attempt yet), `done` (last
|
|
846
|
+
// attempt passed), `waiting` (the run is currently parked ON this step —
|
|
847
|
+
// its last attempt's verdict is `paused`/`refused`, i.e. it went to a
|
|
848
|
+
// human ask and hasn't been answered/resolved yet), `stopped` (a real
|
|
849
|
+
// stop — the last attempt failed for any other reason).
|
|
850
|
+
function stepBoxState(s){
|
|
851
|
+
if(!s.attempts || !s.attempts.length) return "pending";
|
|
852
|
+
var last = s.attempts[s.attempts.length - 1];
|
|
853
|
+
if(last.verdict === "paused" || last.verdict === "refused") return "waiting";
|
|
854
|
+
return verdictPassed(last.verdict) ? "done" : "stopped";
|
|
855
|
+
}
|
|
856
|
+
// hamr's 2026-09-27 review: a step with a server-computed `tryCount > 1`
|
|
857
|
+
// (M2/M3's runner already counts retries/redraft attempts honestly — never
|
|
858
|
+
// recounted here from `attempts.length`, which double-counts an ask step's
|
|
859
|
+
// pause+answer pair) draws a dashed loop-back edge under its map box,
|
|
860
|
+
// matching bareloop's own retry-loop shape (bareloop commit 16825a7,
|
|
861
|
+
// `boxRetryTry`) — ONE shared rule, reused by both the SVG loop path and
|
|
862
|
+
// (if ever needed) any other "does this box retry" check.
|
|
863
|
+
function boxRetryTry(box){
|
|
864
|
+
return box.tryCount > 1 ? box.tryCount : 0;
|
|
865
|
+
}
|
|
866
|
+
function buildStepBoxes(steps){
|
|
867
|
+
return (steps || []).map(function(s){
|
|
868
|
+
return {
|
|
869
|
+
emits: s.emits, goal: s.goal, closeClass: s.closeClass, primitives: s.primitives || [],
|
|
870
|
+
attempts: s.attempts || [], tryCount: s.tryCount || 0,
|
|
871
|
+
// hamr's 2026-09-27 step-card review: the SAME server-computed
|
|
872
|
+
// group pieces the Audit tab's own header reads (src/panel/data.js's
|
|
873
|
+
// deriveAuditGroups, off the SAME enriched rows) — never re-derived
|
|
874
|
+
// here. `null`/`[]` for a step with no group at all (never
|
|
875
|
+
// attempted yet), matching data.js's own honesty rules exactly.
|
|
876
|
+
timeMs: s.timeMs, cost: s.cost, costWhy: s.costWhy, tokensTotal: s.tokensTotal, tryMarks: s.tryMarks || [],
|
|
877
|
+
// Amendment M4a-3: the step's own tool tally + the signed grant it
|
|
878
|
+
// ran under — `toolsTotal`/`toolsWhy` off the SAME server-computed
|
|
879
|
+
// group `tokensTotal` already reads (src/panel/data.js's
|
|
880
|
+
// `summarizeStepTools`), never re-derived; `ungranted` is a real,
|
|
881
|
+
// book-derived list, never guessed from `primitives` by exclusion.
|
|
882
|
+
toolsTotal: s.toolsTotal || null, toolsWhy: s.toolsWhy || null, ungranted: s.ungranted || [],
|
|
883
|
+
stoppedReason: s.stoppedReason || null,
|
|
884
|
+
state: stepBoxState(s),
|
|
885
|
+
};
|
|
886
|
+
});
|
|
887
|
+
}
|
|
888
|
+
function naturalBoxWidth(steps){
|
|
889
|
+
var maxChars = 0;
|
|
890
|
+
steps.forEach(function(s, idx){ maxChars = Math.max(maxChars, stepTitleText(idx, s).length); });
|
|
891
|
+
return Math.max(MIN_BOX_W, Math.ceil(maxChars * CHAR_W) + TITLE_HPAD);
|
|
892
|
+
}
|
|
893
|
+
// hamr review #3: nodes stay compact — a box never stretches past a modest
|
|
894
|
+
// ceiling over its own natural (text-fit) width, even when the available
|
|
895
|
+
// pane is much wider (the bug: every node used to grow to fill the row).
|
|
896
|
+
var MAX_BOX_STRETCH = 1.25;
|
|
897
|
+
function computeMapLayout(n, availW, naturalW){
|
|
898
|
+
if(!availW) return {perRow:n, boxW:naturalW};
|
|
899
|
+
var usableW = availW - MAP_MARGIN * 2;
|
|
900
|
+
var ceiling = naturalW * MAX_BOX_STRETCH;
|
|
901
|
+
for(var perRow = n; perRow >= 2; perRow--){
|
|
902
|
+
var totalW = perRow * naturalW + (perRow - 1) * MAP_GAP;
|
|
903
|
+
if(totalW <= usableW){
|
|
904
|
+
var stretched = (usableW - (perRow - 1) * MAP_GAP) / perRow;
|
|
905
|
+
return {perRow:perRow, boxW:Math.max(naturalW, Math.min(stretched, ceiling))};
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
return {perRow:1, boxW:Math.max(MIN_BOX_W, Math.min(usableW, ceiling))};
|
|
909
|
+
}
|
|
910
|
+
function wrapTitleLines(text, maxWidth){
|
|
911
|
+
var maxChars = Math.max(1, Math.floor((maxWidth - TITLE_HPAD) / CHAR_W));
|
|
912
|
+
if(text.length <= maxChars) return [text];
|
|
913
|
+
var words = text.split(' ');
|
|
914
|
+
var line1 = '', i = 0;
|
|
915
|
+
for(; i < words.length; i++){
|
|
916
|
+
var cand = line1 ? line1 + ' ' + words[i] : words[i];
|
|
917
|
+
if(line1 && cand.length > maxChars) break;
|
|
918
|
+
line1 = cand;
|
|
919
|
+
}
|
|
920
|
+
if(!line1) return [text.slice(0, maxChars), text.slice(maxChars)];
|
|
921
|
+
var line2 = words.slice(i).join(' ');
|
|
922
|
+
return line2 ? [line1, line2] : [line1];
|
|
923
|
+
}
|
|
924
|
+
function buildStepMapSVG(steps, availWidth){
|
|
925
|
+
var n = steps.length;
|
|
926
|
+
var naturalW = naturalBoxWidth(steps);
|
|
927
|
+
var layout = computeMapLayout(n, availWidth, naturalW);
|
|
928
|
+
var perRow = layout.perRow, boxW = layout.boxW, gap = MAP_GAP;
|
|
929
|
+
var rows = Math.ceil(n / perRow);
|
|
930
|
+
var margin = MAP_MARGIN;
|
|
931
|
+
var titleLines = steps.map(function(s, idx){ return wrapTitleLines(stepTitleText(idx, s), boxW); });
|
|
932
|
+
var maxLines = titleLines.reduce(function(m, l){ return Math.max(m, l.length); }, 1);
|
|
933
|
+
var boxH = maxLines > 1 ? BOX_H_2LINE : BOX_H;
|
|
934
|
+
var rowH = boxH + ROW_GAP;
|
|
935
|
+
var totalW = margin * 2 + perRow * boxW + (perRow - 1) * gap;
|
|
936
|
+
var totalH = rows * rowH;
|
|
937
|
+
var uid = "sm" + (stepMapUidCounter++);
|
|
938
|
+
var body =
|
|
939
|
+
'<defs>' +
|
|
940
|
+
'<marker id="' + uid + '-arrow" markerWidth="8" markerHeight="8" refX="6" refY="3" orient="auto">' +
|
|
941
|
+
'<path d="M0,0 L6,3 L0,6 z" fill="var(--text-dim)"></path></marker>' +
|
|
942
|
+
'<marker id="' + uid + '-arrow-grey" markerWidth="8" markerHeight="8" refX="6" refY="3" orient="auto">' +
|
|
943
|
+
'<path d="M0,0 L6,3 L0,6 z" fill="var(--text-faint)"></path></marker>' +
|
|
944
|
+
'</defs>';
|
|
945
|
+
steps.forEach(function(s, idx){
|
|
946
|
+
var row = Math.floor(idx / perRow);
|
|
947
|
+
var col = idx % perRow;
|
|
948
|
+
var rtl = (row % 2) === 1;
|
|
949
|
+
var slotCol = rtl ? (perRow - 1 - col) : col;
|
|
950
|
+
var x = margin + slotCol * (boxW + gap);
|
|
951
|
+
var y = 30 + row * rowH;
|
|
952
|
+
var colors = stepMapColors(s.state);
|
|
953
|
+
var lines = titleLines[idx];
|
|
954
|
+
var nextRowIdx = idx < n - 1 ? Math.floor((idx + 1) / perRow) : null;
|
|
955
|
+
var hasDrop = nextRowIdx !== null && nextRowIdx !== row;
|
|
956
|
+
var stateY = y + boxH - 18;
|
|
957
|
+
// hamr review #4: each node is a clickable group ("map-step", tagged
|
|
958
|
+
// with the step's own `emits` id) — the click listener that turns this
|
|
959
|
+
// into a jump to the Audit tab's matching group is wired AFTER
|
|
960
|
+
// insertion (renderStepMap, below), never inline here (this function
|
|
961
|
+
// only ever builds a markup string).
|
|
962
|
+
body += '<g class="map-step" data-emits="' + escapeXml(s.emits) + '" tabindex="0" role="button" aria-label="open ' + escapeXml(s.emits) + ' in Audit">';
|
|
963
|
+
body += '<rect x="' + x + '" y="' + y + '" width="' + boxW + '" height="' + boxH +
|
|
964
|
+
'" rx="0" fill="var(--panel2)" stroke="' + colors.stroke + '" stroke-width="2"></rect>';
|
|
965
|
+
if(lines.length === 1){
|
|
966
|
+
body += '<text x="' + (x + boxW / 2) + '" y="' + (y + 25) +
|
|
967
|
+
'" text-anchor="middle" font-size="12" fill="var(--text)">' + escapeXml(lines[0]) + '</text>';
|
|
968
|
+
} else {
|
|
969
|
+
body += '<text x="' + (x + boxW / 2) + '" y="' + (y + 17) +
|
|
970
|
+
'" text-anchor="middle" font-size="12" fill="var(--text)">' + escapeXml(lines[0]) + '</text>';
|
|
971
|
+
body += '<text x="' + (x + boxW / 2) + '" y="' + (y + 29) +
|
|
972
|
+
'" text-anchor="middle" font-size="12" fill="var(--text)">' + escapeXml(lines[1]) + '</text>';
|
|
973
|
+
}
|
|
974
|
+
body += '<text x="' + (x + boxW / 2) + '" y="' + stateY +
|
|
975
|
+
'" text-anchor="middle" font-size="10" fill="' + colors.textFill + '">' + escapeXml(stateWord(s.state)) + '</text>';
|
|
976
|
+
body += '</g>';
|
|
977
|
+
// hamr's 2026-09-27 retry-loop review: a step whose server-computed
|
|
978
|
+
// tryCount is >1 gets a dashed grey self-loop under its box, labelled
|
|
979
|
+
// "try N" — ported from bareloop commit 16825a7's own curve (same
|
|
980
|
+
// control-point proportions, scaled to THIS box's own width). When the
|
|
981
|
+
// same box also carries the row-to-row snake drop below (which leaves
|
|
982
|
+
// from dead-center, x=cx), the loop's start is shifted off-center by a
|
|
983
|
+
// fixed pixel offset so the two paths never begin at the same point.
|
|
984
|
+
var retryTry = boxRetryTry(s);
|
|
985
|
+
if(retryTry){
|
|
986
|
+
var retryShift = hasDrop ? 14 : 0;
|
|
987
|
+
var bottom = y + boxH;
|
|
988
|
+
var sx = x + boxW * 0.50 - retryShift, sy = bottom + 5;
|
|
989
|
+
var c1x = x + boxW * 0.278 - retryShift, c1y = bottom + 30;
|
|
990
|
+
var c2x = x + boxW * 0.167 - retryShift, c2y = bottom + 30;
|
|
991
|
+
var ex = x + boxW * 0.028 - retryShift, ey = bottom + 2;
|
|
992
|
+
body += '<path d="M ' + sx + ' ' + sy + ' C ' + c1x + ' ' + c1y + ', ' + c2x + ' ' + c2y + ', ' + ex + ' ' + ey +
|
|
993
|
+
'" fill="none" stroke="var(--text-faint)" stroke-width="1.5" stroke-dasharray="3,3" marker-end="url(#' + uid + '-arrow-grey)"></path>';
|
|
994
|
+
body += '<text x="' + (x + boxW * 0.267 - retryShift) + '" y="' + (bottom + 32) +
|
|
995
|
+
'" text-anchor="middle" font-size="10" fill="var(--text-faint)">try ' + retryTry + '</text>';
|
|
996
|
+
}
|
|
997
|
+
if(idx < n - 1){
|
|
998
|
+
if(nextRowIdx === row){
|
|
999
|
+
var midY = y + boxH / 2;
|
|
1000
|
+
if(!rtl){
|
|
1001
|
+
var nx = x + boxW + gap;
|
|
1002
|
+
body += '<line x1="' + (x + boxW) + '" y1="' + midY + '" x2="' + (nx - 2) + '" y2="' + midY +
|
|
1003
|
+
'" stroke="var(--text-dim)" stroke-width="2" marker-end="url(#' + uid + '-arrow)"></line>';
|
|
1004
|
+
} else {
|
|
1005
|
+
var px = x - gap - boxW;
|
|
1006
|
+
body += '<line x1="' + x + '" y1="' + midY + '" x2="' + (px + boxW + 2) + '" y2="' + midY +
|
|
1007
|
+
'" stroke="var(--text-dim)" stroke-width="2" marker-end="url(#' + uid + '-arrow)"></line>';
|
|
1008
|
+
}
|
|
1009
|
+
} else {
|
|
1010
|
+
var cx = x + boxW / 2;
|
|
1011
|
+
body += '<line x1="' + cx + '" y1="' + (y + boxH) + '" x2="' + cx + '" y2="' + (y + rowH - 2) +
|
|
1012
|
+
'" stroke="var(--text-dim)" stroke-width="2" marker-end="url(#' + uid + '-arrow)"></line>';
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
});
|
|
1016
|
+
return '<svg width="' + totalW + '" height="' + totalH + '" viewBox="0 0 ' + totalW + ' ' + totalH + '" role="img" aria-label="step map">' + body + '</svg>';
|
|
1017
|
+
}
|
|
1018
|
+
// Legend glyphs match the scope's own vocabulary (fix #4): `[✓]` done,
|
|
1019
|
+
// `[✗]` stopped, `[·]` waiting on you (the default/grey dot — never the
|
|
1020
|
+
// amber `[▶]`, which the scope reserves for "running", a state this panel
|
|
1021
|
+
// cannot tell apart from "died" at all today — M4a's own open POC
|
|
1022
|
+
// question). "not started" gets no dot/glyph at all, so it can never be
|
|
1023
|
+
// confused with a reserved one.
|
|
1024
|
+
function stepMapLegendHTML(){
|
|
1025
|
+
return '<div class="map-legend">' +
|
|
1026
|
+
'<span><span class="dot green"></span>done</span>' +
|
|
1027
|
+
'<span><span class="dot red"></span>stopped</span>' +
|
|
1028
|
+
'<span><span class="dot"></span>waiting on you</span>' +
|
|
1029
|
+
'<span>not started</span>' +
|
|
1030
|
+
'<span>⤾ dashed = retry</span>' +
|
|
1031
|
+
'</div>';
|
|
1032
|
+
}
|
|
1033
|
+
var lastSteps = null;
|
|
1034
|
+
var lastWidth = null;
|
|
1035
|
+
function mapAvailWidth(wrapper){
|
|
1036
|
+
if(!wrapper) return null;
|
|
1037
|
+
var w = wrapper.getBoundingClientRect().width;
|
|
1038
|
+
if(!w) return null;
|
|
1039
|
+
return Math.max(0, w - 20);
|
|
1040
|
+
}
|
|
1041
|
+
// hamr review #4: "clicking on cards below codegraph maps should take you
|
|
1042
|
+
// to audit trail" — a map node's click (or Enter/Space, since the node
|
|
1043
|
+
// carries role=button/tabindex) jumps to the Audit tab, switches it to the
|
|
1044
|
+
// Grouped view, and scrolls/highlights that exact step's group.
|
|
1045
|
+
// `openAuditGroup` itself is defined further down (near the Audit-tab
|
|
1046
|
+
// renderer, its natural home) — function declarations in this IIFE are
|
|
1047
|
+
// hoisted, so the forward reference here is safe.
|
|
1048
|
+
function wireMapClicks(mount){
|
|
1049
|
+
mount.querySelectorAll(".map-step").forEach(function(g){
|
|
1050
|
+
g.addEventListener("click", function(){ openAuditGroup(g.getAttribute("data-emits")); });
|
|
1051
|
+
g.addEventListener("keydown", function(e){ if(e.key === "Enter" || e.key === " "){ e.preventDefault(); g.click(); } });
|
|
1052
|
+
});
|
|
1053
|
+
}
|
|
1054
|
+
function renderStepMap(steps){
|
|
1055
|
+
var mount = document.getElementById("map-mount");
|
|
1056
|
+
var wrapper = document.getElementById("map-box");
|
|
1057
|
+
lastSteps = steps;
|
|
1058
|
+
if(!steps || !steps.length){
|
|
1059
|
+
mount.innerHTML = "";
|
|
1060
|
+
wrapper.hidden = true;
|
|
1061
|
+
return;
|
|
1062
|
+
}
|
|
1063
|
+
wrapper.hidden = false;
|
|
1064
|
+
var w = mapAvailWidth(wrapper);
|
|
1065
|
+
lastWidth = w;
|
|
1066
|
+
mount.innerHTML = buildStepMapSVG(steps, w) + stepMapLegendHTML();
|
|
1067
|
+
wireMapClicks(mount);
|
|
1068
|
+
}
|
|
1069
|
+
function reflowMap(){
|
|
1070
|
+
var wrapper = document.getElementById("map-box");
|
|
1071
|
+
if(!wrapper || wrapper.hidden || !lastSteps) return;
|
|
1072
|
+
var w = mapAvailWidth(wrapper);
|
|
1073
|
+
if(w === null || w === lastWidth) return;
|
|
1074
|
+
lastWidth = w;
|
|
1075
|
+
var mount = document.getElementById("map-mount");
|
|
1076
|
+
mount.innerHTML = buildStepMapSVG(lastSteps, w) + stepMapLegendHTML();
|
|
1077
|
+
wireMapClicks(mount);
|
|
1078
|
+
}
|
|
1079
|
+
if(typeof ResizeObserver !== "undefined"){
|
|
1080
|
+
var ro = new ResizeObserver(function(){ reflowMap(); });
|
|
1081
|
+
var mb = document.getElementById("map-box");
|
|
1082
|
+
if(mb) ro.observe(mb);
|
|
1083
|
+
} else {
|
|
1084
|
+
window.addEventListener("resize", reflowMap);
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1087
|
+
// ---- Runs tab: ONE run-row builder shared by History (flat) and the
|
|
1088
|
+
// Workflows view's per-flow expansion — the two never drift on how a run
|
|
1089
|
+
// row reads. Rekeyed from bareloop's job/runid to fwdloop's flow/runId
|
|
1090
|
+
// (GET /api/runs row shape: src/panel/data.js's listRuns).
|
|
1091
|
+
function buildRunRowEl(r){
|
|
1092
|
+
var row = document.createElement("div");
|
|
1093
|
+
// Selected state is computed here, off the module's own `currentRunId`,
|
|
1094
|
+
// so a row freshly built by a RE-RENDER (switching Runs view mode, or a
|
|
1095
|
+
// Workflows parent auto-expanding onto an older run picked from
|
|
1096
|
+
// History) shows selected without needing a click on this exact
|
|
1097
|
+
// element — `selectRun`'s imperative class toggle (used when a click
|
|
1098
|
+
// passes its own `rowEl`) stays layered on top of this, never replaced.
|
|
1099
|
+
var selected = r.flow === currentFlow && r.runId === currentRunId;
|
|
1100
|
+
row.className = "hist-row" + (selected ? " selected" : "");
|
|
1101
|
+
row.setAttribute("data-testid", "hist-row-" + r.flow + "-" + (r.runId || "none"));
|
|
1102
|
+
row.setAttribute("tabindex", "0");
|
|
1103
|
+
row.setAttribute("role", "button");
|
|
1104
|
+
row.setAttribute("aria-pressed", selected ? "true" : "false");
|
|
1105
|
+
var fullName = r.flow + (r.runId ? ' (' + r.runId + ')' : '');
|
|
1106
|
+
if(r.runId === null){
|
|
1107
|
+
// this flow has no runs yet — empty state names why, never a made-up row.
|
|
1108
|
+
row.innerHTML =
|
|
1109
|
+
'<span class="wf-line1"><span class="dot grey"></span>' +
|
|
1110
|
+
'<span class="wf-name" title="' + escapeXml(fullName) + '">' + escapeXml(fullName) + '</span></span>' +
|
|
1111
|
+
'<span class="wf-meta-line"><span class="wf-meta">' + escapeXml(r.why || "no runs yet") + '</span></span>';
|
|
1112
|
+
row.removeAttribute("tabindex");
|
|
1113
|
+
row.removeAttribute("role");
|
|
1114
|
+
return row;
|
|
1115
|
+
}
|
|
1116
|
+
row.innerHTML =
|
|
1117
|
+
'<span class="wf-line1"><span class="dot ' + glyphClass(r.glyph) + '"></span>' +
|
|
1118
|
+
'<span class="wf-name" title="' + escapeXml(fullName) + '">' + escapeXml(fullName) + '</span></span>' +
|
|
1119
|
+
'<span class="wf-meta-line">' +
|
|
1120
|
+
'<span class="wf-meta">' + escapeXml(r.label || "unknown") + '</span>' +
|
|
1121
|
+
'<span class="wf-meta">' + escapeXml(r.spend || r.spendWhy || "unknown") + '</span>' +
|
|
1122
|
+
'<span class="wf-meta">' + escapeXml(r.at ? r.at.slice(0,10) : (r.askedAt ? "asked " + readableDateTime(r.askedAt) : (r.atWhy || "unknown"))) + '</span>' +
|
|
1123
|
+
'</span>';
|
|
1124
|
+
row.addEventListener("click", function(){ selectRun(r.flow, r.runId, row, ".hist-row"); document.getElementById("tab-run").click(); scrollRunIntoViewMobile(); });
|
|
1125
|
+
row.addEventListener("keydown", function(e){ if(e.key === "Enter" || e.key === " "){ e.preventDefault(); row.click(); } });
|
|
1126
|
+
return row;
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1129
|
+
// ---- History view: every row exactly as /api/runs returned it. ----
|
|
1130
|
+
function renderHistory(runs){
|
|
1131
|
+
var el = document.getElementById("history-list");
|
|
1132
|
+
el.innerHTML = "";
|
|
1133
|
+
if(!(runs || []).length){
|
|
1134
|
+
el.innerHTML = '<div class="hint">no runs listed yet — no flow under this root has been run</div>';
|
|
1135
|
+
return;
|
|
1136
|
+
}
|
|
1137
|
+
runs.forEach(function(r){ el.appendChild(buildRunRowEl(r)); });
|
|
1138
|
+
}
|
|
1139
|
+
|
|
1140
|
+
// ---- Workflows view: groups the ONE /api/runs payload by flow name
|
|
1141
|
+
// client-side. Runs arrive newest-first within a flow (server contract,
|
|
1142
|
+
// listRuns), so the first run seen for a flow is its latest.
|
|
1143
|
+
function groupRunsByFlow(runs){
|
|
1144
|
+
var byFlow = {};
|
|
1145
|
+
var order = [];
|
|
1146
|
+
(runs || []).forEach(function(r){
|
|
1147
|
+
if(!byFlow[r.flow]){ byFlow[r.flow] = []; order.push(r.flow); }
|
|
1148
|
+
byFlow[r.flow].push(r);
|
|
1149
|
+
});
|
|
1150
|
+
return order.map(function(flow){
|
|
1151
|
+
var flowRuns = byFlow[flow];
|
|
1152
|
+
var last = flowRuns[0];
|
|
1153
|
+
return {
|
|
1154
|
+
flow: flow,
|
|
1155
|
+
runs: flowRuns,
|
|
1156
|
+
runCount: last.runId === null ? 0 : flowRuns.length,
|
|
1157
|
+
lastRunId: last.runId,
|
|
1158
|
+
lastAt: last.at,
|
|
1159
|
+
lastGlyph: last.glyph,
|
|
1160
|
+
lastLabel: last.label,
|
|
1161
|
+
lastSpend: last.spend,
|
|
1162
|
+
lastRow: last,
|
|
1163
|
+
};
|
|
1164
|
+
});
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1167
|
+
// Matches a flow if ANY of its runs match the filters (not only the
|
|
1168
|
+
// latest) — a one-line adapter over filterRuns, never a reimplementation
|
|
1169
|
+
// of the AND/OR/time/search semantics.
|
|
1170
|
+
function filterWorkflows(flows, filters, nowMs){
|
|
1171
|
+
return (flows || []).filter(function(g){
|
|
1172
|
+
return filterRuns(g.runs, filters, nowMs).length > 0;
|
|
1173
|
+
});
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1176
|
+
function filtersActive(filters){
|
|
1177
|
+
return !!(filters && (
|
|
1178
|
+
(filters.results && filters.results.length) ||
|
|
1179
|
+
(filters.time && filters.time !== "all") ||
|
|
1180
|
+
(filters.search && String(filters.search).trim())
|
|
1181
|
+
));
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
// Pure rule: when filters/search are active, a flow whose LATEST run
|
|
1185
|
+
// doesn't match but an older one does auto-expands so the matching run is
|
|
1186
|
+
// visible without an extra click; inactive filters never force an expand.
|
|
1187
|
+
function autoExpandFlow(group, matchingRuns, active){
|
|
1188
|
+
if(!active || !matchingRuns.length) return false;
|
|
1189
|
+
var latestId = group.runs.length ? group.runs[0].runId : null;
|
|
1190
|
+
var latestIncluded = matchingRuns.some(function(r){ return r.runId === latestId; });
|
|
1191
|
+
return !latestIncluded;
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
// ONE owner for "which run does this parent row stand for" — both its own
|
|
1195
|
+
// selected state and what its click opens read this, never two separate
|
|
1196
|
+
// rules that could drift. Unfiltered (or when the latest still matches),
|
|
1197
|
+
// a flow's parent always stands for its latest run. With a filter/search
|
|
1198
|
+
// that matches an OLDER run but excludes the latest, the parent stands
|
|
1199
|
+
// for the newest MATCHING run instead.
|
|
1200
|
+
function representedRun(group, candidateRuns, active){
|
|
1201
|
+
if(active && candidateRuns.length){
|
|
1202
|
+
var latestIncluded = candidateRuns.some(function(r){ return r.runId === group.lastRunId; });
|
|
1203
|
+
if(!latestIncluded) return candidateRuns[0].runId;
|
|
1204
|
+
}
|
|
1205
|
+
return group.lastRunId;
|
|
1206
|
+
}
|
|
1207
|
+
|
|
1208
|
+
// Is `currentRunId` one of this flow's OLDER runs (i.e. a run that
|
|
1209
|
+
// belongs to this flow but isn't its latest)? Selecting a run from
|
|
1210
|
+
// History and switching to Workflows lands here: the flow must
|
|
1211
|
+
// auto-expand and its matching child row must carry the selected marker
|
|
1212
|
+
// even though no filter/search is active.
|
|
1213
|
+
function activeOlderRun(group){
|
|
1214
|
+
if(currentFlow !== group.flow || !currentRunId || currentRunId === group.lastRunId) return null;
|
|
1215
|
+
var found = group.runs.some(function(r){ return r.runId === currentRunId; });
|
|
1216
|
+
return found ? currentRunId : null;
|
|
1217
|
+
}
|
|
1218
|
+
|
|
1219
|
+
// manual expand/collapse memory, keyed by flow name — survives a
|
|
1220
|
+
// re-render triggered by a filter/search change within the same page
|
|
1221
|
+
// load, reset on full page reload (per-viewer convenience only, never
|
|
1222
|
+
// persisted). A manual collapse click still wins over auto-expand-for-
|
|
1223
|
+
// selection on the next render.
|
|
1224
|
+
var wfExpanded = {};
|
|
1225
|
+
|
|
1226
|
+
function renderWorkflows(flows){
|
|
1227
|
+
var el = document.getElementById("wf-list");
|
|
1228
|
+
el.innerHTML = "";
|
|
1229
|
+
if(!flows.length){
|
|
1230
|
+
el.innerHTML = '<div class="hint">no runs listed yet — no flow under this root has been run</div>';
|
|
1231
|
+
return;
|
|
1232
|
+
}
|
|
1233
|
+
var active = filtersActive(currentRunsFilters());
|
|
1234
|
+
flows.forEach(function(g){
|
|
1235
|
+
if(g.lastRunId === null){ el.appendChild(buildRunRowEl(g.lastRow)); return; } // "this flow has no runs yet"
|
|
1236
|
+
// the parent row IS the flow's latest run (clicking it opens that
|
|
1237
|
+
// run), so the inline child list must be the flow's OTHER runs only.
|
|
1238
|
+
// Expand affordance (caret, aria-expanded, toggle) is gated on there
|
|
1239
|
+
// being a child to actually show.
|
|
1240
|
+
var candidateRuns = active ? filterRuns(g.runs, currentRunsFilters(), Date.now()) : g.runs;
|
|
1241
|
+
var childRuns = candidateRuns.filter(function(r){ return r.runId !== g.lastRunId; });
|
|
1242
|
+
var hasOtherRuns = childRuns.length > 0;
|
|
1243
|
+
var olderSelected = activeOlderRun(g);
|
|
1244
|
+
var autoExpand = hasOtherRuns && (autoExpandFlow(g, candidateRuns, active) || !!olderSelected);
|
|
1245
|
+
var expanded = hasOtherRuns && (Object.prototype.hasOwnProperty.call(wfExpanded, g.flow) ? wfExpanded[g.flow] : autoExpand);
|
|
1246
|
+
var targetRunId = representedRun(g, candidateRuns, active);
|
|
1247
|
+
|
|
1248
|
+
var wrap = document.createElement("div");
|
|
1249
|
+
wrap.className = "wf-job";
|
|
1250
|
+
|
|
1251
|
+
var row = document.createElement("div");
|
|
1252
|
+
// a flow (parent) row also opens its latest run in the Run tab, same
|
|
1253
|
+
// as a child row — computed HERE, at render time (this function tears
|
|
1254
|
+
// down and rebuilds every row on every click).
|
|
1255
|
+
var isSelected = currentFlow === g.flow && currentRunId === targetRunId;
|
|
1256
|
+
row.className = "wf-row" + (isSelected ? " selected" : "");
|
|
1257
|
+
row.setAttribute("data-wf", g.flow);
|
|
1258
|
+
row.setAttribute("data-testid", "wf-row-" + g.flow);
|
|
1259
|
+
row.setAttribute("tabindex", "0");
|
|
1260
|
+
row.setAttribute("role", "button");
|
|
1261
|
+
row.setAttribute("aria-expanded", expanded ? "true" : "false");
|
|
1262
|
+
row.setAttribute("aria-pressed", isSelected ? "true" : "false");
|
|
1263
|
+
var wfFullName = g.flow + ' (' + g.lastRunId + ')';
|
|
1264
|
+
row.innerHTML =
|
|
1265
|
+
'<span class="wf-line1"><span class="wf-caret">' + (hasOtherRuns ? (expanded ? "▼" : "▶") : "") + '</span><span class="dot ' + glyphClass(g.lastGlyph) + '"></span>' +
|
|
1266
|
+
'<span class="wf-name" title="' + escapeXml(wfFullName) + '">' + escapeXml(wfFullName) + '</span></span>' +
|
|
1267
|
+
'<span class="wf-meta-line">' +
|
|
1268
|
+
'<span class="wf-meta">' + escapeXml(g.lastLabel || "unknown") + '</span>' +
|
|
1269
|
+
'<span class="wf-meta">' + escapeXml(g.lastSpend || "unknown") + '</span>' +
|
|
1270
|
+
'<span class="wf-meta">' + escapeXml(g.lastAt ? g.lastAt.slice(0,10) : "unknown") + '</span>' +
|
|
1271
|
+
'<span class="wf-meta">' + g.runCount + ' run' + (g.runCount === 1 ? '' : 's') + '</span>' +
|
|
1272
|
+
'</span>';
|
|
1273
|
+
row.addEventListener("click", function(){
|
|
1274
|
+
// a single-run flow has nothing to expand — the click still opens
|
|
1275
|
+
// the run, it just never toggles `wfExpanded` for it.
|
|
1276
|
+
if(hasOtherRuns) wfExpanded[g.flow] = !expanded;
|
|
1277
|
+
selectRun(g.flow, targetRunId, null, ".hist-row");
|
|
1278
|
+
document.getElementById("tab-run").click();
|
|
1279
|
+
scrollRunIntoViewMobile();
|
|
1280
|
+
renderWorkflows(flows);
|
|
1281
|
+
});
|
|
1282
|
+
row.addEventListener("keydown", function(e){ if(e.key === "Enter" || e.key === " "){ e.preventDefault(); row.click(); } });
|
|
1283
|
+
wrap.appendChild(row);
|
|
1284
|
+
|
|
1285
|
+
if(expanded){
|
|
1286
|
+
var runsWrap = document.createElement("div");
|
|
1287
|
+
runsWrap.className = "wf-runs";
|
|
1288
|
+
childRuns.forEach(function(r){ runsWrap.appendChild(buildRunRowEl(r)); });
|
|
1289
|
+
wrap.appendChild(runsWrap);
|
|
1290
|
+
}
|
|
1291
|
+
el.appendChild(wrap);
|
|
1292
|
+
});
|
|
1293
|
+
}
|
|
1294
|
+
|
|
1295
|
+
// ---- Filter bar — ONE component, ONE state shape ({results, time,
|
|
1296
|
+
// search}), used by BOTH the History tab (filters individual runs) and
|
|
1297
|
+
// the Workflows tab (filters by each flow's OWN latest-run fields).
|
|
1298
|
+
// bareloop's checkType (deterministic/rubric) chips are dropped — fwdloop
|
|
1299
|
+
// has no such concept; the result chips use fwdloop's own glyph
|
|
1300
|
+
// vocabulary ([✓]/[✗]/[·]/[?] — `[▶]` never appears from listRuns today,
|
|
1301
|
+
// see docs/wiki/the-module-ladder.md's M4a open POC question, so no chip
|
|
1302
|
+
// for a state the books can't produce).
|
|
1303
|
+
function filterBarHTML(scope){
|
|
1304
|
+
return (
|
|
1305
|
+
'<div class="filterbar" data-scope="' + scope + '" data-testid="' + scope + '-filters">' +
|
|
1306
|
+
'<input type="text" class="search-input" placeholder="search flow or run id…" ' +
|
|
1307
|
+
'id="' + scope + '-filter-search" data-testid="' + scope + '-filter-search" autocomplete="off">' +
|
|
1308
|
+
'<div class="chips" role="group" aria-label="Filter">' +
|
|
1309
|
+
'<button class="chip fchip" type="button" aria-pressed="false" data-filter-group="result" data-filter-value="[✓]" title="passed" data-testid="chip-' + scope + '-res-pass">✓</button>' +
|
|
1310
|
+
'<button class="chip fchip" type="button" aria-pressed="false" data-filter-group="result" data-filter-value="[✗]" title="failed" data-testid="chip-' + scope + '-res-fail">✗</button>' +
|
|
1311
|
+
'<button class="chip fchip" type="button" aria-pressed="false" data-filter-group="result" data-filter-value="[·]" title="waiting on a human" data-testid="chip-' + scope + '-res-waiting">·</button>' +
|
|
1312
|
+
'<button class="chip fchip" type="button" aria-pressed="false" data-filter-group="result" data-filter-value="[?]" title="running or died: unknown" data-testid="chip-' + scope + '-res-unknown">?</button>' +
|
|
1313
|
+
'<button class="chip fchip" type="button" aria-pressed="false" data-filter-group="time" data-filter-value="7d" title="last 7 days" data-testid="chip-' + scope + '-time-7d">7d</button>' +
|
|
1314
|
+
'<button class="chip fchip" type="button" aria-pressed="false" data-filter-group="time" data-filter-value="30d" title="last 30 days" data-testid="chip-' + scope + '-time-30d">30d</button>' +
|
|
1315
|
+
'<button class="chip fchip" type="button" aria-pressed="true" data-filter-group="time" data-filter-value="all" title="all time" data-testid="chip-' + scope + '-time-all">all</button>' +
|
|
1316
|
+
'<button class="chip fchip" type="button" id="' + scope + '-filter-clear" data-testid="' + scope + '-filter-clear">clear</button>' +
|
|
1317
|
+
'</div>' +
|
|
1318
|
+
'<div class="hint" id="' + scope + '-filter-count" data-testid="' + scope + '-filter-count"></div>' +
|
|
1319
|
+
'</div>'
|
|
1320
|
+
);
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1323
|
+
// Pure function: chips combine AND across the two groups (result/time),
|
|
1324
|
+
// OR within a group (an empty group array means "no filter" for that
|
|
1325
|
+
// group). `time` is single-select, default "all". `nowMs` is injectable
|
|
1326
|
+
// for tests. Field names (flow/runId/glyph/at) match a run row's own
|
|
1327
|
+
// shape (src/panel/data.js's listRuns). Search is case-insensitive
|
|
1328
|
+
// substring match on flow name AND runId.
|
|
1329
|
+
function matchesSearch(flow, runId, query){
|
|
1330
|
+
if(!query) return true;
|
|
1331
|
+
var q = String(query).trim().toLowerCase();
|
|
1332
|
+
if(!q) return true;
|
|
1333
|
+
var f = String(flow || "").toLowerCase();
|
|
1334
|
+
var r = String(runId || "").toLowerCase();
|
|
1335
|
+
return f.indexOf(q) !== -1 || r.indexOf(q) !== -1;
|
|
1336
|
+
}
|
|
1337
|
+
function filterRuns(runs, filters, nowMs){
|
|
1338
|
+
nowMs = (typeof nowMs === "number") ? nowMs : Date.now();
|
|
1339
|
+
var rs = (filters && filters.results) || [];
|
|
1340
|
+
var time = (filters && filters.time) || "all";
|
|
1341
|
+
var q = (filters && filters.search) || "";
|
|
1342
|
+
return (runs || []).filter(function(r){
|
|
1343
|
+
if(r.runId === null) return true; // the "this flow has no runs yet" row always shows
|
|
1344
|
+
if(rs.length && rs.indexOf(r.glyph) === -1) return false;
|
|
1345
|
+
if(!matchesSearch(r.flow, r.runId, q)) return false;
|
|
1346
|
+
if(time !== "all"){
|
|
1347
|
+
var days = time === "7d" ? 7 : 30;
|
|
1348
|
+
var t = typeof r.at === "string" ? Date.parse(r.at) : NaN;
|
|
1349
|
+
if(!isFinite(t)) return false;
|
|
1350
|
+
if(nowMs - t > days * 24 * 60 * 60 * 1000) return false;
|
|
1351
|
+
}
|
|
1352
|
+
return true;
|
|
1353
|
+
});
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1356
|
+
/**
|
|
1357
|
+
* One filter-bar instance: its own localStorage key, its own DOM scope
|
|
1358
|
+
* (`.filterbar[data-scope="..."]`), its own item list — but the same
|
|
1359
|
+
* wiring as every other instance.
|
|
1360
|
+
* @param {{scope:string, storageKey:string, filterFn:Function, applyFn:Function}} opts
|
|
1361
|
+
*/
|
|
1362
|
+
function createFilterBar(opts){
|
|
1363
|
+
var scope = opts.scope;
|
|
1364
|
+
var storageKey = opts.storageKey;
|
|
1365
|
+
var state = { results: [], time: "all", search: "" };
|
|
1366
|
+
var allItems = [];
|
|
1367
|
+
|
|
1368
|
+
function load(){
|
|
1369
|
+
try{
|
|
1370
|
+
var raw = localStorage.getItem(storageKey);
|
|
1371
|
+
if(raw){
|
|
1372
|
+
var parsed = JSON.parse(raw);
|
|
1373
|
+
if(parsed && typeof parsed === "object"){
|
|
1374
|
+
state = {
|
|
1375
|
+
results: Array.isArray(parsed.results) ? parsed.results : [],
|
|
1376
|
+
time: typeof parsed.time === "string" ? parsed.time : "all",
|
|
1377
|
+
search: typeof parsed.search === "string" ? parsed.search : "",
|
|
1378
|
+
};
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
}catch(e){ /* per-viewer convenience only; a blocked/private store just means no memory */ }
|
|
1382
|
+
}
|
|
1383
|
+
function save(){
|
|
1384
|
+
try{ localStorage.setItem(storageKey, JSON.stringify(state)); }catch(e){ /* best-effort only */ }
|
|
1385
|
+
}
|
|
1386
|
+
function paint(){
|
|
1387
|
+
document.querySelectorAll('.filterbar[data-scope="' + scope + '"] .chip[data-filter-group]').forEach(function(chip){
|
|
1388
|
+
var group = chip.getAttribute("data-filter-group");
|
|
1389
|
+
var value = chip.getAttribute("data-filter-value");
|
|
1390
|
+
var active = group === "time" ? state.time === value : state.results.indexOf(value) !== -1;
|
|
1391
|
+
chip.setAttribute("aria-pressed", active ? "true" : "false");
|
|
1392
|
+
});
|
|
1393
|
+
var searchEl = document.getElementById(scope + "-filter-search");
|
|
1394
|
+
if(searchEl && searchEl.value !== state.search) searchEl.value = state.search;
|
|
1395
|
+
}
|
|
1396
|
+
function apply(){
|
|
1397
|
+
var filtered = opts.filterFn(allItems, state, Date.now());
|
|
1398
|
+
opts.applyFn(filtered);
|
|
1399
|
+
var countEl = document.getElementById(scope + "-filter-count");
|
|
1400
|
+
if(countEl) countEl.textContent = "showing " + filtered.length + " of " + allItems.length + " runs";
|
|
1401
|
+
}
|
|
1402
|
+
document.querySelectorAll('.filterbar[data-scope="' + scope + '"] .chip[data-filter-group]').forEach(function(chip){
|
|
1403
|
+
chip.addEventListener("click", function(){
|
|
1404
|
+
var group = chip.getAttribute("data-filter-group");
|
|
1405
|
+
var value = chip.getAttribute("data-filter-value");
|
|
1406
|
+
if(group === "time"){
|
|
1407
|
+
state.time = value; // single-select within time
|
|
1408
|
+
} else {
|
|
1409
|
+
var idx = state.results.indexOf(value);
|
|
1410
|
+
if(idx === -1) state.results.push(value); else state.results.splice(idx, 1);
|
|
1411
|
+
}
|
|
1412
|
+
paint();
|
|
1413
|
+
save();
|
|
1414
|
+
apply();
|
|
1415
|
+
});
|
|
1416
|
+
});
|
|
1417
|
+
var clearBtn = document.getElementById(scope + "-filter-clear");
|
|
1418
|
+
if(clearBtn){
|
|
1419
|
+
clearBtn.addEventListener("click", function(){
|
|
1420
|
+
state = { results: [], time: "all", search: "" };
|
|
1421
|
+
paint();
|
|
1422
|
+
save();
|
|
1423
|
+
apply();
|
|
1424
|
+
});
|
|
1425
|
+
}
|
|
1426
|
+
var searchInput = document.getElementById(scope + "-filter-search");
|
|
1427
|
+
if(searchInput){
|
|
1428
|
+
searchInput.addEventListener("input", function(){
|
|
1429
|
+
state.search = searchInput.value;
|
|
1430
|
+
save();
|
|
1431
|
+
apply();
|
|
1432
|
+
});
|
|
1433
|
+
}
|
|
1434
|
+
load();
|
|
1435
|
+
paint();
|
|
1436
|
+
|
|
1437
|
+
return {
|
|
1438
|
+
setItems: function(items){ allItems = items || []; apply(); },
|
|
1439
|
+
getState: function(){ return state; },
|
|
1440
|
+
refresh: function(){ apply(); },
|
|
1441
|
+
};
|
|
1442
|
+
}
|
|
1443
|
+
|
|
1444
|
+
// Workflows/History view-mode memory — same per-viewer-convenience
|
|
1445
|
+
// posture as every other localStorage read/write on this page.
|
|
1446
|
+
var RUNS_VIEW_KEY = "fwdloop-panel-runs-view";
|
|
1447
|
+
function loadRunsViewMode(){
|
|
1448
|
+
try{
|
|
1449
|
+
var v = localStorage.getItem(RUNS_VIEW_KEY);
|
|
1450
|
+
if(v === "workflows" || v === "history") return v;
|
|
1451
|
+
}catch(e){ /* per-viewer convenience only */ }
|
|
1452
|
+
return "workflows";
|
|
1453
|
+
}
|
|
1454
|
+
function saveRunsViewMode(v){
|
|
1455
|
+
try{ localStorage.setItem(RUNS_VIEW_KEY, v); }catch(e){ /* best-effort only */ }
|
|
1456
|
+
}
|
|
1457
|
+
|
|
1458
|
+
// ONE shared filter bar drives whichever view (Workflows/History) is
|
|
1459
|
+
// currently on — one scope, one localStorage key, so switching views
|
|
1460
|
+
// never loses the search/chip state.
|
|
1461
|
+
document.getElementById("runs-filterbar-anchor").innerHTML = filterBarHTML("runs");
|
|
1462
|
+
|
|
1463
|
+
var runsViewMode = loadRunsViewMode();
|
|
1464
|
+
function runsFilterFn(items, filters, nowMs){
|
|
1465
|
+
if(runsViewMode === "history") return filterRuns(items, filters, nowMs);
|
|
1466
|
+
return filterWorkflows(groupRunsByFlow(items), filters, nowMs);
|
|
1467
|
+
}
|
|
1468
|
+
function runsApplyFn(filtered){
|
|
1469
|
+
if(runsViewMode === "history") renderHistory(filtered);
|
|
1470
|
+
else renderWorkflows(filtered);
|
|
1471
|
+
}
|
|
1472
|
+
var runsFilterBar = createFilterBar({
|
|
1473
|
+
scope: "runs",
|
|
1474
|
+
storageKey: "fwdloop-panel-runs-filters",
|
|
1475
|
+
filterFn: runsFilterFn,
|
|
1476
|
+
applyFn: runsApplyFn,
|
|
1477
|
+
});
|
|
1478
|
+
function currentRunsFilters(){
|
|
1479
|
+
return runsFilterBar ? runsFilterBar.getState() : { results: [], time: "all", search: "" };
|
|
1480
|
+
}
|
|
1481
|
+
function paintRunsViewToggle(){
|
|
1482
|
+
document.querySelectorAll('.chip[data-runs-view]').forEach(function(c){
|
|
1483
|
+
c.setAttribute("aria-pressed", c.getAttribute("data-runs-view") === runsViewMode ? "true" : "false");
|
|
1484
|
+
});
|
|
1485
|
+
document.getElementById("wf-list").hidden = runsViewMode !== "workflows";
|
|
1486
|
+
document.getElementById("history-list").hidden = runsViewMode !== "history";
|
|
1487
|
+
}
|
|
1488
|
+
document.querySelectorAll('.chip[data-runs-view]').forEach(function(chip){
|
|
1489
|
+
chip.addEventListener("click", function(){
|
|
1490
|
+
var next = chip.getAttribute("data-runs-view");
|
|
1491
|
+
if(next === runsViewMode) return;
|
|
1492
|
+
runsViewMode = next;
|
|
1493
|
+
saveRunsViewMode(runsViewMode);
|
|
1494
|
+
paintRunsViewToggle();
|
|
1495
|
+
runsFilterBar.refresh();
|
|
1496
|
+
});
|
|
1497
|
+
});
|
|
1498
|
+
paintRunsViewToggle();
|
|
1499
|
+
|
|
1500
|
+
// item 4: phone-only "scroll the run view into view" on row select, and
|
|
1501
|
+
// the matching "↑ list" jump back. Desktop never runs either — both panes
|
|
1502
|
+
// are already on screen there (the <900px breakpoint here matches the
|
|
1503
|
+
// CSS media query above, both named off the same 900px number).
|
|
1504
|
+
function isMobileLayout(){
|
|
1505
|
+
return typeof window.matchMedia === "function" && window.matchMedia("(max-width: 899px)").matches;
|
|
1506
|
+
}
|
|
1507
|
+
function scrollRunIntoViewMobile(){
|
|
1508
|
+
if(!isMobileLayout()) return;
|
|
1509
|
+
var target = document.getElementById("right-pane-anchor");
|
|
1510
|
+
if(target && target.scrollIntoView) target.scrollIntoView({ behavior: "smooth", block: "start" });
|
|
1511
|
+
}
|
|
1512
|
+
var backToListBtn = document.getElementById("back-to-list");
|
|
1513
|
+
if(backToListBtn){
|
|
1514
|
+
backToListBtn.addEventListener("click", function(){
|
|
1515
|
+
var target = document.getElementById("left-pane-anchor");
|
|
1516
|
+
if(target && target.scrollIntoView) target.scrollIntoView({ behavior: "smooth", block: "start" });
|
|
1517
|
+
});
|
|
1518
|
+
}
|
|
1519
|
+
|
|
1520
|
+
function clearSelection(selector){
|
|
1521
|
+
document.querySelectorAll(".wf-row, .hist-row, .inbox-row").forEach(function(r){ r.classList.remove("selected"); r.setAttribute("aria-pressed","false"); });
|
|
1522
|
+
}
|
|
1523
|
+
|
|
1524
|
+
// ---- Run tab: header + summary + step map + one card per step ATTEMPT
|
|
1525
|
+
// (ruling A, 2026-09-26: "no per-round parts") — built off getRunDetail's
|
|
1526
|
+
// `steps[]` (declaration.steps joined with audit.jsonl attempts), never a
|
|
1527
|
+
// second client-side re-derivation of the step list. ----
|
|
1528
|
+
function renderRun(detail){
|
|
1529
|
+
var name = document.getElementById("active-wf-name");
|
|
1530
|
+
var dot = document.getElementById("active-wf-dot");
|
|
1531
|
+
var verdict = document.getElementById("active-wf-verdict");
|
|
1532
|
+
var date = document.getElementById("active-wf-date");
|
|
1533
|
+
|
|
1534
|
+
name.textContent = detail.flow + " (" + detail.runId + ")";
|
|
1535
|
+
dot.className = "dot " + glyphClass(detail.glyph);
|
|
1536
|
+
verdict.textContent = detail.label || "unknown";
|
|
1537
|
+
// browser re-walk bug #4: this is the DATE field — it must use its own
|
|
1538
|
+
// why (`detail.atWhy`), never `detail.outcomeWhy` (a different book
|
|
1539
|
+
// fact borrowed by mistake). A parked run's ask.json `askedAt` is a
|
|
1540
|
+
// real timestamp the books hold, shown ahead of any generic why text.
|
|
1541
|
+
date.textContent = detail.at ? readableDateTime(detail.at)
|
|
1542
|
+
: (detail.askedAt ? "asked " + readableDateTime(detail.askedAt) : (detail.atWhy || "unknown"));
|
|
1543
|
+
|
|
1544
|
+
document.getElementById("run-empty").hidden = true;
|
|
1545
|
+
document.getElementById("run-content").hidden = false;
|
|
1546
|
+
|
|
1547
|
+
// "took Xs" for a finished run, straight off the history row's own
|
|
1548
|
+
// wallMs (never derived/guessed) — a died/parked run or one whose
|
|
1549
|
+
// history row predates the field both say why instead (fix #5).
|
|
1550
|
+
var capText = typeof detail.capUsd === "number" ? ("$" + detail.capUsd.toFixed(2)) : "unknown";
|
|
1551
|
+
var spendText = detail.spend || "unknown — no spend recorded yet";
|
|
1552
|
+
var wallText = typeof detail.wallMs === "number" ? ("took " + duration(detail.wallMs)) : (detail.wallMsWhy || "wall time unknown");
|
|
1553
|
+
document.getElementById("run-counters").innerHTML =
|
|
1554
|
+
escapeXml(spendText) + " of " + escapeXml(capText) + " cap · " + escapeXml(wallText);
|
|
1555
|
+
|
|
1556
|
+
var box = document.getElementById("run-summary");
|
|
1557
|
+
box.className = "summary-box " + (detail.glyph === "[✗]" ? "red" : (detail.glyph === "[·]" ? "amber" : (detail.glyph === "[?]" ? "magenta" : "")));
|
|
1558
|
+
var stepBoxes = buildStepBoxes(detail.steps);
|
|
1559
|
+
var stepsDone = stepBoxes.filter(function(s){ return s.state === "done"; }).length;
|
|
1560
|
+
var stepsText = stepBoxes.length === 0
|
|
1561
|
+
? (detail.stepsWhy || "no steps recorded")
|
|
1562
|
+
: ('<span class="num">' + stepsDone + '</span> of <span class="num">' + stepBoxes.length + '</span> done');
|
|
1563
|
+
// hamr review #1: "model + provider, steps N of N, why, close class(es),
|
|
1564
|
+
// and spend.jsonl totals" — model+provider shows model only (no book
|
|
1565
|
+
// records a provider on any run, checked against audit.jsonl/
|
|
1566
|
+
// spend.jsonl/declaration.json/signature.json — src/panel/data.js's own
|
|
1567
|
+
// deriveRunModel doc comment). closeClassSummaryText/spendSummaryText
|
|
1568
|
+
// read straight off detail.steps/detail.spendSummary, never re-derived
|
|
1569
|
+
// from a second, separately-fetched copy of the audit rows.
|
|
1570
|
+
var modelText = detail.model || (detail.modelWhy || "no model call recorded yet");
|
|
1571
|
+
var closeText = closeClassSummaryText(detail.steps) || (detail.stepsWhy || "no steps recorded");
|
|
1572
|
+
box.innerHTML =
|
|
1573
|
+
'<div class="summary-headline"><span class="dot ' + glyphClass(detail.glyph) + '"></span><b>' + escapeXml(detail.label || "unknown") + '</b> · <span class="num">' + escapeXml(spendText) + '</span></div>' +
|
|
1574
|
+
'<div class="summary-row" data-testid="summary-model"><span class="sum-label">model:</span><span class="sum-val">' + escapeXml(modelText) + '</span></div>' +
|
|
1575
|
+
'<div class="summary-row"><span class="sum-label">steps:</span><span class="sum-val">' + stepsText + '</span></div>' +
|
|
1576
|
+
'<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>' +
|
|
1577
|
+
'<div class="summary-row" data-testid="summary-close"><span class="sum-label">close:</span><span class="sum-val">' + escapeXml(closeText) + '</span></div>' +
|
|
1578
|
+
'<div class="summary-row" data-testid="summary-spend"><span class="sum-label">spend:</span><span class="sum-val">' + spendSummaryText(detail.spendSummary) + '</span></div>';
|
|
1579
|
+
|
|
1580
|
+
renderStepMap(stepBoxes);
|
|
1581
|
+
|
|
1582
|
+
var listEl = document.getElementById("step-list");
|
|
1583
|
+
listEl.innerHTML = "";
|
|
1584
|
+
stepBoxes.forEach(function(box, idx){
|
|
1585
|
+
var card = document.createElement("div");
|
|
1586
|
+
card.className = "step-card" + (box.state === "waiting" ? " running" : "");
|
|
1587
|
+
card.setAttribute("data-testid", "step-card-" + idx);
|
|
1588
|
+
card.appendChild(buildStepCardHeadEl(box, idx));
|
|
1589
|
+
if(box.goal) card.appendChild(textLineEl("step-meta", box.goal, "step-card-goal-" + idx));
|
|
1590
|
+
// hamr's 2026-09-27 review: the actions line is server data, not a
|
|
1591
|
+
// guess — a step with no group at all (never attempted, `box.attempts`
|
|
1592
|
+
// empty) gets NO actions line rather than a fake "try 0"/"cost
|
|
1593
|
+
// unknown" row.
|
|
1594
|
+
if(box.attempts.length) card.appendChild(buildStepActionsLineEl(box, idx));
|
|
1595
|
+
else card.appendChild(textLineEl("hint", "not attempted yet", "step-card-actions-" + idx));
|
|
1596
|
+
// Amendment M4a-3 (hamr's request): "tools: read 3 · write 1" (this
|
|
1597
|
+
// step's own tool tally, `summarizeStepTools`) plus "allowed: read,
|
|
1598
|
+
// write" (the signed grant, unchanged from the old "granted:" line) —
|
|
1599
|
+
// omitted entirely only when there is NOTHING to say either way (no
|
|
1600
|
+
// tool tally, no why, and nothing granted).
|
|
1601
|
+
var toolsLineEl = buildStepToolsLineEl(box, idx);
|
|
1602
|
+
if(toolsLineEl) card.appendChild(toolsLineEl);
|
|
1603
|
+
// The full stop reason shows on ONLY the one step that stopped the
|
|
1604
|
+
// run (server-derived, src/panel/data.js's stoppedStepEmits) — every
|
|
1605
|
+
// passed step's own `stoppedReason` is `null`, never a guess.
|
|
1606
|
+
if(box.stoppedReason) card.appendChild(textLineEl("hint", "stopped: " + box.stoppedReason, "step-card-stopped-" + idx));
|
|
1607
|
+
// hamr review #4: a step card's own click ALSO jumps to its Audit
|
|
1608
|
+
// group — the same `openAuditGroup` the map node's click uses, so a
|
|
1609
|
+
// click on either surface can never land on a different row.
|
|
1610
|
+
card.setAttribute("tabindex", "0");
|
|
1611
|
+
card.setAttribute("role", "button");
|
|
1612
|
+
card.addEventListener("click", function(){ openAuditGroup(box.emits); });
|
|
1613
|
+
card.addEventListener("keydown", function(e){ if(e.key === "Enter" || e.key === " "){ e.preventDefault(); card.click(); } });
|
|
1614
|
+
listEl.appendChild(card);
|
|
1615
|
+
});
|
|
1616
|
+
}
|
|
1617
|
+
// A plain lower-case, non-bold data line (hamr's 2026-09-27 styling
|
|
1618
|
+
// ruling: only the header is upper case/bold) — every non-header line on
|
|
1619
|
+
// a step card is built through this ONE helper so none of them can drift
|
|
1620
|
+
// from that rule.
|
|
1621
|
+
function textLineEl(extraClass, text, testId){
|
|
1622
|
+
var div = document.createElement("div");
|
|
1623
|
+
div.className = "step-line" + (extraClass ? " " + extraClass : "");
|
|
1624
|
+
if(testId) div.setAttribute("data-testid", testId);
|
|
1625
|
+
div.textContent = text;
|
|
1626
|
+
return div;
|
|
1627
|
+
}
|
|
1628
|
+
// The card's HEADER line: "N · step-name [state] [close class]" — upper
|
|
1629
|
+
// case/bold from CSS (`.step-card .step-head`), the state/close chips
|
|
1630
|
+
// keeping their own `.badge` color. `auditStateClass` is the SAME
|
|
1631
|
+
// function the Audit tab's group headers use to color their own state
|
|
1632
|
+
// word — never a second color scheme for the Run tab's cards.
|
|
1633
|
+
function buildStepCardHeadEl(box, idx){
|
|
1634
|
+
var head = document.createElement("div");
|
|
1635
|
+
head.className = "step-head";
|
|
1636
|
+
var h4 = document.createElement("h4");
|
|
1637
|
+
h4.textContent = (idx + 1) + " · " + box.emits;
|
|
1638
|
+
head.appendChild(h4);
|
|
1639
|
+
var stateBadge = document.createElement("span");
|
|
1640
|
+
stateBadge.className = "badge " + auditStateClass(box.state);
|
|
1641
|
+
stateBadge.setAttribute("data-testid", "step-card-state-" + idx);
|
|
1642
|
+
stateBadge.textContent = stateWord(box.state);
|
|
1643
|
+
head.appendChild(stateBadge);
|
|
1644
|
+
var closeBadge = document.createElement("span");
|
|
1645
|
+
closeBadge.className = "badge cyan";
|
|
1646
|
+
closeBadge.textContent = closeClassLabel(box.closeClass);
|
|
1647
|
+
head.appendChild(closeBadge);
|
|
1648
|
+
return head;
|
|
1649
|
+
}
|
|
1650
|
+
// The actions line: "<time> · <cost> · [N tokens ·] try N <marks>" — every
|
|
1651
|
+
// piece read straight off the SAME server-computed group
|
|
1652
|
+
// (src/panel/data.js's deriveAuditGroups) the Audit tab's own header uses.
|
|
1653
|
+
// Marks are built as real, colored `<span class="mark STATE">` elements
|
|
1654
|
+
// (`auditMarkClass`), the SAME way `buildAuditGroupHeaderEl` already
|
|
1655
|
+
// builds its own try marks.
|
|
1656
|
+
function buildStepActionsLineEl(box, idx){
|
|
1657
|
+
var div = document.createElement("div");
|
|
1658
|
+
div.className = "step-line";
|
|
1659
|
+
div.setAttribute("data-testid", "step-card-actions-" + idx);
|
|
1660
|
+
var bits = [duration(box.timeMs), (box.cost || box.costWhy || "cost unknown")];
|
|
1661
|
+
if(typeof box.tokensTotal === "number") bits.push(box.tokensTotal + " tokens");
|
|
1662
|
+
div.appendChild(document.createTextNode(bits.join(" · ") + " · try " + (box.tryCount || 0) + " "));
|
|
1663
|
+
(box.tryMarks || []).forEach(function(mark){
|
|
1664
|
+
var markSpan = document.createElement("span");
|
|
1665
|
+
markSpan.className = "mark " + auditMarkClass(mark);
|
|
1666
|
+
markSpan.textContent = mark;
|
|
1667
|
+
div.appendChild(markSpan);
|
|
1668
|
+
});
|
|
1669
|
+
return div;
|
|
1670
|
+
}
|
|
1671
|
+
// Amendment M4a-3 (hamr's request): "tools: read 3 · write 1 · allowed:
|
|
1672
|
+
// read, write" — `box.toolsTotal` (`src/panel/data.js`'s
|
|
1673
|
+
// `summarizeStepTools`, sorted count desc/name asc) for the "tools:"
|
|
1674
|
+
// half, `box.primitives` (the signed grant, unchanged shape) for the
|
|
1675
|
+
// "allowed:" half. `box.toolsWhy` ("not recorded (before M4a-3)") stands
|
|
1676
|
+
// in for "tools:" on a pre-M4a-3 step; no model call in the step at all
|
|
1677
|
+
// (`toolsTotal` and `toolsWhy` both null) drops the "tools:" half
|
|
1678
|
+
// entirely, leaving just "allowed: …". Returns `null` (no line at all)
|
|
1679
|
+
// only when there is truly nothing to say on either half. A name in
|
|
1680
|
+
// `box.ungranted` (a real book-derived list — never guessed from
|
|
1681
|
+
// `primitives` by exclusion) appends a red-colored "· not allowed: …",
|
|
1682
|
+
// using the page's own `--red` token, the same one `.mark.red`/
|
|
1683
|
+
// `.badge.red` already use elsewhere on this page.
|
|
1684
|
+
function buildStepToolsLineEl(box, idx){
|
|
1685
|
+
var toolsBit = null;
|
|
1686
|
+
if(box.toolsWhy) toolsBit = "tools: " + box.toolsWhy;
|
|
1687
|
+
else if(box.toolsTotal){
|
|
1688
|
+
var pairs = Object.keys(box.toolsTotal).map(function(name){ return name + " " + box.toolsTotal[name]; });
|
|
1689
|
+
if(pairs.length) toolsBit = "tools: " + pairs.join(" · ");
|
|
1690
|
+
}
|
|
1691
|
+
var allowedBit = box.primitives.length ? "allowed: " + box.primitives.join(", ") : null;
|
|
1692
|
+
if(!toolsBit && !allowedBit && !box.ungranted.length) return null;
|
|
1693
|
+
var div = document.createElement("div");
|
|
1694
|
+
div.className = "step-line";
|
|
1695
|
+
div.setAttribute("data-testid", "step-card-tools-" + idx);
|
|
1696
|
+
var bits = [toolsBit, allowedBit].filter(function(b){ return !!b; });
|
|
1697
|
+
div.appendChild(document.createTextNode(bits.join(" · ")));
|
|
1698
|
+
if(box.ungranted.length){
|
|
1699
|
+
var ungrantedSpan = document.createElement("span");
|
|
1700
|
+
ungrantedSpan.style.color = "var(--red)";
|
|
1701
|
+
ungrantedSpan.setAttribute("data-testid", "step-card-ungranted-" + idx);
|
|
1702
|
+
ungrantedSpan.textContent = (bits.length ? " · " : "") + "not allowed: " + box.ungranted.join(", ");
|
|
1703
|
+
div.appendChild(ungrantedSpan);
|
|
1704
|
+
}
|
|
1705
|
+
return div;
|
|
1706
|
+
}
|
|
1707
|
+
|
|
1708
|
+
// ---- Audit tab: this run's own audit.jsonl rows only, one per step
|
|
1709
|
+
// ATTEMPT (M4a scope item 2: "one row per step attempt", no round/tool-
|
|
1710
|
+
// call granularity — bareloop's All/Writes/Blocked filters and its
|
|
1711
|
+
// per-round table have no fwdloop book to fill them from; they are not
|
|
1712
|
+
// rebuilt here, per the ladder's own ruling). hamr review #5/#6
|
|
1713
|
+
// (2026-09-27): Grouped (default, one section per step with a header) and
|
|
1714
|
+
// Flat (the old one-row-per-attempt table) views, toggled by two chips;
|
|
1715
|
+
// BOTH share the SAME row-cell builder (`buildAuditRowEl`) so the two
|
|
1716
|
+
// views can never disagree on what a row says. Column order everywhere:
|
|
1717
|
+
// Attempt, Step (dropped in Grouped — the header already names it),
|
|
1718
|
+
// Action, Gap, Cost, Verdict, Close. `Action` is `row.action`, set
|
|
1719
|
+
// server-side by src/panel/data.js's `deriveAuditAction` — never
|
|
1720
|
+
// re-derived or guessed here, and never "unknown action". ----
|
|
1721
|
+
// hamr review #4: jump from a map node or step card straight to this run's
|
|
1722
|
+
// OWN audit group for that step — switches to the Audit tab, forces
|
|
1723
|
+
// Grouped view (the group only exists there), scrolls it into view, and
|
|
1724
|
+
// gives it a momentary highlight so the jump is visible even when the
|
|
1725
|
+
// group was already on screen.
|
|
1726
|
+
function openAuditGroup(step){
|
|
1727
|
+
document.getElementById("tab-audit").click();
|
|
1728
|
+
setAuditView("grouped");
|
|
1729
|
+
// A jump from the map/step-card must always land on a REAL group, even
|
|
1730
|
+
// when a human had the Blocked/Human filter active and this step's
|
|
1731
|
+
// rows don't match it — reset to All rather than jumping to nothing.
|
|
1732
|
+
setAuditFilter("all");
|
|
1733
|
+
var row = document.getElementById("audit-group-" + step);
|
|
1734
|
+
if(!row) return;
|
|
1735
|
+
// hamr's 2026-09-27 review item (b): a jump from the Run tab must land
|
|
1736
|
+
// on an OPEN group even if a human had folded it — never scroll to a
|
|
1737
|
+
// collapsed section with nothing visible in it.
|
|
1738
|
+
var table = row.querySelector("table");
|
|
1739
|
+
var header = row.querySelector("h4");
|
|
1740
|
+
if(table && table.hidden){
|
|
1741
|
+
table.hidden = false;
|
|
1742
|
+
if(header) header.setAttribute("aria-expanded", "true");
|
|
1743
|
+
}
|
|
1744
|
+
if(typeof row.scrollIntoView === "function") row.scrollIntoView({ block: "center" });
|
|
1745
|
+
row.classList.add("audit-group-highlight");
|
|
1746
|
+
setTimeout(function(){ row.classList.remove("audit-group-highlight"); }, 1600);
|
|
1747
|
+
}
|
|
1748
|
+
// ONE row-cell builder for both views — `includeStep` controls only
|
|
1749
|
+
// whether the Step cell is rendered (Grouped drops it; the group's own
|
|
1750
|
+
// header already names the step). Column order: Attempt, [Step], Action,
|
|
1751
|
+
// Gap, Cost, Verdict, Close, Time. `data-label` on every `<td>` is what
|
|
1752
|
+
// the mobile (max-width:480px) stacked-card CSS reads via `attr()` —
|
|
1753
|
+
// review item #4: the Time cell (and every other cell) must stay inside
|
|
1754
|
+
// its own card at 390px, never truncated or pushed off the page edge.
|
|
1755
|
+
function buildAuditRowEl(r, includeStep){
|
|
1756
|
+
var tr = document.createElement("tr");
|
|
1757
|
+
var glyph = verdictGlyph(r.verdict, r.class);
|
|
1758
|
+
var word = verdictWord(r.verdict, r.class, r.gap);
|
|
1759
|
+
var isRejectRow = r.class === "hitl" && r.verdict === "red";
|
|
1760
|
+
var badgeClass = glyph === "✓" ? "green" : (glyph === "✗" ? "red" : "amber");
|
|
1761
|
+
var action = typeof r.action === "string" && r.action.length > 0 ? r.action : r.verdict; // server always sets `action` (deriveAuditAction); this fallback is belt-and-braces only
|
|
1762
|
+
// Amendment M4a-3: append this row's own tool tally to the Action cell,
|
|
1763
|
+
// ONLY for a model-call row whose `tools` was actually recorded
|
|
1764
|
+
// (`r.toolsPhrase`, src/panel/data.js's `deriveAuditToolsPhrase`) — a
|
|
1765
|
+
// pre-M4a-3 row or a non-model row appends nothing at all.
|
|
1766
|
+
var actionText = action + (typeof r.toolsPhrase === "string" ? " · " + r.toolsPhrase : "");
|
|
1767
|
+
var cells =
|
|
1768
|
+
"<td data-label=\"Attempt\">" + escapeXml(String(r.attempt)) + "</td>" +
|
|
1769
|
+
(includeStep ? "<td data-label=\"Step\">" + escapeXml(r.step) + "</td>" : "") +
|
|
1770
|
+
"<td data-label=\"Action\">" + escapeXml(actionText) + "</td>" +
|
|
1771
|
+
"<td data-label=\"Gap\">" + escapeXml(isRejectRow ? "" : (r.gap || "")) + "</td>" +
|
|
1772
|
+
"<td data-label=\"Cost\">" + escapeXml(auditCostCellText(r)) + "</td>" +
|
|
1773
|
+
"<td data-label=\"Verdict\"><span class=\"badge " + badgeClass + "\">" + escapeXml(word) + "</span></td>" +
|
|
1774
|
+
"<td data-label=\"Close\">" + escapeXml(closeClassLabel(r.class)) + "</td>" +
|
|
1775
|
+
"<td data-label=\"Time\">" + auditTimeCellHtml(r) + "</td>";
|
|
1776
|
+
tr.innerHTML = cells;
|
|
1777
|
+
return tr;
|
|
1778
|
+
}
|
|
1779
|
+
// ---- hamr's 2026-09-27 exit-check review #2: the Audit tab's All/Human/
|
|
1780
|
+
// Blocked filter — ONE predicate, applied identically to the Grouped and
|
|
1781
|
+
// Flat views (never two separate filter implementations). "Human" reads
|
|
1782
|
+
// `row.action === "human"` (src/panel/data.js's deriveAuditAction);
|
|
1783
|
+
// "Blocked" reads `row.blocked` (src/panel/data.js's isBlockedVerdict) —
|
|
1784
|
+
// both server-derived, never re-guessed here. ----
|
|
1785
|
+
var auditFilterMode = "all";
|
|
1786
|
+
var lastAuditResult = null;
|
|
1787
|
+
function auditRowMatchesFilter(r){
|
|
1788
|
+
if(auditFilterMode === "human") return r.action === "human";
|
|
1789
|
+
if(auditFilterMode === "blocked") return r.blocked === true;
|
|
1790
|
+
return true;
|
|
1791
|
+
}
|
|
1792
|
+
function setAuditFilter(mode){
|
|
1793
|
+
auditFilterMode = mode;
|
|
1794
|
+
document.querySelectorAll('.chip[data-audit-filter]').forEach(function(chip){
|
|
1795
|
+
chip.setAttribute("aria-pressed", chip.getAttribute("data-audit-filter") === mode ? "true" : "false");
|
|
1796
|
+
});
|
|
1797
|
+
if(lastAuditResult) paintAudit(lastAuditResult);
|
|
1798
|
+
}
|
|
1799
|
+
document.querySelectorAll('.chip[data-audit-filter]').forEach(function(chip){
|
|
1800
|
+
chip.addEventListener("click", function(){ setAuditFilter(chip.getAttribute("data-audit-filter")); });
|
|
1801
|
+
});
|
|
1802
|
+
// review item #1: one line per group — `[state] · step · time · cost ·
|
|
1803
|
+
// try N <marks>` — built ONLY from fields `src/panel/data.js`'s
|
|
1804
|
+
// `deriveAuditGroups` already computed (timeMs -> `duration`, a purely
|
|
1805
|
+
// presentational formatter; nothing here re-derives state/cost/tries).
|
|
1806
|
+
// Tokens are appended ONLY when the server sent a real total (omitted,
|
|
1807
|
+
// never "0 tokens", for a pre-M4a-2 row or a no-model-call step).
|
|
1808
|
+
function auditGroupHeaderText(g){
|
|
1809
|
+
var bits = [
|
|
1810
|
+
"[" + g.state + "]", g.step, duration(g.timeMs), (g.cost || "cost unknown"),
|
|
1811
|
+
"try " + g.tryCount + " " + g.tryMarks.join(""),
|
|
1812
|
+
];
|
|
1813
|
+
if(typeof g.tokensTotal === "number") bits.splice(4, 0, g.tokensTotal + " tokens");
|
|
1814
|
+
return bits.join(" · ");
|
|
1815
|
+
}
|
|
1816
|
+
// hamr's 2026-09-27 review: the header's status word gets the SAME color
|
|
1817
|
+
// vocabulary the runs list already uses (glyphClass's green/red/amber/
|
|
1818
|
+
// grey) — never a second color scheme invented for the Audit tab. A
|
|
1819
|
+
// group's `g.state` is server-derived (`deriveStepGroupState`) to exactly
|
|
1820
|
+
// one of 'done'/'waiting'/'stopped' — 'grey' below is an unreached
|
|
1821
|
+
// fallback, never a real state this function is asked to color.
|
|
1822
|
+
function auditStateClass(state){
|
|
1823
|
+
if(state === "done") return "green";
|
|
1824
|
+
if(state === "waiting") return "amber";
|
|
1825
|
+
if(state === "stopped") return "red";
|
|
1826
|
+
return "grey";
|
|
1827
|
+
}
|
|
1828
|
+
function auditMarkClass(mark){
|
|
1829
|
+
if(mark === "✓") return "green";
|
|
1830
|
+
if(mark === "✗") return "red";
|
|
1831
|
+
return "grey"; // "·" — still open, no resolution row yet
|
|
1832
|
+
}
|
|
1833
|
+
// Builds the SAME header line `auditGroupHeaderText` renders as plain
|
|
1834
|
+
// text (used as this header's aria-label, for a screen reader), but as
|
|
1835
|
+
// real DOM: the status word is its own `<span class="badge STATE">`
|
|
1836
|
+
// (reusing the existing `.badge` bracket/color CSS, never a second
|
|
1837
|
+
// "[state]" string built here) and each try mark is its own colored
|
|
1838
|
+
// `<span class="mark STATE">` — built directly off `g.state`/`g.tryMarks`,
|
|
1839
|
+
// never by parsing `auditGroupHeaderText`'s own string back apart.
|
|
1840
|
+
function buildAuditGroupHeaderEl(g){
|
|
1841
|
+
var h4 = document.createElement("h4");
|
|
1842
|
+
h4.className = "audit-status-header";
|
|
1843
|
+
var stateSpan = document.createElement("span");
|
|
1844
|
+
stateSpan.className = "badge " + auditStateClass(g.state);
|
|
1845
|
+
stateSpan.setAttribute("data-testid", "audit-group-state");
|
|
1846
|
+
stateSpan.textContent = g.state;
|
|
1847
|
+
h4.appendChild(stateSpan);
|
|
1848
|
+
h4.appendChild(document.createTextNode(" · " + g.step + " · " + duration(g.timeMs) + " · " + (g.cost || "cost unknown")));
|
|
1849
|
+
if(typeof g.tokensTotal === "number") h4.appendChild(document.createTextNode(" · " + g.tokensTotal + " tokens"));
|
|
1850
|
+
h4.appendChild(document.createTextNode(" · try " + g.tryCount + " "));
|
|
1851
|
+
g.tryMarks.forEach(function(mark){
|
|
1852
|
+
var markSpan = document.createElement("span");
|
|
1853
|
+
markSpan.className = "mark " + auditMarkClass(mark);
|
|
1854
|
+
markSpan.textContent = mark;
|
|
1855
|
+
h4.appendChild(markSpan);
|
|
1856
|
+
});
|
|
1857
|
+
return h4;
|
|
1858
|
+
}
|
|
1859
|
+
// Grouped view: one section per step, server order preserved (first-seen
|
|
1860
|
+
// order of `r.step` across this run's own rows — never re-sorted).
|
|
1861
|
+
// review item #1: COLLAPSED by default — a map/step-card click
|
|
1862
|
+
// (`openAuditGroup`) is the only thing that force-expands one.
|
|
1863
|
+
function renderAuditGroups(result){
|
|
1864
|
+
var container = document.getElementById("audit-groups");
|
|
1865
|
+
container.innerHTML = "";
|
|
1866
|
+
if(!result || result.empty) return;
|
|
1867
|
+
var anyVisible = false;
|
|
1868
|
+
(result.groups || []).forEach(function(g){
|
|
1869
|
+
var rows = (g.rows || []).filter(auditRowMatchesFilter);
|
|
1870
|
+
if(rows.length === 0) return; // a group with no matching rows is hidden, never an empty shell
|
|
1871
|
+
anyVisible = true;
|
|
1872
|
+
var wrap = document.createElement("div");
|
|
1873
|
+
wrap.className = "audit-group";
|
|
1874
|
+
wrap.id = "audit-group-" + g.step;
|
|
1875
|
+
wrap.setAttribute("data-testid", "audit-group-" + g.step);
|
|
1876
|
+
// hamr's 2026-09-27 review item (b), carried forward: the group
|
|
1877
|
+
// header folds/unfolds its own table on click — a `role="button"`
|
|
1878
|
+
// div (never a real `<button>` nested inside an `<h4>`). Review #1:
|
|
1879
|
+
// COLLAPSED by default now (`aria-expanded` starts "false", the
|
|
1880
|
+
// table starts `hidden`) — expanding is something a human (or a
|
|
1881
|
+
// map/step-card jump) does, never the initial state.
|
|
1882
|
+
var header = buildAuditGroupHeaderEl(g);
|
|
1883
|
+
header.setAttribute("role", "button");
|
|
1884
|
+
header.setAttribute("tabindex", "0");
|
|
1885
|
+
header.setAttribute("aria-expanded", "false");
|
|
1886
|
+
header.setAttribute("aria-label", auditGroupHeaderText(g));
|
|
1887
|
+
header.style.cursor = "pointer";
|
|
1888
|
+
wrap.appendChild(header);
|
|
1889
|
+
var table = document.createElement("table");
|
|
1890
|
+
table.hidden = true;
|
|
1891
|
+
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>";
|
|
1892
|
+
var tbody = table.querySelector("tbody");
|
|
1893
|
+
rows.forEach(function(r){ tbody.appendChild(buildAuditRowEl(r, false)); });
|
|
1894
|
+
table.setAttribute("data-testid", "audit-table-grouped-" + g.step);
|
|
1895
|
+
wrap.appendChild(table);
|
|
1896
|
+
function toggleAuditGroup(){
|
|
1897
|
+
var next = table.hidden;
|
|
1898
|
+
table.hidden = !next;
|
|
1899
|
+
header.setAttribute("aria-expanded", next ? "true" : "false");
|
|
1900
|
+
}
|
|
1901
|
+
header.addEventListener("click", toggleAuditGroup);
|
|
1902
|
+
header.addEventListener("keydown", function(e){
|
|
1903
|
+
if(e.key === "Enter" || e.key === " "){ e.preventDefault(); toggleAuditGroup(); }
|
|
1904
|
+
});
|
|
1905
|
+
container.appendChild(wrap);
|
|
1906
|
+
});
|
|
1907
|
+
return anyVisible;
|
|
1908
|
+
}
|
|
1909
|
+
function renderAuditFlat(result){
|
|
1910
|
+
var tbody = document.getElementById("audit-tbody");
|
|
1911
|
+
tbody.innerHTML = "";
|
|
1912
|
+
if(!result || result.empty) return false;
|
|
1913
|
+
var rows = result.rows.filter(auditRowMatchesFilter);
|
|
1914
|
+
rows.forEach(function(r){ tbody.appendChild(buildAuditRowEl(r, true)); });
|
|
1915
|
+
return rows.length > 0;
|
|
1916
|
+
}
|
|
1917
|
+
var auditViewMode = "grouped";
|
|
1918
|
+
function setAuditView(view){
|
|
1919
|
+
auditViewMode = view;
|
|
1920
|
+
document.getElementById("audit-groups").hidden = view !== "grouped";
|
|
1921
|
+
document.getElementById("audit-flat-wrap").hidden = view !== "flat";
|
|
1922
|
+
document.querySelectorAll('.chip[data-view]').forEach(function(chip){
|
|
1923
|
+
chip.setAttribute("aria-pressed", chip.getAttribute("data-view") === view ? "true" : "false");
|
|
1924
|
+
});
|
|
1925
|
+
if(lastAuditResult) paintAudit(lastAuditResult);
|
|
1926
|
+
}
|
|
1927
|
+
document.querySelectorAll('.chip[data-view]').forEach(function(chip){
|
|
1928
|
+
chip.addEventListener("click", function(){ setAuditView(chip.getAttribute("data-view")); });
|
|
1929
|
+
});
|
|
1930
|
+
// Paints both views off the SAME already-fetched result (never a second
|
|
1931
|
+
// fetch) — called on load and again whenever the filter/view changes.
|
|
1932
|
+
// review item #2: "a group with no matching rows is hidden; empty result
|
|
1933
|
+
// says why" — checked against whichever view is actually on screen.
|
|
1934
|
+
function paintAudit(result){
|
|
1935
|
+
var anyGrouped = renderAuditGroups(result);
|
|
1936
|
+
var anyFlat = renderAuditFlat(result);
|
|
1937
|
+
var filterEmpty = document.getElementById("audit-filter-empty");
|
|
1938
|
+
var nothingMatched = auditViewMode === "flat" ? !anyFlat : !anyGrouped;
|
|
1939
|
+
if(nothingMatched && auditFilterMode !== "all"){
|
|
1940
|
+
filterEmpty.hidden = false;
|
|
1941
|
+
filterEmpty.textContent = "no " + auditFilterMode + " rows in this run's audit trail";
|
|
1942
|
+
} else {
|
|
1943
|
+
filterEmpty.hidden = true;
|
|
1944
|
+
}
|
|
1945
|
+
}
|
|
1946
|
+
function renderAudit(result){
|
|
1947
|
+
var empty = document.getElementById("audit-empty");
|
|
1948
|
+
var content = document.getElementById("audit-content");
|
|
1949
|
+
lastAuditResult = result;
|
|
1950
|
+
if(!result || result.empty){
|
|
1951
|
+
empty.hidden = false;
|
|
1952
|
+
empty.textContent = (result && result.why) || "no audit rows for this run";
|
|
1953
|
+
content.hidden = true;
|
|
1954
|
+
return;
|
|
1955
|
+
}
|
|
1956
|
+
empty.hidden = true;
|
|
1957
|
+
content.hidden = false;
|
|
1958
|
+
// a fresh run's own view keeps whatever mode (Grouped/Flat) the chips
|
|
1959
|
+
// are already showing, defaulting to Grouped on first load.
|
|
1960
|
+
var flatPressed = document.querySelector('.chip[data-view="flat"]');
|
|
1961
|
+
setAuditView(flatPressed && flatPressed.getAttribute("aria-pressed") === "true" ? "flat" : "grouped");
|
|
1962
|
+
}
|
|
1963
|
+
|
|
1964
|
+
// ---- Job tab: the signed prose, the arbiter block (cap, asks with TTL,
|
|
1965
|
+
// redo cap, sends, sources), and the signature — read straight off
|
|
1966
|
+
// getRunJob (src/panel/data.js), which reads fwdloop's own signed
|
|
1967
|
+
// declaration.json + signature.json (one per flow, unlike bareloop's
|
|
1968
|
+
// multi-source provenance chain — DROPPED per the M4a fit-check). ----
|
|
1969
|
+
function ttlLabel(ms){
|
|
1970
|
+
if(typeof ms !== "number") return "unknown";
|
|
1971
|
+
return duration(ms);
|
|
1972
|
+
}
|
|
1973
|
+
// hamr's 2026-09-27 exit-check review #5: ONE row-per-piece renderer,
|
|
1974
|
+
// shared by every multi-row Job field (prose/asks/sources/sends/
|
|
1975
|
+
// guardrails/success) — a real `.ro-value` per item (never a single
|
|
1976
|
+
// " · "-joined line, which used to hide a book text value if it happened
|
|
1977
|
+
// to contain " · " itself), an explicit "none signed" hint for an empty
|
|
1978
|
+
// list, book text always via `.textContent`.
|
|
1979
|
+
function renderRowsField(elId, items, emptyText, rowTextFn){
|
|
1980
|
+
var el = document.getElementById(elId);
|
|
1981
|
+
el.innerHTML = "";
|
|
1982
|
+
if(!items || !items.length){
|
|
1983
|
+
el.appendChild(textDiv("hint", emptyText));
|
|
1984
|
+
return;
|
|
1985
|
+
}
|
|
1986
|
+
items.forEach(function(item){
|
|
1987
|
+
el.appendChild(textDiv("ro-value", rowTextFn(item)));
|
|
1988
|
+
});
|
|
1989
|
+
}
|
|
1990
|
+
function renderJob(job){
|
|
1991
|
+
var empty = document.getElementById("job-empty");
|
|
1992
|
+
var card = document.getElementById("job-card");
|
|
1993
|
+
if(!job){ empty.hidden = false; empty.textContent = "select a run first"; card.hidden = true; return; }
|
|
1994
|
+
if(!job.resolved){ empty.hidden = false; empty.textContent = job.why || "job could not be resolved"; card.hidden = true; return; }
|
|
1995
|
+
empty.hidden = true;
|
|
1996
|
+
card.hidden = false;
|
|
1997
|
+
document.getElementById("details-title").textContent = "Job — " + job.flow + " (signed)";
|
|
1998
|
+
// review #5: "Job (prose)" — the signed lines, numbered, WITHOUT their
|
|
1999
|
+
// guardrail mixed in (guardrails get their own field below).
|
|
2000
|
+
renderRowsField("details-prose", job.prose, "no signed prose lines", function(l){
|
|
2001
|
+
return l.line + ". " + l.text;
|
|
2002
|
+
});
|
|
2003
|
+
// review #5: "Ask" — one row per signed ask line.
|
|
2004
|
+
renderRowsField("details-asks", job.asks, "no signed asks", function(ak){
|
|
2005
|
+
return "line " + ak.line + " · \"" + ak.question + "\" · waits " + ttlLabel(ak.waitMs);
|
|
2006
|
+
});
|
|
2007
|
+
// hamr review #7: no declaration/signature book records a model on the
|
|
2008
|
+
// flow itself (checked against `src/panel/data.js`'s own
|
|
2009
|
+
// `deriveRunModel` — only `audit.jsonl`'s per-attempt rows do) — say so
|
|
2010
|
+
// plainly rather than implying the signed prose named it.
|
|
2011
|
+
document.getElementById("details-model").textContent = job.model
|
|
2012
|
+
? ("model used: " + job.model + " (from this run's rows)")
|
|
2013
|
+
: (job.modelWhy || "no model call recorded yet");
|
|
2014
|
+
// hamr's 2026-09-27 final tweak #1: "$ cap" — bareloop-style "$ cap /
|
|
2015
|
+
// Time cap" row: money (signed capUsd + redo cap) THEN time. Checked
|
|
2016
|
+
// against src/declaration.js and src/types.js's own Arbiter typedef:
|
|
2017
|
+
// fwdloop's signed arbiter carries `capUsd`/`redoCap` (and per-ask
|
|
2018
|
+
// `ttlMs`, which is an ask's own wait, not a run-wide time cap) — there
|
|
2019
|
+
// is no signed run-wide time-cap field anywhere in the grammar, so this
|
|
2020
|
+
// NEVER invents one; it says so in words instead.
|
|
2021
|
+
document.getElementById("details-cap").textContent =
|
|
2022
|
+
(typeof job.capUsd === "number" ? ("$" + job.capUsd.toFixed(2)) : "unknown")
|
|
2023
|
+
+ " · redo cap " + (typeof job.redoCap === "number" ? job.redoCap : "unknown")
|
|
2024
|
+
+ " · time cap: no time cap signed";
|
|
2025
|
+
// review #5: "Source" — role -> basename only (never the full signed path).
|
|
2026
|
+
renderRowsField("details-sources", job.sources, "no signed sources", function(s){
|
|
2027
|
+
return s.role + " → " + s.basename;
|
|
2028
|
+
});
|
|
2029
|
+
// review #5: "Destination" — one row per signed send.
|
|
2030
|
+
renderRowsField("details-sends", job.sends, "no signed sends", function(s){
|
|
2031
|
+
return "line " + s.line + " · " + (s.kind || "unknown") + " → " + (s.target || "unknown");
|
|
2032
|
+
});
|
|
2033
|
+
// review #5: "Guardrails" — ONE field, one row per numbered-line guardrail.
|
|
2034
|
+
renderRowsField("details-guardrails", job.guardrails, "no numbered-line guardrails signed", function(g){
|
|
2035
|
+
return "line " + g.line + " · " + g.guardrail;
|
|
2036
|
+
});
|
|
2037
|
+
// review #5: "Success" — one row per declared step, off data.js's own
|
|
2038
|
+
// deriveStepSuccessText (never re-derived client-side).
|
|
2039
|
+
renderRowsField("details-success", job.success, "no declared steps", function(s){
|
|
2040
|
+
return s.step + " · " + s.text;
|
|
2041
|
+
});
|
|
2042
|
+
var sig = job.signature;
|
|
2043
|
+
// hamr's 2026-09-27 final tweak #2: `sig.signedAt` is the raw signed ISO
|
|
2044
|
+
// stamp (e.g. "2026-09-24T13:22:40.950Z") — rendered readable/local via
|
|
2045
|
+
// the SAME `readableDateTime` every other date on this page already
|
|
2046
|
+
// uses, never shown as the raw ISO string.
|
|
2047
|
+
document.getElementById("details-signature").textContent = sig
|
|
2048
|
+
? (sig.signedBy + " at " + (readableDateTime(sig.signedAt) || sig.signedAt) + " (hash " + sig.hash.slice(0, 12) + "…)")
|
|
2049
|
+
: (job.signatureWhy || "unsigned");
|
|
2050
|
+
}
|
|
2051
|
+
|
|
2052
|
+
// ---- selection + loading ----
|
|
2053
|
+
var currentFlow = null;
|
|
2054
|
+
var currentRunId = null;
|
|
2055
|
+
// `focusAskId` (M4a-1): when a click on an Inbox stop calls `selectRun`,
|
|
2056
|
+
// it names the ONE ask that stop is about — `renderAsk` expands exactly
|
|
2057
|
+
// that ask and scrolls it into view, rather than whatever this run's
|
|
2058
|
+
// default (its open ask, if any) would otherwise expand.
|
|
2059
|
+
function selectRun(flow, runId, rowEl, siblingSelector, focusAskId){
|
|
2060
|
+
clearSelection();
|
|
2061
|
+
document.querySelectorAll(siblingSelector).forEach(function(r){ r.classList.remove("selected"); r.setAttribute("aria-pressed","false"); });
|
|
2062
|
+
if(rowEl){ rowEl.classList.add("selected"); rowEl.setAttribute("aria-pressed","true"); }
|
|
2063
|
+
currentFlow = flow;
|
|
2064
|
+
currentRunId = runId;
|
|
2065
|
+
var base = "/api/runs/" + encodeURIComponent(flow) + "/" + encodeURIComponent(runId);
|
|
2066
|
+
// detail, audit, job, and asks each load independently — the Run tab's
|
|
2067
|
+
// step cards get everything they need (including a step's own attempt-
|
|
2068
|
+
// numbering boundary, `afterReject`) straight off `detail.steps` now;
|
|
2069
|
+
// src/panel/data.js works out the boundary server-side, off the run's
|
|
2070
|
+
// full audit-row order, so the client no longer needs a second,
|
|
2071
|
+
// separately-fetched copy of the audit rows to cross-reference (fix #6).
|
|
2072
|
+
getJSON(base).then(renderRun).catch(function(e){
|
|
2073
|
+
document.getElementById("run-empty").hidden = false;
|
|
2074
|
+
document.getElementById("run-empty").textContent = "failed to load run: " + e.message;
|
|
2075
|
+
document.getElementById("run-content").hidden = true;
|
|
2076
|
+
});
|
|
2077
|
+
getJSON(base + "/audit").then(renderAudit).catch(function(){ renderAudit(null); });
|
|
2078
|
+
getJSON(base + "/job").then(renderJob).catch(function(){ renderJob(null); });
|
|
2079
|
+
getJSON(base + "/asks").then(function(result){ renderAsk(result, focusAskId || null); }).catch(function(e){
|
|
2080
|
+
renderAsk(null, null, e.message);
|
|
2081
|
+
});
|
|
2082
|
+
}
|
|
2083
|
+
|
|
2084
|
+
getJSON("/api/runs").then(function(result){
|
|
2085
|
+
var runs = result.rows || [];
|
|
2086
|
+
runsFilterBar.setItems(runs);
|
|
2087
|
+
var first = runs.find(function(r){ return r.runId !== null; });
|
|
2088
|
+
if(first){
|
|
2089
|
+
document.getElementById("tab-runs").click();
|
|
2090
|
+
// newest run overall, opened directly — the Workflows view starts
|
|
2091
|
+
// collapsed, but its flow row still renders "selected" since
|
|
2092
|
+
// `runsFilterBar.refresh()` re-renders AFTER currentFlow/currentRunId
|
|
2093
|
+
// are set.
|
|
2094
|
+
selectRun(first.flow, first.runId, null, ".hist-row");
|
|
2095
|
+
document.getElementById("tab-run").click();
|
|
2096
|
+
runsFilterBar.refresh();
|
|
2097
|
+
}
|
|
2098
|
+
}).catch(function(e){
|
|
2099
|
+
document.getElementById("wf-list").innerHTML = '<div class="hint">failed to load: ' + escapeXml(e.message) + '</div>';
|
|
2100
|
+
document.getElementById("history-list").innerHTML = '<div class="hint">failed to load: ' + escapeXml(e.message) + '</div>';
|
|
2101
|
+
});
|
|
2102
|
+
|
|
2103
|
+
// ---- shared text-node helper — book text (question/draft/artifact
|
|
2104
|
+
// text/reason/gap) is ALWAYS set via `.textContent`, never interpolated
|
|
2105
|
+
// into an `innerHTML` string, on the Inbox list and the Ask tab alike. ----
|
|
2106
|
+
function textDiv(cls, text){
|
|
2107
|
+
var d = document.createElement("div");
|
|
2108
|
+
if(cls) d.className = cls;
|
|
2109
|
+
d.textContent = text;
|
|
2110
|
+
return d;
|
|
2111
|
+
}
|
|
2112
|
+
|
|
2113
|
+
// ---- Inbox tab (M4a-1): a list of STOPS across every flow, like
|
|
2114
|
+
// History — open ones first with time left, past ones newest-answered-
|
|
2115
|
+
// first with a short status word, off GET /api/inbox
|
|
2116
|
+
// (src/panel/data.js's listStops). Status vocabulary is exactly the
|
|
2117
|
+
// words the books' own decision field maps to (never a second, made-up
|
|
2118
|
+
// vocabulary): "accepted" / "rejected" / "reran" / "expired" /
|
|
2119
|
+
// "unanswered" (this IS the open case) / the rare "open" fallback (an
|
|
2120
|
+
// archived ask.json itself failed to parse). No evidence renders here any
|
|
2121
|
+
// more — clicking a stop selects its run and opens the wide right pane's
|
|
2122
|
+
// Ask tab, focused on that one ask. No answer controls — those are M4b. --
|
|
2123
|
+
function stopStatusLine(row){
|
|
2124
|
+
if(row.open) return "time left: " + duration(row.timeLeftMs);
|
|
2125
|
+
var bits = [row.status];
|
|
2126
|
+
if(row.reason) bits.push("reason: " + row.reason);
|
|
2127
|
+
if(row.answeredAt) bits.push("answered " + (readableDateTime(row.answeredAt) || row.answeredAt));
|
|
2128
|
+
if(row.why) bits.push(row.why);
|
|
2129
|
+
return bits.join(" · ");
|
|
2130
|
+
}
|
|
2131
|
+
function renderStopRow(row){
|
|
2132
|
+
var wrap = document.createElement("div");
|
|
2133
|
+
wrap.className = "hist-row inbox-row";
|
|
2134
|
+
wrap.setAttribute("role", "button");
|
|
2135
|
+
wrap.setAttribute("tabindex", "0");
|
|
2136
|
+
wrap.setAttribute("aria-pressed", "false");
|
|
2137
|
+
wrap.setAttribute("data-testid", "inbox-row-" + row.flow + "-" + row.runId + (row.askId ? "-" + row.askId : ""));
|
|
2138
|
+
var head = document.createElement("div");
|
|
2139
|
+
head.className = "wf-line1";
|
|
2140
|
+
var badge = document.createElement("span");
|
|
2141
|
+
badge.className = "badge " + (row.open ? "amber" : (row.status === "accepted" ? "green" : (row.status === "rejected" ? "red" : "grey")));
|
|
2142
|
+
badge.textContent = row.open ? "·" : row.status;
|
|
2143
|
+
head.appendChild(badge);
|
|
2144
|
+
var flowName = textDiv(null, row.flow + " (" + row.runId + ")");
|
|
2145
|
+
flowName.className = "wf-name";
|
|
2146
|
+
head.appendChild(flowName);
|
|
2147
|
+
wrap.appendChild(head);
|
|
2148
|
+
wrap.appendChild(textDiv("wf-meta", stopStatusLine(row)));
|
|
2149
|
+
if(typeof row.question === "string"){
|
|
2150
|
+
wrap.appendChild(textDiv("step-meta", "question: " + row.question));
|
|
2151
|
+
} else if(row.questionWhy){
|
|
2152
|
+
wrap.appendChild(textDiv("hint", row.questionWhy));
|
|
2153
|
+
}
|
|
2154
|
+
function activate(){
|
|
2155
|
+
selectRun(row.flow, row.runId, wrap, ".inbox-row", row.askId);
|
|
2156
|
+
document.getElementById("tab-ask").click();
|
|
2157
|
+
}
|
|
2158
|
+
wrap.addEventListener("click", activate);
|
|
2159
|
+
wrap.addEventListener("keydown", function(e){
|
|
2160
|
+
if(e.key === "Enter" || e.key === " "){ e.preventDefault(); activate(); }
|
|
2161
|
+
});
|
|
2162
|
+
return wrap;
|
|
2163
|
+
}
|
|
2164
|
+
function renderInbox(rows){
|
|
2165
|
+
var el = document.getElementById("inbox-list");
|
|
2166
|
+
el.innerHTML = "";
|
|
2167
|
+
var openCount = 0;
|
|
2168
|
+
(rows || []).forEach(function(r){ if(r.open) openCount += 1; });
|
|
2169
|
+
document.getElementById("inbox-count-label").textContent = openCount > 0 ? (" (" + openCount + ")") : "";
|
|
2170
|
+
if(!rows || !rows.length){
|
|
2171
|
+
el.innerHTML = '<div class="hint">nothing waiting on you — no stops recorded under this root</div>';
|
|
2172
|
+
return;
|
|
2173
|
+
}
|
|
2174
|
+
rows.forEach(function(row){ el.appendChild(renderStopRow(row)); });
|
|
2175
|
+
}
|
|
2176
|
+
getJSON("/api/inbox").then(function(result){ renderInbox(result.rows || []); }).catch(function(e){
|
|
2177
|
+
document.getElementById("inbox-list").innerHTML = '<div class="hint">failed to load: ' + escapeXml(e.message) + '</div>';
|
|
2178
|
+
});
|
|
2179
|
+
|
|
2180
|
+
// ---- Ask tab (M4a-1): every ask of the SELECTED run, collapsed by
|
|
2181
|
+
// default, off GET /api/runs/:flow/:runId/asks (src/panel/data.js's
|
|
2182
|
+
// getRunAsks). Clicking a stop in the left Inbox calls `selectRun` with
|
|
2183
|
+
// that ask's id, which reaches here as `focusAskId` and expands exactly
|
|
2184
|
+
// that one. With no `focusAskId` (a run selected any other way), this
|
|
2185
|
+
// run's own open ask (if it has one) expands by default. No answer
|
|
2186
|
+
// controls anywhere in this panel (M4b) — a clearly marked EMPTY slot
|
|
2187
|
+
// stands in their place; the collapse/expand toggle is a div with
|
|
2188
|
+
// role="button" (never a real <button>), same posture as the step-map's
|
|
2189
|
+
// own SVG nodes elsewhere on this page. ----
|
|
2190
|
+
function askStatusBlock(ask){
|
|
2191
|
+
if(ask.open) return textDiv("wf-meta", "time left: " + duration(ask.timeLeftMs));
|
|
2192
|
+
var bits = [ask.status];
|
|
2193
|
+
if(ask.reason) bits.push("reason: " + ask.reason);
|
|
2194
|
+
if(ask.answeredAt) bits.push("answered " + (readableDateTime(ask.answeredAt) || ask.answeredAt));
|
|
2195
|
+
return textDiv("wf-meta", bits.join(" · "));
|
|
2196
|
+
}
|
|
2197
|
+
function renderAskEvidenceBlock(ask){
|
|
2198
|
+
var ev = document.createElement("div");
|
|
2199
|
+
ev.className = "attempts-list";
|
|
2200
|
+
var evidence = ask.evidence || {};
|
|
2201
|
+
if(evidence.draft){
|
|
2202
|
+
var draftEl = document.createElement("div");
|
|
2203
|
+
draftEl.className = "ro-value scroll";
|
|
2204
|
+
draftEl.textContent = evidence.draft;
|
|
2205
|
+
// hamr's 2026-09-27 exit-check review #3: "the box headers should be
|
|
2206
|
+
// bolder" — a real heading class (same weight/size/uppercase posture
|
|
2207
|
+
// as the Job tab's own field `<label>`s), never the plain `.hint`
|
|
2208
|
+
// style a footnote/why-text uses.
|
|
2209
|
+
ev.appendChild(textDiv("evidence-heading", "draft under review"));
|
|
2210
|
+
ev.appendChild(draftEl);
|
|
2211
|
+
} else {
|
|
2212
|
+
ev.appendChild(textDiv("hint", evidence.why || "no draft on file"));
|
|
2213
|
+
}
|
|
2214
|
+
// hamr review #8/#9 (2026-09-27, carried over from the old Inbox
|
|
2215
|
+
// renderer): `readAskEvidence` (src/ask.js) puts an unjudged artifact's
|
|
2216
|
+
// text straight on `u.text` (never nested under `u.artifact`). The
|
|
2217
|
+
// label reads `u.emits` (the step's real id) when the entry actually
|
|
2218
|
+
// named one; `u.step` (which — despite the name — carries the step's
|
|
2219
|
+
// GOAL prose, not an id) is shown as a smaller subtitle underneath,
|
|
2220
|
+
// never as the primary label, and never assumed present when `u.emits`
|
|
2221
|
+
// is missing.
|
|
2222
|
+
(evidence.unjudged || []).forEach(function(u){
|
|
2223
|
+
var label = typeof u.emits === "string" && u.emits.length > 0 ? u.emits : u.step;
|
|
2224
|
+
ev.appendChild(textDiv("evidence-heading", "unjudged — step: " + label));
|
|
2225
|
+
if(typeof u.emits === "string" && u.emits.length > 0 && u.step !== u.emits){
|
|
2226
|
+
ev.appendChild(textDiv("step-meta", u.step));
|
|
2227
|
+
}
|
|
2228
|
+
var art = document.createElement("div");
|
|
2229
|
+
art.className = "ro-value scroll";
|
|
2230
|
+
art.textContent = typeof u.text === "string" ? u.text : "no artifact text on file";
|
|
2231
|
+
ev.appendChild(art);
|
|
2232
|
+
});
|
|
2233
|
+
// M4b's answer doors (accept/reject/rerun) land here — this panel is
|
|
2234
|
+
// read-only by construction (M4a-1 scope), so the slot is empty and
|
|
2235
|
+
// clearly marked rather than silently absent.
|
|
2236
|
+
var answerSlot = document.createElement("div");
|
|
2237
|
+
answerSlot.className = "hint";
|
|
2238
|
+
answerSlot.setAttribute("data-testid", "ask-answer-slot");
|
|
2239
|
+
answerSlot.textContent = "answer controls are not built yet (M4b)";
|
|
2240
|
+
ev.appendChild(answerSlot);
|
|
2241
|
+
return ev;
|
|
2242
|
+
}
|
|
2243
|
+
// hamr's 2026-09-27 exit-check review #3: "when opened from an Inbox
|
|
2244
|
+
// click it's not clear which ask is shown" — one line naming exactly
|
|
2245
|
+
// which ask this is (`Ask i of n`, from src/panel/data.js's own
|
|
2246
|
+
// index/total), which declared step it belongs to (`stepName`, at its
|
|
2247
|
+
// signed prose `stepLine` — src/panel/data.js's `deriveAskStepInfo`,
|
|
2248
|
+
// never re-derived here), when it was asked, and its status. `stepWhy` is
|
|
2249
|
+
// shown verbatim (never a guessed step name) when the books can't name
|
|
2250
|
+
// one — the honest word "before" a real value never invents.
|
|
2251
|
+
function askHeaderMetaText(ask){
|
|
2252
|
+
var bits = ["Ask " + ask.index + " of " + ask.total];
|
|
2253
|
+
var stepBit = typeof ask.stepName === "string" && ask.stepName.length > 0
|
|
2254
|
+
? ask.stepName + (typeof ask.stepLine === "number" ? " (line " + ask.stepLine + ")" : "")
|
|
2255
|
+
: (ask.stepWhy || "step not determinable");
|
|
2256
|
+
bits.push(stepBit);
|
|
2257
|
+
bits.push(typeof ask.askedAt === "string" ? "asked " + (readableDateTime(ask.askedAt) || ask.askedAt) : "asked: unknown");
|
|
2258
|
+
bits.push(ask.open ? "waiting on you" : ask.status);
|
|
2259
|
+
return bits.join(" · ");
|
|
2260
|
+
}
|
|
2261
|
+
function renderAskRow(ask, expanded){
|
|
2262
|
+
var wrap = document.createElement("div");
|
|
2263
|
+
wrap.className = "audit-group";
|
|
2264
|
+
wrap.setAttribute("data-testid", "ask-row-" + (ask.askId || "no-id"));
|
|
2265
|
+
var head = document.createElement("div");
|
|
2266
|
+
head.setAttribute("role", "button");
|
|
2267
|
+
head.setAttribute("tabindex", "0");
|
|
2268
|
+
head.setAttribute("aria-expanded", expanded ? "true" : "false");
|
|
2269
|
+
head.style.cursor = "pointer";
|
|
2270
|
+
var metaLine = document.createElement("div");
|
|
2271
|
+
metaLine.className = "wf-line1";
|
|
2272
|
+
var badge = document.createElement("span");
|
|
2273
|
+
badge.className = "badge " + (ask.open ? "amber" : (ask.status === "accepted" ? "green" : (ask.status === "rejected" ? "red" : "grey")));
|
|
2274
|
+
badge.textContent = ask.open ? "·" : ask.status;
|
|
2275
|
+
metaLine.appendChild(badge);
|
|
2276
|
+
metaLine.appendChild(textDiv("wf-meta", askHeaderMetaText(ask)));
|
|
2277
|
+
head.appendChild(metaLine);
|
|
2278
|
+
// The question itself — a real, bold heading (review #3: "the question
|
|
2279
|
+
// as a clear heading"), never folded into the same small meta line.
|
|
2280
|
+
var qText = typeof ask.question === "string" ? ask.question : (ask.questionWhy || "question not recorded");
|
|
2281
|
+
var qHeading = document.createElement("h4");
|
|
2282
|
+
qHeading.className = "ask-question-heading";
|
|
2283
|
+
qHeading.textContent = qText;
|
|
2284
|
+
head.appendChild(qHeading);
|
|
2285
|
+
wrap.appendChild(head);
|
|
2286
|
+
var body = document.createElement("div");
|
|
2287
|
+
body.hidden = !expanded;
|
|
2288
|
+
body.appendChild(askStatusBlock(ask));
|
|
2289
|
+
body.appendChild(renderAskEvidenceBlock(ask));
|
|
2290
|
+
wrap.appendChild(body);
|
|
2291
|
+
function toggle(){
|
|
2292
|
+
var next = body.hidden;
|
|
2293
|
+
body.hidden = !next;
|
|
2294
|
+
head.setAttribute("aria-expanded", next ? "true" : "false");
|
|
2295
|
+
}
|
|
2296
|
+
head.addEventListener("click", toggle);
|
|
2297
|
+
head.addEventListener("keydown", function(e){
|
|
2298
|
+
if(e.key === "Enter" || e.key === " "){ e.preventDefault(); toggle(); }
|
|
2299
|
+
});
|
|
2300
|
+
return wrap;
|
|
2301
|
+
}
|
|
2302
|
+
function renderAsk(result, focusAskId, loadError){
|
|
2303
|
+
var empty = document.getElementById("ask-empty");
|
|
2304
|
+
var list = document.getElementById("ask-list");
|
|
2305
|
+
if(loadError){ empty.hidden = false; empty.textContent = "failed to load asks: " + loadError; list.hidden = true; list.innerHTML = ""; return; }
|
|
2306
|
+
if(!result){ empty.hidden = false; empty.textContent = "select a run first"; list.hidden = true; list.innerHTML = ""; return; }
|
|
2307
|
+
var asks = result.asks || [];
|
|
2308
|
+
if(!asks.length){
|
|
2309
|
+
empty.hidden = false;
|
|
2310
|
+
empty.textContent = "this run has never parked on a human — no asks recorded";
|
|
2311
|
+
list.hidden = true;
|
|
2312
|
+
list.innerHTML = "";
|
|
2313
|
+
return;
|
|
2314
|
+
}
|
|
2315
|
+
empty.hidden = true;
|
|
2316
|
+
list.hidden = false;
|
|
2317
|
+
list.innerHTML = "";
|
|
2318
|
+
// Default expansion: the ask named by a click from the Inbox
|
|
2319
|
+
// (`focusAskId`) wins; otherwise this run's own open ask (if it has
|
|
2320
|
+
// one) expands; otherwise every ask stays collapsed.
|
|
2321
|
+
var defaultOpenId = focusAskId;
|
|
2322
|
+
if(!defaultOpenId){
|
|
2323
|
+
var openAsk = asks.find(function(a){ return a.open; });
|
|
2324
|
+
if(openAsk) defaultOpenId = openAsk.askId;
|
|
2325
|
+
}
|
|
2326
|
+
asks.forEach(function(ask){
|
|
2327
|
+
var expanded = defaultOpenId != null && ask.askId === defaultOpenId;
|
|
2328
|
+
var row = renderAskRow(ask, expanded);
|
|
2329
|
+
// hamr's 2026-09-27 exit-check review #3: "the ask opened from the
|
|
2330
|
+
// Inbox gets a visible highlight" — a REAL Inbox click (`focusAskId`
|
|
2331
|
+
// set) on THIS ask, never a run's own default open-ask expansion
|
|
2332
|
+
// (which is chosen here, not clicked from the Inbox). Reuses the
|
|
2333
|
+
// Audit tab's own highlight rule (`.audit-group.audit-group-
|
|
2334
|
+
// highlight`, this row already carries the `audit-group` class) —
|
|
2335
|
+
// persistent here, not momentary, since the human navigated here
|
|
2336
|
+
// specifically to see this one.
|
|
2337
|
+
if(focusAskId && ask.askId === focusAskId){
|
|
2338
|
+
row.classList.add("audit-group-highlight");
|
|
2339
|
+
}
|
|
2340
|
+
list.appendChild(row);
|
|
2341
|
+
if(expanded){
|
|
2342
|
+
// Scroll the focused ask into view (M4a-1 design: clicking a stop
|
|
2343
|
+
// on the left "focuses" it on the right) — never on a run's own
|
|
2344
|
+
// default open-ask expansion (only a real Inbox click scrolls).
|
|
2345
|
+
if(focusAskId){
|
|
2346
|
+
setTimeout(function(){ row.scrollIntoView({ block: "center", behavior: "smooth" }); }, 0);
|
|
2347
|
+
}
|
|
2348
|
+
}
|
|
2349
|
+
});
|
|
2350
|
+
}
|
|
2351
|
+
|
|
2352
|
+
// theme toggle
|
|
2353
|
+
(function(){
|
|
2354
|
+
var root = document.documentElement;
|
|
2355
|
+
var btn = document.getElementById("theme-toggle");
|
|
2356
|
+
var stored = null;
|
|
2357
|
+
try{ stored = localStorage.getItem("fwdloop-panel-theme"); }catch(e){}
|
|
2358
|
+
if(stored === "light" || stored === "dark"){ root.setAttribute("data-theme", stored); }
|
|
2359
|
+
function current(){
|
|
2360
|
+
var attr = root.getAttribute("data-theme");
|
|
2361
|
+
if(attr) return attr;
|
|
2362
|
+
return (window.matchMedia && window.matchMedia("(prefers-color-scheme: light)").matches) ? "light" : "dark";
|
|
2363
|
+
}
|
|
2364
|
+
function paint(){ btn.textContent = current() === "dark" ? "☾" : "☀"; }
|
|
2365
|
+
paint();
|
|
2366
|
+
btn.addEventListener("click", function(){
|
|
2367
|
+
var next = current() === "dark" ? "light" : "dark";
|
|
2368
|
+
root.setAttribute("data-theme", next);
|
|
2369
|
+
try{ localStorage.setItem("fwdloop-panel-theme", next); }catch(e){}
|
|
2370
|
+
paint();
|
|
2371
|
+
});
|
|
2372
|
+
})();
|
|
2373
|
+
|
|
2374
|
+
})();
|
|
2375
|
+
</script>
|
|
2376
|
+
</body>
|
|
2377
|
+
</html>
|