@nanocollective/roster 0.1.0-beta.30 → 0.1.0-beta.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/worker/assets/assets/css/brain.css +2 -0
  2. package/dist/worker/assets/assets/css/home.css +14 -4
  3. package/dist/worker/assets/assets/css/routines.css +3 -0
  4. package/dist/worker/assets/assets/css/setup.css +5 -0
  5. package/dist/worker/assets/assets/js/app.js +3 -0
  6. package/dist/worker/assets/assets/js/mention.js +2 -1
  7. package/dist/worker/assets/assets/js/readiness.js +36 -0
  8. package/dist/worker/assets/assets/js/refresh.js +4 -0
  9. package/dist/worker/assets/assets/js/views/connectors.js +5 -0
  10. package/dist/worker/assets/assets/js/views/health.js +11 -5
  11. package/dist/worker/assets/assets/js/views/home.js +81 -4
  12. package/dist/worker/assets/assets/js/views/inbox.js +14 -1
  13. package/dist/worker/assets/assets/js/views/notready.js +60 -0
  14. package/dist/worker/assets/assets/js/views/org.js +14 -1
  15. package/dist/worker/assets/assets/js/views/routines.js +19 -2
  16. package/dist/worker/assets/assets/js/views/runonce.js +5 -0
  17. package/dist/worker/assets/assets/js/views/runs.js +11 -1
  18. package/dist/worker/assets/assets/js/views/staff.js +18 -3
  19. package/package.json +1 -1
  20. package/templates/portal/css/brain.css +2 -0
  21. package/templates/portal/css/home.css +14 -4
  22. package/templates/portal/css/routines.css +3 -0
  23. package/templates/portal/css/setup.css +5 -0
  24. package/templates/portal/js/app.js +3 -0
  25. package/templates/portal/js/mention.js +2 -1
  26. package/templates/portal/js/readiness.js +36 -0
  27. package/templates/portal/js/refresh.js +4 -0
  28. package/templates/portal/js/views/connectors.js +5 -0
  29. package/templates/portal/js/views/health.js +11 -5
  30. package/templates/portal/js/views/home.js +81 -4
  31. package/templates/portal/js/views/inbox.js +14 -1
  32. package/templates/portal/js/views/notready.js +60 -0
  33. package/templates/portal/js/views/org.js +14 -1
  34. package/templates/portal/js/views/routines.js +19 -2
  35. package/templates/portal/js/views/runonce.js +5 -0
  36. package/templates/portal/js/views/runs.js +11 -1
  37. package/templates/portal/js/views/staff.js +18 -3
@@ -138,3 +138,5 @@
138
138
  .peopleonly::after{content:"Read only";font:12.5px var(--sans);color:var(--ink-dim);margin-left:6px}
139
139
  .peopleonly{justify-content:flex-start;align-items:center}
140
140
  }
141
+ /* An org file setup is still waiting on: a small tag under its name, not a bar. */
142
+ .tlayer .t > .chip{align-self:flex-start;margin-top:4px;height:auto;padding-block:1px;font-size:11px}
@@ -66,13 +66,14 @@
66
66
  /* Progress: a card per staff member. Status and one line, then Done and Next side by side. */
67
67
  /* Progress: one card, a row per staff member. The line on how it is going is what you read;
68
68
  everything else is quieter, and what got done waits behind Full report. */
69
- .homereports{display:flex;flex-direction:column;padding-top:4px;padding-bottom:4px}
70
- .homereport{display:flex;flex-direction:column;gap:4px;padding:12px 0;min-width:0}
69
+ .homereports{display:flex;flex-direction:column;padding-top:6px;padding-bottom:6px}
70
+ .homereport{display:flex;flex-direction:column;gap:8px;padding:14px 0;min-width:0}
71
71
  .homereport + .homereport{border-top:1px solid var(--line)}
72
- .homereporthead{display:flex;align-items:center;flex-wrap:wrap;gap:6px 10px;min-height:28px}
72
+ .homereporthead{display:flex;align-items:center;flex-wrap:wrap;gap:8px 12px;min-height:28px}
73
73
  .homereportstatus{font-weight:600}
74
74
  .homereportwhen{font-size:12px}
75
- .homereportacts{margin-left:auto;display:flex;align-items:center;gap:6px}
75
+ .homereportacts{margin-left:auto;display:flex;align-items:center;gap:8px}
76
+ .homereportacts .ghbtn{min-height:28px;padding:3px 12px;font-size:12.5px}
76
77
  .homereportline{font-size:var(--text-body-size);line-height:var(--text-body-leading);color:var(--ink);
77
78
  padding-left:23px}
78
79
  .homereportline p{margin:0}
@@ -184,3 +185,12 @@
184
185
  .homeline .homerunlog{grid-column:2}
185
186
  .homeline .homerunlog:empty{display:none}
186
187
  }
188
+
189
+ /* Setup that is not finished, above everything else on Home. */
190
+ .homesetup{padding:14px 16px;margin:20px 0 22px;border-color:color-mix(in srgb,var(--warn) 45%,var(--line));
191
+ background:color-mix(in srgb,var(--warn) 7%,var(--panel))}
192
+ .homesetup > b{font:600 15px var(--sans)}
193
+ .homesetup .sub{margin:4px 0 10px}
194
+ .homesetupsteps{margin:0 0 4px;padding-left:20px;display:flex;flex-direction:column;gap:10px;font-size:13.5px}
195
+ .homesetupsteps li > span{display:block;margin-bottom:5px}
196
+ .homesetup .row{margin-top:10px}
@@ -38,3 +38,6 @@
38
38
  }
39
39
  .routwhenpick select{width:auto}
40
40
  .routhead + div > .connhead:first-child{margin-top:20px}
41
+ /* What is left before they can run, as wide as the list it sits over. */
42
+ .connhead + .readyslot{max-width:880px}
43
+ .connhead + .readyslot:not(:empty){margin:0 0 10px}
@@ -180,3 +180,8 @@ a.btn{text-decoration:none}
180
180
  .credform{display:grid;gap:10px}
181
181
  .credform .row{margin:0}
182
182
  .okline{margin:0 0 8px;color:var(--accent);font:600 13px var(--sans)}
183
+ /* A staff member who cannot run yet, on any screen that would start them. */
184
+ .warnline.notready{display:flex;flex-direction:column;gap:10px;padding:12px 14px}
185
+ /* Wherever it is dropped in, it keeps clear of what is above and below it. */
186
+ .readyslot:not(:empty){margin:16px 0 18px}
187
+ .readyslot > .warnline{margin:0}
@@ -404,6 +404,9 @@ function render() {
404
404
  export and a portal can go stale under a page that is already open. */
405
405
  const missing = NEEDS.filter((k) => S.data?.[k] === undefined);
406
406
  if (missing.length) return stale(missing);
407
+ /* A staff member's screen with nobody hired threw on the missing staff member and left the
408
+ page blank. A hash like #/-/brain still lands here, so it gets Home, which says what to do. */
409
+ if (!S.data.staff.length && !ORG_WIDE.has(S.view)) S.view = "home";
407
410
 
408
411
  // A refresh can add or remove a staff member, and the sidebar is built once.
409
412
  const roster = S.data.staff.map((s) => s.handle).join(" ");
@@ -12,6 +12,7 @@
12
12
  */
13
13
 
14
14
  import { el, esc } from "./dom.js";
15
+ import { canRun } from "./readiness.js";
15
16
  import { humansOf, S } from "./state.js";
16
17
 
17
18
  /**
@@ -37,7 +38,7 @@ export function mentionable() {
37
38
  out.push({
38
39
  text: at,
39
40
  label: s.name ?? s.handle,
40
- note: "wakes them, usually within a minute",
41
+ note: canRun(s.handle) ? "wakes them, usually within a minute" : "not set up yet, so nothing wakes them",
41
42
  kind: "staff",
42
43
  terms: [at.replace(/^@/, ""), s.handle, s.name ?? ""],
43
44
  });
@@ -28,6 +28,42 @@ export function notReady() {
28
28
  return (S.data?.staff ?? []).filter((s) => (S.readiness?.[s.handle] ?? []).length);
29
29
  }
30
30
 
31
+ /**
32
+ * Whether a run started now could work: nothing left but the first run itself. Unknown counts
33
+ * as able, so a slow answer from GitHub never greys out a working org's buttons.
34
+ */
35
+ export function canRun(handle) {
36
+ return !(S.readiness?.[handle] ?? []).some((x) => x !== "run once");
37
+ }
38
+
39
+ /** Whether they have never finished a run, as far as is known. */
40
+ export function neverRan(handle) {
41
+ return (S.readiness?.[handle] ?? []).includes("run once");
42
+ }
43
+
44
+ /** Forget every answer, so the next screen asks again: after a refresh, or a step finishing. */
45
+ export function forgetReadiness() {
46
+ S.readiness = null;
47
+ }
48
+
49
+ /** The roster command for each step: the only way to do them from a hosted portal. */
50
+ export const ROSTER = "npx @nanocollective/roster@latest";
51
+ export const ORG_STEPS = {
52
+ hire: ["Hire someone", "hire cto --apply"],
53
+ business: ["Say what the business is, in org/business.md", "brief discover"],
54
+ priorities: ["Say what matters this month, in org/priorities.md", "brief priorities"],
55
+ };
56
+ const STEP_COMMANDS = {
57
+ "write the charter": (h) => `brief charter ${h}`,
58
+ "create the GitHub App": (h) => `app ${h} --apply`,
59
+ "install the GitHub App": (h) => `app ${h} --apply`,
60
+ "add the agent credential": () => "credential --apply",
61
+ "run once": (h) => `run ${h} --apply`,
62
+ };
63
+ export function stepCommand(what, handle) {
64
+ return STEP_COMMANDS[what]?.(handle) ?? "";
65
+ }
66
+
31
67
  /** "install the GitHub App, add the agent credential and run once" */
32
68
  export function sentence(left) {
33
69
  if (left.length < 2) return left.join("");
@@ -11,6 +11,7 @@ import { getInbox, getOrg, getSync } from "./api.js";
11
11
  import { $, ago, el, esc } from "./dom.js";
12
12
  import { render } from "./router.js";
13
13
  import { isFor, sortHome } from "./homesort.js";
14
+ import { checkAll, forgetReadiness } from "./readiness.js";
14
15
  import { humansOf, openCount, S, unreadCount } from "./state.js";
15
16
 
16
17
  /**
@@ -98,6 +99,9 @@ export async function refreshAll(soft) {
98
99
  S.inbox = null; // the inbox re-fetches itself on next paint
99
100
  inflight = null;
100
101
  S.loadedAt = new Date();
102
+ // A step may have been finished since: a first run, a credential added on another machine.
103
+ forgetReadiness();
104
+ checkAll(() => !soft && render());
101
105
  if (!soft) render();
102
106
  stampLoaded();
103
107
  // The badges are now claiming a count from before the sync. Re-ask, and say so meanwhile.
@@ -244,6 +244,11 @@ function customForm(d, close) {
244
244
 
245
245
  function staffPicker(d, picked) {
246
246
  const who = el("div", { className: "connstaff" });
247
+ // An empty picker and then "Pick at least one staff member." had no way out.
248
+ if (!d.staff.length) {
249
+ who.append(el("p", { className: "sub", textContent: "Nobody is hired yet, so there is nobody to give it to. Hire someone first." }));
250
+ return who;
251
+ }
247
252
  for (const s of d.staff) {
248
253
  const box = el("input", { type: "checkbox", checked: picked.has(s.handle) });
249
254
  box.onchange = () => (box.checked ? picked.add(s.handle) : picked.delete(s.handle));
@@ -8,6 +8,7 @@ import { render } from "../router.js";
8
8
  import { S, staff } from "../state.js";
9
9
  import { checklist } from "./checklist.js";
10
10
  import { amendSheet } from "./prompt.js";
11
+ import { notReadyNote, whenKnown } from "./notready.js";
11
12
  import { runOnce } from "./runonce.js";
12
13
 
13
14
  const DAYS = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
@@ -86,12 +87,17 @@ export function viewHealth(m) {
86
87
  /* A workflow that has never run is unproven, and the way to prove it is to run it. Here
87
88
  because Health is where "unproven" is read; a success re-runs the checks below. */
88
89
  let doctor = null;
90
+ /* Only once a run could work. With the App or the credential missing, it started a run that
91
+ could only fail; until then the note says what is left instead. */
89
92
  m.append(
90
- runOnce({
91
- staff: s.handle,
92
- name: s.name,
93
- onDone: (ok) => ok && doctor && checklist(doctor.body, { shell: doctor }),
94
- }),
93
+ whenKnown(s, () =>
94
+ notReadyNote(s) ??
95
+ runOnce({
96
+ staff: s.handle,
97
+ name: s.name,
98
+ onDone: (ok) => ok && doctor && checklist(doctor.body, { shell: doctor }),
99
+ }),
100
+ ),
95
101
  );
96
102
 
97
103
  doctor = section(m, "The org, from roster doctor", "doctor");
@@ -10,6 +10,8 @@ import { askText, sheet } from "../dialog.js";
10
10
  import { ago, el, skeleton } from "../dom.js";
11
11
  import { daysUntil, isFor, sortHome } from "../homesort.js";
12
12
  import { mdlite } from "../md.js";
13
+ import { checkAll, notReady, ORG_STEPS, stepCommand } from "../readiness.js";
14
+ import { commandLine } from "./notready.js";
13
15
  import { parseReport } from "../report.js";
14
16
  import { icon, iconHTML, staffIcon } from "../icons.js";
15
17
  import { ensureInbox, stampCounts } from "../refresh.js";
@@ -56,6 +58,8 @@ export function viewHome(m) {
56
58
 
57
59
  const page = el("div", { className: "home" });
58
60
  page.append(team(staff));
61
+ const unset = setupLeft(staff);
62
+ if (unset) page.append(unset);
59
63
 
60
64
  /* With more than one person, each sees what is on them, plus anything on nobody in
61
65
  particular. Everyone's is one click away, so nothing is hidden for good. */
@@ -114,7 +118,12 @@ const STATUS_TONE = { "on track": "ok", "needs you": "warm", stuck: "hot", block
114
118
  * open under it. Their status issue is rewritten by every run, so this is always the latest.
115
119
  */
116
120
  function reportRow(s, reports) {
117
- const r = reports.find((x) => x.staff.handle === s.handle);
121
+ /* Before a first run the status issue holds the scaffold hire wrote, which read as a report
122
+ from 36 minutes ago. And asking for one wakes somebody who cannot run yet. */
123
+ const left = S.readiness?.[s.handle] ?? [];
124
+ const neverRan = left.includes("run once");
125
+ const unready = left.some((x) => x !== "run once");
126
+ const r = neverRan ? null : reports.find((x) => x.staff.handle === s.handle);
118
127
  const item = r?.item ?? { repo: s.brain, number: s.statusIssue, kind: "issue" };
119
128
  const note = el("span", { className: "meta" });
120
129
  const ask = el("button", { className: "ghbtn sm", textContent: "Ask for an update" });
@@ -160,7 +169,10 @@ function reportRow(s, reports) {
160
169
  }
161
170
  head.append(
162
171
  el("span", { className: "meta homereportwhen" }, [
163
- document.createTextNode((r ? "Updated " + ago(r.at) : "No report yet") + " · "),
172
+ document.createTextNode(
173
+ (r ? "Updated " + ago(r.at) : neverRan ? "No report yet: the first comes with their first run" : "No report yet") +
174
+ " · ",
175
+ ),
164
176
  issue,
165
177
  ]),
166
178
  );
@@ -174,7 +186,7 @@ function reportRow(s, reports) {
174
186
  };
175
187
  acts.append(more);
176
188
  }
177
- acts.append(ask);
189
+ if (!unready) acts.append(ask);
178
190
  head.append(acts);
179
191
  row.append(head);
180
192
 
@@ -523,6 +535,15 @@ function team(staff) {
523
535
  } else if (last) {
524
536
  line = `Last finished ${ago(last.updatedAt)}`;
525
537
  }
538
+ /* Somebody who cannot run yet looked exactly like somebody free. A run in progress, the
539
+ first one included, still says what it is doing. */
540
+ const left = S.readiness?.[s.handle] ?? [];
541
+ const unready = left.length > 0 && !busy && !queued;
542
+ if (unready) {
543
+ // The card is narrow; the steps themselves are in the panel under it.
544
+ word = "Not set up yet";
545
+ line = left.length === 1 ? "One step left: " + left[0] : `${left.length} steps left, below`;
546
+ }
526
547
  // A run takes about a minute to start, and until then the card would say nothing happened.
527
548
  if (!busy && !queued && Date.now() - (askedAt[s.handle] ?? 0) < 120_000) {
528
549
  line = "Sent. Starts in about a minute";
@@ -551,7 +572,8 @@ function team(staff) {
551
572
  el("a", { className: "orblog", href: log, target: "_blank", rel: "noopener", textContent: "View log" }),
552
573
  );
553
574
  }
554
- if (s.brain) {
575
+ // Asking wakes them, which proves nothing until the rest is done. A first run is fine.
576
+ if (s.brain && !(unready && left.some((x) => x !== "run once"))) {
555
577
  const ask = el("button", { className: "ghbtn orbask", textContent: "Ask a question" });
556
578
  ask.onclick = () => askStaff(s);
557
579
  card.append(el("span", { className: "orbgap" }), ask);
@@ -573,6 +595,61 @@ function team(staff) {
573
595
  return box;
574
596
  }
575
597
 
598
+ /* ------------------------------- setup left ----------------------------- */
599
+
600
+ let readinessAsked = false;
601
+
602
+ /**
603
+ * What is left of setting up, at the top of Home. Home said a staff member who could not run
604
+ * was "Free" with a button to ask them something, and nothing on it said setup was unfinished.
605
+ * Hosted, the steps are commands, since that is the only place they can be done.
606
+ */
607
+ function setupLeft(staff) {
608
+ if (staff.some((s) => !S.readiness?.[s.handle]) && !readinessAsked) {
609
+ readinessAsked = true;
610
+ checkAll(() => {
611
+ readinessAsked = false;
612
+ if (S.view === "home") render();
613
+ });
614
+ }
615
+ const steps = [];
616
+ for (const id of S.data?.unfinished ?? []) if (ORG_STEPS[id]) steps.push(ORG_STEPS[id]);
617
+ for (const s of notReady()) {
618
+ for (const what of S.readiness[s.handle]) {
619
+ steps.push([`${s.name}: ${what}`, stepCommand(what, s.handle)]);
620
+ }
621
+ }
622
+ if (!steps.length) return null;
623
+
624
+ const box = el("div", { className: "card homesetup" });
625
+ box.append(
626
+ el("b", { textContent: "Setup is not finished" }),
627
+ el("p", {
628
+ className: "sub",
629
+ textContent: S.hosted
630
+ ? "Nobody runs until these are done. They need your own machine: run each in your workspace, in order."
631
+ : "Nobody runs until these are done.",
632
+ }),
633
+ );
634
+ const seen = new Set();
635
+ const list = el("ol", { className: "homesetupsteps" });
636
+ for (const [what, cmd] of steps) {
637
+ // The credential is the org's, so two staff members missing it is one step.
638
+ if (cmd && seen.has(cmd)) continue;
639
+ seen.add(cmd);
640
+ const row = el("li", {}, [el("span", { textContent: cap(what) })]);
641
+ if (S.hosted && cmd) row.append(commandLine(cmd));
642
+ list.append(row);
643
+ }
644
+ box.append(list);
645
+ if (!S.hosted) {
646
+ const cont = el("button", { className: "btn primary", textContent: "Continue setting up" });
647
+ cont.onclick = () => go({ view: "setup" });
648
+ box.append(el("div", { className: "row" }, [cont]));
649
+ }
650
+ return box;
651
+ }
652
+
576
653
  const cap = (t) => t.charAt(0).toUpperCase() + t.slice(1);
577
654
 
578
655
  function minutes(since) {
@@ -6,6 +6,7 @@ import { ago, el, esc, markCurrent, skeleton } from "../dom.js";
6
6
  import { icon, iconHTML, staffIcon } from "../icons.js";
7
7
  import { mdlite } from "../md.js";
8
8
  import { attachMentions } from "../mention.js";
9
+ import { canRun } from "../readiness.js";
9
10
  import { ensureInbox, refreshAll, stampCounts } from "../refresh.js";
10
11
  import { humanLabel, humansOf, isHuman, S, writeHash } from "../state.js";
11
12
  import { renderDiff } from "./changed.js";
@@ -342,7 +343,13 @@ function inboxScreen(m, opts) {
342
343
  String(b.updatedAt).localeCompare(String(a.updatedAt)),
343
344
  );
344
345
  if (!items.length) {
345
- list.append(el("p", { className: "empty", textContent: "Nothing matches." }));
346
+ // With nobody hired there is nothing to match yet, and that is setup, not a filter.
347
+ list.append(
348
+ el("p", {
349
+ className: "empty",
350
+ textContent: S.data.staff.length ? "Nothing matches." : "Nothing here yet: nobody is hired. Home says what setup has left.",
351
+ }),
352
+ );
346
353
  return;
347
354
  }
348
355
 
@@ -1391,6 +1398,12 @@ function newIssueForm(viewer) {
1391
1398
  return;
1392
1399
  }
1393
1400
  create.disabled = false;
1401
+ // The issue is worth filing either way; it waits. What it must not do is promise a reply.
1402
+ if (!canRun(s.handle)) {
1403
+ forWhom.textContent =
1404
+ "Goes to " + s.brain + ". " + s.name + " is not set up yet, so nothing will wake them: it waits for their first run.";
1405
+ return;
1406
+ }
1394
1407
  forWhom.textContent =
1395
1408
  "Goes to " + s.brain + ". " +
1396
1409
  (String(body.value ?? "").includes(mentionOf(s))
@@ -0,0 +1,60 @@
1
+ /* What a screen says about a staff member who cannot run yet.
2
+ *
3
+ * Every screen with a button that wakes somebody (Run now, Run once now, a new issue, a
4
+ * mention) used to offer it to a staff member with no App or no credential, and the run it
5
+ * started failed where nobody was looking. One note, the same everywhere: what is left, and on
6
+ * a hosted portal the command for each step, since setting up is only done on your machine. */
7
+
8
+ import { el, toClipboard } from "../dom.js";
9
+ import { canRun, ROSTER, sentence, stepCommand, whatsLeft } from "../readiness.js";
10
+ import { go } from "../router.js";
11
+ import { S } from "../state.js";
12
+
13
+ /** One roster command, with a Copy button. */
14
+ export function commandLine(cmd) {
15
+ const text = `${ROSTER} ${cmd}`;
16
+ const copy = el("button", { className: "ghbtn", textContent: "Copy" });
17
+ copy.onclick = () => toClipboard(text, copy, "Copy");
18
+ return el("div", { className: "connline" }, [el("code", { textContent: text }), copy]);
19
+ }
20
+
21
+ /** The note, or null when they can run (or it is not known yet). */
22
+ export function notReadyNote(s) {
23
+ if (canRun(s.handle)) return null;
24
+ const left = S.readiness[s.handle];
25
+ const box = el("div", { className: "warnline notready" }, [
26
+ el("span", {
27
+ textContent: `${s.name} is not set up yet, so nothing will start them. Still to do: ${sentence(left)}.`,
28
+ }),
29
+ ]);
30
+ if (!S.hosted) {
31
+ // On your machine the steps are a click away, on Staff.
32
+ const finish = el("button", { className: "ghbtn primary", textContent: "Finish setting up" });
33
+ finish.onclick = () => {
34
+ S.staffOpen = { handle: s.handle, name: s.name, dir: s.dir };
35
+ go({ view: "staff" });
36
+ };
37
+ box.append(el("div", { className: "row" }, [finish]));
38
+ } else {
39
+ const seen = new Set();
40
+ for (const what of left) {
41
+ const cmd = stepCommand(what, s.handle);
42
+ if (!cmd || seen.has(cmd)) continue;
43
+ seen.add(cmd);
44
+ box.append(commandLine(cmd));
45
+ }
46
+ }
47
+ return box;
48
+ }
49
+
50
+ /**
51
+ * A slot filled once their readiness is known: at once when it is, or when GitHub answers.
52
+ * Landing straight on a screen used to find nothing known yet and nothing that asked.
53
+ */
54
+ export function whenKnown(s, fill) {
55
+ const slot = el("div", { className: "readyslot" });
56
+ const paint = () => slot.replaceChildren(...[fill()].flat().filter(Boolean));
57
+ if (S.readiness?.[s.handle]) paint();
58
+ else whatsLeft(s).then(paint, paint);
59
+ return slot;
60
+ }
@@ -102,13 +102,23 @@ export function viewOrg(m) {
102
102
  .then(({ files }) => {
103
103
  S.orgFiles = files ?? [];
104
104
  paintTree();
105
- const first = S.orgFiles[0]?.path;
105
+ // A file still the questions it shipped with is the thing to do here, so it opens first.
106
+ const first = unwritten().find((p) => S.orgFiles.some((f) => f.path === p)) ?? S.orgFiles[0]?.path;
106
107
  open(S.orgFiles.some((f) => f.path === S.orgOpen) ? S.orgOpen : first);
107
108
  })
108
109
  .catch((e) => {
109
110
  tree.replaceChildren(el("p", { className: "empty err", textContent: e.message }));
110
111
  });
111
112
 
113
+ /** The org files setup is still waiting on, by path. */
114
+ function unwritten() {
115
+ const ids = S.data.unfinished ?? [];
116
+ return [
117
+ ids.includes("business") && "org/business.md",
118
+ ids.includes("priorities") && "org/priorities.md",
119
+ ].filter(Boolean);
120
+ }
121
+
112
122
  function why(file) {
113
123
  return KNOWN[file.path] ?? file.title ?? "";
114
124
  }
@@ -132,6 +142,9 @@ export function viewOrg(m) {
132
142
  el("span", { className: "lname", textContent: f.path.replace(/^(org|prompts)\//, "") }),
133
143
  el("span", { className: "lrepo", textContent: why(f) }),
134
144
  );
145
+ if (unwritten().includes(f.path)) {
146
+ t.append(el("span", { className: "chip warm", textContent: "Not written yet" }));
147
+ }
135
148
  b.append(t);
136
149
  b.onclick = () => open(f.path);
137
150
  group.append(b);
@@ -9,7 +9,10 @@ import { post } from "../api.js";
9
9
  import { sheet } from "../dialog.js";
10
10
  import { el, grow } from "../dom.js";
11
11
  import { icon } from "../icons.js";
12
+ import { canRun, whatsLeft } from "../readiness.js";
12
13
  import { render } from "../router.js";
14
+ import { S } from "../state.js";
15
+ import { commandLine, notReadyNote, whenKnown } from "./notready.js";
13
16
 
14
17
  /* The last answer, so a repaint after Save does not flash an empty screen. */
15
18
  let last = null;
@@ -36,7 +39,8 @@ function draw(body, d, add) {
36
39
  add.onclick = () => edit(d, null, null);
37
40
  add.disabled = !d.staff.length;
38
41
  if (!d.staff.length) {
39
- body.append(el("p", { className: "sub", textContent: "Hire a staff member first." }));
42
+ body.append(el("p", { className: "sub", textContent: S.hosted ? "Hire a staff member first, on your machine:" : "Hire a staff member first, under Staff." }));
43
+ if (S.hosted) body.append(commandLine("hire cto --apply"));
40
44
  return;
41
45
  }
42
46
  for (const s of d.staff) {
@@ -46,7 +50,9 @@ function draw(body, d, add) {
46
50
  const more = el("button", { className: "routadd" }, [icon("plus"), el("span", { textContent: "Add a routine for " + s.name })]);
47
51
  more.onclick = () => edit(d, s, null);
48
52
  list.append(more);
49
- body.append(el("h2", { className: "connhead", textContent: s.name }), list);
53
+ // Routines run on the same App and credential as everything else, so they wait on setup too.
54
+ const who = whole(s);
55
+ body.append(el("h2", { className: "connhead", textContent: s.name }), whenKnown(who, () => notReadyNote(who)), list);
50
56
  }
51
57
  }
52
58
 
@@ -66,6 +72,12 @@ function dailyRow(s, d) {
66
72
  function routineRow(s, r, d) {
67
73
  const run = el("button", { className: "ghbtn", textContent: "Run now" });
68
74
  run.onclick = () => runNow(s, r, run);
75
+ const who = whole(s);
76
+ whatsLeft(who).then(() => {
77
+ if (canRun(s.handle)) return;
78
+ run.disabled = true;
79
+ run.title = `${s.name} is not set up yet`;
80
+ }, () => {});
69
81
  const change = el("button", { className: "ghbtn", textContent: "Edit" });
70
82
  change.onclick = () => edit(d, s, r);
71
83
  const remove = el("button", { className: "ghbtn", textContent: "Remove" });
@@ -81,6 +93,11 @@ function routineRow(s, r, d) {
81
93
  ]);
82
94
  }
83
95
 
96
+ /** The staff member as the org export has them, which is what readiness reads. */
97
+ function whole(s) {
98
+ return (S.data?.staff ?? []).find((x) => x.handle === s.handle) ?? s;
99
+ }
100
+
84
101
  async function runNow(s, r, btn) {
85
102
  btn.disabled = true;
86
103
  btn.textContent = "Starting…";
@@ -7,6 +7,8 @@
7
7
  import { runStatus, startRun } from "../api.js";
8
8
  import { askYes } from "../dialog.js";
9
9
  import { el } from "../dom.js";
10
+ import { whatsLeft } from "../readiness.js";
11
+ import { S } from "../state.js";
10
12
 
11
13
  /**
12
14
  * @param {{staff: string, name: string, onDone?: (ok: boolean) => void}} opts
@@ -86,6 +88,9 @@ export function runOnce(opts) {
86
88
  for (const f of now.failedAt ?? []) done.append(el("p", { className: "sub", textContent: "Failed at " + f }));
87
89
  if (!ok) done.append(el("p", { className: "sub", textContent: "Troubleshooting, in the docs, has what each failure usually means." }));
88
90
  out.replaceChildren(done);
91
+ // "Run once" is done now, and every screen that said otherwise should stop saying it.
92
+ const who = (S.data?.staff ?? []).find((x) => x.handle === opts.staff);
93
+ if (ok && who) whatsLeft(who, true).catch(() => {});
89
94
  opts.onDone?.(ok);
90
95
  };
91
96
  tick();
@@ -7,6 +7,7 @@ import { getRuns } from "../api.js";
7
7
  import { ago, el, esc, skeleton } from "../dom.js";
8
8
  import { render } from "../router.js";
9
9
  import { S } from "../state.js";
10
+ import { notReadyNote, whenKnown } from "./notready.js";
10
11
 
11
12
  /** How many runs a staff member's table shows. The spend covers all of the last 30 days. */
12
13
  const SHOWN = 15;
@@ -89,6 +90,9 @@ function paint(m, data) {
89
90
  }, 3000);
90
91
  }
91
92
 
93
+ if (!(data.staff ?? []).length) {
94
+ m.append(el("p", { className: "hnote", textContent: "Nobody hired yet, so nothing has run. Home says what is left." }));
95
+ }
92
96
  for (const s of data.staff ?? []) m.append(...staffSection(s));
93
97
 
94
98
  m.append(
@@ -111,7 +115,13 @@ function staffSection(s) {
111
115
  const body = el("div", { className: "hbody runs" });
112
116
  for (const e of s.errors ?? []) body.append(el("p", { className: "hnote err", textContent: e }));
113
117
  if (!(s.runs ?? []).length) {
114
- body.append(el("p", { className: "hnote", textContent: "No runs in the last 30 days." }));
118
+ // "No runs" read as idle, when the truth was that they could not run at all.
119
+ const who = (S.data?.staff ?? []).find((x) => x.handle === s.handle) ?? s;
120
+ body.append(
121
+ whenKnown(who, () =>
122
+ notReadyNote(who) ?? el("p", { className: "hnote", textContent: "No runs in the last 30 days." }),
123
+ ),
124
+ );
115
125
  return [head, body];
116
126
  }
117
127
 
@@ -9,10 +9,11 @@ import { post } from "../api.js";
9
9
  import { askYes, sheet } from "../dialog.js";
10
10
  import { pending } from "../inflight.js";
11
11
  import { ago, el, esc } from "../dom.js";
12
- import { sentence, staffProgress, whatsLeft } from "../readiness.js";
12
+ import { sentence, staffProgress, stepCommand, whatsLeft } from "../readiness.js";
13
13
  import { refreshAll } from "../refresh.js";
14
14
  import { S } from "../state.js";
15
15
  import { hireFlow, line, rolePicker } from "./hire.js";
16
+ import { commandLine } from "./notready.js";
16
17
 
17
18
  /**
18
19
  * Resolves once nothing is loading and `node` has stopped changing for a moment, or after a few
@@ -50,7 +51,15 @@ let current = null;
50
51
  export function viewStaff(m, o = {}) {
51
52
  m.append(el("h1", { textContent: "Staff" }));
52
53
  const empty = !S.data.staff.length;
53
- if (empty) m.append(el("p", { className: "sub", textContent: "No staff yet. Pick a role to hire your first." }));
54
+ /* Hosted, the picker led to a hire that only the server on your machine can do, and it
55
+ failed there. The command is the way in. */
56
+ if (empty && S.hosted) {
57
+ m.append(
58
+ el("p", { className: "sub", textContent: "No staff yet. Hiring creates repos and an App, so it is done on your machine:" }),
59
+ commandLine("hire cto --apply"),
60
+ el("p", { className: "sub", textContent: "cmo and support are the other roles, or any handle with --name." }),
61
+ );
62
+ } else if (empty) m.append(el("p", { className: "sub", textContent: "No staff yet. Pick a role to hire your first." }));
54
63
 
55
64
  const pane = el("div", { className: "hirepane" });
56
65
 
@@ -83,7 +92,7 @@ export function viewStaff(m, o = {}) {
83
92
  if (current) current.close();
84
93
  else pane.replaceChildren();
85
94
  S.staffOpen = null;
86
- if (empty) pick();
95
+ if (empty && !S.hosted) pick();
87
96
  }
88
97
 
89
98
  // With nobody hired the roles are the page. After that they are a dialog behind Hire someone.
@@ -196,6 +205,12 @@ export function viewStaff(m, o = {}) {
196
205
  warn.textContent =
197
206
  "Not ready to run. " + (p ? `${p.done} of ${p.total} done. ` : "") +
198
207
  "Still to do: " + sentence(left) + ".";
208
+ // Hosted has no Finish setting up, so each step comes with what to run instead.
209
+ if (S.hosted) {
210
+ const cmds = [...new Set(left.map((x) => stepCommand(x, s.handle)).filter(Boolean))];
211
+ warn.classList.add("notready");
212
+ warn.replaceChildren(el("span", { textContent: warn.textContent }), ...cmds.map(commandLine));
213
+ }
199
214
  });
200
215
  d.append(warn);
201
216
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nanocollective/roster",
3
- "version": "0.1.0-beta.30",
3
+ "version": "0.1.0-beta.31",
4
4
  "description": "An agent-run org, powered by GitHub. Scaffold AI staff members whose brain is a repo.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -138,3 +138,5 @@
138
138
  .peopleonly::after{content:"Read only";font:12.5px var(--sans);color:var(--ink-dim);margin-left:6px}
139
139
  .peopleonly{justify-content:flex-start;align-items:center}
140
140
  }
141
+ /* An org file setup is still waiting on: a small tag under its name, not a bar. */
142
+ .tlayer .t > .chip{align-self:flex-start;margin-top:4px;height:auto;padding-block:1px;font-size:11px}