@nanocollective/roster 0.1.0-beta.2 → 0.1.0-beta.21

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.
Files changed (99) hide show
  1. package/README.md +8 -0
  2. package/dist/agents-POITEZRI.js +232 -0
  3. package/dist/chunk-FF2WBNNW.js +370 -0
  4. package/dist/chunk-GDAJPOHK.js +562 -0
  5. package/dist/cli.js +3187 -1105
  6. package/dist/compose-5DBEHSEV.js +17 -0
  7. package/dist/connectors-5E5ZMGZV.js +23 -0
  8. package/dist/worker/assets/assets/css/base.css +21 -2
  9. package/dist/worker/assets/assets/css/brain.css +20 -0
  10. package/dist/worker/assets/assets/css/connectors.css +50 -0
  11. package/dist/worker/assets/assets/css/home.css +141 -54
  12. package/dist/worker/assets/assets/css/inbox.css +11 -0
  13. package/dist/worker/assets/assets/css/layout.css +6 -0
  14. package/dist/worker/assets/assets/css/markdown.css +21 -0
  15. package/dist/worker/assets/assets/css/routines.css +40 -0
  16. package/dist/worker/assets/assets/js/api.js +33 -0
  17. package/dist/worker/assets/assets/js/app.js +47 -3
  18. package/dist/worker/assets/assets/js/homesort.js +28 -21
  19. package/dist/worker/assets/assets/js/icons.js +4 -0
  20. package/dist/worker/assets/assets/js/md.js +7 -2
  21. package/dist/worker/assets/assets/js/refcard.js +216 -0
  22. package/dist/worker/assets/assets/js/refresh.js +4 -2
  23. package/dist/worker/assets/assets/js/report.js +51 -0
  24. package/dist/worker/assets/assets/js/state.js +14 -1
  25. package/dist/worker/assets/assets/js/views/connectors.js +290 -0
  26. package/dist/worker/assets/assets/js/views/home.js +368 -152
  27. package/dist/worker/assets/assets/js/views/inbox.js +68 -16
  28. package/dist/worker/assets/assets/js/views/org.js +2 -0
  29. package/dist/worker/assets/assets/js/views/people.js +103 -0
  30. package/dist/worker/assets/assets/js/views/routines.js +378 -0
  31. package/dist/worker/assets/index.html +8 -0
  32. package/dist/worker/index.js +3972 -963
  33. package/docs/README.md +2 -0
  34. package/docs/architecture.md +23 -4
  35. package/docs/commands.md +111 -9
  36. package/docs/concepts.md +2 -1
  37. package/docs/connectors.md +157 -0
  38. package/docs/cost.md +1 -1
  39. package/docs/developing.md +3 -3
  40. package/docs/doctor-codes.md +8 -2
  41. package/docs/export.md +4 -3
  42. package/docs/extending.md +1 -1
  43. package/docs/getting-started.md +19 -2
  44. package/docs/hosting.md +42 -3
  45. package/docs/memory.md +3 -2
  46. package/docs/org-yaml.md +58 -5
  47. package/docs/portal.md +37 -6
  48. package/docs/prompts.md +3 -2
  49. package/docs/routines.md +65 -0
  50. package/docs/security.md +35 -4
  51. package/docs/session-workflow.md +31 -8
  52. package/docs/staff-yaml.md +7 -3
  53. package/docs/troubleshooting.md +1 -1
  54. package/docs/upgrading.md +1 -1
  55. package/docs/writing-a-charter.md +1 -1
  56. package/package.json +2 -1
  57. package/templates/brain/.gitattributes +3 -0
  58. package/templates/brain/.github/workflows/%%STAFF%%-daily.yaml +24 -15
  59. package/templates/brain/.github/workflows/%%STAFF%%-mention.yaml +12 -10
  60. package/templates/brain/CHARTER.md +2 -2
  61. package/templates/brain/STATE.md +16 -0
  62. package/templates/brain/memory/INDEX.md +1 -1
  63. package/templates/brain/staff.yaml +3 -0
  64. package/templates/ops/.gitattributes +3 -0
  65. package/templates/ops/.github/workflows/session.yaml +74 -13
  66. package/templates/ops/agents.mjs +38 -11
  67. package/templates/ops/compose.mjs +60 -2
  68. package/templates/ops/connectors.mjs +722 -0
  69. package/templates/ops/org/operating.md +10 -0
  70. package/templates/ops/org/voice.md +21 -3
  71. package/templates/ops/prompts/_identity.md +20 -0
  72. package/templates/ops/prompts/daily.md +70 -19
  73. package/templates/ops/prompts/mention.md +7 -2
  74. package/templates/ops/status-week.mjs +169 -0
  75. package/templates/portal/css/base.css +21 -2
  76. package/templates/portal/css/brain.css +20 -0
  77. package/templates/portal/css/connectors.css +50 -0
  78. package/templates/portal/css/home.css +141 -54
  79. package/templates/portal/css/inbox.css +11 -0
  80. package/templates/portal/css/layout.css +6 -0
  81. package/templates/portal/css/markdown.css +21 -0
  82. package/templates/portal/css/routines.css +40 -0
  83. package/templates/portal/index.html +8 -0
  84. package/templates/portal/js/api.js +33 -0
  85. package/templates/portal/js/app.js +47 -3
  86. package/templates/portal/js/homesort.js +28 -21
  87. package/templates/portal/js/icons.js +4 -0
  88. package/templates/portal/js/md.js +7 -2
  89. package/templates/portal/js/refcard.js +216 -0
  90. package/templates/portal/js/refresh.js +4 -2
  91. package/templates/portal/js/report.js +51 -0
  92. package/templates/portal/js/state.js +14 -1
  93. package/templates/portal/js/views/connectors.js +290 -0
  94. package/templates/portal/js/views/home.js +368 -152
  95. package/templates/portal/js/views/inbox.js +68 -16
  96. package/templates/portal/js/views/org.js +2 -0
  97. package/templates/portal/js/views/people.js +103 -0
  98. package/templates/portal/js/views/routines.js +378 -0
  99. package/templates/skill/SKILL.md +115 -0
@@ -1,4 +1,5 @@
1
- /* Home: what needs you, who is working, what you asked for, and what was closed today.
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,51 +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
- if (h.reports.length) {
59
- page.append(section("Latest reports"));
60
- const box = el("div", { className: "card homereports" });
61
- for (const r of h.reports) {
62
- /* The report is markdown the staff member wrote, with links to the work it names. The
63
- whole report opens their status issue, where it was posted; a link inside it goes
64
- where it points. */
65
- const row = el("div", { className: "homereport homeclick", tabIndex: 0, role: "button" }, [
66
- el("div", { className: "homereportwho" }, [
67
- el("span", { className: "homewho2" }, [icon(staffIcon(r.staff), "ic"), el("b", { textContent: r.staff.name })]),
68
- el("span", { className: "meta", textContent: ago(r.at) }),
69
- ]),
70
- el("div", {
71
- className: "md homereportbody",
72
- innerHTML: mdlite(r.lines.join("\n\n"), { repo: r.staff.brain }),
73
- }),
74
- ]);
75
- row.onclick = (ev) => {
76
- if (!ev.target.closest("a, button")) openThread(r.item);
77
- };
78
- row.onkeydown = (ev) => {
79
- if (ev.target === row && (ev.key === "Enter" || ev.key === " ")) {
80
- ev.preventDefault();
81
- openThread(r.item);
82
- }
83
- };
84
- box.append(row);
85
- }
86
- page.append(box);
87
- }
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);
70
+ /* One list rather than a card each: five boxes with a green button apiece read as a wall, and
71
+ nothing in it said which to do first. The top row's action is the one in green. */
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
+ );
76
+ } else page.append(el("p", { className: "homeempty", textContent: "Nothing needs you." }));
88
77
 
89
- page.append(section("Needs you", h.needs.length));
90
- if (h.needs.length) for (const e of h.needs) page.append(needCard(e));
91
- else page.append(el("p", { className: "homeempty", textContent: "Nothing needs you." }));
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
+ }
92
83
 
93
84
  if (h.unread.length) {
94
85
  page.append(section("Unread", h.unread.length));
95
86
  page.append(listBox(h.unread.map(unreadRow)));
96
87
  }
97
88
 
98
- page.append(section("Working now"));
99
- page.append(working(staff));
100
-
101
89
  if (h.requests.length) {
102
90
  page.append(section("Your requests", h.requests.length));
103
91
  page.append(listBox(h.requests.map(requestRow)));
@@ -113,25 +101,165 @@ export function viewHome(m) {
113
101
  m.append(page);
114
102
  }
115
103
 
104
+ /* ------------------------------- reports -------------------------------- */
105
+
106
+ /** Whose reports are open in full. Kept here, since Home repaints on every poll. */
107
+ const openReports = new Set();
108
+
109
+ const STATUS_TONE = { "on track": "ok", "needs you": "warm", stuck: "hot", blocked: "hot" };
110
+
111
+ /**
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.
115
+ */
116
+ function reportRow(s, reports) {
117
+ const r = reports.find((x) => x.staff.handle === s.handle);
118
+ const item = r?.item ?? { repo: s.brain, number: s.statusIssue, kind: "issue" };
119
+ const note = el("span", { className: "meta" });
120
+ const ask = el("button", { className: "ghbtn", textContent: "Ask for an update" });
121
+ ask.onclick = async () => {
122
+ ask.disabled = true;
123
+ note.className = "meta";
124
+ note.textContent = "Asking…";
125
+ try {
126
+ await post({
127
+ action: "comment",
128
+ repo: s.brain,
129
+ number: s.statusIssue,
130
+ body: `${s.mention ?? "@" + s.handle} Report, please.`,
131
+ });
132
+ ask.remove();
133
+ note.textContent = `Asked. ${s.name} updates it in a few minutes.`;
134
+ refreshSoon();
135
+ } catch (e) {
136
+ note.textContent = String(e.message || e);
137
+ note.className = "meta err";
138
+ ask.disabled = false;
139
+ }
140
+ };
141
+
142
+ const full = openReports.has(s.handle);
143
+ const card = el("div", { className: "card homereport" + (full ? " full" : "") });
144
+ const issue = el("button", { className: "homereportissue", textContent: "#" + item.number });
145
+ issue.onclick = () => openThread(item);
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
+ ]),
163
+ );
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 = () => {
200
+ if (openReports.has(s.handle)) openReports.delete(s.handle);
201
+ else openReports.add(s.handle);
202
+ repaintInPlace();
203
+ };
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;
218
+ }
219
+
116
220
  /* ------------------------------- asking -------------------------------- */
117
221
 
222
+ /** What is in the ask box, kept across repaints. */
223
+ const askDraft = { who: "", text: "" };
224
+
118
225
  function askBox(staff) {
119
- const who = el("select", { className: "homewho", ariaLabel: "Who to ask" });
120
- for (const s of staff.filter((x) => x.brain)) {
226
+ const people = staff.filter((x) => x.brain);
227
+ const who = el("select", { className: "homewho", id: "homewho" });
228
+ for (const s of people) {
121
229
  who.append(el("option", { value: s.handle, textContent: s.name }));
122
230
  }
231
+ if (askDraft.who && people.some((x) => x.handle === askDraft.who)) who.value = askDraft.who;
123
232
  const text = el("textarea", {
124
233
  className: "homeask",
125
- rows: 2,
126
- placeholder: "Ask a staff member to do something",
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,
127
238
  });
128
- const send = el("button", { className: "ghbtn primary", textContent: "Send" });
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
+ };
129
253
  const note = el("span", { className: "meta" });
130
254
  send.onclick = async () => {
131
255
  const s = staff.find((x) => x.handle === who.value);
132
256
  const said = text.value.trim();
133
- if (!s || !said) return;
257
+ if (!s || !said) {
258
+ text.focus();
259
+ return;
260
+ }
134
261
  send.disabled = true;
262
+ note.className = "meta";
135
263
  note.textContent = "Sending…";
136
264
  try {
137
265
  await post({
@@ -141,6 +269,7 @@ function askBox(staff) {
141
269
  body: `${s.mention ?? "@" + s.handle} ${said}`,
142
270
  });
143
271
  text.value = "";
272
+ askDraft.text = "";
144
273
  note.textContent = `Sent. ${s.name} starts in about a minute.`;
145
274
  refreshSoon();
146
275
  } catch (e) {
@@ -151,7 +280,8 @@ function askBox(staff) {
151
280
  }
152
281
  };
153
282
  return el("div", { className: "card homeaskcard" }, [
154
- el("div", { className: "row" }, [who]),
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]),
155
285
  text,
156
286
  el("div", { className: "row" }, [send, note]),
157
287
  ]);
@@ -165,57 +295,107 @@ function titleOf(said) {
165
295
 
166
296
  /* ------------------------------ needs you ------------------------------- */
167
297
 
168
- function needCard(e) {
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) {
169
345
  const { item, kind } = e;
170
- /* The whole card opens the thread; the one quick action on it does not. Answering in words
346
+ /* The whole row opens the thread; the one quick action on it does not. Answering in words
171
347
  happens in the thread, where what was asked is in front of you. */
172
- const card = el("div", {
173
- className: "card homecard" + (item.unread ? " unread" : ""),
348
+ const row = el("div", {
349
+ className: "homeneed" + (item.unread ? " unread" : ""),
174
350
  tabIndex: 0,
175
351
  role: "button",
176
352
  });
177
- card.onclick = (ev) => {
353
+ row.onclick = (ev) => {
178
354
  if (!ev.target.closest("button, a, textarea")) openThread(item);
179
355
  };
180
- card.onkeydown = (ev) => {
181
- if (ev.target === card && (ev.key === "Enter" || ev.key === " ")) {
356
+ row.onkeydown = (ev) => {
357
+ if (ev.target === row && (ev.key === "Enter" || ev.key === " ")) {
182
358
  ev.preventDefault();
183
359
  openThread(item);
184
360
  }
185
361
  };
186
- // What it is on the left, what you can do about it on the right.
187
- const about = el("div", { className: "homeabout" }, [
188
- el("div", { className: "homehead" }, [
189
- el("span", { className: "chip " + (KIND_TONE[kind] ?? ""), textContent: KIND_LABEL[kind] }),
190
- openLink(item),
191
- ]),
192
- el("div", { className: "meta", textContent: whereOf(e) + " · " + ago(item.createdAt) }),
193
- ]);
194
- card.append(about);
195
362
 
363
+ /* What kind of thing it is sits in the line under the title, so every title starts in the
364
+ same place; a chip in front of it pushed each one along by its own width. */
365
+ const other = forWhom(e, me);
366
+ const meta = el("div", { className: "meta" }, [
367
+ el("span", { className: "homekind " + (KIND_TONE[kind] ?? ""), textContent: KIND_LABEL[kind] }),
368
+ ...(other ? [document.createTextNode(" · "), el("span", { className: "homefor", textContent: other })] : []),
369
+ document.createTextNode(" · " + whereOf(e) + " · " + ago(item.createdAt)),
370
+ ]);
371
+ const about = el("div", { className: "homeabout" }, [openLink(item), meta]);
196
372
  if (kind === "decision" && item.due) about.append(dueLine(item.due));
197
373
  if (kind === "merge") about.append(checksLine(item));
198
374
 
199
375
  // The note comes first so that what happened sits just left of the button that did it.
200
376
  const note = el("span", { className: "meta" });
201
377
  const actions = el("div", { className: "row homeacts" }, [note]);
378
+ row.append(el("span", { className: "homedot", ariaHidden: "true" }), about, actions);
202
379
 
203
380
  if (kind === "decision" || kind === "ask") {
204
- actions.append(button("Reply", true, () => openThread(item)));
205
- if (item.due) actions.append(button("Go with the default", false, () => say(e, "Go with your default.", note, actions)));
381
+ actions.append(button("Reply", first, () => openThread(item)));
382
+ if (item.due) {
383
+ actions.append(button("Go with the default", false, () => say(e, "Go with your default.", note, actions)));
384
+ }
206
385
  } else if (kind === "review") {
207
- actions.append(button("Approve", true, () => say(e, "Approved.", note, actions)));
386
+ actions.append(button("Approve", first, () => say(e, "Approved.", note, actions)));
208
387
  } else if (kind === "chore") {
209
- actions.append(button("Done", true, () => done(e, note, actions)));
388
+ actions.append(button("Done", first, () => done(e, note, actions)));
210
389
  } else if (kind === "merge") {
211
- const blocked = item.checks === "failing" || item.mergeable === "CONFLICTING";
212
- const needsReview = item.reviewDecision === "REVIEW_REQUIRED";
213
- const merge = button("Merge", !needsReview, () => merge_(e, note, actions));
214
- merge.disabled = blocked || item.checks === "pending" || needsReview;
215
- /* The branch rules want an approving review. Approve is the person's review, given on
216
- purpose; Merge waits for it rather than approving on their behalf. */
217
- if (needsReview) {
218
- const approve = button("Approve", true, async () => {
390
+ /* Merge is offered only when pressing it can work. A conflict, failing checks or checks
391
+ still running are in the line under the title instead; a grey button that cannot be
392
+ pressed looked like one that could. */
393
+ const blocked =
394
+ item.checks === "failing" || item.checks === "pending" || item.mergeable === "CONFLICTING";
395
+ const merge = () => button("Merge", first, () => merge_(e, note, actions));
396
+ if (item.reviewDecision === "REVIEW_REQUIRED") {
397
+ // Approve is the person's review, given on purpose; Merge waits for it.
398
+ const approve = button("Approve", first, async () => {
219
399
  approve.disabled = true;
220
400
  note.className = "meta";
221
401
  note.textContent = "Approving…";
@@ -224,8 +404,7 @@ function needCard(e) {
224
404
  item.reviewDecision = "APPROVED";
225
405
  note.textContent = "Approved.";
226
406
  approve.remove();
227
- merge.className = "ghbtn primary";
228
- merge.disabled = blocked || item.checks === "pending";
407
+ if (!blocked) actions.append(merge());
229
408
  } catch (err) {
230
409
  note.textContent = String(err.message || err);
231
410
  note.className = "meta err";
@@ -233,11 +412,9 @@ function needCard(e) {
233
412
  }
234
413
  });
235
414
  actions.append(approve);
236
- }
237
- actions.append(merge);
415
+ } else if (!blocked) actions.append(merge());
238
416
  }
239
- card.append(actions);
240
- return card;
417
+ return row;
241
418
  }
242
419
 
243
420
  function dueLine(due) {
@@ -250,20 +427,20 @@ function dueLine(due) {
250
427
  });
251
428
  }
252
429
 
430
+ /** Where a pull request stands, with only the parts that stop a merge in amber. */
253
431
  function checksLine(item) {
254
- const words = {
255
- passing: "Checks pass.",
256
- failing: "Checks fail.",
257
- pending: "Checks are running.",
258
- none: "No checks.",
259
- };
260
- const conflict =
261
- (item.mergeable === "CONFLICTING" ? " Conflicts with its base." : "") +
262
- (item.reviewDecision === "REVIEW_REQUIRED" ? " Needs your approval to merge." : "");
263
- return el("p", {
264
- className: "homedue" + (item.checks === "failing" || conflict ? " late" : ""),
265
- textContent: (words[item.checks] ?? "") + conflict,
432
+ const parts = [];
433
+ if (item.checks === "passing") parts.push(["Checks pass", false]);
434
+ if (item.checks === "failing") parts.push(["Checks fail", true]);
435
+ if (item.checks === "pending") parts.push(["Checks are running", false]);
436
+ if (item.mergeable === "CONFLICTING") parts.push(["Conflicts with its base", true]);
437
+ if (item.reviewDecision === "REVIEW_REQUIRED") parts.push(["Needs your approval", false]);
438
+ const line = el("p", { className: "homedue" });
439
+ parts.forEach(([text, bad], i) => {
440
+ if (i) line.append(document.createTextNode(" · "));
441
+ line.append(el("span", { className: bad ? "bad" : "", textContent: text }));
266
442
  });
443
+ return line;
267
444
  }
268
445
 
269
446
  async function say(e, text, note, actions) {
@@ -289,7 +466,7 @@ async function act(note, actions, payload, ok) {
289
466
  await post(payload);
290
467
  note.textContent = ok;
291
468
  // Done is done: the card goes now, rather than when GitHub next answers.
292
- const card = actions.closest?.(".homecard, .homeline");
469
+ const card = actions.closest?.(".homeneed, .homeline");
293
470
  if (card) {
294
471
  card.classList.add("gone");
295
472
  setTimeout(() => card.remove(), 220);
@@ -302,76 +479,108 @@ async function act(note, actions, payload, ok) {
302
479
  }
303
480
  }
304
481
 
305
- /* ------------------------------ working now ----------------------------- */
482
+ /* ---------------------------------- team ---------------------------------- */
306
483
 
307
- /** What a run was, in a few words: "daily run", "answering #12", "a peer's ask #4". */
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. */
308
488
  function whatRun(r) {
309
- if (r.trigger === "mention") return r.issue ? `answering #${r.issue}` : "answering a mention";
310
- if (r.trigger === "peer") return r.issue ? `a peer's ask #${r.issue}` : "a peer's ask";
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";
492
+ if (r.trigger === "routine") return r.routine ? `Running the ${r.routine} routine` : "Running a routine";
311
493
  return (
312
- { daily: "daily run", manual: "run started by hand", "follow-on": "follow-on run" }[r.trigger] ??
313
- "run"
494
+ {
495
+ daily: "Doing their daily work",
496
+ manual: "Doing the work you started",
497
+ "follow-on": "Carrying on from their last session",
498
+ }[r.trigger] ?? "Working"
314
499
  );
315
500
  }
316
501
 
317
- function working(staff) {
318
- const box = el("div", { className: "card homeworking" });
319
- if (!S.live) {
320
- box.append(el("p", { className: "homerunwhat", textContent: "Asking GitHub…" }));
321
- return box;
322
- }
323
- for (const s of staff) {
324
- const l = (S.live.staff ?? []).find((x) => x.handle === s.handle);
502
+ /** ": the issue's title", when the inbox has it. */
503
+ function titleOn(r) {
504
+ const s = (S.data?.staff ?? []).find((x) => x.handle === r.handle);
505
+ const it = (S.inbox?.items ?? []).find((i) => i.number === r.issue && (!s || i.repo === s.brain));
506
+ return it?.title ? `: ${it.title}` : "";
507
+ }
508
+
509
+ /**
510
+ * Who is working, as a row of orbs. A lit, moving orb is somebody at work; a still, dim one is
511
+ * somebody free. Under it, in words, what they are doing or when they last finished. Pressing
512
+ * an orb that is answering something opens that thread.
513
+ */
514
+ function team(staff) {
515
+ const box = el("div", { className: "hometeam" });
516
+ const live = S.live?.staff ?? [];
517
+ staff.forEach((s, i) => {
518
+ const l = live.find((x) => x.handle === s.handle);
325
519
  const runs = l && !l.error ? (l.running ?? []) : [];
326
- const busy = runs.length > 0;
520
+ const queued = runs.length > 0 && runs.every((r) => r.status === "queued");
521
+ const busy = runs.length > 0 && !queued;
327
522
  const last = l?.finished?.[0];
328
-
329
- const what = el("div", { className: "homerunwhat" });
330
- let log = null;
331
- if (!l || l.error) {
332
- what.append(el("span", { className: "err", textContent: l?.error ?? "Could not read their runs." }));
333
- } else if (busy) {
334
- for (const r of runs) {
335
- what.append(el("div", { textContent: `${cap(whatRun(r))} · ${minutes(r.createdAt)} so far` }));
336
- }
337
- log = runs[0].url;
523
+ const failed = !runs.length && last && last.conclusion === "failure";
524
+ const state = !S.live ? "wait" : busy ? "busy" : queued ? "queued" : failed ? "failed" : "idle";
525
+
526
+ let word = "Free";
527
+ let line = "Not working right now";
528
+ if (!S.live) {
529
+ word = "…";
530
+ line = "Checking…";
531
+ } else if (!l || l.error) {
532
+ word = "Unknown";
533
+ line = "Could not check on them";
534
+ } else if (busy || queued) {
535
+ const r = { ...runs[0], handle: s.handle };
536
+ word = busy ? "Working" : "Waiting to start";
537
+ line = busy
538
+ ? `${whatRun(r)} · ${minutes(r.createdAt)} so far`
539
+ : `${whatRun(r)} · queued ${minutes(r.createdAt)} ago`;
540
+ } else if (failed) {
541
+ word = "Free";
542
+ line = `Their last session stopped with a problem, ${ago(last.updatedAt)}`;
338
543
  } else if (last) {
339
- what.append(
340
- el("div", { textContent: `${cap(whatRun(last))}, ${outcome(last)} ${ago(last.updatedAt)}` }),
341
- );
342
- log = last.url;
343
- } else {
344
- what.append(el("div", { textContent: "No runs in the last few hours." }));
345
- }
346
- if (l && !l.error && l.automatic) {
347
- what.append(
348
- el("div", {
349
- className: "homerunsub",
350
- textContent: `${l.automatic} of ${l.limit} runs today that nobody asked for`,
351
- }),
352
- );
544
+ line = `Last finished ${ago(last.updatedAt)}`;
353
545
  }
354
546
 
355
- const state = el("span", {
356
- className: "chip homestate " + (busy ? "ok" : ""),
357
- textContent: busy ? (runs[0].status === "queued" ? "Queued" : "Working") : "Idle",
547
+ const issue = (busy || queued) && runs[0].issue && s.brain ? runs[0].issue : null;
548
+ const card = el("div", {
549
+ className: "orbcard " + state + (issue ? " homeclick" : ""),
550
+ ...(issue ? { tabIndex: 0, role: "button", title: `Open #${issue}` } : {}),
358
551
  });
359
- const actions = el("div", { className: "homerunlog" });
360
- if (log) {
361
- actions.append(
362
- el("a", { className: "ghbtn", href: log, target: "_blank", rel: "noopener", textContent: "Log" }),
552
+ card.style?.setProperty?.("--hue", HUES[i % HUES.length]);
553
+ const orb = el("div", { className: "orb", ariaHidden: "true" }, [
554
+ el("span", { className: "orbglow" }),
555
+ el("span", { className: "orbbody" }, [el("span", { className: "orbswirl" })]),
556
+ el("span", { className: "orbicon" }, [icon(staffIcon(s), "ic")]),
557
+ ]);
558
+ card.append(
559
+ orb,
560
+ el("b", { className: "orbname", textContent: s.name }),
561
+ el("span", { className: "orbstate", textContent: word }),
562
+ el("span", { className: "orbline", textContent: line }),
563
+ );
564
+ const log = runs[0]?.url ?? last?.url;
565
+ if (log && state !== "idle") {
566
+ card.append(
567
+ el("a", { className: "orblog", href: log, target: "_blank", rel: "noopener", textContent: "View log" }),
363
568
  );
364
569
  }
365
-
366
- box.append(
367
- el("div", { className: "homerun" + (busy ? " busy" : "") }, [
368
- el("span", { className: "homewho2" }, [icon(staffIcon(s), "ic"), el("b", { textContent: s.name })]),
369
- state,
370
- what,
371
- actions,
372
- ]),
373
- );
374
- }
570
+ if (issue) {
571
+ const open = () => openThread({ repo: s.brain, number: issue, kind: "issue" });
572
+ card.onclick = (ev) => {
573
+ if (!ev.target.closest("a")) open();
574
+ };
575
+ card.onkeydown = (ev) => {
576
+ if (ev.target === card && (ev.key === "Enter" || ev.key === " ")) {
577
+ ev.preventDefault();
578
+ open();
579
+ }
580
+ };
581
+ }
582
+ box.append(card);
583
+ });
375
584
  return box;
376
585
  }
377
586
 
@@ -410,7 +619,10 @@ function poll() {
410
619
  issuesAt = Date.now();
411
620
  refreshSoon(false);
412
621
  } else if (changed && S.view === "home" && !document.querySelector("dialog[open]")) {
413
- repaintInPlace();
622
+ /* Typing in the ask box is not interrupted by a run starting: only the orbs move. */
623
+ const row = document.querySelector(".hometeam");
624
+ if (row && document.activeElement?.closest?.(".homeaskcard")) row.replaceWith(team(S.data.staff));
625
+ else repaintInPlace();
414
626
  }
415
627
  })
416
628
  .catch(() => {})
@@ -423,7 +635,7 @@ function poll() {
423
635
 
424
636
  /* ------------------------------ your requests ---------------------------- */
425
637
 
426
- /** A card of rows, laid out like Working now. */
638
+ /** A card of rows. */
427
639
  function listBox(rows) {
428
640
  return el("div", { className: "card homeworking" }, rows);
429
641
  }
@@ -437,10 +649,14 @@ function listRow(e, { chip, tone = "", sub, action = null }) {
437
649
  "div",
438
650
  { className: "homeline homeclick" + (e.item.unread ? " unread" : ""), tabIndex: 0, role: "button" },
439
651
  [
440
- el("span", { className: "chip homestate " + tone, textContent: chip }),
652
+ // The same row as Needs you: an unread dot, the title, and what it is in the line under it.
653
+ el("span", { className: "homedot", ariaHidden: "true" }),
441
654
  el("div", { className: "homerunwhat" }, [
442
655
  el("div", { className: "homerowtitle", textContent: e.item.title }),
443
- el("div", { className: "homerunsub", textContent: `${whereOf(e)} · ${sub}` }),
656
+ el("div", { className: "homerunsub" }, [
657
+ el("span", { className: "homekind " + tone, textContent: chip }),
658
+ document.createTextNode(` · ${whereOf(e)} · ${sub}`),
659
+ ]),
444
660
  ]),
445
661
  el("div", { className: "homerunlog" }, action ? [action] : []),
446
662
  ],