trantor 0.18.138 → 0.18.140

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/ui.html DELETED
@@ -1,1141 +0,0 @@
1
- <!doctype html>
2
- <html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
3
- <title>trantor</title>
4
- <style>
5
- :root{--bg:#0a0e16;--panel:#111726;--card:#161d2e;--card2:#1b2335;--line:#1f2839;--tx:#e6edf6;--mut:#8a97a8;--dim:#5b6675;
6
- --grn:#2dd4bf;--grn2:#14b8a6;--amb:#f59e0b;--blu:#4a90d9;--red:#ef6a6a;--pur:#9b6fd4}
7
- *{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--tx);font:14px/1.5 ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,sans-serif;height:100vh;display:flex;flex-direction:column}
8
- header{display:flex;align-items:center;gap:13px;padding:11px 18px;border-bottom:1px solid var(--line);background:var(--panel)}
9
- .logo{font-weight:800;letter-spacing:.4px;font-size:16px}.logo b{color:var(--grn)}
10
- .dot{width:9px;height:9px;border-radius:50%;background:var(--grn);box-shadow:0 0 8px var(--grn);display:inline-block;flex:0 0 auto}
11
- .dot.off{background:var(--dim);box-shadow:none}
12
- .muted{color:var(--mut)}.dim{color:var(--dim)}.spacer{flex:1}
13
- .pill{background:var(--card);border:1px solid var(--line);border-radius:20px;padding:3px 11px;font-size:12px;color:var(--mut)}
14
- .pill.lowbal{color:#ffb4b4;border-color:#5a2c2c;background:#2a1517;animation:failpulse 2.4s ease-in-out infinite}
15
- main{flex:1;display:grid;grid-template-columns:var(--lw,44px) 1fr 330px;min-height:0}
16
- main.learn-open{--lw:372px}
17
- .boards{overflow-y:auto;padding:16px 18px}
18
- /* Project-tab strip (between header + main): jump to a project (multi) or switch focus (solo). */
19
- .ptabs{display:flex;gap:6px;align-items:center;padding:7px 18px;border-bottom:1px solid var(--line);background:var(--panel);overflow-x:auto;white-space:nowrap}
20
- .ptab{display:inline-flex;align-items:center;gap:6px;font:inherit;font-size:11px;font-weight:600;color:var(--mut);background:#0c121e;border:1px solid #34465f;border-radius:11px;padding:4px 10px;cursor:pointer;white-space:nowrap;text-decoration:none;flex:none}
21
- .ptab:hover{color:var(--tx);border-color:var(--grn)}
22
- .ptab.on{color:#06120c;background:var(--grn);border-color:var(--grn)}
23
- .ptab.live::before{content:"";width:6px;height:6px;border-radius:50%;background:var(--grn);box-shadow:0 0 6px var(--grn);flex:none}
24
- .ptab.home{color:var(--dim);font-weight:700}
25
- /* per-project "open in its own window" pop-out icon */
26
- .popout{color:var(--mut);text-decoration:none;font-size:16px;line-height:1;cursor:pointer;flex:none}
27
- .popout:hover{color:var(--grn)}
28
- .proj.flash{animation:flashp 1.2s ease}
29
- @keyframes flashp{0%,100%{box-shadow:none}30%{box-shadow:0 0 0 2px var(--grn)}}
30
- /* SOLO = single-project full-window (deep link ?project=<name>): hide side rails, board fills the window. */
31
- body.solo main{grid-template-columns:1fr}
32
- body.solo .learn,body.solo aside{display:none}
33
- body.solo .boards{padding:0}
34
- body.solo .popout{display:none}
35
- body.solo .proj{margin:0;border:none;border-radius:0}
36
- /* Learning sidebar (collapsible left rail) — surfaces the self-learning loop */
37
- .learn{background:var(--panel);border-right:1px solid var(--line);display:flex;flex-direction:column;min-height:0;overflow:hidden}
38
- .learn-head{display:flex;align-items:center;gap:8px;padding:11px 12px;border-bottom:1px solid var(--line);cursor:pointer;white-space:nowrap;user-select:none}
39
- .learn-head .lt{font-weight:700;font-size:13px;color:var(--tx)}.learn-head .lt b{color:var(--grn)}
40
- .learn-head .chev{margin-left:auto;color:var(--mut);font-size:14px}
41
- main:not(.learn-open) .learn-head{flex-direction:column;gap:12px;padding:14px 0;height:100%;border-bottom:none;justify-content:flex-start}
42
- main:not(.learn-open) .learn-head .lt{writing-mode:vertical-rl;transform:rotate(180deg);letter-spacing:.6px}
43
- main:not(.learn-open) .learn-head .chev{margin:0}
44
- main:not(.learn-open) .learn-body{display:none}
45
- .learn-body{overflow-y:auto;padding:10px 12px 26px;flex:1}
46
- .lsum{font-size:11.5px;color:var(--mut);line-height:1.5;margin-bottom:13px}.lsum b{color:var(--grn)}
47
- .lsec{margin-bottom:17px}
48
- .lsec>h3{font-size:10.5px;text-transform:uppercase;letter-spacing:.6px;color:var(--dim);margin:0 0 7px;display:flex;align-items:center;gap:6px}
49
- .lsel{background:var(--card);color:var(--tx);border:1px solid var(--line);border-radius:6px;font:inherit;font-size:11px;padding:2px 4px;margin-left:auto;cursor:pointer;outline:none}
50
- .lcard{background:var(--card);border:1px solid var(--line);border-radius:9px;padding:8px 10px;margin-bottom:7px}
51
- .lcard .lc-h{display:flex;align-items:center;gap:7px;font-size:12px;margin-bottom:5px}
52
- .lcard .lc-h .nm{font-weight:600;color:var(--tx)}
53
- .lcard .lc-h .mut{color:var(--mut);font-size:10.5px;margin-left:auto}
54
- .lles{font-size:11.5px;color:var(--mut);line-height:1.45;padding:5px 0;border-top:1px solid var(--line)}
55
- .lles:first-child{border-top:none}
56
- .lles .sc{display:inline-block;font-size:9px;color:var(--dim);border:1px solid var(--line);border-radius:8px;padding:0 5px;margin-right:5px;vertical-align:1px;text-transform:uppercase;letter-spacing:.4px}
57
- .lguard{font-size:11px;color:var(--mut);line-height:1.42;padding:3px 0 3px 13px;position:relative}
58
- .lguard:before{content:"";position:absolute;left:3px;top:9px;width:4px;height:4px;border-radius:50%;background:var(--grn)}
59
- .ltask{font-size:9px;color:var(--dim);text-transform:uppercase;letter-spacing:.5px;margin:5px 0 2px}
60
- .lstat{display:inline-block;font-size:10.5px;color:var(--mut);margin-right:10px}
61
- .lstat b{color:var(--tx)}.lstat.bad b{color:var(--red)}.lstat.good b{color:var(--grn)}
62
- .lchart{margin-top:4px}.lchart svg{display:block;width:100%;height:42px}
63
- .lbadge{font-size:8.5px;color:var(--grn);border:1px solid #1d4a44;border-radius:8px;padding:1px 6px;text-transform:none;letter-spacing:0}
64
- .lempty{font-size:11px;color:var(--dim);font-style:italic;padding:4px 0}
65
- .proj{background:var(--panel);border:1px solid var(--line);border-radius:14px;margin-bottom:16px;overflow:hidden}
66
- .proj-h{display:flex;align-items:center;gap:11px;padding:11px 16px;border-bottom:1px solid var(--line);background:#0e1421;border-left:3px solid var(--grn)}
67
- .proj-h .pname{font-family:'Sora',ui-sans-serif,sans-serif;font-weight:800;font-size:22px;letter-spacing:.3px;line-height:1.05;flex:none;white-space:nowrap;padding-right:6px;border-right:1px solid var(--line);margin-right:3px}
68
- .proj-h .pname b{color:var(--grn)}
69
- .proj.idle .proj-h{border-left-color:var(--line)}
70
- .proj.idle .proj-h .pname{font-size:16px}
71
- .agents{display:flex;gap:6px;flex-wrap:wrap}
72
- .agent{display:flex;align-items:center;gap:5px;background:var(--card);border:1px solid var(--line);border-radius:16px;padding:2px 9px 2px 6px;font-size:11.5px;color:var(--mut)}
73
- .agent .nm{color:var(--tx)}
74
- .agent .stale{font-size:9.5px;font-weight:700;color:#ffb454;background:#2a1f10;border:1px solid #5a3c1a;border-radius:7px;padding:1px 5px;cursor:help}
75
- .agent svg{flex:none}
76
- .agent.offl{opacity:.42}
77
- .agent.err{border-color:#ef4444;color:#ef4444}
78
- .agent.err .nm{color:#ef4444}
79
- .agent.down{border-color:#ef4444;background:rgba(239,68,68,.14);color:#ef4444}
80
- .agent.down .nm{color:#ef4444;font-weight:600}
81
- .agent .ast{color:var(--mut)}
82
- .prog{font-size:11.5px;color:var(--dim);white-space:nowrap}
83
- /* project brief + phase row */
84
- .proj-brief{display:flex;align-items:center;gap:12px;padding:9px 16px 4px;flex-wrap:wrap}
85
- .brief{font-size:12.5px;color:var(--mut);line-height:1.45;flex:1;min-width:200px}
86
- .brief.dim{color:var(--dim);font-style:italic}
87
- .phase{font-size:11px;font-weight:600;padding:3px 10px;border-radius:14px;white-space:nowrap;border:1px solid var(--line);background:var(--card)}
88
- .phase.building{color:var(--blu);border-color:#26405f}
89
- .phase.blocked{color:var(--red);border-color:#5a2c2c}
90
- .phase.shipped{color:var(--grn);border-color:#1d4a44}
91
- .phase.planned{color:var(--mut)}
92
- .pbar{height:4px;border-radius:3px;background:#0d1320;margin:2px 16px 0;overflow:hidden}
93
- .pbar i{display:block;height:100%;background:linear-gradient(90deg,var(--grn2),var(--grn));border-radius:3px;transition:width .4s}
94
- .kanban{display:grid;grid-template-columns:repeat(6,1fr);gap:10px;padding:12px 16px}
95
- .col{background:#0d1320;border:1px solid var(--line);border-radius:10px;padding:9px;min-height:140px;max-height:clamp(280px,58vh,1100px);overflow-y:auto}
96
- .col::-webkit-scrollbar{width:6px}.col::-webkit-scrollbar-thumb{background:#243049;border-radius:3px}
97
- .col h4{position:sticky;top:-9px;background:#0d1320;padding:9px 0 6px;margin-top:-9px;z-index:1}
98
- .col h4{margin:0 0 8px;font-size:10.5px;text-transform:uppercase;letter-spacing:.08em;color:var(--dim);display:flex;justify-content:space-between}
99
- .col.todo h4 i{color:var(--mut)}.col.doing h4 i{color:var(--blu)}.col.testing h4 i{color:var(--amb)}.col.done h4 i{color:var(--grn)}.col.blocked h4 i{color:var(--red)}.col.stale h4 i{color:#a99fd0}
100
- .col h4 i{font-style:normal}
101
- .tcard{background:var(--card);border:1px solid var(--line);border-left:3px solid var(--mut);border-radius:7px;padding:7px 9px;margin-bottom:7px;cursor:pointer;font-size:13px}
102
- .tcard:hover{background:var(--card2);border-color:#2c3a52}
103
- .col.doing .tcard{border-left-color:var(--blu)}.col.testing .tcard{border-left-color:var(--amb)}.col.done .tcard{border-left-color:var(--grn)}.col.blocked .tcard{border-left-color:var(--red)}.col.stale .tcard{border-left-color:#8a7fb0;opacity:.82}
104
- .swp{cursor:pointer;font-size:11px;color:var(--dim);border:1px solid var(--line);border-radius:5px;padding:1px 7px;margin-left:6px;user-select:none}.swp:hover{color:var(--amb);border-color:#3a4458}.swp.arm{color:#0b1120;background:var(--amb);border-color:var(--amb)}
105
- .tcard.failed{border-left-color:var(--red);border-color:#5a2c2c;animation:failpulse 1.1s ease-in-out infinite}
106
- .tcard.failed .who{color:#ef6a6a}
107
- @keyframes failpulse{0%,100%{box-shadow:0 0 0 0 rgba(239,106,106,0)}50%{box-shadow:0 0 14px 2px rgba(239,106,106,.55);border-color:#ef6a6a}}
108
- .tcard .who{color:var(--dim);font-size:11px;margin-top:4px;display:flex;align-items:center;gap:3px}
109
- .diff{font-size:9px;font-weight:800;letter-spacing:.04em;padding:1px 5px;border-radius:8px;margin-left:5px;vertical-align:1px}
110
- .diff.easy{background:#13302b;color:#2dd4bf}.diff.medium{background:#2c2a17;color:#f5d90b}.diff.hard{background:#33181f;color:#ff7a90}
111
- .bounce{display:inline-block;font-size:9.5px;font-weight:700;color:#ef6a6a;background:#2a1517;border:1px solid #5a2c2c;border-radius:8px;padding:1px 6px;margin-left:5px}
112
- .mdl{font-size:9px;font-family:ui-monospace,monospace;color:#8fa3be;background:#16202f;border:1px solid #243049;border-radius:7px;padding:1px 5px;margin-left:4px;vertical-align:1px}
113
- .xcount{font-size:9px;font-weight:800;color:#cbd5e1;background:#1c2740;border:1px solid #2c3a52;border-radius:8px;padding:1px 5px;margin-left:5px;vertical-align:1px}
114
- .tcard.done{opacity:.65}.tcard.done span{text-decoration:line-through}
115
- .empty{color:var(--dim);text-align:center;padding:30px}
116
- .empty.big{padding:60px 20px;font-size:15px}
117
- /* idle projects — collapsed thin rows below the live boards */
118
- .idle-head{font-size:10.5px;text-transform:uppercase;letter-spacing:.09em;color:var(--dim);font-weight:700;margin:18px 2px 8px}
119
- .idle-row{display:flex;align-items:center;gap:7px;background:var(--panel);border:1px solid var(--line);border-radius:10px;padding:7px 14px;margin-bottom:7px;font-size:12.5px;color:var(--mut);cursor:pointer}
120
- .idle-row:hover{background:var(--card);border-color:#2c3a52}
121
- .idle-row .nm{color:var(--tx);font-weight:600}
122
- .mv{display:inline-flex;gap:3px;margin-left:6px}
123
- .mv b{cursor:pointer;color:var(--dim);font-size:10px;line-height:1;padding:3px 5px;border:1px solid var(--line);border-radius:6px;background:var(--card);font-weight:400}
124
- .mv b:hover{color:var(--tx);border-color:#2c3a52}
125
- .pdel{cursor:pointer;color:var(--dim);font-size:10.5px;padding:2px 7px;border:1px solid var(--line);border-radius:6px;background:var(--card);margin-left:5px;white-space:nowrap}
126
- .pdel:hover{color:var(--red);border-color:#5a2c2c}
127
- .pdel.arm{color:#fff;background:var(--red);border-color:var(--red)}
128
- .sortmode{font-size:10.5px;color:var(--dim);margin:0 0 10px;cursor:pointer;user-select:none}
129
- .sortmode:hover{color:var(--mut)}
130
- .proj.idle .proj-h{opacity:.55;cursor:pointer}
131
- /* flow (DAG) view */
132
- /* view switcher — a clearly-labelled segmented control so it doesn't disappear next to the model chips */
133
- .vtog{display:inline-flex;align-items:stretch;margin-left:12px;border:1px solid #34465f;border-radius:11px;overflow:hidden;background:#0c121e;flex:none}
134
- .vtog .vlbl{display:flex;align-items:center;font-size:8.5px;font-weight:800;letter-spacing:.09em;color:var(--mut);padding:0 8px;text-transform:uppercase;background:#131c2c;border-right:1px solid #34465f}
135
- .vbtn{font-size:10.5px;font-weight:800;letter-spacing:.04em;padding:4px 13px;border:0;border-left:1px solid #1f2839;background:transparent;color:#9fb0c4;cursor:pointer}
136
- .vbtn:first-of-type{border-left:0}
137
- .vbtn:hover{background:#172339;color:var(--tx)}
138
- .vbtn.on{color:#04110e;background:var(--grn)}
139
- .vbtn.on:hover{background:var(--grn);color:#04110e}
140
- .flowwrap{padding:14px 16px;overflow:auto}
141
- .flowwrap svg{display:block}
142
- .fnode{cursor:pointer}
143
- .fnode rect{fill:var(--card);stroke:var(--line);stroke-width:1.4;rx:9}
144
- .fnode.todo rect{stroke:#3a4458}
145
- .fnode.doing rect{stroke:var(--blu);filter:drop-shadow(0 0 5px rgba(74,144,217,.45))}
146
- .fnode.testing rect{stroke:var(--amb);filter:drop-shadow(0 0 5px rgba(245,158,11,.4))}
147
- .fnode.done rect{stroke:var(--grn);fill:#0f1d1b}
148
- .fnode.blocked rect{stroke:var(--red)}
149
- .fnode.failed rect{stroke:var(--red);animation:fpulse 1.1s ease-in-out infinite}
150
- @keyframes fpulse{0%,100%{filter:drop-shadow(0 0 0 rgba(239,106,106,0))}50%{filter:drop-shadow(0 0 9px rgba(239,106,106,.8))}}
151
- .fnode text{fill:var(--tx);font-size:11.5px;font-family:ui-sans-serif,system-ui}
152
- .fnode .fmeta{fill:var(--dim);font-size:9.5px}
153
- .fnode.done .ftitle{fill:#7d9b95;text-decoration:line-through}
154
- .fedge{fill:none;stroke:#2b3650;stroke-width:1.6}
155
- .fedge.done{stroke:var(--grn2);opacity:.8}
156
- .fedge.active{stroke:var(--blu);stroke-dasharray:6 5;animation:fdash 1s linear infinite}
157
- @keyframes fdash{to{stroke-dashoffset:-11}}
158
- .floop{fill:none;stroke:var(--red);stroke-width:1.4;opacity:.85}
159
- .floopn{fill:var(--red);font-size:9px;font-weight:700}
160
- .flowwrap{position:relative;height:66vh;min-height:340px;overflow:hidden;background:radial-gradient(circle at 1px 1px, #18233a 1px, transparent 0);background-size:26px 26px;border-top:1px solid var(--line);border-bottom:1px solid var(--line);cursor:grab}
161
- .flowwrap.panning{cursor:grabbing}
162
- .flowwrap svg{position:absolute;inset:0;width:100%;height:100%}
163
- .fnode{cursor:move}
164
- .fctl{position:absolute;top:8px;right:10px;display:flex;gap:4px;z-index:2}
165
- .fctl button{font-size:10px;font-weight:700;padding:3px 9px;border-radius:8px;border:1px solid var(--line);background:var(--card);color:var(--mut);cursor:pointer}
166
- .fctl button:hover{color:var(--grn);border-color:#1d4a44}
167
- .fhint{position:absolute;bottom:7px;right:10px;font-size:9.5px;color:var(--dim);z-index:2;pointer-events:none}
168
- .fedge-hit{fill:none;stroke:transparent;stroke-width:12;cursor:pointer}
169
- .felabel{fill:#7e8ca3;font-size:9px;font-family:ui-monospace,monospace;opacity:0;pointer-events:none;transition:opacity .15s}
170
- .fe:hover .felabel{opacity:1}
171
- .fe:hover .fedge{stroke:#5fa8ff}
172
- /* FLOW = development timeline: build-order columns, agent lanes, readable fixed cards, native scroll */
173
- .tlwrap{position:relative;background:#0b1019;border-top:1px solid var(--line);overflow:hidden}
174
- .tlscroll{position:absolute;inset:0;overflow-x:auto;overflow-y:auto}
175
- .tlscroll svg{display:block}
176
- .tlband{fill:#101827}
177
- .tlsep{stroke:#161e2c;stroke-width:1}
178
- .tlgrid{stroke:#161e2c;stroke-width:1}
179
- .tlt{fill:var(--dim);font-size:9px;font-family:ui-sans-serif,system-ui;text-anchor:middle}
180
- .tledge{fill:none;stroke:#33405c;stroke-width:1.6;opacity:.8}
181
- .tledge.done{stroke:var(--grn2)}
182
- .tlbar{fill:none;stroke:rgba(255,255,255,.14);stroke-width:1}
183
- .tlnode{cursor:default}
184
- .tlnode:hover .tlbar{stroke:rgba(255,255,255,.55)}
185
- .tlnode.doing .tlbar,.tlnode.testing .tlbar{stroke:rgba(255,255,255,.3)}
186
- .tlnode.failed .tlbar,.tlnode.blocked .tlbar{stroke:var(--red)}
187
- .tltitle{fill:#eaf1fa;font-size:10.5px;font-family:ui-sans-serif,system-ui;pointer-events:none}
188
- /* pinned lane-label gutter (stays put while the chart scrolls) */
189
- .tlgut{position:absolute;left:0;top:0;bottom:0;background:#0b1019;border-right:1px solid var(--line);z-index:3;pointer-events:none}
190
- .tlguth{display:flex;align-items:center;padding-left:8px;font-size:9px;color:var(--dim);border-bottom:1px solid #161e2c}
191
- .tlgl{display:flex;align-items:center;gap:6px;padding-left:8px;font-size:11px;font-weight:600;color:var(--mut)}
192
- .tlgl svg{flex:none}
193
- .tlwrap .fhint{position:absolute;right:10px;bottom:6px;z-index:3}
194
- .tlnode{cursor:pointer}
195
- /* FLOW v2 = horizontal orchestrator-rooted flowchart TREE. A spine runs left→right; each phase is a
196
- ◇ plan node that fans OUT (drawn edges) to its crew/LLM card nodes, then converges INTO a ◆ integrate
197
- node, which connects to the next phase. Agent is a node property, not the axis. Native horizontal scroll. */
198
- .pflowwrap{background:#0b1019;border-top:1px solid var(--line)}
199
- .finfo{background:#1a2030;border:1px solid var(--line);border-radius:8px;padding:7px 10px;font-size:11px;color:var(--mut);margin:10px 14px 0}
200
- .pflowwrap.gflow{position:relative;padding-bottom:22px}
201
- .gscroll{overflow-x:auto;overflow-y:hidden;padding:4px 0 2px}
202
- .gscroll svg{display:block}
203
- .gedge{fill:none;stroke:#33405c;stroke-width:1.6;opacity:.8}
204
- .gedge.done{stroke:var(--grn2);opacity:.5}
205
- .gspine{fill:none;stroke:#5a6b86;stroke-width:2.5}
206
- .gnode{cursor:default}
207
- .gnode[data-id]{cursor:pointer}
208
- .gnbox{fill:#101827;stroke:rgba(255,255,255,.12);stroke-width:1}
209
- .gnode[data-id]:hover .gnbox{stroke:rgba(255,255,255,.55);fill:#162032}
210
- .gnode.orch .gnbox{fill:#0e1730;stroke:#2c3a55;stroke-dasharray:4 3}
211
- .gnode.failed .gnbox,.gnode.blocked .gnbox{stroke:var(--red)}
212
- .gntext{fill:#eaf1fa;font-size:11px;font-family:ui-sans-serif,system-ui;pointer-events:none}
213
- .gnsub{fill:var(--mut);font-size:9.5px;font-family:ui-sans-serif,system-ui;pointer-events:none}
214
- .gncost{fill:var(--blu);font-size:9px;font-family:ui-sans-serif,system-ui;text-anchor:end;pointer-events:none}
215
- .pfband{fill:#0c1320;opacity:.45}
216
- .pfband.alt{fill:#0e1626;opacity:.55}
217
- .pfbandtop{opacity:.12}
218
- .pfbandtop.done{fill:var(--grn2)}.pfbandtop.active{fill:#f0b24b}.pfbandtop.failed,.pfbandtop.blocked{fill:var(--red)}.pfbandtop.planned{fill:#46566f}
219
- .pflabel{font-size:16px;font-weight:800;font-family:ui-sans-serif,system-ui}
220
- .pflabel.done{fill:var(--grn2)}.pflabel.active{fill:#f0b24b}.pflabel.failed{fill:var(--red)}.pflabel.planned,.pflabel.blocked{fill:#aeb9c8}
221
- .pfcount{fill:var(--mut);font-size:10.5px;font-family:ui-sans-serif,system-ui}
222
- .pfsub{fill:#9fb0c4;font-size:10.5px;font-family:ui-sans-serif,system-ui}
223
- .pflowwrap .fhint{position:absolute;right:12px;bottom:5px}
224
- /* mini-map scrubber: whole project compressed to a bar; click/drag to jump, .gmapview shows position */
225
- .gmap{position:relative;height:18px;margin:10px 16px 4px;border-radius:6px;background:#0c1320;border:1px solid var(--line);overflow:hidden;cursor:pointer;touch-action:none}
226
- .gmapseg{position:absolute;top:2px;bottom:2px;border-radius:2px;opacity:.5}
227
- .gmapseg.done{background:var(--grn2)}.gmapseg.active{background:#f0b24b}.gmapseg.failed,.gmapseg.blocked{background:var(--red)}.gmapseg.planned{background:#46566f}
228
- .gmap:hover .gmapseg{opacity:.7}
229
- .gmapview{position:absolute;top:-1px;bottom:-1px;min-width:8px;background:rgba(255,255,255,.14);border:1.5px solid rgba(255,255,255,.6);border-radius:5px;pointer-events:none;transition:left .04s linear}
230
- /* card detail modal — the full story of one card: status journey + the agent's own bus reports */
231
- .cmodal{position:fixed;inset:0;z-index:60;display:flex;align-items:center;justify-content:center;background:rgba(4,7,12,.62)}
232
- .cmpanel{background:var(--panel);border:1px solid var(--line);border-radius:14px;width:min(760px,93vw);max-height:84vh;display:flex;flex-direction:column;box-shadow:0 20px 64px rgba(0,0,0,.55)}
233
- .cmhead{display:flex;align-items:flex-start;gap:10px;padding:15px 18px;border-bottom:1px solid var(--line)}
234
- .cmtitle{font-size:15px;font-weight:700;color:var(--tx);line-height:1.35}
235
- .cmmeta{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-top:6px;font-size:11.5px;color:var(--mut)}
236
- .cmmeta svg{flex:none;vertical-align:middle}
237
- .cmstat{font-size:10px;padding:1px 8px;border-radius:9px;border:1px solid var(--line)}
238
- .cmclose{margin-left:auto;cursor:pointer;color:var(--mut);font-size:17px;line-height:1;padding:3px 7px;border-radius:6px;flex:none}
239
- .cmclose:hover{background:var(--card);color:var(--tx)}
240
- .cmbody{overflow-y:auto;padding:10px 18px 18px}
241
- .cmrow{display:flex;gap:10px;padding:8px 0;border-top:1px solid #161e2c;font-size:12.5px;line-height:1.5}
242
- .cmrow:first-child{border-top:none}
243
- .cmrow .cmt{flex:none;color:var(--dim);font-size:10px;width:66px;padding-top:2px}
244
- .cmrow.ev .cmtx{color:var(--mut)}
245
- .cmrow .cmtx b{color:var(--tx);font-weight:600}
246
- .cmrow.msg .cmfrom{color:var(--tx);font-weight:600}
247
- .cmrow.msg svg{vertical-align:-2px}
248
- .cmempty{color:var(--dim);font-style:italic;font-size:12px;padding:8px 0}
249
- /* timeline view */
250
- .timeline{padding:14px 18px;overflow-y:auto;max-height:66vh;display:flex;flex-direction:column;gap:5px;background:#0c111c;border-top:1px solid var(--line)}
251
- .tevent{font-size:12.5px;line-height:1.4;color:var(--mut);display:flex;align-items:center;gap:7px;padding:4px 0}
252
- .tevent .tts{font-family:ui-monospace,monospace;font-size:10px;color:var(--dim);min-width:64px}
253
- .tevent .tphrase b{color:var(--tx)}
254
- .tevent .tstatus{font-weight:700;font-size:11px;text-transform:uppercase;letter-spacing:.04em}
255
- .tevent .tstatus.todo{color:var(--mut)}
256
- .tevent .tstatus.doing{color:var(--blu)}
257
- .tevent .tstatus.testing{color:var(--amb)}
258
- .tevent .tstatus.failed{color:var(--red)}
259
- .tevent .tstatus.done{color:var(--grn)}
260
- .tevent .tstatus.blocked{color:var(--red)}
261
- .tevent .tstatus.stale{color:#a99fd0}
262
- .tevent .arr{color:var(--dim);margin:0 2px}
263
- /* FEED view — the unified event log, the board's second lens (v0.17.54) */
264
- .feed{display:flex;flex-direction:column;background:#0c111c;border-top:1px solid var(--line)}
265
- .feedbar{display:flex;align-items:center;gap:6px;padding:8px 18px;border-bottom:1px solid var(--line);flex-wrap:wrap}
266
- .feedbar .flbl{font-size:10px;text-transform:uppercase;letter-spacing:.09em;color:var(--dim);margin-right:2px}
267
- .fchip{background:#131a29;border:1px solid var(--line);color:var(--mut);border-radius:999px;padding:2px 10px;font-size:10.5px;cursor:pointer;text-transform:uppercase;letter-spacing:.05em}
268
- .fchip:hover{color:var(--tx);border-color:#2c3550}
269
- .fchip.on{background:var(--grn);border-color:var(--grn);color:#04120c;font-weight:700}
270
- .fthread{margin-left:auto;display:flex;align-items:center;gap:7px;font-size:11px;color:var(--mut)}
271
- .fthread b{color:var(--tx)}
272
- .fthread .fclr{cursor:pointer;color:var(--dim);border:1px solid var(--line);border-radius:6px;padding:1px 6px}
273
- .fthread .fclr:hover{color:var(--red);border-color:var(--red)}
274
- .feedlog{padding:12px 18px;overflow-y:auto;max-height:66vh;display:flex;flex-direction:column;gap:2px}
275
- .feedlog.empty{color:var(--dim);font-size:12px;padding:18px}
276
- .fev{display:flex;align-items:flex-start;gap:8px;padding:4px 6px;border-radius:6px;font-size:12.5px;line-height:1.45;color:var(--mut);border-left:2px solid transparent}
277
- .fev:hover{background:#111828}
278
- .fev .fts{font-family:ui-monospace,monospace;font-size:10px;color:var(--dim);min-width:64px;padding-top:2px}
279
- .fev .fgl{min-width:15px;text-align:center;padding-top:1px}
280
- .fev .fbody{flex:1;min-width:0;overflow-wrap:anywhere}
281
- .fev .fwho{font-weight:600;color:var(--tx)}
282
- .fev b{color:var(--tx);font-weight:600}
283
- .fev .fmeta{color:var(--dim);font-size:10.5px}
284
- .fev .fref{display:inline-block;background:#16203a;border:1px solid #27324d;color:#8fb4ff;border-radius:5px;padding:0 5px;font-family:ui-monospace,monospace;font-size:10.5px;cursor:pointer;margin:0 1px}
285
- .fev .fref:hover{background:#1e2c4d;color:#bcd4ff}
286
- .fev.k-message{border-left-color:#3b7dd8;color:var(--tx)}
287
- .fev.k-card{border-left-color:#2f8f6b}
288
- .fev.k-presence{border-left-color:#39415a}
289
- .fev.k-focus{border-left-color:#7f6fd0}
290
- .fev.k-handoff{border-left-color:#d08a3a}
291
- .fev.k-gate{border-left-color:#d05a5a}
292
- .fev.k-lesson{border-left-color:#2dd4bf}
293
- .fev.k-commit{border-left-color:#8a8f9c}
294
- .fev.k-cost{border-left-color:#c9a227}
295
- /* per-project inter-agent conversation lane */
296
- .proj-chat{margin:4px 16px 14px;border:1px solid var(--line);border-radius:10px;background:#0c111c}
297
- .proj-chat h5{margin:0;padding:7px 11px;font-size:10px;text-transform:uppercase;letter-spacing:.09em;color:var(--dim);border-bottom:1px solid var(--line);display:flex;align-items:center;gap:6px}
298
- .proj-chat h5 .lc{width:6px;height:6px;border-radius:50%;background:var(--grn);box-shadow:0 0 6px var(--grn)}
299
- .chatlog{max-height:clamp(130px,20vh,320px);overflow-y:auto;padding:7px 11px;display:flex;flex-direction:column;gap:5px}
300
- .cmsg{font-size:12px;line-height:1.4;color:var(--tx)}
301
- .cmsg .ct{color:var(--dim);font-family:ui-monospace,monospace;font-size:10px;margin-right:5px}
302
- .cmsg .cf{font-weight:600}
303
- .cmsg .arr{color:var(--dim);margin:0 4px}
304
- .cmsg .cto{color:var(--blu)}.cmsg.bc .cto{color:var(--amb)}
305
- .cmsg svg{vertical-align:-2px;margin-right:3px}
306
- .chatempty{color:var(--dim);font-size:11.5px;padding:8px 11px;font-style:italic}
307
- aside{border-left:1px solid var(--line);background:var(--panel);display:flex;flex-direction:column;min-height:0}
308
- aside h2{font-size:10.5px;text-transform:uppercase;letter-spacing:.09em;color:var(--dim);margin:0;padding:13px 14px 8px;font-weight:700}
309
- .feed{flex:1;overflow-y:auto;padding:0 14px 10px}
310
- .msg{padding:6px 0;border-bottom:1px solid #131a28;font-size:12.5px}
311
- .msg .t{color:var(--dim);font-size:10.5px;font-family:ui-monospace,monospace}
312
- .msg svg{vertical-align:-2px;margin:0 1px}
313
- .msg .from{color:var(--grn);font-weight:600}.msg .to{color:var(--blu)}.msg.bc .to{color:var(--amb)}
314
- .compose{border-top:1px solid var(--line);padding:10px 12px;display:flex;gap:6px;flex-wrap:wrap}
315
- .compose select,.compose input{background:var(--card);border:1px solid var(--line);color:var(--tx);border-radius:7px;padding:7px 9px;font-size:12.5px}
316
- .compose input{flex:1;min-width:120px}
317
- .compose button{background:var(--grn2);border:none;color:#04201d;font-weight:700;border-radius:7px;padding:7px 14px;cursor:pointer}
318
- @import url('https://fonts.googleapis.com/css2?family=Sora:wght@600;700&display=swap');
319
- </style></head>
320
- <body>
321
- <header>
322
- <span class="dot" id="livedot"></span>
323
- <span class="logo">tran<b>t</b>or</span>
324
- <span class="pill" id="hub">—</span>
325
- <span class="spacer"></span>
326
- <span class="pill" id="econ" title="Trantor savings vs frontier models — lifetime running total + last 24h (from the Scrooge ledger)" style="display:none"></span>
327
- <span class="pill" id="credits" title="Provider credit left — $ balance (prepaid) or % quota (coding plans). Refill/pace before a build stalls. Pushed by sessions/CLI (the hub has no keys)." style="display:none"></span>
328
- <span class="pill"><span id="nproj">0</span> projects · <span id="nsess">0</span> live · <span id="ntask">0</span> cards</span>
329
- </header>
330
- <div class="ptabs" id="ptabs" style="display:none"></div>
331
- <main>
332
- <section class="learn" id="learn">
333
- <div class="learn-head" id="learnToggle" title="Learning — lessons, per-LLM reliability, baked-in guardrails">
334
- <span class="lt">🧠 <b>Learning</b></span><span class="chev" id="learnChev">›</span>
335
- </div>
336
- <div class="learn-body" id="learnBody"></div>
337
- </section>
338
- <div class="boards" id="boards"><div class="empty big">no projects yet — agents register a project on connect</div></div>
339
- <aside>
340
- <h2>Live feed</h2>
341
- <div class="feed" id="feed"></div>
342
- <div class="compose">
343
- <select id="to"><option value="all">all (broadcast)</option></select>
344
- <input id="text" placeholder="message the bus…" />
345
- <button id="send">Send</button>
346
- </div>
347
- </aside>
348
- </main>
349
- <div id="cardmodal" class="cmodal" style="display:none"></div>
350
- <script>
351
- const $=s=>document.querySelector(s);
352
- const esc=s=>String(s).replace(/[&<>"]/g,c=>({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;'}[c]));
353
- // money: thousands separators + 2dp, readable as dollar amounts ($131,965.50). `usd()` returns just the
354
- // number; `$usd()` prefixes the currency symbol.
355
- const usd=(n,dp=2)=>(Number(n)||0).toLocaleString('en-US',{minimumFractionDigits:dp,maximumFractionDigits:dp});
356
- const $usd=(n,sym='$',dp=2)=>sym+usd(n,dp);
357
- const COLS=[['todo','To Do'],['doing','In Progress'],['testing','Testing'],['done','Done'],['blocked','Blocked'],['stale','Stale']];
358
- let nmsg=0;
359
- // SOLO = single-project full-window mode via deep link ?project=<name>. Parsed once (search is static
360
- // per load). When set, render() shows ONLY that project's board/FLOW/TIMELINE and hides the side rails.
361
- const SOLO=(()=>{try{return decodeURIComponent(new URLSearchParams(location.search).get('project')||'');}catch(e){return new URLSearchParams(location.search).get('project')||'';}})();
362
-
363
- /* ---- LLM provider icons (lobehub SVGs — same set used across crebral.ai) ----
364
- Keyed by the AI coding-CLI brand parsed from a session id (e.g. "claude:crebral"). */
365
- const ICON={
366
- anthropic:{c:'#D97757',p:['M13.827 3.52h3.603L24 20h-3.603l-6.57-16.48zm-7.258 0h3.767L16.906 20h-3.674l-1.343-3.461H5.017l-1.344 3.46H0L6.57 3.522zm4.132 9.959L8.453 7.687 6.205 13.48H10.7z']},
367
- openai:{c:'#10A37F',p:['M9.205 8.658v-2.26c0-.19.072-.333.238-.428l4.543-2.616c.619-.357 1.356-.523 2.117-.523 2.854 0 4.662 2.212 4.662 4.566 0 .167 0 .357-.024.547l-4.71-2.759a.797.797 0 00-.856 0l-5.97 3.473zm10.609 8.8V12.06c0-.333-.143-.57-.429-.737l-5.97-3.473 1.95-1.118a.433.433 0 01.476 0l4.543 2.617c1.309.76 2.189 2.378 2.189 3.948 0 1.808-1.07 3.473-2.76 4.163zM7.802 12.703l-1.95-1.142c-.167-.095-.239-.238-.239-.428V5.899c0-2.545 1.95-4.472 4.591-4.472 1 0 1.927.333 2.712.928L8.23 5.067c-.285.166-.428.404-.428.737v6.898zM12 15.128l-2.795-1.57v-3.33L12 8.658l2.795 1.57v3.33L12 15.128zm1.796 7.23c-1 0-1.927-.332-2.712-.927l4.686-2.712c.285-.166.428-.404.428-.737v-6.898l1.974 1.142c.167.095.238.238.238.428v5.233c0 2.545-1.974 4.472-4.614 4.472zm-5.637-5.303l-4.544-2.617c-1.308-.761-2.188-2.378-2.188-3.948A4.482 4.482 0 014.21 6.327v5.423c0 .333.143.571.428.738l5.947 3.449-1.95 1.118a.432.432 0 01-.476 0zm-.262 3.9c-2.688 0-4.662-2.021-4.662-4.519 0-.19.024-.38.047-.57l4.686 2.71c.286.167.571.167.856 0l5.97-3.448v2.26c0 .19-.07.333-.237.428l-4.543 2.616c-.619.357-1.356.523-2.117.523zm5.899 2.83a5.947 5.947 0 005.827-4.756C22.287 18.339 24 15.84 24 13.296c0-1.665-.713-3.282-1.998-4.448.119-.5.19-.999.19-1.498 0-3.401-2.759-5.947-5.946-5.947-.642 0-1.26.095-1.88.31A5.962 5.962 0 0010.205 0a5.947 5.947 0 00-5.827 4.757C1.713 5.447 0 7.945 0 10.49c0 1.666.713 3.283 1.998 4.448-.119.5-.19 1-.19 1.499 0 3.401 2.759 5.946 5.946 5.946.642 0 1.26-.095 1.88-.309a5.96 5.96 0 004.162 1.713z']},
368
- gemini:{c:'#4285F4',p:['M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z']},
369
- mistral:{c:'#FA520F',p:['M3.428 3.4h3.429v3.428h3.429v3.429h-.002 3.431V6.828h3.427V3.4h3.43v13.714H24v3.429H13.714v-3.428h-3.428v-3.429h-3.43v3.428h3.43v3.429H0v-3.429h3.428V3.4zm10.286 13.715h3.428v-3.429h-3.427v3.429z']},
370
- deepseek:{c:'#4D6BFE',p:['M23.748 4.482c-.254-.124-.364.113-.512.234-.051.039-.094.09-.137.136-.372.397-.806.657-1.373.626-.829-.046-1.537.214-2.163.848-.133-.782-.575-1.248-1.247-1.548-.352-.156-.708-.311-.955-.65-.172-.241-.219-.51-.305-.774-.055-.16-.11-.323-.293-.35-.2-.031-.278.136-.356.276-.313.572-.434 1.202-.422 1.84.027 1.436.633 2.58 1.838 3.393.137.093.172.187.129.323-.082.28-.18.552-.266.833-.055.179-.137.217-.329.14a5.526 5.526 0 01-1.736-1.18c-.857-.828-1.631-1.742-2.597-2.458a11.365 11.365 0 00-.689-.471c-.985-.957.13-1.743.388-1.836.27-.098.093-.432-.779-.428-.872.004-1.67.295-2.687.684a3.055 3.055 0 01-.465.137 9.597 9.597 0 00-2.883-.102c-1.885.21-3.39 1.102-4.497 2.623C.082 8.606-.231 10.684.152 12.85c.403 2.284 1.569 4.175 3.36 5.653 1.858 1.533 3.997 2.284 6.438 2.14 1.482-.085 3.133-.284 4.994-1.86.47.234.962.327 1.78.397.63.059 1.236-.03 1.705-.128.735-.156.684-.837.419-.961-2.155-1.004-1.682-.595-2.113-.926 1.096-1.296 2.746-2.642 3.392-7.003.05-.347.007-.565 0-.845-.004-.17.035-.237.23-.256a4.173 4.173 0 001.545-.475c1.396-.763 1.96-2.015 2.093-3.517.02-.23-.004-.467-.247-.588zM11.581 18c-2.089-1.642-3.102-2.183-3.52-2.16-.392.024-.321.471-.235.763.09.288.207.486.371.739.114.167.192.416-.113.603-.673.416-1.842-.14-1.897-.167-1.361-.802-2.5-1.86-3.301-3.307-.774-1.393-1.224-2.887-1.298-4.482-.02-.386.093-.522.477-.592a4.696 4.696 0 011.529-.039c2.132.312 3.946 1.265 5.468 2.774.868.86 1.525 1.887 2.202 2.891.72 1.066 1.494 2.082 2.48 2.914.348.292.625.514.891.677-.802.09-2.14.11-3.054-.614zm1-6.44a.306.306 0 01.415-.287.302.302 0 01.2.288.306.306 0 01-.31.307.303.303 0 01-.304-.308zm3.11 1.596c-.2.081-.399.151-.59.16a1.245 1.245 0 01-.798-.254c-.274-.23-.47-.358-.552-.758a1.73 1.73 0 01.016-.588c.07-.327-.008-.537-.239-.727-.187-.156-.426-.199-.688-.199a.559.559 0 01-.254-.078c-.11-.054-.2-.19-.114-.358.028-.054.16-.186.192-.21.356-.202.767-.136 1.146.016.352.144.618.408 1.001.782.391.451.462.576.685.914.176.265.336.537.445.848.067.195-.019.354-.25.452z']},
371
- moonshot:{c:'#A78BFA',p:['M1.052 16.916l9.539 2.552c.02.68.04 1.36.06 2.033l5.956 1.593a11.997 11.997 0 01-5.586.865 11.99 11.99 0 01-9.969-7.043zm-1.02-5.794l11.353 3.037c-.18.66-.337 1.332-.469 2.011l10.817 2.894a12.076 12.076 0 01-1.845 2.005L.657 15.923a11.99 11.99 0 01-.625-4.801zm1.593-5.15l11.948 3.196c-.368.605-.705 1.231-1.01 1.875l11.295 3.022c-.142.82-.368 1.612-.668 2.365l-11.55-3.09L.124 10.26a11.9 11.9 0 011.501-4.288zm4.442-4.4L17.352 4.59a20.77 20.77 0 00-1.688 1.721l7.823 2.093c.267.852.442 1.744.513 2.665L2.106 5.213a12.084 12.084 0 013.96-3.641zM12.017 0a11.99 11.99 0 0110.42 6.054L7.222.994A11.95 11.95 0 0112.017 0z']},
372
- qwen:{c:'#615CED',p:['M12.604 1.34c.393.69.784 1.382 1.174 2.075a.18.18 0 00.157.091h5.552c.174 0 .322.11.446.327l1.454 2.57c.19.337.24.478.024.837-.26.43-.513.864-.76 1.3l-.367.658c-.106.196-.223.28-.04.512l2.652 4.637c.172.301.111.494-.043.77-.437.785-.882 1.564-1.335 2.34-.159.272-.352.375-.68.37-.777-.016-1.552-.01-2.327.016a.099.099 0 00-.081.05 575.097 575.097 0 01-2.705 4.74c-.169.293-.38.363-.725.364-.997.003-2.002.004-3.017.002a.537.537 0 01-.465-.271l-1.335-2.323a.09.09 0 00-.083-.049H4.982c-.285.03-.553-.001-.805-.092l-1.603-2.77a.543.543 0 01-.002-.54l1.207-2.12a.198.198 0 000-.197 550.951 550.951 0 01-1.875-3.272l-.79-1.395c-.16-.31-.173-.496.095-.965.465-.813.927-1.625 1.387-2.436.132-.234.304-.334.584-.335a338.3 338.3 0 012.589-.001.124.124 0 00.107-.063l2.806-4.895a.488.488 0 01.422-.246c.524-.001 1.053 0 1.583-.006L11.704 1c.341-.003.724.032.9.34zm-3.432.403a.06.06 0 00-.052.03L6.254 6.788a.157.157 0 01-.135.078H3.253c-.056 0-.07.025-.041.074l5.81 10.156c.025.042.013.062-.034.063l-2.795.015a.218.218 0 00-.2.116l-1.32 2.31c-.044.078-.021.118.068.118l5.716.008c.046 0 .08.02.104.061l1.403 2.454c.046.081.092.082.139 0l5.006-8.76.783-1.382a.055.055 0 01.096 0l1.424 2.53a.122.122 0 00.107.062l2.763-.02a.04.04 0 00.035-.02.041.041 0 000-.04l-2.9-5.086a.108.108 0 010-.113l.293-.507 1.12-1.977c.024-.041.012-.062-.035-.062H9.2c-.059 0-.073-.026-.043-.077l1.434-2.505a.107.107 0 000-.114L9.225 1.774a.06.06 0 00-.053-.031z']},
373
- grok:{c:'#cfd3dc',p:['M9.27 15.29l7.978-5.897c.391-.29.95-.177 1.137.272.98 2.369.542 5.215-1.41 7.169-1.951 1.954-4.667 2.382-7.149 1.406l-2.711 1.257c3.889 2.661 8.611 2.003 11.562-.953 2.341-2.344 3.066-5.539 2.388-8.42l.006.007c-.983-4.232.242-5.924 2.75-9.383.06-.082.12-.164.179-.248l-3.301 3.305v-.01L9.267 15.292M7.623 16.723c-2.792-2.67-2.31-6.801.071-9.184 1.761-1.763 4.647-2.483 7.166-1.425l2.705-1.25a7.808 7.808 0 00-1.829-1A8.975 8.975 0 005.984 5.83c-2.533 2.536-3.33 6.436-1.962 9.764 1.022 2.487-.653 4.246-2.34 6.022-.599.63-1.199 1.259-1.682 1.925l7.62-6.815']},
374
- cursor:{c:'#cfd3dc',p:['M22.106 5.68L12.5.135a.998.998 0 00-.998 0L1.893 5.68a.84.84 0 00-.419.726v11.186c0 .3.16.577.42.727l9.607 5.547a.999.999 0 00.998 0l9.608-5.547a.84.84 0 00.42-.727V6.407a.84.84 0 00-.42-.726zm-.603 1.176L12.228 22.92c-.063.108-.228.064-.228-.061V12.34a.59.59 0 00-.295-.51l-9.11-5.26c-.107-.062-.063-.228.062-.228h18.55c.264 0 .428.286.296.514z']}
375
- };
376
- const BRAND=[[/claude|anthropic/,'anthropic'],[/codex|openai|gpt|chatgpt/,'openai'],[/gemini|bard/,'gemini'],[/mistral|mixtral/,'mistral'],[/deepseek/,'deepseek'],[/kimi|moonshot|\bk2\b/,'moonshot'],[/qwen/,'qwen'],[/grok|xai/,'grok'],[/cursor/,'cursor']];
377
- function brandOf(s){const x=String(s).toLowerCase();for(const[re,b]of BRAND)if(re.test(x))return b;return null;}
378
- function iconFor(s,size){const b=brandOf(s);if(!b||!ICON[b])return `<span style="display:inline-flex;width:${size}px;height:${size}px;align-items:center;justify-content:center;border-radius:50%;background:#2a3346;color:#aeb9c9;font-size:${Math.round(size*.55)}px;font-weight:700">${esc(String(s).slice(0,1).toUpperCase())}</span>`;const i=ICON[b];return `<svg viewBox="0 0 24 24" width="${size}" height="${size}" fill="currentColor" style="color:${i.c}">${i.p.map(d=>`<path d="${d}"/>`).join('')}</svg>`;}
379
- const phaseClass=ph=>/^idle ·/.test(ph)?'planned':/FAILED|blocked/.test(ph)?'blocked':/building|verifying|progress/.test(ph)?'building':/shipped|done/.test(ph)?'shipped':'planned';
380
-
381
- let POOLS={};
382
- let ECON=null;
383
- const ECON_WINS=[['24h','last 24h'],['week','last week'],['month','last month'],['quarter','last quarter'],['year','last year']];
384
- let econWin=localStorage.getItem('abEconWin')||'24h';
385
- const econSaved=x=>x?(x.saved_usd!=null?(+x.saved_usd):Math.max(0,(x.opus_equiv_usd||0)-(x.cost_usd||0))):0;
386
- // notional (plan-covered) cost of the orchestrator's OWN Claude work for a window — subagent +
387
- // orchestrator costKinds, summed ONLY with each other (never with real Scrooge spend).
388
- function econNotional(win){
389
- const ck=ECON&&ECON.costKinds&&ECON.costKinds[win]; if(!ck)return 0;
390
- return ((ck['subagent-notional']&&ck['subagent-notional'].usd)||0)+((ck['orchestrator-notional']&&ck['orchestrator-notional'].usd)||0);
391
- }
392
- // invocation count behind the notional figure — lets the pill stay visible (rebuilding) at $0 after a
393
- // reset, instead of vanishing, since there's still recorded sub-agent activity.
394
- function econNotionalCount(win){
395
- const ck=ECON&&ECON.costKinds&&ECON.costKinds[win]; if(!ck)return 0;
396
- return ((ck['subagent-notional']&&ck['subagent-notional'].count)||0)+((ck['orchestrator-notional']&&ck['orchestrator-notional'].count)||0);
397
- }
398
- function renderEcon(){
399
- const lifeCalls=(ECON&&ECON.lifetime&&ECON.lifetime.calls)||0;
400
- const notionalLife=ECON?econNotional('lifetime'):0;
401
- const notionalCnt=ECON?econNotionalCount('lifetime'):0;
402
- if(!ECON||(!lifeCalls&&!notionalCnt&&!(notionalLife>0)))return; // show once we have real savings OR any CC sub-agent activity
403
- const el=$('#econ'); el.style.display='';
404
- // lifetime running total is the fixed headline; the dropdown picks the comparison window.
405
- if(!el.dataset.built){
406
- el.innerHTML=`🪙 Trantor saved <b style="color:var(--grn)" id="econlife"></b> vs frontier`+
407
- `<span style="opacity:.55"> · lifetime · </span>`+
408
- `<select id="econsel" title="comparison window" style="background:#1a2030;color:inherit;border:1px solid rgba(255,255,255,.18);border-radius:4px;font:inherit;font-size:11px;padding:1px 3px;cursor:pointer;outline:none">`+
409
- ECON_WINS.map(([k,l])=>`<option value="${k}">${l}</option>`).join('')+`</select>`+
410
- `<span style="opacity:.85" id="econwinval"></span>`+
411
- `<span id="econnotional" title="Claude's OWN sub-agent work (Agent/Workflow/ultracode) at API rates — plan-covered on a subscription, NOT real spend. Shown separately so it's never confused with the real Scrooge \$ saved." style="opacity:.9;margin-left:2px"></span>`;
412
- const sel=$('#econsel'); sel.value=econWin;
413
- sel.onchange=()=>{econWin=sel.value; localStorage.setItem('abEconWin',econWin); renderEcon();};
414
- el.dataset.built='1';
415
- }
416
- const w=(ECON.windows&&ECON.windows[econWin])||ECON.scrooge, wc=w?w.calls:0;
417
- $('#econlife').textContent=$usd(econSaved(ECON.lifetime));
418
- $('#econwinval').textContent=' '+$usd(econSaved(w))+' ('+wc+' call'+(wc===1?'':'s')+')';
419
- // separate notional line — distinct icon + "notional" wording, never added to the savings number
420
- const nEl=$('#econnotional');
421
- if(nEl) nEl.innerHTML = (notionalLife>0||notionalCnt>0)
422
- ? `<span style="opacity:.5"> · </span>🤖 CC sub-agents <b style="color:var(--blu)">${$usd(notionalLife)}</b> <span style="opacity:.7">notional${notionalLife<=0&&notionalCnt>0?' · rebuilding':''}</span>`
423
- : '';
424
- const sel=$('#econsel'); if(sel)sel.value=econWin;
425
- }
426
- async function econ(){
427
- try{
428
- const e=await (await fetch('/economics')).json();
429
- POOLS={}; for(const[k,v]of Object.entries(e.profile||{}))POOLS[k]=v.tier;
430
- ECON=e; renderEcon();
431
- }catch(_){}
432
- }
433
- econ();setInterval(econ,15000);
434
- async function credits(){
435
- try{
436
- const b=await (await fetch('/balances')).json();
437
- const el=$('#credits'); if(!el)return;
438
- const all=(b.entries||[]);
439
- if(!all.length){el.style.display='none';return;}
440
- el.style.display='';
441
- const sym=c=>c==='CNY'?'¥':c==='EUR'?'€':'$';
442
- const lbl=e=>e.label.replace(/ \(.*/,'');
443
- const cap=s=>String(s||'').replace(/^./,c=>c.toUpperCase());
444
- const txt=e=>e.kind==='quota'
445
- ? `${lbl(e)} ${e.remainingPct==null?'?':e.remainingPct+'%'}`
446
- : `${lbl(e)} ${e.remaining==null?'∞':$usd(e.remaining,sym(e.currency))}`;
447
- const metered=all.filter(e=>e.kind==='prepaid'||e.kind==='quota');
448
- const subs=all.filter(e=>e.kind==='subscription');
449
- const ok=metered.filter(e=>e.ok && (e.remaining!=null||e.remainingPct!=null));
450
- const lows=ok.filter(e=>e.low);
451
- const errs=metered.filter(e=>!e.ok).map(lbl);
452
- const staleTag=b.stale?' · <span style="opacity:.6">stale</span>':'';
453
- // subscriptions (claude/codex/gemini) have no balance to refill — show them dimmed so the configured
454
- // crew is fully visible, just not as $ figures.
455
- const subTxt=subs.length?` <span style="opacity:.5">· ${subs.map(e=>cap(lbl(e))+(e.plan?' ('+e.plan+')':'')).join(' · ')} (sub)</span>`:'';
456
- if(lows.length){
457
- el.classList.add('lowbal');
458
- const rest=ok.filter(e=>!e.low);
459
- el.innerHTML=`🔴 <b>low:</b> ${lows.map(txt).join(' · ')}`+(rest.length?` <span style="opacity:.7">| ${rest.map(txt).join(' · ')}</span>`:'')+subTxt+staleTag;
460
- } else if(ok.length){
461
- el.classList.remove('lowbal');
462
- el.innerHTML=`💳 ${ok.map(txt).join(' · ')}`+(errs.length?` <span style="opacity:.55">· ${errs.join(',')} ?</span>`:'')+subTxt+staleTag;
463
- } else {
464
- el.classList.remove('lowbal');
465
- el.innerHTML=`💳 <span style="opacity:.6">${subs.length?'metered: none':'no credit reporting'}${errs.length?' ('+errs.join(',')+' ?)':''}</span>`+subTxt;
466
- }
467
- }catch(_){}
468
- }
469
- credits();setInterval(credits,30000);
470
- function poolOf(session){const b=brandOf(session);const k=b==='anthropic'?'claude':b==='openai'?'codex':b==='moonshot'?'kimi':b;return POOLS[k]||'';}
471
- const VIEWS = JSON.parse(localStorage.getItem("abViews") || "{}");
472
- let HISTORY = {};
473
- let PHASES = {};
474
- let EVENTS = {}; // project -> unified log (the FEED)
475
- const FEEDF = JSON.parse(localStorage.getItem("abFeedFilter") || "{}"); // project -> filter key
476
- const FEEDT = {}; // project -> pinned thread (card id) or null
477
- function setView(proj, v){ VIEWS[proj] = v; localStorage.setItem("abViews", JSON.stringify(VIEWS)); render(); }
478
- function setFeedFilter(proj, f){ FEEDF[proj] = f; localStorage.setItem("abFeedFilter", JSON.stringify(FEEDF)); render(); }
479
- function setFeedThread(proj, id){ if(id) FEEDT[proj] = id; else delete FEEDT[proj]; render(); }
480
- function toggleIdle(name){ if(!name)return; const s=new Set(JSON.parse(localStorage.getItem("abIdleOpen")||"[]")); s.has(name)?s.delete(name):s.add(name); localStorage.setItem("abIdleOpen",JSON.stringify([...s])); render(); }
481
- let armedDel=null,armedTs=0; // pending ✕ confirmation (project name + when it was armed)
482
- let armedSwp=null,armedSwpTs=0,armedSwpCount=0; // pending 🧹 sweep confirmation (project + when armed + previewed count)
483
- // ▲▼: snapshot the currently displayed order, swap, persist — manual order then wins until ↺ reset
484
- function moveProj(name,dir){
485
- const names=[...document.querySelectorAll('#boards [data-projname]')].map(d=>d.dataset.projname);
486
- const i=names.indexOf(name),j=i+dir;
487
- if(i<0||j<0||j>=names.length)return;
488
- [names[i],names[j]]=[names[j],names[i]];
489
- localStorage.setItem("abOrder",JSON.stringify(names)); render();
490
- }
491
- // FLOW v2 = the project's TRUE shape: an orchestrator-rooted phase flowchart. The orchestrator is the
492
- // spine (the left rail); each PHASE blooms — ◇ plan → the crew fans out to its cards → ◆ converge —
493
- // then the next phase begins. Agent identity is a node badge, not the axis. Phases come from the hub
494
- // (/phases: title-prefix + time-cluster; deps-sparse boards fall back to time + a visible notice).
495
- // Each crew node keeps its full /card detail on click.
496
- function flowHTML(pt, proj){
497
- const data = PHASES[proj];
498
- if (!data) return '<div class="pflowwrap"><div class="empty">loading flow…</div></div>';
499
- if (!data.phases || !data.phases.length) return '<div class="pflowwrap"><div class="empty">no cards yet</div></div>';
500
- const SCOL = { todo:'#3a4458', doing:'#4a90d9', testing:'#f59e0b', failed:'#ef6a6a', blocked:'#ef6a6a', done:'#14b8a6', stale:'#8a7fb0' };
501
- const NW = 168, NH = 34, RG = 11, CG = 64, PGAP = 76, MT = 64, MB = 22;
502
- const MAXPC = 10; // max nodes stacked per column before collapsing into a "+N more" node
503
- let pi0 = 0; // running id base so each phase's overflow nodes get unique negative ids
504
- const stackH = n => n*NH + Math.max(0,n-1)*RG;
505
- // Per-phase layout: cards spread by their INTRA-PHASE dependency depth. Independent cards share
506
- // column 0 (parallel, hanging off the plan node); a card that depends on another lands one column
507
- // to the right of its parent (a branch/chain). Leaves (no dependents) converge into integrate.
508
- const layouts = data.phases.map(ph => {
509
- const work = [...ph.crew.map(n => ({ ...n, _orch:false })), ...ph.orchestrators.map(n => ({ ...n, _orch:true }))];
510
- const cards = work.length ? work : [{ id:0, title:'(no cards)', status:ph.status, agent:'', synthetic:true, deps:[] }];
511
- const idSet = new Set(cards.map(c => c.id)); const byId = {}; cards.forEach(c => byId[c.id] = c);
512
- const parentsOf = c => (c.deps || []).filter(d => idSet.has(d) && d !== c.id);
513
- const dmemo = {}; const depth = (c, seen) => {
514
- if (dmemo[c.id] != null) return dmemo[c.id];
515
- seen = seen || new Set(); if (seen.has(c.id)) return 0; seen.add(c.id);
516
- const ps = parentsOf(c); const d = ps.length ? Math.max(...ps.map(p => depth(byId[p], seen))) + 1 : 0;
517
- return (dmemo[c.id] = d);
518
- };
519
- cards.forEach(c => c._d = depth(c));
520
- const maxDepth = Math.max(0, ...cards.map(c => c._d));
521
- let cols = []; for (let d = 0; d <= maxDepth; d++) cols[d] = cards.filter(c => c._d === d);
522
- const hasChild = c => cards.some(o => parentsOf(o).includes(c.id));
523
- // DEFENSIVE CAP: never stack more than MAXPC nodes in one column. A phase that legitimately (or
524
- // through a bug — see the cc-subagent dedup) has hundreds of independent cards would otherwise make
525
- // the whole canvas thousands of px tall. Collapse the overflow into one "+N more" summary node.
526
- cols = cols.map((col, d) => {
527
- if (col.length <= MAXPC) return col;
528
- const shown = col.slice(0, MAXPC - 1);
529
- const rest = col.slice(MAXPC - 1);
530
- const runs = rest.reduce((n, c) => n + (c.count || 1), 0);
531
- shown.push({ id: -(pi0 + d + 1), title: `+${rest.length} more · ${runs} run${runs > 1 ? 's' : ''}`,
532
- status: rest[0].status, agent: '', synthetic: true, deps: [], _d: d, _overflow: true });
533
- return shown;
534
- });
535
- pi0 += maxDepth + 1;
536
- const displayCards = cols.flat();
537
- return { ph, cards: displayCards, byId, parentsOf, hasChild, maxDepth, cols };
538
- });
539
- const maxColCount = Math.max(1, ...layouts.flatMap(L => L.cols.map(c => c.length)));
540
- const Y0 = MT + stackH(maxColCount)/2; // shared horizontal spine midline
541
- const totalH = MT + stackH(maxColCount) + MB;
542
- const gnode = (x, y, title, status, id, orch, agent, cost) => {
543
- const stripe = SCOL[status] || '#3a4458';
544
- const c = (typeof cost === 'number') ? (cost < 0.005 ? '$' + cost.toFixed(4) : $usd(cost)) : '';
545
- return `<g class="gnode ${status}${orch?' orch':''}"${id?` data-id="${id}"`:''}>`
546
- + `<rect class="gnbox" x="${x}" y="${y}" width="${NW}" height="${NH}" rx="8"/>`
547
- + `<rect x="${x}" y="${y}" width="4" height="${NH}" rx="2" fill="${stripe}"/>`
548
- + `<text class="gntext" x="${x+11}" y="${y+(agent?15:23)}">${esc(title.slice(0,24))}${title.length>24?'…':''}</text>`
549
- + (agent?`<text class="gnsub" x="${x+11}" y="${y+29}">@${esc(agent)}</text>`:'')
550
- + (c?`<text class="gncost" x="${x+NW-8}" y="${y+(agent?15:23)}">${c}</text>`:'')
551
- + `<title>${esc(title)}${agent?' · @'+esc(agent):''}${c?` · ${c} notional`:''} — ${status}</title></g>`;
552
- };
553
- const gedge = (x1,y1,x2,y2,done) => { const mx=(x1+x2)/2;
554
- return `<path class="gedge${done?' done':''}" d="M${x1},${y1} C${mx},${y1} ${mx},${y2} ${x2},${y2}"/>`; };
555
- let x = 26, svg = '', bands = '', segs = [], prevIntRight = null, pi = 0;
556
- for (const L of layouts){
557
- const { ph, cards, byId, parentsOf, hasChild, maxDepth, cols } = L;
558
- const planX = x, planY = Y0 - NH/2;
559
- const colX = d => planX + (d+1)*(NW+CG);
560
- const intX = colX(maxDepth + 1), intY = Y0 - NH/2;
561
- // per-phase background band (alternating) so each phase reads as one region; collected separately
562
- // so all bands paint BEHIND the edges/nodes. The header sits inside the band's top strip.
563
- const bx = planX - 16, bw = (intX + NW + 16) - bx;
564
- bands += `<rect class="pfband ${pi%2?'alt':''}" x="${bx}" y="2" width="${bw}" height="${totalH-4}" rx="10"/>`
565
- + `<rect class="pfbandtop ${ph.status}" x="${bx}" y="2" width="${bw}" height="${MT-12}" rx="10"/>`;
566
- segs.push({ label: ph.label, status: ph.status, total: ph.total, x0: bx, cx: planX, x1: bx + bw });
567
- // header: phase label + the GOAL (explicit) or derived THEME — "what this phase is about"
568
- const desc = (ph.goal || ph.theme || '').slice(0, Math.max(28, Math.floor(bw/7)));
569
- svg += `<text class="pflabel ${ph.status}" x="${planX}" y="${MT-38}">${esc(ph.label)}</text>`
570
- + `<text class="pfcount" x="${planX}" y="${MT-38}" dx="${(esc(ph.label).length*9)+12}">${ph.status} · ${ph.total} card${ph.total>1?'s':''}</text>`
571
- + `<text class="pfsub" x="${planX}" y="${MT-21}">${esc(desc)}</text>`;
572
- if (prevIntRight != null) svg += `<path class="gspine" marker-end="url(#garr)" d="M${prevIntRight},${Y0} L${planX},${Y0}"/>`;
573
- svg += gnode(planX, planY, '◇ '+ph.label+' · plan', ph.status, null, true, '');
574
- // position every card: x by dep-depth column, y stacked + centered on the spine within its column
575
- const pos = {};
576
- cols.forEach((colCards, d) => {
577
- const startY = Y0 - stackH(colCards.length)/2;
578
- colCards.forEach((c, k) => { pos[c.id] = { x: colX(d), y: startY + k*(NH+RG) }; });
579
- });
580
- for (const c of cards){
581
- const p = pos[c.id], parents = parentsOf(c);
582
- if (parents.length) for (const pid of parents){ const pp = pos[pid]; if (pp) svg += gedge(pp.x+NW, pp.y+NH/2, p.x, p.y+NH/2, byId[pid].status==='done'); }
583
- else svg += gedge(planX+NW, planY+NH/2, p.x, p.y+NH/2, ph.status==='done'); // root → plan
584
- const idPrefix = (c.id > 0 && !c.synthetic) ? '#'+c.id+' ' : '';
585
- const cnt = (c.count > 1) ? ' ×'+c.count : '';
586
- svg += gnode(p.x, p.y, idPrefix+c.title+cnt, c.status, c.synthetic?null:c.id, !!c._orch, c.agent||'', c.costUsd);
587
- if (!hasChild(c)) svg += gedge(p.x+NW, p.y+NH/2, intX, intY+NH/2, c.status==='done'); // leaf → integrate
588
- }
589
- svg += gnode(intX, intY, '◆ integrate', ph.status, null, true, '');
590
- prevIntRight = intX + NW;
591
- x = intX + NW + PGAP;
592
- pi++;
593
- }
594
- const totalW = x + 10;
595
- const defs = `<defs><marker id="garr" viewBox="0 0 8 8" refX="7" refY="4" markerWidth="6" markerHeight="6" orient="auto"><path d="M0,0 L8,4 L0,8 z" fill="#46566f"/></marker></defs>`;
596
- const notice = data.sparse ? `<div class="finfo">⚠ inferred phases — few cards carry explicit tags (P1/P5…), so they're grouped by time + title. Prefix cards (e.g. "P6 …") for sharper phases.</div>` : '';
597
- // mini-map / scrubber: each phase a status-colored segment (% of total width). Click or drag to
598
- // jump anywhere; the .gmapview overlay tracks where you are. data-total lets the JS map px↔ratio.
599
- const pct = v => (100 * v / totalW).toFixed(3);
600
- const mapsegs = segs.map(s =>
601
- `<div class="gmapseg ${s.status}" style="left:${pct(s.x0)}%;width:${pct(s.x1 - s.x0)}%" data-cx="${s.cx}" title="${esc(s.label)} · ${s.status} · ${s.total} card${s.total>1?'s':''}"></div>`).join('');
602
- const map = `<div class="gmap" data-proj="${esc(proj)}" data-total="${totalW}">${mapsegs}<div class="gmapview"></div></div>`;
603
- return `<div class="pflowwrap gflow" data-proj="${esc(proj)}">${notice}${map}`
604
- + `<div class="gscroll" data-proj="${esc(proj)}"><svg width="${totalW}" height="${totalH}">${defs}${bands}${svg}</svg></div>`
605
- + `<div class="fhint">orchestrator → crew → integrate · phase by phase · click/drag the bar above to scrub →</div></div>`;
606
- }
607
- const GSCROLL = {};
608
- function wireTimeline(el){
609
- // FLOW v2 graph: scroll-position scrubber (mini-map) + click a card node for its /card detail.
610
- el.querySelectorAll('.gflow').forEach(wrap => {
611
- const proj = wrap.dataset.proj;
612
- const s = wrap.querySelector('.gscroll'), map = wrap.querySelector('.gmap'), view = map && map.querySelector('.gmapview');
613
- if (!s) return;
614
- if (GSCROLL[proj] != null) s.scrollLeft = GSCROLL[proj];
615
- const syncView = () => { // reflect where we are onto the mini-map
616
- if (!view) return;
617
- const w = s.scrollWidth || 1;
618
- view.style.left = (100 * s.scrollLeft / w) + '%';
619
- view.style.width = Math.min(100, 100 * s.clientWidth / w) + '%';
620
- };
621
- s.onscroll = () => { GSCROLL[proj] = s.scrollLeft; flowBusy = Date.now(); syncView(); }; // flag busy so render() defers
622
- requestAnimationFrame(syncView);
623
- if (map) {
624
- const scrubTo = (clientX) => { // map a pointer x onto a scroll position (centered)
625
- const r = map.getBoundingClientRect();
626
- const ratio = Math.max(0, Math.min(1, (clientX - r.left) / r.width));
627
- flowBusy = Date.now(); // keep render() off the board WHILE scrubbing
628
- s.scrollLeft = ratio * s.scrollWidth - s.clientWidth / 2;
629
- };
630
- let scrubbing = false;
631
- map.addEventListener('pointerdown', e => {
632
- scrubbing = true; flowBusy = Date.now();
633
- try { map.setPointerCapture?.(e.pointerId); } catch {}
634
- const seg = e.target.closest && e.target.closest('.gmapseg'); // click a phase segment → jump to that phase
635
- if (seg && seg.dataset.cx != null) s.scrollLeft = +seg.dataset.cx - 40; else scrubTo(e.clientX);
636
- e.preventDefault();
637
- });
638
- map.addEventListener('pointermove', e => { if (scrubbing) scrubTo(e.clientX); });
639
- const end = () => { scrubbing = false; flowBusy = Date.now(); }; // freshen lock on release so the next render is deferred ~1s
640
- map.addEventListener('pointerup', end); map.addEventListener('pointercancel', end); map.addEventListener('lostpointercapture', end);
641
- }
642
- });
643
- el.querySelectorAll('.gnode[data-id]').forEach(n => n.onclick = () => openCard(+n.dataset.id));
644
- }
645
- // Card detail modal: one card's FULL story — its status journey interleaved with the agent's own bus
646
- // reports (what it did, why, how). Click any card in the FLOW timeline to open it.
647
- let cardEsc = null;
648
- async function openCard(id){
649
- let d; try { d = await (await fetch('/card?id=' + id)).json(); } catch { return; }
650
- const t = d.task; if (!t) return;
651
- const SC = { todo:'var(--mut)', doing:'var(--blu)', testing:'var(--amb)', failed:'var(--red)', blocked:'var(--red)', done:'var(--grn)', deleted:'var(--dim)', stale:'#a99fd0' };
652
- const items = [];
653
- for (const e of (d.events||[])) items.push({ ts:e.ts, ev:e });
654
- for (const m of (d.messages||[])) items.push({ ts:m.ts, m });
655
- items.sort((a,b)=> (a.ts||0)-(b.ts||0));
656
- const tm = ts => new Date(ts).toLocaleString([], {month:'short',day:'numeric',hour:'2-digit',minute:'2-digit'});
657
- const rows = items.map(it => {
658
- if (it.ev){ const e=it.ev; const tx = e.type==='created'?`created as <b>${esc(e.to||'todo')}</b>` : e.type==='moved'?`moved <b>${esc(e.from||'')}</b> → <b>${esc(e.to||'')}</b>` : e.type==='deleted'?`deleted` : `updated`;
659
- return `<div class="cmrow ev"><span class="cmt">${esc(tm(e.ts))}</span><span class="cmtx">${tx}${e.by?` · ${esc(String(e.by).split(':')[0])}`:''}</span></div>`; }
660
- const m=it.m; return `<div class="cmrow msg"><span class="cmt">${esc(tm(m.ts))}</span><span class="cmtx">${iconFor(m.from,13)} <span class="cmfrom">${esc(String(m.from).split(':')[0])}</span>${m.to&&m.to!=='all'?` → ${esc(String(m.to).split(':')[0])}`:''}: ${esc(m.text)}</span></div>`;
661
- }).join('');
662
- const el = $('#cardmodal');
663
- el.innerHTML = `<div class="cmpanel">`
664
- + `<div class="cmhead"><div><div class="cmtitle">${esc(t.title)}</div>`
665
- + `<div class="cmmeta">${iconFor(t.assignee||'',14)} ${esc(String(t.assignee||'unassigned').split(':')[0])}`
666
- + ` <span class="cmstat" style="color:${SC[t.status]||'var(--mut)'};border-color:${SC[t.status]||'var(--line)'}">${esc(t.status)}</span>`
667
- + `${t.difficulty?` · ${esc(t.difficulty)}`:''}${t.model?` · ${esc(String(t.model).slice(0,26))}`:''} · #${id} · ${esc(t.project||'')}</div>`
668
- + `<div class="cmmeta">drill: ${t.drill?esc(t.drill):'<i>none on the card — the hub refuses done until one is set</i>'}</div></div>`
669
- + `<span class="cmclose" id="cmclose">✕</span></div>`
670
- + `<div class="cmbody">${rows || '<div class="cmempty">No recorded activity for this card yet — no bus reports reference #'+id+'.</div>'}</div></div>`;
671
- el.style.display = 'flex';
672
- el.querySelector('.cmpanel').onclick = e => e.stopPropagation();
673
- el.onclick = closeCard; $('#cmclose').onclick = closeCard;
674
- cardEsc = e => { if (e.key === 'Escape') closeCard(); };
675
- document.addEventListener('keydown', cardEsc);
676
- }
677
- function closeCard(){ const el=$('#cardmodal'); el.style.display='none'; el.innerHTML=''; if(cardEsc){ document.removeEventListener('keydown', cardEsc); cardEsc=null; } }
678
- let dragging = null; // suppresses re-render mid-gesture
679
- let flowBusy = 0; // timestamp of the last FLOW scrub/scroll — render() defers while you interact
680
- // (the 2.5s poll / SSE rebuild was replacing the scrubber DOM mid-drag → freeze)
681
- function saveCam(proj, cam){ const c = JSON.parse(localStorage.getItem("abFlowCam") || "{}"); c[proj] = cam; localStorage.setItem("abFlowCam", JSON.stringify(c)); }
682
- function wireFlow(el){
683
- el.querySelectorAll(".flowwrap").forEach(w => {
684
- const proj = w.dataset.proj, svg = w.querySelector("svg"), g = w.querySelector(".fcam");
685
- let cam = (JSON.parse(localStorage.getItem("abFlowCam") || "{}"))[proj] || { s: 0.9, tx: 30, ty: 20 };
686
- const apply = () => g.setAttribute("transform", `translate(${cam.tx},${cam.ty}) scale(${cam.s})`);
687
- const zoomAt = (px, py, k) => {
688
- const ns = Math.min(2.5, Math.max(0.2, cam.s * k));
689
- cam.tx = px - (px - cam.tx) * (ns / cam.s); cam.ty = py - (py - cam.ty) * (ns / cam.s); cam.s = ns;
690
- apply(); saveCam(proj, cam);
691
- };
692
- const fit = () => {
693
- try {
694
- const bb = g.getBBox(), r = w.getBoundingClientRect();
695
- const sc = Math.min((r.width - 40) / bb.width, (r.height - 40) / bb.height, 1.6);
696
- cam = { s: sc, tx: (r.width - bb.width * sc) / 2 - bb.x * sc, ty: (r.height - bb.height * sc) / 2 - bb.y * sc };
697
- apply(); saveCam(proj, cam);
698
- } catch {}
699
- };
700
- w.__fit = fit;
701
- // wheel: ONLY zoom with cmd/ctrl held (trackpad pinch reports as ctrl+wheel) — plain wheel scrolls the PAGE
702
- w.addEventListener("wheel", e => {
703
- if (!(e.metaKey || e.ctrlKey)) return; // let it through — never trap page scroll
704
- e.preventDefault();
705
- const r = w.getBoundingClientRect();
706
- zoomAt(e.clientX - r.left, e.clientY - r.top, e.deltaY < 0 ? 1.1 : 1 / 1.1);
707
- }, { passive: false });
708
- w.addEventListener("pointerdown", e => {
709
- if (e.target.closest(".fctl")) return; // controls are not a pan gesture
710
- const node = e.target.closest(".fnode");
711
- if (node) { // drag a node
712
- const id = node.dataset.id;
713
- const tr = /translate\(([-\d.]+),([-\d.]+)\)/.exec(node.getAttribute("transform"));
714
- dragging = { kind: "node", node, id, sx: e.clientX, sy: e.clientY, ox: +tr[1], oy: +tr[2], moved: false, proj };
715
- } else { // pan the canvas
716
- dragging = { kind: "pan", sx: e.clientX, sy: e.clientY, ox: cam.tx, oy: cam.ty, w, proj };
717
- w.classList.add("panning");
718
- }
719
- w.setPointerCapture(e.pointerId);
720
- });
721
- w.addEventListener("pointermove", e => {
722
- if (!dragging) return;
723
- const dx = e.clientX - dragging.sx, dy = e.clientY - dragging.sy;
724
- if (dragging.kind === "node") {
725
- if (Math.abs(dx) + Math.abs(dy) > 3) dragging.moved = true;
726
- dragging.nx = dragging.ox + dx / cam.s; dragging.ny = dragging.oy + dy / cam.s;
727
- dragging.node.setAttribute("transform", `translate(${dragging.nx},${dragging.ny})`);
728
- } else { cam.tx = dragging.ox + dx; cam.ty = dragging.oy + dy; apply(); }
729
- });
730
- w.addEventListener("pointerup", () => {
731
- if (!dragging) return;
732
- if (dragging.kind === "node" && dragging.moved) {
733
- const pos = JSON.parse(localStorage.getItem("abFlowPos") || "{}");
734
- (pos[proj] ||= {})[dragging.id] = { x: dragging.nx, y: dragging.ny };
735
- localStorage.setItem("abFlowPos", JSON.stringify(pos));
736
- dragging.suppressClick = dragging.node.dataset.id; // a drag is not a click
737
- setTimeout(() => (suppressClickId = null), 50);
738
- suppressClickId = dragging.id;
739
- }
740
- if (dragging.kind === "pan") { saveCam(proj, cam); w.classList.remove("panning"); }
741
- dragging = null;
742
- });
743
- w.querySelectorAll(".fctl button").forEach(b => b.onclick = (e) => {
744
- e.stopPropagation(); e.preventDefault();
745
- const r = w.getBoundingClientRect();
746
- if (b.dataset.fa === "in") zoomAt(r.width / 2, r.height / 2, 1.25);
747
- else if (b.dataset.fa === "out") zoomAt(r.width / 2, r.height / 2, 0.8);
748
- else if (b.dataset.fa === "fit") fit();
749
- else if (b.dataset.fa === "auto") {
750
- const pos = JSON.parse(localStorage.getItem("abFlowPos") || "{}");
751
- delete pos[proj]; localStorage.setItem("abFlowPos", JSON.stringify(pos));
752
- const cams = JSON.parse(localStorage.getItem("abFlowCam") || "{}");
753
- delete cams[proj]; localStorage.setItem("abFlowCam", JSON.stringify(cams));
754
- render();
755
- }
756
- });
757
- // first load of this project's flow (no saved camera): fit the whole graph into the stage
758
- if (!(JSON.parse(localStorage.getItem("abFlowCam") || "{}"))[proj]) fit();
759
- });
760
- }
761
- let suppressClickId = null;
762
- function projOf(m){return m.project||(String(m.from).includes(':')?String(m.from).split(':').pop():'');}
763
- function timelineHTML(proj) {
764
- const events = HISTORY[proj] || [];
765
- if (!events.length) return '<div class="timeline empty">no history yet</div>';
766
- const rows = events.map(e => {
767
- const time = new Date(e.ts).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', second: '2-digit' });
768
- let phrase = "";
769
- if (e.type === "created") phrase = `created "<b>${esc(e.title)}</b>" as <span class="tstatus ${esc(e.to)}">${esc(e.to)}</span>`;
770
- else if (e.type === "moved") phrase = `moved "<b>${esc(e.title)}</b>" <span class="tstatus ${esc(e.from)}">${esc(e.from)}</span> <span class="arr">→</span> <span class="tstatus ${esc(e.to)}">${esc(e.to)}</span>`;
771
- else phrase = `${esc(e.type)} "<b>${esc(e.title)}</b>"`;
772
- return `<div class="tevent"><span class="tts">${time}</span>${iconFor(e.by, 13)} <span class="tphrase">${phrase}</span> <span class="dim">by @${esc(String(e.by).split(':')[0])}</span></div>`;
773
- }).join('');
774
- return `<div class="timeline" data-proj="${esc(proj)}">${rows}</div>`;
775
- }
776
- // --- FEED: the unified event log as the board's second lens -------------------------------
777
- // BOARD answers "where does everything stand"; FEED answers "what actually happened, in order,
778
- // and who did it". Same data — /events is the log the board's cards are derived from. A card id
779
- // anywhere in the stream is a clickable #chip that pins the thread (that card's events + every
780
- // message citing it), which is the closest thing here to a chat thread.
781
- const FEEDKINDS = [
782
- ["all", "all", () => true],
783
- ["chat", "chat", e => e.type === "message"],
784
- ["cards", "cards", e => ["created","moved","updated"].includes(e.type)],
785
- ["presence", "presence", e => e.type.startsWith("presence.") || e.type === "focus"],
786
- ["flow", "handoff·gates", e => e.type.startsWith("handoff.") || e.type.startsWith("verify.") || e.type === "lesson"],
787
- ];
788
- function feedKindClass(e){
789
- if (e.type === "message") return "k-message";
790
- if (e.type === "focus") return "k-focus";
791
- if (e.type.startsWith("presence.")) return "k-presence";
792
- if (e.type.startsWith("handoff.")) return "k-handoff";
793
- if (e.type.startsWith("verify.")) return "k-gate";
794
- if (e.type === "lesson") return "k-lesson";
795
- if (e.source === "git") return "k-commit";
796
- if (e.costUsd != null) return "k-cost";
797
- return "k-card";
798
- }
799
- function feedGlyph(e){
800
- if (e.type === "message") return "💬";
801
- if (e.type === "focus") return "◆";
802
- if (e.type === "presence.online") return "○";
803
- if (e.type === "presence.offline") return "◌";
804
- if (e.type === "handoff.written") return "⇄";
805
- if (e.type === "handoff.claimed") return "⇄";
806
- if (e.type === "verify.gate.opened") return "⚠";
807
- if (e.type === "verify.gate.resolved") return "✓";
808
- if (e.type === "lesson") return "🎓";
809
- if (e.source === "git") return "⑂";
810
- if (e.costUsd != null) return "$";
811
- return "●";
812
- }
813
- // Linkify "#123" into a thread chip. Runs on ALREADY-ESCAPED text — never on raw input.
814
- function feedRefs(escaped){
815
- return escaped.replace(/#(\d{1,7})(?![0-9])/g, (m, id) => `<span class="fref" data-ref="${id}">#${id}</span>`);
816
- }
817
- function feedPhrase(e){
818
- const st = s => `<span class="tstatus ${esc(s)}">${esc(s)}</span>`;
819
- switch (true) {
820
- case e.type === "message":
821
- return `<span class="fmeta">→ ${esc(e.toSession === "all" ? "all" : String(e.toSession||"").split(":")[0])}</span> ${feedRefs(esc(e.text || ""))}`;
822
- case e.type === "focus":
823
- return `${e.shift ? "refocused" : "focused"} on “<b>${esc(e.title)}</b>”`;
824
- case e.type === "presence.online": return `came online${e.status?` <span class="fmeta">— ${esc(e.status)}</span>`:""}`;
825
- case e.type === "presence.offline": return `went offline`;
826
- case e.type === "handoff.written": return `wrote a handoff <span class="fmeta">(${esc(e.trigger||"manual")})</span>`;
827
- case e.type === "handoff.claimed": return `claimed the handoff <span class="fmeta">${esc(e.handoffId||"")}</span>`;
828
- case e.type === "verify.gate.opened": return `opened verify gate <b>#${esc(String(e.gateId))}</b> — “${esc(e.claim)}”`;
829
- case e.type === "verify.gate.resolved": return `resolved gate <b>#${esc(String(e.gateId))}</b> as ${st(e.status||"verified")}`;
830
- case e.type === "lesson": return `recorded a lesson — “${esc(e.text)}”`;
831
- case e.source === "git": return `committed “<b>${esc(e.title)}</b>”`;
832
- case e.type === "created": return `created “<b>${esc(e.title)}</b>” as ${st(e.to)}${e.costUsd!=null?` <span class="fmeta">· $${e.costUsd.toFixed(3)}</span>`:""}`;
833
- case e.type === "moved": return `moved “<b>${esc(e.title)}</b>” ${st(e.from)} <span class="arr">→</span> ${st(e.to)}`;
834
- case e.type === "updated": return `re-titled “<b>${esc(e.title)}</b>”`;
835
- default: return `${esc(e.type)} ${e.title?`“<b>${esc(e.title)}</b>”`:""}`;
836
- }
837
- }
838
- function feedHTML(proj){
839
- const all = EVENTS[proj] || [];
840
- const fkey = FEEDF[proj] || "all";
841
- const thread = FEEDT[proj] || null;
842
- const kind = FEEDKINDS.find(k => k[0] === fkey) || FEEDKINDS[0];
843
- const inThread = e => e.taskId === thread || (Array.isArray(e.refs) && e.refs.includes(thread));
844
- const shown = all.filter(e => (thread ? inThread(e) : kind[2](e)));
845
- const chips = FEEDKINDS.map(([k, label]) => {
846
- const n = all.filter(FEEDKINDS.find(x => x[0] === k)[2]).length;
847
- return `<button class="fchip ${fkey===k&&!thread?"on":""}" data-proj="${esc(proj)}" data-feedf="${k}">${esc(label)} ${n}</button>`;
848
- }).join("");
849
- const tbar = thread
850
- ? `<span class="fthread">thread <b>#${esc(String(thread))}</b> · ${shown.length} event(s) <span class="fclr" data-proj="${esc(proj)}" data-feedclear="1">clear ✕</span></span>`
851
- : `<span class="fthread fmeta">${all.length} event(s) · click any #id to open its thread</span>`;
852
- const rows = shown.length ? shown.map(e => {
853
- const time = new Date(e.ts).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', second: '2-digit' });
854
- const who = String(e.by || "system").split(":")[0];
855
- const ref = e.taskId ? `<span class="fref" data-ref="${e.taskId}">#${e.taskId}</span> ` : "";
856
- return `<div class="fev ${feedKindClass(e)}"><span class="fts">${time}</span><span class="fgl">${feedGlyph(e)}</span>`+
857
- `<span class="fbody">${ref}${iconFor(e.by, 13)} <span class="fwho">${esc(who)}</span> ${feedPhrase(e)}</span></div>`;
858
- }).join("") : `<div class="feedlog empty">nothing matches this filter yet</div>`;
859
- return `<div class="feed" data-proj="${esc(proj)}"><div class="feedbar"><span class="flbl">feed</span>${chips}${tbar}</div>`+
860
- (shown.length ? `<div class="feedlog" data-proj="${esc(proj)}">${rows}</div>` : rows)+`</div>`;
861
- }
862
- function chatLane(msgs){
863
- if(!msgs.length)return `<div class="proj-chat"><h5><span class="lc"></span>conversation</h5><div class="chatempty">no messages yet — agents talk here as they coordinate</div></div>`;
864
- const rows=msgs.slice(-8).map(m=>`<div class="cmsg ${m.to==='all'?'bc':''}"><span class="ct">${new Date(m.ts).toLocaleTimeString([],{hour:'2-digit',minute:'2-digit'})}</span>${iconFor(m.from,13)}<span class="cf">${esc(String(m.from).split(':')[0])}</span><span class="arr">→</span><span class="cto">${esc(m.to==='all'?'all':String(m.to).split(':')[0])}</span>: ${esc(m.text)}</div>`).join('');
865
- return `<div class="proj-chat"><h5><span class="lc"></span>conversation · ${msgs.length}</h5><div class="chatlog">${rows}</div></div>`;
866
- }
867
- // Top project-tab strip: chips for every real project. In SOLO it switches the focused project (navigates);
868
- // in the multi-project view it smooth-scrolls to that project's section. The current SOLO project is hilit.
869
- function renderTabStrip(projects){
870
- const strip=$('#ptabs');if(!strip)return;
871
- const real=projects.filter(p=>p.project&&p.project!=='(unassigned)');
872
- if(!real.length){strip.style.display='none';return;}
873
- strip.style.display='';
874
- const chips=real.map(p=>{
875
- const on=SOLO&&(p.project===SOLO||p.project.toLowerCase()===SOLO.toLowerCase());
876
- const live=(p.agents||[]).some(a=>a.online);
877
- return `<button class="ptab${on?' on':''}${live?' live':''}" data-proj="${esc(p.project)}" title="${esc(p.project)}"><span>${esc(p.project)}</span></button>`;
878
- }).join('');
879
- strip.innerHTML=(SOLO?`<a class="ptab home" href="${esc(location.pathname)}" title="back to all projects">⌂ all</a>`:'')+chips;
880
- strip.querySelectorAll('.ptab[data-proj]').forEach(b=>b.onclick=()=>{
881
- const name=b.dataset.proj;
882
- if(SOLO){location.search='?project='+encodeURIComponent(name);return;}
883
- const sec=document.querySelector(`.proj[data-projname="${CSS.escape(name)}"], .idle-row[data-projname="${CSS.escape(name)}"]`);
884
- if(sec){sec.scrollIntoView({behavior:'smooth',block:'start'});sec.classList.add('flash');setTimeout(()=>sec.classList.remove('flash'),1200);}
885
- });
886
- }
887
- async function render(){
888
- let projects=[],tasks=[],msgs=[];
889
- try{projects=(await (await fetch('/projects')).json()).projects||[];}catch(e){}
890
- try{tasks=(await (await fetch('/tasks')).json()).tasks||[];}catch(e){}
891
- try{msgs=(await (await fetch('/recent?limit=200')).json()).messages||[];}catch(e){}
892
-
893
- const histP = projects.filter(p => VIEWS[p.project] === "timeline").map(async p => {
894
- try {
895
- const h = await (await fetch(`/history?project=${encodeURIComponent(p.project)}`)).json();
896
- HISTORY[p.project] = h.events || [];
897
- } catch(e) {}
898
- });
899
- const phaseP = projects.filter(p => VIEWS[p.project] === "flow").map(async p => {
900
- try { PHASES[p.project] = await (await fetch(`/phases?project=${encodeURIComponent(p.project)}`)).json(); } catch(e) {}
901
- });
902
- // FEED pulls the unified log. Unfiltered by type — the chips filter client-side, so switching
903
- // filters is instant and the counts on every chip stay honest.
904
- const feedP = projects.filter(p => VIEWS[p.project] === "feed").map(async p => {
905
- try { EVENTS[p.project] = (await (await fetch(`/events?project=${encodeURIComponent(p.project)}&limit=500`)).json()).events || []; } catch(e) {}
906
- });
907
- await Promise.all([...histP, ...phaseP, ...feedP]);
908
-
909
- // hub was reset (server empty but feed shows history) -> clear the stale client-side feed
910
- if(!msgs.length&&$('#feed').childElementCount>0){$('#feed').innerHTML='';nmsg=0;}
911
- const liveSess=new Set();projects.forEach(p=>p.agents.forEach(a=>{if(a.online)liveSess.add(a.session)}));
912
- $('#nproj').textContent=projects.filter(p=>p.project!=='(unassigned)').length;
913
- $('#nsess').textContent=liveSess.size;
914
- $('#ntask').textContent=tasks.length;
915
- // session dropdown for composer
916
- const allS=[...new Set(projects.flatMap(p=>p.agents.map(a=>a.session)))];
917
- const sel=$('#to'),cur=sel.value;
918
- sel.innerHTML='<option value="all">all (broadcast)</option>'+allS.map(s=>`<option value="${esc(s)}">${esc(s)}</option>`).join('');
919
- sel.value=cur;
920
- // STABLE display order: projects keep their first-seen position so the board NEVER reshuffles on
921
- // activity — a working board updates in place instead of jumping to the top (which made boards
922
- // pop in and out and impossible to read). Manual ▲▼ (abOrder) still wins; live boards group above
923
- // idle. (Recency auto-sort removed — that was the thrash.)
924
- let SEEN=JSON.parse(localStorage.getItem("abSeen")||"[]");
925
- const curNames=projects.map(p=>p.project);
926
- const SEEN2=[...SEEN.filter(n=>curNames.includes(n)),...curNames.filter(n=>!SEEN.includes(n))];
927
- if(JSON.stringify(SEEN2)!==JSON.stringify(SEEN)){SEEN=SEEN2;localStorage.setItem("abSeen",JSON.stringify(SEEN));}
928
- const ORDER=JSON.parse(localStorage.getItem("abOrder")||"[]");
929
- projects.sort((a,b)=>{
930
- const ia=ORDER.indexOf(a.project),ib=ORDER.indexOf(b.project);
931
- if(ia>=0||ib>=0)return (ia<0?1e9:ia)-(ib<0?1e9:ib);
932
- const oa=a.agents.some(x=>x.online),ob=b.agents.some(x=>x.online);if(oa!==ob)return ob-oa;
933
- if(a.project==='(unassigned)')return 1;if(b.project==='(unassigned)')return -1;
934
- return SEEN.indexOf(a.project)-SEEN.indexOf(b.project); // stable first-seen order
935
- });
936
- const el=$('#boards');
937
- if(dragging)return; // never rebuild mid-gesture (project drag / pan)
938
- if(Date.now()-flowBusy < 1000){ clearTimeout(render._t); render._t=setTimeout(render,1100); return; } // ...nor mid-scrub/scroll; catch up shortly after
939
- if(!projects.length){el.innerHTML='<div class="empty big">no projects yet — agents register a project on connect</div>';return;}
940
- const idleOpen=new Set(JSON.parse(localStorage.getItem("abIdleOpen")||"[]"));
941
- const projBlock=p=>{
942
- const pt = tasks.filter(t=>t.project===p.project);
943
- const pmsgs = msgs.filter(m=>projOf(m)===p.project);
944
- const done=pt.filter(t=>t.status==='done').length;
945
- const pct=pt.length?Math.round(done/pt.length*100):0;
946
- const agents=p.agents.sort((a,b)=>b.online-a.online).map(a=>`<span class="agent ${a.online?'':'offl'}${a.health==='down'?' down':a.health==='errored'?' err':''}" title="${esc(a.session)}${a.online?' · online':' · offline'}${a.health&&a.health!=='ok'?' · '+a.health:''}${a.staleHooks?' · OLD Trantor hooks ('+esc(a.hookVersion)+') — restart this session to get the baton safety fixes':''}">${iconFor(a.session,15)}<span class="nm">${esc(a.session)}</span>${a.staleHooks?` <span class="stale" title="running old Trantor hooks (${esc(a.hookVersion)}) — restart to load the baton storm/kill safety fixes">⚠ old hooks</span>`:''}${a.status?` <span class="ast">· ${esc(a.status)}</span>`:''}${poolOf(a.session)?` <span class="ast" style="opacity:.7">[${esc(poolOf(a.session))}]</span>`:''}</span>`).join('');
947
- const cols=COLS.map(([k,label])=>{
948
- let cards=pt.filter(t=>k==='testing'?(t.status==='testing'||t.status==='failed'):t.status===k);
949
- if(k==='done')cards=[...cards].sort((a,b)=>(b.updated||0)-(a.updated||0)); // newest finished on top
950
- if(k==='testing')cards=[...cards].sort((a,b)=>(a.status==='failed'?-1:1)-(b.status==='failed'?-1:1)); // failures float up
951
- return `<div class="col ${k}"><h4>${label} <i>${cards.length}</i></h4>${cards.map(t=>(()=>{
952
- const hist=(t.history||[]);
953
- const last=hist[hist.length-1];
954
- const rank={todo:0,doing:1,testing:2,done:3};
955
- const bounced=last&&last.from!==undefined&&rank[last.to]<rank[last.from]&&(Date.now()-last.ts)<10*60*1000;
956
- const trail=hist.map(h=>`${h.from?h.from+'→':''}${h.to}${h.by?' by '+String(h.by).split(':')[0]:''} @${new Date(h.ts).toLocaleTimeString([],{hour:'2-digit',minute:'2-digit'})}`).join('\n');
957
- return `<div class="tcard ${t.status}" data-id="${t.id}" title="${esc(trail)||'click to advance'}"><span>${esc(t.title)}</span>${t.count>1?`<span class="xcount">×${t.count}</span>`:''}${t.drill?`<span class="mdl" title="drill: ${esc(t.drill)}">drill</span>`:''}${t.difficulty?`<span class="diff ${t.difficulty}">${t.difficulty[0].toUpperCase()}</span>`:''}${t.model?`<span class="mdl">${esc(t.model)}</span>`:''}${bounced?`<span class="bounce">↩ bounced${last.by?' by '+esc(String(last.by).split(':')[0]):''}</span>`:''}${t.assignee?`<div class="who">${iconFor(t.assignee,12)}@${esc(t.assignee)}</div>`:''}</div>`;
958
- })()).join('')}</div>`;
959
- }).join('');
960
- const ph=p.phase||'';
961
- const brief=p.brief?`<span class="brief">${esc(p.brief)}</span>`:`<span class="brief dim">— no brief yet · an agent sets it with relay_project_brief</span>`;
962
- const view = VIEWS[p.project] || "board";
963
- const vtog = `<div class="vtog"><span class="vlbl">view</span><button class="vbtn ${view==="board"?"on":""}" data-proj="${esc(p.project)}" data-view="board">BOARD</button><button class="vbtn ${view==="flow"?"on":""}" data-proj="${esc(p.project)}" data-view="flow">FLOW</button><button class="vbtn ${view==="timeline"?"on":""}" data-proj="${esc(p.project)}" data-view="timeline">TIMELINE</button><button class="vbtn ${view==="feed"?"on":""}" data-proj="${esc(p.project)}" data-view="feed" title="the unified event log — cards, chat, presence, handoffs and gates in one stream">FEED</button></div>`;
964
- const ctl=`<span class="swp" data-proj="${esc(p.project)}" title="sweep stuck in-progress cards (idle > 30m) to the Stale lane — first click previews the count, second click within 4s confirms">🧹 sweep</span><span class="mv"><b class="mvup" data-proj="${esc(p.project)}" title="move up">▲</b><b class="mvdn" data-proj="${esc(p.project)}" title="move down">▼</b></span>${p.idle===true?`<span class="pdel" data-proj="${esc(p.project)}" title="forget this project (cards, peers, brief) — it returns if an agent registers it again">✕</span>`:''}`;
965
-
966
- return `<div class="proj${p.idle===true?' idle':''}" data-projname="${esc(p.project)}"${p.idle===true?` data-idleproj="${esc(p.project)}"`:''}>`+
967
- `<div class="proj-h"><span class="pname">📁 <b>${esc(p.project)}</b></span><a class="popout" href="?project=${encodeURIComponent(p.project)}" target="_blank" rel="noopener" title="open this project in its own window" onclick="event.stopPropagation()">↗</a>${vtog}<div class="agents">${agents||'<span class="dim">no agents</span>'}</div><span class="spacer"></span><span class="prog">${done}/${pt.length} done · ${pct}%</span>${ctl}</div>`+
968
- `<div class="proj-brief">${brief}${ph?`<span class="phase ${phaseClass(ph)}">${esc(ph)}</span>`:''}</div>`+
969
- `<div class="pbar"><i style="width:${pct}%"></i></div>`+
970
- (view === "flow" ? flowHTML(pt, p.project) : view === "timeline" ? timelineHTML(p.project) : view === "feed" ? feedHTML(p.project) : `<div class="kanban">${cols}</div>`)+
971
- chatLane(pmsgs)+
972
- `</div>`;
973
- };
974
- // idle projects (zero online agents) collapse to thin rows below the live boards
975
- const idleRow=p=>{
976
- const pt=tasks.filter(t=>t.project===p.project);const done=pt.filter(t=>t.status==='done').length;
977
- return `<div class="idle-row" data-projname="${esc(p.project)}" data-idleproj="${esc(p.project)}" title="click to expand">💤 <span class="nm">${esc(p.project)}</span><span class="dim">· ${esc(p.phase||'')} · ${done}/${pt.length} cards</span><span class="spacer"></span><a class="popout" href="?project=${encodeURIComponent(p.project)}" target="_blank" rel="noopener" title="open this project in its own window" onclick="event.stopPropagation()">↗</a><span class="mv"><b class="mvup" data-proj="${esc(p.project)}" title="move up">▲</b><b class="mvdn" data-proj="${esc(p.project)}" title="move down">▼</b></span><span class="pdel" data-proj="${esc(p.project)}" title="forget this project (cards, peers, brief) — it returns if an agent registers it again">✕</span></div>`;
978
- };
979
- renderTabStrip(projects);
980
- if(SOLO){
981
- // single-project full-window: render ONLY the deep-linked project, side rails hidden via body.solo
982
- document.body.classList.add('solo');
983
- const only=projects.filter(p=>p.project===SOLO||p.project.toLowerCase()===SOLO.toLowerCase());
984
- if(!only.length){el.innerHTML=`<div class="empty big">project “${esc(SOLO)}” not found — <a href="${esc(location.pathname)}" style="color:var(--grn)">view all projects</a></div>`;return;}
985
- el.innerHTML=only.map(projBlock).join('');
986
- } else {
987
- const live=projects.filter(p=>p.idle!==true),idlers=projects.filter(p=>p.idle===true);
988
- el.innerHTML=(ORDER.length?`<div class="sortmode" id="sortreset" title="you've ordered projects manually — click to go back to automatic (recency) ordering">sort: manual · ↺ back to auto</div>`:'')
989
- +live.map(projBlock).join('')
990
- +(idlers.length?`<div class="idle-head">idle projects · ${idlers.length}</div>`+idlers.map(p=>idleOpen.has(p.project)?projBlock(p):idleRow(p)).join(''):'');
991
- }
992
- // keep each project's chat scrolled to the latest line
993
- el.querySelectorAll('.chatlog').forEach(c=>{if(c.scrollHeight-c.clientHeight<60||c.dataset.stuck!=='0')c.scrollTop=c.scrollHeight;c.onscroll=()=>{c.dataset.stuck=(c.scrollHeight-c.scrollTop-c.clientHeight<40)?'1':'0';};});
994
- // click a card -> advance status todo->doing->done
995
- el.querySelectorAll('.vbtn').forEach(b=>b.onclick=()=>setView(b.dataset.proj,b.dataset.view));
996
- // collapsed idle row -> expand; expanded idle project's header -> collapse again
997
- el.querySelectorAll('.idle-row').forEach(r=>r.onclick=e=>{if(e.target.closest('.mv,.pdel'))return;toggleIdle(r.dataset.idleproj);});
998
- el.querySelectorAll('.proj.idle .proj-h').forEach(h=>h.onclick=e=>{if(e.target.closest('.vbtn,.agent,.mv,.pdel'))return;toggleIdle(h.closest('.proj').dataset.idleproj);});
999
- // ▲▼ reorder (persists as a manual order); ✕ forget — armed two-step, no popup
1000
- el.querySelectorAll('.mvup').forEach(b=>b.onclick=e=>{e.stopPropagation();moveProj(b.dataset.proj,-1);});
1001
- el.querySelectorAll('.mvdn').forEach(b=>b.onclick=e=>{e.stopPropagation();moveProj(b.dataset.proj,1);});
1002
- // 🧹 sweep — armed two-step (no popup): first click previews the count via dryRun, second confirms.
1003
- el.querySelectorAll('.swp').forEach(b=>b.onclick=async e=>{
1004
- e.stopPropagation();
1005
- const p=b.dataset.proj;
1006
- if(!(armedSwp===p&&Date.now()-armedSwpTs<4000)){
1007
- const dry=await fetch('/sweep',{method:'POST',headers:{'content-type':'application/json'},body:JSON.stringify({project:p,olderMs:1800000,dryRun:true})}).then(r=>r.json()).catch(()=>({count:0}));
1008
- if(!dry.count){b.textContent='🧹 nothing idle';setTimeout(()=>{b.textContent='🧹 sweep';},1600);return;}
1009
- armedSwp=p;armedSwpTs=Date.now();armedSwpCount=dry.count;b.classList.add('arm');b.textContent=`🧹 sweep ${dry.count}?`;return;
1010
- }
1011
- armedSwp=null;b.classList.remove('arm');
1012
- await fetch('/sweep',{method:'POST',headers:{'content-type':'application/json'},body:JSON.stringify({project:p,olderMs:1800000,by:'dashboard'})});
1013
- render();
1014
- });
1015
- el.querySelectorAll('.pdel').forEach(b=>b.onclick=async e=>{
1016
- e.stopPropagation();
1017
- const p=b.dataset.proj;
1018
- if(!(armedDel===p&&Date.now()-armedTs<4000)){armedDel=p;armedTs=Date.now();b.classList.add('arm');b.textContent='✕ sure?';return;}
1019
- armedDel=null;
1020
- await fetch('/project/delete',{method:'POST',headers:{'content-type':'application/json'},body:JSON.stringify({project:p})});
1021
- render();
1022
- });
1023
- // the 2.5s re-render rebuilds the DOM — re-apply a still-fresh armed state so the
1024
- // "✕ sure?" confirmation survives until it expires instead of silently resetting
1025
- if(armedDel&&Date.now()-armedTs<4000){const ab=el.querySelector(`.pdel[data-proj="${CSS.escape(armedDel)}"]`);if(ab){ab.classList.add('arm');ab.textContent='✕ sure?';}}
1026
- if(armedSwp&&Date.now()-armedSwpTs<4000){const sb=el.querySelector(`.swp[data-proj="${CSS.escape(armedSwp)}"]`);if(sb){sb.classList.add('arm');sb.textContent=`🧹 sweep ${armedSwpCount||''}?`;}}else{armedSwp=null;}
1027
- const sr=$('#sortreset');if(sr)sr.onclick=()=>{localStorage.removeItem('abOrder');render();};
1028
- wireFlow(el);wireTimeline(el);
1029
- // keep each timeline scrolled to the latest event
1030
- el.querySelectorAll('.timeline').forEach(c=>{if(c.scrollHeight-c.clientHeight<60||c.dataset.stuck!=='0')c.scrollTop=c.scrollHeight;c.onscroll=()=>{c.dataset.stuck=(c.scrollHeight-c.scrollTop-c.clientHeight<40)?'1':'0';};});
1031
- // FEED: filter chips, #id thread pinning, and the same stick-to-latest scroll as the timeline
1032
- el.querySelectorAll('.fchip[data-feedf]').forEach(b=>b.onclick=e=>{e.stopPropagation();setFeedThread(b.dataset.proj,null);setFeedFilter(b.dataset.proj,b.dataset.feedf);});
1033
- el.querySelectorAll('.fclr[data-feedclear]').forEach(b=>b.onclick=e=>{e.stopPropagation();setFeedThread(b.dataset.proj,null);});
1034
- el.querySelectorAll('.feed .fref[data-ref]').forEach(b=>b.onclick=e=>{
1035
- e.stopPropagation();
1036
- const proj=b.closest('.feed')?.dataset.proj;if(!proj)return;
1037
- setFeedThread(proj,+b.dataset.ref);
1038
- });
1039
- el.querySelectorAll('.feedlog').forEach(c=>{if(c.scrollHeight-c.clientHeight<60||c.dataset.stuck!=='0')c.scrollTop=c.scrollHeight;c.onscroll=()=>{c.dataset.stuck=(c.scrollHeight-c.scrollTop-c.clientHeight<40)?'1':'0';};});
1040
- el.querySelectorAll('.tcard, .fnode').forEach(c=>c.onclick=async()=>{
1041
- const id=+c.dataset.id,t=tasks.find(x=>x.id===id);if(!t)return;
1042
- if(suppressClickId&&+suppressClickId===id)return; // drag-end, not a click
1043
- const next={todo:'doing',doing:'testing',testing:'done',failed:'doing',done:'todo',blocked:'doing',stale:'todo'}[t.status];
1044
- const r=await fetch('/task/update',{method:'POST',headers:{'content-type':'application/json'},body:JSON.stringify({id,status:next})});
1045
- if(!r.ok){let j={};try{j=await r.json();}catch{} alert(`#${id} stays ${t.status}: ${j.error||('hub '+r.status)}`);} // #6452: a refused move (no drill line, frozen assignee) says why
1046
- render();
1047
- });
1048
- }
1049
- function addMsg(m,count=true){
1050
- if(count){nmsg++;$('#ntask');}
1051
- const d=document.createElement('div');d.className='msg'+(m.to==='all'?' bc':'');
1052
- d.innerHTML=`<span class="t">${new Date(m.ts).toLocaleTimeString()}</span> ${iconFor(m.from,12)} <span class="from">${esc(m.from)}</span> → <span class="to">${esc(m.to)}</span>: ${esc(m.text)}`;
1053
- const f=$('#feed');const stick=f.scrollHeight-f.scrollTop-f.clientHeight<50;f.appendChild(d);if(stick)f.scrollTop=f.scrollHeight;
1054
- }
1055
- let _ev=null;
1056
- function stream(){
1057
- try{_ev&&_ev.close();}catch(_){} // drop any prior connection before reopening (no duplicate streams)
1058
- const ev=new EventSource('/stream?session=all&events=1');_ev=ev;
1059
- ev.onmessage=e=>{try{addMsg(JSON.parse(e.data));render();}catch(_){}};
1060
- // The unified log arrives on its own NAMED channel ("ev") so it can never be mistaken for a bus
1061
- // message by onmessage above. Append in place, then re-render — the FEED is live, not polled.
1062
- ev.addEventListener('ev',e=>{try{
1063
- const x=JSON.parse(e.data),p=x.project||'';
1064
- if(!p||VIEWS[p]!=='feed')return; // only for a project actually showing the feed
1065
- const arr=EVENTS[p]||(EVENTS[p]=[]);
1066
- if(!arr.some(y=>y.id===x.id)){arr.push(x);if(arr.length>500)arr.splice(0,arr.length-500);}
1067
- render();
1068
- }catch(_){}});
1069
- ev.onerror=()=>{$('#livedot').classList.add('off');setTimeout(()=>{ev.close();if(_ev===ev)stream();$('#livedot').classList.remove('off');},2000);};}
1070
- $('#send').onclick=async()=>{const t=$('#text').value.trim();if(!t)return;
1071
- await fetch('/send',{method:'POST',headers:{'content-type':'application/json'},body:JSON.stringify({from:'dashboard',to:$('#to').value,text:t})});$('#text').value='';};
1072
- $('#text').addEventListener('keydown',e=>{if(e.key==='Enter')$('#send').click();});
1073
- fetch('/recent?limit=40').then(r=>r.json()).then(d=>(d.messages||[]).forEach(m=>addMsg(m,false))).catch(()=>{});
1074
- $('#hub').textContent=location.host;
1075
- /* ---- Learning sidebar: the self-learning loop, surfaced ---- */
1076
- const LGRN='#2dd4bf',LRED='#ef6a6a';
1077
- // tiny inline-SVG charts (no library) — match the flow view's hand-rolled SVG approach
1078
- function lcLine(pts,key,opt){opt=opt||{};const w=300,h=42,pad=4,color=opt.color||LGRN;if(!pts||!pts.length)return '';
1079
- const ys=pts.map(p=>+p[key]||0),max=Math.max(1e-6,...ys),n=pts.length;
1080
- const X=i=>pad+(n<=1?(w-2*pad)/2:i*(w-2*pad)/(n-1)),Y=v=>h-pad-(v/max)*(h-2*pad);
1081
- const pl=pts.map((p,i)=>`${X(i).toFixed(1)},${Y(+p[key]||0).toFixed(1)}`).join(' ');
1082
- return `<svg viewBox="0 0 ${w} ${h}" preserveAspectRatio="none">`+
1083
- (opt.fill?`<polygon points="${pad},${h-pad} ${pl} ${X(n-1).toFixed(1)},${h-pad}" fill="${color}" opacity=".13"/>`:'')+
1084
- `<polyline points="${pl}" fill="none" stroke="${color}" stroke-width="1.5" stroke-linejoin="round"/>`+
1085
- (n===1?`<circle cx="${X(0).toFixed(1)}" cy="${Y(ys[0]).toFixed(1)}" r="2.2" fill="${color}"/>`:'')+`</svg>`;}
1086
- function lcBars(pts,key,opt){opt=opt||{};const w=300,h=42,pad=4,color=opt.color||LGRN;if(!pts||!pts.length)return '';
1087
- const ys=pts.map(p=>+p[key]||0),max=Math.max(1e-6,...ys),n=pts.length,gap=(w-2*pad)/n,bw=gap*0.68;
1088
- return `<svg viewBox="0 0 ${w} ${h}" preserveAspectRatio="none">`+pts.map((p,i)=>{const v=+p[key]||0,bh=(v/max)*(h-2*pad),x=pad+i*gap+(gap-bw)/2;
1089
- return `<rect x="${x.toFixed(1)}" y="${(h-pad-bh).toFixed(1)}" width="${bw.toFixed(1)}" height="${Math.max(0.5,bh).toFixed(1)}" rx="1" fill="${color}" opacity=".75"/>`;}).join('')+`</svg>`;}
1090
- let LEARN=null,learnProj=localStorage.getItem('abLearnProj')||'';
1091
- let learnOpen=localStorage.getItem('abLearnOpen')==='1';
1092
- function applyLearnState(){document.querySelector('main').classList.toggle('learn-open',learnOpen);$('#learnChev').textContent=learnOpen?'‹':'›';}
1093
- function renderLearnBody(){const el=$('#learnBody');if(!el)return;if(!LEARN){el.innerHTML='<div class="lempty">loading…</div>';return;}
1094
- const L=LEARN,t=L.totals||{};
1095
- let h=`<div class="lsum">Trantor has recorded <b>${t.lessons||0}</b> lessons and baked <b>${t.guardrails||0}</b> guardrails into model prompts. Across <b>${t.turns||0}</b> crew turns the failure rate is <b>${((t.failRate||0)*100).toFixed(1)}%</b> — self-healing as fixes compound.</div>`;
1096
- // Lessons (project filter; lifetime also shows per-agent lessons)
1097
- const projOpts=['<option value="">All projects (lifetime)</option>'].concat((L.lessons.projects||[]).map(p=>`<option value="${esc(p)}"${p===learnProj?' selected':''}>${esc(p)}</option>`)).join('');
1098
- h+=`<div class="lsec"><h3>Lessons <select class="lsel" id="lprojSel">${projOpts}</select></h3>`;
1099
- const lessons=learnProj?(L.lessons.byProject[learnProj]||[]):(L.lessons.global||[]);
1100
- if(!lessons.length)h+=`<div class="lempty">no lessons recorded for this scope yet</div>`;
1101
- else h+=lessons.slice(0,40).map(l=>`<div class="lles"><span class="sc">${esc(l.scope)}</span>${esc(l.text)}</div>`).join('');
1102
- if(!learnProj)for(const[ag,arr]of Object.entries(L.lessons.byAgent||{}))h+=`<div class="lles"><span class="sc">${esc(ag)}</span>${esc(arr[0].text)}${arr.length>1?` <span class="dim">+${arr.length-1} more</span>`:''}</div>`;
1103
- h+=`</div>`;
1104
- // Per-LLM reliability + progression charts — scoped to the selected project (or all)
1105
- const scopeLbl=learnProj?` <span class="dim" style="text-transform:none;letter-spacing:0">· ${esc(learnProj)}</span>`:'';
1106
- const ags=learnProj?(L.agentsByProject[learnProj]||[]):(L.agents||[]);
1107
- h+=`<div class="lsec"><h3>Per-LLM reliability${scopeLbl}</h3>`;
1108
- if(!ags.length)h+=`<div class="lempty">no turn telemetry${learnProj?' for this project':''} yet</div>`;
1109
- for(const a of ags){const fr=(a.failRate*100).toFixed(1);
1110
- h+=`<div class="lcard"><div class="lc-h">${iconFor(a.agent,14)}<span class="nm">${esc(a.agent)}</span><span class="mut">${a.models.filter(m=>m!=='default').join(', ')||'default'}</span></div>`;
1111
- h+=`<span class="lstat"><b>${a.turns}</b> turns</span><span class="lstat ${a.failures?'bad':'good'}"><b>${fr}%</b> fail</span>${a.lastFailure?`<span class="lstat">last exit ${a.lastFailure.exit}</span>`:''}`;
1112
- if((a.series.failRate||[]).length>1)h+=`<div class="lchart"><div class="ltask">fail-rate / day</div>${lcLine(a.series.failRate,'rate',{color:LRED,fill:true})}</div>`;
1113
- if((a.series.lessons||[]).length>1)h+=`<div class="lchart"><div class="ltask">lessons learned (cumulative)</div>${lcLine(a.series.lessons,'count',{color:LGRN,fill:true})}</div>`;
1114
- h+=`</div>`;}
1115
- h+=`</div>`;
1116
- // Baked-in guardrails per model + savings chart — guardrails are global; savings scoped to the project
1117
- h+=`<div class="lsec"><h3>Baked-in improvements${scopeLbl} <span class="lbadge">auto-injected into prompts</span></h3>`;
1118
- const gm=(learnProj?(L.modelsByProject[learnProj]||[]):(L.models||[])).filter(m=>m.guardrailCount>0);
1119
- if(!gm.length)h+=`<div class="lempty">no guardrailed models${learnProj?' used in this project':''} yet</div>`;
1120
- for(const m of gm){h+=`<div class="lcard"><div class="lc-h"><span class="nm">${esc(m.model)}</span>${m.saved_usd?`<span class="mut">$${m.saved_usd} saved · ${m.calls} calls</span>`:''}</div>`;
1121
- for(const[task,arr]of Object.entries(m.guardrails||{})){h+=`<div class="ltask">${esc(task)}</div>`;for(const g of arr)h+=`<div class="lguard">${esc(g)}</div>`;}
1122
- if((m.series.saved||[]).length>1)h+=`<div class="lchart"><div class="ltask">savings / day</div>${lcBars(m.series.saved,'saved',{color:LGRN})}</div>`;
1123
- h+=`</div>`;}
1124
- h+=`</div>`;
1125
- el.innerHTML=h;
1126
- const ps=$('#lprojSel');if(ps)ps.onchange=()=>{learnProj=ps.value;localStorage.setItem('abLearnProj',learnProj);renderLearnBody();};}
1127
- async function learn(){try{LEARN=await (await fetch('/learning')).json();if(learnOpen)renderLearnBody();}catch(_){}}
1128
- $('#learnToggle').onclick=()=>{learnOpen=!learnOpen;localStorage.setItem('abLearnOpen',learnOpen?'1':'0');applyLearnState();if(learnOpen)renderLearnBody();};
1129
- applyLearnState();learn();setInterval(learn,20000);
1130
-
1131
- render();setInterval(render,2500);stream();
1132
- // Self-heal after the laptop sleeps / the tab is backgrounded: browser timers and the SSE
1133
- // stream get suspended and don't reliably resume, so the board freezes on stale data. The
1134
- // moment the tab becomes visible / focused / regains network, force an immediate refresh +
1135
- // stream reconnect — the equivalent of the heartbeat's "first action after wake" on the UI side.
1136
- function wake(){render();stream();}
1137
- document.addEventListener('visibilitychange',()=>{if(!document.hidden)wake();});
1138
- addEventListener('focus',wake);
1139
- addEventListener('online',wake);
1140
- </script>
1141
- </body></html>