@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 +49 -15
- package/dist/worker/assets/assets/css/markdown.css +21 -0
- package/dist/worker/assets/assets/js/app.js +2 -0
- package/dist/worker/assets/assets/js/refcard.js +216 -0
- package/dist/worker/assets/assets/js/views/inbox.js +16 -5
- package/dist/worker/index.js +38 -7
- package/docs/doctor-codes.md +1 -1
- package/docs/export.md +1 -1
- package/docs/hosting.md +2 -0
- package/docs/org-yaml.md +8 -0
- package/docs/portal.md +4 -2
- package/docs/prompts.md +2 -1
- package/package.json +1 -1
- package/templates/ops/compose.mjs +8 -2
- package/templates/ops/prompts/_identity.md +6 -0
- package/templates/portal/css/markdown.css +21 -0
- package/templates/portal/js/app.js +2 -0
- package/templates/portal/js/refcard.js +216 -0
- package/templates/portal/js/views/inbox.js +16 -5
package/docs/doctor-codes.md
CHANGED
|
@@ -25,7 +25,7 @@ ran at all.
|
|
|
25
25
|
|---|---|
|
|
26
26
|
| `gh` | Whether `gh` is installed and authenticated. A warning here means every network check was skipped, not that anything is wrong. |
|
|
27
27
|
| `org.yaml` | The org manifest parsed, and how much it declares. |
|
|
28
|
-
| `human` | **fail.** `org.yaml` names nobody with a `github` login, in either `human` or `humans`. The mention callers gate on those logins, so nothing can wake an agent. |
|
|
28
|
+
| `human` | **fail.** `org.yaml` names nobody with a `github` login, in either `human` or `humans`, who is not `view_only`. The mention callers gate on those logins, so nothing can wake an agent. |
|
|
29
29
|
| `human.login` | One of the people in `humans` has a name but no `github` login. They read as somebody the staff answer to and are not: the gate can never match them. |
|
|
30
30
|
| `repo` | Every repo in `org.yaml` is reachable. A failure means it does not exist or your `gh` cannot see it. |
|
|
31
31
|
| `repo.visibility` | A repo's real visibility disagrees with what `org.yaml` records. Cosmetic, but the posture it records is then fiction. |
|
package/docs/export.md
CHANGED
|
@@ -23,7 +23,7 @@ that reads it gets the same view without reimplementing the memory grammar.
|
|
|
23
23
|
| `name` | the business name |
|
|
24
24
|
| `opsName` | the ops repo's directory, so a consumer can address `org.yaml` and `org/*.md` by path |
|
|
25
25
|
| `human` | the first human, normalised: `{ github, name, marker, role }`. Kept for consumers written when an org had exactly one |
|
|
26
|
-
| `humans[]` | everyone the staff answer to, in order, read from `humans` or the singular `human`. `human` is `humans[0]` |
|
|
26
|
+
| `humans[]` | everyone the staff answer to, in order, read from `humans` or the singular `human`, leaving out anyone `view_only`. `human` is `humans[0]` |
|
|
27
27
|
| `generatedAt` | ISO timestamp |
|
|
28
28
|
| `staff[]` | one entry per staff member |
|
|
29
29
|
|
package/docs/hosting.md
CHANGED
|
@@ -35,6 +35,8 @@ does. That is not something to put behind a public URL.
|
|
|
35
35
|
## Who can get in
|
|
36
36
|
|
|
37
37
|
Only the people listed under `humans:` in `org.yaml`, signed in with their own GitHub account.
|
|
38
|
+
That includes anyone marked `view_only`, who can read everything and wake nobody; see
|
|
39
|
+
[org.yaml](org-yaml.md#human-and-humans).
|
|
38
40
|
|
|
39
41
|
- Sign-in is GitHub's own OAuth flow, through an OAuth App your org creates for the portal.
|
|
40
42
|
The token it hands back is that person's, scoped `repo` and `notifications`, the same kind
|
package/docs/org-yaml.md
CHANGED
|
@@ -80,6 +80,7 @@ humans:
|
|
|
80
80
|
| `name` | no | What to call them in prose. Defaults to the login. |
|
|
81
81
|
| `marker` | no | Provenance tag on a fact they ruled on, as in `[will]`. Also used as a label. Defaults to the first part of the name, lowercased. |
|
|
82
82
|
| `role` | no | Prose only. |
|
|
83
|
+
| `view_only` | no | `true` for somebody who should see how the org runs and nothing more. See below. |
|
|
83
84
|
|
|
84
85
|
Both keys are read, and the singular is not deprecated: an org with one human should keep
|
|
85
86
|
writing `human`. When both are present, anyone in `human` who is not already in the list is
|
|
@@ -91,6 +92,13 @@ here"), and a list of two cannot go in that sentence, so the first one goes ther
|
|
|
91
92
|
`{{humans_extra}}` in the identity fragment. Everything that *gates* on identity reads all of
|
|
92
93
|
them: the mention caller's `if:` is `contains(fromJSON('["will-lamerton","sam-x"]'), …)`.
|
|
93
94
|
|
|
95
|
+
**View-only.** `{ name: Ben, github: ben-x, view_only: true }` signs in to the portal and the
|
|
96
|
+
Claude connector like anyone in the list, and reads everything there. They are not in the mention
|
|
97
|
+
gate, so an `@cto` from them wakes nobody, and the portal refuses to post one rather than leave
|
|
98
|
+
them waiting. The staff prompts name them only to say that nothing they write is a ruling, and
|
|
99
|
+
that nothing needing a human goes to them. A view-only person is never the primary, wherever they
|
|
100
|
+
are in the list. What they can do on GitHub itself is still whatever their access there allows.
|
|
101
|
+
|
|
94
102
|
Adding a human changes every generated caller workflow, so it takes a `roster upgrade` to reach
|
|
95
103
|
the brain repos. Until that lands, the new person can open issues and read everything, and
|
|
96
104
|
mentioning a staff member does nothing.
|
package/docs/portal.md
CHANGED
|
@@ -189,8 +189,10 @@ down with the list, so opening a thread is a render rather than a request.
|
|
|
189
189
|
to find out it landed.
|
|
190
190
|
- **How much conversation** is on each row, which is most of what tells a live thread from
|
|
191
191
|
something filed and never answered.
|
|
192
|
-
- Issue and PR references in a body become chips
|
|
193
|
-
|
|
192
|
+
- Issue and PR references in a body become chips, and `@handle` mentions become chips too.
|
|
193
|
+
Hovering a chip for one of the org's repos shows a card with its title, state, opening
|
|
194
|
+
lines and labels. Clicking it opens the thread in a side sheet, closed or not, over
|
|
195
|
+
whatever you were reading. ⌘-click or middle-click still opens GitHub. A mention of somebody on this roster goes to their repository
|
|
194
196
|
rather than to a GitHub profile of that name, which for `@cto` is a stranger.
|
|
195
197
|
- **Not every comment is markdown.** Deploy bots post raw HTML. A `<table>` renders as a
|
|
196
198
|
table, and inline `<a>`, `<img>`, `<strong>`, `<em>`, `<code>` and `<br>` are reduced to
|
package/docs/prompts.md
CHANGED
|
@@ -91,11 +91,12 @@ than a hang.
|
|
|
91
91
|
|---|---|
|
|
92
92
|
| `org` | the whole of `org.yaml` |
|
|
93
93
|
| `org.name`, `org.org` | the business name, the GitHub org |
|
|
94
|
-
| `human` | the primary human: the first of `humans
|
|
94
|
+
| `human` | the primary human: the first of `humans` who is not view-only, or the singular `human` block |
|
|
95
95
|
| `human.name`, `human.github`, `human.marker` | |
|
|
96
96
|
| `humans` | everyone the staff answer to, in order. See [org.yaml](org-yaml.md#human-and-humans) |
|
|
97
97
|
| `human_list` | all of them as a sentence: "Will (@will-lamerton) and Sam (@sam-x)" |
|
|
98
98
|
| `humans_extra` | the same, minus the primary. **Empty when there is only one**, which is what makes `{{#if humans_extra}}` the way to mention the others |
|
|
99
|
+
| `humans_viewing` | the `view_only` humans, as a sentence. Empty when there are none |
|
|
99
100
|
| `ops.dir` | ops repo directory in the checkout |
|
|
100
101
|
| `staff` | the whole of this staff member's `staff.yaml` |
|
|
101
102
|
| `staff.dir` | where their brain lands in the checkout |
|
package/package.json
CHANGED
|
@@ -242,7 +242,9 @@ function truthy(v) {
|
|
|
242
242
|
// Who the staff answer to
|
|
243
243
|
//
|
|
244
244
|
// One person was written as `human:`. More than one is a `humans:` list. Both are read, the
|
|
245
|
-
// singular still works, and the first entry is the one the prose addresses.
|
|
245
|
+
// singular still works, and the first entry is the one the prose addresses. Anyone marked
|
|
246
|
+
// `view_only` reads along and nothing more: they are left out of everything that says who the
|
|
247
|
+
// staff answer to, and named only so a staff member knows what not to act on. Duplicated in
|
|
246
248
|
// roster's own src/lib/humans.ts rather than imported, for the same reason the YAML parser
|
|
247
249
|
// above is: a run must not depend on npm or on a network call.
|
|
248
250
|
// ---------------------------------------------------------------------------
|
|
@@ -260,6 +262,7 @@ export function readHumans(org) {
|
|
|
260
262
|
name: name || github,
|
|
261
263
|
marker: String(entry.marker ?? "").trim() || defaultMarker(name || github),
|
|
262
264
|
role: entry.role ?? undefined,
|
|
265
|
+
...(entry.view_only === true ? { viewOnly: true } : {}),
|
|
263
266
|
});
|
|
264
267
|
}
|
|
265
268
|
return out;
|
|
@@ -348,7 +351,8 @@ export function compose({
|
|
|
348
351
|
const inflightFile = join(runDir ?? join(brainsDir, ".roster-run"), "inflight.md");
|
|
349
352
|
const inflight = existsSync(inflightFile) ? readFileSync(inflightFile, "utf8").trim() : "";
|
|
350
353
|
|
|
351
|
-
const
|
|
354
|
+
const everyone = readHumans(org);
|
|
355
|
+
const humans = everyone.filter((h) => !h.viewOnly);
|
|
352
356
|
const ctx = {
|
|
353
357
|
org,
|
|
354
358
|
event,
|
|
@@ -382,6 +386,8 @@ export function compose({
|
|
|
382
386
|
human_list: humanSentence(humans),
|
|
383
387
|
inflight,
|
|
384
388
|
humans_extra: humanSentence(humans.slice(1)),
|
|
389
|
+
// Who can read along and cannot rule. Empty, and the paragraph gone, when nobody is.
|
|
390
|
+
humans_viewing: humanSentence(everyone.filter((h) => h.viewOnly)),
|
|
385
391
|
};
|
|
386
392
|
|
|
387
393
|
// "staff:foo.md" resolves inside the staff member's own brain repo, which is how a
|
|
@@ -13,6 +13,12 @@ binding as one from {{human.name}}. Reply to whoever asked; address a new `decis
|
|
|
13
13
|
person it is actually for.
|
|
14
14
|
{{/if}}
|
|
15
15
|
|
|
16
|
+
{{#if humans_viewing}}
|
|
17
|
+
View-only: {{humans_viewing}}. They can read everything here, but they cannot wake you, and
|
|
18
|
+
nothing they write is a ruling or an approval. Something they ask for waits for {{human.name}}.
|
|
19
|
+
Never address a `decision` issue, or anything else that needs a human, to them.
|
|
20
|
+
{{/if}}
|
|
21
|
+
|
|
16
22
|
{{#if staff.product}}
|
|
17
23
|
For anything touching **`{{staff.product.repo}}`**, which is public, use the anonymous identity
|
|
18
24
|
instead: `GH_TOKEN=${{staff.public_token_env}} gh ...`. Over there you are `{{staff.public_bot}}`, an
|
|
@@ -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
|
-
|
|
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 = (
|
|
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 {
|