@popcorn245/cornfield 0.64.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',
@@ -6,13 +6,14 @@
6
6
  * a waiting run folded into the spec it asks about. The page draws it (explorer/pieces/inbox.js).
7
7
  *
8
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)
9
10
  *
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);
11
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).
12
13
  * Nothing here files, archives or hides a row by hand (D7): a row moves only when the graph says its state moved.
13
14
  */
14
15
 
15
- import { tagOf } from './work-model.js';
16
+ import { tagOf, REL_WORDS } from './work-model.js';
16
17
 
17
18
  /** The groups, in the queue's order (D2), with their words, and whether each starts open */
18
19
  export const GROUPS = Object.freeze([
@@ -85,7 +86,7 @@ export function placeOf(item, { edges, byId }) {
85
86
  case 'run': {
86
87
  if (item.waiting) return { group: 'waiting', why: text(item.note) || 'Waiting on your answer', action: act('answer') };
87
88
  if (item.state === 'failed') return { group: 'move', why: `Failed${item.note ? `: ${item.note}` : ''}`, bad: true, action: act('retry') };
88
- 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: act('land', `Land PR #${item.pull.number}`) };
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
89
90
  if (item.open) return { group: 'motion', why: `${cap(item.state)}${item.note ? `: ${item.note}` : ''}`, action: null };
90
91
  return { group: 'done', why: text(item.note) || cap(item.state), action: null };
91
92
  }
@@ -178,3 +179,51 @@ export function nextAfter(order, id) {
178
179
  export function rowWords(row, ago) {
179
180
  return `${row.tag}, ${text(row.item.title)}. ${row.why}${row.also ? `, and ${row.also.tag} waits on your answer` : ''}. ${ago}.`;
180
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
+ }
@@ -4,15 +4,18 @@
4
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
5
  * inbox-model.js (pure); work-view.js owns the read of the graph and the Inbox · Graph toggle, and mounts this once.
6
6
  *
7
- * mount(stage, { pick, act, announce, refresh, colorOf, now }) -> { paint(graph, { on, selected }), focus(), destroy() }
7
+ * mount(stage, { pick, act, announce, refresh, colorOf, say, showOnMap, toGraph, now }) -> { paint(graph, { on, selected, scene }), focus(), destroy() }
8
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)` selects it and does its primary action, the
10
- * node panel's own button, 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,
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
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).
12
14
  */
13
15
 
14
- import { GROUPS, inboxOf, headingOf, openedWords, orderOf, rowWords } from '../inbox-model.js';
16
+ import { GROUPS, ACTIONS, inboxOf, aroundOf, headingOf, openedWords, orderOf, rowWords } from '../inbox-model.js';
15
17
  import { relativeTime } from '../review-model.js';
18
+ import { tagOf } from '../work-model.js';
16
19
 
17
20
  const SHAPE = { thread: 'circle', issue: 'circle', proposal: 'diamond', run: 'hexagon', pull: 'rounded', deploy: 'square' };
18
21
 
@@ -39,31 +42,42 @@ function glyph(kind, color) {
39
42
  /** A number as data, and a kind's tag: the page's own `count` and `tag` hooks (docs/theming.md) */
40
43
  const counted = (n) => { const el = make('span', 'hx-inbox-count', String(n)); el.dataset.corn = 'count'; el.setAttribute('part', 'count'); return el; };
41
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);
42
47
  const make = (tag, cls, words) => { const el = document.createElement(tag); if (cls) el.className = cls; if (words != null) el.textContent = words; return el; };
43
48
 
44
49
  /**
45
50
  * @param {HTMLElement} stage the Work view's stage (the map's box)
46
- * @param {{ pick: (id: string) => boolean, act: (id: string) => void, announce: (words: string) => void, now?: () => number, refresh: () => void, colorOf?: (kind: string) => string }} hooks
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
47
53
  */
48
54
  export function mount(stage, hooks) {
49
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);
50
62
  const color = (kind) => (hooks.colorOf ? hooks.colorOf(kind) : '');
51
63
  const root = make('section', 'hx-inbox');
52
64
  root.dataset.corn = 'inbox';
53
65
  root.setAttribute('part', 'inbox');
54
- root.setAttribute('aria-label', 'Inbox');
66
+ root.setAttribute('aria-label', t('inbox'));
55
67
  root.hidden = true;
56
68
  const queue = make('div', 'hx-inbox-queue');
57
69
  const head = make('div', 'hx-inbox-head');
58
- const title = make('h2', 'hx-inbox-title', 'Inbox');
70
+ const title = make('h2', 'hx-inbox-title', t('inbox'));
59
71
  const sub = make('span', 'hx-inbox-sub');
60
72
  head.append(title, sub);
61
73
  const list = make('div', 'hx-inbox-groups');
62
74
  queue.append(head, list);
63
- const aside = make('p', 'hx-inbox-pick', 'Pick a row: what it needs opens beside the queue.');
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.');
64
77
  aside.dataset.corn = 'hint';
65
78
  aside.setAttribute('part', 'hint');
66
- root.append(queue, aside);
79
+ side.append(aside);
80
+ root.append(queue, side);
67
81
  stage.append(root);
68
82
 
69
83
  /** which groups are open: the ones GROUPS starts open, then as the viewer folds them (kept while the page is open) */
@@ -72,11 +86,13 @@ export function mount(stage, hooks) {
72
86
  let selected = null;
73
87
  let was = false;
74
88
 
75
- function paint(graph, { on, selected: sel = null } = {}) {
89
+ function paint(graph, { on, selected: sel = null, scene = null } = {}) {
76
90
  root.hidden = !on;
77
91
  if (!on) { was = false; return; }
78
92
  inbox = inboxOf(graph);
79
93
  selected = sel;
94
+ root.setAttribute('aria-label', t('inbox'));
95
+ title.textContent = t('inbox');
80
96
  sub.textContent = headingOf(inbox);
81
97
  list.textContent = '';
82
98
  if (!inbox.count) {
@@ -98,12 +114,12 @@ export function mount(stage, hooks) {
98
114
  btn.type = 'button';
99
115
  btn.dataset.inboxGroup = g.key;
100
116
  btn.setAttribute('aria-expanded', String(isOpen));
101
- btn.append(make('span', 'hx-inbox-group-title', g.title), counted(rows.length));
117
+ btn.append(make('span', 'hx-inbox-group-title', titleOf(g.key)), counted(rows.length));
102
118
  if (g.hint) btn.append(make('span', 'hx-inbox-hint', g.hint));
103
119
  group.append(btn);
104
120
  if (isOpen) {
105
121
  const ul = make('ul', 'hx-inbox-rows');
106
- ul.setAttribute('aria-label', g.title);
122
+ ul.setAttribute('aria-label', titleOf(g.key));
107
123
  for (const r of rows) ul.append(rowEl(r, g.key));
108
124
  group.append(ul);
109
125
  }
@@ -111,10 +127,12 @@ export function mount(stage, hooks) {
111
127
  }
112
128
  if (inbox.drafts) {
113
129
  const d = make('p', 'hx-inbox-drafts');
114
- d.append(make('span', 'hx-inbox-group-title', 'Drafts in the checkout'), counted(inbox.drafts), make('span', 'hx-inbox-hint', 'nobody has been asked to decide them'));
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'));
115
131
  list.append(d);
116
132
  }
117
- aside.hidden = !!selected;
133
+ const around = selected ? aroundOf(selected, scene) : null;
134
+ root.classList.toggle('is-picked', !!around);
135
+ paintAround(around);
118
136
  if (!was) { hooks.announce(openedWords(inbox)); was = true; }
119
137
  }
120
138
 
@@ -135,7 +153,7 @@ export function mount(stage, hooks) {
135
153
  const why = make('span', `hx-inbox-why${r.bad ? ' is-bad' : ''}`, r.why);
136
154
  li.append(glyph(r.item.kind, color(r.item.kind)), top, make('span', 'hx-inbox-age', ago), why);
137
155
  if (r.action) {
138
- const go = make('button', `hx-inbox-act${group === 'waiting' ? ' is-primary' : ''}`, r.action.label);
156
+ const go = make('button', `hx-inbox-act${group === 'waiting' ? ' is-primary' : ''}`, actionWords(r.action));
139
157
  go.type = 'button';
140
158
  go.tabIndex = -1;
141
159
  go.dataset.inboxAct = r.id;
@@ -149,6 +167,126 @@ export function mount(stage, hooks) {
149
167
  return li;
150
168
  }
151
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
+
152
290
  const order = () => orderOf(inbox, open);
153
291
  const rowOf = (id) => list.querySelector(`.hx-inbox-row[data-id="${CSS.escape(id)}"]`);
154
292
 
@@ -160,27 +298,32 @@ export function mount(stage, hooks) {
160
298
  }
161
299
 
162
300
  function onClick(e) {
163
- const t = e.target && e.target.closest ? e.target : null;
164
- if (!t || !root.contains(t)) return;
165
- const fold = t.closest('[data-inbox-group]');
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]');
166
309
  if (fold) { const k = fold.dataset.inboxGroup; if (open.has(k)) open.delete(k); else open.add(k); hooks.refresh(); return; }
167
- const go = t.closest('[data-inbox-act]');
168
- if (go) { e.stopPropagation(); hooks.act(go.dataset.inboxAct); return; }
169
- const row = t.closest('.hx-inbox-row');
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');
170
313
  if (row) choose(row.dataset.id, { focus: false });
171
314
  }
172
315
 
173
316
  function onKey(e) {
174
317
  if (root.hidden || e.ctrlKey || e.metaKey || e.altKey) return;
175
- const t = e.target;
176
- if (!t || !root.contains(t) || (t.closest && t.closest('input, textarea, select'))) return;
318
+ const el = e.target;
319
+ if (!el || !root.contains(el) || !queue.contains(el) || (el.closest && el.closest('input, textarea, select'))) return;
177
320
  const ids = order();
178
- const cur = t.closest('.hx-inbox-row') ? t.closest('.hx-inbox-row').dataset.id : selected;
321
+ const cur = el.closest('.hx-inbox-row') ? el.closest('.hx-inbox-row').dataset.id : selected;
179
322
  const i = ids.indexOf(cur);
180
323
  let to = null;
181
324
  if (e.key === 'j' || e.key === 'J' || e.key === 'ArrowDown') to = ids[Math.min(ids.length - 1, i + 1)] ?? ids[0];
182
325
  else if (e.key === 'k' || e.key === 'K' || e.key === 'ArrowUp') to = ids[Math.max(0, i - 1)] ?? ids[0];
183
- else if (e.key === 'Enter' && cur && t.closest('.hx-inbox-row')) { e.preventDefault(); hooks.act(cur); return; }
326
+ else if (e.key === 'Enter' && cur && el.closest('.hx-inbox-row')) { e.preventDefault(); act(cur); return; }
184
327
  else return;
185
328
  e.preventDefault();
186
329
  if (to) choose(to);
@@ -59,7 +59,7 @@ body:has(.hx-stage.is-work) .hx-layers :is([data-corn="legend-key"], [data-corn=
59
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
60
  .hx-inbox[hidden] { display: none; }
61
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-8); border-right: var(--corn-border) solid var(--corn-line); background: var(--corn-surface-1); }
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
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
64
  .hx-inbox-title { margin: 0; font-size: var(--corn-text-md); font-weight: 600; }
65
65
  .hx-inbox-sub { color: var(--corn-text-3); font-size: var(--corn-text-sm); }
@@ -94,6 +94,42 @@ body:has(.hx-stage.is-work) .hx-layers :is([data-corn="legend-key"], [data-corn=
94
94
  @media (hover: none) { .hx-inbox-act { opacity: 1; } }
95
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
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
+ }
97
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; }
98
134
  .hx-inbox-pick[hidden] { display: none; }
99
135
  @container corn-box (max-width: 767px) {
@@ -184,9 +184,12 @@ function mount() {
184
184
  if (inbox) inbox.destroy();
185
185
  inbox = mountInbox(stage, {
186
186
  pick: (id) => pick(id, { frame: false, source: 'link' }),
187
- act: (id) => actOn(id),
187
+ act: (id, key) => actOn(id, key),
188
188
  announce: (words) => announce(inst(), words),
189
189
  colorOf: (kind) => badgeColor(kind),
190
+ say: (key) => t(inst(), key),
191
+ showOnMap: (id) => showOnMap(id),
192
+ toGraph: () => setAs('graph'),
190
193
  refresh: () => paintInbox(),
191
194
  });
192
195
  paintList(!!inst().ask('work:on')); // the List toggle is there while the Work piece is on: a signed-in maintainer of a forge
@@ -278,7 +281,10 @@ function paintBar() {
278
281
  els.bar.hidden = !on();
279
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
280
283
  els.waiting.hidden = inInbox(); // the Inbox is what waits on you, in a queue: dimming is the Graph's
281
- for (const b of els.as.querySelectorAll('[data-work-as]')) b.setAttribute('aria-pressed', String(b.dataset.workAs === asOf()));
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
+ }
282
288
  if (els.stage) els.stage.classList.toggle('is-inbox', inInbox());
283
289
  els.busy.hidden = !(on() && w.status === 'ok' && w.updating);
284
290
  els.loading.hidden = !(on() && w.status === 'loading');
@@ -292,7 +298,7 @@ function paintBar() {
292
298
  function paintInbox() {
293
299
  if (!inbox) return;
294
300
  const w = work();
295
- inbox.paint(w.graph, { on: inInbox() && w.status === 'ok', selected: state.selectedNode ? state.selectedNode.id : null });
301
+ inbox.paint(w.graph, { on: inInbox() && w.status === 'ok', selected: state.selectedNode ? state.selectedNode.id : null, scene: { nodes: w.nodes, edges: w.edges } });
296
302
  }
297
303
 
298
304
  /** Inbox or Graph (spec 0016 D1), remembered; the Graph is fitted again as it comes back */
@@ -307,16 +313,54 @@ function setAs(as) {
307
313
  announce(inst(), as === 'inbox' ? 'Inbox.' : 'Graph: the lanes of work.');
308
314
  }
309
315
 
310
- /** A row's action (spec 0016 D5, D6): its piece of work is selected and the node panel's own primary action is pressed, with the confirm step it has there */
311
- function actOn(id) {
312
- if (!pick(id, { frame: false, source: 'link' })) return;
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;
313
345
  const t0 = Date.now();
314
346
  const press = () => {
315
- const bar = document.querySelector('[data-corn="node-panel"] [data-corn="actions"]');
316
- const btn = bar ? bar.querySelector('button:not([disabled]), a[href]') : null;
317
- if (btn) { btn.click(); return; }
318
- if (Date.now() - t0 < 2000) setTimeout(press, 60); // the Work piece draws a piece of work's actions once what it needs is read
319
- else announce(inst(), 'Its actions are in the panel.');
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.');
320
364
  };
321
365
  setTimeout(press, 0);
322
366
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@popcorn245/cornfield",
3
- "version": "0.64.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)",