@nanocollective/roster 0.1.0-alpha.8 → 0.1.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/dist/cli.js +4084 -1936
- package/dist/worker/assets/assets/css/base.css +312 -0
- package/dist/worker/assets/assets/css/brain.css +116 -0
- package/dist/worker/assets/assets/css/diff.css +33 -0
- package/dist/worker/assets/assets/css/graph.css +39 -0
- package/dist/worker/assets/assets/css/health.css +75 -0
- package/dist/worker/assets/assets/css/home.css +101 -0
- package/dist/worker/assets/assets/css/inbox.css +199 -0
- package/dist/worker/assets/assets/css/layout.css +175 -0
- package/dist/worker/assets/assets/css/markdown.css +96 -0
- package/dist/worker/assets/assets/css/runs.css +13 -0
- package/dist/worker/assets/assets/css/search.css +48 -0
- package/dist/worker/assets/assets/css/setup.css +194 -0
- package/dist/worker/assets/assets/js/api.js +161 -0
- package/dist/worker/assets/assets/js/app.js +465 -0
- package/dist/worker/assets/assets/js/dialog.js +196 -0
- package/dist/worker/assets/assets/js/dom.js +131 -0
- package/dist/worker/assets/assets/js/homesort.js +174 -0
- package/dist/worker/assets/assets/js/icons.js +142 -0
- package/dist/worker/assets/assets/js/inflight.js +18 -0
- package/dist/worker/assets/assets/js/lightbox.js +273 -0
- package/dist/worker/assets/assets/js/md.js +406 -0
- package/dist/worker/assets/assets/js/mdedit.js +84 -0
- package/dist/worker/assets/assets/js/mention.js +264 -0
- package/dist/worker/assets/assets/js/readiness.js +70 -0
- package/dist/worker/assets/assets/js/refresh.js +197 -0
- package/dist/worker/assets/assets/js/router.js +20 -0
- package/dist/worker/assets/assets/js/search.js +366 -0
- package/dist/worker/assets/assets/js/state.js +213 -0
- package/dist/worker/assets/assets/js/textdiff.js +96 -0
- package/dist/worker/assets/assets/js/views/app.js +145 -0
- package/dist/worker/assets/assets/js/views/brain.js +260 -0
- package/dist/worker/assets/assets/js/views/changed.js +157 -0
- package/dist/worker/assets/assets/js/views/checklist.js +115 -0
- package/dist/worker/assets/assets/js/views/credential.js +84 -0
- package/dist/worker/assets/assets/js/views/docs.js +174 -0
- package/dist/worker/assets/assets/js/views/files.js +139 -0
- package/dist/worker/assets/assets/js/views/graph.js +436 -0
- package/dist/worker/assets/assets/js/views/health.js +304 -0
- package/dist/worker/assets/assets/js/views/hire.js +593 -0
- package/dist/worker/assets/assets/js/views/home.js +585 -0
- package/dist/worker/assets/assets/js/views/inbox.js +1558 -0
- package/dist/worker/assets/assets/js/views/memory.js +150 -0
- package/dist/worker/assets/assets/js/views/org.js +195 -0
- package/dist/worker/assets/assets/js/views/orgedit.js +240 -0
- package/dist/worker/assets/assets/js/views/paste.js +216 -0
- package/dist/worker/assets/assets/js/views/prompt.js +457 -0
- package/dist/worker/assets/assets/js/views/repos.js +97 -0
- package/dist/worker/assets/assets/js/views/runonce.js +94 -0
- package/dist/worker/assets/assets/js/views/runs.js +182 -0
- package/dist/worker/assets/assets/js/views/setup.js +557 -0
- package/dist/worker/assets/assets/js/views/staff.js +291 -0
- package/dist/worker/assets/assets/js/views/todo.js +62 -0
- package/dist/worker/assets/assets/js/yaml.js +134 -0
- package/dist/worker/assets/docs-images/brain.jpg +0 -0
- package/dist/worker/assets/docs-images/home.jpg +0 -0
- package/dist/worker/assets/docs-images/org.jpg +0 -0
- package/dist/worker/assets/docs-images/prompt.jpg +0 -0
- package/dist/worker/assets/docs-images/setup-org.jpg +0 -0
- package/dist/worker/assets/docs-images/setup-plan.jpg +0 -0
- package/dist/worker/assets/docs-images/staff.jpg +0 -0
- package/dist/worker/assets/index.html +82 -0
- package/dist/worker/index.js +4430 -0
- package/docs/README.md +2 -2
- package/docs/architecture.md +1 -1
- package/docs/charters/analyst.md +65 -0
- package/docs/charters/community.md +63 -0
- package/docs/charters/designer.md +65 -0
- package/docs/charters/devops.md +65 -0
- package/docs/charters/pm.md +70 -0
- package/docs/charters/qa.md +65 -0
- package/docs/charters/writer.md +63 -0
- package/docs/commands.md +13 -3
- package/docs/concepts.md +33 -20
- package/docs/cost.md +3 -3
- package/docs/developing.md +27 -9
- package/docs/doctor-codes.md +3 -1
- package/docs/export.md +2 -0
- package/docs/getting-started.md +44 -27
- package/docs/hosting.md +89 -43
- package/docs/images/brain.jpg +0 -0
- package/docs/images/home.jpg +0 -0
- package/docs/images/org.jpg +0 -0
- package/docs/images/prompt.jpg +0 -0
- package/docs/images/staff.jpg +0 -0
- package/docs/manual-steps.md +3 -2
- package/docs/org-yaml.md +3 -0
- package/docs/portal.md +143 -45
- package/docs/prompts.md +6 -0
- package/docs/security.md +57 -11
- package/docs/session-workflow.md +14 -0
- package/docs/staff-yaml.md +17 -1
- package/docs/upgrading.md +3 -3
- package/docs/writing-a-charter.md +19 -6
- package/package.json +4 -3
- package/templates/brain/.github/workflows/%%STAFF%%-daily.yaml +20 -1
- package/templates/brain/.github/workflows/%%STAFF%%-mention.yaml +53 -13
- package/templates/brain/staff.yaml +4 -1
- package/templates/briefs/amend.md +4 -3
- package/templates/briefs/priorities.md +46 -0
- package/templates/ops/.github/workflows/session.yaml +137 -3
- package/templates/ops/compose.mjs +35 -8
- package/templates/ops/org/operating.md +29 -10
- package/templates/ops/prompts/daily.md +23 -4
- package/templates/ops/prompts/mention.md +19 -0
- package/templates/ops/run-record.mjs +5 -3
- package/templates/portal/css/base.css +34 -0
- package/templates/portal/css/health.css +14 -1
- package/templates/portal/css/home.css +101 -0
- package/templates/portal/css/inbox.css +21 -4
- package/templates/portal/css/layout.css +29 -3
- package/templates/portal/css/markdown.css +19 -0
- package/templates/portal/css/search.css +48 -0
- package/templates/portal/css/setup.css +79 -4
- package/templates/portal/index.html +15 -9
- package/templates/portal/js/api.js +30 -4
- package/templates/portal/js/app.js +90 -7
- package/templates/portal/js/dialog.js +36 -0
- package/templates/portal/js/homesort.js +174 -0
- package/templates/portal/js/icons.js +41 -0
- package/templates/portal/js/inflight.js +18 -0
- package/templates/portal/js/md.js +5 -2
- package/templates/portal/js/mdedit.js +84 -0
- package/templates/portal/js/readiness.js +70 -0
- package/templates/portal/js/refresh.js +10 -2
- package/templates/portal/js/search.js +366 -0
- package/templates/portal/js/state.js +11 -5
- package/templates/portal/js/views/app.js +1 -2
- package/templates/portal/js/views/brain.js +1 -1
- package/templates/portal/js/views/checklist.js +19 -4
- package/templates/portal/js/views/credential.js +42 -51
- package/templates/portal/js/views/health.js +11 -6
- package/templates/portal/js/views/hire.js +593 -0
- package/templates/portal/js/views/home.js +585 -0
- package/templates/portal/js/views/inbox.js +237 -68
- package/templates/portal/js/views/org.js +31 -111
- package/templates/portal/js/views/orgedit.js +240 -0
- package/templates/portal/js/views/paste.js +111 -66
- package/templates/portal/js/views/prompt.js +94 -40
- package/templates/portal/js/views/repos.js +10 -10
- package/templates/portal/js/views/runs.js +21 -4
- package/templates/portal/js/views/setup.js +130 -163
- package/templates/portal/js/views/staff.js +181 -301
- package/templates/portal/js/views/todo.js +62 -0
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { getLabels, getPr, getThread, post, upload } from "../api.js";
|
|
4
4
|
import { askText, askYes } from "../dialog.js";
|
|
5
5
|
import { ago, el, esc, markCurrent, skeleton } from "../dom.js";
|
|
6
|
-
import { icon, iconHTML } from "../icons.js";
|
|
6
|
+
import { icon, iconHTML, staffIcon } from "../icons.js";
|
|
7
7
|
import { mdlite } from "../md.js";
|
|
8
8
|
import { attachMentions } from "../mention.js";
|
|
9
9
|
import { ensureInbox, refreshAll, stampCounts } from "../refresh.js";
|
|
@@ -92,6 +92,10 @@ export function belongsTo(item, s) {
|
|
|
92
92
|
return false;
|
|
93
93
|
}
|
|
94
94
|
|
|
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. */
|
|
97
|
+
const THREADS = new Map();
|
|
98
|
+
|
|
95
99
|
export const viewInbox = (m) => inboxScreen(m, {});
|
|
96
100
|
|
|
97
101
|
/**
|
|
@@ -104,16 +108,36 @@ export const viewInbox = (m) => inboxScreen(m, {});
|
|
|
104
108
|
*/
|
|
105
109
|
export const viewPrs = (m) => inboxScreen(m, { prs: true });
|
|
106
110
|
|
|
111
|
+
/**
|
|
112
|
+
* One thread, drawn into `host` on its own: the header, its actions, the reply box and the
|
|
113
|
+
* conversation, with no list beside it. Home opens a card this way, in a side sheet.
|
|
114
|
+
*
|
|
115
|
+
* It is the same screen as Trackers, built off-page, with only its viewer kept. Replying,
|
|
116
|
+
* closing and merging repaint a list nobody can see and then reopen this thread, which is
|
|
117
|
+
* what they do on Trackers too.
|
|
118
|
+
*/
|
|
119
|
+
export function threadInto(host, ref) {
|
|
120
|
+
/* Read fresh. Home can be minutes behind GitHub, and the reason to open something is usually
|
|
121
|
+
to read the reply that made its row change. Reading it again also brings the row up to
|
|
122
|
+
date, so Home is right when the sheet closes. */
|
|
123
|
+
const item = (S.inbox?.items ?? []).find((i) => i.repo === ref.repo && i.number === ref.number);
|
|
124
|
+
if (item) {
|
|
125
|
+
THREADS.delete(item.repo + "#" + item.number);
|
|
126
|
+
item.partial = true;
|
|
127
|
+
}
|
|
128
|
+
host.append(inboxScreen(el("div"), { prs: ref.kind === "pr", only: ref }));
|
|
129
|
+
}
|
|
130
|
+
|
|
107
131
|
function inboxScreen(m, opts) {
|
|
108
132
|
/* "Pending work", not "Pull requests". Every one of these is a piece of work a staff member
|
|
109
133
|
has finished and cannot land on their own, which is the thing you are being asked about.
|
|
110
134
|
That it arrives as a pull request is how it is delivered, not what it is. */
|
|
111
|
-
m.append(el("h1", { textContent: opts.prs ? "Pending work" : "
|
|
135
|
+
m.append(el("h1", { textContent: opts.prs ? "Pending work" : "Trackers" }));
|
|
112
136
|
const sub = el("p", {
|
|
113
137
|
className: "sub",
|
|
114
138
|
textContent: opts.prs
|
|
115
139
|
? "Work the staff have finished and cannot land themselves."
|
|
116
|
-
: "
|
|
140
|
+
: "Every issue on each staff member's tracker and the product repos. What needs you is on Home.",
|
|
117
141
|
});
|
|
118
142
|
m.append(sub);
|
|
119
143
|
|
|
@@ -122,37 +146,25 @@ function inboxScreen(m, opts) {
|
|
|
122
146
|
placeholder: "Filter by title, label, repo…",
|
|
123
147
|
value: S.query,
|
|
124
148
|
});
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
el("option", { value: "all", textContent: "Open and closed" }),
|
|
141
|
-
);
|
|
142
|
-
state.value = S.inboxState;
|
|
143
|
-
|
|
144
|
-
const whose = el("select", {
|
|
145
|
-
title: "Whose work: their brain repo, anything their bot wrote, and anything addressed to them",
|
|
146
|
-
});
|
|
147
|
-
whose.append(
|
|
148
|
-
el("option", { value: "", textContent: "Everyone" }),
|
|
149
|
-
...S.data.staff.map((s) => el("option", { value: s.handle, textContent: s.name })),
|
|
150
|
-
);
|
|
151
|
-
whose.value = S.inboxStaff;
|
|
149
|
+
/* Open or closed, as a toggle. Who and what (a staff member, what is on you, decisions)
|
|
150
|
+
moved to the sidebar under Inbox, where a row of dropdowns used to be. */
|
|
151
|
+
if (S.inboxState === "all") S.inboxState = "";
|
|
152
|
+
const toggle = el("div", { className: "modes inboxstate" });
|
|
153
|
+
for (const [value, label] of [["", "Open"], ["closed", "Closed"]]) {
|
|
154
|
+
const b = el("button", { className: "mode", textContent: label });
|
|
155
|
+
b.classList.toggle("on", (S.inboxState || "") === value);
|
|
156
|
+
b.onclick = () => {
|
|
157
|
+
S.inboxState = value;
|
|
158
|
+
for (const x of toggle.children) x.classList.toggle("on", x === b);
|
|
159
|
+
writeHash(false);
|
|
160
|
+
paint();
|
|
161
|
+
};
|
|
162
|
+
toggle.append(b);
|
|
163
|
+
}
|
|
152
164
|
|
|
153
165
|
const refresh = el("button", { className: "iconbtn", title: "Refresh from GitHub" });
|
|
154
166
|
refresh.innerHTML = '<span class="sync">' + iconHTML("refresh") + "</span>";
|
|
155
|
-
const controls = [search,
|
|
167
|
+
const controls = [search, toggle, refresh];
|
|
156
168
|
// A pull request comes from a branch, so there is nothing here that could open one.
|
|
157
169
|
if (!opts.prs) {
|
|
158
170
|
const newBtn = el("button", { className: "ghbtn", textContent: "New issue" });
|
|
@@ -162,7 +174,7 @@ function inboxScreen(m, opts) {
|
|
|
162
174
|
};
|
|
163
175
|
controls.push(newBtn);
|
|
164
176
|
}
|
|
165
|
-
m.append(el("div", { className: "row", style: "margin-bottom:16px" }, controls));
|
|
177
|
+
m.append(el("div", { className: "row inboxbar", style: "margin-bottom:16px" }, controls));
|
|
166
178
|
|
|
167
179
|
const split = el("div", { className: "split" });
|
|
168
180
|
const list = el("div", { className: "tree" });
|
|
@@ -171,16 +183,18 @@ function inboxScreen(m, opts) {
|
|
|
171
183
|
m.append(split);
|
|
172
184
|
|
|
173
185
|
search.oninput = () => { S.query = search.value; writeHash(false); paint(); };
|
|
174
|
-
scope.onchange = () => { S.inboxFilter = scope.value; writeHash(false); paint(); };
|
|
175
|
-
whose.onchange = () => { S.inboxStaff = whose.value; writeHash(false); paint(); };
|
|
176
|
-
state.onchange = () => { S.inboxState = state.value; writeHash(false); paint(); };
|
|
177
186
|
refresh.onclick = () => { refresh.classList.add("spin"); load(true); };
|
|
178
187
|
|
|
179
188
|
if (S.inbox) { stampCounts(); paint(); restore(); } else load(false);
|
|
189
|
+
if (opts.only) return viewer;
|
|
180
190
|
|
|
181
191
|
/** A `?t=` in the URL names a thread. It used to be read into the state and then never
|
|
182
192
|
acted on, because only the already-loaded branch opened one. */
|
|
183
193
|
function restore() {
|
|
194
|
+
if (opts.only) {
|
|
195
|
+
openThread(opts.only);
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
184
198
|
if (!S.inboxOpen) return;
|
|
185
199
|
// The two screens share one open thread, and each holds half the org. Whatever was open on
|
|
186
200
|
// the other one is not in this list, so it is dropped rather than opened beside it.
|
|
@@ -245,12 +259,22 @@ function inboxScreen(m, opts) {
|
|
|
245
259
|
// "On you" is on any of the humans this org answers to, not only the first one.
|
|
246
260
|
const onAHuman = (i) => (i.assignees ?? []).some(isHuman);
|
|
247
261
|
|
|
248
|
-
|
|
262
|
+
// The sidebar's filters are the inbox's. Pending work has no control for them, so it ignores them.
|
|
263
|
+
const staffPick = opts.prs ? "" : S.inboxStaff;
|
|
264
|
+
// "Issues" is the product repos: every repo a staff member works in.
|
|
265
|
+
const products = new Set(S.data.staff.flatMap((s) => s.worksIn ?? []));
|
|
266
|
+
const issuesOnly = staffPick === "@issues";
|
|
267
|
+
const unreadOnly = staffPick === "@unread";
|
|
268
|
+
const whoseStaff = staffPick && !issuesOnly ? S.data.staff.find((s) => s.handle === staffPick) : null;
|
|
249
269
|
/* The two screens partition the org rather than overlap on it. Pending work is every pull
|
|
250
270
|
request; the inbox is everything else. An inbox that also listed the PRs said the same
|
|
251
271
|
thing twice and made the badge beside it a number you could not act on. */
|
|
252
272
|
const mine = S.inbox.items
|
|
253
|
-
|
|
273
|
+
/* A staff member's link is their tracker: what is in their repo, whoever filed it. Matching
|
|
274
|
+
on who filed or was named put an issue the CMO filed for the CTO under both of them. */
|
|
275
|
+
.filter((i) =>
|
|
276
|
+
unreadOnly ? Boolean(i.unread) : issuesOnly ? products.has(i.repo) : !whoseStaff || i.repo === whoseStaff.brain,
|
|
277
|
+
)
|
|
254
278
|
.filter((i) => (i.kind === "pr") === !!opts.prs);
|
|
255
279
|
const isOpen = (i) => i.state === "OPEN";
|
|
256
280
|
const scoped = mine.filter(
|
|
@@ -261,8 +285,9 @@ function inboxScreen(m, opts) {
|
|
|
261
285
|
(i) => !q || (i.title + " " + i.repo + " " + i.labels.join(" ") + " #" + i.number)
|
|
262
286
|
.toLowerCase().includes(q),
|
|
263
287
|
);
|
|
264
|
-
|
|
265
|
-
|
|
288
|
+
const filter = opts.prs ? "" : S.inboxFilter;
|
|
289
|
+
if (filter === "mine") items = items.filter(onAHuman);
|
|
290
|
+
else if (filter === "decision") items = items.filter((i) => i.labels.includes("decision"));
|
|
266
291
|
/* `s=pr` was the inbox's "Open work (PRs)" scope, and Pending work is now that screen. An
|
|
267
292
|
old bookmark carrying it is ignored rather than honoured into an empty list. */
|
|
268
293
|
|
|
@@ -298,9 +323,15 @@ function inboxScreen(m, opts) {
|
|
|
298
323
|
list.append(el("div", { className: "tdir err", textContent: e }));
|
|
299
324
|
}
|
|
300
325
|
|
|
301
|
-
//
|
|
302
|
-
// happened to sort first; the project moves onto the row instead.
|
|
303
|
-
items = items
|
|
326
|
+
// Unread first, then newest first, flat. Grouping by repo buried a fresh comment under
|
|
327
|
+
// whichever project happened to sort first; the project moves onto the row instead.
|
|
328
|
+
items = items
|
|
329
|
+
.slice()
|
|
330
|
+
.sort(
|
|
331
|
+
(a, b) =>
|
|
332
|
+
Number(Boolean(b.unread)) - Number(Boolean(a.unread)) ||
|
|
333
|
+
String(b.updatedAt).localeCompare(String(a.updatedAt)),
|
|
334
|
+
);
|
|
304
335
|
if (!items.length) {
|
|
305
336
|
list.append(el("p", { className: "empty", textContent: "Nothing matches." }));
|
|
306
337
|
return;
|
|
@@ -308,7 +339,7 @@ function inboxScreen(m, opts) {
|
|
|
308
339
|
|
|
309
340
|
for (const i of items) {
|
|
310
341
|
const shutState = i.state === "MERGED" ? "merged" : i.state === "OPEN" ? "" : "closed";
|
|
311
|
-
const b = el("button", { className: "irow" + (shutState ? " shut" : "") });
|
|
342
|
+
const b = el("button", { className: "irow" + (shutState ? " shut" : "") + (i.unread ? " unread" : "") });
|
|
312
343
|
const yours = onAHuman(i);
|
|
313
344
|
const chips = i.labels
|
|
314
345
|
.slice(0, 3)
|
|
@@ -335,9 +366,9 @@ function inboxScreen(m, opts) {
|
|
|
335
366
|
: "") +
|
|
336
367
|
// How much conversation is on a thread, which is most of what tells a live one from
|
|
337
368
|
// something that was filed and never answered.
|
|
338
|
-
(i.comments.length
|
|
339
|
-
? '<span class="cc" title="' + i.comments.length + ' comments">' +
|
|
340
|
-
iconHTML("review") + i.comments.length + "</span>"
|
|
369
|
+
((i.commentCount ?? i.comments.length)
|
|
370
|
+
? '<span class="cc" title="' + (i.commentCount ?? i.comments.length) + ' comments">' +
|
|
371
|
+
iconHTML("review") + (i.commentCount ?? i.comments.length) + "</span>"
|
|
341
372
|
: "") +
|
|
342
373
|
chips +
|
|
343
374
|
'<span class="when">' + ago(i.updatedAt) + "</span>" +
|
|
@@ -367,22 +398,63 @@ function inboxScreen(m, opts) {
|
|
|
367
398
|
}
|
|
368
399
|
const row = list.querySelector('[data-ref="' + item.repo + "#" + item.number + '"]');
|
|
369
400
|
if (row) markCurrent(list, row);
|
|
401
|
+
// Opening it is reading it: cleared here at once, and on GitHub in the background.
|
|
402
|
+
if (item.unread) {
|
|
403
|
+
const thread = item.unread.thread;
|
|
404
|
+
item.unread = null;
|
|
405
|
+
row?.classList.remove("unread");
|
|
406
|
+
stampCounts();
|
|
407
|
+
post({ thread, ref: item.repo + "#" + item.number }, "/api/notifications/read").catch(() => {});
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/* The list carries no bodies or timelines (carrying them cost most of an hour's GitHub
|
|
411
|
+
allowance per load), so a thread is read when it is opened, and kept until GitHub says
|
|
412
|
+
it has changed. Reopening one costs nothing. */
|
|
413
|
+
if (item.partial) {
|
|
414
|
+
const key = item.repo + "#" + item.number;
|
|
415
|
+
const kept = THREADS.get(key);
|
|
416
|
+
const keep = { role: item.role, unread: item.unread };
|
|
417
|
+
if (kept && kept.updatedAt === item.updatedAt) {
|
|
418
|
+
Object.assign(item, kept, keep, { partial: false });
|
|
419
|
+
} else {
|
|
420
|
+
viewer.dataset.want = key;
|
|
421
|
+
viewer.replaceChildren(...skeleton("head", 1), ...skeleton("line", 8));
|
|
422
|
+
getThread(item.repo, item.number, item.kind)
|
|
423
|
+
.then((fresh) => {
|
|
424
|
+
if (!fresh || fresh.error) throw new Error(fresh?.error ?? "could not read it");
|
|
425
|
+
THREADS.set(key, fresh);
|
|
426
|
+
Object.assign(item, fresh, keep, { partial: false });
|
|
427
|
+
})
|
|
428
|
+
.catch((e) => {
|
|
429
|
+
item.partial = false;
|
|
430
|
+
item.loadError = String(e.message || e);
|
|
431
|
+
})
|
|
432
|
+
.finally(() => {
|
|
433
|
+
// Somebody may have opened another thread while this one was loading.
|
|
434
|
+
if (viewer.dataset.want === key) openThread(ref);
|
|
435
|
+
});
|
|
436
|
+
return;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
370
439
|
|
|
371
440
|
const head = el("div", { className: "thead" });
|
|
372
441
|
head.innerHTML =
|
|
373
442
|
'<div class="meta">' + esc(item.repo) + " · " + (item.kind === "pr" ? "PR " : "") + "#" + item.number +
|
|
374
443
|
' · <span class="' + (item.state === "OPEN" ? "ok" : "") + '">' + esc(item.state) + "</span>" +
|
|
375
|
-
" · " + esc(item.author) + " · " + ago(item.updatedAt) +
|
|
444
|
+
" · " + esc(item.author) + " · " + ago(item.updatedAt) +
|
|
445
|
+
// The labels sit on this line, after the time, rather than taking a line of their own.
|
|
446
|
+
(item.labels.length
|
|
447
|
+
? '<span class="tmetalabels">' +
|
|
448
|
+
item.labels.map((l) => '<span class="chip ' + tone(l) + '">' + esc(l) + "</span>").join("") +
|
|
449
|
+
"</span>"
|
|
450
|
+
: "") +
|
|
451
|
+
"</div>" +
|
|
376
452
|
"<h3>" + esc(item.title) + "</h3>" +
|
|
377
453
|
(item.mergeable === "CONFLICTING"
|
|
378
454
|
? '<p class="tconflict">This branch conflicts with its base and cannot be merged ' +
|
|
379
455
|
"until someone rebases or merges the base into it.</p>"
|
|
380
456
|
: "") +
|
|
381
|
-
|
|
382
|
-
? '<div class="row tlabels">' +
|
|
383
|
-
item.labels.map((l) => '<span class="chip ' + tone(l) + '">' + esc(l) + "</span>").join("") +
|
|
384
|
-
"</div>"
|
|
385
|
-
: "");
|
|
457
|
+
"";
|
|
386
458
|
head.append(threadActions(item));
|
|
387
459
|
delete viewer.dataset.wait;
|
|
388
460
|
viewer.replaceChildren(head);
|
|
@@ -393,6 +465,11 @@ function inboxScreen(m, opts) {
|
|
|
393
465
|
for a wrapper that would only ever hold one thing. */
|
|
394
466
|
const pane = item.kind === "pr" ? el("div") : viewer;
|
|
395
467
|
if (item.kind === "pr") viewer.append(prTabs(item, pane), pane);
|
|
468
|
+
if (item.loadError) {
|
|
469
|
+
pane.append(el("p", { className: "err", textContent: "Couldn't load the conversation: " + item.loadError }));
|
|
470
|
+
delete item.loadError;
|
|
471
|
+
item.partial = true; // so opening it again tries again
|
|
472
|
+
}
|
|
396
473
|
conversation(pane, item);
|
|
397
474
|
viewer.scrollTop = 0;
|
|
398
475
|
}
|
|
@@ -575,10 +652,11 @@ function inboxScreen(m, opts) {
|
|
|
575
652
|
status.textContent = msg ?? "";
|
|
576
653
|
status.className = "meta";
|
|
577
654
|
};
|
|
655
|
+
// busy(false) clears the status line, so it goes first: the other way round wiped the
|
|
656
|
+
// error as it was written, and a refused merge looked like nothing happening at all.
|
|
578
657
|
const failed = (e) => {
|
|
579
|
-
status.textContent = e.message;
|
|
580
|
-
status.className = "meta err";
|
|
581
658
|
busy(false);
|
|
659
|
+
status.textContent = e.message;
|
|
582
660
|
status.className = "meta err";
|
|
583
661
|
};
|
|
584
662
|
|
|
@@ -673,7 +751,20 @@ function inboxScreen(m, opts) {
|
|
|
673
751
|
body: body || undefined,
|
|
674
752
|
});
|
|
675
753
|
DRAFTS.delete(key);
|
|
676
|
-
|
|
754
|
+
/* What changed is known, so it is changed here rather than re-reading every repo,
|
|
755
|
+
which redrew the whole inbox for one issue. The next refresh confirms it. */
|
|
756
|
+
const me = humansOf()[0]?.github ?? "you";
|
|
757
|
+
const now = new Date().toISOString();
|
|
758
|
+
item.events = [
|
|
759
|
+
...(item.events ?? []),
|
|
760
|
+
...(body ? [{ type: "comment", actor: me, createdAt: now, body }] : []),
|
|
761
|
+
{ type: closing ? "closed" : "reopened", actor: me, createdAt: now },
|
|
762
|
+
];
|
|
763
|
+
item.state = closing ? "CLOSED" : "OPEN";
|
|
764
|
+
item.updatedAt = now;
|
|
765
|
+
stampCounts();
|
|
766
|
+
paint();
|
|
767
|
+
openThread({ repo: item.repo, number: item.number, kind: item.kind });
|
|
677
768
|
} catch (e) { failed(e); }
|
|
678
769
|
};
|
|
679
770
|
buttons.push(closeBtn);
|
|
@@ -701,9 +792,31 @@ function inboxScreen(m, opts) {
|
|
|
701
792
|
busy(true, "merging…");
|
|
702
793
|
try {
|
|
703
794
|
await post({ action: "merge", repo: item.repo, number: item.number });
|
|
704
|
-
|
|
795
|
+
// As with closing: the change is known, so it is made here rather than re-reading every repo.
|
|
796
|
+
item.state = "MERGED";
|
|
797
|
+
item.updatedAt = new Date().toISOString();
|
|
798
|
+
stampCounts();
|
|
799
|
+
paint();
|
|
800
|
+
openThread({ repo: item.repo, number: item.number, kind: item.kind });
|
|
705
801
|
} catch (e) { failed(e); }
|
|
706
802
|
};
|
|
803
|
+
/* The branch rules want an approving review before a merge. Approve is your review,
|
|
804
|
+
given on purpose; Merge never gives it for you, so it waits until there is one. */
|
|
805
|
+
if (item.reviewDecision === "REVIEW_REQUIRED" && item.mergeable !== "CONFLICTING") {
|
|
806
|
+
merge.disabled = true;
|
|
807
|
+
merge.title = "Approve it first: the branch rules need an approving review";
|
|
808
|
+
const approve = el("button", { className: "ghbtn primary", textContent: "Approve" });
|
|
809
|
+
approve.onclick = async () => {
|
|
810
|
+
busy(true, "approving…");
|
|
811
|
+
try {
|
|
812
|
+
await post({ action: "approve", repo: item.repo, number: item.number });
|
|
813
|
+
item.reviewDecision = "APPROVED";
|
|
814
|
+
openThread({ repo: item.repo, number: item.number, kind: item.kind });
|
|
815
|
+
} catch (e) { failed(e); }
|
|
816
|
+
};
|
|
817
|
+
buttons.push(approve);
|
|
818
|
+
row.append(approve);
|
|
819
|
+
}
|
|
707
820
|
buttons.push(merge);
|
|
708
821
|
row.append(merge);
|
|
709
822
|
}
|
|
@@ -731,7 +844,12 @@ function inboxScreen(m, opts) {
|
|
|
731
844
|
const at = S.inbox.items.findIndex(
|
|
732
845
|
(i) => i.repo === item.repo && i.number === item.number,
|
|
733
846
|
);
|
|
734
|
-
if (at >= 0)
|
|
847
|
+
if (at >= 0) {
|
|
848
|
+
const old = S.inbox.items[at];
|
|
849
|
+
THREADS.set(item.repo + "#" + item.number, fresh);
|
|
850
|
+
// A single thread does not know which part of the org it is in, or whether it is unread.
|
|
851
|
+
S.inbox.items[at] = { ...old, ...fresh, role: old.role, unread: old.unread, partial: false };
|
|
852
|
+
}
|
|
735
853
|
}
|
|
736
854
|
} catch {
|
|
737
855
|
/* the comment posted; a stale pane is not worth an error */
|
|
@@ -767,6 +885,19 @@ function inboxScreen(m, opts) {
|
|
|
767
885
|
* you are still typing and the button has to stay as it was; once it closes there is a request
|
|
768
886
|
* in flight against GitHub that can take seconds, and that is what needs saying.
|
|
769
887
|
*/
|
|
888
|
+
/**
|
|
889
|
+
* Who a reply is for, by default: the staff member whose tracker the issue is on, or whose App
|
|
890
|
+
* opened it. They are only woken by an @mention, so a reply without one reached nobody.
|
|
891
|
+
*/
|
|
892
|
+
export function addressee(item) {
|
|
893
|
+
const staff = S.data?.staff ?? [];
|
|
894
|
+
const s =
|
|
895
|
+
staff.find((x) => x.brain === item.repo) ??
|
|
896
|
+
staff.find((x) => (x.soloBots ?? []).includes(item.author));
|
|
897
|
+
if (!s) return "";
|
|
898
|
+
return (s.mention || "@" + s.handle) + " ";
|
|
899
|
+
}
|
|
900
|
+
|
|
770
901
|
async function openReply(item, anchor, onSend) {
|
|
771
902
|
const key = item.repo + "#" + item.number + (anchor ? " · " + anchor.path : "");
|
|
772
903
|
let deaf = null;
|
|
@@ -775,7 +906,7 @@ async function openReply(item, anchor, onSend) {
|
|
|
775
906
|
title: "Reply to " + item.repo + " #" + item.number,
|
|
776
907
|
hint: anchor ? anchor.path : item.title,
|
|
777
908
|
confirm: "Comment",
|
|
778
|
-
value: DRAFTS.get(key) ??
|
|
909
|
+
value: DRAFTS.get(key) ?? addressee(item),
|
|
779
910
|
/* It goes out through whoever's `gh` is signed in here, which is only knowably one person
|
|
780
911
|
when the org has one. With two it would be a guess, and a wrong name on a reply box is
|
|
781
912
|
worse than no name. */
|
|
@@ -786,6 +917,10 @@ async function openReply(item, anchor, onSend) {
|
|
|
786
917
|
else DRAFTS.delete(key);
|
|
787
918
|
};
|
|
788
919
|
deaf = deafNote(ta, item, anchor);
|
|
920
|
+
// Typing starts after the @mention, not in front of it.
|
|
921
|
+
setTimeout(() => {
|
|
922
|
+
ta.selectionStart = ta.selectionEnd = ta.value.length;
|
|
923
|
+
}, 0);
|
|
789
924
|
return el("div", {}, [attachBox(ta, () => item.repo).node, deaf.node]);
|
|
790
925
|
},
|
|
791
926
|
});
|
|
@@ -1054,15 +1189,36 @@ function xref(source, item, openThread) {
|
|
|
1054
1189
|
return b;
|
|
1055
1190
|
}
|
|
1056
1191
|
|
|
1192
|
+
/* Who wrote something, as a person would say it: a staff member by their role, with their
|
|
1193
|
+
icon; one of the humans by name; anyone else by their login. */
|
|
1194
|
+
function whoWrote(login) {
|
|
1195
|
+
const s = (S.data?.staff ?? []).find((x) => (x.soloBots ?? []).includes(login));
|
|
1196
|
+
if (s) return { name: s.name, glyph: staffIcon(s), kind: "staff" };
|
|
1197
|
+
if (isHuman(login)) {
|
|
1198
|
+
const h = humansOf().find((x) => x.github === login);
|
|
1199
|
+
return { name: h?.name ?? login, glyph: "person", kind: "human" };
|
|
1200
|
+
}
|
|
1201
|
+
return { name: login || "?", glyph: "person", kind: "other" };
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1204
|
+
/* A comment is a card: a header strip saying who and when, then what they said. As text
|
|
1205
|
+
between thin rules, it was hard to see where one message ended and the next began. */
|
|
1057
1206
|
function comment({ author, when, body, first, repo, badge, reactions }) {
|
|
1058
|
-
const
|
|
1059
|
-
const
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1207
|
+
const who = whoWrote(author);
|
|
1208
|
+
const d = el("div", { className: "cmt " + who.kind + (first ? " first" : "") });
|
|
1209
|
+
const head = el("div", { className: "chead" });
|
|
1210
|
+
head.append(icon(who.glyph, "ic"), el("b", { textContent: who.name }));
|
|
1211
|
+
if (who.name !== author && author) head.append(el("span", { className: "clogin", textContent: author }));
|
|
1212
|
+
if (badge) head.append(el("span", { className: "pill", textContent: badge }));
|
|
1213
|
+
head.append(
|
|
1214
|
+
el("span", { className: "cwhen", title: new Date(when).toLocaleString(), textContent: ago(when) }),
|
|
1215
|
+
);
|
|
1216
|
+
d.append(head);
|
|
1217
|
+
const bodyEl = el("div", { className: "cbodywrap" });
|
|
1218
|
+
bodyEl.append(el("div", { className: "md cbody", innerHTML: mdlite(body || "_no description_", { repo }) }));
|
|
1064
1219
|
const marks = reactionRow(reactions);
|
|
1065
|
-
if (marks)
|
|
1220
|
+
if (marks) bodyEl.append(marks);
|
|
1221
|
+
d.append(bodyEl);
|
|
1066
1222
|
return d;
|
|
1067
1223
|
}
|
|
1068
1224
|
|
|
@@ -1210,9 +1366,22 @@ function newIssueForm(viewer) {
|
|
|
1210
1366
|
body: body.value,
|
|
1211
1367
|
labels: picked.chosen(),
|
|
1212
1368
|
});
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1369
|
+
/* The form is done once GitHub has the issue. What you sent is shown as what it now is,
|
|
1370
|
+
a thread in the inbox, open and selected, rather than a link out to github.com beside
|
|
1371
|
+
a form still holding what you typed. The filters are set so its row is on the list. */
|
|
1372
|
+
const number = Number(String(r.url ?? "").match(/\/issues\/(\d+)/)?.[1]);
|
|
1373
|
+
S.inboxOpen = number ? { repo: s.brain, number, kind: "issue" } : null;
|
|
1374
|
+
S.inboxState = "";
|
|
1375
|
+
S.inboxFilter = "";
|
|
1376
|
+
S.query = "";
|
|
1377
|
+
if (S.inboxStaff && S.inboxStaff !== s.handle) S.inboxStaff = s.handle;
|
|
1378
|
+
writeHash(false);
|
|
1379
|
+
status.textContent = "sent · opening it…";
|
|
1380
|
+
// It is sent either way. A refresh that fails must not read as a send that failed.
|
|
1381
|
+
await refreshAll(false).catch(() => {
|
|
1382
|
+
status.textContent = "sent · refresh to see it";
|
|
1383
|
+
});
|
|
1384
|
+
return;
|
|
1216
1385
|
} catch (e) {
|
|
1217
1386
|
status.textContent = e.message;
|
|
1218
1387
|
status.className = "meta err";
|