@nanocollective/roster 0.1.0-beta.1 → 0.1.0-beta.10

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 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;
@@ -7155,7 +7195,9 @@ function event(e) {
7155
7195
  type: "review-requested",
7156
7196
  actor: who,
7157
7197
  createdAt: at,
7158
- assignee: e.requestedReviewer?.login ?? e.requestedReviewer?.name ?? ""
7198
+ /* A team's name needs the read:org scope, which a portal signed in with `repo` alone does
7199
+ not have, and asking for it fails the whole thread. Its type needs nothing. */
7200
+ assignee: e.requestedReviewer?.login ?? (e.requestedReviewer?.__typename === "Team" ? "a team" : "")
7159
7201
  };
7160
7202
  case "LabeledEvent":
7161
7203
  return { type: "labeled", actor: who, createdAt: at, label: e.label?.name ?? "" };
@@ -7521,15 +7563,19 @@ function isTextPath(path, size2) {
7521
7563
  return size2 <= MAX_TEXT && !BINARY.test(path);
7522
7564
  }
7523
7565
  var Snapshots = class {
7524
- constructor(kv, freshMs = 4e3) {
7566
+ constructor(kv, freshMs = 4e3, shareInflight = true) {
7525
7567
  this.kv = kv;
7526
7568
  this.freshMs = freshMs;
7569
+ this.shareInflight = shareInflight;
7527
7570
  }
7528
7571
  kv;
7529
7572
  freshMs;
7573
+ shareInflight;
7530
7574
  repos = /* @__PURE__ */ new Map();
7531
7575
  inflight = /* @__PURE__ */ new Map();
7532
7576
  checked = /* @__PURE__ */ new Map();
7577
+ /** Who wants to hear how a refresh in flight is going. Every caller that joined it. */
7578
+ listeners = /* @__PURE__ */ new Map();
7533
7579
  get(repo) {
7534
7580
  return this.repos.get(repo);
7535
7581
  }
@@ -7544,11 +7590,23 @@ var Snapshots = class {
7544
7590
  if (!opts.force && this.repos.has(repo) && Date.now() - last < this.freshMs) {
7545
7591
  return Promise.resolve({ ok: true, changed: false });
7546
7592
  }
7593
+ const pathsOnly = opts.pathsOnly === true;
7594
+ if (!this.shareInflight) {
7595
+ return this.load(gh, repo, pathsOnly, (step) => opts.report?.(repo, step));
7596
+ }
7597
+ if (opts.report) {
7598
+ if (!this.listeners.has(repo)) this.listeners.set(repo, /* @__PURE__ */ new Set());
7599
+ this.listeners.get(repo).add(opts.report);
7600
+ }
7547
7601
  const running = this.inflight.get(repo);
7548
7602
  if (running) return running;
7549
- const work = this.load(gh, repo, opts.pathsOnly === true).finally(
7550
- () => this.inflight.delete(repo)
7551
- );
7603
+ const say = (step) => {
7604
+ for (const report3 of this.listeners.get(repo) ?? []) report3(repo, step);
7605
+ };
7606
+ const work = this.load(gh, repo, pathsOnly, say).finally(() => {
7607
+ this.inflight.delete(repo);
7608
+ this.listeners.delete(repo);
7609
+ });
7552
7610
  this.inflight.set(repo, work);
7553
7611
  return work;
7554
7612
  }
@@ -7569,7 +7627,8 @@ var Snapshots = class {
7569
7627
  if (commit2) snap.sha = commit2;
7570
7628
  void this.kv.put(`blob:${sha}`, text2);
7571
7629
  }
7572
- async load(gh, repo, pathsOnly) {
7630
+ async load(gh, repo, pathsOnly, say) {
7631
+ say("checking for changes");
7573
7632
  const head2 = await gh.request("GET", `repos/${repo}/commits/HEAD`, {
7574
7633
  accept: "application/vnd.github.sha",
7575
7634
  as: "text"
@@ -7581,14 +7640,16 @@ var Snapshots = class {
7581
7640
  const sha = head2.data.trim();
7582
7641
  const before = this.repos.get(repo);
7583
7642
  if (before && before.sha === sha && before.pathsOnly === pathsOnly) {
7643
+ say("up to date");
7584
7644
  return { ok: true, changed: false };
7585
7645
  }
7586
- const next = await this.build(gh, repo, sha, pathsOnly, before);
7646
+ say("reading the file list");
7647
+ const next = await this.build(gh, repo, sha, pathsOnly, say, before);
7587
7648
  if (!next.ok) return { ok: false, changed: false, error: next.error, status: next.status };
7588
7649
  this.repos.set(repo, next.snap);
7589
7650
  return { ok: true, changed: true };
7590
7651
  }
7591
- async build(gh, repo, sha, pathsOnly, before) {
7652
+ async build(gh, repo, sha, pathsOnly, say, before) {
7592
7653
  const [tree, commit2] = await Promise.all([
7593
7654
  gh.request(
7594
7655
  "GET",
@@ -7631,6 +7692,7 @@ var Snapshots = class {
7631
7692
  })
7632
7693
  );
7633
7694
  if (missing2.length > TARBALL_OVER) {
7695
+ say("downloading the repository");
7634
7696
  const tgz = await gh.request("GET", `repos/${repo}/tarball/${sha}`, {
7635
7697
  as: "bytes"
7636
7698
  });
@@ -7645,6 +7707,9 @@ var Snapshots = class {
7645
7707
  void this.kv.put(`blob:${e.sha}`, text2);
7646
7708
  }
7647
7709
  } else {
7710
+ if (missing2.length) {
7711
+ say(`fetching ${missing2.length} changed file${missing2.length === 1 ? "" : "s"}`);
7712
+ }
7648
7713
  await pool2(missing2, 8, async ([, e]) => {
7649
7714
  const res = await gh.request("GET", `repos/${repo}/git/blobs/${e.sha}`, {
7650
7715
  accept: "application/vnd.github.raw",
@@ -7657,7 +7722,7 @@ var Snapshots = class {
7657
7722
  void this.kv.put(`blob:${e.sha}`, text2);
7658
7723
  });
7659
7724
  }
7660
- await this.dates(gh, repo, snap, before);
7725
+ await this.dates(gh, repo, snap, say, before);
7661
7726
  return { ok: true, snap };
7662
7727
  }
7663
7728
  /**
@@ -7667,7 +7732,7 @@ var Snapshots = class {
7667
7732
  * GitHub, in batches, only for the ones that are new or changed. Kept by commit, so a warm
7668
7733
  * start never asks at all.
7669
7734
  */
7670
- async dates(gh, repo, snap, before) {
7735
+ async dates(gh, repo, snap, say, before) {
7671
7736
  const key = `dates:${repo}@${snap.sha}`;
7672
7737
  const kept = await this.kv.get(key);
7673
7738
  if (kept) {
@@ -7682,6 +7747,7 @@ var Snapshots = class {
7682
7747
  else ask.push(path);
7683
7748
  }
7684
7749
  const [owner, name] = repo.split("/");
7750
+ if (ask.length) say("reading file dates");
7685
7751
  for (let i = 0; i < ask.length; i += DATES_PER_QUERY) {
7686
7752
  const batch = ask.slice(i, i + DATES_PER_QUERY);
7687
7753
  const fields = batch.map(
@@ -7767,7 +7833,7 @@ var TTL = 45e3;
7767
7833
  var LABEL_TTL = 3e5;
7768
7834
  function createPortal(opts) {
7769
7835
  const root2 = opts.root ?? `/@roster/${opts.org}`;
7770
- const snapshots = new Snapshots(opts.kv);
7836
+ const snapshots = new Snapshots(opts.kv, void 0, opts.shareInflight ?? true);
7771
7837
  mount(
7772
7838
  root2,
7773
7839
  snapshots.tree((repo) => repo.slice(repo.indexOf("/") + 1))
@@ -7812,19 +7878,24 @@ async function handlePortal(req, portal, actor) {
7812
7878
  }
7813
7879
  async function ready(c, opts = {}) {
7814
7880
  const { portal, actor } = c;
7815
- const ops = await portal.snapshots.refresh(actor.gh, `${portal.org}/${portal.opsName}`, opts);
7881
+ const report3 = opts.report;
7882
+ const ops = await portal.snapshots.refresh(actor.gh, `${portal.org}/${portal.opsName}`, {
7883
+ force: opts.force,
7884
+ report: report3
7885
+ });
7816
7886
  if (!ops.ok) {
7817
7887
  throw new HttpError(
7818
7888
  ops.status === 404 || ops.status === 401 ? ops.status : 502,
7819
7889
  `could not read ${portal.org}/${portal.opsName}: ${ops.error}`
7820
7890
  );
7821
7891
  }
7892
+ report3?.(`${portal.org}/${portal.opsName}`, "ready");
7822
7893
  const org = readOrg(portal.ws.opsDir, parseYaml2);
7823
7894
  const brains = (org.staff ?? []).map((s) => String(s.dir ?? s.handle));
7824
7895
  const products = opts.products ? (org.repos ?? []).map((r) => String(r.name)).filter((n) => n !== portal.opsName && !brains.includes(n)) : [];
7825
7896
  const results = await Promise.all([
7826
7897
  ...brains.map(
7827
- (d) => portal.snapshots.refresh(actor.gh, `${portal.org}/${d}`, { force: opts.force }).then((r) => ({ dir: d, ...r }))
7898
+ (d) => portal.snapshots.refresh(actor.gh, `${portal.org}/${d}`, { force: opts.force, report: report3 }).then((r) => ({ dir: d, ...r }))
7828
7899
  ),
7829
7900
  ...products.map(
7830
7901
  (d) => portal.snapshots.refresh(actor.gh, `${portal.org}/${d}`, { force: opts.force, pathsOnly: true }).then((r) => ({ dir: d, ...r }))
@@ -7852,24 +7923,26 @@ var ROUTES = {
7852
7923
  headers: { "content-type": asset.type, "cache-control": "public, max-age=86400" }
7853
7924
  });
7854
7925
  },
7926
+ /* The whole org. With ?progress=1 it is a stream instead: a line per step as it is read from
7927
+ GitHub, then the org, so a first load can say what it is doing rather than "Loading…". */
7855
7928
  "/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 });
7929
+ if (c.url.searchParams.get("progress") !== "1") return json(await orgExport(c));
7930
+ const { readable, writable } = new TransformStream();
7931
+ const out = writable.getWriter();
7932
+ const line = (o) => out.write(new TextEncoder().encode(`${JSON.stringify(o)}
7933
+ `));
7934
+ const report3 = (repo, step) => {
7935
+ void line({ repo: repo.slice(repo.indexOf("/") + 1), step });
7936
+ };
7937
+ void orgExport(c, report3).then((org) => line({ org })).catch(
7938
+ (err) => line({ error: String(err?.message ?? err), status: err.status })
7939
+ ).finally(() => out.close());
7940
+ return new Response(readable, {
7941
+ headers: {
7942
+ "content-type": "application/x-ndjson; charset=utf-8",
7943
+ "cache-control": "no-store"
7944
+ }
7945
+ });
7873
7946
  },
7874
7947
  /* Every file in the org layer the portal may write: isWritable's allowlist, nothing more. */
7875
7948
  "/api/orglayer": async (c) => {
@@ -8431,6 +8504,24 @@ ${diff}`,
8431
8504
  return new Response(bytes2, { headers: { "content-type": type, "cache-control": "no-store" } });
8432
8505
  }
8433
8506
  };
8507
+ async function orgExport(c, report3) {
8508
+ const { portal, actor } = c;
8509
+ const { org, brains } = await ready(c, { report: report3 });
8510
+ const byRoot = /* @__PURE__ */ new Map();
8511
+ await Promise.all(
8512
+ brains.map(async (dir) => {
8513
+ const repo = `${portal.org}/${dir}`;
8514
+ const snap = portal.snapshots.get(repo);
8515
+ if (!snap) return;
8516
+ report3?.(repo, "reading recent history");
8517
+ byRoot.set(join29(portal.ws.root, dir), await loadHistory(actor.gh, portal.kv, repo, snap.sha));
8518
+ report3?.(repo, "ready");
8519
+ })
8520
+ );
8521
+ const data = buildExport(portal.ws, org, parseYaml2, { history: loadedHistory(byRoot) });
8522
+ const left = unfinished(portal.ws.opsDir, (org.staff ?? []).length);
8523
+ return { ...data, unfinished: left };
8524
+ }
8434
8525
  function knownRepos(portal) {
8435
8526
  const org = readOrg(portal.ws.opsDir, parseYaml2);
8436
8527
  return (org.repos ?? []).map((r) => ({
@@ -8998,7 +9089,17 @@ async function portalCommand(argv) {
8998
9089
  return;
8999
9090
  }
9000
9091
  res.writeHead(answer.status, Object.fromEntries(answer.headers));
9001
- res.end(Buffer.from(await answer.arrayBuffer()));
9092
+ if (!answer.body) {
9093
+ res.end();
9094
+ return;
9095
+ }
9096
+ const reader = answer.body.getReader();
9097
+ for (; ; ) {
9098
+ const { done, value } = await reader.read();
9099
+ if (done) break;
9100
+ res.write(value);
9101
+ }
9102
+ res.end();
9002
9103
  };
9003
9104
  const writeAllowed = (req) => {
9004
9105
  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
  /**