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

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 (133) 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/astryx.css +948 -0
  9. package/dist/worker/assets/assets/css/base.css +64 -110
  10. package/dist/worker/assets/assets/css/brain.css +26 -2
  11. package/dist/worker/assets/assets/css/connectors.css +50 -0
  12. package/dist/worker/assets/assets/css/graph.css +9 -12
  13. package/dist/worker/assets/assets/css/health.css +4 -7
  14. package/dist/worker/assets/assets/css/home.css +145 -60
  15. package/dist/worker/assets/assets/css/inbox.css +11 -0
  16. package/dist/worker/assets/assets/css/layout.css +16 -20
  17. package/dist/worker/assets/assets/css/markdown.css +22 -1
  18. package/dist/worker/assets/assets/css/routines.css +40 -0
  19. package/dist/worker/assets/assets/css/runs.css +5 -3
  20. package/dist/worker/assets/assets/css/search.css +3 -6
  21. package/dist/worker/assets/assets/css/setup.css +3 -15
  22. package/dist/worker/assets/assets/js/api.js +33 -0
  23. package/dist/worker/assets/assets/js/app.js +49 -3
  24. package/dist/worker/assets/assets/js/astryx-ui.js +34 -0
  25. package/dist/worker/assets/assets/js/homesort.js +28 -21
  26. package/dist/worker/assets/assets/js/icons.js +6 -0
  27. package/dist/worker/assets/assets/js/md.js +7 -2
  28. package/dist/worker/assets/assets/js/refcard.js +216 -0
  29. package/dist/worker/assets/assets/js/refresh.js +4 -2
  30. package/dist/worker/assets/assets/js/report.js +51 -0
  31. package/dist/worker/assets/assets/js/select.js +362 -0
  32. package/dist/worker/assets/assets/js/state.js +14 -1
  33. package/dist/worker/assets/assets/js/views/connectors.js +290 -0
  34. package/dist/worker/assets/assets/js/views/graph.js +67 -28
  35. package/dist/worker/assets/assets/js/views/home.js +378 -176
  36. package/dist/worker/assets/assets/js/views/inbox.js +68 -16
  37. package/dist/worker/assets/assets/js/views/org.js +2 -0
  38. package/dist/worker/assets/assets/js/views/people.js +109 -0
  39. package/dist/worker/assets/assets/js/views/routines.js +378 -0
  40. package/dist/worker/assets/assets/js/views/runs.js +3 -1
  41. package/dist/worker/assets/docs-images/brain.jpg +0 -0
  42. package/dist/worker/assets/docs-images/home.jpg +0 -0
  43. package/dist/worker/assets/docs-images/org.jpg +0 -0
  44. package/dist/worker/assets/docs-images/prompt.jpg +0 -0
  45. package/dist/worker/assets/docs-images/setup-org.jpg +0 -0
  46. package/dist/worker/assets/docs-images/setup-plan.jpg +0 -0
  47. package/dist/worker/assets/docs-images/staff.jpg +0 -0
  48. package/dist/worker/assets/index.html +16 -1
  49. package/dist/worker/index.js +3972 -963
  50. package/docs/README.md +2 -0
  51. package/docs/architecture.md +23 -4
  52. package/docs/commands.md +111 -9
  53. package/docs/concepts.md +2 -1
  54. package/docs/connectors.md +157 -0
  55. package/docs/cost.md +1 -1
  56. package/docs/developing.md +3 -3
  57. package/docs/doctor-codes.md +8 -2
  58. package/docs/export.md +4 -3
  59. package/docs/extending.md +1 -1
  60. package/docs/getting-started.md +20 -3
  61. package/docs/hosting.md +42 -3
  62. package/docs/images/brain.jpg +0 -0
  63. package/docs/images/home.jpg +0 -0
  64. package/docs/images/org.jpg +0 -0
  65. package/docs/images/prompt.jpg +0 -0
  66. package/docs/images/setup-org.jpg +0 -0
  67. package/docs/images/setup-plan.jpg +0 -0
  68. package/docs/images/staff.jpg +0 -0
  69. package/docs/memory.md +3 -2
  70. package/docs/org-yaml.md +58 -5
  71. package/docs/portal.md +43 -10
  72. package/docs/prompts.md +3 -2
  73. package/docs/routines.md +65 -0
  74. package/docs/security.md +35 -4
  75. package/docs/session-workflow.md +31 -8
  76. package/docs/staff-yaml.md +7 -3
  77. package/docs/troubleshooting.md +1 -1
  78. package/docs/upgrading.md +1 -1
  79. package/docs/writing-a-charter.md +1 -1
  80. package/package.json +8 -1
  81. package/templates/brain/.gitattributes +3 -0
  82. package/templates/brain/.github/workflows/%%STAFF%%-daily.yaml +24 -15
  83. package/templates/brain/.github/workflows/%%STAFF%%-mention.yaml +12 -10
  84. package/templates/brain/CHARTER.md +2 -2
  85. package/templates/brain/STATE.md +16 -0
  86. package/templates/brain/memory/INDEX.md +1 -1
  87. package/templates/brain/staff.yaml +3 -0
  88. package/templates/ops/.gitattributes +3 -0
  89. package/templates/ops/.github/workflows/session.yaml +74 -13
  90. package/templates/ops/agents.mjs +38 -11
  91. package/templates/ops/compose.mjs +60 -2
  92. package/templates/ops/connectors.mjs +722 -0
  93. package/templates/ops/org/operating.md +10 -0
  94. package/templates/ops/org/voice.md +21 -3
  95. package/templates/ops/prompts/_identity.md +20 -0
  96. package/templates/ops/prompts/daily.md +70 -19
  97. package/templates/ops/prompts/mention.md +7 -2
  98. package/templates/ops/status-week.mjs +169 -0
  99. package/templates/portal/css/astryx.css +948 -0
  100. package/templates/portal/css/base.css +64 -110
  101. package/templates/portal/css/brain.css +26 -2
  102. package/templates/portal/css/connectors.css +50 -0
  103. package/templates/portal/css/graph.css +9 -12
  104. package/templates/portal/css/health.css +4 -7
  105. package/templates/portal/css/home.css +145 -60
  106. package/templates/portal/css/inbox.css +11 -0
  107. package/templates/portal/css/layout.css +16 -20
  108. package/templates/portal/css/markdown.css +22 -1
  109. package/templates/portal/css/routines.css +40 -0
  110. package/templates/portal/css/runs.css +5 -3
  111. package/templates/portal/css/search.css +3 -6
  112. package/templates/portal/css/setup.css +3 -15
  113. package/templates/portal/index.html +16 -1
  114. package/templates/portal/js/api.js +33 -0
  115. package/templates/portal/js/app.js +49 -3
  116. package/templates/portal/js/astryx-ui.js +34 -0
  117. package/templates/portal/js/homesort.js +28 -21
  118. package/templates/portal/js/icons.js +6 -0
  119. package/templates/portal/js/md.js +7 -2
  120. package/templates/portal/js/refcard.js +216 -0
  121. package/templates/portal/js/refresh.js +4 -2
  122. package/templates/portal/js/report.js +51 -0
  123. package/templates/portal/js/select.js +362 -0
  124. package/templates/portal/js/state.js +14 -1
  125. package/templates/portal/js/views/connectors.js +290 -0
  126. package/templates/portal/js/views/graph.js +67 -28
  127. package/templates/portal/js/views/home.js +378 -176
  128. package/templates/portal/js/views/inbox.js +68 -16
  129. package/templates/portal/js/views/org.js +2 -0
  130. package/templates/portal/js/views/people.js +109 -0
  131. package/templates/portal/js/views/routines.js +378 -0
  132. package/templates/portal/js/views/runs.js +3 -1
  133. package/templates/skill/SKILL.md +115 -0
@@ -1,14 +1,16 @@
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
5
6
  * sheet, the same thread view Trackers has, with the reply box in it. */
6
7
 
7
8
  import { getLive, post } from "../api.js";
8
- import { sheet } from "../dialog.js";
9
+ import { askText, 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,56 +55,42 @@ export function viewHome(m) {
53
55
  stampCounts();
54
56
 
55
57
  const page = el("div", { className: "home" });
56
- page.append(askBox(staff));
57
-
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
- }
88
-
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." }));
58
+ page.append(team(staff));
59
+
60
+ /* With more than one person, each sees what is on them, plus anything on nobody in
61
+ particular. Everyone's is one click away, so nothing is hidden for good. */
62
+ const me = meHuman();
63
+ const split = Boolean(me) && humansOf().length > 1;
64
+ const mine = split ? h.needs.filter((e) => isFor(e, me.github)) : h.needs;
65
+ const shown = split && needsScope === "all" ? h.needs : mine;
66
+ const needsHead = section("Needs you", shown.length);
67
+ if (split && mine.length !== h.needs.length) needsHead.append(scopeToggle(mine.length, h.needs.length));
68
+ page.append(needsHead);
69
+ /* One list rather than a card each: five boxes with a green button apiece read as a wall, and
70
+ nothing in it said which to do first. The top row's action is the one in green. */
71
+ if (shown.length) {
72
+ page.append(
73
+ el("div", { className: "card homelist" }, shown.map((e, i) => needRow(e, i === 0, split ? me : null))),
74
+ );
75
+ } else page.append(el("p", { className: "homeempty", textContent: "Nothing needs you." }));
92
76
 
77
+ // What is waiting on you, or was asked by you, comes before how the staff say it is going.
93
78
  if (h.unread.length) {
94
79
  page.append(section("Unread", h.unread.length));
95
80
  page.append(listBox(h.unread.map(unreadRow)));
96
81
  }
97
82
 
98
- page.append(section("Working now"));
99
- page.append(working(staff));
100
-
101
83
  if (h.requests.length) {
102
84
  page.append(section("Your requests", h.requests.length));
103
85
  page.append(listBox(h.requests.map(requestRow)));
104
86
  }
105
87
 
88
+ const reporters = staff.filter((x) => x.brain && x.statusIssue);
89
+ if (reporters.length) {
90
+ page.append(section("Progress"));
91
+ page.append(el("div", { className: "card homereports" }, reporters.map((s) => reportRow(s, h.reports))));
92
+ }
93
+
106
94
  if (h.closedToday.length) {
107
95
  page.append(section("Closed today", h.closedToday.length));
108
96
  page.append(listBox(h.closedToday.map(closedRow)));
@@ -113,48 +101,170 @@ export function viewHome(m) {
113
101
  m.append(page);
114
102
  }
115
103
 
116
- /* ------------------------------- asking -------------------------------- */
104
+ /* ------------------------------- reports -------------------------------- */
117
105
 
118
- function askBox(staff) {
119
- const who = el("select", { className: "homewho", ariaLabel: "Who to ask" });
120
- for (const s of staff.filter((x) => x.brain)) {
121
- who.append(el("option", { value: s.handle, textContent: s.name }));
122
- }
123
- const text = el("textarea", {
124
- className: "homeask",
125
- rows: 2,
126
- placeholder: "Ask a staff member to do something",
127
- });
128
- const send = el("button", { className: "ghbtn primary", textContent: "Send" });
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, as a row: who, their status, and when it was written; then the
113
+ * one line on how it is going and what is next. What got done, and the rest of the report,
114
+ * open under it. Their status issue is rewritten by every run, so this is always the latest.
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" };
129
119
  const note = el("span", { className: "meta" });
130
- send.onclick = async () => {
131
- const s = staff.find((x) => x.handle === who.value);
132
- const said = text.value.trim();
133
- if (!s || !said) return;
134
- send.disabled = true;
135
- note.textContent = "Sending…";
120
+ const ask = el("button", { className: "ghbtn sm", textContent: "Ask for an update" });
121
+ ask.onclick = async () => {
122
+ ask.disabled = true;
123
+ note.className = "meta";
124
+ note.textContent = "Asking…";
136
125
  try {
137
126
  await post({
138
- action: "create",
127
+ action: "comment",
139
128
  repo: s.brain,
140
- title: titleOf(said),
141
- body: `${s.mention ?? "@" + s.handle} ${said}`,
129
+ number: s.statusIssue,
130
+ body: `${s.mention ?? "@" + s.handle} Report, please.`,
142
131
  });
143
- text.value = "";
144
- note.textContent = `Sent. ${s.name} starts in about a minute.`;
132
+ ask.remove();
133
+ note.textContent = `Asked. ${s.name} updates it in a few minutes.`;
145
134
  refreshSoon();
146
135
  } catch (e) {
147
136
  note.textContent = String(e.message || e);
148
137
  note.className = "meta err";
149
- } finally {
150
- send.disabled = false;
138
+ ask.disabled = false;
151
139
  }
152
140
  };
153
- return el("div", { className: "card homeaskcard" }, [
154
- el("div", { className: "row" }, [who]),
155
- text,
156
- el("div", { className: "row" }, [send, note]),
141
+
142
+ const full = openReports.has(s.handle);
143
+ const row = el("div", { className: "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 needs = p?.sections.needs?.length ?? 0;
148
+
149
+ const head = el("div", { className: "homereporthead" }, [
150
+ el("span", { className: "homewho2" }, [icon(staffIcon(s), "ic"), el("b", { textContent: s.name })]),
157
151
  ]);
152
+ if (p?.status) {
153
+ head.append(
154
+ el("span", {
155
+ className: "chip homereportstatus " + (STATUS_TONE[p.status] ?? ""),
156
+ textContent: cap(p.status) + (needs ? ` · ${needs}` : ""),
157
+ title: needs ? `Waiting on a person: ${needs} thing${needs === 1 ? "" : "s"}` : "",
158
+ }),
159
+ );
160
+ }
161
+ head.append(
162
+ el("span", { className: "meta homereportwhen" }, [
163
+ document.createTextNode((r ? "Updated " + ago(r.at) : "No report yet") + " · "),
164
+ issue,
165
+ ]),
166
+ );
167
+ const acts = el("span", { className: "homereportacts" }, [note]);
168
+ if (r) {
169
+ const more = el("button", { className: "ghbtn sm", textContent: full ? "Show less" : "Full report" });
170
+ more.onclick = () => {
171
+ if (openReports.has(s.handle)) openReports.delete(s.handle);
172
+ else openReports.add(s.handle);
173
+ repaintInPlace();
174
+ };
175
+ acts.append(more);
176
+ }
177
+ acts.append(ask);
178
+ head.append(acts);
179
+ row.append(head);
180
+
181
+ if (!p) return row;
182
+ if (p.headline) {
183
+ row.append(el("div", { className: "md homereportline", innerHTML: mdlite(p.headline, { repo: s.brain }) }));
184
+ }
185
+ const next = p.sections.next?.[0];
186
+ if (next && !full) {
187
+ row.append(
188
+ el("div", { className: "homereportnext" }, [
189
+ el("b", { textContent: "Next" }),
190
+ el("span", { className: "md", innerHTML: mdlite(next, { repo: s.brain }) }),
191
+ ]),
192
+ );
193
+ }
194
+ if (full) {
195
+ const cols = [
196
+ ["done", "Done"],
197
+ ["next", "Next"],
198
+ ["needs", "Waiting on a person"],
199
+ ].filter(([k]) => p.sections[k]?.length);
200
+ if (cols.length) {
201
+ row.append(
202
+ el(
203
+ "div",
204
+ { className: "homereportcols" },
205
+ cols.map(([k, label]) => bullets(label, p.sections[k], s.brain, 99)),
206
+ ),
207
+ );
208
+ } else {
209
+ // A report in the old shape has no sections, so the whole of it stands in.
210
+ row.append(el("div", { className: "md homereportbody", innerHTML: mdlite(r.body, { repo: s.brain }) }));
211
+ }
212
+ }
213
+ return row;
214
+ }
215
+
216
+ /** A short list under a label, with how many more there are once it runs past `max`. */
217
+ function bullets(label, items, repo, max) {
218
+ const list = el(
219
+ "ul",
220
+ {},
221
+ items.slice(0, max).map((x) => el("li", { className: "md", innerHTML: mdlite(x, { repo }) })),
222
+ );
223
+ const box = el("div", { className: "homereportcol" }, [el("h3", { textContent: label }), list]);
224
+ if (items.length > max) box.append(el("p", { className: "meta", textContent: `and ${items.length - max} more` }));
225
+ return box;
226
+ }
227
+
228
+ /* ------------------------------- asking -------------------------------- */
229
+
230
+ /** What each staff member is being asked, kept if the dialog is closed before sending. */
231
+ const askDrafts = {};
232
+ /** When each was last asked, so their card can say so until they pick it up. */
233
+ const askedAt = {};
234
+
235
+ /**
236
+ * Asking one staff member to do something: their card's button opens this, already addressed
237
+ * to them. It becomes a new issue on their tracker that mentions them, which starts a run.
238
+ */
239
+ async function askStaff(s, error = "") {
240
+ const said = await askText({
241
+ title: `Ask ${s.name}`,
242
+ hint: error,
243
+ value: askDrafts[s.handle] ?? "",
244
+ placeholder: "What do you need? For example: write a post about the new pricing page.",
245
+ confirm: "Send",
246
+ decorate: (ta) => {
247
+ ta.addEventListener("input", () => {
248
+ askDrafts[s.handle] = ta.value;
249
+ });
250
+ },
251
+ });
252
+ if (!said) return;
253
+ try {
254
+ await post({
255
+ action: "create",
256
+ repo: s.brain,
257
+ title: titleOf(said),
258
+ body: `${s.mention ?? "@" + s.handle} ${said}`,
259
+ });
260
+ delete askDrafts[s.handle];
261
+ askedAt[s.handle] = Date.now();
262
+ repaintInPlace();
263
+ refreshSoon();
264
+ } catch (e) {
265
+ askDrafts[s.handle] = said;
266
+ await askStaff(s, String(e.message || e));
267
+ }
158
268
  }
159
269
 
160
270
  /** The first line, short enough to be an issue title. */
@@ -165,57 +275,107 @@ function titleOf(said) {
165
275
 
166
276
  /* ------------------------------ needs you ------------------------------- */
167
277
 
168
- function needCard(e) {
278
+ /** "mine" or "all": whose asks Needs you lists, when there is more than one person. */
279
+ let needsScope = readScope();
280
+
281
+ function readScope() {
282
+ try {
283
+ return localStorage.getItem("roster.needsScope") === "all" ? "all" : "mine";
284
+ } catch {
285
+ return "mine";
286
+ }
287
+ }
288
+
289
+ /** The signed-in person, when they are one of the org's humans. */
290
+ function meHuman() {
291
+ const login = String(S.me ?? "").toLowerCase();
292
+ return login ? (humansOf().find((h) => String(h.github ?? "").toLowerCase() === login) ?? null) : null;
293
+ }
294
+
295
+ function scopeToggle(mine, all) {
296
+ const bar = el("span", { className: "homescope", role: "group", ariaLabel: "Whose to show" });
297
+ for (const [value, label] of [
298
+ ["mine", `Yours ${mine}`],
299
+ ["all", `Everyone's ${all}`],
300
+ ]) {
301
+ const b = el("button", { className: needsScope === value ? "on" : "", textContent: label });
302
+ b.setAttribute("aria-pressed", String(needsScope === value));
303
+ b.onclick = () => {
304
+ needsScope = value;
305
+ try {
306
+ localStorage.setItem("roster.needsScope", value);
307
+ } catch {
308
+ /* a private window: it is only remembered for this visit */
309
+ }
310
+ repaintInPlace();
311
+ };
312
+ bar.append(b);
313
+ }
314
+ return bar;
315
+ }
316
+
317
+ /** "For Ben", on an ask that is on somebody else. */
318
+ function forWhom(e, me) {
319
+ if (!me || !e.for?.length || e.for.some((g) => g.toLowerCase() === me.github.toLowerCase())) return "";
320
+ const names = e.for.map((g) => humansOf().find((h) => h.github === g)?.name ?? g);
321
+ return "For " + names.join(" and ");
322
+ }
323
+
324
+ function needRow(e, first, me = null) {
169
325
  const { item, kind } = e;
170
- /* The whole card opens the thread; the one quick action on it does not. Answering in words
326
+ /* The whole row opens the thread; the one quick action on it does not. Answering in words
171
327
  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" : ""),
328
+ const row = el("div", {
329
+ className: "homeneed" + (item.unread ? " unread" : ""),
174
330
  tabIndex: 0,
175
331
  role: "button",
176
332
  });
177
- card.onclick = (ev) => {
333
+ row.onclick = (ev) => {
178
334
  if (!ev.target.closest("button, a, textarea")) openThread(item);
179
335
  };
180
- card.onkeydown = (ev) => {
181
- if (ev.target === card && (ev.key === "Enter" || ev.key === " ")) {
336
+ row.onkeydown = (ev) => {
337
+ if (ev.target === row && (ev.key === "Enter" || ev.key === " ")) {
182
338
  ev.preventDefault();
183
339
  openThread(item);
184
340
  }
185
341
  };
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
342
 
343
+ /* What kind of thing it is sits in the line under the title, so every title starts in the
344
+ same place; a chip in front of it pushed each one along by its own width. */
345
+ const other = forWhom(e, me);
346
+ const meta = el("div", { className: "meta" }, [
347
+ el("span", { className: "homekind " + (KIND_TONE[kind] ?? ""), textContent: KIND_LABEL[kind] }),
348
+ ...(other ? [document.createTextNode(" · "), el("span", { className: "homefor", textContent: other })] : []),
349
+ document.createTextNode(" · " + whereOf(e) + " · " + ago(item.createdAt)),
350
+ ]);
351
+ const about = el("div", { className: "homeabout" }, [openLink(item), meta]);
196
352
  if (kind === "decision" && item.due) about.append(dueLine(item.due));
197
353
  if (kind === "merge") about.append(checksLine(item));
198
354
 
199
355
  // The note comes first so that what happened sits just left of the button that did it.
200
356
  const note = el("span", { className: "meta" });
201
357
  const actions = el("div", { className: "row homeacts" }, [note]);
358
+ row.append(el("span", { className: "homedot", ariaHidden: "true" }), about, actions);
202
359
 
203
360
  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)));
361
+ actions.append(button("Reply", first, () => openThread(item)));
362
+ if (item.due) {
363
+ actions.append(button("Go with the default", false, () => say(e, "Go with your default.", note, actions)));
364
+ }
206
365
  } else if (kind === "review") {
207
- actions.append(button("Approve", true, () => say(e, "Approved.", note, actions)));
366
+ actions.append(button("Approve", first, () => say(e, "Approved.", note, actions)));
208
367
  } else if (kind === "chore") {
209
- actions.append(button("Done", true, () => done(e, note, actions)));
368
+ actions.append(button("Done", first, () => done(e, note, actions)));
210
369
  } 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 () => {
370
+ /* Merge is offered only when pressing it can work. A conflict, failing checks or checks
371
+ still running are in the line under the title instead; a grey button that cannot be
372
+ pressed looked like one that could. */
373
+ const blocked =
374
+ item.checks === "failing" || item.checks === "pending" || item.mergeable === "CONFLICTING";
375
+ const merge = () => button("Merge", first, () => merge_(e, note, actions));
376
+ if (item.reviewDecision === "REVIEW_REQUIRED") {
377
+ // Approve is the person's review, given on purpose; Merge waits for it.
378
+ const approve = button("Approve", first, async () => {
219
379
  approve.disabled = true;
220
380
  note.className = "meta";
221
381
  note.textContent = "Approving…";
@@ -224,8 +384,7 @@ function needCard(e) {
224
384
  item.reviewDecision = "APPROVED";
225
385
  note.textContent = "Approved.";
226
386
  approve.remove();
227
- merge.className = "ghbtn primary";
228
- merge.disabled = blocked || item.checks === "pending";
387
+ if (!blocked) actions.append(merge());
229
388
  } catch (err) {
230
389
  note.textContent = String(err.message || err);
231
390
  note.className = "meta err";
@@ -233,11 +392,9 @@ function needCard(e) {
233
392
  }
234
393
  });
235
394
  actions.append(approve);
236
- }
237
- actions.append(merge);
395
+ } else if (!blocked) actions.append(merge());
238
396
  }
239
- card.append(actions);
240
- return card;
397
+ return row;
241
398
  }
242
399
 
243
400
  function dueLine(due) {
@@ -250,20 +407,20 @@ function dueLine(due) {
250
407
  });
251
408
  }
252
409
 
410
+ /** Where a pull request stands, with only the parts that stop a merge in amber. */
253
411
  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,
412
+ const parts = [];
413
+ if (item.checks === "passing") parts.push(["Checks pass", false]);
414
+ if (item.checks === "failing") parts.push(["Checks fail", true]);
415
+ if (item.checks === "pending") parts.push(["Checks are running", false]);
416
+ if (item.mergeable === "CONFLICTING") parts.push(["Conflicts with its base", true]);
417
+ if (item.reviewDecision === "REVIEW_REQUIRED") parts.push(["Needs your approval", false]);
418
+ const line = el("p", { className: "homedue" });
419
+ parts.forEach(([text, bad], i) => {
420
+ if (i) line.append(document.createTextNode(" · "));
421
+ line.append(el("span", { className: bad ? "bad" : "", textContent: text }));
266
422
  });
423
+ return line;
267
424
  }
268
425
 
269
426
  async function say(e, text, note, actions) {
@@ -289,7 +446,7 @@ async function act(note, actions, payload, ok) {
289
446
  await post(payload);
290
447
  note.textContent = ok;
291
448
  // Done is done: the card goes now, rather than when GitHub next answers.
292
- const card = actions.closest?.(".homecard, .homeline");
449
+ const card = actions.closest?.(".homeneed, .homeline");
293
450
  if (card) {
294
451
  card.classList.add("gone");
295
452
  setTimeout(() => card.remove(), 220);
@@ -302,76 +459,117 @@ async function act(note, actions, payload, ok) {
302
459
  }
303
460
  }
304
461
 
305
- /* ------------------------------ working now ----------------------------- */
462
+ /* ---------------------------------- team ---------------------------------- */
463
+
464
+ /* One colour per staff member, in hire order, so two orbs side by side are told apart. */
465
+ const HUES = ["#30d158", "#0a84ff", "#bf5af2", "#ff375f", "#ff9f0a", "#64d2ff", "#ffd60a"];
306
466
 
307
- /** What a run was, in a few words: "daily run", "answering #12", "a peer's ask #4". */
467
+ /** What a run is doing, as a person would say it. */
308
468
  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";
469
+ const on = r.issue ? titleOn(r) : "";
470
+ if (r.trigger === "mention") return r.issue ? `Answering #${r.issue}${on}` : "Answering a message";
471
+ if (r.trigger === "peer") return r.issue ? `Helping a colleague with #${r.issue}${on}` : "Helping a colleague";
472
+ if (r.trigger === "routine") return r.routine ? `Running the ${r.routine} routine` : "Running a routine";
311
473
  return (
312
- { daily: "daily run", manual: "run started by hand", "follow-on": "follow-on run" }[r.trigger] ??
313
- "run"
474
+ {
475
+ daily: "Doing their daily work",
476
+ manual: "Doing the work you started",
477
+ "follow-on": "Carrying on from their last session",
478
+ }[r.trigger] ?? "Working"
314
479
  );
315
480
  }
316
481
 
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);
482
+ /** ": the issue's title", when the inbox has it. */
483
+ function titleOn(r) {
484
+ const s = (S.data?.staff ?? []).find((x) => x.handle === r.handle);
485
+ const it = (S.inbox?.items ?? []).find((i) => i.number === r.issue && (!s || i.repo === s.brain));
486
+ return it?.title ? `: ${it.title}` : "";
487
+ }
488
+
489
+ /**
490
+ * Who is working, as a row of orbs. A lit, moving orb is somebody at work; a still, dim one is
491
+ * somebody free. Under it, in words, what they are doing or when they last finished. Pressing
492
+ * an orb that is answering something opens that thread.
493
+ */
494
+ function team(staff) {
495
+ const box = el("div", { className: "hometeam" });
496
+ const live = S.live?.staff ?? [];
497
+ staff.forEach((s, i) => {
498
+ const l = live.find((x) => x.handle === s.handle);
325
499
  const runs = l && !l.error ? (l.running ?? []) : [];
326
- const busy = runs.length > 0;
500
+ const queued = runs.length > 0 && runs.every((r) => r.status === "queued");
501
+ const busy = runs.length > 0 && !queued;
327
502
  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;
503
+ const failed = !runs.length && last && last.conclusion === "failure";
504
+ const state = !S.live ? "wait" : busy ? "busy" : queued ? "queued" : failed ? "failed" : "idle";
505
+
506
+ let word = "Free";
507
+ let line = "Not working right now";
508
+ if (!S.live) {
509
+ word = "…";
510
+ line = "Checking…";
511
+ } else if (!l || l.error) {
512
+ word = "Unknown";
513
+ line = "Could not check on them";
514
+ } else if (busy || queued) {
515
+ const r = { ...runs[0], handle: s.handle };
516
+ word = busy ? "Working" : "Waiting to start";
517
+ line = busy
518
+ ? `${whatRun(r)} · ${minutes(r.createdAt)} so far`
519
+ : `${whatRun(r)} · queued ${minutes(r.createdAt)} ago`;
520
+ } else if (failed) {
521
+ word = "Free";
522
+ line = `Their last session stopped with a problem, ${ago(last.updatedAt)}`;
338
523
  } 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." }));
524
+ line = `Last finished ${ago(last.updatedAt)}`;
345
525
  }
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
- );
526
+ // A run takes about a minute to start, and until then the card would say nothing happened.
527
+ if (!busy && !queued && Date.now() - (askedAt[s.handle] ?? 0) < 120_000) {
528
+ line = "Sent. Starts in about a minute";
353
529
  }
354
530
 
355
- const state = el("span", {
356
- className: "chip homestate " + (busy ? "ok" : ""),
357
- textContent: busy ? (runs[0].status === "queued" ? "Queued" : "Working") : "Idle",
531
+ const issue = (busy || queued) && runs[0].issue && s.brain ? runs[0].issue : null;
532
+ const card = el("div", {
533
+ className: "orbcard " + state + (issue ? " homeclick" : ""),
534
+ ...(issue ? { tabIndex: 0, role: "button", title: `Open #${issue}` } : {}),
358
535
  });
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" }),
536
+ card.style?.setProperty?.("--hue", HUES[i % HUES.length]);
537
+ const orb = el("div", { className: "orb", ariaHidden: "true" }, [
538
+ el("span", { className: "orbglow" }),
539
+ el("span", { className: "orbbody" }, [el("span", { className: "orbswirl" })]),
540
+ el("span", { className: "orbicon" }, [icon(staffIcon(s), "ic")]),
541
+ ]);
542
+ card.append(
543
+ orb,
544
+ el("b", { className: "orbname", textContent: s.name }),
545
+ el("span", { className: "orbstate", textContent: word }),
546
+ el("span", { className: "orbline", textContent: line }),
547
+ );
548
+ const log = runs[0]?.url ?? last?.url;
549
+ if (log && state !== "idle") {
550
+ card.append(
551
+ el("a", { className: "orblog", href: log, target: "_blank", rel: "noopener", textContent: "View log" }),
363
552
  );
364
553
  }
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
- }
554
+ if (s.brain) {
555
+ const ask = el("button", { className: "ghbtn orbask", textContent: "Ask a question" });
556
+ ask.onclick = () => askStaff(s);
557
+ card.append(el("span", { className: "orbgap" }), ask);
558
+ }
559
+ if (issue) {
560
+ const open = () => openThread({ repo: s.brain, number: issue, kind: "issue" });
561
+ card.onclick = (ev) => {
562
+ if (!ev.target.closest("a, button")) open();
563
+ };
564
+ card.onkeydown = (ev) => {
565
+ if (ev.target === card && (ev.key === "Enter" || ev.key === " ")) {
566
+ ev.preventDefault();
567
+ open();
568
+ }
569
+ };
570
+ }
571
+ box.append(card);
572
+ });
375
573
  return box;
376
574
  }
377
575
 
@@ -423,7 +621,7 @@ function poll() {
423
621
 
424
622
  /* ------------------------------ your requests ---------------------------- */
425
623
 
426
- /** A card of rows, laid out like Working now. */
624
+ /** A card of rows. */
427
625
  function listBox(rows) {
428
626
  return el("div", { className: "card homeworking" }, rows);
429
627
  }
@@ -437,10 +635,14 @@ function listRow(e, { chip, tone = "", sub, action = null }) {
437
635
  "div",
438
636
  { className: "homeline homeclick" + (e.item.unread ? " unread" : ""), tabIndex: 0, role: "button" },
439
637
  [
440
- el("span", { className: "chip homestate " + tone, textContent: chip }),
638
+ // The same row as Needs you: an unread dot, the title, and what it is in the line under it.
639
+ el("span", { className: "homedot", ariaHidden: "true" }),
441
640
  el("div", { className: "homerunwhat" }, [
442
641
  el("div", { className: "homerowtitle", textContent: e.item.title }),
443
- el("div", { className: "homerunsub", textContent: `${whereOf(e)} · ${sub}` }),
642
+ el("div", { className: "homerunsub" }, [
643
+ el("span", { className: "homekind " + tone, textContent: chip }),
644
+ document.createTextNode(` · ${whereOf(e)} · ${sub}`),
645
+ ]),
444
646
  ]),
445
647
  el("div", { className: "homerunlog" }, action ? [action] : []),
446
648
  ],