@oakgreencc/canopy 0.0.8 → 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 +130 -25
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
|
@@ -1,19 +1,37 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
|
|
3
3
|
const CSS = `
|
|
4
|
-
:root{color-scheme:light dark;--bg:#f7f7f5;--panel:#fff;--line:#e4e4e0;--text:#1d1d1b;--muted:#
|
|
4
|
+
:root{color-scheme:light dark;--bg:#f7f7f5;--panel:#fff;--line:#e4e4e0;--text:#1d1d1b;--muted:#5f5f5a;--faint:#72726c;
|
|
5
5
|
--ok:#2f7d4f;--warn:#a5670a;--err:#b42f2f;--accent:#2f5f9e;--chip:#efefeb;--bar:#dcdcd6;
|
|
6
6
|
--s1:4px;--s2:8px;--s3:12px;--s4:16px;--s5:24px}
|
|
7
|
-
@media (prefers-color-scheme:dark){:root{--bg:#141413;--panel:#1c1c1a;--line:#2e2e2b;--text:#e6e6e1;--muted:#
|
|
7
|
+
@media (prefers-color-scheme:dark){:root{--bg:#141413;--panel:#1c1c1a;--line:#2e2e2b;--text:#e6e6e1;--muted:#b0b0aa;--faint:#8a8a84;
|
|
8
8
|
--ok:#6cc08b;--warn:#e0a44a;--err:#ec7b7b;--accent:#86aee6;--chip:#262624;--bar:#353532}}
|
|
9
9
|
*{box-sizing:border-box}
|
|
10
10
|
body{margin:0;background:var(--bg);color:var(--text);font:13px/1.45 system-ui,-apple-system,"Segoe UI",sans-serif;font-variant-numeric:tabular-nums}
|
|
11
|
-
|
|
11
|
+
::selection{background:color-mix(in srgb,var(--accent) 28%,transparent)}
|
|
12
|
+
a{color:var(--accent);text-decoration:none;text-underline-offset:2px}a:hover{text-decoration:underline}
|
|
12
13
|
a:focus-visible{outline:2px solid var(--accent);outline-offset:2px;border-radius:2px}
|
|
13
14
|
code,.mono{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:12px}
|
|
14
|
-
|
|
15
|
+
#top{position:sticky;top:0;z-index:1}
|
|
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)}
|
|
15
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}
|
|
16
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}
|
|
17
35
|
section{background:var(--panel);border:1px solid var(--line);border-radius:6px;padding:var(--s3) var(--s4);min-width:0}
|
|
18
36
|
section.attn{border-color:color-mix(in srgb,var(--warn) 45%,var(--line))}section.attn>h2 .n{color:var(--warn)}
|
|
19
37
|
h2{font-size:11px;text-transform:uppercase;letter-spacing:.06em;color:var(--muted);margin:0 0 var(--s2);font-weight:600}
|
|
@@ -21,10 +39,9 @@ h2 .n{color:var(--faint);margin-left:4px}
|
|
|
21
39
|
.muted{color:var(--muted)}.faint{color:var(--faint)}.ok{color:var(--ok)}.warn{color:var(--warn)}.err{color:var(--err)}
|
|
22
40
|
.pill{display:inline-block;padding:0 7px;border-radius:9px;background:var(--chip);font-size:12px}
|
|
23
41
|
.pill.ok{background:color-mix(in srgb,var(--ok) 16%,transparent)}.pill.warn{background:color-mix(in srgb,var(--warn) 18%,transparent)}
|
|
24
|
-
.pill.err{background:color-mix(in srgb,var(--err) 16%,transparent)}
|
|
42
|
+
.pill.err{background:color-mix(in srgb,var(--err) 16%,transparent)}.pill .faint{color:var(--muted)}
|
|
25
43
|
.banner{padding:var(--s2) var(--s3);border-radius:6px;border:1px solid var(--line);background:var(--panel)}
|
|
26
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))}
|
|
27
|
-
.top{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,360px),1fr));gap:var(--s4)}
|
|
28
45
|
.detail{display:grid;grid-template-columns:minmax(0,3fr) minmax(0,2fr);gap:var(--s4);align-items:start}
|
|
29
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)}
|
|
30
47
|
.steps{display:flex;flex-wrap:wrap;gap:var(--s1)}.steps+.err{margin-top:var(--s1)}
|
|
@@ -33,19 +50,24 @@ h2 .n{color:var(--faint);margin-left:4px}
|
|
|
33
50
|
.col{min-width:0}.col ul{list-style:none;margin:0;padding:0}
|
|
34
51
|
.col li{padding:6px 0;border-top:1px solid var(--line)}.col li:first-child{border-top:0}
|
|
35
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}
|
|
36
54
|
.meta{font-size:12px;color:var(--muted);display:flex;flex-wrap:wrap;gap:2px 8px}
|
|
37
55
|
.empty{color:var(--faint);font-size:12px}
|
|
38
56
|
table{border-collapse:collapse;width:100%}th{text-align:left;font-weight:500;color:var(--muted);font-size:12px}
|
|
39
57
|
td,th{padding:4px 10px 4px 0;border-top:1px solid var(--line);vertical-align:top;white-space:nowrap}tr.logs td{border-top:0;padding-top:0;white-space:normal;overflow-wrap:anywhere}.scroll{overflow-x:auto}thead th{border-top:0}
|
|
40
58
|
.bar{display:inline-block;width:80px;height:6px;background:var(--bar);border-radius:3px;vertical-align:middle;overflow:hidden;margin-right:6px}
|
|
41
59
|
.bar i{display:block;height:100%;background:var(--ok)}.bar i.warn{background:var(--warn)}.bar i.err{background:var(--err)}
|
|
60
|
+
.events,.scroll{scrollbar-width:thin;scrollbar-color:var(--bar) transparent}
|
|
61
|
+
.events:focus-visible,.scroll:focus-visible{outline:2px solid var(--accent);outline-offset:2px;border-radius:2px}
|
|
62
|
+
body.down #top,body.down main>:not(#down){opacity:.5;transition:opacity .3s ease-out}
|
|
42
63
|
.events{max-height:320px;overflow:auto}.events div{display:grid;grid-template-columns:62px 40px minmax(0,1fr);gap:8px;padding:2px 0}
|
|
43
64
|
.dot{display:inline-block;width:8px;height:8px;border-radius:50%;background:var(--faint);margin-right:5px}
|
|
44
65
|
.dot.ok{background:var(--ok)}.dot.warn{background:var(--warn)}.dot.err{background:var(--err)}
|
|
45
66
|
@media (max-width:1100px){.cols{grid-template-columns:repeat(4,minmax(0,1fr))}.detail{grid-template-columns:1fr}
|
|
46
67
|
.col.prs{grid-column:1/-1;border-left:0;padding-left:0;border-top:1px solid var(--line);padding-top:var(--s3)}}
|
|
47
68
|
@media (max-width:760px){.cols{grid-template-columns:repeat(2,minmax(0,1fr))}}
|
|
48
|
-
@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)}}
|
|
49
71
|
`
|
|
50
72
|
|
|
51
73
|
const JS = `
|
|
@@ -80,9 +102,9 @@ function header(s, now) {
|
|
|
80
102
|
kids.push(h('span', { class: 'muted' }, d.host || '?', d.pid ? ' · pid ' + d.pid : ''))
|
|
81
103
|
kids.push(h('span', { class: hb.stale ? 'warn' : 'muted' }, 'tick ', d.tick.n ?? '–', ' · ', ago(d.tick.finishedAt, now), d.tick.durationMs != null ? ' · took ' + dur(d.tick.durationMs) : ''))
|
|
82
104
|
if (d.tick.nextAt && !hb.stale) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
105
|
+
const left = Date.parse(d.tick.nextAt) - now
|
|
106
|
+
kids.push(h('span', { class: 'faint' }, left > 0 ? 'next in ' + dur(left) : 'next tick due'))
|
|
107
|
+
}
|
|
86
108
|
}
|
|
87
109
|
const gh = s.github
|
|
88
110
|
kids.push(h('span', { class: 'faint', style: 'margin-left:auto' }, 'GitHub ', gh.fetchedAt ? ago(gh.fetchedAt, now) : '–', s.cacheMs ? ' (cached ' + dur(s.cacheMs) + ')' : ''))
|
|
@@ -139,17 +161,39 @@ function pr(p, multi, now) {
|
|
|
139
161
|
const isMulti = (gh) => new Set(gh.repos.map((r) => r.slug)).size > 1
|
|
140
162
|
const list = (xs, render, multi, now) => xs.length ? h('ul', {}, xs.map((x) => render(x, multi, now))) : h('div', { class: 'empty' }, 'empty')
|
|
141
163
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
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)))))))
|
|
145
181
|
}
|
|
146
182
|
|
|
147
183
|
function queues(s, now) {
|
|
148
184
|
const gh = s.github, multi = isMulti(gh)
|
|
149
|
-
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))
|
|
150
187
|
return h('section', {}, h('div', { class: 'cols' },
|
|
151
|
-
|
|
152
|
-
|
|
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
|
|
153
197
|
}
|
|
154
198
|
|
|
155
199
|
function workers(d, ageMs) {
|
|
@@ -168,14 +212,14 @@ function workers(d, ageMs) {
|
|
|
168
212
|
h('td', { class: 'mono' }, w.branch || '–')),
|
|
169
213
|
logs.length ? h('tr', { class: 'logs' }, h('td', { colspan: 6, class: 'mono faint' }, logs.map((l) => h('div', {}, l)))) : null]
|
|
170
214
|
})
|
|
171
|
-
return section('Workers', d.workers.length, h('div', { class: 'scroll' }, h('table', {},
|
|
215
|
+
return section('Workers', d.workers.length, h('div', { class: 'scroll', tabindex: 0, 'aria-label': 'Workers table' }, h('table', {},
|
|
172
216
|
h('thead', {}, h('tr', {}, ['issue', 'phase', 'attempt', 'pid', 'elapsed / cap', 'branch'].map((t) => h('th', {}, t)))),
|
|
173
217
|
h('tbody', {}, rows))))
|
|
174
218
|
}
|
|
175
219
|
|
|
176
220
|
function events(d) {
|
|
177
221
|
const list = d.events.slice(-60).reverse()
|
|
178
|
-
return section('Recent events', d.events.length, list.length ? h('div', { class: 'events mono' }, list.map((e) => {
|
|
222
|
+
return section('Recent events', d.events.length, list.length ? h('div', { class: 'events mono', tabindex: 0, 'aria-label': 'Recent events' }, list.map((e) => {
|
|
179
223
|
const t = e.at ? new Date(e.at) : null
|
|
180
224
|
return h('div', {}, h('span', { class: 'faint', title: e.at || '' }, t ? t.toLocaleTimeString([], { hour12: false }) : '–'),
|
|
181
225
|
h('span', { class: e.level === 'error' ? 'err' : e.level === 'warn' ? 'warn' : 'faint' }, e.level || ''),
|
|
@@ -183,16 +227,70 @@ function events(d) {
|
|
|
183
227
|
})) : h('div', { class: 'empty' }, 'no events'))
|
|
184
228
|
}
|
|
185
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
|
+
|
|
186
269
|
function render(s) {
|
|
270
|
+
last = s
|
|
187
271
|
const now = Date.parse(s.now) || Date.now()
|
|
188
272
|
const d = s.heartbeat.data
|
|
189
273
|
const body = [...banners(s)]
|
|
190
|
-
|
|
191
|
-
body.push(queues(s, now))
|
|
192
|
-
if (
|
|
193
|
-
|
|
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)
|
|
281
|
+
const focused = document.activeElement, href = focused && focused.getAttribute && focused.getAttribute('href')
|
|
282
|
+
const scrolled = [...document.querySelectorAll('.events,.scroll')].map((el) => [el.className, el.scrollTop, el.scrollLeft])
|
|
283
|
+
$('head').replaceChildren(header(s, now))
|
|
194
284
|
$('main').replaceChildren(...body)
|
|
195
|
-
document.
|
|
285
|
+
document.body.classList.remove('down')
|
|
286
|
+
for (const [cls, top, left] of scrolled) {
|
|
287
|
+
const el = document.getElementsByClassName(cls)[0]
|
|
288
|
+
if (el) Object.assign(el, { scrollTop: top, scrollLeft: left })
|
|
289
|
+
}
|
|
290
|
+
if (href) [...document.querySelectorAll('a')].find((a) => a.getAttribute('href') === href)?.focus({ preventScroll: true })
|
|
291
|
+
else if (focused && focused.classList && (focused.classList.contains('events') || focused.classList.contains('scroll'))) document.getElementsByClassName(focused.className)[0]?.focus({ preventScroll: true })
|
|
292
|
+
const human = s.github.columns.human.length
|
|
293
|
+
document.title = (human ? '(' + human + ') ' : '') + 'canopy' + (d ? ' · ' + d.mode : '') + (s.heartbeat.stale ? ' · stale' : '')
|
|
196
294
|
}
|
|
197
295
|
|
|
198
296
|
let pollMs = 5000
|
|
@@ -205,6 +303,8 @@ async function poll() {
|
|
|
205
303
|
render(s)
|
|
206
304
|
} catch (err) {
|
|
207
305
|
$('down')?.remove()
|
|
306
|
+
document.body.classList.add('down')
|
|
307
|
+
document.title = 'canopy · unreachable'
|
|
208
308
|
$('main').prepend(h('div', { id: 'down', class: 'banner err' },'canopy server unreachable: ' + (err && err.message)))
|
|
209
309
|
}
|
|
210
310
|
setTimeout(poll, pollMs)
|
|
@@ -222,8 +322,13 @@ export const PAGE = `<!doctype html>
|
|
|
222
322
|
<style>${CSS}</style>
|
|
223
323
|
</head>
|
|
224
324
|
<body>
|
|
225
|
-
<div id="top"><header><h1>canopy</h1><span class="faint">loading…</span></header></div>
|
|
226
|
-
<
|
|
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>
|
|
227
332
|
<script>${JS}</script>
|
|
228
333
|
</body>
|
|
229
334
|
</html>
|