cornfield 0.61.0 → 0.63.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/release-notes.js +2 -2
- package/explorer/css/changes.css +3 -7
- package/explorer/css/header.css +15 -0
- package/explorer/css/layers.css +11 -2
- package/explorer/css/map.css +27 -0
- package/explorer/css/node-panel.css +45 -0
- package/explorer/css/page.css +2 -7
- package/explorer/css/proposal.css +2 -3
- package/explorer/css/work.css +7 -7
- package/explorer/engine/hint.js +7 -7
- package/explorer/engine/keyboard.js +5 -4
- package/explorer/engine/map-rect.js +2 -2
- package/explorer/engine/render.js +2 -1
- package/explorer/forge-panel-model.js +24 -0
- package/explorer/history-model.js +93 -12
- package/explorer/history-replay.js +318 -0
- package/explorer/history.js +40 -9
- package/explorer/index.html +7 -1
- package/explorer/instance-state.js +1 -0
- package/explorer/page.js +3 -0
- package/explorer/panel-model.js +103 -0
- package/explorer/panel-sections.js +140 -0
- package/explorer/pieces/layers.js +27 -6
- package/explorer/pieces/node-panel.js +80 -1
- package/explorer/pieces/search.js +22 -9
- package/explorer/pieces/work-deploys.js +13 -13
- package/explorer/pieces/work-issues.js +10 -5
- package/explorer/pieces/work-list.js +72 -9
- package/explorer/pieces/work-paint.js +45 -10
- package/explorer/pieces/work-prs.js +46 -34
- package/explorer/pieces/work-runs.js +17 -5
- package/explorer/pieces/work-specs.js +24 -4
- package/explorer/pieces/work-threads.js +59 -15
- package/explorer/pieces/work.js +6 -3
- package/explorer/proposal-model.js +3 -6
- package/explorer/runs-view.js +42 -8
- package/explorer/scene.js +35 -1
- package/explorer/work-model.js +266 -55
- package/explorer/work-view.css +9 -16
- package/explorer/work-view.js +107 -34
- package/package.json +1 -1
- package/server/server.js +1 -1
- package/server/work-graph.js +5 -5
package/explorer/work-model.js
CHANGED
|
@@ -5,8 +5,10 @@
|
|
|
5
5
|
* (server/work-graph.js: `{ ok, nodes, edges, problems }`) to nodes the scene draws, where they sit, what a layer hides, what the node panel
|
|
6
6
|
* says of one, what search finds and what an address asks for. No DOM, no state, no fetch: work-view.js (the page's half) holds those.
|
|
7
7
|
*
|
|
8
|
-
* - `workScene(graph, mapNodes)`
|
|
9
|
-
* ones a proposal adds),
|
|
8
|
+
* - `workScene(graph, mapNodes, mapEdges)` the nodes and edges of the Work view: the work, the code it touches (copies of the map's nodes, and the planned
|
|
9
|
+
* ones a proposal adds) grouped by area (spec 0015 D1), the lines between them with their words, and a spec pull request's
|
|
10
|
+
* threads folded into its proposal (spec 0015 D2)
|
|
11
|
+
* - `drawnEdges(nodes, edges, open)` the lines the scene walks: a line to code in a closed area ends at the area
|
|
10
12
|
* - `layoutWork(nodes, edges, { phone })` where each node sits, and the lanes behind them; writes `x`, `y` and `r` on the nodes it is given
|
|
11
13
|
* - `applyFilters(nodes, edges, { layers, waiting })` sets `hidden` (a layer is off) and `dim` ("Waiting on you" is on) on the nodes
|
|
12
14
|
* - `layerRowsOf(nodes)` the Layers menu's rows in the Work view, each with its count in words
|
|
@@ -15,6 +17,7 @@
|
|
|
15
17
|
*/
|
|
16
18
|
|
|
17
19
|
import { NODE_THEMES } from '../core/schema.js';
|
|
20
|
+
import { groupLinks, relTitle, sectionHtml } from './panel-model.js';
|
|
18
21
|
import { WORK_KINDS, WORK_THEMES, WORK_EDGE_THEMES, workType } from '../core/schema.js';
|
|
19
22
|
import { relativeTime } from './review-model.js';
|
|
20
23
|
import { SPEC_STATE_WORDS, specStateOf } from './waiting-model.js';
|
|
@@ -22,6 +25,7 @@ import { runName, canAnswer } from './runs-model.js';
|
|
|
22
25
|
import { cornState } from './corn-state.js';
|
|
23
26
|
import { escapeHtml as esc } from '../core/text.js';
|
|
24
27
|
import { safeUrl } from './pieces/work-common.js';
|
|
28
|
+
import { areaOf, mapIndex } from '../core/release-notes.js';
|
|
25
29
|
|
|
26
30
|
/** The words of a kind of work, singular and as a layer */
|
|
27
31
|
export const KIND_WORDS = Object.freeze({ thread: 'Thread', issue: 'Issue', proposal: 'Proposal', run: 'Agent run', pull: 'Pull request', deploy: 'Deploy' });
|
|
@@ -71,6 +75,8 @@ export const relWord = (rel) => (Object.hasOwn(REL_WORDS, rel) ? REL_WORDS[rel][
|
|
|
71
75
|
* than that on screen); on a phone a piece of work is drawn as its tag alone */
|
|
72
76
|
export const LABEL_CHARS = 34;
|
|
73
77
|
export const DRAWN_CHARS = 28;
|
|
78
|
+
/** The most characters of a title drawn after a node's tag on a desktop (spec 0015 D7: the lanes have the width the grouped code gives back) */
|
|
79
|
+
export const TITLE_CHARS = 32;
|
|
74
80
|
const clip = (s, n) => (s.length > n ? `${s.slice(0, n - 1).trimEnd()}…` : s);
|
|
75
81
|
/** The same, cut at a word when one is near the end of what fits */
|
|
76
82
|
const clipWords = (s, n) => { if (s.length <= n) return s; const cut = s.slice(0, n - 1); const sp = cut.lastIndexOf(' '); return `${(sp > n * 0.6 ? cut.slice(0, sp) : cut).trimEnd()}…`; };
|
|
@@ -156,9 +162,15 @@ export function oldItem(kind, src) {
|
|
|
156
162
|
* The scene of the Work view.
|
|
157
163
|
* @param {{ nodes?: object[], edges?: { from: string, to: string, rel: string }[] } | null} graph the server's answer
|
|
158
164
|
* @param {{ id: string, label?: string, type?: string }[]} mapNodes the map's nodes (the code a piece of work touches is found among them by id)
|
|
159
|
-
* @
|
|
165
|
+
* @param {{ from: string, to: string, kind?: string }[]} [mapEdges] the map's edges: its ownership edges say which area a node of code is in (core/release-notes.js `areaOf`)
|
|
166
|
+
* @returns {{ nodes: object[], edges: object[], counts: { work: number, code: number, waiting: number, areas: number, folded: number } }}
|
|
167
|
+
*
|
|
168
|
+
* The code is grouped by area (spec 0015 D1): an area's node (`area: true`, its id the map's node of the area, `members` the ids of its nodes that work touches,
|
|
169
|
+
* `self` when the area's own node is one of them) is drawn in the code column, and each node of code carries the `areaId` it is in; a planned node joins the
|
|
170
|
+
* area of its parent (a planned parent's, up to the map), else is an area of its own. A thread whose only links are `discusses` or `became` to the proposal of a
|
|
171
|
+
* spec pull request is not drawn (spec 0015 D2): it carries `foldedInto` (that proposal's id), and the proposal the ids of its threads, `folded`.
|
|
160
172
|
*/
|
|
161
|
-
export function workScene(graph, mapNodes) {
|
|
173
|
+
export function workScene(graph, mapNodes, mapEdges = []) {
|
|
162
174
|
const items = Array.isArray(graph && graph.nodes) ? graph.nodes : [];
|
|
163
175
|
const links = Array.isArray(graph && graph.edges) ? graph.edges : [];
|
|
164
176
|
const onMap = new Map((mapNodes || []).map((n) => [n.id, n]));
|
|
@@ -197,11 +209,113 @@ export function workScene(graph, mapNodes) {
|
|
|
197
209
|
if (!base && !plan) continue;
|
|
198
210
|
code++;
|
|
199
211
|
nodes.push(base
|
|
200
|
-
? { ...base, x: 0, y: 0, r: CODE_R, touches: by.size, degree: by.size, hidden: false, dim: false }
|
|
201
|
-
: { id, type: plannedType(plan.type), label: text(plan.label) || id, planned: true, r: CODE_R, touches: by.size, degree: by.size, x: 0, y: 0, groupName: CODE_LAYER_WORDS });
|
|
212
|
+
? { ...base, x: 0, y: 0, r: CODE_R, touches: by.size, degree: by.size, hidden: false, dim: false, by: [...by] }
|
|
213
|
+
: { id, type: plannedType(plan.type), label: text(plan.label) || id, planned: true, r: CODE_R, touches: by.size, degree: by.size, x: 0, y: 0, groupName: CODE_LAYER_WORDS, by: [...by] });
|
|
202
214
|
}
|
|
215
|
+
groupByArea(nodes, onMap, planned, mapIndex({ nodes: mapNodes || [], edges: mapEdges || [] }));
|
|
216
|
+
const folded = foldThreads(nodes, edges);
|
|
203
217
|
const waiting = nodes.filter((n) => n.waiting).length;
|
|
204
|
-
return { nodes, edges, counts: { work: work.size, code, waiting } };
|
|
218
|
+
return { nodes, edges, counts: { work: work.size, code, waiting, areas: nodes.filter((n) => n.area).length, folded } };
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/** The radius of an area's node in the Work view: a little bigger than its nodes' */
|
|
222
|
+
export const AREA_R = 13;
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Groups the code by area (spec 0015 D1): writes `areaId` on every node of code, and adds the node of each area that is not itself touched.
|
|
226
|
+
* The area of a node of the map is the ancestor just below the root (core/release-notes.js `areaOf`); a planned node's is its parent's (a planned parent's in turn).
|
|
227
|
+
*/
|
|
228
|
+
function groupByArea(nodes, onMap, planned, index) {
|
|
229
|
+
const areaOfMap = (node) => (node.type === 'root' ? null : areaOf(node, index).id);
|
|
230
|
+
const areaOfPlanned = (plan) => {
|
|
231
|
+
let at = plan;
|
|
232
|
+
const seen = new Set();
|
|
233
|
+
while (!seen.has(at.id)) {
|
|
234
|
+
seen.add(at.id);
|
|
235
|
+
const up = text(at.parent);
|
|
236
|
+
if (onMap.has(up)) return areaOfMap(onMap.get(up)) || at.id; // the root's own child is an area
|
|
237
|
+
if (!planned.has(up)) return at.id;
|
|
238
|
+
at = planned.get(up);
|
|
239
|
+
}
|
|
240
|
+
return at.id;
|
|
241
|
+
};
|
|
242
|
+
const code = nodes.filter((n) => !n.work);
|
|
243
|
+
const groups = new Map();
|
|
244
|
+
for (const n of code) {
|
|
245
|
+
n.areaId = onMap.has(n.id) ? areaOfMap(onMap.get(n.id)) || n.id : areaOfPlanned(planned.get(n.id) || { id: n.id });
|
|
246
|
+
(groups.get(n.areaId) || groups.set(n.areaId, []).get(n.areaId)).push(n);
|
|
247
|
+
}
|
|
248
|
+
const byId = new Map(code.map((n) => [n.id, n]));
|
|
249
|
+
for (const [id, members] of groups) {
|
|
250
|
+
const own = byId.get(id);
|
|
251
|
+
const base = onMap.get(id);
|
|
252
|
+
const area = own || (base ? { ...base, x: 0, y: 0, hidden: false, dim: false } : { id, type: 'page', label: id, x: 0, y: 0 });
|
|
253
|
+
area.area = true;
|
|
254
|
+
area.self = !!own;
|
|
255
|
+
area.r = AREA_R;
|
|
256
|
+
area.members = members.map((n) => n.id);
|
|
257
|
+
area.size = members.length; // how many of its nodes work touches: the number drawn beside its name
|
|
258
|
+
area.planned = members.every((n) => n.planned === true); // drawn as planned (dashed) only while every node of it is
|
|
259
|
+
area.mapped = !!(own ? onMap.has(id) : base); // the map holds the area's own node: "Show on the map" goes to it
|
|
260
|
+
area.touches = new Set(members.flatMap((n) => n.by || [])).size;
|
|
261
|
+
area.degree = area.touches;
|
|
262
|
+
area.groupName = CODE_LAYER_WORDS;
|
|
263
|
+
if (!own) nodes.push(area);
|
|
264
|
+
}
|
|
265
|
+
for (const n of code) delete n.by;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/** A spec pull request's conversation folded into its proposal (spec 0015 D2): a thread whose every line is `discusses` or `became` to such a proposal. How many were folded. */
|
|
269
|
+
function foldThreads(nodes, edges) {
|
|
270
|
+
const byId = new Map(nodes.map((n) => [n.id, n]));
|
|
271
|
+
const specPull = (n) => !!n && n.work === 'proposal' && Number.isInteger(n.item.number);
|
|
272
|
+
let count = 0;
|
|
273
|
+
for (const n of nodes) {
|
|
274
|
+
if (n.work !== 'thread') continue;
|
|
275
|
+
const mine = edges.filter((e) => e.from === n.id || e.to === n.id);
|
|
276
|
+
if (!mine.length || !mine.every((e) => e.from === n.id && (e.kind === 'discusses' || e.kind === 'became') && specPull(byId.get(e.to)))) continue;
|
|
277
|
+
const into = byId.get((mine.find((e) => byId.get(e.to).item.number === n.item.number) || mine[0]).to);
|
|
278
|
+
n.foldedInto = into.id;
|
|
279
|
+
(into.folded || (into.folded = [])).push(n.id);
|
|
280
|
+
count++;
|
|
281
|
+
}
|
|
282
|
+
return count;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* The lines the scene walks in the Work view (`state.edges`): the work's own, a line to code in a closed area moved to end at the area (one per piece of work,
|
|
287
|
+
* area and rel, `via` naming the nodes it stands for), and for the open area the lines (drawn nowhere: `tone: 'area'`) that tie it to its nodes (an ownership:
|
|
288
|
+
* no kind) and to the work that touches them (their rel), so that selecting it lights them.
|
|
289
|
+
* @param {object[]} nodes the view's nodes (`workScene`)
|
|
290
|
+
* @param {object[]} edges the view's edges (`workScene`)
|
|
291
|
+
* @param {string | null} [open] the id of the open area
|
|
292
|
+
*/
|
|
293
|
+
export function drawnEdges(nodes, edges, open = null) {
|
|
294
|
+
const byId = new Map(nodes.map((n) => [n.id, n]));
|
|
295
|
+
const out = [];
|
|
296
|
+
const seen = new Map();
|
|
297
|
+
const touching = new Set();
|
|
298
|
+
for (const e of edges) {
|
|
299
|
+
const to = e.tone === 'code' ? byId.get(e.to) : null;
|
|
300
|
+
const area = to && to.areaId && to.areaId !== to.id && to.areaId !== open ? to.areaId : null;
|
|
301
|
+
if (to && to.areaId === open && open) touching.add(`${e.from}|${e.kind}`);
|
|
302
|
+
const end = area || e.to;
|
|
303
|
+
const key = `${e.from}->${end}|${e.kind}`;
|
|
304
|
+
const had = seen.get(key);
|
|
305
|
+
if (had) { if (area) had.via.push(e.to); continue; }
|
|
306
|
+
const line = area ? { ...e, to: area, via: [e.to] } : e.tone === 'code' ? { ...e, via: [] } : e;
|
|
307
|
+
seen.set(key, line);
|
|
308
|
+
out.push(line);
|
|
309
|
+
}
|
|
310
|
+
if (open) {
|
|
311
|
+
// the area owns its nodes (a line with no kind, as the map's ownership is: the node panel says "Owns 3"), and the work touching them touches it, by the same rel
|
|
312
|
+
for (const n of nodes) if (n.areaId === open && n.id !== open && !n.hidden) out.push({ from: open, to: n.id, tone: 'area' });
|
|
313
|
+
for (const k of touching) {
|
|
314
|
+
const [from, kind] = k.split('|');
|
|
315
|
+
if (!seen.has(`${from}->${open}|${kind}`)) out.push({ from, to: open, kind, tone: 'area', word: relWord(kind) });
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
return out;
|
|
205
319
|
}
|
|
206
320
|
|
|
207
321
|
/**
|
|
@@ -215,16 +329,25 @@ export function workScene(graph, mapNodes) {
|
|
|
215
329
|
* @param {string} key the line's key
|
|
216
330
|
* @param {{ PROPOSED_DASH: number[], USAGE_DASH: number[] }} dashes the map's two dash patterns
|
|
217
331
|
* @param {Partial<Record<'work' | 'code' | 'adds', string>>} [colors] what the theme's `--corn-work-edge-<name>` tokens say (`state.workEdgeColors`); a name it does not set is drawn in its default (core/schema.js WORK_EDGE_THEMES)
|
|
332
|
+
* @param {{ selected?: string | null, hover?: string | null }} [focus] the selected node's id and the one under the pointer: a line from work to code is drawn only for
|
|
333
|
+
* them (spec 0015 D1), or for the area the code is in; null when the line is not drawn (and for the lines that tie an open area to its nodes, which are never drawn)
|
|
218
334
|
*/
|
|
219
|
-
export function workEdge(edge, source, target, connected, focused, key, dashes, colors) {
|
|
220
|
-
|
|
335
|
+
export function workEdge(edge, source, target, connected, focused, key, dashes, colors, focus = {}) {
|
|
336
|
+
if (edge.tone === 'area') return null;
|
|
337
|
+
let mine = false;
|
|
338
|
+
if (edge.tone === 'code') {
|
|
339
|
+
const ends = (id) => !!id && (id === source.id || id === target.id || id === target.areaId);
|
|
340
|
+
mine = ends(focus.selected);
|
|
341
|
+
if (!mine && !ends(focus.hover)) return null;
|
|
342
|
+
}
|
|
343
|
+
const lit = focused && (connected || mine);
|
|
221
344
|
const name = edge.kind === 'adds' ? 'adds' : edge.tone === 'work' ? 'work' : 'code';
|
|
222
345
|
const color = (colors && colors[name]) || WORK_EDGE_THEMES[name];
|
|
223
346
|
const faded = source.dim === true && target.dim === true; // "Waiting on you" is on and neither end waits
|
|
224
347
|
return {
|
|
225
348
|
key, from: edge.from, to: edge.to, kind: edge.kind,
|
|
226
349
|
x1: source.x, y1: source.y, x2: target.x, y2: target.y, r1: source.r, r2: target.r,
|
|
227
|
-
color, width: lit ? 2.4 : 1.4, alpha: faded ? 0.12 : focused ? (connected ? 1 : 0.08) : 0.35,
|
|
350
|
+
color, width: lit ? 2.4 : edge.tone === 'code' ? 1.8 : 1.4, alpha: faded ? 0.12 : lit ? 1 : edge.tone === 'code' ? 0.6 : focused ? (connected ? 1 : 0.08) : 0.35, // a line to code not of the selection is the pointer's
|
|
228
351
|
dash: edge.kind === 'adds' ? dashes.PROPOSED_DASH : edge.kind === 'mentions' ? dashes.USAGE_DASH : null,
|
|
229
352
|
ticks: 0, curve: null, arrow: false, end: null, glow: 0, glowColor: null,
|
|
230
353
|
label: lit ? { text: typeof edge.word === 'string' && edge.word ? edge.word : edge.kind, x: (source.x + target.x) / 2, y: (source.y + target.y) / 2, color, italic: false } : null,
|
|
@@ -243,13 +366,15 @@ export const CODE_R = 9;
|
|
|
243
366
|
export const byLane = (a, b) => (a.waiting === b.waiting ? 0 : a.waiting ? -1 : 1) || (a.updated < b.updated ? 1 : a.updated > b.updated ? -1 : 0) || (a.id < b.id ? -1 : a.id > b.id ? 1 : 0);
|
|
244
367
|
/** Most touched first, then by name: the order of the code */
|
|
245
368
|
export const byTouch = (a, b) => (b.touches || 0) - (a.touches || 0) || String(a.label).localeCompare(String(b.label)) || (a.id < b.id ? -1 : 1);
|
|
369
|
+
/** The areas: the most nodes touched first, then the most work, then by name */
|
|
370
|
+
export const byArea = (a, b) => ((b.drawn ?? b.size) || 0) - ((a.drawn ?? a.size) || 0) || byTouch(a, b);
|
|
246
371
|
|
|
247
372
|
/**
|
|
248
373
|
* The sizes the layout works in. World units, laid out for the zoom the first fit will have, so a name under a node (11 px at least, whatever the zoom: labels.js) has
|
|
249
374
|
* the room on screen it needs: a cell is wide enough for a name, a row tall enough for a disc and a name under it, and lanes next to each other are staggered by half a row
|
|
250
375
|
* so a name that runs past its lane lands between the next lane's. `margin` is what the first fit leaves on screen around the lanes, in px (the names at the edge, and the toggles at the top).
|
|
251
376
|
*/
|
|
252
|
-
const DESK = { cell:
|
|
377
|
+
const DESK = { cell: 236, row: 70, codeCell: 190, codeRow: 44, gap: 14, pad: 6, margin: { x: 100, top: 56, bottom: 24 }, caps: [100, 64, 48, 40, 32, 28, 24, 20, 18, 16, 14, 12, 10, 9, 8, 7, 6, 5] };
|
|
253
378
|
const PHONE = { cell: 104, row: 84, codeCell: 150, codeRow: 40, gap: 12, pad: 4, margin: { x: 36, top: 112, bottom: 16 } };
|
|
254
379
|
/** A lane's title (screen px) the first node sits under, and a name under a node (its gap and its line, px) */
|
|
255
380
|
const TITLE_PX = 40;
|
|
@@ -263,7 +388,11 @@ const lane = (key, title, count, x, y, w, h) => ({ key, name: title, count, x, y
|
|
|
263
388
|
/** The text drawn under a node: a piece of work's tag and the start of its title (a phone: the tag), the name of a node of code (a phone: the start of it) */
|
|
264
389
|
function nameNodes(nodes, phone) {
|
|
265
390
|
for (const n of nodes) {
|
|
266
|
-
if (n.work) {
|
|
391
|
+
if (n.work) {
|
|
392
|
+
const tag = tagOf(n.item);
|
|
393
|
+
const folded = n.folded && n.folded.length ? ` · ${n.folded.length} ${n.folded.length === 1 ? 'thread' : 'threads'}` : ''; // its conversations, folded into it (spec 0015 D2)
|
|
394
|
+
n.labelText = phone ? `${tag}${n.folded && n.folded.length ? ` · ${n.folded.length}` : ''}` : `${tag} · ${clipWords(n.title, TITLE_CHARS)}${folded}`;
|
|
395
|
+
} else if (n.area) n.labelText = `${clip(String(n.label), phone ? 12 : 26)} · ${n.drawn ?? n.size}`; // an area: its name and how many of its nodes work touches (the work drawn)
|
|
267
396
|
else n.labelText = clip(String(n.label), phone ? 12 : 32);
|
|
268
397
|
}
|
|
269
398
|
}
|
|
@@ -296,7 +425,9 @@ export function layoutWork(nodes, { phone = false, width = 1200, height = 800, p
|
|
|
296
425
|
for (const n of shown.filter((x) => x.work && !x.draft && !known.has(x.id))) stages.find((s) => s.key === { thread: 'talk', issue: 'talk', proposal: 'decide', run: 'build', pull: 'build', deploy: 'ship' }[n.work]).nodes.push(n);
|
|
297
426
|
stages.forEach((s) => s.nodes.sort(byLane));
|
|
298
427
|
const drafts = shown.filter((n) => n.draft).sort(byLane);
|
|
299
|
-
|
|
428
|
+
// the code column: the areas, most touched first, each with its nodes under it while it is open (spec 0015 D1)
|
|
429
|
+
const code = shown.filter((n) => n.area).sort(byArea);
|
|
430
|
+
for (const a of code) a.inside = shown.filter((n) => !n.work && !n.area && n.areaId === a.id).sort(byTouch);
|
|
300
431
|
const v = { width: Math.max(160, width), height: Math.max(160, height) };
|
|
301
432
|
return phone ? layoutPhone(stages, drafts, code, v, padding) : layoutDesk(stages, drafts, code, v, padding);
|
|
302
433
|
}
|
|
@@ -317,7 +448,7 @@ function layoutDesk(stages, drafts, code, v, p) {
|
|
|
317
448
|
const parts = lanes.map((l, i) => {
|
|
318
449
|
const cell = l.code ? c.codeCell : c.cell;
|
|
319
450
|
const row = l.code ? c.codeRow : c.row;
|
|
320
|
-
const r = l.code ?
|
|
451
|
+
const r = l.code ? AREA_R : 20;
|
|
321
452
|
const { cols, rows } = cut(l.nodes.length, cap);
|
|
322
453
|
const w = cols * cell + 2 * c.pad;
|
|
323
454
|
const stagger = cols > 1 || i % 2 ? 0.5 : 0;
|
|
@@ -342,20 +473,38 @@ function layoutDesk(stages, drafts, code, v, p) {
|
|
|
342
473
|
}
|
|
343
474
|
const { g } = best;
|
|
344
475
|
const out = [];
|
|
476
|
+
const order = [];
|
|
477
|
+
let bottom = g.h;
|
|
345
478
|
for (const part of g.parts) {
|
|
346
479
|
const { l, i, cell, row, r, cols, rows } = part;
|
|
480
|
+
if (l.code) {
|
|
481
|
+
// an open area's nodes sit under it, in its column, and push the areas below it down; the fit is the closed column's, so opening one moves nothing else
|
|
482
|
+
const at = new Array(cols).fill(0);
|
|
483
|
+
l.nodes.forEach((n, j) => {
|
|
484
|
+
const col = Math.floor(j / rows);
|
|
485
|
+
const x = part.x + c.pad + (col + 0.5) * cell;
|
|
486
|
+
const y = (k) => g.room + AREA_R + (k + ((i + col) % 2) * 0.5) * row;
|
|
487
|
+
n.x = x;
|
|
488
|
+
n.y = y(at[col]++);
|
|
489
|
+
order.push(n.id);
|
|
490
|
+
for (const m of n.inside) { m.x = x + 12; m.y = y(at[col]++); order.push(m.id); }
|
|
491
|
+
});
|
|
492
|
+
const h = Math.max(g.h, g.room + 2 * AREA_R + (Math.max(...at) - 0.5) * row + NAME_PX / z + 8);
|
|
493
|
+
bottom = Math.max(bottom, h);
|
|
494
|
+
out.push(lane(l.key, l.title, l.nodes.length, part.x, 0, part.w, h));
|
|
495
|
+
continue;
|
|
496
|
+
}
|
|
347
497
|
l.nodes.forEach((n, j) => {
|
|
348
498
|
const col = Math.floor(j / rows);
|
|
349
499
|
n.x = part.x + c.pad + (col + 0.5) * cell;
|
|
350
500
|
n.y = g.room + r + (j % rows + ((i + col) % 2) * 0.5) * row;
|
|
501
|
+
order.push(n.id);
|
|
351
502
|
});
|
|
352
503
|
out.push(lane(l.key, l.title, l.nodes.length, part.x, 0, part.w, g.h));
|
|
353
504
|
}
|
|
354
|
-
const order = g.parts.flatMap((part) => part.l.nodes.map((n) => n.id));
|
|
355
|
-
let bottom = g.h;
|
|
356
505
|
if (drafts.length) {
|
|
357
506
|
// the band: columns of the lanes' own cell, as many as the row is wide, staggered as the lanes' are; it starts a gap under the row
|
|
358
|
-
const top =
|
|
507
|
+
const top = bottom + c.gap; // under the row, and under an open area that runs past it
|
|
359
508
|
const room = TITLE_PX / z;
|
|
360
509
|
const cols = Math.max(1, Math.floor((g.w - 2 * c.pad) / c.cell));
|
|
361
510
|
const rows = Math.ceil(drafts.length / cols);
|
|
@@ -371,8 +520,9 @@ function layoutDesk(stages, drafts, code, v, p) {
|
|
|
371
520
|
return { lanes: out, order, bounds: { x: 0, y: 0, w: g.w, h: bottom }, fit: fitBoxOf(g.w, g.h, z, c.margin, p, v) };
|
|
372
521
|
}
|
|
373
522
|
|
|
374
|
-
function layoutPhone(stages, drafts,
|
|
523
|
+
function layoutPhone(stages, drafts, areas, v, p) {
|
|
375
524
|
const c = PHONE;
|
|
525
|
+
const code = areas.flatMap((a) => [a, ...a.inside]); // a phone's column: each area, and the open one's nodes after it
|
|
376
526
|
const bands = [stages[0], stages[1], ...(drafts.length ? [{ key: 'drafts', title: DRAFT_LANE_TITLE, nodes: drafts }] : []), { key: 'build-ship', title: 'Build · Ship', nodes: [...stages[2].nodes, ...stages[3].nodes] }];
|
|
377
527
|
const plan = (z, perRow, codeCols) => {
|
|
378
528
|
const room = TITLE_PX / z;
|
|
@@ -389,7 +539,7 @@ function layoutPhone(stages, drafts, code, v, p) {
|
|
|
389
539
|
const hBands = y - c.gap;
|
|
390
540
|
const codeRows = Math.max(1, Math.ceil(code.length / codeCols));
|
|
391
541
|
const wCode = code.length ? codeCols * c.codeCell + 2 * c.pad : 0;
|
|
392
|
-
const hCode = code.length ? room + 2 *
|
|
542
|
+
const hCode = code.length ? room + 2 * AREA_R + (codeRows - 1 + (codeCols > 1 ? 0.5 : 0)) * c.codeRow + below + 8 : 0;
|
|
393
543
|
return { parts, wBand, wCode, hBands, hCode, codeRows, room, w: wBand + (code.length ? c.gap + wCode : 0), h: Math.max(hBands, hCode) };
|
|
394
544
|
};
|
|
395
545
|
let z = 0.5;
|
|
@@ -413,8 +563,8 @@ function layoutPhone(stages, drafts, code, v, p) {
|
|
|
413
563
|
}
|
|
414
564
|
if (code.length) {
|
|
415
565
|
const x0 = g.wBand + c.gap;
|
|
416
|
-
code.forEach((n, j) => { const col = Math.floor(j / g.codeRows); n.x = x0 + c.pad + (col + 0.5) * c.codeCell; n.y = g.room +
|
|
417
|
-
out.push(lane('code', CODE_LANE_TITLE,
|
|
566
|
+
code.forEach((n, j) => { const col = Math.floor(j / g.codeRows); n.x = x0 + c.pad + (col + 0.5) * c.codeCell + (n.area ? 0 : 8); n.y = g.room + AREA_R + (j % g.codeRows + (col % 2) * 0.5) * c.codeRow; });
|
|
567
|
+
out.push(lane('code', CODE_LANE_TITLE, areas.length, x0, 0, g.wCode, g.hCode));
|
|
418
568
|
}
|
|
419
569
|
return { lanes: out, order: [...g.parts.flatMap((part) => part.b.nodes.map((n) => n.id)), ...code.map((n) => n.id)], bounds: { x: 0, y: 0, w: g.w, h: g.h }, fit: fitBoxOf(g.w, g.h, z, c.margin, p, v) };
|
|
420
570
|
}
|
|
@@ -427,17 +577,19 @@ function layoutPhone(stages, drafts, code, v, p) {
|
|
|
427
577
|
export const startLayers = () => Object.fromEntries(LAYER_KEYS.map((k) => [k, k !== DRAFT_LAYER]));
|
|
428
578
|
|
|
429
579
|
/**
|
|
430
|
-
* Sets `hidden` and `dim` on the nodes. A piece of work is hidden when its layer is off
|
|
431
|
-
* hidden (only code that work touches is drawn)
|
|
580
|
+
* Sets `hidden` and `dim` on the nodes. A piece of work is hidden when its layer is off, and a thread folded into its proposal always (spec 0015 D2); code when its
|
|
581
|
+
* layer is off or every piece of work that touches it is hidden (only code that work touches is drawn): an area while any of its nodes is drawn, a node of an area
|
|
582
|
+
* only while that area is open (`open`, spec 0015 D1). With "Waiting on you" on, everything that does not wait is dimmed.
|
|
432
583
|
*/
|
|
433
|
-
export function applyFilters(nodes, edges, { layers = startLayers(), waiting = false } = {}) {
|
|
584
|
+
export function applyFilters(nodes, edges, { layers = startLayers(), waiting = false, open = null } = {}) {
|
|
434
585
|
const on = (key) => layers[key] !== false;
|
|
435
586
|
const shown = new Set();
|
|
436
|
-
for (const n of nodes) { n.hidden = n.draft ? !on(DRAFT_LAYER) : n.work ? !on(workType(n.work)) : false; if (n.work && !n.hidden) shown.add(n.id); }
|
|
587
|
+
for (const n of nodes) { n.hidden = n.foldedInto ? true : n.draft ? !on(DRAFT_LAYER) : n.work ? !on(workType(n.work)) : false; if (n.work && !n.hidden) shown.add(n.id); }
|
|
437
588
|
const reached = new Set();
|
|
438
589
|
for (const e of edges) if (e.tone === 'code' && shown.has(e.from)) reached.add(e.to);
|
|
439
590
|
for (const n of nodes) {
|
|
440
|
-
if (
|
|
591
|
+
if (n.area) { n.drawn = n.members.filter((id) => reached.has(id)).length; n.hidden = !on(CODE_LAYER) || !n.drawn; n.open = n.id === open; } // `drawn`: how many of its nodes the work drawn touches
|
|
592
|
+
else if (!n.work) n.hidden = !on(CODE_LAYER) || !reached.has(n.id) || (!!n.areaId && n.areaId !== n.id && n.areaId !== open);
|
|
441
593
|
n.dim = waiting && !n.waiting;
|
|
442
594
|
}
|
|
443
595
|
return nodes;
|
|
@@ -445,7 +597,7 @@ export function applyFilters(nodes, edges, { layers = startLayers(), waiting = f
|
|
|
445
597
|
|
|
446
598
|
/** The Layers menu's rows in the Work view: `{ key, label, color, desc, countText }`, the six kinds, the local drafts and the code they touch */
|
|
447
599
|
export function layerRowsOf(nodes) {
|
|
448
|
-
const of = (kind) => nodes.filter((n) => n.work === kind && !n.draft);
|
|
600
|
+
const of = (kind) => nodes.filter((n) => n.work === kind && !n.draft && !n.foldedInto); // a thread folded into its proposal is not drawn, nor counted (spec 0015 D2)
|
|
449
601
|
const word = (n, w) => `${n} ${w}`;
|
|
450
602
|
const rows = KIND_ORDER.map((kind) => {
|
|
451
603
|
const list = of(kind);
|
|
@@ -459,7 +611,7 @@ export function layerRowsOf(nodes) {
|
|
|
459
611
|
});
|
|
460
612
|
const drafts = nodes.filter((n) => n.draft).length;
|
|
461
613
|
rows.push({ key: DRAFT_LAYER, label: DRAFT_LAYER_WORDS, color: WORK_THEMES.proposal.color, desc: 'Proposals that are only files in the checkout: no pull request holds them, nobody has been asked to decide them', countText: word(drafts, 'local'), count: drafts });
|
|
462
|
-
const codeCount = nodes.filter((n) => !n.work).length;
|
|
614
|
+
const codeCount = nodes.filter((n) => !n.work && (!n.area || n.self)).length; // the nodes of code, not the areas they are grouped in
|
|
463
615
|
rows.push({ key: CODE_LAYER, label: CODE_LAYER_WORDS, color: NODE_THEMES.page.color, desc: 'The code the work touches', countText: String(codeCount), count: codeCount });
|
|
464
616
|
return rows;
|
|
465
617
|
}
|
|
@@ -504,7 +656,8 @@ export function saysOf(item) {
|
|
|
504
656
|
}
|
|
505
657
|
|
|
506
658
|
/**
|
|
507
|
-
* What the node panel says of a piece of work (the page draws it: work-view.js).
|
|
659
|
+
* What the node panel says of a piece of work (the page draws it: work-view.js). Spec 0015 D4: one state pill (the state and the action say what waits on you) and one line of facts:
|
|
660
|
+
* its tag, who, when, its spec PR or its kind of run. A thread folded into a proposal (`foldedInto`, kept out of the drawing: spec 0015 D2) is a row of the proposal's Connected.
|
|
508
661
|
* @param {object} node a node of the Work view (a piece of work)
|
|
509
662
|
* @param {object[]} nodes every node of the view
|
|
510
663
|
* @param {object[]} edges every edge of the view
|
|
@@ -514,19 +667,25 @@ export function panelOf(node, nodes, edges, { now = Date.now() } = {}) {
|
|
|
514
667
|
const item = node.item;
|
|
515
668
|
const byId = new Map(nodes.map((n) => [n.id, n]));
|
|
516
669
|
const pills = [{ text: stateWordsOf(item), state: pillStateOf(item) }];
|
|
517
|
-
|
|
518
|
-
if (item.kind === 'proposal' && Number.isInteger(item.number))
|
|
519
|
-
if (item.kind === 'run' && item.runKind)
|
|
520
|
-
const meta =
|
|
670
|
+
const facts = [tagOf(item), item.author ? text(item.author) : '', relativeTime(item.updated, now)];
|
|
671
|
+
if (item.kind === 'proposal' && Number.isInteger(item.number)) facts.push(`PR #${item.number}`);
|
|
672
|
+
if (item.kind === 'run' && item.runKind) facts.push(text(item.runKind));
|
|
673
|
+
const meta = facts.filter(Boolean).join(' · ');
|
|
521
674
|
const links = [];
|
|
675
|
+
const seen = new Set();
|
|
676
|
+
const foldedLink = (rel, other) => ({ rel, id: other.id, label: tagOf(other.item), work: 'thread', code: false, planned: false, state: '', folded: true, number: other.item.number, comments: Number.isInteger(other.item.comments) ? other.item.comments : null });
|
|
522
677
|
for (const e of edges) {
|
|
523
678
|
const out = e.from === node.id;
|
|
524
679
|
const other = byId.get(out ? e.to : e.from);
|
|
525
680
|
if (!other || (!out && e.to !== node.id)) continue;
|
|
526
|
-
|
|
681
|
+
const rel = REL_WORDS[e.kind][out ? 0 : 1];
|
|
682
|
+
if (other.item && other.foldedInto === node.id) { if (!seen.has(other.id)) links.push(foldedLink(rel, other)); seen.add(other.id); continue; }
|
|
683
|
+
links.push({ rel, id: other.id, label: other.label, work: other.work || '', code: !other.work, planned: other.planned === true, state: other.item ? stateWordsOf(other.item) : '', folded: false });
|
|
527
684
|
}
|
|
685
|
+
// A folded thread no edge names here (the canvas may keep only its mark): it is discussed in this proposal all the same
|
|
686
|
+
for (const other of nodes) if (other.item && other.foldedInto === node.id && !seen.has(other.id)) links.push(foldedLink(REL_WORDS.discusses[1], other));
|
|
528
687
|
// Work first (in the order of the lanes), then code; the same words together
|
|
529
|
-
const rank = (l) => (l.work ? LANES.findIndex((x) => x.key === (byId.get(l.id).stage || '')) : 9);
|
|
688
|
+
const rank = (l) => (l.work ? LANES.findIndex((x) => x.key === ((byId.get(l.id) || {}).stage || '')) : 9);
|
|
530
689
|
links.sort((a, b) => rank(a) - rank(b) || a.rel.localeCompare(b.rel) || a.label.localeCompare(b.label));
|
|
531
690
|
return { kind: KIND_WORDS[item.kind], tag: tagOf(item), title: node.title, color: WORK_THEMES[item.kind].color, pills, meta, links, says: saysOf(item), url: text(item.url) };
|
|
532
691
|
}
|
|
@@ -537,11 +696,38 @@ export function panelOf(node, nodes, edges, { now = Date.now() } = {}) {
|
|
|
537
696
|
const pill = (p) => `<span class="hx-forge-state${p.state ? ` hx-forge-state--${esc(p.state)}` : ''}" data-corn="state-pill"${cornState(p.state) ? ` data-corn-state="${esc(cornState(p.state))}"` : ''}>${esc(p.text)}</span>`;
|
|
538
697
|
const dotOf = (kind, color) => { const c = typeof color === 'function' ? color(kind) : ''; return `<span class="hx-work-dot" data-corn="swatch" data-work-kind="${esc(kind || 'code')}" aria-hidden="true"${c ? ` data-style="background-color: ${esc(c)}"` : ''}></span>`; };
|
|
539
698
|
const linkButton = (l) => `<button type="button" class="hx-linkbtn" data-corn="node-link" data-action="select-node" data-id="${esc(l.id)}">${esc(l.label)}</button>`;
|
|
699
|
+
/** A folded thread's row: it shows the thread in the panel, and the proposal stays selected on the map (pieces/work-threads.js `showFolded`) */
|
|
700
|
+
const commentWords = (n) => (Number.isInteger(n) ? `${n} ${n === 1 ? 'comment' : 'comments'}` : '');
|
|
701
|
+
const foldedButton = (l) => `<button type="button" class="hx-linkbtn" data-corn="node-link" data-work-folded="${esc(l.number)}" data-id="${esc(l.id)}">${esc(l.label)}</button><span class="hx-faint" data-folded-count="${esc(l.number)}">${l.comments !== null ? ` · ${esc(commentWords(l.comments))}` : ''}</span>`;
|
|
702
|
+
const linkRow = (l, color, rel = true) => `<li data-corn="work-link">${rel ? `<span class="hx-work-rel">${esc(relTitle(l.rel))}</span>` : ''}${dotOf(l.work, color)}${l.folded ? foldedButton(l) : linkButton(l)}${l.planned ? ' <span class="hx-faint">planned</span>' : ''}${l.state && !l.folded ? ` <span class="hx-faint">· ${esc(l.state.toLowerCase())}</span>` : ''}</li>`;
|
|
703
|
+
|
|
704
|
+
/** "pull requests", "planned nodes": what a group of connections is, counted */
|
|
705
|
+
function groupNoun(rows) {
|
|
706
|
+
const n = rows.length;
|
|
707
|
+
const kinds = new Set(rows.map((l) => l.work || (l.planned ? 'planned' : 'code')));
|
|
708
|
+
const [k] = kinds;
|
|
709
|
+
if (kinds.size !== 1 || k === 'code') return n === 1 ? 'node' : 'nodes';
|
|
710
|
+
if (k === 'planned') return n === 1 ? 'planned node' : 'planned nodes';
|
|
711
|
+
const word = (KIND_WORDS[k] || 'node').toLowerCase();
|
|
712
|
+
return n === 1 ? word : `${word}s`;
|
|
713
|
+
}
|
|
540
714
|
|
|
541
715
|
/**
|
|
542
|
-
*
|
|
543
|
-
*
|
|
544
|
-
*
|
|
716
|
+
* Connected, grouped by relation (spec 0015 D4): a group of one is its row ("Agent on it Run 000003 · working"); a bigger one is its count, which opens it ("Adds 5 planned nodes").
|
|
717
|
+
* @param {ReturnType<typeof panelOf>['links']} links
|
|
718
|
+
* @param {{ color?: (kind: string) => string }} [opts]
|
|
719
|
+
*/
|
|
720
|
+
export function connectedHtml(links, { color = () => '' } = {}) {
|
|
721
|
+
const rows = groupLinks(links).map((g) => (g.rows.length === 1
|
|
722
|
+
? linkRow(g.rows[0], color)
|
|
723
|
+
: `<li class="hx-work-group" data-corn="work-link"><button type="button" class="hx-textbtn hx-work-gtoggle" data-sub-toggle aria-expanded="false" data-corn-kind="quiet">${esc(`${relTitle(g.rel)} ${g.rows.length} ${groupNoun(g.rows)}`)}</button><ul class="hx-work-links hx-work-sub" hidden>${g.rows.map((l) => linkRow(l, color, false)).join('')}</ul></li>`));
|
|
724
|
+
return `<ul class="hx-work-links" data-corn="work-links">${rows.join('')}</ul>`;
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
/**
|
|
728
|
+
* The node panel's markup for a piece of work (`panelOf`'s answer), in spec 0015 D4's order: its one state pill and one line of facts, then the place of its actions (`forge-detail`:
|
|
729
|
+
* the Work piece draws the action bar and the Next line into its `bar` place, notices into `notes` and its other sections into `sections`: pieces/work-paint.js `paintDetail`),
|
|
730
|
+
* with Connected, the first section, between them. Until the actions are drawn the bar holds the link to the forge, when the kind's own actions do not carry it.
|
|
545
731
|
* @param {ReturnType<typeof panelOf>} p
|
|
546
732
|
* @param {object} node
|
|
547
733
|
* @param {{ color?: (kind: string) => string }} [opts] `color`: a kind's colour as the map draws it
|
|
@@ -550,32 +736,36 @@ export function workPanelHtml(p, node, { color = () => '' } = {}) {
|
|
|
550
736
|
const url = safeUrl(p.url);
|
|
551
737
|
const kind = node.item.kind;
|
|
552
738
|
const links = node.old
|
|
553
|
-
? '
|
|
554
|
-
: p.links.length
|
|
555
|
-
|
|
556
|
-
: '<div class="hx-fact" data-corn="section"><div class="hx-fact-k">Connected</div><div class="hx-fact-v hx-faint">Nothing it is linked to is drawn.</div></div>';
|
|
557
|
-
// A pull request's (a spec's too) and a deploy's own actions carry their link to the forge; the others get it here
|
|
739
|
+
? sectionHtml({ key: 'connected', title: 'Connected', body: '<p class="hx-faint">Its links are not drawn here: it is older than the 14 days the map of work covers, or past its limits.</p>' })
|
|
740
|
+
: sectionHtml({ key: 'connected', title: 'Connected', count: p.links.length, body: p.links.length ? connectedHtml(p.links, { color }) : '<p class="hx-faint">Nothing it is linked to is drawn.</p>' });
|
|
741
|
+
// A pull request's (a spec's too) and a deploy's own actions carry their link to the forge; the others' bar has it (the Work piece draws it again with their actions)
|
|
558
742
|
const specPull = kind === 'proposal' && Number.isInteger(node.item.number); // its pull request's actions carry the link
|
|
559
743
|
const out = url && kind !== 'pull' && kind !== 'deploy' && !specPull ? `<a class="hx-btn hx-btn--quiet hx-foot-btn" data-corn-kind="quiet" data-corn="open-link" href="${esc(url)}" target="_blank" rel="noreferrer">Open on the forge ↗</a>` : '';
|
|
560
|
-
const
|
|
561
|
-
|
|
744
|
+
const bar = out ? `<div class="hx-actions" data-corn="actions" role="group" aria-label="Actions"><div class="hx-actions-row">${out}</div></div>` : '';
|
|
745
|
+
const actions = `<div id="forge-detail" class="hx-forge-detail hx-work-actions" data-corn="work-detail" data-work-kind="${esc(kind)}" data-work-ref="${esc(node.id)}">`
|
|
746
|
+
+ `<div class="hx-work-bar" data-work-place="bar">${bar}</div><div class="hx-work-notes" data-work-place="notes"></div>${links}<div class="hx-work-sections" data-work-place="sections"></div></div>`;
|
|
747
|
+
return `<div class="hx-work-head" data-corn="work-head"><p class="hx-work-pills" data-corn="work-pills">${p.pills.map(pill).join(' ')}</p><p class="hx-faint hx-work-facts">${esc(p.meta)}</p></div>${actions}`;
|
|
562
748
|
}
|
|
563
749
|
|
|
564
750
|
/** The node panel's section for a node of code in the Work view: the work that touches it, and "Show on the map" (a planned node is not on the map yet) */
|
|
565
751
|
export function codePanelHtml(node, touching, { color = () => '' } = {}) {
|
|
752
|
+
const planned = node.planned === true && !node.mapped; // an area drawn as planned whose own node the map holds is on the map
|
|
566
753
|
const list = touching.length
|
|
567
754
|
? `<ul class="hx-work-links" data-corn="work-links">${touching.map((l) => `<li data-corn="work-link"><span class="hx-work-rel">${esc(l.rel)}</span>${dotOf(l.work, color)}${linkButton(l)}</li>`).join('')}</ul>`
|
|
568
755
|
: '<p class="hx-faint">No work touches it now.</p>';
|
|
569
|
-
const show =
|
|
570
|
-
return `<div class="hx-fact" data-corn="section"><div class="hx-fact-k">Work</div><div class="hx-fact-v">${
|
|
756
|
+
const show = planned ? '' : `<button type="button" class="hx-btn hx-btn--secondary hx-foot-btn" data-corn-kind="secondary" data-work-action="show-on-map" data-id="${esc(node.id)}">Show on the map</button>`;
|
|
757
|
+
return `<div class="hx-fact" data-corn="section"><div class="hx-fact-k">Work</div><div class="hx-fact-v">${planned ? '<p class="hx-faint">Planned: a proposal adds it, and the map does not hold it yet.</p>' : ''}${list}${show}</div></div>`;
|
|
571
758
|
}
|
|
572
759
|
|
|
573
760
|
/** The work that touches a node of code, as the node panel lists it: `{ rel, id, label, work }` */
|
|
574
761
|
export function touchedBy(node, nodes, edges) {
|
|
575
762
|
const byId = new Map(nodes.map((n) => [n.id, n]));
|
|
763
|
+
const ids = new Set(node.area ? node.members : [node.id]); // an area: the work touching any of its nodes, once per piece of work and rel
|
|
576
764
|
const out = [];
|
|
765
|
+
const seen = new Set();
|
|
577
766
|
for (const e of edges) {
|
|
578
|
-
if (e.to
|
|
767
|
+
if (!ids.has(e.to) || !Object.hasOwn(REL_WORDS, e.kind) || seen.has(`${e.from}|${e.kind}`)) continue;
|
|
768
|
+
seen.add(`${e.from}|${e.kind}`);
|
|
579
769
|
const from = byId.get(e.from);
|
|
580
770
|
if (from && from.work) out.push({ rel: REL_WORDS[e.kind][1], id: from.id, label: from.label, work: from.work, waiting: from.waiting });
|
|
581
771
|
}
|
|
@@ -608,6 +798,8 @@ export function arrowTarget(nodes, from, key) {
|
|
|
608
798
|
|
|
609
799
|
/** What a screen reader hears when the keyboard lands on a node of the Work view: its name, its kind and state, what waits, and its place in the lanes */
|
|
610
800
|
export function landingWords(node, index, count) {
|
|
801
|
+
const size = node.drawn ?? node.size;
|
|
802
|
+
if (node.area && !(node.self && size === 1)) return `${node.label}, area${node.planned ? ', planned' : ''}, ${size} ${size === 1 ? 'node' : 'nodes'} of it touched by ${node.touches || 0} ${node.touches === 1 ? 'piece' : 'pieces'} of work, ${node.open ? 'open' : 'closed'}, ${index + 1} of ${count}`;
|
|
611
803
|
if (!node.work) return `${node.label}, code${node.planned ? ', planned' : ''}, ${node.touches || 0} ${node.touches === 1 ? 'piece' : 'pieces'} of work touch it, ${index + 1} of ${count}`;
|
|
612
804
|
const item = node.item;
|
|
613
805
|
return `${node.label}, ${KIND_WORDS[item.kind].toLowerCase()}${node.draft ? ' (a local draft)' : ''}, ${stateWordsOf(item).toLowerCase()}${node.waiting ? ', waiting on you' : ''}, ${index + 1} of ${count}`;
|
|
@@ -648,7 +840,7 @@ export function nodeForAddress(ask, nodes) {
|
|
|
648
840
|
const hit = ask.kind === 'proposal'
|
|
649
841
|
? mine.find((n) => n.item.slug === ask.key) || mine.find((n) => specNumber(text(n.item.slug)) === ask.key)
|
|
650
842
|
: ask.kind === 'run' ? mine.find((n) => n.item.runId === ask.key) : ask.kind === 'deploy' ? mine.find((n) => n.item.deployId === ask.key) : mine.find((n) => String(n.item.number) === ask.key);
|
|
651
|
-
return hit ? hit.id : null;
|
|
843
|
+
return hit ? hit.foldedInto || hit.id : null; // a thread folded into its proposal: the proposal (spec 0015 D2)
|
|
652
844
|
}
|
|
653
845
|
|
|
654
846
|
/** The address a node of work has in the page (`?pr=27`), so a link can be given; null for a node that has none (a deploy) */
|
|
@@ -675,21 +867,40 @@ export function openedWords({ work, code, waiting }) {
|
|
|
675
867
|
// ---------------------------------------------------------------------------
|
|
676
868
|
|
|
677
869
|
/** What the Work view keeps on the state (`state.work`): the answer, the scene made of it, the layers, the toggle, and the map it stands in for while it is open */
|
|
678
|
-
export const newWorkState = () => ({ status: 'idle', graph: null, nodes: [], edges: [], lanes: [], counts: { work: 0, code: 0, waiting: 0 }, problems: [], badges: new Map(), layers: startLayers(), waiting: false, saved: null, bounds: null, fit: null, order: [], updating: false, stale: '', lastError: '' });
|
|
870
|
+
export const newWorkState = () => ({ status: 'idle', graph: null, nodes: [], edges: [], open: null, lanes: [], counts: { work: 0, code: 0, waiting: 0 }, problems: [], badges: new Map(), layers: startLayers(), waiting: false, saved: null, bounds: null, fit: null, order: [], updating: false, stale: '', lastError: '' });
|
|
679
871
|
|
|
680
|
-
/** Makes the scene of an answer (`workScene`), keeps the node a selection named, and sets the filters; the layout is `applyWorkLayout`'s */
|
|
681
|
-
export function setWorkGraph(state, graph, mapNodes) {
|
|
872
|
+
/** Makes the scene of an answer (`workScene`), keeps the node a selection named and the area that was open, and sets the filters; the layout is `applyWorkLayout`'s */
|
|
873
|
+
export function setWorkGraph(state, graph, mapNodes, mapEdges = []) {
|
|
682
874
|
const w = state.work || (state.work = newWorkState());
|
|
683
|
-
const scene = workScene(graph, mapNodes);
|
|
875
|
+
const scene = workScene(graph, mapNodes, mapEdges);
|
|
876
|
+
if (w.open && !scene.nodes.some((n) => n.area && n.id === w.open)) w.open = null;
|
|
684
877
|
w.graph = graph;
|
|
685
878
|
w.nodes = scene.nodes;
|
|
686
879
|
w.edges = scene.edges;
|
|
687
880
|
w.counts = scene.counts;
|
|
688
881
|
w.problems = Array.isArray(graph && graph.problems) ? graph.problems : [];
|
|
689
|
-
applyFilters(w.nodes, w.edges, { layers: w.layers, waiting: w.waiting });
|
|
882
|
+
applyFilters(w.nodes, w.edges, { layers: w.layers, waiting: w.waiting, open: w.open });
|
|
690
883
|
return w;
|
|
691
884
|
}
|
|
692
885
|
|
|
886
|
+
/** The area a node of code is in, or the area itself; null for a piece of work */
|
|
887
|
+
export const areaFor = (node) => (node && !node.work && (node.area ? node.id : node.areaId)) || null;
|
|
888
|
+
|
|
889
|
+
/**
|
|
890
|
+
* Opens an area of the code column in place, or closes it (`id` null): its nodes are shown under it and the others' stay closed (spec 0015 D1). Sets the filters and
|
|
891
|
+
* the lines the scene walks; the page lays the view out again (`applyWorkLayout`). Whether anything changed.
|
|
892
|
+
*/
|
|
893
|
+
export function setOpenArea(state, id) {
|
|
894
|
+
const w = state.work;
|
|
895
|
+
if (!w) return false;
|
|
896
|
+
const next = id && w.nodes.some((n) => n.area && n.id === id) ? id : null;
|
|
897
|
+
if (w.open === next) return false;
|
|
898
|
+
w.open = next;
|
|
899
|
+
applyFilters(w.nodes, w.edges, { layers: w.layers, waiting: w.waiting, open: w.open });
|
|
900
|
+
if (state.workLayers) state.edges = drawnEdges(w.nodes, w.edges, w.open);
|
|
901
|
+
return true;
|
|
902
|
+
}
|
|
903
|
+
|
|
693
904
|
/** Puts the Work view's nodes on the state, keeping the map's to put back (`leaveWork`) */
|
|
694
905
|
export function enterWork(state) {
|
|
695
906
|
const w = state.work || (state.work = newWorkState());
|
|
@@ -702,7 +913,7 @@ export function showWork(state) {
|
|
|
702
913
|
const w = state.work;
|
|
703
914
|
state.workEdge = workEdge; // the scene draws the Work view's lines with it (scene.js)
|
|
704
915
|
state.nodes = w.nodes;
|
|
705
|
-
state.edges = w.edges;
|
|
916
|
+
state.edges = drawnEdges(w.nodes, w.edges, w.open); // a line to a closed area ends at the area (spec 0015 D1)
|
|
706
917
|
state.rings = { rings: [], clusters: [] };
|
|
707
918
|
state.workLayers = w.layers; // set only while the view is open (leaveWork clears it): the layer code reads its presence as the Work view
|
|
708
919
|
state.workRows = layerRowsOf(w.nodes);
|