@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.
Files changed (37) hide show
  1. package/README.md +1 -0
  2. package/dist/cli.js +150 -45
  3. package/dist/worker/assets/assets/css/base.css +17 -2
  4. package/dist/worker/assets/assets/css/home.css +42 -29
  5. package/dist/worker/assets/assets/css/layout.css +6 -0
  6. package/dist/worker/assets/assets/js/api.js +30 -0
  7. package/dist/worker/assets/assets/js/app.js +37 -2
  8. package/dist/worker/assets/assets/js/homesort.js +4 -21
  9. package/dist/worker/assets/assets/js/views/home.js +115 -79
  10. package/dist/worker/index.js +795 -85
  11. package/docs/architecture.md +22 -3
  12. package/docs/commands.md +29 -8
  13. package/docs/concepts.md +1 -1
  14. package/docs/developing.md +1 -1
  15. package/docs/getting-started.md +5 -2
  16. package/docs/hosting.md +25 -0
  17. package/docs/memory.md +2 -1
  18. package/docs/portal.md +4 -3
  19. package/docs/security.md +13 -0
  20. package/docs/session-workflow.md +10 -6
  21. package/docs/staff-yaml.md +5 -2
  22. package/package.json +1 -1
  23. package/templates/brain/CHARTER.md +2 -2
  24. package/templates/brain/STATE.md +16 -0
  25. package/templates/brain/memory/INDEX.md +1 -1
  26. package/templates/ops/.github/workflows/session.yaml +14 -1
  27. package/templates/ops/org/voice.md +2 -2
  28. package/templates/ops/prompts/daily.md +27 -18
  29. package/templates/ops/prompts/mention.md +6 -2
  30. package/templates/ops/status-week.mjs +169 -0
  31. package/templates/portal/css/base.css +17 -2
  32. package/templates/portal/css/home.css +42 -29
  33. package/templates/portal/css/layout.css +6 -0
  34. package/templates/portal/js/api.js +30 -0
  35. package/templates/portal/js/app.js +37 -2
  36. package/templates/portal/js/homesort.js +4 -21
  37. package/templates/portal/js/views/home.js +115 -79
package/README.md CHANGED
@@ -47,6 +47,7 @@ roster run cto # one run now, followed to the end
47
47
  roster doctor # is any of this actually wired up
48
48
  roster fix # every finding, as one brief for a coding agent
49
49
  roster portal # read every brain, and the docs, locally
50
+ roster portal deploy # the same portal on your own URL, behind Sign in with GitHub
50
51
  roster prompt cto # the exact prompt a run will be sent
51
52
  roster upgrade # take framework changes without losing your edits
52
53
  roster retire cto # let someone go, with their brain kept
package/dist/cli.js CHANGED
@@ -2122,6 +2122,7 @@ function buildPlan(ws, org, handle, opts, parseYaml3) {
2122
2122
  handle,
2123
2123
  ...ASK_KINDS,
2124
2124
  "keep-open",
2125
+ "status",
2125
2126
  "build",
2126
2127
  "blocked",
2127
2128
  ...peers.map((p) => `from-${p.handle}`)
@@ -2381,12 +2382,15 @@ async function applyPlan(ws, plan2, opts) {
2381
2382
  "-X",
2382
2383
  "POST",
2383
2384
  "-f",
2384
- "title=\u{1F4CD} Where we are (living status - always current)",
2385
+ `title=${statusTitle(/* @__PURE__ */ new Date())}`,
2385
2386
  "-f",
2386
2387
  `body=${statusBody(staff)}`,
2387
- // A sweep closes anything with nothing left to do on it. This one never runs out.
2388
+ // A sweep closes anything with nothing left to do on it. This one never runs out, until
2389
+ // next week's replaces it.
2388
2390
  "-f",
2389
- "labels[]=keep-open"
2391
+ "labels[]=keep-open",
2392
+ "-f",
2393
+ "labels[]=status"
2390
2394
  ]);
2391
2395
  if (issue.ok && issue.data?.number) {
2392
2396
  await ghJson([
@@ -2499,9 +2503,20 @@ ${line.trimEnd()}
2499
2503
  lines.splice(i, 0, line.trimEnd());
2500
2504
  return lines.join("\n");
2501
2505
  }
2506
+ function statusTitle(now) {
2507
+ const monday = new Date(
2508
+ Date.UTC(
2509
+ now.getUTCFullYear(),
2510
+ now.getUTCMonth(),
2511
+ now.getUTCDate() - (now.getUTCDay() + 6) % 7
2512
+ )
2513
+ );
2514
+ const month = "Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" ")[monday.getUTCMonth()];
2515
+ return `\u{1F4CD} Where we are: week of ${monday.getUTCDate()} ${month}`;
2516
+ }
2502
2517
  function statusBody(staff) {
2503
2518
  return [
2504
- `**${staff.name}'s living status. Always current \u2014 this issue is rewritten, never appended to.**`,
2519
+ `**${staff.name}'s status this week. Rewritten every run; a new issue opens each Monday.**`,
2505
2520
  "",
2506
2521
  "| | The ask |",
2507
2522
  "|---|---|",
@@ -2913,7 +2928,20 @@ function workerBundle() {
2913
2928
  }
2914
2929
  return null;
2915
2930
  }
2916
- function wrangler(args) {
2931
+ async function wrangler(args) {
2932
+ let code = 1;
2933
+ for (let attempt = 1; attempt <= 3; attempt++) {
2934
+ code = await wranglerOnce(args);
2935
+ if (code === 0) return 0;
2936
+ if (attempt < 3) {
2937
+ process.stdout.write(` wrangler failed; trying again (${attempt + 1} of 3)\u2026
2938
+ `);
2939
+ await new Promise((r) => setTimeout(r, 15e3 * attempt));
2940
+ }
2941
+ }
2942
+ return code;
2943
+ }
2944
+ function wranglerOnce(args) {
2917
2945
  return new Promise((resolve8) => {
2918
2946
  const child = spawn("npx", ["--yes", WRANGLER, ...args], { stdio: "inherit" });
2919
2947
  child.on("close", (code) => resolve8(code ?? 1));
@@ -3038,11 +3066,22 @@ function githubClient(token, opts = {}) {
3038
3066
  body2 = JSON.stringify(o.body);
3039
3067
  h["content-type"] = "application/json";
3040
3068
  }
3069
+ const reads = method === "GET" || o.retry === true;
3041
3070
  let res;
3042
- try {
3043
- res = await doFetch(url, { method, headers: h, body: body2 });
3044
- } catch (err) {
3045
- return { ok: false, error: `GitHub could not be reached: ${err.message}` };
3071
+ for (let attempt = 0; ; attempt++) {
3072
+ try {
3073
+ res = await doFetch(url, { method, headers: h, body: body2 });
3074
+ } catch (err) {
3075
+ if (reads && attempt === 0) continue;
3076
+ return { ok: false, error: `GitHub could not be reached: ${err.message}` };
3077
+ }
3078
+ if (reads && attempt === 0 && [502, 503, 504].includes(res.status)) {
3079
+ await res.body?.cancel().catch(() => {
3080
+ });
3081
+ await new Promise((r) => setTimeout(r, 400));
3082
+ continue;
3083
+ }
3084
+ break;
3046
3085
  }
3047
3086
  if (res.status === 304 && kept) {
3048
3087
  seen.delete(key);
@@ -3072,7 +3111,8 @@ function githubClient(token, opts = {}) {
3072
3111
  const res = await request(
3073
3112
  "POST",
3074
3113
  "graphql",
3075
- { body: { query: query2, variables: vars } }
3114
+ // A query reads; a mutation writes, and is never asked twice.
3115
+ { body: { query: query2, variables: vars }, retry: !/^\s*mutation\b/.test(query2) }
3076
3116
  );
3077
3117
  if (!res.ok) return { ok: false, status: res.status, error: res.error };
3078
3118
  const errors = res.data?.errors ?? [];
@@ -5608,7 +5648,7 @@ Nothing to fix. \`roster doctor\` is clean.
5608
5648
  "them is reverted by the next `roster upgrade`, and the mistake is invisible until it is",
5609
5649
  "expensive. Do not touch:",
5610
5650
  "",
5611
- `- \`${ws.opsName}/compose.mjs\`, \`agents.mjs\`, \`runner-plan.mjs\`, \`inflight.mjs\`, \`run-record.mjs\` \u2014 vendored from the framework.`,
5651
+ `- \`${ws.opsName}/compose.mjs\`, \`agents.mjs\`, \`runner-plan.mjs\`, \`inflight.mjs\`, \`run-record.mjs\`, \`status-week.mjs\` \u2014 vendored from the framework.`,
5612
5652
  `- \`${ws.opsName}/.github/workflows/\` and any brain's \`.github/workflows/\` \u2014 generated, and`,
5613
5653
  " GitHub App tokens cannot push changes there in any case.",
5614
5654
  `- \`${ws.opsName}/.roster/\` \u2014 the recorded merge base.`,
@@ -6910,7 +6950,7 @@ var TIMELINE_PR = `
6910
6950
  ... on ReadyForReviewEvent { actor { login } createdAt }
6911
6951
  ... on ReviewRequestedEvent {
6912
6952
  actor { login } createdAt
6913
- requestedReviewer { ... on User { login } ... on Team { name } }
6953
+ requestedReviewer { __typename ... on User { login } ... on Bot { login } }
6914
6954
  }
6915
6955
  `;
6916
6956
  var CLOSED_FIRST = 30;
@@ -7019,6 +7059,9 @@ async function query(gh, owner, name) {
7019
7059
  if (!res.ok) throw new Error(res.error);
7020
7060
  return res.data?.repository;
7021
7061
  }
7062
+ function isStatus(n) {
7063
+ return (n.labels?.nodes ?? []).some((l) => l?.name === "status" || l?.name === "keep-open");
7064
+ }
7022
7065
  function shape(n, repo, role, kind) {
7023
7066
  const events = (n.timelineItems?.nodes ?? []).map((e) => event(e)).filter(Boolean);
7024
7067
  return {
@@ -7028,8 +7071,9 @@ function shape(n, repo, role, kind) {
7028
7071
  number: n.number,
7029
7072
  title: n.title ?? "",
7030
7073
  // The list carries the body only to find a decision's default; a row never shows it, and
7031
- // a thread that is opened is read whole on its own.
7032
- body: n.timelineItems ? n.body ?? "" : "",
7074
+ // a thread that is opened is read whole on its own. A status issue's body is the exception:
7075
+ // it is the staff member's report, and Home shows it.
7076
+ body: n.timelineItems || isStatus(n) ? n.body ?? "" : "",
7033
7077
  ...extras(n),
7034
7078
  labels: (n.labels?.nodes ?? []).map((l) => l.name),
7035
7079
  assignees: (n.assignees?.nodes ?? []).map((a) => a.login),
@@ -7155,7 +7199,9 @@ function event(e) {
7155
7199
  type: "review-requested",
7156
7200
  actor: who,
7157
7201
  createdAt: at,
7158
- assignee: e.requestedReviewer?.login ?? e.requestedReviewer?.name ?? ""
7202
+ /* A team's name needs the read:org scope, which a portal signed in with `repo` alone does
7203
+ not have, and asking for it fails the whole thread. Its type needs nothing. */
7204
+ assignee: e.requestedReviewer?.login ?? (e.requestedReviewer?.__typename === "Team" ? "a team" : "")
7159
7205
  };
7160
7206
  case "LabeledEvent":
7161
7207
  return { type: "labeled", actor: who, createdAt: at, label: e.label?.name ?? "" };
@@ -7521,15 +7567,19 @@ function isTextPath(path, size2) {
7521
7567
  return size2 <= MAX_TEXT && !BINARY.test(path);
7522
7568
  }
7523
7569
  var Snapshots = class {
7524
- constructor(kv, freshMs = 4e3) {
7570
+ constructor(kv, freshMs = 4e3, shareInflight = true) {
7525
7571
  this.kv = kv;
7526
7572
  this.freshMs = freshMs;
7573
+ this.shareInflight = shareInflight;
7527
7574
  }
7528
7575
  kv;
7529
7576
  freshMs;
7577
+ shareInflight;
7530
7578
  repos = /* @__PURE__ */ new Map();
7531
7579
  inflight = /* @__PURE__ */ new Map();
7532
7580
  checked = /* @__PURE__ */ new Map();
7581
+ /** Who wants to hear how a refresh in flight is going. Every caller that joined it. */
7582
+ listeners = /* @__PURE__ */ new Map();
7533
7583
  get(repo) {
7534
7584
  return this.repos.get(repo);
7535
7585
  }
@@ -7544,11 +7594,23 @@ var Snapshots = class {
7544
7594
  if (!opts.force && this.repos.has(repo) && Date.now() - last < this.freshMs) {
7545
7595
  return Promise.resolve({ ok: true, changed: false });
7546
7596
  }
7597
+ const pathsOnly = opts.pathsOnly === true;
7598
+ if (!this.shareInflight) {
7599
+ return this.load(gh, repo, pathsOnly, (step) => opts.report?.(repo, step));
7600
+ }
7601
+ if (opts.report) {
7602
+ if (!this.listeners.has(repo)) this.listeners.set(repo, /* @__PURE__ */ new Set());
7603
+ this.listeners.get(repo).add(opts.report);
7604
+ }
7547
7605
  const running = this.inflight.get(repo);
7548
7606
  if (running) return running;
7549
- const work = this.load(gh, repo, opts.pathsOnly === true).finally(
7550
- () => this.inflight.delete(repo)
7551
- );
7607
+ const say = (step) => {
7608
+ for (const report3 of this.listeners.get(repo) ?? []) report3(repo, step);
7609
+ };
7610
+ const work = this.load(gh, repo, pathsOnly, say).finally(() => {
7611
+ this.inflight.delete(repo);
7612
+ this.listeners.delete(repo);
7613
+ });
7552
7614
  this.inflight.set(repo, work);
7553
7615
  return work;
7554
7616
  }
@@ -7569,7 +7631,8 @@ var Snapshots = class {
7569
7631
  if (commit2) snap.sha = commit2;
7570
7632
  void this.kv.put(`blob:${sha}`, text2);
7571
7633
  }
7572
- async load(gh, repo, pathsOnly) {
7634
+ async load(gh, repo, pathsOnly, say) {
7635
+ say("checking for changes");
7573
7636
  const head2 = await gh.request("GET", `repos/${repo}/commits/HEAD`, {
7574
7637
  accept: "application/vnd.github.sha",
7575
7638
  as: "text"
@@ -7581,14 +7644,16 @@ var Snapshots = class {
7581
7644
  const sha = head2.data.trim();
7582
7645
  const before = this.repos.get(repo);
7583
7646
  if (before && before.sha === sha && before.pathsOnly === pathsOnly) {
7647
+ say("up to date");
7584
7648
  return { ok: true, changed: false };
7585
7649
  }
7586
- const next = await this.build(gh, repo, sha, pathsOnly, before);
7650
+ say("reading the file list");
7651
+ const next = await this.build(gh, repo, sha, pathsOnly, say, before);
7587
7652
  if (!next.ok) return { ok: false, changed: false, error: next.error, status: next.status };
7588
7653
  this.repos.set(repo, next.snap);
7589
7654
  return { ok: true, changed: true };
7590
7655
  }
7591
- async build(gh, repo, sha, pathsOnly, before) {
7656
+ async build(gh, repo, sha, pathsOnly, say, before) {
7592
7657
  const [tree, commit2] = await Promise.all([
7593
7658
  gh.request(
7594
7659
  "GET",
@@ -7631,6 +7696,7 @@ var Snapshots = class {
7631
7696
  })
7632
7697
  );
7633
7698
  if (missing2.length > TARBALL_OVER) {
7699
+ say("downloading the repository");
7634
7700
  const tgz = await gh.request("GET", `repos/${repo}/tarball/${sha}`, {
7635
7701
  as: "bytes"
7636
7702
  });
@@ -7645,6 +7711,9 @@ var Snapshots = class {
7645
7711
  void this.kv.put(`blob:${e.sha}`, text2);
7646
7712
  }
7647
7713
  } else {
7714
+ if (missing2.length) {
7715
+ say(`fetching ${missing2.length} changed file${missing2.length === 1 ? "" : "s"}`);
7716
+ }
7648
7717
  await pool2(missing2, 8, async ([, e]) => {
7649
7718
  const res = await gh.request("GET", `repos/${repo}/git/blobs/${e.sha}`, {
7650
7719
  accept: "application/vnd.github.raw",
@@ -7657,7 +7726,7 @@ var Snapshots = class {
7657
7726
  void this.kv.put(`blob:${e.sha}`, text2);
7658
7727
  });
7659
7728
  }
7660
- await this.dates(gh, repo, snap, before);
7729
+ await this.dates(gh, repo, snap, say, before);
7661
7730
  return { ok: true, snap };
7662
7731
  }
7663
7732
  /**
@@ -7667,7 +7736,7 @@ var Snapshots = class {
7667
7736
  * GitHub, in batches, only for the ones that are new or changed. Kept by commit, so a warm
7668
7737
  * start never asks at all.
7669
7738
  */
7670
- async dates(gh, repo, snap, before) {
7739
+ async dates(gh, repo, snap, say, before) {
7671
7740
  const key = `dates:${repo}@${snap.sha}`;
7672
7741
  const kept = await this.kv.get(key);
7673
7742
  if (kept) {
@@ -7682,6 +7751,7 @@ var Snapshots = class {
7682
7751
  else ask.push(path);
7683
7752
  }
7684
7753
  const [owner, name] = repo.split("/");
7754
+ if (ask.length) say("reading file dates");
7685
7755
  for (let i = 0; i < ask.length; i += DATES_PER_QUERY) {
7686
7756
  const batch = ask.slice(i, i + DATES_PER_QUERY);
7687
7757
  const fields = batch.map(
@@ -7767,7 +7837,7 @@ var TTL = 45e3;
7767
7837
  var LABEL_TTL = 3e5;
7768
7838
  function createPortal(opts) {
7769
7839
  const root2 = opts.root ?? `/@roster/${opts.org}`;
7770
- const snapshots = new Snapshots(opts.kv);
7840
+ const snapshots = new Snapshots(opts.kv, void 0, opts.shareInflight ?? true);
7771
7841
  mount(
7772
7842
  root2,
7773
7843
  snapshots.tree((repo) => repo.slice(repo.indexOf("/") + 1))
@@ -7812,19 +7882,24 @@ async function handlePortal(req, portal, actor) {
7812
7882
  }
7813
7883
  async function ready(c, opts = {}) {
7814
7884
  const { portal, actor } = c;
7815
- const ops = await portal.snapshots.refresh(actor.gh, `${portal.org}/${portal.opsName}`, opts);
7885
+ const report3 = opts.report;
7886
+ const ops = await portal.snapshots.refresh(actor.gh, `${portal.org}/${portal.opsName}`, {
7887
+ force: opts.force,
7888
+ report: report3
7889
+ });
7816
7890
  if (!ops.ok) {
7817
7891
  throw new HttpError(
7818
7892
  ops.status === 404 || ops.status === 401 ? ops.status : 502,
7819
7893
  `could not read ${portal.org}/${portal.opsName}: ${ops.error}`
7820
7894
  );
7821
7895
  }
7896
+ report3?.(`${portal.org}/${portal.opsName}`, "ready");
7822
7897
  const org = readOrg(portal.ws.opsDir, parseYaml2);
7823
7898
  const brains = (org.staff ?? []).map((s) => String(s.dir ?? s.handle));
7824
7899
  const products = opts.products ? (org.repos ?? []).map((r) => String(r.name)).filter((n) => n !== portal.opsName && !brains.includes(n)) : [];
7825
7900
  const results = await Promise.all([
7826
7901
  ...brains.map(
7827
- (d) => portal.snapshots.refresh(actor.gh, `${portal.org}/${d}`, { force: opts.force }).then((r) => ({ dir: d, ...r }))
7902
+ (d) => portal.snapshots.refresh(actor.gh, `${portal.org}/${d}`, { force: opts.force, report: report3 }).then((r) => ({ dir: d, ...r }))
7828
7903
  ),
7829
7904
  ...products.map(
7830
7905
  (d) => portal.snapshots.refresh(actor.gh, `${portal.org}/${d}`, { force: opts.force, pathsOnly: true }).then((r) => ({ dir: d, ...r }))
@@ -7852,24 +7927,26 @@ var ROUTES = {
7852
7927
  headers: { "content-type": asset.type, "cache-control": "public, max-age=86400" }
7853
7928
  });
7854
7929
  },
7930
+ /* The whole org. With ?progress=1 it is a stream instead: a line per step as it is read from
7931
+ GitHub, then the org, so a first load can say what it is doing rather than "Loading…". */
7855
7932
  "/api/org": async (c) => {
7856
- const { portal, actor } = c;
7857
- const { org, brains } = await ready(c);
7858
- const byRoot = /* @__PURE__ */ new Map();
7859
- await Promise.all(
7860
- brains.map(async (dir) => {
7861
- const repo = `${portal.org}/${dir}`;
7862
- const snap = portal.snapshots.get(repo);
7863
- if (!snap) return;
7864
- byRoot.set(
7865
- join29(portal.ws.root, dir),
7866
- await loadHistory(actor.gh, portal.kv, repo, snap.sha)
7867
- );
7868
- })
7869
- );
7870
- const data = buildExport(portal.ws, org, parseYaml2, { history: loadedHistory(byRoot) });
7871
- const left = unfinished(portal.ws.opsDir, (org.staff ?? []).length);
7872
- return json({ ...data, unfinished: left });
7933
+ if (c.url.searchParams.get("progress") !== "1") return json(await orgExport(c));
7934
+ const { readable, writable } = new TransformStream();
7935
+ const out = writable.getWriter();
7936
+ const line = (o) => out.write(new TextEncoder().encode(`${JSON.stringify(o)}
7937
+ `));
7938
+ const report3 = (repo, step) => {
7939
+ void line({ repo: repo.slice(repo.indexOf("/") + 1), step });
7940
+ };
7941
+ void orgExport(c, report3).then((org) => line({ org })).catch(
7942
+ (err) => line({ error: String(err?.message ?? err), status: err.status })
7943
+ ).finally(() => out.close());
7944
+ return new Response(readable, {
7945
+ headers: {
7946
+ "content-type": "application/x-ndjson; charset=utf-8",
7947
+ "cache-control": "no-store"
7948
+ }
7949
+ });
7873
7950
  },
7874
7951
  /* Every file in the org layer the portal may write: isWritable's allowlist, nothing more. */
7875
7952
  "/api/orglayer": async (c) => {
@@ -8431,6 +8508,24 @@ ${diff}`,
8431
8508
  return new Response(bytes2, { headers: { "content-type": type, "cache-control": "no-store" } });
8432
8509
  }
8433
8510
  };
8511
+ async function orgExport(c, report3) {
8512
+ const { portal, actor } = c;
8513
+ const { org, brains } = await ready(c, { report: report3 });
8514
+ const byRoot = /* @__PURE__ */ new Map();
8515
+ await Promise.all(
8516
+ brains.map(async (dir) => {
8517
+ const repo = `${portal.org}/${dir}`;
8518
+ const snap = portal.snapshots.get(repo);
8519
+ if (!snap) return;
8520
+ report3?.(repo, "reading recent history");
8521
+ byRoot.set(join29(portal.ws.root, dir), await loadHistory(actor.gh, portal.kv, repo, snap.sha));
8522
+ report3?.(repo, "ready");
8523
+ })
8524
+ );
8525
+ const data = buildExport(portal.ws, org, parseYaml2, { history: loadedHistory(byRoot) });
8526
+ const left = unfinished(portal.ws.opsDir, (org.staff ?? []).length);
8527
+ return { ...data, unfinished: left };
8528
+ }
8434
8529
  function knownRepos(portal) {
8435
8530
  const org = readOrg(portal.ws.opsDir, parseYaml2);
8436
8531
  return (org.repos ?? []).map((r) => ({
@@ -8998,7 +9093,17 @@ async function portalCommand(argv) {
8998
9093
  return;
8999
9094
  }
9000
9095
  res.writeHead(answer.status, Object.fromEntries(answer.headers));
9001
- res.end(Buffer.from(await answer.arrayBuffer()));
9096
+ if (!answer.body) {
9097
+ res.end();
9098
+ return;
9099
+ }
9100
+ const reader = answer.body.getReader();
9101
+ for (; ; ) {
9102
+ const { done, value } = await reader.read();
9103
+ if (done) break;
9104
+ res.write(value);
9105
+ }
9106
+ res.end();
9002
9107
  };
9003
9108
  const writeAllowed = (req) => {
9004
9109
  if (req.method !== "POST") return false;
@@ -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 edge, so the header leaves room for it. */
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;padding-right:44px}
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
- .homecard{padding:14px 16px;cursor:pointer;display:grid;grid-template-columns:1fr auto;
24
- align-items:center;gap:10px 18px}
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
- .homecard:hover{border-color:var(--border-strong)}
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:4px}
34
- .homedue{margin:8px 0 0;font-size:12.5px;color:var(--ink-dim)}
35
- .homedue.late{color:var(--warn)}
36
- .homeacts{justify-content:flex-end;flex-wrap:nowrap}
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
- .homecard{grid-template-columns:1fr}
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
- .homecard.gone,.homeline.gone{opacity:0;transform:translateX(12px);
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, and on a card in Needs you a blue
70
- edge that follows its corners. A row inside a list card carries no edge, since a bar drawn to
71
- the card's side squares off its rounded corners. Opening the thread marks it read, here and on
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
- .unread .homeopen::before,.unread .homerowtitle::before{content:"";display:inline-block;width:7px;height:7px;border-radius:50%;
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:auto 1fr auto;align-items:center;gap:12px;
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 { getOrg, getSession } from "./api.js";
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([getOrg(), getSession()]);
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
  /**