@nanocollective/roster 0.1.0-beta.16 → 0.1.0-beta.19
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/dist/{agents-NMGVORU3.js → agents-Q2DSTLOQ.js} +1 -1
- package/dist/{chunk-E3EVPK4I.js → chunk-JH3LQ34C.js} +16 -1
- package/dist/{chunk-QCKEGMXD.js → chunk-UEZPQ5PV.js} +2 -2
- package/dist/cli.js +210 -16
- package/dist/{compose-56JIIIHA.js → compose-H43W3QI5.js} +3 -1
- package/dist/{connectors-ZVEPXSAR.js → connectors-U5VT5W2I.js} +1 -1
- package/dist/worker/assets/assets/css/base.css +4 -0
- package/dist/worker/assets/assets/css/brain.css +20 -0
- package/dist/worker/assets/assets/css/home.css +102 -34
- package/dist/worker/assets/assets/css/inbox.css +11 -0
- package/dist/worker/assets/assets/js/app.js +1 -0
- package/dist/worker/assets/assets/js/homesort.js +24 -0
- package/dist/worker/assets/assets/js/md.js +7 -2
- package/dist/worker/assets/assets/js/refresh.js +4 -2
- package/dist/worker/assets/assets/js/report.js +51 -0
- package/dist/worker/assets/assets/js/state.js +2 -0
- package/dist/worker/assets/assets/js/views/home.js +274 -119
- package/dist/worker/assets/assets/js/views/inbox.js +52 -11
- package/dist/worker/assets/assets/js/views/org.js +2 -0
- package/dist/worker/assets/assets/js/views/people.js +103 -0
- package/dist/worker/index.js +201 -15
- package/docs/doctor-codes.md +2 -0
- package/docs/export.md +2 -1
- package/docs/org-yaml.md +25 -4
- package/package.json +1 -1
- package/templates/brain/.github/workflows/%%STAFF%%-mention.yaml +4 -4
- package/templates/ops/compose.mjs +20 -0
- package/templates/ops/org/operating.md +10 -0
- package/templates/ops/org/voice.md +19 -1
- package/templates/ops/prompts/daily.md +27 -6
- package/templates/ops/prompts/mention.md +3 -2
- package/templates/portal/css/base.css +4 -0
- package/templates/portal/css/brain.css +20 -0
- package/templates/portal/css/home.css +102 -34
- package/templates/portal/css/inbox.css +11 -0
- package/templates/portal/js/app.js +1 -0
- package/templates/portal/js/homesort.js +24 -0
- package/templates/portal/js/md.js +7 -2
- package/templates/portal/js/refresh.js +4 -2
- package/templates/portal/js/report.js +51 -0
- package/templates/portal/js/state.js +2 -0
- package/templates/portal/js/views/home.js +274 -119
- package/templates/portal/js/views/inbox.js +52 -11
- package/templates/portal/js/views/org.js +2 -0
- package/templates/portal/js/views/people.js +103 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
/* Home: what needs you,
|
|
1
|
+
/* Home: who is working, what needs you, how each staff member is getting on, what you asked
|
|
2
|
+
* for, and what was closed today.
|
|
2
3
|
*
|
|
3
4
|
* Built from the inbox list and /api/live, sorted by homesort.js, which is where the rule that
|
|
4
5
|
* every open item has exactly one place lives. Clicking an item opens its thread in a side
|
|
@@ -7,8 +8,9 @@
|
|
|
7
8
|
import { getLive, post } from "../api.js";
|
|
8
9
|
import { sheet } from "../dialog.js";
|
|
9
10
|
import { ago, el, skeleton } from "../dom.js";
|
|
10
|
-
import { daysUntil, sortHome } from "../homesort.js";
|
|
11
|
+
import { daysUntil, isFor, sortHome } from "../homesort.js";
|
|
11
12
|
import { mdlite } from "../md.js";
|
|
13
|
+
import { parseReport } from "../report.js";
|
|
12
14
|
import { icon, iconHTML, staffIcon } from "../icons.js";
|
|
13
15
|
import { ensureInbox, stampCounts } from "../refresh.js";
|
|
14
16
|
import { go, render } from "../router.js";
|
|
@@ -53,29 +55,37 @@ export function viewHome(m) {
|
|
|
53
55
|
stampCounts();
|
|
54
56
|
|
|
55
57
|
const page = el("div", { className: "home" });
|
|
58
|
+
page.append(team(staff));
|
|
56
59
|
page.append(askBox(staff));
|
|
57
60
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
/* With more than one person, each sees what is on them, plus anything on nobody in
|
|
62
|
+
particular. Everyone's is one click away, so nothing is hidden for good. */
|
|
63
|
+
const me = meHuman();
|
|
64
|
+
const split = Boolean(me) && humansOf().length > 1;
|
|
65
|
+
const mine = split ? h.needs.filter((e) => isFor(e, me.github)) : h.needs;
|
|
66
|
+
const shown = split && needsScope === "all" ? h.needs : mine;
|
|
67
|
+
const needsHead = section("Needs you", shown.length);
|
|
68
|
+
if (split && mine.length !== h.needs.length) needsHead.append(scopeToggle(mine.length, h.needs.length));
|
|
69
|
+
page.append(needsHead);
|
|
65
70
|
/* One list rather than a card each: five boxes with a green button apiece read as a wall, and
|
|
66
71
|
nothing in it said which to do first. The top row's action is the one in green. */
|
|
67
|
-
if (
|
|
68
|
-
page.append(
|
|
72
|
+
if (shown.length) {
|
|
73
|
+
page.append(
|
|
74
|
+
el("div", { className: "card homelist" }, shown.map((e, i) => needRow(e, i === 0, split ? me : null))),
|
|
75
|
+
);
|
|
69
76
|
} else page.append(el("p", { className: "homeempty", textContent: "Nothing needs you." }));
|
|
70
77
|
|
|
78
|
+
const reporters = staff.filter((x) => x.brain && x.statusIssue);
|
|
79
|
+
if (reporters.length) {
|
|
80
|
+
page.append(section("Progress"));
|
|
81
|
+
page.append(el("div", { className: "homereports" }, reporters.map((s) => reportRow(s, h.reports))));
|
|
82
|
+
}
|
|
83
|
+
|
|
71
84
|
if (h.unread.length) {
|
|
72
85
|
page.append(section("Unread", h.unread.length));
|
|
73
86
|
page.append(listBox(h.unread.map(unreadRow)));
|
|
74
87
|
}
|
|
75
88
|
|
|
76
|
-
page.append(section("Working now"));
|
|
77
|
-
page.append(working(staff));
|
|
78
|
-
|
|
79
89
|
if (h.requests.length) {
|
|
80
90
|
page.append(section("Your requests", h.requests.length));
|
|
81
91
|
page.append(listBox(h.requests.map(requestRow)));
|
|
@@ -96,16 +106,18 @@ export function viewHome(m) {
|
|
|
96
106
|
/** Whose reports are open in full. Kept here, since Home repaints on every poll. */
|
|
97
107
|
const openReports = new Set();
|
|
98
108
|
|
|
109
|
+
const STATUS_TONE = { "on track": "ok", "needs you": "warm", stuck: "hot", blocked: "hot" };
|
|
110
|
+
|
|
99
111
|
/**
|
|
100
|
-
* One staff member's report: the body of their status issue, which every run rewrites,
|
|
101
|
-
*
|
|
102
|
-
*
|
|
112
|
+
* One staff member's report: the body of their status issue, which every run rewrites, as a
|
|
113
|
+
* card. Its status and one line on how it is going, what got done and what is next, with the
|
|
114
|
+
* rest a click away. There is a button to ask for a fresh one.
|
|
103
115
|
*/
|
|
104
116
|
function reportRow(s, reports) {
|
|
105
117
|
const r = reports.find((x) => x.staff.handle === s.handle);
|
|
106
118
|
const item = r?.item ?? { repo: s.brain, number: s.statusIssue, kind: "issue" };
|
|
107
119
|
const note = el("span", { className: "meta" });
|
|
108
|
-
const ask = el("button", { className: "ghbtn", textContent: "Ask for
|
|
120
|
+
const ask = el("button", { className: "ghbtn", textContent: "Ask for an update" });
|
|
109
121
|
ask.onclick = async () => {
|
|
110
122
|
ask.disabled = true;
|
|
111
123
|
note.className = "meta";
|
|
@@ -127,68 +139,127 @@ function reportRow(s, reports) {
|
|
|
127
139
|
}
|
|
128
140
|
};
|
|
129
141
|
|
|
142
|
+
const full = openReports.has(s.handle);
|
|
143
|
+
const card = el("div", { className: "card homereport" + (full ? " full" : "") });
|
|
130
144
|
const issue = el("button", { className: "homereportissue", textContent: "#" + item.number });
|
|
131
145
|
issue.onclick = () => openThread(item);
|
|
132
|
-
const
|
|
133
|
-
const
|
|
134
|
-
"
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
? el("div", { className: "md homereportbody", innerHTML: mdlite(r.body, { repo: s.brain }) })
|
|
150
|
-
: el("div"),
|
|
151
|
-
],
|
|
146
|
+
const p = r ? parseReport(r.body) : null;
|
|
147
|
+
const head = el("div", { className: "homereporthead" }, [
|
|
148
|
+
el("span", { className: "homewho2" }, [icon(staffIcon(s), "ic"), el("b", { textContent: s.name })]),
|
|
149
|
+
]);
|
|
150
|
+
if (p?.status) {
|
|
151
|
+
head.append(
|
|
152
|
+
el("span", {
|
|
153
|
+
className: "chip homereportstatus " + (STATUS_TONE[p.status] ?? ""),
|
|
154
|
+
textContent: cap(p.status),
|
|
155
|
+
}),
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
head.append(
|
|
159
|
+
el("span", { className: "meta homereportwhen" }, [
|
|
160
|
+
document.createTextNode((r ? "Updated " + ago(r.at) : "No report yet") + " · "),
|
|
161
|
+
issue,
|
|
162
|
+
]),
|
|
152
163
|
);
|
|
153
|
-
|
|
154
|
-
|
|
164
|
+
card.append(head);
|
|
165
|
+
|
|
166
|
+
if (p) {
|
|
167
|
+
if (p.headline) {
|
|
168
|
+
card.append(el("div", { className: "md homereportline", innerHTML: mdlite(p.headline, { repo: s.brain }) }));
|
|
169
|
+
}
|
|
170
|
+
const cols = [
|
|
171
|
+
["done", "Done"],
|
|
172
|
+
["next", "Next"],
|
|
173
|
+
].filter(([k]) => p.sections[k]?.length);
|
|
174
|
+
if (cols.length && !full) {
|
|
175
|
+
card.append(
|
|
176
|
+
el(
|
|
177
|
+
"div",
|
|
178
|
+
{ className: "homereportcols" },
|
|
179
|
+
cols.map(([k, label]) => bullets(label, p.sections[k], s.brain, 3)),
|
|
180
|
+
),
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
const needs = p.sections.needs?.length ?? 0;
|
|
184
|
+
if (needs && !full) {
|
|
185
|
+
card.append(
|
|
186
|
+
el("p", {
|
|
187
|
+
className: "homereportneeds",
|
|
188
|
+
textContent: `Waiting on a person: ${needs} thing${needs === 1 ? "" : "s"}.`,
|
|
189
|
+
}),
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
// A report in the old shape has no sections to show, so its opening lines stand in.
|
|
193
|
+
const body = el("div", { className: "md homereportbody", innerHTML: mdlite(r.body, { repo: s.brain }) });
|
|
194
|
+
if (full || !cols.length) card.append(body);
|
|
195
|
+
if (!cols.length && !full) body.classList.add("fade");
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
const more = el("button", { className: "ghbtn", textContent: full ? "Show less" : "Read the full report" });
|
|
199
|
+
more.onclick = () => {
|
|
155
200
|
if (openReports.has(s.handle)) openReports.delete(s.handle);
|
|
156
201
|
else openReports.add(s.handle);
|
|
157
|
-
|
|
158
|
-
row.classList.toggle("full", now);
|
|
159
|
-
row.setAttribute("aria-expanded", String(now));
|
|
202
|
+
repaintInPlace();
|
|
160
203
|
};
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
204
|
+
card.append(el("div", { className: "row homereportacts" }, [...(r ? [more] : []), ask, note]));
|
|
205
|
+
return card;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/** A short list under a label, with how many more there are once it runs past `max`. */
|
|
209
|
+
function bullets(label, items, repo, max) {
|
|
210
|
+
const list = el(
|
|
211
|
+
"ul",
|
|
212
|
+
{},
|
|
213
|
+
items.slice(0, max).map((x) => el("li", { className: "md", innerHTML: mdlite(x, { repo }) })),
|
|
214
|
+
);
|
|
215
|
+
const box = el("div", { className: "homereportcol" }, [el("h3", { textContent: label }), list]);
|
|
216
|
+
if (items.length > max) box.append(el("p", { className: "meta", textContent: `and ${items.length - max} more` }));
|
|
217
|
+
return box;
|
|
171
218
|
}
|
|
172
219
|
|
|
173
220
|
/* ------------------------------- asking -------------------------------- */
|
|
174
221
|
|
|
222
|
+
/** What is in the ask box, kept across repaints. */
|
|
223
|
+
const askDraft = { who: "", text: "" };
|
|
224
|
+
|
|
175
225
|
function askBox(staff) {
|
|
176
|
-
const
|
|
177
|
-
|
|
226
|
+
const people = staff.filter((x) => x.brain);
|
|
227
|
+
const who = el("select", { className: "homewho", id: "homewho" });
|
|
228
|
+
for (const s of people) {
|
|
178
229
|
who.append(el("option", { value: s.handle, textContent: s.name }));
|
|
179
230
|
}
|
|
231
|
+
if (askDraft.who && people.some((x) => x.handle === askDraft.who)) who.value = askDraft.who;
|
|
180
232
|
const text = el("textarea", {
|
|
181
233
|
className: "homeask",
|
|
182
|
-
rows:
|
|
183
|
-
|
|
234
|
+
rows: 3,
|
|
235
|
+
ariaLabel: "What you need",
|
|
236
|
+
placeholder: "What do you need? For example: write a post about the new pricing page.",
|
|
237
|
+
value: askDraft.text,
|
|
184
238
|
});
|
|
185
|
-
|
|
239
|
+
// Home repaints as runs start and finish, and what you were typing must survive that.
|
|
240
|
+
text.oninput = () => {
|
|
241
|
+
askDraft.text = text.value;
|
|
242
|
+
};
|
|
243
|
+
const send = el("button", { className: "ghbtn primary" });
|
|
244
|
+
const label = () => {
|
|
245
|
+
const s = people.find((x) => x.handle === who.value);
|
|
246
|
+
send.textContent = s ? `Send to ${s.name}` : "Send";
|
|
247
|
+
};
|
|
248
|
+
label();
|
|
249
|
+
who.onchange = () => {
|
|
250
|
+
askDraft.who = who.value;
|
|
251
|
+
label();
|
|
252
|
+
};
|
|
186
253
|
const note = el("span", { className: "meta" });
|
|
187
254
|
send.onclick = async () => {
|
|
188
255
|
const s = staff.find((x) => x.handle === who.value);
|
|
189
256
|
const said = text.value.trim();
|
|
190
|
-
if (!s || !said)
|
|
257
|
+
if (!s || !said) {
|
|
258
|
+
text.focus();
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
191
261
|
send.disabled = true;
|
|
262
|
+
note.className = "meta";
|
|
192
263
|
note.textContent = "Sending…";
|
|
193
264
|
try {
|
|
194
265
|
await post({
|
|
@@ -198,6 +269,7 @@ function askBox(staff) {
|
|
|
198
269
|
body: `${s.mention ?? "@" + s.handle} ${said}`,
|
|
199
270
|
});
|
|
200
271
|
text.value = "";
|
|
272
|
+
askDraft.text = "";
|
|
201
273
|
note.textContent = `Sent. ${s.name} starts in about a minute.`;
|
|
202
274
|
refreshSoon();
|
|
203
275
|
} catch (e) {
|
|
@@ -208,7 +280,8 @@ function askBox(staff) {
|
|
|
208
280
|
}
|
|
209
281
|
};
|
|
210
282
|
return el("div", { className: "card homeaskcard" }, [
|
|
211
|
-
el("
|
|
283
|
+
el("h2", { className: "homeasktitle", textContent: "Ask a staff member to do something" }),
|
|
284
|
+
el("div", { className: "row homeaskto" }, [el("label", { htmlFor: "homewho", textContent: "To" }), who]),
|
|
212
285
|
text,
|
|
213
286
|
el("div", { className: "row" }, [send, note]),
|
|
214
287
|
]);
|
|
@@ -222,7 +295,53 @@ function titleOf(said) {
|
|
|
222
295
|
|
|
223
296
|
/* ------------------------------ needs you ------------------------------- */
|
|
224
297
|
|
|
225
|
-
|
|
298
|
+
/** "mine" or "all": whose asks Needs you lists, when there is more than one person. */
|
|
299
|
+
let needsScope = readScope();
|
|
300
|
+
|
|
301
|
+
function readScope() {
|
|
302
|
+
try {
|
|
303
|
+
return localStorage.getItem("roster.needsScope") === "all" ? "all" : "mine";
|
|
304
|
+
} catch {
|
|
305
|
+
return "mine";
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/** The signed-in person, when they are one of the org's humans. */
|
|
310
|
+
function meHuman() {
|
|
311
|
+
const login = String(S.me ?? "").toLowerCase();
|
|
312
|
+
return login ? (humansOf().find((h) => String(h.github ?? "").toLowerCase() === login) ?? null) : null;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
function scopeToggle(mine, all) {
|
|
316
|
+
const bar = el("span", { className: "homescope", role: "group", ariaLabel: "Whose to show" });
|
|
317
|
+
for (const [value, label] of [
|
|
318
|
+
["mine", `Yours ${mine}`],
|
|
319
|
+
["all", `Everyone's ${all}`],
|
|
320
|
+
]) {
|
|
321
|
+
const b = el("button", { className: needsScope === value ? "on" : "", textContent: label });
|
|
322
|
+
b.setAttribute("aria-pressed", String(needsScope === value));
|
|
323
|
+
b.onclick = () => {
|
|
324
|
+
needsScope = value;
|
|
325
|
+
try {
|
|
326
|
+
localStorage.setItem("roster.needsScope", value);
|
|
327
|
+
} catch {
|
|
328
|
+
/* a private window: it is only remembered for this visit */
|
|
329
|
+
}
|
|
330
|
+
repaintInPlace();
|
|
331
|
+
};
|
|
332
|
+
bar.append(b);
|
|
333
|
+
}
|
|
334
|
+
return bar;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/** "For Ben", on an ask that is on somebody else. */
|
|
338
|
+
function forWhom(e, me) {
|
|
339
|
+
if (!me || !e.for?.length || e.for.some((g) => g.toLowerCase() === me.github.toLowerCase())) return "";
|
|
340
|
+
const names = e.for.map((g) => humansOf().find((h) => h.github === g)?.name ?? g);
|
|
341
|
+
return "For " + names.join(" and ");
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
function needRow(e, first, me = null) {
|
|
226
345
|
const { item, kind } = e;
|
|
227
346
|
/* The whole row opens the thread; the one quick action on it does not. Answering in words
|
|
228
347
|
happens in the thread, where what was asked is in front of you. */
|
|
@@ -243,8 +362,10 @@ function needRow(e, first) {
|
|
|
243
362
|
|
|
244
363
|
/* What kind of thing it is sits in the line under the title, so every title starts in the
|
|
245
364
|
same place; a chip in front of it pushed each one along by its own width. */
|
|
365
|
+
const other = forWhom(e, me);
|
|
246
366
|
const meta = el("div", { className: "meta" }, [
|
|
247
367
|
el("span", { className: "homekind " + (KIND_TONE[kind] ?? ""), textContent: KIND_LABEL[kind] }),
|
|
368
|
+
...(other ? [document.createTextNode(" · "), el("span", { className: "homefor", textContent: other })] : []),
|
|
248
369
|
document.createTextNode(" · " + whereOf(e) + " · " + ago(item.createdAt)),
|
|
249
370
|
]);
|
|
250
371
|
const about = el("div", { className: "homeabout" }, [openLink(item), meta]);
|
|
@@ -358,76 +479,107 @@ async function act(note, actions, payload, ok) {
|
|
|
358
479
|
}
|
|
359
480
|
}
|
|
360
481
|
|
|
361
|
-
/*
|
|
482
|
+
/* ---------------------------------- team ---------------------------------- */
|
|
362
483
|
|
|
363
|
-
|
|
484
|
+
/* One colour per staff member, in hire order, so two orbs side by side are told apart. */
|
|
485
|
+
const HUES = ["#30d158", "#0a84ff", "#bf5af2", "#ff375f", "#ff9f0a", "#64d2ff", "#ffd60a"];
|
|
486
|
+
|
|
487
|
+
/** What a run is doing, as a person would say it. */
|
|
364
488
|
function whatRun(r) {
|
|
365
|
-
|
|
366
|
-
if (r.trigger === "
|
|
489
|
+
const on = r.issue ? titleOn(r) : "";
|
|
490
|
+
if (r.trigger === "mention") return r.issue ? `Answering #${r.issue}${on}` : "Answering a message";
|
|
491
|
+
if (r.trigger === "peer") return r.issue ? `Helping a colleague with #${r.issue}${on}` : "Helping a colleague";
|
|
367
492
|
return (
|
|
368
|
-
{
|
|
369
|
-
|
|
493
|
+
{
|
|
494
|
+
daily: "Doing their daily work",
|
|
495
|
+
manual: "Doing the work you started",
|
|
496
|
+
"follow-on": "Carrying on from their last session",
|
|
497
|
+
}[r.trigger] ?? "Working"
|
|
370
498
|
);
|
|
371
499
|
}
|
|
372
500
|
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
501
|
+
/** ": the issue's title", when the inbox has it. */
|
|
502
|
+
function titleOn(r) {
|
|
503
|
+
const s = (S.data?.staff ?? []).find((x) => x.handle === r.handle);
|
|
504
|
+
const it = (S.inbox?.items ?? []).find((i) => i.number === r.issue && (!s || i.repo === s.brain));
|
|
505
|
+
return it?.title ? `: ${it.title}` : "";
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
/**
|
|
509
|
+
* Who is working, as a row of orbs. A lit, moving orb is somebody at work; a still, dim one is
|
|
510
|
+
* somebody free. Under it, in words, what they are doing or when they last finished. Pressing
|
|
511
|
+
* an orb that is answering something opens that thread.
|
|
512
|
+
*/
|
|
513
|
+
function team(staff) {
|
|
514
|
+
const box = el("div", { className: "hometeam" });
|
|
515
|
+
const live = S.live?.staff ?? [];
|
|
516
|
+
staff.forEach((s, i) => {
|
|
517
|
+
const l = live.find((x) => x.handle === s.handle);
|
|
381
518
|
const runs = l && !l.error ? (l.running ?? []) : [];
|
|
382
|
-
const
|
|
519
|
+
const queued = runs.length > 0 && runs.every((r) => r.status === "queued");
|
|
520
|
+
const busy = runs.length > 0 && !queued;
|
|
383
521
|
const last = l?.finished?.[0];
|
|
384
|
-
|
|
385
|
-
const
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
522
|
+
const failed = !runs.length && last && last.conclusion === "failure";
|
|
523
|
+
const state = !S.live ? "wait" : busy ? "busy" : queued ? "queued" : failed ? "failed" : "idle";
|
|
524
|
+
|
|
525
|
+
let word = "Free";
|
|
526
|
+
let line = "Not working right now";
|
|
527
|
+
if (!S.live) {
|
|
528
|
+
word = "…";
|
|
529
|
+
line = "Checking…";
|
|
530
|
+
} else if (!l || l.error) {
|
|
531
|
+
word = "Unknown";
|
|
532
|
+
line = "Could not check on them";
|
|
533
|
+
} else if (busy || queued) {
|
|
534
|
+
const r = { ...runs[0], handle: s.handle };
|
|
535
|
+
word = busy ? "Working" : "Waiting to start";
|
|
536
|
+
line = busy
|
|
537
|
+
? `${whatRun(r)} · ${minutes(r.createdAt)} so far`
|
|
538
|
+
: `${whatRun(r)} · queued ${minutes(r.createdAt)} ago`;
|
|
539
|
+
} else if (failed) {
|
|
540
|
+
word = "Free";
|
|
541
|
+
line = `Their last session stopped with a problem, ${ago(last.updatedAt)}`;
|
|
394
542
|
} else if (last) {
|
|
395
|
-
|
|
396
|
-
el("div", { textContent: `${cap(whatRun(last))}, ${outcome(last)} ${ago(last.updatedAt)}` }),
|
|
397
|
-
);
|
|
398
|
-
log = last.url;
|
|
399
|
-
} else {
|
|
400
|
-
what.append(el("div", { textContent: "No runs in the last few hours." }));
|
|
401
|
-
}
|
|
402
|
-
if (l && !l.error && l.automatic) {
|
|
403
|
-
what.append(
|
|
404
|
-
el("div", {
|
|
405
|
-
className: "homerunsub",
|
|
406
|
-
textContent: `${l.automatic} of ${l.limit} runs today that nobody asked for`,
|
|
407
|
-
}),
|
|
408
|
-
);
|
|
543
|
+
line = `Last finished ${ago(last.updatedAt)}`;
|
|
409
544
|
}
|
|
410
545
|
|
|
411
|
-
const
|
|
412
|
-
|
|
413
|
-
|
|
546
|
+
const issue = (busy || queued) && runs[0].issue && s.brain ? runs[0].issue : null;
|
|
547
|
+
const card = el("div", {
|
|
548
|
+
className: "orbcard " + state + (issue ? " homeclick" : ""),
|
|
549
|
+
...(issue ? { tabIndex: 0, role: "button", title: `Open #${issue}` } : {}),
|
|
414
550
|
});
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
551
|
+
card.style?.setProperty?.("--hue", HUES[i % HUES.length]);
|
|
552
|
+
const orb = el("div", { className: "orb", ariaHidden: "true" }, [
|
|
553
|
+
el("span", { className: "orbglow" }),
|
|
554
|
+
el("span", { className: "orbbody" }, [el("span", { className: "orbswirl" })]),
|
|
555
|
+
el("span", { className: "orbicon" }, [icon(staffIcon(s), "ic")]),
|
|
556
|
+
]);
|
|
557
|
+
card.append(
|
|
558
|
+
orb,
|
|
559
|
+
el("b", { className: "orbname", textContent: s.name }),
|
|
560
|
+
el("span", { className: "orbstate", textContent: word }),
|
|
561
|
+
el("span", { className: "orbline", textContent: line }),
|
|
562
|
+
);
|
|
563
|
+
const log = runs[0]?.url ?? last?.url;
|
|
564
|
+
if (log && state !== "idle") {
|
|
565
|
+
card.append(
|
|
566
|
+
el("a", { className: "orblog", href: log, target: "_blank", rel: "noopener", textContent: "View log" }),
|
|
419
567
|
);
|
|
420
568
|
}
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
569
|
+
if (issue) {
|
|
570
|
+
const open = () => openThread({ repo: s.brain, number: issue, kind: "issue" });
|
|
571
|
+
card.onclick = (ev) => {
|
|
572
|
+
if (!ev.target.closest("a")) open();
|
|
573
|
+
};
|
|
574
|
+
card.onkeydown = (ev) => {
|
|
575
|
+
if (ev.target === card && (ev.key === "Enter" || ev.key === " ")) {
|
|
576
|
+
ev.preventDefault();
|
|
577
|
+
open();
|
|
578
|
+
}
|
|
579
|
+
};
|
|
580
|
+
}
|
|
581
|
+
box.append(card);
|
|
582
|
+
});
|
|
431
583
|
return box;
|
|
432
584
|
}
|
|
433
585
|
|
|
@@ -466,7 +618,10 @@ function poll() {
|
|
|
466
618
|
issuesAt = Date.now();
|
|
467
619
|
refreshSoon(false);
|
|
468
620
|
} else if (changed && S.view === "home" && !document.querySelector("dialog[open]")) {
|
|
469
|
-
|
|
621
|
+
/* Typing in the ask box is not interrupted by a run starting: only the orbs move. */
|
|
622
|
+
const row = document.querySelector(".hometeam");
|
|
623
|
+
if (row && document.activeElement?.closest?.(".homeaskcard")) row.replaceWith(team(S.data.staff));
|
|
624
|
+
else repaintInPlace();
|
|
470
625
|
}
|
|
471
626
|
})
|
|
472
627
|
.catch(() => {})
|
|
@@ -479,7 +634,7 @@ function poll() {
|
|
|
479
634
|
|
|
480
635
|
/* ------------------------------ your requests ---------------------------- */
|
|
481
636
|
|
|
482
|
-
/** A card of rows
|
|
637
|
+
/** A card of rows. */
|
|
483
638
|
function listBox(rows) {
|
|
484
639
|
return el("div", { className: "card homeworking" }, rows);
|
|
485
640
|
}
|