@oakgreencc/canopy 0.0.9 → 0.0.10
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/README.md +3 -1
- package/package.json +1 -1
- package/src/page.mjs +104 -15
package/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# canopy
|
|
2
2
|
|
|
3
|
-
A local, read-only page over [cambium](../cambium)'s heartbeat and the GitHub queues: mode, last tick and its staleness, step results, counts and caps, workers (attempt, elapsed against the wall-clock cap, log paths), recent events, and one
|
|
3
|
+
A local, read-only page over [cambium](../cambium)'s heartbeat and the GitHub queues: mode, last tick and its staleness, step results, counts and caps, workers (attempt, elapsed against the wall-clock cap, log paths), recent events, the `q:human` items with their `why:*`, and one swim lane per queue (`q:intake`, `q:task`, `running`, `q:promote`) next to the open `agent/*` PRs and their checks.
|
|
4
|
+
|
|
5
|
+
The page has three tabs under a header that always shows mode and tick: **Inbox** (`q:human`, what needs you), **Queue** (the swim lanes and agent PRs) and **Loop** (last tick, workers, events). Tab badges carry the inbox count, the in-flight count and a health dot, and the browser tab title is prefixed with the inbox count. The tab is kept in the URL hash (`#inbox`, `#queue`, `#loop`).
|
|
4
6
|
|
|
5
7
|
Zero runtime dependencies, Node ≥ 22. GitHub is read through [`graft`](../graft) (`graft graphql`), which must be on `PATH`; canopy holds no credentials and writes nothing.
|
|
6
8
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oakgreencc/canopy",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"description": "A local read-only page over cambium's heartbeat and the GitHub queues: mode, ticks, workers, events, and the q:* columns with agent PRs.",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"type": "module",
|
package/src/page.mjs
CHANGED
|
@@ -15,7 +15,23 @@ code,.mono{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:12p
|
|
|
15
15
|
#top{position:sticky;top:0;z-index:1}
|
|
16
16
|
header{display:flex;flex-wrap:wrap;align-items:baseline;gap:6px var(--s4);padding:10px var(--s4);border-bottom:1px solid var(--line);background:var(--panel)}
|
|
17
17
|
header h1{font-size:14px;margin:0;font-weight:600}
|
|
18
|
+
.tabs{display:flex;gap:var(--s5);padding:0 var(--s4);border-bottom:1px solid var(--line);background:var(--panel);overflow-x:auto;scrollbar-width:none}
|
|
19
|
+
.tab{appearance:none;background:none;border:0;border-bottom:2px solid transparent;margin-bottom:-1px;padding:9px 0 8px;font:inherit;font-weight:500;color:var(--muted);cursor:pointer;display:inline-flex;align-items:center;gap:6px;white-space:nowrap}
|
|
20
|
+
.tab:hover{color:var(--text)}.tab[aria-selected=true]{color:var(--text);border-bottom-color:var(--text);font-weight:600}
|
|
21
|
+
.tab:focus-visible{outline:2px solid var(--accent);outline-offset:-2px;border-radius:3px}
|
|
22
|
+
.tab .count{min-width:18px;padding:0 6px;border-radius:9px;background:var(--chip);color:var(--muted);font-size:12px;font-weight:500;text-align:center}
|
|
23
|
+
.tab .count.attn{background:color-mix(in srgb,var(--warn) 20%,transparent);color:var(--warn);font-weight:600}
|
|
24
|
+
.tab .dot{margin:0}
|
|
18
25
|
main{padding:var(--s4) var(--s4) var(--s5);display:grid;gap:var(--s4);max-width:1600px}
|
|
26
|
+
.inbox{list-style:none;margin:0;padding:0}
|
|
27
|
+
.inbox li{padding:var(--s3) 0;border-top:1px solid var(--line)}.inbox li:first-child{border-top:0;padding-top:var(--s1)}
|
|
28
|
+
.inbox .title{font-size:14px;font-weight:500;overflow-wrap:anywhere}.inbox .title .faint{font-weight:400}
|
|
29
|
+
.inbox .why{display:inline-block;padding:0 7px;border-radius:9px;font-size:12px;font-weight:600;color:var(--warn);background:color-mix(in srgb,var(--warn) 14%,transparent)}
|
|
30
|
+
.inbox .meta{margin-top:var(--s1);align-items:center}
|
|
31
|
+
.calm{padding:var(--s5) 0;text-align:center}.calm p{margin:0}.calm p+p{margin-top:var(--s1)}.calm b{font-size:14px;font-weight:600}
|
|
32
|
+
.lane-label{font-weight:400;text-transform:none;letter-spacing:0;color:var(--faint);margin-left:6px}
|
|
33
|
+
.linkish{appearance:none;background:none;border:0;padding:0;font:inherit;color:var(--accent);cursor:pointer}.linkish:hover{text-decoration:underline}
|
|
34
|
+
.linkish:focus-visible{outline:2px solid var(--accent);outline-offset:2px;border-radius:2px}
|
|
19
35
|
section{background:var(--panel);border:1px solid var(--line);border-radius:6px;padding:var(--s3) var(--s4);min-width:0}
|
|
20
36
|
section.attn{border-color:color-mix(in srgb,var(--warn) 45%,var(--line))}section.attn>h2 .n{color:var(--warn)}
|
|
21
37
|
h2{font-size:11px;text-transform:uppercase;letter-spacing:.06em;color:var(--muted);margin:0 0 var(--s2);font-weight:600}
|
|
@@ -26,7 +42,6 @@ h2 .n{color:var(--faint);margin-left:4px}
|
|
|
26
42
|
.pill.err{background:color-mix(in srgb,var(--err) 16%,transparent)}.pill .faint{color:var(--muted)}
|
|
27
43
|
.banner{padding:var(--s2) var(--s3);border-radius:6px;border:1px solid var(--line);background:var(--panel)}
|
|
28
44
|
.banner.err{border-color:color-mix(in srgb,var(--err) 45%,var(--line))}.banner.warn{border-color:color-mix(in srgb,var(--warn) 45%,var(--line))}
|
|
29
|
-
.top{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,360px),1fr));gap:var(--s4)}
|
|
30
45
|
.detail{display:grid;grid-template-columns:minmax(0,3fr) minmax(0,2fr);gap:var(--s4);align-items:start}
|
|
31
46
|
.stats{display:flex;flex-wrap:wrap;gap:var(--s1) var(--s4);margin-top:var(--s3);padding-top:var(--s3);border-top:1px solid var(--line)}.stat b{font-size:16px;font-weight:600;margin-right:var(--s1)}
|
|
32
47
|
.steps{display:flex;flex-wrap:wrap;gap:var(--s1)}.steps+.err{margin-top:var(--s1)}
|
|
@@ -35,6 +50,7 @@ h2 .n{color:var(--faint);margin-left:4px}
|
|
|
35
50
|
.col{min-width:0}.col ul{list-style:none;margin:0;padding:0}
|
|
36
51
|
.col li{padding:6px 0;border-top:1px solid var(--line)}.col li:first-child{border-top:0}
|
|
37
52
|
.t{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
53
|
+
.col .t{white-space:normal;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow-wrap:anywhere}
|
|
38
54
|
.meta{font-size:12px;color:var(--muted);display:flex;flex-wrap:wrap;gap:2px 8px}
|
|
39
55
|
.empty{color:var(--faint);font-size:12px}
|
|
40
56
|
table{border-collapse:collapse;width:100%}th{text-align:left;font-weight:500;color:var(--muted);font-size:12px}
|
|
@@ -50,7 +66,8 @@ body.down #top,body.down main>:not(#down){opacity:.5;transition:opacity .3s ease
|
|
|
50
66
|
@media (max-width:1100px){.cols{grid-template-columns:repeat(4,minmax(0,1fr))}.detail{grid-template-columns:1fr}
|
|
51
67
|
.col.prs{grid-column:1/-1;border-left:0;padding-left:0;border-top:1px solid var(--line);padding-top:var(--s3)}}
|
|
52
68
|
@media (max-width:760px){.cols{grid-template-columns:repeat(2,minmax(0,1fr))}}
|
|
53
|
-
@media (max-width:480px){main{padding:var(--s3) var(--s3) var(--s5);gap:var(--s3)}section{padding:var(--s3)}.cols{grid-template-columns:1fr}
|
|
69
|
+
@media (max-width:480px){main{padding:var(--s3) var(--s3) var(--s5);gap:var(--s3)}section{padding:var(--s3)}.cols{grid-template-columns:1fr}
|
|
70
|
+
.tabs{padding:0 var(--s3);gap:var(--s4)}}
|
|
54
71
|
`
|
|
55
72
|
|
|
56
73
|
const JS = `
|
|
@@ -144,17 +161,39 @@ function pr(p, multi, now) {
|
|
|
144
161
|
const isMulti = (gh) => new Set(gh.repos.map((r) => r.slug)).size > 1
|
|
145
162
|
const list = (xs, render, multi, now) => xs.length ? h('ul', {}, xs.map((x) => render(x, multi, now))) : h('div', { class: 'empty' }, 'empty')
|
|
146
163
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
164
|
+
const LANES = [['intake', 'Intake', 'q:intake'], ['task', 'Task', 'q:task'], ['running', 'Running', 'running'], ['promote', 'Promote', 'q:promote']]
|
|
165
|
+
const inFlight = (gh) => LANES.reduce((n, [k]) => n + gh.columns[k].length, 0)
|
|
166
|
+
|
|
167
|
+
function inbox(s, now) {
|
|
168
|
+
const gh = s.github, xs = gh.columns.human, multi = isMulti(gh)
|
|
169
|
+
if (!xs.length) return h('section', { class: 'calm' },
|
|
170
|
+
h('p', {}, h('b', {}, 'Nothing needs you.')),
|
|
171
|
+
h('p', { class: 'muted' }, inFlight(gh) + ' in the queue · ' + gh.prs.length + ' agent PR' + (gh.prs.length === 1 ? '' : 's') + ' · ',
|
|
172
|
+
h('button', { class: 'linkish', type: 'button', 'data-go': 'queue' }, 'see the queue')))
|
|
173
|
+
return h('section', { class: 'attn' }, h('h2', {}, 'Needs you', h('span', { class: 'n' }, xs.length), h('span', { class: 'lane-label mono' }, 'q:human')),
|
|
174
|
+
h('ul', { class: 'inbox' }, xs.map((i) => h('li', {},
|
|
175
|
+
link(i.url, h('span', { class: 'title', title: i.title }, h('span', { class: 'faint' }, '#' + i.number + ' '), i.title)),
|
|
176
|
+
h('div', { class: 'meta' },
|
|
177
|
+
i.why ? h('span', { class: 'why' }, 'why:' + i.why) : h('span', { class: 'faint' }, 'no why:* reason'),
|
|
178
|
+
i.priority ? h('span', {}, 'priority:' + i.priority) : null,
|
|
179
|
+
multi ? h('span', {}, i.repo) : null,
|
|
180
|
+
h('span', { class: 'faint', title: i.updatedAt || i.createdAt || '' }, ago(i.updatedAt || i.createdAt, now)))))))
|
|
150
181
|
}
|
|
151
182
|
|
|
152
183
|
function queues(s, now) {
|
|
153
184
|
const gh = s.github, multi = isMulti(gh)
|
|
154
|
-
const col = (title, xs, render, cls) => h('div', { class: 'col' + (cls ? ' ' + cls : '') },
|
|
185
|
+
const col = (title, label, xs, render, cls) => h('div', { class: 'col' + (cls ? ' ' + cls : '') },
|
|
186
|
+
h('h2', {}, title, h('span', { class: 'n' }, xs.length), label ? h('span', { class: 'lane-label mono' }, label) : null), list(xs, render, multi, now))
|
|
155
187
|
return h('section', {}, h('div', { class: 'cols' },
|
|
156
|
-
|
|
157
|
-
|
|
188
|
+
LANES.map(([k, title, label]) => col(title, label, gh.columns[k], item)), col('Agent PRs', 'agent/*', gh.prs, pr, 'prs')))
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function loopTrouble(s) {
|
|
192
|
+
const hb = s.heartbeat, d = hb.data
|
|
193
|
+
if (hb.status !== 'ok' || !d) return 'err'
|
|
194
|
+
if (d.steps.some((st) => !st.ok) || d.workers.some((w) => w.killedReason)) return 'err'
|
|
195
|
+
if (hb.stale || d.mode !== 'running') return 'warn'
|
|
196
|
+
return null
|
|
158
197
|
}
|
|
159
198
|
|
|
160
199
|
function workers(d, ageMs) {
|
|
@@ -188,16 +227,60 @@ function events(d) {
|
|
|
188
227
|
})) : h('div', { class: 'empty' }, 'no events'))
|
|
189
228
|
}
|
|
190
229
|
|
|
230
|
+
const TABS = ['inbox', 'queue', 'loop']
|
|
231
|
+
const tabFromHash = () => (TABS.includes(location.hash.slice(1)) ? location.hash.slice(1) : 'inbox')
|
|
232
|
+
let tab = tabFromHash(), last = null
|
|
233
|
+
|
|
234
|
+
function tabs(s) {
|
|
235
|
+
const human = s.github.columns.human.length, trouble = loopTrouble(s)
|
|
236
|
+
$('n-inbox').textContent = human
|
|
237
|
+
$('n-inbox').className = 'count' + (human ? ' attn' : '')
|
|
238
|
+
$('n-queue').textContent = inFlight(s.github)
|
|
239
|
+
$('d-loop').className = 'dot ' + (trouble || 'ok')
|
|
240
|
+
$('d-loop').title = trouble === 'err' ? 'something failed' : trouble === 'warn' ? 'stale or not running' : 'healthy'
|
|
241
|
+
for (const t of TABS) {
|
|
242
|
+
const b = $('tab-' + t), on = t === tab
|
|
243
|
+
b.setAttribute('aria-selected', on)
|
|
244
|
+
b.tabIndex = on ? 0 : -1
|
|
245
|
+
}
|
|
246
|
+
$('main').setAttribute('aria-labelledby', 'tab-' + tab)
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function go(t, focus) {
|
|
250
|
+
if (!TABS.includes(t)) return
|
|
251
|
+
tab = t
|
|
252
|
+
history.replaceState(null, '', '#' + t)
|
|
253
|
+
window.scrollTo(0, 0)
|
|
254
|
+
if (last) render(last)
|
|
255
|
+
if (focus) $('tab-' + t).focus()
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
$('tabs').addEventListener('click', (e) => { const b = e.target.closest('[data-tab]'); if (b) go(b.dataset.tab) })
|
|
259
|
+
$('tabs').addEventListener('keydown', (e) => {
|
|
260
|
+
const step = { ArrowRight: 1, ArrowLeft: -1 }[e.key]
|
|
261
|
+
if (e.key === 'Home' || e.key === 'End') { e.preventDefault(); return go(e.key === 'Home' ? TABS[0] : TABS[TABS.length - 1], true) }
|
|
262
|
+
if (!step) return
|
|
263
|
+
e.preventDefault()
|
|
264
|
+
go(TABS[(TABS.indexOf(tab) + step + TABS.length) % TABS.length], true)
|
|
265
|
+
})
|
|
266
|
+
$('main').addEventListener('click', (e) => { const b = e.target.closest('[data-go]'); if (b) go(b.dataset.go, true) })
|
|
267
|
+
addEventListener('hashchange', () => { tab = tabFromHash(); if (last) render(last) })
|
|
268
|
+
|
|
191
269
|
function render(s) {
|
|
270
|
+
last = s
|
|
192
271
|
const now = Date.parse(s.now) || Date.now()
|
|
193
272
|
const d = s.heartbeat.data
|
|
194
273
|
const body = [...banners(s)]
|
|
195
|
-
|
|
196
|
-
body.push(queues(s, now))
|
|
197
|
-
if (
|
|
274
|
+
if (tab === 'inbox') body.push(inbox(s, now))
|
|
275
|
+
if (tab === 'queue') body.push(queues(s, now))
|
|
276
|
+
if (tab === 'loop') {
|
|
277
|
+
if (d) body.push(summary(d), h('div', { class: 'detail' }, workers(d, s.heartbeat.ageMs), events(d)))
|
|
278
|
+
else body.push(section('Loop', null, h('div', { class: 'empty' }, 'no heartbeat to show: ' + s.heartbeat.status)))
|
|
279
|
+
}
|
|
280
|
+
tabs(s)
|
|
198
281
|
const focused = document.activeElement, href = focused && focused.getAttribute && focused.getAttribute('href')
|
|
199
282
|
const scrolled = [...document.querySelectorAll('.events,.scroll')].map((el) => [el.className, el.scrollTop, el.scrollLeft])
|
|
200
|
-
$('
|
|
283
|
+
$('head').replaceChildren(header(s, now))
|
|
201
284
|
$('main').replaceChildren(...body)
|
|
202
285
|
document.body.classList.remove('down')
|
|
203
286
|
for (const [cls, top, left] of scrolled) {
|
|
@@ -206,7 +289,8 @@ function render(s) {
|
|
|
206
289
|
}
|
|
207
290
|
if (href) [...document.querySelectorAll('a')].find((a) => a.getAttribute('href') === href)?.focus({ preventScroll: true })
|
|
208
291
|
else if (focused && focused.classList && (focused.classList.contains('events') || focused.classList.contains('scroll'))) document.getElementsByClassName(focused.className)[0]?.focus({ preventScroll: true })
|
|
209
|
-
|
|
292
|
+
const human = s.github.columns.human.length
|
|
293
|
+
document.title = (human ? '(' + human + ') ' : '') + 'canopy' + (d ? ' · ' + d.mode : '') + (s.heartbeat.stale ? ' · stale' : '')
|
|
210
294
|
}
|
|
211
295
|
|
|
212
296
|
let pollMs = 5000
|
|
@@ -238,8 +322,13 @@ export const PAGE = `<!doctype html>
|
|
|
238
322
|
<style>${CSS}</style>
|
|
239
323
|
</head>
|
|
240
324
|
<body>
|
|
241
|
-
<div id="top"><header><h1>canopy</h1><span class="faint">loading…</span></header></div>
|
|
242
|
-
<
|
|
325
|
+
<div id="top"><div id="head"><header><h1>canopy</h1><span class="faint">loading…</span></header></div>
|
|
326
|
+
<nav class="tabs" id="tabs" role="tablist" aria-label="Views">
|
|
327
|
+
<button class="tab" role="tab" type="button" id="tab-inbox" data-tab="inbox" aria-controls="main">Inbox <span class="count" id="n-inbox">–</span></button>
|
|
328
|
+
<button class="tab" role="tab" type="button" id="tab-queue" data-tab="queue" aria-controls="main" tabindex="-1">Queue <span class="count" id="n-queue">–</span></button>
|
|
329
|
+
<button class="tab" role="tab" type="button" id="tab-loop" data-tab="loop" aria-controls="main" tabindex="-1">Loop <span class="dot" id="d-loop"></span></button>
|
|
330
|
+
</nav></div>
|
|
331
|
+
<main id="main" role="tabpanel" aria-labelledby="tab-inbox"></main>
|
|
243
332
|
<script>${JS}</script>
|
|
244
333
|
</body>
|
|
245
334
|
</html>
|