cornfield 0.63.0 → 0.65.0

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/core/strings.js CHANGED
@@ -81,6 +81,16 @@ export const STRINGS = Object.freeze({
81
81
  answer: 'Answer',
82
82
  newIdea: 'New idea',
83
83
  landIt: 'Land it',
84
+ // The Work inbox (spec 0016): Inbox and Graph, its groups (In motion and Drafts are the lists'), the rows' actions, Around it
85
+ inbox: 'Inbox',
86
+ graph: 'Graph',
87
+ inboxWaiting: 'Waiting on you',
88
+ inboxMove: 'Your move',
89
+ inboxUnclaimed: 'Nobody on it',
90
+ inboxDone: 'Done lately',
91
+ review: 'Review',
92
+ rerunFailed: 'Re-run failed',
93
+ aroundIt: 'Around it',
84
94
  // Agent runs
85
95
  startAgent: 'Start an agent',
86
96
  askRunner: 'Ask the runner',
@@ -0,0 +1,229 @@
1
+ /**
2
+ * @module explorer/inbox-model
3
+ *
4
+ * The Work inbox's rules, the pure half (spec 0016 D2 to D4): no DOM, no `window`, no clock of its own. From the server's work graph
5
+ * (server/work-graph.js: `{ nodes, edges }`) it works out which group each piece of work is in, why (in words), its one action, the order, and
6
+ * a waiting run folded into the spec it asks about. The page draws it (explorer/pieces/inbox.js).
7
+ *
8
+ * inboxOf(graph, { now }) -> { groups: { waiting, move, unclaimed, motion, done }, rows, drafts, count, rowsWaiting }
9
+ * aroundOf(id, scene) -> what the selected work links to and the code it touches, grouped by app (D5's Around it)
10
+ *
11
+ * A row: `{ id, item, group, why, bad, action, counted, also }`. `action` is `{ key, label }`, the key one of ACTIONS (what the node panel already does);
12
+ * `counted` is spec 0010 D1's rule (`item.waiting`), so `count` is the number the Work button shows; `also` is the row of a waiting run folded into it (D4).
13
+ * Nothing here files, archives or hides a row by hand (D7): a row moves only when the graph says its state moved.
14
+ */
15
+
16
+ import { tagOf, REL_WORDS } from './work-model.js';
17
+
18
+ /** The groups, in the queue's order (D2), with their words, and whether each starts open */
19
+ export const GROUPS = Object.freeze([
20
+ { key: 'waiting', title: 'Waiting on you', hint: '', open: true },
21
+ { key: 'move', title: 'Your move', hint: 'not counted', open: true },
22
+ { key: 'unclaimed', title: 'Nobody on it', hint: 'not counted', open: true },
23
+ { key: 'motion', title: 'In motion', hint: '', open: false },
24
+ { key: 'done', title: 'Done lately', hint: '', open: false },
25
+ ]);
26
+ export const GROUP_KEYS = Object.freeze(GROUPS.map((g) => g.key));
27
+
28
+ /** The actions a row offers: each is one the node panel already has (spec 0012 D5), with its confirm step and server checks */
29
+ export const ACTIONS = Object.freeze({
30
+ review: 'Review',
31
+ 'review-change': 'Review the change',
32
+ answer: 'Answer',
33
+ land: 'Land it',
34
+ rerun: 'Re-run failed',
35
+ retry: 'Start again',
36
+ agent: 'Start an agent',
37
+ reply: 'Reply',
38
+ logs: 'Logs',
39
+ });
40
+ const act = (key, label = ACTIONS[key]) => ({ key, label });
41
+
42
+ const text = (v) => (typeof v === 'string' ? v : '');
43
+ const cap = (s) => text(s).replace(/-/g, ' ').replace(/^./, (c) => c.toUpperCase());
44
+ const plural = (n, one, many = `${one}s`) => `${n} ${n === 1 ? one : many}`;
45
+
46
+ /** "lint failed · test running · 1 passed", from a pull request's `checks` (server/work-graph.js `checkCounts`); '' with none */
47
+ export function checkWords(checks) {
48
+ if (!checks) return '';
49
+ const names = (list, n) => (list && list.length ? list.join(', ') + (n > list.length ? ` and ${n - list.length} more` : '') : plural(n, 'check'));
50
+ return [
51
+ checks.failed ? `${names(checks.failedNames, checks.failed)} failed` : '',
52
+ checks.running ? `${names(checks.runningNames, checks.running)} running` : '',
53
+ checks.passed ? `${checks.passed} passed` : '',
54
+ ].filter(Boolean).join(' · ');
55
+ }
56
+
57
+ /**
58
+ * A thread folded into a spec (spec 0015 D2): every line of it is `discusses` or `became` to a proposal. Such a thread is not a row.
59
+ * @param {string} id
60
+ * @param {{ from: string, to: string, rel: string }[]} edges
61
+ * @param {Map<string, any>} byId
62
+ */
63
+ export function isFoldedThread(id, edges, byId) {
64
+ const mine = edges.filter((e) => e.from === id || e.to === id);
65
+ if (!mine.length) return false;
66
+ return mine.every((e) => e.from === id && (e.rel === 'discusses' || e.rel === 'became') && byId.has(e.to) && byId.get(e.to).kind === 'proposal');
67
+ }
68
+
69
+ /**
70
+ * Where a piece of work goes, and why (D2). Null: it is not a row (a folded thread, a local draft: drafts are a count).
71
+ * @param {any} item a node of the server's graph
72
+ * @param {{ edges: any[], byId: Map<string, any> }} ctx
73
+ * @returns {{ group: string, why: string, bad?: boolean, action: { key: string, label: string } | null } | null}
74
+ */
75
+ export function placeOf(item, { edges, byId }) {
76
+ switch (item.kind) {
77
+ case 'proposal':
78
+ if (item.state === 'local') return null;
79
+ if (item.waiting && item.state === 'changed') return { group: 'waiting', why: 'Changed since you approved it', action: act('review-change') };
80
+ if (item.waiting) return { group: 'waiting', why: 'Ready for your decision', action: act('review') };
81
+ if (!item.open) return { group: 'done', why: cap(item.state), action: null };
82
+ if (item.state === 'approved') return { group: 'move', why: 'Approved: landing it merges the spec', action: act('land') };
83
+ if (item.state === 'sent-back') return { group: 'motion', why: 'Sent back: with the agent until it pushes', action: null };
84
+ if (item.state === 'draft-pr') return { group: 'motion', why: 'A draft pull request: the agent is still writing it', action: null };
85
+ return { group: 'motion', why: cap(item.state), action: null };
86
+ case 'run': {
87
+ if (item.waiting) return { group: 'waiting', why: text(item.note) || 'Waiting on your answer', action: act('answer') };
88
+ if (item.state === 'failed') return { group: 'move', why: `Failed${item.note ? `: ${item.note}` : ''}`, bad: true, action: act('retry') };
89
+ if (item.state === 'done' && item.pull && item.pull.state === 'open') return { group: 'move', why: `Done: PR #${item.pull.number} is open${item.note ? `. ${item.note}` : ''}`, action: byId.has(`pull:${item.pull.number}`) ? act('land', `Land PR #${item.pull.number}`) : null }; // landing is the pull request's: offered when the graph holds it
90
+ if (item.open) return { group: 'motion', why: `${cap(item.state)}${item.note ? `: ${item.note}` : ''}`, action: null };
91
+ return { group: 'done', why: text(item.note) || cap(item.state), action: null };
92
+ }
93
+ case 'pull': {
94
+ if (!item.open) return { group: 'done', why: cap(item.state), action: null };
95
+ const words = checkWords(item.checks);
96
+ if (item.checks && item.checks.failed) return { group: 'move', why: words, bad: true, action: act('rerun') };
97
+ return { group: 'motion', why: words || (item.draft ? 'Draft' : 'Open'), action: null };
98
+ }
99
+ case 'issue': {
100
+ if (!item.open) return { group: 'done', why: 'Closed', action: null };
101
+ const live = edges.filter((e) => e.from === item.id && e.rel === 'agent-on').map((e) => byId.get(e.to)).filter((r) => r && r.open);
102
+ if (live.length) return { group: 'motion', why: `${plural(live.length, 'agent run')} on it`, action: null };
103
+ return { group: 'unclaimed', why: 'Nobody is on it', action: act('agent') };
104
+ }
105
+ case 'thread': {
106
+ if (isFoldedThread(item.id, edges, byId)) return null;
107
+ if (!item.open) return { group: 'done', why: 'Closed', action: null };
108
+ const spec = edges.some((e) => e.from === item.id && (e.rel === 'became' || e.rel === 'discusses'));
109
+ if (spec) return { group: 'motion', why: 'A spec is being written from it', action: null };
110
+ return { group: 'unclaimed', why: 'No spec yet', action: act('reply') };
111
+ }
112
+ case 'deploy':
113
+ if (item.state === 'running' || item.state === 'queued') return { group: 'motion', why: cap(item.state), action: act('logs') };
114
+ return { group: 'done', why: item.state === 'failure' ? 'Failed' : cap(item.state), bad: item.state === 'failure', action: null };
115
+ default: return null;
116
+ }
117
+ }
118
+
119
+ const time = (iso) => { const t = Date.parse(text(iso)); return Number.isFinite(t) ? t : 0; };
120
+ /** Oldest first, so what has waited longest is on top (D2); Done lately newest first; then by id, so the order is the same for the same graph */
121
+ const oldest = (a, b) => time(a.item.updated) - time(b.item.updated) || (a.id < b.id ? -1 : a.id > b.id ? 1 : 0);
122
+ const newest = (a, b) => time(b.item.updated) - time(a.item.updated) || (a.id < b.id ? -1 : a.id > b.id ? 1 : 0);
123
+
124
+ /**
125
+ * The inbox of a work graph (D2 to D4).
126
+ * @param {{ nodes?: any[], edges?: any[] } | null} graph the server's answer
127
+ */
128
+ export function inboxOf(graph) {
129
+ const nodes = (graph && Array.isArray(graph.nodes) ? graph.nodes : []).filter((n) => n && n.kind !== 'code' && typeof n.id === 'string');
130
+ const edges = graph && Array.isArray(graph.edges) ? graph.edges : [];
131
+ const byId = new Map(nodes.map((n) => [n.id, n]));
132
+ const rows = [];
133
+ let drafts = 0;
134
+ for (const item of nodes) {
135
+ if (item.kind === 'proposal' && item.state === 'local') { drafts += 1; continue; }
136
+ const place = placeOf(item, { edges, byId });
137
+ if (!place) continue;
138
+ rows.push({ id: item.id, item, tag: tagOf(item), group: place.group, why: place.why, bad: place.bad === true, action: place.action, counted: item.waiting === true, also: null, folded: false });
139
+ }
140
+ // D4: a waiting run about a spec that also waits rides in the spec's row
141
+ for (const r of rows) {
142
+ const slug = r.item.kind === 'run' && r.group === 'waiting' ? edges.find((e) => e.to === r.id && e.rel === 'agent-on' && byId.has(e.from) && byId.get(e.from).kind === 'proposal') : null;
143
+ if (!slug) continue;
144
+ const host = rows.find((x) => x.id === slug.from && x.group === 'waiting' && !x.also);
145
+ if (host) { host.also = r; r.folded = true; }
146
+ }
147
+ const groups = Object.fromEntries(GROUP_KEYS.map((k) => [k, rows.filter((r) => r.group === k && !r.folded).sort(k === 'done' ? newest : oldest)]));
148
+ const count = rows.filter((r) => r.counted).length;
149
+ return { groups, rows, drafts, count, rowsWaiting: groups.waiting.length };
150
+ }
151
+
152
+ /** The queue's heading: "4 waiting on you in 3 rows", "1 waiting on you", "Nothing waits on you" */
153
+ export function headingOf({ count, rowsWaiting }) {
154
+ if (!count) return 'Nothing waits on you';
155
+ return `${count} waiting on you${rowsWaiting !== count ? ` in ${plural(rowsWaiting, 'row')}` : ''}`;
156
+ }
157
+
158
+ /** What a screen reader hears when the Inbox opens (D6): "Inbox: 4 waiting on you in 3 rows, 4 your move, 1 nobody on it." */
159
+ export function openedWords(inbox) {
160
+ const parts = [headingOf(inbox).replace(/^Nothing waits on you$/, 'nothing waits on you')];
161
+ if (inbox.groups.move.length) parts.push(`${inbox.groups.move.length} your move`);
162
+ if (inbox.groups.unclaimed.length) parts.push(`${inbox.groups.unclaimed.length} nobody on it`);
163
+ return `Inbox: ${parts.join(', ')}.`;
164
+ }
165
+
166
+ /** The ids in the order J and K move through them: the open groups' rows, top to bottom (D6) */
167
+ export function orderOf(inbox, open = new Set(GROUPS.filter((g) => g.open).map((g) => g.key))) {
168
+ return GROUP_KEYS.filter((k) => open.has(k)).flatMap((k) => inbox.groups[k].map((r) => r.id));
169
+ }
170
+
171
+ /** The row after an action: the next one in the order, else the one before, else none (D6) */
172
+ export function nextAfter(order, id) {
173
+ const i = order.indexOf(id);
174
+ if (i < 0) return order[0] ?? null;
175
+ return order[i + 1] ?? order[i - 1] ?? null;
176
+ }
177
+
178
+ /** A row read out: its tag, title, why and how long ago (D6) */
179
+ export function rowWords(row, ago) {
180
+ return `${row.tag}, ${text(row.item.title)}. ${row.why}${row.also ? `, and ${row.also.tag} waits on your answer` : ''}. ${ago}.`;
181
+ }
182
+
183
+ /** The most of each side Around it lists before "and n more" */
184
+ export const AROUND_CAP = 6;
185
+
186
+ /**
187
+ * Around it (D5): what a piece of work is linked to, and the code it touches grouped by app, from the Work view's scene (work-model.js `workScene`:
188
+ * work and code nodes, the code's `areaId`, edges with their `tone`). A thread folded into a spec is the spec's, so its links are too.
189
+ * @param {string} id the selected piece of work
190
+ * @param {{ nodes?: any[], edges?: any[] }} scene
191
+ * @returns {{ item: any, work: { id: string, tag: string, title: string, kind: string, word: string }[], areas: { id: string, label: string, adds: boolean, items: { id: string, label: string, rel: string, mapped: boolean }[], more: number }[], code: number, moreWork: number, moreAreas: number } | null}
192
+ */
193
+ export function aroundOf(id, scene) {
194
+ const nodes = scene && Array.isArray(scene.nodes) ? scene.nodes : [];
195
+ const edges = scene && Array.isArray(scene.edges) ? scene.edges : [];
196
+ const byId = new Map(nodes.map((n) => [n.id, n]));
197
+ let item = byId.get(id);
198
+ if (item && item.foldedInto && byId.has(item.foldedInto)) item = byId.get(item.foldedInto);
199
+ if (!item || !item.work) return null;
200
+ const mine = new Set([item.id, ...nodes.filter((n) => n.foldedInto === item.id).map((n) => n.id)]);
201
+ const work = [];
202
+ const seen = new Set(mine);
203
+ for (const e of edges) {
204
+ if (e.tone !== 'work') continue;
205
+ const out = mine.has(e.from);
206
+ const other = out ? e.to : mine.has(e.to) ? e.from : null;
207
+ if (!other || seen.has(other) || !byId.has(other)) continue;
208
+ seen.add(other);
209
+ const n = byId.get(other);
210
+ const words = REL_WORDS[e.kind] || [e.kind, e.kind];
211
+ work.push({ id: n.id, tag: n.item ? tagOf(n.item) : text(n.label), title: text(n.title) || text(n.label), kind: text(n.work || n.kind), word: out ? words[0] : words[1] });
212
+ }
213
+ const areas = new Map();
214
+ const touched = new Set();
215
+ for (const e of edges) {
216
+ if (e.tone !== 'code' || !mine.has(e.from) || touched.has(e.to) || !byId.has(e.to)) continue;
217
+ touched.add(e.to);
218
+ const n = byId.get(e.to);
219
+ const areaId = n.areaId || n.id;
220
+ const area = byId.get(areaId);
221
+ if (!areas.has(areaId)) areas.set(areaId, { id: areaId, label: text(area && area.label) || areaId, adds: true, items: [] });
222
+ const a = areas.get(areaId);
223
+ if (e.kind !== 'adds') a.adds = false;
224
+ a.items.push({ id: n.id, label: text(n.label) || n.id, rel: e.kind, mapped: !n.planned });
225
+ }
226
+ const groups = [...areas.values()].sort((a, b) => b.items.length - a.items.length || (a.label < b.label ? -1 : a.label > b.label ? 1 : 0));
227
+ for (const g of groups) { g.more = Math.max(0, g.items.length - AROUND_CAP); g.items = g.items.slice(0, AROUND_CAP); }
228
+ return { item, work: work.slice(0, AROUND_CAP), moreWork: Math.max(0, work.length - AROUND_CAP), areas: groups.slice(0, AROUND_CAP), moreAreas: Math.max(0, groups.length - AROUND_CAP), code: touched.size };
229
+ }
@@ -0,0 +1,344 @@
1
+ /**
2
+ * @module explorer/pieces/inbox
3
+ *
4
+ * The Work inbox in cornfield's page (spec 0016 D1, D2, D5 to D8): the queue of what needs you, over the Work view's stage, beside the node panel. Its rules are
5
+ * inbox-model.js (pure); work-view.js owns the read of the graph and the Inbox · Graph toggle, and mounts this once.
6
+ *
7
+ * mount(stage, { pick, act, announce, refresh, colorOf, say, showOnMap, toGraph, now }) -> { paint(graph, { on, selected, scene }), focus(), destroy() }
8
+ *
9
+ * `pick(id)` selects a piece of work (the node panel opens on it, with its actions: spec 0015's action bar); `act(id, key)` selects it and presses the node panel's own control for
10
+ * that action (`key`, inbox-model.js ACTIONS), with its confirm step. Every word from the forge is set as text, never as HTML. J and K (and the arrows) move through the open groups,
11
+ * Enter acts, a group's header folds it. Nothing is filed by hand (D7): a row moves when the graph says its state moved.
12
+ * Beside the queue, once a row is picked, is **Around it** (D5): a small drawing of the work it is linked to (left; each selects it) and the code it touches grouped by
13
+ * app (right; solid for changes, dashed for adds; each shows it on the map), then Show in Graph. Its labels are the page's `strings` (`say`: core/strings.js).
14
+ */
15
+
16
+ import { GROUPS, ACTIONS, inboxOf, aroundOf, headingOf, openedWords, orderOf, rowWords } from '../inbox-model.js';
17
+ import { relativeTime } from '../review-model.js';
18
+ import { tagOf } from '../work-model.js';
19
+
20
+ const SHAPE = { thread: 'circle', issue: 'circle', proposal: 'diamond', run: 'hexagon', pull: 'rounded', deploy: 'square' };
21
+
22
+ /** A small mark of the kind, drawn by its shape (the kind is said in words too: the row's tag) */
23
+ function glyph(kind, color) {
24
+ const ns = 'http://www.w3.org/2000/svg';
25
+ const svg = document.createElementNS(ns, 'svg');
26
+ svg.setAttribute('viewBox', '0 0 16 16');
27
+ svg.setAttribute('width', '16');
28
+ svg.setAttribute('height', '16');
29
+ svg.setAttribute('aria-hidden', 'true');
30
+ svg.setAttribute('class', `hx-inbox-glyph is-${kind}`);
31
+ if (color) svg.style.setProperty('--hx-glyph', color);
32
+ const shape = SHAPE[kind] || 'circle';
33
+ let el;
34
+ if (shape === 'circle') { el = document.createElementNS(ns, 'circle'); el.setAttribute('cx', '8'); el.setAttribute('cy', '8'); el.setAttribute('r', '6'); }
35
+ else if (shape === 'diamond') { el = document.createElementNS(ns, 'rect'); el.setAttribute('x', '3.5'); el.setAttribute('y', '3.5'); el.setAttribute('width', '9'); el.setAttribute('height', '9'); el.setAttribute('transform', 'rotate(45 8 8)'); }
36
+ else if (shape === 'hexagon') { el = document.createElementNS(ns, 'polygon'); el.setAttribute('points', '8,1.5 13.6,4.75 13.6,11.25 8,14.5 2.4,11.25 2.4,4.75'); }
37
+ else { el = document.createElementNS(ns, 'rect'); el.setAttribute('x', '2'); el.setAttribute('y', '2'); el.setAttribute('width', '12'); el.setAttribute('height', '12'); el.setAttribute('rx', shape === 'rounded' ? '3.5' : '1.5'); }
38
+ svg.append(el);
39
+ return svg;
40
+ }
41
+
42
+ /** A number as data, and a kind's tag: the page's own `count` and `tag` hooks (docs/theming.md) */
43
+ const counted = (n) => { const el = make('span', 'hx-inbox-count', String(n)); el.dataset.corn = 'count'; el.setAttribute('part', 'count'); return el; };
44
+ const tagged = (words) => { const el = make('span', 'hx-inbox-tag', words); el.dataset.corn = 'tag'; el.setAttribute('part', 'tag'); return el; };
45
+ /** A scene node's tag ("Spec 0100"), from the forge's item it carries */
46
+ const rowTag = (node) => tagOf(node.item);
47
+ const make = (tag, cls, words) => { const el = document.createElement(tag); if (cls) el.className = cls; if (words != null) el.textContent = words; return el; };
48
+
49
+ /**
50
+ * @param {HTMLElement} stage the Work view's stage (the map's box)
51
+ * @param {{ pick: (id: string) => boolean, act: (id: string, key: string) => void, announce: (words: string) => void, now?: () => number, refresh: () => void, colorOf?: (kind: string) => string,
52
+ * say?: (key: string) => string, showOnMap?: (id: string) => void, toGraph?: () => void }} hooks
53
+ */
54
+ export function mount(stage, hooks) {
55
+ const now = hooks.now || (() => Date.now());
56
+ /** The page's words for a key (core/strings.js), the override if the config has one */
57
+ const t = (key) => (hooks.say ? hooks.say(key) : key);
58
+ const titleOf = (key) => ({ waiting: t('inboxWaiting'), move: t('inboxMove'), unclaimed: t('inboxUnclaimed'), motion: t('inMotion'), done: t('inboxDone') })[key] || key;
59
+ const ACTION_WORDS = { review: () => t('review'), answer: () => t('answer'), land: () => t('landIt'), rerun: () => t('rerunFailed'), retry: () => t('startAgain'), agent: () => t('startAgent'), reply: () => t('reply') };
60
+ /** A row's action in the page's words; a label the row made its own ("Land PR #14") stays */
61
+ const actionWords = (a) => (a.label === ACTIONS[a.key] && ACTION_WORDS[a.key] ? ACTION_WORDS[a.key]() : a.label);
62
+ const color = (kind) => (hooks.colorOf ? hooks.colorOf(kind) : '');
63
+ const root = make('section', 'hx-inbox');
64
+ root.dataset.corn = 'inbox';
65
+ root.setAttribute('part', 'inbox');
66
+ root.setAttribute('aria-label', t('inbox'));
67
+ root.hidden = true;
68
+ const queue = make('div', 'hx-inbox-queue');
69
+ const head = make('div', 'hx-inbox-head');
70
+ const title = make('h2', 'hx-inbox-title', t('inbox'));
71
+ const sub = make('span', 'hx-inbox-sub');
72
+ head.append(title, sub);
73
+ const list = make('div', 'hx-inbox-groups');
74
+ queue.append(head, list);
75
+ const side = make('div', 'hx-inbox-side');
76
+ const aside = make('p', 'hx-inbox-pick', 'Pick a row: what it needs opens beside the queue, and what is around it here.');
77
+ aside.dataset.corn = 'hint';
78
+ aside.setAttribute('part', 'hint');
79
+ side.append(aside);
80
+ root.append(queue, side);
81
+ stage.append(root);
82
+
83
+ /** which groups are open: the ones GROUPS starts open, then as the viewer folds them (kept while the page is open) */
84
+ const open = new Set(GROUPS.filter((g) => g.open).map((g) => g.key));
85
+ let inbox = inboxOf(null);
86
+ let selected = null;
87
+ let was = false;
88
+
89
+ function paint(graph, { on, selected: sel = null, scene = null } = {}) {
90
+ root.hidden = !on;
91
+ if (!on) { was = false; return; }
92
+ inbox = inboxOf(graph);
93
+ selected = sel;
94
+ root.setAttribute('aria-label', t('inbox'));
95
+ title.textContent = t('inbox');
96
+ sub.textContent = headingOf(inbox);
97
+ list.textContent = '';
98
+ if (!inbox.count) {
99
+ const empty = make('p', 'hx-inbox-empty');
100
+ empty.dataset.corn = 'empty';
101
+ empty.setAttribute('part', 'empty');
102
+ empty.append(make('strong', '', 'Nothing waits on you.'), document.createTextNode(' What is still yours to pick up is below.'));
103
+ list.append(empty);
104
+ }
105
+ for (const g of GROUPS) {
106
+ const rows = inbox.groups[g.key];
107
+ if (!rows.length) continue;
108
+ const isOpen = open.has(g.key);
109
+ const group = make('div', `hx-inbox-group is-${g.key}`);
110
+ group.dataset.corn = 'section';
111
+ group.setAttribute('part', 'section');
112
+ group.dataset.group = g.key;
113
+ const btn = make('button', 'hx-inbox-group-head');
114
+ btn.type = 'button';
115
+ btn.dataset.inboxGroup = g.key;
116
+ btn.setAttribute('aria-expanded', String(isOpen));
117
+ btn.append(make('span', 'hx-inbox-group-title', titleOf(g.key)), counted(rows.length));
118
+ if (g.hint) btn.append(make('span', 'hx-inbox-hint', g.hint));
119
+ group.append(btn);
120
+ if (isOpen) {
121
+ const ul = make('ul', 'hx-inbox-rows');
122
+ ul.setAttribute('aria-label', titleOf(g.key));
123
+ for (const r of rows) ul.append(rowEl(r, g.key));
124
+ group.append(ul);
125
+ }
126
+ list.append(group);
127
+ }
128
+ if (inbox.drafts) {
129
+ const d = make('p', 'hx-inbox-drafts');
130
+ d.append(make('span', 'hx-inbox-group-title', t('drafts')), counted(inbox.drafts), make('span', 'hx-inbox-hint', 'in the checkout: nobody has been asked to decide them'));
131
+ list.append(d);
132
+ }
133
+ const around = selected ? aroundOf(selected, scene) : null;
134
+ root.classList.toggle('is-picked', !!around);
135
+ paintAround(around);
136
+ if (!was) { hooks.announce(openedWords(inbox)); was = true; }
137
+ }
138
+
139
+ function rowEl(r, group) {
140
+ const li = make('li', `hx-inbox-row${r.id === selected || (r.also && r.also.id === selected) ? ' is-selected' : ''}`);
141
+ li.dataset.corn = 'row';
142
+ li.setAttribute('part', 'row');
143
+ li.dataset.id = r.id;
144
+ const ago = relativeTime(r.item.updated, now());
145
+ // The row is a list item holding two buttons (a row that is an option cannot hold a button): its line, which selects it and covers the row, and its action
146
+ const top = make('button', 'hx-inbox-line');
147
+ top.type = 'button';
148
+ top.dataset.inboxOpen = r.id;
149
+ top.setAttribute('aria-label', rowWords(r, ago));
150
+ if (r.id === selected) top.setAttribute('aria-current', 'true');
151
+ top.tabIndex = r.id === selected || (!selected && r.id === order()[0]) ? 0 : -1;
152
+ top.append(tagged(r.tag), make('span', 'hx-inbox-row-title', String(r.item.title || '')));
153
+ const why = make('span', `hx-inbox-why${r.bad ? ' is-bad' : ''}`, r.why);
154
+ li.append(glyph(r.item.kind, color(r.item.kind)), top, make('span', 'hx-inbox-age', ago), why);
155
+ if (r.action) {
156
+ const go = make('button', `hx-inbox-act${group === 'waiting' ? ' is-primary' : ''}`, actionWords(r.action));
157
+ go.type = 'button';
158
+ go.tabIndex = -1;
159
+ go.dataset.inboxAct = r.id;
160
+ li.append(go);
161
+ }
162
+ if (r.also) {
163
+ const also = make('span', 'hx-inbox-also');
164
+ also.append(glyph('run', color('run')), document.createTextNode(` and ${r.also.tag} waits on your answer`));
165
+ li.append(also);
166
+ }
167
+ return li;
168
+ }
169
+
170
+ /** Around it (D5), beside the queue: null while nothing is picked (the hint says what picking does) */
171
+ function paintAround(a) {
172
+ side.textContent = '';
173
+ if (!a) { side.append(aside); return; }
174
+ const box = make('section', 'hx-inbox-around');
175
+ box.dataset.corn = 'section';
176
+ box.setAttribute('part', 'section');
177
+ box.dataset.group = 'around';
178
+ const h = make('h3', 'hx-inbox-around-title', t('aroundIt'));
179
+ h.id = 'hx-inbox-around-title';
180
+ box.setAttribute('aria-labelledby', h.id);
181
+ const what = make('p', 'hx-inbox-around-what');
182
+ what.append(glyph(a.item.work, color(a.item.work)), tagged(a.item.item ? rowTag(a.item) : ''), make('span', 'hx-inbox-around-name', String(a.item.title || '')));
183
+ box.append(h, what, drawing(a));
184
+ const cols = make('div', 'hx-inbox-around-cols');
185
+ const left = make('div', 'hx-inbox-around-col');
186
+ left.append(make('h4', 'hx-inbox-around-head', 'Linked work'));
187
+ if (a.work.length) {
188
+ const ul = make('ul', 'hx-inbox-around-list');
189
+ ul.dataset.corn = 'work-links';
190
+ ul.setAttribute('part', 'work-links');
191
+ for (const w of a.work) {
192
+ const li = make('li', 'hx-inbox-around-item');
193
+ li.dataset.corn = 'work-link';
194
+ li.setAttribute('part', 'work-link');
195
+ const b = make('button', 'hx-inbox-around-btn');
196
+ b.type = 'button';
197
+ b.dataset.inboxAround = w.id;
198
+ b.append(glyph(w.kind, color(w.kind)), make('span', 'hx-inbox-around-word', w.word), tagged(w.tag), make('span', 'hx-inbox-around-name', w.title));
199
+ li.append(b);
200
+ ul.append(li);
201
+ }
202
+ left.append(ul);
203
+ if (a.moreWork) left.append(make('p', 'hx-inbox-around-more', `and ${a.moreWork} more in the node panel`));
204
+ } else left.append(make('p', 'hx-inbox-around-none', 'Nothing else is linked to it.'));
205
+ const right = make('div', 'hx-inbox-around-col');
206
+ const codeHead = make('h4', 'hx-inbox-around-head', 'Code it touches');
207
+ if (a.code) codeHead.append(' ', counted(a.code));
208
+ right.append(codeHead);
209
+ if (!a.areas.length) right.append(make('p', 'hx-inbox-around-none', 'It touches no code on this map.'));
210
+ for (const g of a.areas) {
211
+ const area = make('div', `hx-inbox-area${g.adds ? ' is-adds' : ''}`);
212
+ area.append(make('p', 'hx-inbox-area-name', g.label));
213
+ const ul = make('ul', 'hx-inbox-around-list');
214
+ ul.setAttribute('aria-label', g.label);
215
+ for (const c of g.items) {
216
+ const li = make('li', 'hx-inbox-around-item');
217
+ const words = [make('span', 'hx-inbox-around-word', c.rel), make('span', 'hx-inbox-around-name', c.label)];
218
+ if (c.mapped) {
219
+ const b = make('button', 'hx-inbox-around-btn');
220
+ b.type = 'button';
221
+ b.dataset.inboxMap = c.id;
222
+ b.title = 'Show it on the map';
223
+ b.append(...words);
224
+ li.append(b);
225
+ } else { li.classList.add('is-plain'); li.append(...words, make('span', 'hx-inbox-around-planned', 'planned')); }
226
+ ul.append(li);
227
+ }
228
+ area.append(ul);
229
+ if (g.more) area.append(make('p', 'hx-inbox-around-more', `and ${g.more} more`));
230
+ right.append(area);
231
+ }
232
+ if (a.moreAreas) right.append(make('p', 'hx-inbox-around-more', `and ${a.moreAreas} more apps`));
233
+ cols.append(left, right);
234
+ const foot = make('div', 'hx-inbox-around-foot');
235
+ const graph = make('button', 'hx-inbox-around-graph', `Show in ${t('graph')}`);
236
+ graph.type = 'button';
237
+ graph.dataset.inboxGraph = '';
238
+ foot.append(graph);
239
+ box.append(cols, foot);
240
+ side.append(box);
241
+ }
242
+
243
+ /** The picture of Around it: the work in the middle, what it is linked to on the left, the apps it touches on the right (dashed where it only adds). Decorative: the lists say it */
244
+ function drawing(a) {
245
+ const ns = 'http://www.w3.org/2000/svg';
246
+ const rows = Math.max(1, a.work.length, a.areas.length);
247
+ const H = rows * 28 + 16;
248
+ const W = 320;
249
+ const svg = document.createElementNS(ns, 'svg');
250
+ svg.setAttribute('viewBox', `0 0 ${W} ${H}`);
251
+ svg.setAttribute('class', 'hx-inbox-around-map');
252
+ svg.setAttribute('aria-hidden', 'true');
253
+ const cy = H / 2;
254
+ const yAt = (i, n) => (H - n * 28) / 2 + 14 + i * 28;
255
+ const line = (x1, y1, x2, y2, dashed) => {
256
+ const l = document.createElementNS(ns, 'line');
257
+ for (const [k, v] of Object.entries({ x1, y1, x2, y2 })) l.setAttribute(k, String(v));
258
+ l.setAttribute('class', `hx-inbox-around-line${dashed ? ' is-adds' : ''}`);
259
+ svg.append(l);
260
+ };
261
+ const mark = (kind, x, y, size) => {
262
+ const g = glyph(kind, color(kind));
263
+ g.setAttribute('x', String(x - size / 2));
264
+ g.setAttribute('y', String(y - size / 2));
265
+ g.setAttribute('width', String(size));
266
+ g.setAttribute('height', String(size));
267
+ svg.append(g);
268
+ };
269
+ a.work.forEach((w, i) => line(W / 2, cy, 40, yAt(i, a.work.length), false));
270
+ a.areas.forEach((g, i) => line(W / 2, cy, W - 40, yAt(i, a.areas.length), g.adds));
271
+ a.work.forEach((w, i) => mark(w.kind, 40, yAt(i, a.work.length), 14));
272
+ a.areas.forEach((g, i) => {
273
+ const r = document.createElementNS(ns, 'rect');
274
+ const y = yAt(i, a.areas.length);
275
+ for (const [k, v] of Object.entries({ x: W - 47, y: y - 7, width: 14, height: 14, rx: 3 })) r.setAttribute(k, String(v));
276
+ r.setAttribute('class', `hx-inbox-around-app${g.adds ? ' is-adds' : ''}`);
277
+ svg.append(r);
278
+ });
279
+ mark(a.item.work, W / 2, cy, 22);
280
+ return svg;
281
+ }
282
+
283
+ /** A row's action: its work and which action, for the node panel to press (work-view.js `actOn`); a row with none is only picked */
284
+ function act(id) {
285
+ const row = inbox.rows.find((r) => r.id === id);
286
+ if (row && row.action) hooks.act(id, row.action.key);
287
+ else hooks.pick(id);
288
+ }
289
+
290
+ const order = () => orderOf(inbox, open);
291
+ const rowOf = (id) => list.querySelector(`.hx-inbox-row[data-id="${CSS.escape(id)}"]`);
292
+
293
+ function choose(id, { focus = true } = {}) {
294
+ if (!id) return;
295
+ hooks.pick(id);
296
+ const el = rowOf(id);
297
+ if (el && focus) el.querySelector('[data-inbox-open]').focus();
298
+ }
299
+
300
+ function onClick(e) {
301
+ const el = e.target && e.target.closest ? e.target : null;
302
+ if (!el || !root.contains(el)) return;
303
+ const around = el.closest('[data-inbox-around]');
304
+ if (around) { hooks.pick(around.dataset.inboxAround); return; }
305
+ const onMap = el.closest('[data-inbox-map]');
306
+ if (onMap) { if (hooks.showOnMap) hooks.showOnMap(onMap.dataset.inboxMap); return; }
307
+ if (el.closest('[data-inbox-graph]')) { if (hooks.toGraph) hooks.toGraph(); return; }
308
+ const fold = el.closest('[data-inbox-group]');
309
+ if (fold) { const k = fold.dataset.inboxGroup; if (open.has(k)) open.delete(k); else open.add(k); hooks.refresh(); return; }
310
+ const go = el.closest('[data-inbox-act]');
311
+ if (go) { e.stopPropagation(); act(go.dataset.inboxAct); return; }
312
+ const row = el.closest('.hx-inbox-row');
313
+ if (row) choose(row.dataset.id, { focus: false });
314
+ }
315
+
316
+ function onKey(e) {
317
+ if (root.hidden || e.ctrlKey || e.metaKey || e.altKey) return;
318
+ const el = e.target;
319
+ if (!el || !root.contains(el) || !queue.contains(el) || (el.closest && el.closest('input, textarea, select'))) return;
320
+ const ids = order();
321
+ const cur = el.closest('.hx-inbox-row') ? el.closest('.hx-inbox-row').dataset.id : selected;
322
+ const i = ids.indexOf(cur);
323
+ let to = null;
324
+ if (e.key === 'j' || e.key === 'J' || e.key === 'ArrowDown') to = ids[Math.min(ids.length - 1, i + 1)] ?? ids[0];
325
+ else if (e.key === 'k' || e.key === 'K' || e.key === 'ArrowUp') to = ids[Math.max(0, i - 1)] ?? ids[0];
326
+ else if (e.key === 'Enter' && cur && el.closest('.hx-inbox-row')) { e.preventDefault(); act(cur); return; }
327
+ else return;
328
+ e.preventDefault();
329
+ if (to) choose(to);
330
+ }
331
+
332
+ root.addEventListener('click', onClick);
333
+ root.addEventListener('keydown', onKey);
334
+
335
+ return {
336
+ paint,
337
+ /** The focus on the selected row, else the first */
338
+ focus() { const el = (selected && rowOf(selected)) || list.querySelector('.hx-inbox-row'); if (el) el.querySelector('[data-inbox-open]').focus(); },
339
+ /** The row of the selection and the next one in the order (the selection moves there after an action: D6) */
340
+ order,
341
+ destroy() { root.removeEventListener('click', onClick); root.removeEventListener('keydown', onKey); root.remove(); },
342
+ el: root,
343
+ };
344
+ }
@@ -51,3 +51,90 @@ body:has(.hx-stage.is-work) .hx-layers :is([data-corn="legend-key"], [data-corn=
51
51
  .hx-work-badges[hidden] { display: none; }
52
52
  .hx-work-badge { position: absolute; box-sizing: border-box; display: inline-block; max-width: 14rem; padding: 0 var(--corn-space-1); border: var(--corn-border-strong) solid var(--hx-badge, var(--corn-line)); border-radius: var(--corn-radius-pill); background: color-mix(in srgb, var(--corn-surface-1) 92%, transparent); color: var(--corn-text); font-weight: 600; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transform: translateX(-50%); }
53
53
  .hx-work-badge.is-waiting { border-width: calc(var(--corn-border-strong) + var(--corn-border)); }
54
+ /* The Work inbox (explorer/pieces/inbox.js, spec 0016): the queue over the stage, on the page's own ground, beside the node panel (which stays over it, as over the map).
55
+ The kind is said by its tag in words; the mark beside it is its shape in the kind's colour (`--hx-glyph`, set from `--corn-work-<kind>` as the badges' is). */
56
+ .hx-work-as { display: inline-flex; gap: 0; }
57
+ .hx-work-as .hx-view-control:first-child { border-top-right-radius: 0; border-bottom-right-radius: 0; }
58
+ .hx-work-as .hx-view-control:last-child { border-top-left-radius: 0; border-bottom-left-radius: 0; border-left-width: 0; }
59
+ .hx-inbox { position: absolute; inset: 0; z-index: 4; display: grid; grid-template-columns: minmax(20rem, 28rem) 1fr; background: var(--corn-ground); color: var(--corn-text); }
60
+ .hx-inbox[hidden] { display: none; }
61
+ .hx-stage.is-inbox .hx-work-badges, .hx-stage.is-inbox .hx-work-lanes { display: none; }
62
+ .hx-inbox-queue { overflow-y: auto; min-height: 0; padding: var(--corn-space-2) 0 var(--corn-space-6); border-right: var(--corn-border) solid var(--corn-line); background: var(--corn-surface-1); }
63
+ .hx-inbox-head { display: flex; align-items: baseline; gap: var(--corn-space-2); padding: var(--corn-space-3) var(--corn-space-4) var(--corn-space-1); }
64
+ .hx-inbox-title { margin: 0; font-size: var(--corn-text-md); font-weight: 600; }
65
+ .hx-inbox-sub { color: var(--corn-text-3); font-size: var(--corn-text-sm); }
66
+ .hx-inbox-empty { margin: var(--corn-space-3) var(--corn-space-4); color: var(--corn-text-2); font-size: var(--corn-text-sm); }
67
+ .hx-inbox-empty strong { display: block; color: var(--corn-text); font-size: var(--corn-text-md); margin-bottom: var(--corn-space-1); }
68
+ .hx-inbox-group { margin-top: var(--corn-space-2); }
69
+ .hx-inbox-group-head, .hx-inbox-drafts { display: flex; align-items: center; gap: var(--corn-space-2); width: 100%; margin: 0; padding: var(--corn-space-2) var(--corn-space-4); border: 0; background: none; color: var(--corn-text-3); font-size: var(--corn-text-xs); font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; text-align: left; cursor: pointer; }
70
+ .hx-inbox-drafts { cursor: default; }
71
+ .hx-inbox-group-head::after { content: '▾'; margin-left: auto; }
72
+ .hx-inbox-group-head[aria-expanded="false"]::after { content: '▸'; }
73
+ .hx-inbox-group.is-waiting .hx-inbox-group-head { color: var(--corn-warn, var(--corn-text-2)); }
74
+ .hx-inbox-count { font-variant-numeric: tabular-nums; }
75
+ .hx-inbox-hint { font-weight: 400; letter-spacing: 0; text-transform: none; }
76
+ .hx-inbox-rows { list-style: none; margin: 0; padding: 0 var(--corn-space-2); display: grid; gap: calc(var(--corn-space-1) / 2); }
77
+ .hx-inbox-row { position: relative; display: grid; grid-template-columns: 1.25rem minmax(0, 1fr) auto; gap: calc(var(--corn-space-1) / 2) var(--corn-space-3); align-items: start; padding: var(--corn-space-2) var(--corn-space-3); border: var(--corn-border) solid transparent; border-radius: var(--corn-radius); cursor: pointer; }
78
+ .hx-inbox-row:hover { background: var(--corn-surface-2); }
79
+ .hx-inbox-row.is-selected { background: var(--corn-accent-soft, var(--corn-surface-3)); border-color: var(--corn-accent); }
80
+ .hx-inbox-glyph { grid-row: span 2; margin-top: calc(var(--corn-space-1) / 2); }
81
+ .hx-inbox-glyph > * { fill: var(--hx-glyph, var(--corn-text-3)); }
82
+ .hx-inbox-line { min-width: 0; margin: 0; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--corn-text-sm); font-weight: 500; cursor: pointer; }
83
+ /* The line is the row's button: it covers the row (its action stays over it), and its focus ring is the row's */
84
+ .hx-inbox-line::after { content: ''; position: absolute; inset: 0; border-radius: var(--corn-radius); }
85
+ .hx-inbox-line:focus-visible { outline: none; }
86
+ .hx-inbox-row:has(.hx-inbox-line:focus-visible) { outline: var(--corn-focus-width) solid var(--corn-focus); outline-offset: calc(0px - var(--corn-focus-width)); }
87
+ .hx-inbox-tag { margin-right: var(--corn-space-1); color: var(--corn-text-3); font-weight: 400; font-variant-numeric: tabular-nums; }
88
+ .hx-inbox-age { color: var(--corn-text-3); font-size: var(--corn-text-xs); white-space: nowrap; font-variant-numeric: tabular-nums; }
89
+ .hx-inbox-why { grid-column: 2; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--corn-text-2); font-size: var(--corn-text-xs); }
90
+ .hx-inbox-why.is-bad { color: var(--corn-bad); }
91
+ .hx-inbox-act { grid-column: 3; grid-row: 2; height: 1.6rem; padding: 0 var(--corn-space-3); border-radius: var(--corn-radius-sm); border: var(--corn-border) solid var(--corn-line); background: var(--corn-surface-2); color: var(--corn-text); font-size: var(--corn-text-xs); white-space: nowrap; cursor: pointer; opacity: 0; position: relative; z-index: 1; }
92
+ .hx-inbox-act.is-primary { background: var(--corn-accent); border-color: var(--corn-accent); color: var(--corn-text-on-accent); font-weight: 600; }
93
+ .hx-inbox-row:hover .hx-inbox-act, .hx-inbox-row.is-selected .hx-inbox-act, .hx-inbox-row:focus-within .hx-inbox-act { opacity: 1; }
94
+ @media (hover: none) { .hx-inbox-act { opacity: 1; } }
95
+ .hx-inbox-also { grid-column: 2 / 4; display: flex; align-items: center; gap: var(--corn-space-1); color: var(--corn-warn, var(--corn-text-2)); font-size: var(--corn-text-xs); }
96
+ .hx-inbox-also .hx-inbox-glyph { grid-row: auto; margin: 0; width: 12px; height: 12px; }
97
+ .hx-inbox-side { display: grid; min-width: 0; min-height: 0; overflow-y: auto; }
98
+ /* Picked: the third column is the node panel's, which lies over the stage (node-panel.css), so Around it takes the room between the queue and it */
99
+ .hx-inbox.is-picked { grid-template-columns: minmax(20rem, 28rem) minmax(0, 1fr) 30rem; }
100
+ .hx-inbox-around { align-self: start; display: grid; gap: var(--corn-space-3); max-width: 40rem; margin: 0 auto; padding: var(--corn-space-5) var(--corn-space-5) var(--corn-space-6); width: 100%; box-sizing: border-box; }
101
+ .hx-inbox-around-title { margin: 0; color: var(--corn-text-3); font-size: var(--corn-text-xs); font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; }
102
+ .hx-inbox-around-what { display: flex; align-items: center; gap: var(--corn-space-2); margin: 0; min-width: 0; font-size: var(--corn-text-md); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
103
+ .hx-inbox-around-what .hx-inbox-glyph { flex: none; margin: 0; }
104
+ .hx-inbox-around-map { width: 100%; height: auto; max-height: 10rem; }
105
+ .hx-inbox-around-line { stroke: var(--corn-text-3); stroke-width: 1.5; }
106
+ .hx-inbox-around-line.is-adds, .hx-inbox-around-app.is-adds { stroke-dasharray: 4 3; }
107
+ .hx-inbox-around-app { fill: var(--corn-surface-2); stroke: var(--corn-text-2); stroke-width: 1.5; }
108
+ .hx-inbox-around-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--corn-space-5); }
109
+ .hx-inbox-around-head { display: flex; align-items: baseline; gap: var(--corn-space-1); margin: 0 0 var(--corn-space-2); color: var(--corn-text-2); font-size: var(--corn-text-sm); font-weight: 600; }
110
+ .hx-inbox-around-list { list-style: none; margin: 0; padding: 0; display: grid; gap: calc(var(--corn-space-1) / 2); }
111
+ .hx-inbox-around-item { display: flex; align-items: center; gap: var(--corn-space-2); min-width: 0; font-size: var(--corn-text-sm); }
112
+ .hx-inbox-around-item.is-plain { padding: var(--corn-space-1) var(--corn-space-2); }
113
+ .hx-inbox-around-what .hx-inbox-tag { flex: none; margin: 0; color: var(--corn-text-3); font-weight: 400; }
114
+ .hx-inbox-around-btn { display: flex; align-items: center; gap: var(--corn-space-2); width: 100%; min-width: 0; margin: 0; padding: var(--corn-space-1) var(--corn-space-2); border: 0; border-radius: var(--corn-radius-sm); background: none; color: var(--corn-text); font: inherit; text-align: left; cursor: pointer; }
115
+ .hx-inbox-around-btn:hover { background: var(--corn-surface-2); }
116
+ .hx-inbox-around-btn .hx-inbox-glyph { flex: none; grid-row: auto; margin: 0; width: 12px; height: 12px; }
117
+ .hx-inbox-around-btn .hx-inbox-tag { flex: none; margin: 0; white-space: nowrap; }
118
+ .hx-inbox-around-word { flex: none; color: var(--corn-text-3); font-size: var(--corn-text-xs); }
119
+ .hx-inbox-around-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
120
+ .hx-inbox-around-planned { color: var(--corn-text-3); font-size: var(--corn-text-xs); font-style: italic; }
121
+ .hx-inbox-area { margin-bottom: var(--corn-space-3); padding-left: var(--corn-space-2); border-left: var(--corn-border-strong) solid var(--corn-line); }
122
+ .hx-inbox-area.is-adds { border-left-style: dashed; }
123
+ .hx-inbox-area-name { margin: 0 0 var(--corn-space-1); color: var(--corn-text-2); font-size: var(--corn-text-xs); font-weight: 600; }
124
+ .hx-inbox-around-more, .hx-inbox-around-none { margin: var(--corn-space-1) 0 0; color: var(--corn-text-3); font-size: var(--corn-text-xs); }
125
+ .hx-inbox-around-foot { display: flex; gap: var(--corn-space-2); }
126
+ .hx-inbox-around-graph { height: var(--corn-control-height); padding: 0 var(--corn-space-4); border: var(--corn-border) solid var(--corn-line); border-radius: var(--corn-radius); background: var(--corn-surface-2); color: var(--corn-text); font: inherit; font-size: var(--corn-text-sm); cursor: pointer; }
127
+ .hx-inbox-around-graph:hover { border-color: var(--corn-accent); }
128
+ /* Not room for it beside the node panel: the panel says what it is linked to (Connected) */
129
+ @container corn-box (max-width: 1199px) {
130
+ .hx-inbox.is-picked { grid-template-columns: minmax(20rem, 28rem) 1fr; }
131
+ .hx-inbox-around { display: none; }
132
+ }
133
+ .hx-inbox-pick { align-self: center; justify-self: center; max-width: 24rem; margin: 0; color: var(--corn-text-3); font-size: var(--corn-text-sm); text-align: center; }
134
+ .hx-inbox-pick[hidden] { display: none; }
135
+ @container corn-box (max-width: 767px) {
136
+ /* The Layers chip and the view's controls float on the map's top two rows here (layers.css, header.css): the queue starts under them */
137
+ .hx-inbox { grid-template-columns: 1fr; padding-top: calc(2 * var(--hx-control-h) + 2 * var(--corn-space-4)); }
138
+ .hx-inbox-queue { border-right: 0; border-top: var(--corn-border) solid var(--corn-line); }
139
+ .hx-inbox-pick { display: none; }
140
+ }
@@ -46,6 +46,7 @@ import { workButtonName } from './waiting-model.js';
46
46
  import { stepFrom } from './keyboard-model.js';
47
47
  import { RUNS_POLL_MS } from './pieces/work-common.js';
48
48
  import { showWorkRef, openForge, closeForge } from './forge-panel.js';
49
+ import { mount as mountInbox } from './pieces/inbox.js';
49
50
  import {
50
51
  CODE_LAYER, DRAFT_LAYER, KIND_WORDS, addressOf, applyFilters, areaFor, arrowTarget, drawnEdges, landingWords, applyWorkLayout, codePanelHtml, layerRowsOf, newWorkState, nodeForAddress, openedWords, panelOf, setOpenArea, setWorkGraph, showWork, touchedBy, workAddress, workPanelHtml,
51
52
  } from './work-model.js';
@@ -62,11 +63,20 @@ let offPaint = null;
62
63
  let badges = null; // the Work layer's pills over the map (work-badges.js)
63
64
  let badgeWas = false; // whether the layer wanted the graph at the last look: it asks for it when it comes on
64
65
  let card = null; // the map's own card (pieces/status.js)
66
+ let inbox = null; // the Work inbox over the stage (pieces/inbox.js, spec 0016)
65
67
  let timer = 0;
66
68
  let seq = 0; // the answer that is waited for: an older one is dropped
67
69
  let wasOn = false;
68
70
 
69
71
  const inst = () => pageInstance();
72
+
73
+ /** Inbox or Graph (spec 0016 D1): the Work view opens on the Inbox; the choice is remembered like a layer */
74
+ const AS_KEY = 'cornfield.work.as';
75
+ function rememberedAs() {
76
+ try { return localStorage.getItem(AS_KEY) === 'graph' ? 'graph' : 'inbox'; } catch { return 'inbox'; }
77
+ }
78
+ const asOf = () => { const w = work(); if (w.as !== 'inbox' && w.as !== 'graph') w.as = rememberedAs(); return w.as; };
79
+ const inInbox = () => on() && asOf() === 'inbox';
70
80
  const work = () => state.work || (state.work = newWorkState());
71
81
  const on = () => state.view === 'work';
72
82
 
@@ -148,7 +158,8 @@ function mount() {
148
158
  if (!stage || (els && els.stage === stage && els.bar.isConnected && stage.contains(els.lanes))) return;
149
159
  const bar = controlsSlot(stage);
150
160
  bar.hidden = true;
151
- bar.innerHTML = '<button type="button" class="hx-view-control" data-corn="work-chip" data-corn-kind="secondary" data-work-toggle="waiting" aria-pressed="false" title="Show only what waits on you; the rest is dimmed">Waiting on you</button>'
161
+ bar.innerHTML = '<span class="hx-work-as" role="group" aria-label="Show the work as"><button type="button" class="hx-view-control" data-corn="work-chip" data-corn-kind="secondary" data-work-as="inbox" aria-pressed="true" title="What needs you, in a queue (G switches)">Inbox</button><button type="button" class="hx-view-control" data-corn="work-chip" data-corn-kind="secondary" data-work-as="graph" aria-pressed="false" title="The lanes of work and the code they touch (G switches)">Graph</button></span>'
162
+ + '<button type="button" class="hx-view-control" data-corn="work-chip" data-corn-kind="secondary" data-work-toggle="waiting" aria-pressed="false" title="Show only what waits on you; the rest is dimmed">Waiting on you</button>'
152
163
  + '<button type="button" class="hx-view-control" data-corn="work-chip" data-corn-kind="secondary" data-action="toggle-forge" aria-expanded="false" aria-controls="forge-panel" aria-label="Work list" title="The lists of issues, pull requests, proposals, threads, runs and deploys" hidden>List</button>'
153
164
  + '<span class="hx-work-busy" hidden>Updating…</span>';
154
165
  const note = document.createElement('p');
@@ -169,7 +180,18 @@ function mount() {
169
180
  loading.innerHTML = `<div class="hx-work-skeleton" aria-hidden="true">${['Talk', 'Decide', 'Build', 'Ship', 'Code it touches'].map((name) => `<div class="hx-work-skel-lane"><span class="hx-work-lane-title">${name}</span><i></i><i></i><i></i><i></i></div>`).join('')}</div>`
170
181
  + '<p class="hx-work-loading-text" role="status">Reading the work from the forge. A big repository can take several seconds the first time; the page works meanwhile.</p>';
171
182
  stage.append(lanes, loading, note);
172
- els = { stage, bar, waiting: bar.children[0], list: bar.children[1], busy: bar.children[2], note, lanes, loading };
183
+ els = { stage, bar, as: bar.children[0], waiting: bar.children[1], list: bar.children[2], busy: bar.children[3], note, lanes, loading };
184
+ if (inbox) inbox.destroy();
185
+ inbox = mountInbox(stage, {
186
+ pick: (id) => pick(id, { frame: false, source: 'link' }),
187
+ act: (id, key) => actOn(id, key),
188
+ announce: (words) => announce(inst(), words),
189
+ colorOf: (kind) => badgeColor(kind),
190
+ say: (key) => t(inst(), key),
191
+ showOnMap: (id) => showOnMap(id),
192
+ toGraph: () => setAs('graph'),
193
+ refresh: () => paintInbox(),
194
+ });
173
195
  paintList(!!inst().ask('work:on')); // the List toggle is there while the Work piece is on: a signed-in maintainer of a forge
174
196
  if (offPaint) offPaint();
175
197
  if (badges) badges.destroy();
@@ -205,7 +227,7 @@ function watchSize(stage) {
205
227
  function paintLanes(scene, camera) {
206
228
  if (!els) return;
207
229
  const w = work();
208
- const show = on() && w.status === 'ok' && w.lanes.length > 0;
230
+ const show = on() && !inInbox() && w.status === 'ok' && w.lanes.length > 0;
209
231
  els.lanes.hidden = !show;
210
232
  if (!show) return;
211
233
  if (laneKey !== w.lanes) {
@@ -258,11 +280,89 @@ function paintBar() {
258
280
  const w = work();
259
281
  els.bar.hidden = !on();
260
282
  els.waiting.setAttribute('aria-pressed', String(!!w.waiting)); // the Work button's badge says how many; the toggle says only that it is on
283
+ els.waiting.hidden = inInbox(); // the Inbox is what waits on you, in a queue: dimming is the Graph's
284
+ for (const b of els.as.querySelectorAll('[data-work-as]')) {
285
+ b.setAttribute('aria-pressed', String(b.dataset.workAs === asOf()));
286
+ b.textContent = b.dataset.workAs === 'inbox' ? t(inst(), 'inbox') : t(inst(), 'graph'); // the page's words (core/strings.js)
287
+ }
288
+ if (els.stage) els.stage.classList.toggle('is-inbox', inInbox());
261
289
  els.busy.hidden = !(on() && w.status === 'ok' && w.updating);
262
290
  els.loading.hidden = !(on() && w.status === 'loading');
263
291
  const lines = [...(w.stale ? [w.stale] : []), ...(w.lastError ? [w.lastError] : []), ...w.problems.map((p) => p.text)];
264
292
  els.note.hidden = !on() || !lines.length;
265
293
  els.note.textContent = lines.length ? lines.slice(0, 2).join(' ') + (lines.length > 2 ? ` and ${lines.length - 2} more.` : '') : '';
294
+ paintInbox();
295
+ }
296
+
297
+ /** The Inbox drawn from the last answer, the selection marked (spec 0016); hidden in the Graph and off the Work view */
298
+ function paintInbox() {
299
+ if (!inbox) return;
300
+ const w = work();
301
+ inbox.paint(w.graph, { on: inInbox() && w.status === 'ok', selected: state.selectedNode ? state.selectedNode.id : null, scene: { nodes: w.nodes, edges: w.edges } });
302
+ }
303
+
304
+ /** Inbox or Graph (spec 0016 D1), remembered; the Graph is fitted again as it comes back */
305
+ function setAs(as) {
306
+ const w = work();
307
+ if (asOf() === as) return;
308
+ w.as = as;
309
+ try { localStorage.setItem(AS_KEY, as); } catch { /* remembering is a convenience */ }
310
+ paintBar();
311
+ if (on() && w.status === 'ok' && as === 'graph') { applyWorkLayout(state, { phone: isPhone() }); inst().touchScene(); fitGraphToViewport(fitPadding()); render(); }
312
+ if (as === 'inbox' && inbox) inbox.focus();
313
+ announce(inst(), as === 'inbox' ? 'Inbox.' : 'Graph: the lanes of work.');
314
+ }
315
+
316
+ /** Where each of a row's actions is in the node panel (inbox-model.js ACTIONS): the control the row names, never just the first one there */
317
+ const ACTION_AT = Object.freeze({
318
+ review: '[data-work-action="review"]',
319
+ 'review-change': '[data-work-action="review"]',
320
+ land: '[data-forge-merge]',
321
+ rerun: '[data-forge-rerun]',
322
+ retry: '[data-forge-retry]',
323
+ agent: '[data-forge-agent]',
324
+ answer: 'textarea',
325
+ reply: 'textarea, a[href*="/issues/"], a[href*="/pull/"]',
326
+ logs: 'a[href*="/actions/"], a[href*="log"]',
327
+ });
328
+
329
+ /** …and the words such a control starts with, for one that carries no marker (a Land it that is off) */
330
+ const ACTION_WORDS = Object.freeze({ review: 'review', 'review-change': 'review', land: 'land it', rerun: 're-run', retry: 'start again', agent: 'start an agent' });
331
+
332
+ /**
333
+ * A row's action (spec 0016 D5, D6): its piece of work is selected and the node panel's own control for that action is pressed, with the confirm step it has there.
334
+ * A run that is done lands its pull request, so that is what is selected. A field (an answer) or a link (a reply, logs) takes the focus and is not followed; a control
335
+ * that is off says why (its title) and is not pressed; one that is not there leaves the focus on the panel's actions.
336
+ */
337
+ function actOn(id, key) {
338
+ let target = id;
339
+ if (key === 'land' && id.startsWith('run:')) {
340
+ const run = work().nodes.find((n) => n.id === id);
341
+ const pull = run && run.item && run.item.pull;
342
+ if (pull && Number.isInteger(pull.number)) target = `pull:${pull.number}`;
343
+ }
344
+ if (!pick(target, { frame: false, source: 'link' })) return;
345
+ const t0 = Date.now();
346
+ const press = () => {
347
+ const panel = document.querySelector('[data-corn="node-panel"]');
348
+ const bar = panel ? panel.querySelector('[data-corn="actions"]') : null;
349
+ const at = ACTION_AT[key];
350
+ const word = ACTION_WORDS[key];
351
+ const found = panel && at ? [...panel.querySelectorAll(at)] : [];
352
+ if (panel && word) for (const el of panel.querySelectorAll('[data-corn="actions"] button, [data-corn="section"] button')) if (!found.includes(el) && el.textContent.trim().replace(/\s*…$/, '').toLowerCase().startsWith(word)) found.push(el); // a control that is off may carry no marker: its words say which
353
+ const live = found.find((el) => !el.disabled);
354
+ if (live) {
355
+ if (live.tagName === 'BUTTON') live.click();
356
+ else live.focus(); // a field to write in, or a link: the viewer goes on from there
357
+ return;
358
+ }
359
+ if (found.length) { found[0].focus(); announce(inst(), found[0].title || 'It cannot be done yet: the panel says why.'); return; }
360
+ if (Date.now() - t0 < 2000) { setTimeout(press, 60); return; } // the Work piece draws a piece of work's actions once what it needs is read
361
+ const first = bar && bar.querySelector('button:not([disabled]), a[href]');
362
+ if (first) first.focus();
363
+ announce(inst(), 'Its actions are in the panel.');
364
+ };
365
+ setTimeout(press, 0);
266
366
  }
267
367
 
268
368
  /** The view opened or closed: the button, the bar, the stage; the map's own layers are back when it closed (work-model.js `leaveWork`) */
@@ -569,6 +669,7 @@ let opened = null;
569
669
  */
570
670
  function onSelection({ node: picked }) {
571
671
  if (!on() || work().status !== 'ok') return;
672
+ paintInbox();
572
673
  if (!picked) { openArea(null); return; }
573
674
  const node = work().nodes.find((n) => n.id === picked.id); // the view's own node (a tap names the scene's)
574
675
  if (!node) return;
@@ -638,6 +739,11 @@ function pickRef(ref) {
638
739
  // Keys (the map's own are for the other views: Shift and an arrow still pan, the rest are the map's)
639
740
  // ---------------------------------------------------------------------------
640
741
  function onKey(e) {
742
+ if (on() && !e.defaultPrevented && !e.ctrlKey && !e.metaKey && !e.altKey && (e.key === 'g' || e.key === 'G') && !(e.target && e.target.closest && e.target.closest('input, textarea, select, [contenteditable="true"]'))) {
743
+ e.preventDefault();
744
+ setAs(asOf() === 'inbox' ? 'graph' : 'inbox');
745
+ return;
746
+ }
641
747
  if (!on() || e.defaultPrevented || e.ctrlKey || e.metaKey || e.altKey || !state.canvas || e.target !== state.canvas) return;
642
748
  const shown = shownInOrder();
643
749
  if (!shown.length) return;
@@ -663,6 +769,8 @@ function onClick(e) {
663
769
  if (t_.closest('[data-action="preset-work"]')) { if (on()) closeWork(); else openWork(); return; }
664
770
  if (t_.closest('[data-action="refresh-forge"]') && on()) { load({ again: true }); return; }
665
771
  if (t_.closest('[data-work-toggle="waiting"]') && on()) { setWaiting(!work().waiting); return; }
772
+ const as = t_.closest('[data-work-as]');
773
+ if (as && on()) { setAs(as.dataset.workAs); return; }
666
774
  const act = t_.closest('[data-work-action]');
667
775
  if (!act) return;
668
776
  if (act.dataset.workAction === 'open-item') { // a node panel's "Open work" link: the Work view opens on that piece of work (a new tab, by the link's own address, is left alone)
@@ -702,6 +810,7 @@ export async function followWorkAddress(search = location.search) {
702
810
  if (!ask) return false;
703
811
  if (!offered) { announce(inst(), 'The map of work needs a forge in the config.'); return false; }
704
812
  spend();
813
+ try { const as = new URLSearchParams(search).get('as'); if (as === 'graph' || as === 'inbox') work().as = as; } catch { /* the address is a convenience */ }
705
814
  return openWork({ ask: ask.kind ? ask : null });
706
815
  }
707
816
 
@@ -733,6 +842,8 @@ export function resetWorkViewForTests() {
733
842
  offered = false;
734
843
  els = null;
735
844
  card = null;
845
+ if (inbox) inbox.destroy();
846
+ inbox = null;
736
847
  seq++;
737
848
  wasOn = false;
738
849
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cornfield",
3
- "version": "0.63.0",
3
+ "version": "0.65.0",
4
4
  "description": "A self-hostable dev dashboard with the topology map at its centre: proposals on the map, scenarios, outages and what-if edits, for any repo.",
5
5
  "license": "MIT",
6
6
  "author": "popcorn245 (https://github.com/popcorn245)",
@@ -15,7 +15,8 @@
15
15
  * deploy deploy:<id> ship a workflow run the config says is a deploy (server/deploys.js)
16
16
  *
17
17
  * Every node: `{ id, kind, stage, title, state, open, waiting, url, updated, ...}` and its number (`number`), slug (`slug`), run id (`runId`) or
18
- * deploy id (`deployId`). `waiting` is spec 0010 D1's rule, worked out by the same functions the page's number uses (explorer/waiting-model.js
18
+ * deploy id (`deployId`). A run also carries `note` (its report's last word, the question when it waits), `brief` and `pull` (`{ number, state }` of the pull
19
+ * request it opened); an open pull request `checks` (`checkCounts`: failed, running, passed, green and the names), or null when they could not be read (spec 0016 D9). `waiting` is spec 0010 D1's rule, worked out by the same functions the page's number uses (explorer/waiting-model.js
19
20
  * `specStateOf`, explorer/runs-model.js `canAnswer`): a spec to decide, a run waiting on an answer; nothing else asks the maintainer a question.
20
21
  * The code a proposal adds, and the map does not hold yet, comes as `{ id, kind: 'code', planned: true, label, type, parent }`; the code that exists is
21
22
  * on the map the page already has, and is only named by edges.
@@ -51,7 +52,7 @@
51
52
  */
52
53
 
53
54
  import fs from 'node:fs';
54
- import { DEFAULT_LIMIT, ForgeError } from './forge.js';
55
+ import { DEFAULT_LIMIT, ForgeError, isGreen, RERUN_STATES } from './forge.js';
55
56
  import { filesAt, forgeWords, pullProposals, readPullProposal, reviewStates } from './proposal-pulls.js';
56
57
  import { listProposalFiles } from './files.js';
57
58
  import { deploysOf } from './deploys.js';
@@ -152,6 +153,48 @@ async function each(items, fn) {
152
153
  return out;
153
154
  }
154
155
 
156
+ /** The longest a run's note or brief is carried, in characters */
157
+ export const NOTE_CUT = 300;
158
+ const clip = (s, n) => (s.length > n ? `${s.slice(0, n - 1)}…` : s);
159
+ /** The states a check is still on its way in */
160
+ const GOING = new Set(['queued', 'running', 'pending', 'in_progress', 'waiting']);
161
+
162
+ /**
163
+ * A commit's checks as counts (spec 0016 D9): failed (failed or cancelled), running (queued or running), passed, and `green` as landing reads it
164
+ * (server/forge.js `isGreen`). The inbox says "lint failed · test running" from the names of the failed and running ones (`failedNames`, `runningNames`, at most five each).
165
+ * @param {{ name: string, state: string }[]} checks
166
+ */
167
+ export function checkCounts(checks) {
168
+ const list = Array.isArray(checks) ? checks : [];
169
+ const failed = list.filter((c) => RERUN_STATES.includes(c.state));
170
+ const going = list.filter((c) => GOING.has(c.state));
171
+ return {
172
+ failed: failed.length, running: going.length, passed: list.filter((c) => c.state === 'success').length, green: isGreen(list),
173
+ failedNames: failed.slice(0, 5).map((c) => text(c.name)), runningNames: going.slice(0, 5).map((c) => text(c.name)),
174
+ };
175
+ }
176
+
177
+ /** How long a head's checks are kept: while one runs, a minute (the page asks every minute); once all are over, ten (a re-run starts them again) */
178
+ export const CHECKS_KEEP_RUNNING_MS = 60_000;
179
+ export const CHECKS_KEEP_DONE_MS = 10 * 60_000;
180
+ const CHECKS_KEPT_MAX = 500;
181
+ /** where -> sha -> { at, keep, counts } */
182
+ const checkCaches = new WeakMap();
183
+
184
+ /** The checks at a head sha as counts, kept per `where` (CHECKS_KEEP_*); a failed read is never kept */
185
+ async function checksAt(forge, where, sha, nowMs) {
186
+ const key = where && typeof where === 'object' ? where : checkCaches;
187
+ let kept = checkCaches.get(key);
188
+ if (!kept) checkCaches.set(key, (kept = new Map()));
189
+ const got = kept.get(sha);
190
+ if (got && nowMs - got.at < got.keep) return got.counts;
191
+ const counts = checkCounts(await forge.checks(sha));
192
+ kept.delete(sha);
193
+ kept.set(sha, { at: nowMs, keep: counts.running ? CHECKS_KEEP_RUNNING_MS : CHECKS_KEEP_DONE_MS, counts });
194
+ while (kept.size > CHECKS_KEPT_MAX) kept.delete(kept.keys().next().value);
195
+ return counts;
196
+ }
197
+
155
198
  /** An id of the work graph's own: a map node with one would be two things */
156
199
  const WORK_ID = /^(?:thread|issue|proposal|run|pull|deploy):/;
157
200
  /** A link the page may open: http(s) only; anything else (a runner's report saying `javascript:`) is no link */
@@ -338,10 +381,21 @@ export async function workGraph(forge, config, map, { where = config, runs = nul
338
381
  }
339
382
  }
340
383
 
384
+ // The checks on each open pull request's head, as counts (spec 0016 D9): asked each time, since a head's checks move while it stays
385
+ const checkable = pulls.filter((p) => !specEntries.has(p.number) && p.state === 'open' && p.head && p.head.sha);
386
+ const gotChecks = await each(checkable, (pull) => attempt(() => checksAt(forge, where, pull.head.sha, nowMs)));
387
+ const checksOf = new Map();
388
+ const noChecks = [];
389
+ for (const [i, pull] of checkable.entries()) {
390
+ if (gotChecks[i].err) noChecks.push(pull.number);
391
+ else checksOf.set(pull.number, gotChecks[i].value);
392
+ }
393
+ if (noChecks.length) say('pulls', `The checks of ${noChecks.length === 1 ? 'pull request' : 'pull requests'} ${numbers(noChecks)} could not be read, so they are not said.`);
394
+
341
395
  for (const pull of pulls) {
342
396
  if (specEntries.has(pull.number)) continue;
343
397
  const id = `pull:${pull.number}`;
344
- put({ id, kind: 'pull', title: pull.title, state: pull.state, open: pull.state === 'open', number: pull.number, url: webUrl(pull.url), updated: pull.updatedAt, draft: pull.draft, author: pull.author ? pull.author.login : null });
398
+ put({ id, kind: 'pull', title: pull.title, state: pull.state, open: pull.state === 'open', number: pull.number, url: webUrl(pull.url), updated: pull.updatedAt, draft: pull.draft, author: pull.author ? pull.author.login : null, checks: checksOf.get(pull.number) ?? null });
345
399
  byPull.set(pull.number, [id]);
346
400
  if (filesOf.has(pull.number)) for (const to of nodesOfFiles(filesOf.get(pull.number), mapNodes)) edge(id, to, 'changes');
347
401
  }
@@ -459,6 +513,9 @@ export async function workGraph(forge, config, map, { where = config, runs = nul
459
513
  put({
460
514
  id, kind: 'run', title: runName(run), state: run.status, open: run.open === true, waiting: canAnswer(run), runId: run.runId, number: null, url: webUrl(run.report && run.report.url) || webUrl(run.comment && run.comment.url) || webUrl(run.pull && run.pull.url),
461
515
  updated: ended, requestedBy: run.requestedBy ?? null,
516
+ // what the inbox says of it (spec 0016 D9): its question or last word, what it was asked to do, and the pull request it opened
517
+ note: clip(text(run.report && run.report.note), NOTE_CUT) || null, brief: clip(text(run.brief), NOTE_CUT) || null,
518
+ pull: run.pull && Number.isInteger(run.pull.number) ? { number: run.pull.number, state: text(run.pull.state) || null } : null,
462
519
  });
463
520
  const about = [run.refs && run.refs.issue, run.refs && run.refs.thread].filter((n) => n != null).map(talkNode).filter(Boolean);
464
521
  for (const from of new Set(about)) edge(from, id, 'agent-on');