@nanocollective/roster 0.1.0-beta.12 → 0.1.0-beta.14

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/dist/cli.js CHANGED
@@ -1215,13 +1215,24 @@ function readHumans(org) {
1215
1215
  github,
1216
1216
  name: name || github,
1217
1217
  marker: String(entry.marker ?? "").trim() || defaultMarker(name || github),
1218
- role: entry.role === void 0 || entry.role === null ? void 0 : String(entry.role)
1218
+ role: entry.role === void 0 || entry.role === null ? void 0 : String(entry.role),
1219
+ ...entry.view_only === true ? { viewOnly: true } : {}
1219
1220
  });
1220
1221
  }
1221
1222
  return out;
1222
1223
  }
1224
+ function staffHumans(org) {
1225
+ return readHumans(org).filter((h) => !h.viewOnly);
1226
+ }
1227
+ function isViewOnly(org, login) {
1228
+ const l = login.toLowerCase();
1229
+ return readHumans(org).some((h) => h.viewOnly && h.github.toLowerCase() === l);
1230
+ }
1231
+ function primaryHuman(org) {
1232
+ return staffHumans(org)[0] ?? null;
1233
+ }
1223
1234
  function humanLogins(org) {
1224
- return readHumans(org).map((h) => h.github).filter(Boolean);
1235
+ return staffHumans(org).map((h) => h.github).filter(Boolean);
1225
1236
  }
1226
1237
  function defaultMarker(name) {
1227
1238
  return String(name).trim().split(/[\s-]+/)[0].toLowerCase().replace(/[^a-z0-9]/g, "") || "human";
@@ -1390,6 +1401,8 @@ function validateOrgYaml(text2, parseYaml3) {
1390
1401
  }
1391
1402
  for (const h of doc.humans ?? []) {
1392
1403
  if (!h?.github) return "every entry in humans needs a github login";
1404
+ if (h.view_only !== void 0 && typeof h.view_only !== "boolean")
1405
+ return "view_only is true or false";
1393
1406
  }
1394
1407
  return null;
1395
1408
  }
@@ -1496,7 +1509,7 @@ function staffTokens(ws, org, handle, parseYaml3) {
1496
1509
  return tokensFor(spec(org, ws), specFromManifest(manifest, dir));
1497
1510
  }
1498
1511
  function spec(org, ws) {
1499
- const humans = readHumans(org);
1512
+ const humans = staffHumans(org);
1500
1513
  const first = humans[0];
1501
1514
  return {
1502
1515
  org: org.org,
@@ -2089,7 +2102,7 @@ function buildPlan(ws, org, handle, opts, parseYaml3) {
2089
2102
  "status_issue is 0 until --apply opens the pinned issue; prompts will not compose before then"
2090
2103
  );
2091
2104
  }
2092
- const humans = readHumans(org);
2105
+ const humans = staffHumans(org);
2093
2106
  const orgSpec2 = {
2094
2107
  org: org.org,
2095
2108
  name: org.name,
@@ -2104,7 +2117,7 @@ function buildPlan(ws, org, handle, opts, parseYaml3) {
2104
2117
  warnings.push("org.yaml has no human.github, so the mention gate will never match");
2105
2118
  if (humans.length > 1) {
2106
2119
  warnings.push(
2107
- `the mention gate accepts ${humans.map((h) => h.github).join(", ")} \u2014 everyone in org.yaml`
2120
+ `the mention gate accepts ${humans.map((h) => h.github).join(", ")} \u2014 everyone in org.yaml but the view-only`
2108
2121
  );
2109
2122
  }
2110
2123
  const tokens = tokensFor(orgSpec2, staff);
@@ -4003,8 +4016,8 @@ function planBrains(ws, parseYaml3) {
4003
4016
  name: org.name,
4004
4017
  opsRepo: `${org.org}/${ws.opsName}`,
4005
4018
  opsDirName: ws.opsName,
4006
- human: readHumans(org)[0]?.github ?? "",
4007
- humanMarker: readHumans(org)[0]?.marker ?? "human",
4019
+ human: primaryHuman(org)?.github ?? "",
4020
+ humanMarker: primaryHuman(org)?.marker ?? "human",
4008
4021
  humanLogins: humanLogins(org),
4009
4022
  allowedTools: toolsOf(org)
4010
4023
  };
@@ -4238,12 +4251,12 @@ function checkWorkspace(ws, org) {
4238
4251
  title: `org.yaml names ${org.repos?.length ?? 0} repos and ${org.staff?.length ?? 0} staff`
4239
4252
  });
4240
4253
  const humans = readHumans(org);
4241
- if (!humans.some((h) => h.github)) {
4254
+ if (!staffHumans(org).some((h) => h.github)) {
4242
4255
  out.push({
4243
4256
  scope,
4244
4257
  level: "fail",
4245
4258
  id: "human",
4246
- title: "org.yaml names no human with a github login",
4259
+ title: "org.yaml names no human with a github login who is not view-only",
4247
4260
  fix: "The mention callers gate on these logins. Without one nothing can wake an agent. Write `human: { github: you }`, or a `humans:` list for more than one."
4248
4261
  });
4249
4262
  } else if (humans.some((h) => !h.github)) {
@@ -4610,7 +4623,7 @@ async function checkStaff(ws, org, entry, composer, online) {
4610
4623
  });
4611
4624
  }
4612
4625
  if (online && manifest.brain) {
4613
- const logins = readHumans(org).flatMap((h) => h.github ? [h.github] : []);
4626
+ const logins = humanLogins(org);
4614
4627
  out.push(...await checkStaffOnline(scope, manifest, callers, logins));
4615
4628
  }
4616
4629
  return out;
@@ -5224,7 +5237,7 @@ function buildExport(ws, org, parseYaml3, opts = {}) {
5224
5237
  s.soloBots = s.bots.filter((b) => times.get(b) === 1);
5225
5238
  s.sharedBots = s.bots.filter((b) => (times.get(b) ?? 0) > 1);
5226
5239
  }
5227
- const humans = readHumans(org);
5240
+ const humans = staffHumans(org);
5228
5241
  return {
5229
5242
  org: org.org,
5230
5243
  name: org.name,
@@ -6528,7 +6541,8 @@ function readHumans2(org) {
6528
6541
  github,
6529
6542
  name: name || github,
6530
6543
  marker: String(entry.marker ?? "").trim() || defaultMarker2(name || github),
6531
- role: entry.role ?? void 0
6544
+ role: entry.role ?? void 0,
6545
+ ...entry.view_only === true ? { viewOnly: true } : {}
6532
6546
  });
6533
6547
  }
6534
6548
  return out;
@@ -6580,7 +6594,8 @@ function compose({
6580
6594
  };
6581
6595
  const inflightFile = join27(runDir ?? join27(brainsDir, ".roster-run"), "inflight.md");
6582
6596
  const inflight = existsSync18(inflightFile) ? readFileSync18(inflightFile, "utf8").trim() : "";
6583
- const humans = readHumans2(org);
6597
+ const everyone = readHumans2(org);
6598
+ const humans = everyone.filter((h) => !h.viewOnly);
6584
6599
  const ctx = {
6585
6600
  org,
6586
6601
  event: event2,
@@ -6613,7 +6628,9 @@ function compose({
6613
6628
  // makes `{{#if humans_extra}}` the right way to mention the others at all.
6614
6629
  human_list: humanSentence(humans),
6615
6630
  inflight,
6616
- humans_extra: humanSentence(humans.slice(1))
6631
+ humans_extra: humanSentence(humans.slice(1)),
6632
+ // Who can read along and cannot rule. Empty, and the paragraph gone, when nobody is.
6633
+ humans_viewing: humanSentence(everyone.filter((h) => h.viewOnly))
6617
6634
  };
6618
6635
  const readPartial = (rel) => {
6619
6636
  const p = rel.startsWith("staff:") ? join27(brainDir, rel.slice(6)) : join27(opsDir, rel);
@@ -6727,6 +6744,12 @@ ${ticks}`;
6727
6744
 
6728
6745
  // src/lib/act.ts
6729
6746
  var MERGE_METHODS = ["squash", "merge", "rebase"];
6747
+ function wouldWake(req, handles) {
6748
+ if (req.action === "ask") return true;
6749
+ const text2 = `${req.title ?? ""}
6750
+ ${req.body ?? ""}`.toLowerCase();
6751
+ return handles.some((h) => new RegExp(`@${h.toLowerCase()}(?![\\w-])`).test(text2));
6752
+ }
6730
6753
  async function act(gh, req) {
6731
6754
  const { action, repo } = req;
6732
6755
  if (action === "create") {
@@ -6995,6 +7018,7 @@ var THREAD_QUERY = `
6995
7018
  query($owner:String!, $name:String!, $number:Int!) {
6996
7019
  repository(owner:$owner, name:$name) {
6997
7020
  issueOrPullRequest(number:$number) {
7021
+ __typename
6998
7022
  ... on Issue {
6999
7023
  number title body url state createdAt updatedAt ${ROW_EXTRAS}
7000
7024
  author { login }
@@ -7229,6 +7253,7 @@ async function fetchThread(gh, repo, number, kind) {
7229
7253
  if (!res.ok) throw new Error(res.error);
7230
7254
  const n = res.data?.repository?.issueOrPullRequest;
7231
7255
  if (!n) throw new Error(`${repo}#${number} was not found in ${repo}`);
7256
+ if (n.__typename) kind = n.__typename === "PullRequest" ? "pr" : "issue";
7232
7257
  const item = shape(n, repo, "", kind);
7233
7258
  if (kind === "pr") {
7234
7259
  item.draft = n.isDraft;
@@ -7475,7 +7500,7 @@ function renderBrief2(text2, tokens) {
7475
7500
  return text2.replace(/%%([A-Z_]+)%%/g, (m, name) => tokens[name] ?? m);
7476
7501
  }
7477
7502
  function orgSpec(org, w) {
7478
- const humans = readHumans(org);
7503
+ const humans = staffHumans(org);
7479
7504
  const first = humans[0];
7480
7505
  return {
7481
7506
  org: org.org,
@@ -8195,6 +8220,15 @@ var ROUTES = {
8195
8220
  if (payload.action === "ask" && !known.includes(payload.ask?.pr?.repo ?? "")) {
8196
8221
  return json({ error: `${payload.ask?.pr?.repo ?? ""} is not a repo in org.yaml` }, 400);
8197
8222
  }
8223
+ const handles = (org.staff ?? []).map((s) => String(s.handle));
8224
+ if (isViewOnly(org, actor.id) && wouldWake(payload, handles)) {
8225
+ return json(
8226
+ {
8227
+ error: "You are view-only in org.yaml, so this would not reach the staff. Nothing was posted."
8228
+ },
8229
+ 403
8230
+ );
8231
+ }
8198
8232
  try {
8199
8233
  const result = await act(actor.gh, payload);
8200
8234
  portal.caches.inbox.delete(actor.id);
@@ -60,6 +60,27 @@ pre.yaml{color:var(--ink)}
60
60
  .ref.pr{color:var(--measured)}
61
61
  .ref.pr:hover{border-color:var(--measured);background:color-mix(in srgb,var(--measured) 14%,transparent)}
62
62
 
63
+ /* What a chip is, on hover. In the top layer as a popover, so it shows over a side sheet too;
64
+ the UA's popover styles (inset, margin, border) are reset for that reason. */
65
+ .refcard{position:fixed;inset:auto;margin:0;z-index:60;width:340px;max-width:calc(100vw - 24px);
66
+ padding:12px 14px;background:var(--bg-elev);color:var(--ink);border:1px solid var(--border-strong);
67
+ border-radius:var(--r);box-shadow:var(--shadow-lg);font:13px/1.45 var(--sans);
68
+ opacity:0;transform:translateY(-2px);transition:opacity .12s var(--ease),transform .12s var(--ease)}
69
+ .refcard.on{opacity:1;transform:none}
70
+ .refcard[hidden]{display:none}
71
+ .refcard .rcmeta{display:flex;align-items:center;gap:8px;font:11.5px var(--mono);color:var(--ink-dim)}
72
+ .refcard .rcstate{display:inline-flex;align-items:center;gap:4px;font:600 11px var(--sans);
73
+ padding:1px 8px 1px 6px;border-radius:20px;--ic:12px}
74
+ .refcard .rcstate.open{color:var(--accent);background:var(--accent-soft)}
75
+ .refcard .rcstate.closed,.refcard .rcstate.merged{color:var(--derived);
76
+ background:color-mix(in srgb,var(--derived) 15%,transparent)}
77
+ .refcard .rctitle{margin-top:8px;font:600 14px/1.35 var(--sans);letter-spacing:-.005em}
78
+ .refcard .rcbody{margin:6px 0 0;color:var(--ink-dim);display:-webkit-box;-webkit-line-clamp:3;
79
+ -webkit-box-orient:vertical;overflow:hidden}
80
+ .refcard .rclabels{display:flex;flex-wrap:wrap;gap:4px;margin-top:8px}
81
+ .refcard .rcfoot{margin-top:10px;font-size:11.5px;color:var(--ink-faint)}
82
+ .refcard .sk{margin-top:8px}
83
+
63
84
  /* @cto and @you are how work is handed between people here, so they are marked
64
85
  rather than left as prose. `.you` is anyone on this org's roster; a stranger stays plain. */
65
86
  .at{display:inline-block;font:11.5px var(--mono);color:var(--ink-dim);background:var(--panel-2);
@@ -13,6 +13,7 @@ import {
13
13
  stampLoaded,
14
14
  syncNotice,
15
15
  } from "./refresh.js";
16
+ import { installRefs } from "./refcard.js";
16
17
  import { onRender } from "./router.js";
17
18
  import { ORG_WIDE, S, VIEWS, applyHash, humanLabel, readHash, writeHash } from "./state.js";
18
19
  import { viewBrain } from "./views/brain.js";
@@ -92,6 +93,7 @@ export async function boot() {
92
93
  /* Before the first render, and once: it is delegated, so it covers every image any screen
93
94
  draws from here on, including the setup screen. */
94
95
  installLightbox();
96
+ installRefs();
95
97
 
96
98
  /* Before there is a tenant the server answers every data route with `mode: setup`. That is
97
99
  not an error state: it is the first thing a new user ever sees, and the whole page becomes
@@ -0,0 +1,216 @@
1
+ /* What a #175 is, without leaving the page.
2
+ *
3
+ * Half of a status report is issue numbers, and the only way to find out what one was used to
4
+ * be a click through to GitHub, which is a new tab and the end of whatever you were reading.
5
+ * Hovering one now shows a card with its title, state and opening lines, the way GitHub does,
6
+ * and clicking it opens the thread in a side sheet over the page you were on.
7
+ *
8
+ * Only for the org's own repos: the server reads nothing else, so a chip pointing anywhere
9
+ * else stays a plain link. ⌘-click and middle-click still go to GitHub, as a link should.
10
+ */
11
+
12
+ import { getRepos, getThread } from "./api.js";
13
+ import { ago, el, esc } from "./dom.js";
14
+ import { iconHTML } from "./icons.js";
15
+ import { openThread } from "./views/home.js";
16
+ import { tone } from "./views/inbox.js";
17
+
18
+ const REF_HREF = /^https:\/\/github\.com\/([\w.-]+\/[\w.-]+)\/(?:issues|pull)\/(\d+)/;
19
+ const SHOW_AFTER = 350;
20
+ const HIDE_AFTER = 200;
21
+ // Long enough to hover the same few numbers on a report without asking again; short enough
22
+ // that a card is not an hour out of date.
23
+ const FRESH_FOR = 5 * 60_000;
24
+
25
+ let known = null;
26
+ const cache = new Map();
27
+ let card = null;
28
+ let showing = null;
29
+ let showTimer = 0;
30
+ let hideTimer = 0;
31
+
32
+ export function installRefs() {
33
+ /* Read once, off disk. A failure leaves every chip a plain link, which is what they were. */
34
+ getRepos()
35
+ .then((r) => {
36
+ known = new Set((r?.repos ?? []).map((x) => x.owner + "/" + x.name));
37
+ })
38
+ .catch(() => {});
39
+
40
+ document.addEventListener?.("click", (e) => {
41
+ const ref = refOf(e.target);
42
+ if (!ref || e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;
43
+ e.preventDefault();
44
+ hide();
45
+ openThread(ref);
46
+ });
47
+
48
+ document.addEventListener?.("pointerover", (e) => {
49
+ if (e.pointerType === "touch") return;
50
+ if (card?.contains(e.target)) {
51
+ clearTimeout(hideTimer);
52
+ return;
53
+ }
54
+ const a = e.target?.closest?.("a.ref");
55
+ const ref = refOf(e.target);
56
+ if (!ref) return;
57
+ clearTimeout(hideTimer);
58
+ if (showing === a) return;
59
+ // The card says everything the native tooltip did, and both at once is clutter.
60
+ a.removeAttribute("title");
61
+ clearTimeout(showTimer);
62
+ showTimer = setTimeout(() => show(a, ref), SHOW_AFTER);
63
+ });
64
+
65
+ document.addEventListener?.("pointerout", (e) => {
66
+ const from = e.target?.closest?.("a.ref, .refcard");
67
+ if (!from || from.contains(e.relatedTarget)) return;
68
+ clearTimeout(showTimer);
69
+ hideTimer = setTimeout(hide, HIDE_AFTER);
70
+ });
71
+
72
+ addEventListener?.("keydown", (e) => e.key === "Escape" && hide());
73
+ addEventListener?.("scroll", hide, true);
74
+ addEventListener?.("hashchange", hide);
75
+ }
76
+
77
+ /** The repo and number a chip points at, if it is one of the org's own. */
78
+ function refOf(target) {
79
+ const a = target?.closest?.("a.ref");
80
+ if (!a || !known) return null;
81
+ const m = REF_HREF.exec(a.getAttribute("href") ?? "");
82
+ if (!m || !known.has(m[1])) return null;
83
+ return { repo: m[1], number: Number(m[2]), kind: a.classList.contains("pr") ? "pr" : undefined };
84
+ }
85
+
86
+ function peek(ref) {
87
+ const key = ref.repo + "#" + ref.number;
88
+ const hit = cache.get(key);
89
+ if (hit && Date.now() - hit.at < FRESH_FOR) return hit.p;
90
+ const p = getThread(ref.repo, ref.number, ref.kind ?? "").then((t) => {
91
+ if (!t || t.error) throw new Error(t?.error ?? "could not read it");
92
+ return t;
93
+ });
94
+ // A failure is not kept: the next hover asks again.
95
+ p.catch(() => cache.delete(key));
96
+ cache.set(key, { at: Date.now(), p });
97
+ return p;
98
+ }
99
+
100
+ function show(a, ref) {
101
+ if (!a.isConnected) return;
102
+ showing = a;
103
+ ensureCard();
104
+ card.replaceChildren(
105
+ el("div", { className: "rcmeta", textContent: ref.repo + " #" + ref.number }),
106
+ el("div", { className: "sk sk-line" }),
107
+ el("div", { className: "sk sk-line" }),
108
+ );
109
+ open(a);
110
+ peek(ref)
111
+ .then((t) => {
112
+ if (showing === a) {
113
+ fill(t);
114
+ place(a);
115
+ }
116
+ })
117
+ .catch((e) => {
118
+ if (showing !== a) return;
119
+ card.replaceChildren(
120
+ el("div", { className: "rcmeta", textContent: ref.repo + " #" + ref.number }),
121
+ el("p", {
122
+ className: "rcbody",
123
+ // A bare #213 is read as this repo's, and the writer often meant another one.
124
+ textContent: /could not resolve|not found/i.test(e.message)
125
+ ? "There is no #" + ref.number + " in " + ref.repo + "."
126
+ : "Couldn't read it: " + e.message,
127
+ }),
128
+ );
129
+ });
130
+ }
131
+
132
+ function fill(t) {
133
+ const merged = t.state === "MERGED";
134
+ const shut = t.state !== "OPEN";
135
+ const glyph = merged ? "merged" : t.draft ? "draft" : shut ? "issue-closed" : "issue-open";
136
+ const word = merged ? "Merged" : shut ? "Closed" : t.draft ? "Draft" : "Open";
137
+ const excerpt = plain(t.body);
138
+ const comments = t.commentCount ?? t.comments?.length ?? 0;
139
+
140
+ card.innerHTML =
141
+ '<div class="rcmeta">' +
142
+ '<span class="rcstate ' + (merged ? "merged" : shut ? "closed" : "open") + '">' +
143
+ iconHTML(glyph) + word + "</span>" +
144
+ "<span>" + esc(t.repo) + " " + (t.kind === "pr" ? "PR " : "") + "#" + t.number + "</span>" +
145
+ "</div>" +
146
+ '<div class="rctitle">' + esc(t.title) + "</div>" +
147
+ (excerpt ? '<p class="rcbody">' + esc(excerpt) + "</p>" : "") +
148
+ (t.labels?.length
149
+ ? '<div class="rclabels">' +
150
+ t.labels.map((l) => '<span class="chip ' + tone(l) + '">' + esc(l) + "</span>").join("") +
151
+ "</div>"
152
+ : "") +
153
+ '<div class="rcfoot">' +
154
+ esc(t.author) + " · updated " + ago(t.updatedAt) +
155
+ (comments ? " · " + comments + (comments === 1 ? " comment" : " comments") : "") +
156
+ "</div>";
157
+ }
158
+
159
+ /** The opening of a body as a sentence: no headings, tables, images or link syntax. */
160
+ function plain(body) {
161
+ const text = String(body ?? "")
162
+ .replace(/<!--[\s\S]*?-->/g, "")
163
+ .replace(/```[\s\S]*?```/g, " ")
164
+ .replace(/!\[[^\]]*\]\([^)]*\)/g, "")
165
+ .replace(/\[([^\]]*)\]\([^)]*\)/g, "$1")
166
+ .split("\n")
167
+ .map((l) => l.replace(/^\s*(#{1,6}\s+|>\s?|[-*+]\s+(\[[ x]\]\s+)?|\d+\.\s+)/i, "").trim())
168
+ .filter((l) => l && !/^\|/.test(l) && !/^[-|:\s]+$/.test(l))
169
+ .join(" ")
170
+ .replace(/[*_`]/g, "")
171
+ .replace(/\s+/g, " ")
172
+ .trim();
173
+ return text.length > 220 ? text.slice(0, 219).trimEnd() + "…" : text;
174
+ }
175
+
176
+ function ensureCard() {
177
+ if (card) return;
178
+ card = el("div", { className: "refcard", role: "tooltip" });
179
+ /* A popover goes in the top layer, so the card shows over an open side sheet too. A plain
180
+ fixed div would sit underneath a modal <dialog> however high its z-index. */
181
+ if (typeof card.showPopover === "function") card.setAttribute("popover", "manual");
182
+ document.body.append(card);
183
+ }
184
+
185
+ function open(a) {
186
+ // The top layer is ordered by when things were shown. Reopening puts the card above a
187
+ // sheet that opened after it last showed.
188
+ if (card.matches?.(":popover-open")) card.hidePopover();
189
+ if (typeof card.showPopover === "function") card.showPopover();
190
+ else card.hidden = false;
191
+ card.classList.add("on");
192
+ place(a);
193
+ }
194
+
195
+ /** Under the chip, or above it when there is no room below; never off the side. */
196
+ function place(a) {
197
+ const r = a.getBoundingClientRect();
198
+ const w = card.offsetWidth;
199
+ const h = card.offsetHeight;
200
+ const gap = 8;
201
+ const left = Math.max(12, Math.min(r.left, innerWidth - w - 12));
202
+ const below = r.bottom + gap + h <= innerHeight - 12;
203
+ const top = below ? r.bottom + gap : Math.max(12, r.top - gap - h);
204
+ card.style.left = left + "px";
205
+ card.style.top = top + "px";
206
+ }
207
+
208
+ function hide() {
209
+ clearTimeout(showTimer);
210
+ clearTimeout(hideTimer);
211
+ showing = null;
212
+ if (!card) return;
213
+ card.classList.remove("on");
214
+ if (card.matches?.(":popover-open")) card.hidePopover();
215
+ else if (typeof card.showPopover !== "function") card.hidden = true;
216
+ }
@@ -26,7 +26,7 @@ const LABEL_TONE = {
26
26
  * which coloured exactly one org's and left every other org's looking like an ordinary tag.
27
27
  * It comes off org.yaml now, so it is right wherever this runs.
28
28
  */
29
- function tone(label) {
29
+ export function tone(label) {
30
30
  if (LABEL_TONE[label]) return LABEL_TONE[label];
31
31
  const name = String(label).toLowerCase();
32
32
  return humansOf().some(
@@ -125,7 +125,13 @@ export function threadInto(host, ref) {
125
125
  THREADS.delete(item.repo + "#" + item.number);
126
126
  item.partial = true;
127
127
  }
128
- host.append(inboxScreen(el("div"), { prs: ref.kind === "pr", only: ref }));
128
+ /* A #175 in a report is as likely to be closed, or in a repo nobody watches, as it is to be
129
+ in the inbox. It is read on its own and kept beside the inbox rather than added to it,
130
+ where it would turn up as a row on Trackers. */
131
+ const stray = item
132
+ ? null
133
+ : { repo: ref.repo, number: ref.number, kind: ref.kind ?? "issue", labels: [], partial: true };
134
+ host.append(inboxScreen(el("div"), { prs: ref.kind === "pr", only: ref, stray }));
129
135
  }
130
136
 
131
137
  function inboxScreen(m, opts) {
@@ -385,11 +391,14 @@ function inboxScreen(m, opts) {
385
391
  }
386
392
  }
387
393
 
394
+ function find(ref) {
395
+ const same = (i) => i.repo === ref.repo && i.number === ref.number;
396
+ return (S.inbox?.items ?? []).find(same) ?? (opts.stray && same(opts.stray) ? opts.stray : null);
397
+ }
398
+
388
399
  /* Everything is already loaded, so opening a thread is a render, not a request. */
389
400
  function openThread(ref) {
390
- const item = (S.inbox?.items ?? []).find(
391
- (i) => i.repo === ref.repo && i.number === ref.number,
392
- );
401
+ const item = find(ref);
393
402
  if (!item) {
394
403
  viewer.replaceChildren(
395
404
  el("p", { className: "empty", textContent: "That one is no longer open. Refresh." }),
@@ -849,6 +858,8 @@ function inboxScreen(m, opts) {
849
858
  THREADS.set(item.repo + "#" + item.number, fresh);
850
859
  // A single thread does not know which part of the org it is in, or whether it is unread.
851
860
  S.inbox.items[at] = { ...old, ...fresh, role: old.role, unread: old.unread, partial: false };
861
+ } else if (opts.stray && find(item) === opts.stray) {
862
+ Object.assign(opts.stray, fresh, { partial: false });
852
863
  }
853
864
  }
854
865
  } catch {