@nanocollective/roster 0.1.0-beta.1 → 0.1.0-beta.11
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 +1 -0
- package/dist/cli.js +150 -45
- package/dist/worker/assets/assets/css/base.css +17 -2
- package/dist/worker/assets/assets/css/home.css +42 -29
- package/dist/worker/assets/assets/css/layout.css +6 -0
- package/dist/worker/assets/assets/js/api.js +30 -0
- package/dist/worker/assets/assets/js/app.js +37 -2
- package/dist/worker/assets/assets/js/homesort.js +4 -21
- package/dist/worker/assets/assets/js/views/home.js +115 -79
- package/dist/worker/index.js +795 -85
- package/docs/architecture.md +22 -3
- package/docs/commands.md +29 -8
- package/docs/concepts.md +1 -1
- package/docs/developing.md +1 -1
- package/docs/getting-started.md +5 -2
- package/docs/hosting.md +25 -0
- package/docs/memory.md +2 -1
- package/docs/portal.md +4 -3
- package/docs/security.md +13 -0
- package/docs/session-workflow.md +10 -6
- package/docs/staff-yaml.md +5 -2
- package/package.json +1 -1
- package/templates/brain/CHARTER.md +2 -2
- package/templates/brain/STATE.md +16 -0
- package/templates/brain/memory/INDEX.md +1 -1
- package/templates/ops/.github/workflows/session.yaml +14 -1
- package/templates/ops/org/voice.md +2 -2
- package/templates/ops/prompts/daily.md +27 -18
- package/templates/ops/prompts/mention.md +6 -2
- package/templates/ops/status-week.mjs +169 -0
- package/templates/portal/css/base.css +17 -2
- package/templates/portal/css/home.css +42 -29
- package/templates/portal/css/layout.css +6 -0
- package/templates/portal/js/api.js +30 -0
- package/templates/portal/js/app.js +37 -2
- package/templates/portal/js/homesort.js +4 -21
- package/templates/portal/js/views/home.js +115 -79
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Opens this week's status issue, before the prompt is composed, when the one in staff.yaml is
|
|
3
|
+
// from an earlier week.
|
|
4
|
+
//
|
|
5
|
+
// Written because one status issue that lasts forever turns into a diary. Pip's ran from August
|
|
6
|
+
// to October as forty-odd run reports in one thread, and the human stopped reading it. A week
|
|
7
|
+
// per issue keeps a thread short, and the closed ones read back as the history, a week at a time.
|
|
8
|
+
//
|
|
9
|
+
// The housekeeping is here rather than in the prompt because it has to happen every week, the
|
|
10
|
+
// same way, whatever the agent does: open the issue, pin it, carry last week's body across, and
|
|
11
|
+
// move staff.yaml on, so every reader of `status_issue` (the prompts, the portal, doctor, the
|
|
12
|
+
// failure notice) follows without knowing weeks exist. What only the agent can write, the week's
|
|
13
|
+
// summary on the old issue, is left to it: the old issue loses `keep-open` and its pin, and the
|
|
14
|
+
// prompt is told its number.
|
|
15
|
+
//
|
|
16
|
+
// Vendored alongside compose.mjs for the same reason: it runs on the runner and must not depend
|
|
17
|
+
// on npm. It asks GitHub through `gh`. It never fails a run: if anything here goes wrong, the run
|
|
18
|
+
// carries on with last week's issue, which is how every run went before this existed.
|
|
19
|
+
//
|
|
20
|
+
// Usage: node roster-ops/status-week.mjs --staff cto --ops roster-ops --brains .
|
|
21
|
+
// Prints `previous=#15` for $GITHUB_OUTPUT when a week's issue is waiting for its summary.
|
|
22
|
+
|
|
23
|
+
import { execFileSync } from "node:child_process";
|
|
24
|
+
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
25
|
+
import { join, resolve } from "node:path";
|
|
26
|
+
import { fileURLToPath } from "node:url";
|
|
27
|
+
import { parseYaml } from "./compose.mjs";
|
|
28
|
+
|
|
29
|
+
export const STATUS_LABEL = "status";
|
|
30
|
+
const MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
|
|
31
|
+
|
|
32
|
+
/** Monday 00:00 UTC of the week `now` falls in. */
|
|
33
|
+
export function weekStart(now) {
|
|
34
|
+
const d = new Date(now);
|
|
35
|
+
const back = (d.getUTCDay() + 6) % 7;
|
|
36
|
+
return new Date(Date.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate() - back));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function weekTitle(now) {
|
|
40
|
+
const m = weekStart(now);
|
|
41
|
+
return `📍 Where we are: week of ${m.getUTCDate()} ${MONTHS[m.getUTCMonth()]}`;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Whether `issue` is this week's, and still the one to write to. */
|
|
45
|
+
export function isCurrent(issue, now) {
|
|
46
|
+
return Boolean(issue) && issue.state === "open" && new Date(issue.created_at) >= weekStart(now);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** staff.yaml with `status_issue:` moved to `n`, keeping everything else byte for byte. */
|
|
50
|
+
export function withStatusIssue(yaml, n) {
|
|
51
|
+
if (/^status_issue:.*$/m.test(yaml)) return yaml.replace(/^status_issue:.*$/m, `status_issue: ${n}`);
|
|
52
|
+
return yaml.replace(/^(brain:.*\n)/m, `$1status_issue: ${n}\n`);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const FIRST_BODY = "Nothing yet. The first run of the week rewrites this.";
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Works out the week and does the GitHub half of it. Returns the issue to write to and the
|
|
59
|
+
* earlier ones still waiting for a summary. `gh` takes argv and returns stdout, so a test
|
|
60
|
+
* drives it without the network.
|
|
61
|
+
*/
|
|
62
|
+
export function rollWeek({ repo, current, gh, now = Date.now() }) {
|
|
63
|
+
const issue = current ? JSON.parse(gh(["api", `repos/${repo}/issues/${current}`])) : null;
|
|
64
|
+
|
|
65
|
+
// Created on every run because it costs one call and an org that upgraded never had it.
|
|
66
|
+
try {
|
|
67
|
+
gh(["label", "create", STATUS_LABEL, "--repo", repo, "--color", "0e8a16",
|
|
68
|
+
"--description", "A week's status issue"]);
|
|
69
|
+
} catch {
|
|
70
|
+
// Already there, which is the usual answer.
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
let next = current;
|
|
74
|
+
let rolled = false;
|
|
75
|
+
if (!isCurrent(issue, now)) {
|
|
76
|
+
const opened = JSON.parse(
|
|
77
|
+
gh([
|
|
78
|
+
"api", `repos/${repo}/issues`, "-X", "POST",
|
|
79
|
+
"-f", `title=${weekTitle(now)}`,
|
|
80
|
+
"-f", `body=${issue?.state === "open" && issue.body?.trim() ? issue.body : FIRST_BODY}`,
|
|
81
|
+
"-f", `labels[]=${STATUS_LABEL}`,
|
|
82
|
+
"-f", "labels[]=keep-open",
|
|
83
|
+
]),
|
|
84
|
+
);
|
|
85
|
+
next = opened.number;
|
|
86
|
+
rolled = true;
|
|
87
|
+
|
|
88
|
+
// Three issues can be pinned, so the old one comes off first.
|
|
89
|
+
if (issue?.state === "open") {
|
|
90
|
+
quietly(() => gh(["api", "graphql", "-f", "query=mutation($id:ID!){unpinIssue(input:{issueId:$id}){issue{number}}}", "-f", `id=${issue.node_id}`]));
|
|
91
|
+
// Without keep-open the agent may close it, which is what the summary ends with. The
|
|
92
|
+
// label marks it as a week's issue for the sweep below, should that run not finish.
|
|
93
|
+
quietly(() => gh(["api", `repos/${repo}/issues/${current}/labels/keep-open`, "-X", "DELETE"]));
|
|
94
|
+
quietly(() => gh(["api", `repos/${repo}/issues/${current}/labels`, "-X", "POST", "-f", `labels[]=${STATUS_LABEL}`]));
|
|
95
|
+
}
|
|
96
|
+
quietly(() => gh(["api", "graphql", "-f", "query=mutation($id:ID!){pinIssue(input:{issueId:$id}){issue{number}}}", "-f", `id=${opened.node_id}`]));
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Every earlier week still open: last week's, and any week whose summary run did not finish.
|
|
100
|
+
// Last week's is added by hand when it was just rolled: the label filter lags a label added a
|
|
101
|
+
// moment ago, and on Pip's first roll the listing came back without it, so no summary was asked for.
|
|
102
|
+
const open = JSON.parse(
|
|
103
|
+
gh(["api", `repos/${repo}/issues?state=open&labels=${STATUS_LABEL}&per_page=20`]) || "[]",
|
|
104
|
+
);
|
|
105
|
+
const numbers = new Set(open.filter((i) => !i.pull_request).map((i) => i.number));
|
|
106
|
+
if (rolled && issue?.state === "open") numbers.add(current);
|
|
107
|
+
numbers.delete(next);
|
|
108
|
+
const previous = [...numbers].sort((a, b) => a - b);
|
|
109
|
+
return { current: next, rolled, previous };
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function quietly(fn) {
|
|
113
|
+
try {
|
|
114
|
+
fn();
|
|
115
|
+
} catch (err) {
|
|
116
|
+
console.error(`::warning::status-week: ${String(err.message).split("\n")[0]}`);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** Commits staff.yaml's new number, retrying the push over anything another run pushed. */
|
|
121
|
+
function commit(brainDir, n) {
|
|
122
|
+
const git = (...a) => execFileSync("git", ["-C", brainDir, ...a], { stdio: ["ignore", "pipe", "pipe"] });
|
|
123
|
+
git("add", "staff.yaml");
|
|
124
|
+
git("commit", "-m", `roster: this week's status issue is #${n}`);
|
|
125
|
+
for (let i = 0; ; i++) {
|
|
126
|
+
try {
|
|
127
|
+
git("push");
|
|
128
|
+
return;
|
|
129
|
+
} catch (err) {
|
|
130
|
+
if (i === 2) throw err;
|
|
131
|
+
git("pull", "--rebase");
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function main(argv) {
|
|
137
|
+
const args = {};
|
|
138
|
+
for (let i = 0; i < argv.length; i += 2) args[argv[i].replace(/^--/, "")] = argv[i + 1];
|
|
139
|
+
if (!args.staff) throw new Error("--staff is required");
|
|
140
|
+
const opsDir = resolve(args.ops ?? ".");
|
|
141
|
+
const org = parseYaml(readFileSync(join(opsDir, "org.yaml"), "utf8"), "org.yaml");
|
|
142
|
+
const entry = (org.staff ?? []).find((s) => s.handle === args.staff);
|
|
143
|
+
if (!entry) throw new Error(`org.yaml has no staff member "${args.staff}"`);
|
|
144
|
+
const brainDir = join(resolve(args.brains ?? ".."), entry.dir ?? entry.handle);
|
|
145
|
+
const file = join(brainDir, "staff.yaml");
|
|
146
|
+
if (!existsSync(file)) throw new Error(`no staff.yaml at ${file}`);
|
|
147
|
+
const yaml = readFileSync(file, "utf8");
|
|
148
|
+
const manifest = parseYaml(yaml, "staff.yaml");
|
|
149
|
+
const repo = String(manifest.brain ?? `${org.org}/${entry.dir ?? entry.handle}`);
|
|
150
|
+
|
|
151
|
+
const gh = (a) => execFileSync("gh", a, { encoding: "utf8", maxBuffer: 16 * 1024 * 1024 });
|
|
152
|
+
const week = rollWeek({ repo, current: Number(manifest.status_issue) || 0, gh });
|
|
153
|
+
if (week.rolled) {
|
|
154
|
+
writeFileSync(file, withStatusIssue(yaml, week.current));
|
|
155
|
+
commit(brainDir, week.current);
|
|
156
|
+
console.error(`opened #${week.current} for this week`);
|
|
157
|
+
}
|
|
158
|
+
if (week.previous.length) {
|
|
159
|
+
process.stdout.write(`previous=${week.previous.map((n) => `#${n}`).join(", ")}\n`);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (process.argv[1] && resolve(process.argv[1]) === resolve(fileURLToPath(import.meta.url))) {
|
|
164
|
+
try {
|
|
165
|
+
main(process.argv.slice(2));
|
|
166
|
+
} catch (err) {
|
|
167
|
+
console.error(`::warning::status-week: ${err.message}`);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
@@ -300,9 +300,11 @@ dialog.sheet.side .sheetbody{max-height:100vh;height:100%;box-sizing:border-box;
|
|
|
300
300
|
.sidebar-x{position:sticky;top:0;display:flex;justify-content:flex-end;margin:-6px -6px 4px;z-index:1}
|
|
301
301
|
dialog.sheet.side .viewer{border:0;box-shadow:none;padding:0;min-height:0;background:none}
|
|
302
302
|
/* The title and its actions stay in view while a long thread scrolls under them. The close
|
|
303
|
-
button floats over the header's right
|
|
303
|
+
button floats over the header's top right, so the lines beside it leave room for it; the
|
|
304
|
+
actions below it run to the edge, so Open in GitHub lines up with the close button. */
|
|
304
305
|
dialog.sheet.side .thead{position:sticky;top:-18px;z-index:1;background:var(--bg);
|
|
305
|
-
padding-top:18px;margin-top:-18px
|
|
306
|
+
padding-top:18px;margin-top:-18px}
|
|
307
|
+
dialog.sheet.side .thead > :not(.tacts){padding-right:44px}
|
|
306
308
|
dialog.sheet.side .sidebar-x{position:sticky;top:0;height:0;margin:0;z-index:2;overflow:visible}
|
|
307
309
|
dialog.sheet.side .sidebar-x .iconbtn{margin-top:-4px}
|
|
308
310
|
.sheettitle{margin:0 0 14px;font:600 18px var(--sans);letter-spacing:-.02em}
|
|
@@ -310,3 +312,16 @@ dialog.sheet.side .sidebar-x .iconbtn{margin-top:-4px}
|
|
|
310
312
|
.spinner{width:22px;height:22px;border-radius:50%;border:2px solid var(--line);border-top-color:var(--accent);
|
|
311
313
|
animation:spin .7s linear infinite}
|
|
312
314
|
@keyframes spin{to{transform:rotate(360deg)}}
|
|
315
|
+
|
|
316
|
+
/* The first load, while the org is read from GitHub: a row per repository. */
|
|
317
|
+
.loadlist{display:flex;flex-direction:column;gap:2px;max-width:520px}
|
|
318
|
+
.loadrow{display:grid;grid-template-columns:18px 140px 1fr;align-items:center;gap:10px;padding:7px 0;
|
|
319
|
+
font-size:13.5px;border-bottom:1px solid var(--line)}
|
|
320
|
+
.loadrow b{font-weight:500}
|
|
321
|
+
.loadrow .meta{color:var(--ink-dim)}
|
|
322
|
+
.loadmark{width:10px;height:10px;border-radius:50%;border:2px solid var(--accent-dim);
|
|
323
|
+
border-top-color:var(--accent);animation:loadspin .8s linear infinite}
|
|
324
|
+
.loadrow.done .loadmark{animation:none;border-color:var(--accent);background:var(--accent)}
|
|
325
|
+
.loadrow.done .meta{color:var(--ink-faint)}
|
|
326
|
+
@keyframes loadspin{to{transform:rotate(360deg)}}
|
|
327
|
+
@media (prefers-reduced-motion:reduce){.loadmark{animation:none}}
|
|
@@ -20,24 +20,33 @@
|
|
|
20
20
|
.homewho{font:500 12.5px var(--sans);color:var(--ink);background:var(--surface-2);border:0;
|
|
21
21
|
border-radius:8px;padding:5px 8px}
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
/* Needs you: one list, a row per thing. A dot column for unread, the thing itself, and its
|
|
24
|
+
action; titles all start in the same place, and buttons are small enough not to shout. */
|
|
25
|
+
.homelist{padding:0 16px}
|
|
26
|
+
.homeneed{display:grid;grid-template-columns:8px minmax(0,1fr) auto;align-items:center;
|
|
27
|
+
gap:4px 14px;padding:14px 0;cursor:pointer}
|
|
28
|
+
.homeneed + .homeneed{border-top:1px solid var(--line)}
|
|
29
|
+
.homeneed:focus-visible{outline:2px solid var(--accent);outline-offset:2px;border-radius:6px}
|
|
30
|
+
.homeneed:hover .homeopen{text-decoration:underline}
|
|
31
|
+
.homedot{align-self:start;width:7px;height:7px;margin-top:7px;border-radius:50%}
|
|
32
|
+
.homeneed.unread .homedot{background:var(--blue)}
|
|
25
33
|
.homeabout{min-width:0}
|
|
26
|
-
.
|
|
27
|
-
.homecard:focus-visible{outline:none;border-color:var(--accent);box-shadow:0 0 0 3px var(--accent-soft)}
|
|
28
|
-
.homehead{display:flex;align-items:baseline;gap:8px}
|
|
29
|
-
.homehead .chip{flex:none}
|
|
30
|
-
.homeopen{all:unset;cursor:pointer;font:600 14px/1.35 var(--sans);color:var(--ink);letter-spacing:-.01em}
|
|
31
|
-
.homeopen:hover{text-decoration:underline}
|
|
34
|
+
.homeopen{all:unset;cursor:pointer;font:600 14px/1.4 var(--sans);color:var(--ink);letter-spacing:-.01em}
|
|
32
35
|
.homeopen:focus-visible{outline:2px solid var(--accent);outline-offset:2px;border-radius:4px}
|
|
33
|
-
.homeabout > .meta{margin-top:
|
|
34
|
-
.
|
|
35
|
-
.
|
|
36
|
-
.
|
|
36
|
+
.homeabout > .meta{margin-top:3px}
|
|
37
|
+
.homekind{font-weight:600;color:var(--ink-dim)}
|
|
38
|
+
.homekind.hot{color:var(--err)}
|
|
39
|
+
.homekind.warm{color:var(--warn)}
|
|
40
|
+
.homekind.cool{color:var(--ruled)}
|
|
41
|
+
.homekind.ok{color:var(--accent)}
|
|
42
|
+
.homedue{margin:5px 0 0;font-size:12.5px;color:var(--ink-dim)}
|
|
43
|
+
.homedue.late,.homedue .bad{color:var(--warn)}
|
|
44
|
+
.homeacts{justify-content:flex-end;flex-wrap:nowrap;gap:8px}
|
|
45
|
+
.homeacts .ghbtn{min-height:28px;padding:3px 12px;font-size:12.5px}
|
|
37
46
|
.homeacts .meta{white-space:normal;text-align:right;max-width:220px}
|
|
38
47
|
@media (max-width:640px){
|
|
39
|
-
.
|
|
40
|
-
.homeacts{justify-content:flex-start;flex-wrap:wrap}
|
|
48
|
+
.homeneed{grid-template-columns:8px minmax(0,1fr)}
|
|
49
|
+
.homeacts{grid-column:2;justify-content:flex-start;flex-wrap:wrap}
|
|
41
50
|
.homeacts .meta{text-align:left}
|
|
42
51
|
}
|
|
43
52
|
|
|
@@ -58,22 +67,19 @@
|
|
|
58
67
|
.homerunlog .ghbtn{min-height:28px;padding:3px 12px}
|
|
59
68
|
@media (max-width:640px){
|
|
60
69
|
.homerun{grid-template-columns:1fr auto;grid-template-areas:"who state" "what what" "log log"}
|
|
61
|
-
.homewho2{grid-area:who}.homestate{grid-area:state;justify-self:end}
|
|
62
|
-
.homerunwhat{grid-area:what}.homerunlog{grid-area:log}
|
|
70
|
+
.homerun .homewho2{grid-area:who}.homerun .homestate{grid-area:state;justify-self:end}
|
|
71
|
+
.homerun .homerunwhat{grid-area:what}.homerun .homerunlog{grid-area:log}
|
|
63
72
|
}
|
|
64
73
|
|
|
65
74
|
.homerest{margin-top:26px}
|
|
66
|
-
.
|
|
75
|
+
.homeneed.gone,.homeline.gone{opacity:0;transform:translateX(12px);
|
|
67
76
|
transition:opacity .2s var(--ease),transform .2s var(--ease)}
|
|
68
77
|
|
|
69
|
-
/* Activity you have not seen: a blue dot and a bold title
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
GitHub. */
|
|
73
|
-
.homecard.unread{box-shadow:inset 3px 0 0 var(--blue)}
|
|
78
|
+
/* Activity you have not seen: a blue dot and a bold title. In Needs you the dot has a column of
|
|
79
|
+
its own; in the other lists it sits before the title. Opening the thread marks it read, here
|
|
80
|
+
and on GitHub. */
|
|
74
81
|
.unread .homeopen,.unread .homerowtitle{font-weight:700}
|
|
75
|
-
|
|
76
|
-
background:var(--blue);margin:0 7px 1px 0;vertical-align:middle}
|
|
82
|
+
|
|
77
83
|
|
|
78
84
|
.homereports{display:flex;flex-direction:column;gap:14px;padding:14px 16px}
|
|
79
85
|
.homereport{display:grid;grid-template-columns:190px 1fr;gap:12px;font-size:13px;line-height:1.5;
|
|
@@ -82,20 +88,27 @@
|
|
|
82
88
|
.homereport:focus-visible{outline:2px solid var(--accent);outline-offset:0}
|
|
83
89
|
.homereportwho{display:flex;flex-direction:column;gap:2px;min-width:0}
|
|
84
90
|
.homereportwho .meta{padding-left:21px}
|
|
91
|
+
.homereportask{display:flex;flex-wrap:wrap;align-items:center;gap:6px;padding-left:21px;margin-top:6px}
|
|
92
|
+
.homereportask .meta{padding-left:0}
|
|
85
93
|
.homereportbody p{margin:0 0 4px;color:var(--ink-dim);font-size:13px;line-height:1.5}
|
|
86
94
|
.homereportbody p:first-child{color:var(--ink)}
|
|
87
95
|
.homereportbody a{color:var(--accent)}
|
|
88
96
|
@media (max-width:640px){.homereport{grid-template-columns:1fr;gap:4px}}
|
|
89
97
|
|
|
90
|
-
@media (max-width:640px){
|
|
91
|
-
.homehead{flex-wrap:wrap}
|
|
92
|
-
}
|
|
93
98
|
|
|
94
99
|
/* Rows in a list card (Unread, Your requests, Closed today) that open a thread. */
|
|
95
|
-
.homeline{display:grid;grid-template-columns:
|
|
100
|
+
.homeline{display:grid;grid-template-columns:8px minmax(0,1fr) auto;align-items:center;gap:4px 14px;
|
|
96
101
|
padding:12px 0;font-size:13.5px;cursor:pointer}
|
|
102
|
+
.homeline.unread .homedot{background:var(--blue)}
|
|
97
103
|
.homeline + .homeline{border-top:1px solid var(--line)}
|
|
98
|
-
.homeline .homestate{min-width:64px;justify-content:center}
|
|
99
104
|
.homeline:hover .homerowtitle{text-decoration:underline}
|
|
100
105
|
.homeline:focus-visible{outline:2px solid var(--accent);outline-offset:2px;border-radius:6px}
|
|
101
106
|
.homerowtitle{font-weight:600;color:var(--ink)}
|
|
107
|
+
|
|
108
|
+
/* On a phone the lists use the width: last in the file, so it wins over each list's own padding. */
|
|
109
|
+
@media (max-width:640px){
|
|
110
|
+
.homelist,.homeworking,.homereports{padding-left:14px;padding-right:14px}
|
|
111
|
+
.homeline{grid-template-columns:8px minmax(0,1fr)}
|
|
112
|
+
.homeline .homerunlog{grid-column:2}
|
|
113
|
+
.homeline .homerunlog:empty{display:none}
|
|
114
|
+
}
|
|
@@ -150,6 +150,12 @@ main{padding:36px 44px 96px;max-width:1220px;overflow-x:clip}
|
|
|
150
150
|
.side{position:static;height:auto;border-right:none;border-bottom:1px solid var(--line)}
|
|
151
151
|
.sidefoot{margin-top:0}
|
|
152
152
|
}
|
|
153
|
+
/* A phone: the page uses its width. 44px a side was a desktop gutter, and on a phone it took
|
|
154
|
+
a quarter of the screen, with a card's own padding inside it again. */
|
|
155
|
+
@media (max-width:640px){
|
|
156
|
+
main{padding:20px 16px 64px}
|
|
157
|
+
.card{padding:14px}
|
|
158
|
+
}
|
|
153
159
|
|
|
154
160
|
/* A staff member who cannot run yet (readiness.js). */
|
|
155
161
|
.readydot{width:7px;height:7px;border-radius:50%;background:var(--warn);flex:none;margin-left:4px}
|
|
@@ -14,6 +14,36 @@ export const getSession = () =>
|
|
|
14
14
|
.catch(() => null);
|
|
15
15
|
|
|
16
16
|
export const getOrg = () => json("/api/org");
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The org, for the first load, saying what it is doing as it goes: `onStep(repo, step)` for each
|
|
20
|
+
* line the server streams, then the org itself. Anything that is not a stream (the setup answer,
|
|
21
|
+
* an older server) is read as plain JSON, so this is never worse than getOrg.
|
|
22
|
+
*/
|
|
23
|
+
export async function getOrgWithProgress(onStep) {
|
|
24
|
+
const res = await fetch("/api/org?progress=1", { cache: "no-store" });
|
|
25
|
+
if (res.status === 401) location.reload();
|
|
26
|
+
const type = String(res.headers?.get?.("content-type") ?? "");
|
|
27
|
+
if (!type.includes("ndjson") || !res.body?.pipeThrough) return res.json();
|
|
28
|
+
const reader = res.body.pipeThrough(new TextDecoderStream()).getReader();
|
|
29
|
+
let buf = "";
|
|
30
|
+
for (;;) {
|
|
31
|
+
const { done, value } = await reader.read();
|
|
32
|
+
if (done) break;
|
|
33
|
+
buf += value;
|
|
34
|
+
let nl;
|
|
35
|
+
while ((nl = buf.indexOf("\n")) >= 0) {
|
|
36
|
+
const line = buf.slice(0, nl).trim();
|
|
37
|
+
buf = buf.slice(nl + 1);
|
|
38
|
+
if (!line) continue;
|
|
39
|
+
const msg = JSON.parse(line);
|
|
40
|
+
if (msg.org) return msg.org;
|
|
41
|
+
if (msg.error) throw new Error(msg.error);
|
|
42
|
+
onStep(msg.repo, msg.step);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
throw new Error("The org did not arrive. Reload to try again.");
|
|
46
|
+
}
|
|
17
47
|
export const getDocs = () => json("/api/docs");
|
|
18
48
|
export const getInbox = (force) => json("/api/inbox" + (force ? "?refresh=1" : ""));
|
|
19
49
|
export const getSync = () => json("/api/sync").catch(() => null);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* The shell: boot, the sidebar, and dispatching a view into <main>. */
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { getOrgWithProgress, getSession } from "./api.js";
|
|
4
4
|
import { $, el, store } from "./dom.js";
|
|
5
5
|
import { icon, iconHTML, staffIcon } from "./icons.js";
|
|
6
6
|
import { installLightbox } from "./lightbox.js";
|
|
@@ -96,7 +96,7 @@ export async function boot() {
|
|
|
96
96
|
/* Before there is a tenant the server answers every data route with `mode: setup`. That is
|
|
97
97
|
not an error state: it is the first thing a new user ever sees, and the whole page becomes
|
|
98
98
|
the thing that fixes it. */
|
|
99
|
-
const [first, session] = await Promise.all([
|
|
99
|
+
const [first, session] = await Promise.all([loadWithProgress(), getSession()]);
|
|
100
100
|
S.hosted = session?.hosted ? session : null;
|
|
101
101
|
if (S.hosted) showSignedIn(S.hosted.login);
|
|
102
102
|
if (first && first.mode === "setup") {
|
|
@@ -409,6 +409,41 @@ function render() {
|
|
|
409
409
|
(SCREEN[S.view] ?? viewBrain)(m);
|
|
410
410
|
}
|
|
411
411
|
|
|
412
|
+
/* ------------------------------- first load -------------------------------- */
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* The first read of the org, with what it is doing on screen. A cold start reads every
|
|
416
|
+
* repository from GitHub, which can take a while, and "Loading…" for fifteen seconds reads as
|
|
417
|
+
* broken. One row per repository, saying which step it is on, and a tick when it is ready.
|
|
418
|
+
*/
|
|
419
|
+
async function loadWithProgress() {
|
|
420
|
+
const main = $("#main");
|
|
421
|
+
const rows = new Map();
|
|
422
|
+
const list = el("div", { className: "loadlist" });
|
|
423
|
+
const head = el("p", { className: "sub", textContent: "Reading the org from GitHub…" });
|
|
424
|
+
// Only once something is actually slow: a warm load is over before this would be read.
|
|
425
|
+
const show = setTimeout(() => main.replaceChildren(head, list), 400);
|
|
426
|
+
try {
|
|
427
|
+
return await getOrgWithProgress((repo, step) => {
|
|
428
|
+
let row = rows.get(repo);
|
|
429
|
+
if (!row) {
|
|
430
|
+
row = el("div", { className: "loadrow" }, [
|
|
431
|
+
el("span", { className: "loadmark" }),
|
|
432
|
+
el("b", { textContent: repo }),
|
|
433
|
+
el("span", { className: "meta" }),
|
|
434
|
+
]);
|
|
435
|
+
rows.set(repo, row);
|
|
436
|
+
list.append(row);
|
|
437
|
+
}
|
|
438
|
+
const ready = step === "ready" || step === "up to date";
|
|
439
|
+
row.classList.toggle("done", ready);
|
|
440
|
+
row.lastChild.textContent = ready ? "ready" : step;
|
|
441
|
+
});
|
|
442
|
+
} finally {
|
|
443
|
+
clearTimeout(show);
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
|
|
412
447
|
/* -------------------------------- signed in -------------------------------- */
|
|
413
448
|
|
|
414
449
|
/**
|
|
@@ -20,17 +20,6 @@ const CHORE_WORDS = ["setup", "submit", "data", "blocked"];
|
|
|
20
20
|
|
|
21
21
|
const lower = (s) => String(s ?? "").toLowerCase();
|
|
22
22
|
|
|
23
|
-
/** How old a run report can be and still be this morning's. */
|
|
24
|
-
const REPORT_HOURS = 20;
|
|
25
|
-
|
|
26
|
-
/** A run report as lines, without the @mention it opens with. */
|
|
27
|
-
function reportLines(body) {
|
|
28
|
-
return String(body ?? "")
|
|
29
|
-
.split("\n")
|
|
30
|
-
.map((l) => l.replace(/^\s*(@[\w-]+\s*)+/, "").replace(/^[-*]\s+/, "").trim())
|
|
31
|
-
.filter(Boolean)
|
|
32
|
-
.slice(0, 5);
|
|
33
|
-
}
|
|
34
23
|
|
|
35
24
|
/**
|
|
36
25
|
* @param items the inbox list: open and recently closed issues and pull requests
|
|
@@ -76,16 +65,10 @@ export function sortHome(items, staff, humans, live = [], now = new Date()) {
|
|
|
76
65
|
continue;
|
|
77
66
|
}
|
|
78
67
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
if (
|
|
82
|
-
owner
|
|
83
|
-
item.number === owner.statusIssue &&
|
|
84
|
-
c &&
|
|
85
|
-
!people.has(lower(c.author)) &&
|
|
86
|
-
now - new Date(c.createdAt) < REPORT_HOURS * 3_600_000
|
|
87
|
-
) {
|
|
88
|
-
out.reports.push({ staff: owner, item, at: c.createdAt, lines: reportLines(c.body) });
|
|
68
|
+
/* The report: the body of a staff member's status issue, which every run rewrites. Not its
|
|
69
|
+
comments, which used to be the reports and grew into a thread nobody wanted to scroll. */
|
|
70
|
+
if (owner && item.number === owner.statusIssue && String(item.body ?? "").trim()) {
|
|
71
|
+
out.reports.push({ staff: owner, item, at: item.updatedAt, body: String(item.body).trim() });
|
|
89
72
|
}
|
|
90
73
|
|
|
91
74
|
const place = placeOf(item, owner, people, markers);
|