@nanocollective/roster 0.1.0-beta.16 → 0.1.0-beta.17

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 (36) hide show
  1. package/dist/{agents-NMGVORU3.js → agents-Q2DSTLOQ.js} +1 -1
  2. package/dist/{chunk-E3EVPK4I.js → chunk-JH3LQ34C.js} +16 -1
  3. package/dist/{chunk-QCKEGMXD.js → chunk-UEZPQ5PV.js} +2 -2
  4. package/dist/cli.js +38 -9
  5. package/dist/{compose-56JIIIHA.js → compose-H43W3QI5.js} +3 -1
  6. package/dist/{connectors-ZVEPXSAR.js → connectors-U5VT5W2I.js} +1 -1
  7. package/dist/worker/assets/assets/css/base.css +4 -0
  8. package/dist/worker/assets/assets/css/home.css +98 -34
  9. package/dist/worker/assets/assets/css/inbox.css +11 -0
  10. package/dist/worker/assets/assets/js/app.js +1 -0
  11. package/dist/worker/assets/assets/js/homesort.js +20 -0
  12. package/dist/worker/assets/assets/js/md.js +7 -2
  13. package/dist/worker/assets/assets/js/refresh.js +4 -2
  14. package/dist/worker/assets/assets/js/report.js +51 -0
  15. package/dist/worker/assets/assets/js/state.js +2 -0
  16. package/dist/worker/assets/assets/js/views/home.js +272 -119
  17. package/dist/worker/assets/assets/js/views/inbox.js +52 -11
  18. package/dist/worker/index.js +58 -8
  19. package/docs/org-yaml.md +15 -0
  20. package/package.json +1 -1
  21. package/templates/ops/compose.mjs +20 -0
  22. package/templates/ops/org/operating.md +10 -0
  23. package/templates/ops/org/voice.md +19 -1
  24. package/templates/ops/prompts/daily.md +27 -6
  25. package/templates/ops/prompts/mention.md +3 -2
  26. package/templates/portal/css/base.css +4 -0
  27. package/templates/portal/css/home.css +98 -34
  28. package/templates/portal/css/inbox.css +11 -0
  29. package/templates/portal/js/app.js +1 -0
  30. package/templates/portal/js/homesort.js +20 -0
  31. package/templates/portal/js/md.js +7 -2
  32. package/templates/portal/js/refresh.js +4 -2
  33. package/templates/portal/js/report.js +51 -0
  34. package/templates/portal/js/state.js +2 -0
  35. package/templates/portal/js/views/home.js +272 -119
  36. package/templates/portal/js/views/inbox.js +52 -11
@@ -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,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
- const reporters = staff.filter((x) => x.brain && x.statusIssue);
59
- if (reporters.length) {
60
- page.append(section("Latest reports"));
61
- page.append(el("div", { className: "card homereports" }, reporters.map((s) => reportRow(s, h.reports))));
62
- }
63
-
64
- page.append(section("Needs you", h.needs.length));
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 (h.needs.length) {
68
- page.append(el("div", { className: "card homelist" }, h.needs.map((e, i) => needRow(e, i === 0))));
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, with a
101
- * button that asks them to bring it up to date now. It is markdown they wrote, with links to the
102
- * work it names. It shows its first few lines; the row opens it in full, and closes it again.
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 a report" });
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 full = openReports.has(s.handle);
133
- const row = el(
134
- "div",
135
- {
136
- className: "homereport" + (r ? " homeclick" : "") + (full ? " full" : ""),
137
- ...(r ? { tabIndex: 0, role: "button", ariaExpanded: String(full) } : {}),
138
- },
139
- [
140
- el("div", { className: "homereportwho" }, [
141
- el("span", { className: "homewho2" }, [icon(staffIcon(s), "ic"), el("b", { textContent: s.name })]),
142
- el("span", { className: "meta" }, [
143
- document.createTextNode((r ? "Updated " + ago(r.at) : "No report yet") + " · "),
144
- issue,
145
- ]),
146
- el("div", { className: "homereportask" }, [ask, note]),
147
- ]),
148
- r
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
- if (!r) return row;
154
- const toggle = () => {
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
- const now = openReports.has(s.handle);
158
- row.classList.toggle("full", now);
159
- row.setAttribute("aria-expanded", String(now));
202
+ repaintInPlace();
160
203
  };
161
- row.onclick = (ev) => {
162
- if (!ev.target.closest("a, button")) toggle();
163
- };
164
- row.onkeydown = (ev) => {
165
- if (ev.target === row && (ev.key === "Enter" || ev.key === " ")) {
166
- ev.preventDefault();
167
- toggle();
168
- }
169
- };
170
- return row;
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 who = el("select", { className: "homewho", ariaLabel: "Who to ask" });
177
- 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) {
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: 2,
183
- 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,
184
238
  });
185
- 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
+ };
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) return;
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("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]),
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
- function needRow(e, first) {
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,105 @@ async function act(note, actions, payload, ok) {
358
479
  }
359
480
  }
360
481
 
361
- /* ------------------------------ working now ----------------------------- */
482
+ /* ---------------------------------- team ---------------------------------- */
362
483
 
363
- /** 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. */
364
488
  function whatRun(r) {
365
- if (r.trigger === "mention") return r.issue ? `answering #${r.issue}` : "answering a mention";
366
- 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";
367
492
  return (
368
- { daily: "daily run", manual: "run started by hand", "follow-on": "follow-on run" }[r.trigger] ??
369
- "run"
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
- function working(staff) {
374
- const box = el("div", { className: "card homeworking" });
375
- if (!S.live) {
376
- box.append(el("p", { className: "homerunwhat", textContent: "Asking GitHub…" }));
377
- return box;
378
- }
379
- for (const s of staff) {
380
- const l = (S.live.staff ?? []).find((x) => x.handle === s.handle);
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 busy = runs.length > 0;
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 what = el("div", { className: "homerunwhat" });
386
- let log = null;
387
- if (!l || l.error) {
388
- what.append(el("span", { className: "err", textContent: l?.error ?? "Could not read their runs." }));
389
- } else if (busy) {
390
- for (const r of runs) {
391
- what.append(el("div", { textContent: `${cap(whatRun(r))} · ${minutes(r.createdAt)} so far` }));
392
- }
393
- log = runs[0].url;
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" : "Starting";
536
+ line = busy ? `${whatRun(r)} · ${minutes(r.createdAt)} so far` : "About to start";
537
+ } else if (failed) {
538
+ word = "Free";
539
+ line = `Their last session stopped with a problem, ${ago(last.updatedAt)}`;
394
540
  } else if (last) {
395
- what.append(
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
- );
541
+ line = `Last finished ${ago(last.updatedAt)}`;
409
542
  }
410
543
 
411
- const state = el("span", {
412
- className: "chip homestate " + (busy ? "ok" : ""),
413
- textContent: busy ? (runs[0].status === "queued" ? "Queued" : "Working") : "Idle",
544
+ const issue = (busy || queued) && runs[0].issue && s.brain ? runs[0].issue : null;
545
+ const card = el("div", {
546
+ className: "orbcard " + state + (issue ? " homeclick" : ""),
547
+ ...(issue ? { tabIndex: 0, role: "button", title: `Open #${issue}` } : {}),
414
548
  });
415
- const actions = el("div", { className: "homerunlog" });
416
- if (log) {
417
- actions.append(
418
- el("a", { className: "ghbtn", href: log, target: "_blank", rel: "noopener", textContent: "Log" }),
549
+ card.style?.setProperty?.("--hue", HUES[i % HUES.length]);
550
+ const orb = el("div", { className: "orb", ariaHidden: "true" }, [
551
+ el("span", { className: "orbglow" }),
552
+ el("span", { className: "orbbody" }, [el("span", { className: "orbswirl" })]),
553
+ el("span", { className: "orbicon" }, [icon(staffIcon(s), "ic")]),
554
+ ]);
555
+ card.append(
556
+ orb,
557
+ el("b", { className: "orbname", textContent: s.name }),
558
+ el("span", { className: "orbstate", textContent: word }),
559
+ el("span", { className: "orbline", textContent: line }),
560
+ );
561
+ const log = runs[0]?.url ?? last?.url;
562
+ if (log && state !== "idle") {
563
+ card.append(
564
+ el("a", { className: "orblog", href: log, target: "_blank", rel: "noopener", textContent: "View log" }),
419
565
  );
420
566
  }
421
-
422
- box.append(
423
- el("div", { className: "homerun" + (busy ? " busy" : "") }, [
424
- el("span", { className: "homewho2" }, [icon(staffIcon(s), "ic"), el("b", { textContent: s.name })]),
425
- state,
426
- what,
427
- actions,
428
- ]),
429
- );
430
- }
567
+ if (issue) {
568
+ const open = () => openThread({ repo: s.brain, number: issue, kind: "issue" });
569
+ card.onclick = (ev) => {
570
+ if (!ev.target.closest("a")) open();
571
+ };
572
+ card.onkeydown = (ev) => {
573
+ if (ev.target === card && (ev.key === "Enter" || ev.key === " ")) {
574
+ ev.preventDefault();
575
+ open();
576
+ }
577
+ };
578
+ }
579
+ box.append(card);
580
+ });
431
581
  return box;
432
582
  }
433
583
 
@@ -466,7 +616,10 @@ function poll() {
466
616
  issuesAt = Date.now();
467
617
  refreshSoon(false);
468
618
  } else if (changed && S.view === "home" && !document.querySelector("dialog[open]")) {
469
- repaintInPlace();
619
+ /* Typing in the ask box is not interrupted by a run starting: only the orbs move. */
620
+ const row = document.querySelector(".hometeam");
621
+ if (row && document.activeElement?.closest?.(".homeaskcard")) row.replaceWith(team(S.data.staff));
622
+ else repaintInPlace();
470
623
  }
471
624
  })
472
625
  .catch(() => {})
@@ -479,7 +632,7 @@ function poll() {
479
632
 
480
633
  /* ------------------------------ your requests ---------------------------- */
481
634
 
482
- /** A card of rows, laid out like Working now. */
635
+ /** A card of rows. */
483
636
  function listBox(rows) {
484
637
  return el("div", { className: "card homeworking" }, rows);
485
638
  }
@@ -93,8 +93,11 @@ export function belongsTo(item, s) {
93
93
  }
94
94
 
95
95
  /* Threads read so far, by repo#number, kept for the session. Each is reused while its
96
- updatedAt matches the list's, so a thread is fetched again only when it has changed. */
96
+ updatedAt matches the list's, so a thread is fetched again only when it has changed, or once
97
+ the signed links to its images (good for five minutes) are about to run out. */
97
98
  const THREADS = new Map();
99
+ const THREAD_AT = new Map();
100
+ const THREAD_FRESH = 4 * 60_000;
98
101
 
99
102
  export const viewInbox = (m) => inboxScreen(m, {});
100
103
 
@@ -423,7 +426,7 @@ function inboxScreen(m, opts) {
423
426
  const key = item.repo + "#" + item.number;
424
427
  const kept = THREADS.get(key);
425
428
  const keep = { role: item.role, unread: item.unread };
426
- if (kept && kept.updatedAt === item.updatedAt) {
429
+ if (kept && kept.updatedAt === item.updatedAt && Date.now() - (THREAD_AT.get(key) ?? 0) < THREAD_FRESH) {
427
430
  Object.assign(item, kept, keep, { partial: false });
428
431
  } else {
429
432
  viewer.dataset.want = key;
@@ -432,6 +435,7 @@ function inboxScreen(m, opts) {
432
435
  .then((fresh) => {
433
436
  if (!fresh || fresh.error) throw new Error(fresh?.error ?? "could not read it");
434
437
  THREADS.set(key, fresh);
438
+ THREAD_AT.set(key, Date.now());
435
439
  Object.assign(item, fresh, keep, { partial: false });
436
440
  })
437
441
  .catch((e) => {
@@ -490,7 +494,22 @@ function inboxScreen(m, opts) {
490
494
  just happened. The title and the actions are in the header, so nothing you need is
491
495
  further down than the first screenful. */
492
496
  const from = pane.children.length;
493
- for (const node of timeline(item, openThread)) pane.append(node);
497
+ const nodes = timeline(item, openThread);
498
+ /* The newest message is what you came for, so it is marked and everything between it and
499
+ the opening post folds behind one button. What happened after it (closed, relabelled)
500
+ stays in view above it, and the opening post stays at the bottom, since it says what
501
+ was asked in the first place. */
502
+ const latest = nodes.findIndex((n) => n.classList?.contains("cmt"));
503
+ if (latest >= 0) {
504
+ nodes[latest].classList.add("latest");
505
+ nodes[latest].querySelector?.(".cwhen")?.before?.(el("span", { className: "pill clatest", textContent: "Latest" }));
506
+ const older = nodes.slice(latest + 1);
507
+ const said = older.filter((n) => n.classList?.contains("cmt")).length;
508
+ if (said) {
509
+ nodes.splice(latest + 1, older.length, earlier(older, said));
510
+ }
511
+ }
512
+ for (const node of nodes) pane.append(node);
494
513
  pane.append(
495
514
  comment({
496
515
  author: item.author, when: item.createdAt, body: item.body, first: true,
@@ -733,9 +752,11 @@ function inboxScreen(m, opts) {
733
752
  };
734
753
  buttons.push(reply);
735
754
 
755
+ /* Closing, in words a person uses: "close" read as shutting the panel. Light red and over
756
+ by Open in GitHub, away from Reply, so it is not pressed on the way to answering. */
736
757
  const closeBtn = el("button", {
737
- className: "ghbtn",
738
- textContent: item.state === "OPEN" ? "Close" : "Reopen",
758
+ className: "ghbtn" + (item.state === "OPEN" ? " danger" : ""),
759
+ textContent: item.state === "OPEN" ? "Mark as completed" : "Reopen",
739
760
  });
740
761
  closeBtn.onclick = async () => {
741
762
  const closing = item.state === "OPEN";
@@ -744,9 +765,9 @@ function inboxScreen(m, opts) {
744
765
  // Closing is the one thing here that is awkward to undo from a phone later, so it asks
745
766
  // — and since it is asking anyway, it takes a parting comment.
746
767
  body = await compose({
747
- title: "Close " + item.repo + " #" + item.number + "?",
748
- hint: "Anything you write here is posted as a comment first. Leave it empty to just close.",
749
- confirm: "Close it",
768
+ title: "Are you sure you want to mark #" + item.number + " as completed?",
769
+ hint: "This closes it. Anything you write here is posted as a comment first.",
770
+ confirm: "Mark as completed",
750
771
  allowEmpty: true,
751
772
  });
752
773
  if (body === null) return;
@@ -776,9 +797,8 @@ function inboxScreen(m, opts) {
776
797
  openThread({ repo: item.repo, number: item.number, kind: item.kind });
777
798
  } catch (e) { failed(e); }
778
799
  };
779
- buttons.push(closeBtn);
780
-
781
800
  const row = el("div", { className: "row tacts" }, buttons);
801
+ buttons.push(closeBtn);
782
802
 
783
803
  /* Merging cannot be undone with another click, so it asks first and names what it is about
784
804
  to merge. It does not ask *how*: squash, merge commit or rebase is a question about git
@@ -833,9 +853,11 @@ function inboxScreen(m, opts) {
833
853
  row.append(status);
834
854
  // Last, and pushed to the far end: it is the way out of this screen rather than one of the
835
855
  // things you do on it. Same shape as the rest, so the row reads as one set of controls.
856
+ closeBtn.classList.add("out");
836
857
  row.append(
858
+ closeBtn,
837
859
  el("a", {
838
- className: "ghbtn out",
860
+ className: "ghbtn",
839
861
  href: item.url,
840
862
  target: "_blank",
841
863
  rel: "noopener",
@@ -856,6 +878,7 @@ function inboxScreen(m, opts) {
856
878
  if (at >= 0) {
857
879
  const old = S.inbox.items[at];
858
880
  THREADS.set(item.repo + "#" + item.number, fresh);
881
+ THREAD_AT.set(item.repo + "#" + item.number, Date.now());
859
882
  // A single thread does not know which part of the org it is in, or whether it is unread.
860
883
  S.inbox.items[at] = { ...old, ...fresh, role: old.role, unread: old.unread, partial: false };
861
884
  } else if (opts.stray && find(item) === opts.stray) {
@@ -1069,6 +1092,24 @@ function timeline(item, openThread) {
1069
1092
  return out;
1070
1093
  }
1071
1094
 
1095
+ /** Older messages in a thread, behind one button that shows them all. */
1096
+ function earlier(nodes, said) {
1097
+ const box = el("div", { className: "tearlier" });
1098
+ const btn = el("button", {
1099
+ className: "tearlierbtn",
1100
+ textContent: "Show " + said + " earlier message" + (said === 1 ? "" : "s"),
1101
+ });
1102
+ btn.setAttribute("aria-expanded", "false");
1103
+ const body = el("div", {}, nodes);
1104
+ body.hidden = true;
1105
+ btn.onclick = () => {
1106
+ body.hidden = false;
1107
+ btn.remove();
1108
+ };
1109
+ box.append(btn, body);
1110
+ return box;
1111
+ }
1112
+
1072
1113
  function folded(events, item, openThread) {
1073
1114
  const box = el("div");
1074
1115
  const btn = el("button", { className: "tevmore" });