@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.
- package/README.md +8 -0
- package/dist/agents-POITEZRI.js +232 -0
- package/dist/chunk-FF2WBNNW.js +370 -0
- package/dist/chunk-GDAJPOHK.js +562 -0
- package/dist/cli.js +3187 -1105
- package/dist/compose-5DBEHSEV.js +17 -0
- package/dist/connectors-5E5ZMGZV.js +23 -0
- package/dist/worker/assets/assets/css/astryx.css +948 -0
- package/dist/worker/assets/assets/css/base.css +64 -110
- package/dist/worker/assets/assets/css/brain.css +26 -2
- package/dist/worker/assets/assets/css/connectors.css +50 -0
- package/dist/worker/assets/assets/css/graph.css +9 -12
- package/dist/worker/assets/assets/css/health.css +4 -7
- package/dist/worker/assets/assets/css/home.css +145 -60
- package/dist/worker/assets/assets/css/inbox.css +11 -0
- package/dist/worker/assets/assets/css/layout.css +16 -20
- package/dist/worker/assets/assets/css/markdown.css +22 -1
- package/dist/worker/assets/assets/css/routines.css +40 -0
- package/dist/worker/assets/assets/css/runs.css +5 -3
- package/dist/worker/assets/assets/css/search.css +3 -6
- package/dist/worker/assets/assets/css/setup.css +3 -15
- package/dist/worker/assets/assets/js/api.js +33 -0
- package/dist/worker/assets/assets/js/app.js +49 -3
- package/dist/worker/assets/assets/js/astryx-ui.js +34 -0
- package/dist/worker/assets/assets/js/homesort.js +28 -21
- package/dist/worker/assets/assets/js/icons.js +6 -0
- package/dist/worker/assets/assets/js/md.js +7 -2
- package/dist/worker/assets/assets/js/refcard.js +216 -0
- package/dist/worker/assets/assets/js/refresh.js +4 -2
- package/dist/worker/assets/assets/js/report.js +51 -0
- package/dist/worker/assets/assets/js/select.js +362 -0
- package/dist/worker/assets/assets/js/state.js +14 -1
- package/dist/worker/assets/assets/js/views/connectors.js +290 -0
- package/dist/worker/assets/assets/js/views/graph.js +67 -28
- package/dist/worker/assets/assets/js/views/home.js +378 -176
- package/dist/worker/assets/assets/js/views/inbox.js +68 -16
- package/dist/worker/assets/assets/js/views/org.js +2 -0
- package/dist/worker/assets/assets/js/views/people.js +109 -0
- package/dist/worker/assets/assets/js/views/routines.js +378 -0
- package/dist/worker/assets/assets/js/views/runs.js +3 -1
- 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 +16 -1
- package/dist/worker/index.js +3972 -963
- package/docs/README.md +2 -0
- package/docs/architecture.md +23 -4
- package/docs/commands.md +111 -9
- package/docs/concepts.md +2 -1
- package/docs/connectors.md +157 -0
- package/docs/cost.md +1 -1
- package/docs/developing.md +3 -3
- package/docs/doctor-codes.md +8 -2
- package/docs/export.md +4 -3
- package/docs/extending.md +1 -1
- package/docs/getting-started.md +20 -3
- package/docs/hosting.md +42 -3
- 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/setup-org.jpg +0 -0
- package/docs/images/setup-plan.jpg +0 -0
- package/docs/images/staff.jpg +0 -0
- package/docs/memory.md +3 -2
- package/docs/org-yaml.md +58 -5
- package/docs/portal.md +43 -10
- package/docs/prompts.md +3 -2
- package/docs/routines.md +65 -0
- package/docs/security.md +35 -4
- package/docs/session-workflow.md +31 -8
- package/docs/staff-yaml.md +7 -3
- package/docs/troubleshooting.md +1 -1
- package/docs/upgrading.md +1 -1
- package/docs/writing-a-charter.md +1 -1
- package/package.json +8 -1
- package/templates/brain/.gitattributes +3 -0
- package/templates/brain/.github/workflows/%%STAFF%%-daily.yaml +24 -15
- package/templates/brain/.github/workflows/%%STAFF%%-mention.yaml +12 -10
- package/templates/brain/CHARTER.md +2 -2
- package/templates/brain/STATE.md +16 -0
- package/templates/brain/memory/INDEX.md +1 -1
- package/templates/brain/staff.yaml +3 -0
- package/templates/ops/.gitattributes +3 -0
- package/templates/ops/.github/workflows/session.yaml +74 -13
- package/templates/ops/agents.mjs +38 -11
- package/templates/ops/compose.mjs +60 -2
- package/templates/ops/connectors.mjs +722 -0
- package/templates/ops/org/operating.md +10 -0
- package/templates/ops/org/voice.md +21 -3
- package/templates/ops/prompts/_identity.md +20 -0
- package/templates/ops/prompts/daily.md +70 -19
- package/templates/ops/prompts/mention.md +7 -2
- package/templates/ops/status-week.mjs +169 -0
- package/templates/portal/css/astryx.css +948 -0
- package/templates/portal/css/base.css +64 -110
- package/templates/portal/css/brain.css +26 -2
- package/templates/portal/css/connectors.css +50 -0
- package/templates/portal/css/graph.css +9 -12
- package/templates/portal/css/health.css +4 -7
- package/templates/portal/css/home.css +145 -60
- package/templates/portal/css/inbox.css +11 -0
- package/templates/portal/css/layout.css +16 -20
- package/templates/portal/css/markdown.css +22 -1
- package/templates/portal/css/routines.css +40 -0
- package/templates/portal/css/runs.css +5 -3
- package/templates/portal/css/search.css +3 -6
- package/templates/portal/css/setup.css +3 -15
- package/templates/portal/index.html +16 -1
- package/templates/portal/js/api.js +33 -0
- package/templates/portal/js/app.js +49 -3
- package/templates/portal/js/astryx-ui.js +34 -0
- package/templates/portal/js/homesort.js +28 -21
- package/templates/portal/js/icons.js +6 -0
- package/templates/portal/js/md.js +7 -2
- package/templates/portal/js/refcard.js +216 -0
- package/templates/portal/js/refresh.js +4 -2
- package/templates/portal/js/report.js +51 -0
- package/templates/portal/js/select.js +362 -0
- package/templates/portal/js/state.js +14 -1
- package/templates/portal/js/views/connectors.js +290 -0
- package/templates/portal/js/views/graph.js +67 -28
- package/templates/portal/js/views/home.js +378 -176
- package/templates/portal/js/views/inbox.js +68 -16
- package/templates/portal/js/views/org.js +2 -0
- package/templates/portal/js/views/people.js +109 -0
- package/templates/portal/js/views/routines.js +378 -0
- package/templates/portal/js/views/runs.js +3 -1
- package/templates/skill/SKILL.md +115 -0
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
/* Home: what needs you,
|
|
1
|
+
/* Home: who is working, what needs you, how each staff member is getting on, what you asked
|
|
2
|
+
* for, and what was closed today.
|
|
2
3
|
*
|
|
3
4
|
* Built from the inbox list and /api/live, sorted by homesort.js, which is where the rule that
|
|
4
5
|
* every open item has exactly one place lives. Clicking an item opens its thread in a side
|
|
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(
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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
|
-
/* -------------------------------
|
|
104
|
+
/* ------------------------------- reports -------------------------------- */
|
|
117
105
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
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: "
|
|
127
|
+
action: "comment",
|
|
139
128
|
repo: s.brain,
|
|
140
|
-
|
|
141
|
-
body: `${s.mention ?? "@" + s.handle}
|
|
129
|
+
number: s.statusIssue,
|
|
130
|
+
body: `${s.mention ?? "@" + s.handle} Report, please.`,
|
|
142
131
|
});
|
|
143
|
-
|
|
144
|
-
note.textContent = `
|
|
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
|
-
|
|
150
|
-
send.disabled = false;
|
|
138
|
+
ask.disabled = false;
|
|
151
139
|
}
|
|
152
140
|
};
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
173
|
-
className: "
|
|
328
|
+
const row = el("div", {
|
|
329
|
+
className: "homeneed" + (item.unread ? " unread" : ""),
|
|
174
330
|
tabIndex: 0,
|
|
175
331
|
role: "button",
|
|
176
332
|
});
|
|
177
|
-
|
|
333
|
+
row.onclick = (ev) => {
|
|
178
334
|
if (!ev.target.closest("button, a, textarea")) openThread(item);
|
|
179
335
|
};
|
|
180
|
-
|
|
181
|
-
if (ev.target ===
|
|
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",
|
|
205
|
-
if (item.due)
|
|
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",
|
|
366
|
+
actions.append(button("Approve", first, () => say(e, "Approved.", note, actions)));
|
|
208
367
|
} else if (kind === "chore") {
|
|
209
|
-
actions.append(button("Done",
|
|
368
|
+
actions.append(button("Done", first, () => done(e, note, actions)));
|
|
210
369
|
} else if (kind === "merge") {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
if (
|
|
218
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
const
|
|
261
|
-
|
|
262
|
-
(
|
|
263
|
-
|
|
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?.(".
|
|
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
|
-
/*
|
|
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
|
|
467
|
+
/** What a run is doing, as a person would say it. */
|
|
308
468
|
function whatRun(r) {
|
|
309
|
-
|
|
310
|
-
if (r.trigger === "
|
|
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
|
-
{
|
|
313
|
-
|
|
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
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
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
|
|
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
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
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
|
-
|
|
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
|
-
|
|
347
|
-
|
|
348
|
-
|
|
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
|
|
356
|
-
|
|
357
|
-
|
|
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
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
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
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
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
|
|
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
|
-
|
|
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"
|
|
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
|
],
|