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.
Files changed (43) hide show
  1. package/core/release-notes.js +2 -2
  2. package/explorer/css/changes.css +3 -7
  3. package/explorer/css/header.css +15 -0
  4. package/explorer/css/layers.css +11 -2
  5. package/explorer/css/map.css +27 -0
  6. package/explorer/css/node-panel.css +45 -0
  7. package/explorer/css/page.css +2 -7
  8. package/explorer/css/proposal.css +2 -3
  9. package/explorer/css/work.css +7 -7
  10. package/explorer/engine/hint.js +7 -7
  11. package/explorer/engine/keyboard.js +5 -4
  12. package/explorer/engine/map-rect.js +2 -2
  13. package/explorer/engine/render.js +2 -1
  14. package/explorer/forge-panel-model.js +24 -0
  15. package/explorer/history-model.js +93 -12
  16. package/explorer/history-replay.js +318 -0
  17. package/explorer/history.js +40 -9
  18. package/explorer/index.html +7 -1
  19. package/explorer/instance-state.js +1 -0
  20. package/explorer/page.js +3 -0
  21. package/explorer/panel-model.js +103 -0
  22. package/explorer/panel-sections.js +140 -0
  23. package/explorer/pieces/layers.js +27 -6
  24. package/explorer/pieces/node-panel.js +80 -1
  25. package/explorer/pieces/search.js +22 -9
  26. package/explorer/pieces/work-deploys.js +13 -13
  27. package/explorer/pieces/work-issues.js +10 -5
  28. package/explorer/pieces/work-list.js +72 -9
  29. package/explorer/pieces/work-paint.js +45 -10
  30. package/explorer/pieces/work-prs.js +46 -34
  31. package/explorer/pieces/work-runs.js +17 -5
  32. package/explorer/pieces/work-specs.js +24 -4
  33. package/explorer/pieces/work-threads.js +59 -15
  34. package/explorer/pieces/work.js +6 -3
  35. package/explorer/proposal-model.js +3 -6
  36. package/explorer/runs-view.js +42 -8
  37. package/explorer/scene.js +35 -1
  38. package/explorer/work-model.js +266 -55
  39. package/explorer/work-view.css +9 -16
  40. package/explorer/work-view.js +107 -34
  41. package/package.json +1 -1
  42. package/server/server.js +1 -1
  43. package/server/work-graph.js +5 -5
@@ -1,11 +1,4 @@
1
- /* The Work view (explorer/work-view.js, spec 0012): the toggles at the top left of the stage (All work, Waiting on you, List), the line of what could not be read, and the node panel's work detail. */
2
- .hx-work-bar { position: absolute; z-index: 4; left: var(--corn-space-4); top: var(--corn-space-4); display: flex; gap: var(--corn-space-2); }
3
- .hx-work-bar { align-items: center; }
4
- .hx-work-bar[hidden] { display: none; }
5
- .hx-work-chip { box-sizing: border-box; min-height: 2rem; padding: 0 var(--corn-space-4); border: var(--corn-border) solid var(--corn-line); border-radius: var(--corn-radius-pill); background: var(--corn-surface-1); color: var(--corn-text-2); font-family: inherit; font-size: var(--corn-text-xs); font-weight: 600; cursor: pointer; }
6
- .hx-work-chip[aria-pressed="true"], .hx-work-chip[aria-expanded="true"] { background: var(--corn-accent); border-color: var(--corn-accent); color: var(--corn-text-on-accent); }
7
- .hx-work-chip[hidden] { display: none; }
8
- .hx-work-chip:focus-visible { outline: var(--corn-focus-width) solid var(--corn-focus); outline-offset: var(--corn-focus-offset); }
1
+ /* The Work view (explorer/work-view.js, spec 0012): the line of what could not be read, and the node panel's work detail. Its controls (Waiting on you, List) are the header's (css/header.css, spec 0015 D5). */
9
2
  .hx-work-note { position: absolute; z-index: 3; left: var(--corn-space-4); bottom: var(--corn-space-4); max-width: min(32rem, calc(100% - var(--corn-space-8))); margin: 0; padding: var(--corn-space-2) var(--corn-space-3); border-radius: var(--corn-radius); background: var(--corn-surface-1); color: var(--corn-text-2); font-size: var(--corn-text-xs); }
10
3
  .hx-work-note[hidden] { display: none; }
11
4
  .hx-view-badge { margin-left: var(--corn-space-2); }
@@ -18,34 +11,34 @@
18
11
  .hx-work-head, .hx-work-actions { display: flex; flex-direction: column; gap: var(--corn-space-2); margin: var(--corn-space-3) 0; }
19
12
  .hx-work-pills { display: flex; flex-wrap: wrap; gap: var(--corn-space-2); margin: 0; }
20
13
  .hx-work-actions .hx-foot-btn { align-self: flex-start; }
21
- /* The lanes' titles: lines over the map, in screen space (work-view.js `paintLanes`), so they read at any zoom */
14
+ /* The lanes' titles: lines over the map, in screen space (work-view.js `paintLanes`), so they read at any zoom; held at the map's top while their lane is in view */
22
15
  .hx-work-lanes { position: absolute; inset: 0; z-index: 2; overflow: hidden; pointer-events: none; }
23
16
  .hx-work-lanes[hidden] { display: none; }
24
17
  .hx-work-lane-title { position: absolute; display: flex; gap: var(--corn-space-2); align-items: baseline; max-width: 100%; overflow: hidden; white-space: nowrap; font-size: var(--corn-text-xs); font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--corn-text-2); }
25
- .hx-work-lane-title.is-held { padding: 0 var(--corn-space-2); border-radius: var(--corn-radius-sm); background: color-mix(in srgb, var(--corn-surface-1) 85%, transparent); } /* held under the toggles over the lane's nodes: a ground of its own */
18
+ .hx-work-lane-title.is-held { padding: 0 var(--corn-space-2); border-radius: var(--corn-radius-sm); background: color-mix(in srgb, var(--corn-surface-1) 85%, transparent); } /* held at the top over the lane's nodes: a ground of its own */
26
19
  .hx-work-lane-title > :first-child { overflow: hidden; text-overflow: ellipsis; }
27
20
  .hx-work-lane-count { flex: none; font-weight: 600; letter-spacing: 0; }
28
- .hx-work-busy { margin-left: var(--corn-space-2); font-size: var(--corn-text-xs); color: var(--corn-text-2); }
21
+ .hx-work-busy { font-size: var(--corn-text-xs); color: var(--corn-text-2); white-space: nowrap; }
29
22
  .hx-work-busy[hidden] { display: none; }
30
23
  /* While the first answer is on its way: the lanes, empty, with the words; nothing on the page waits for it */
31
24
  .hx-work-loading { position: absolute; z-index: 2; inset: 0; pointer-events: none; }
32
25
  .hx-work-loading[hidden] { display: none; }
33
- .hx-work-skeleton { position: absolute; left: var(--corn-space-4); right: var(--corn-space-4); top: 3.5rem; bottom: var(--corn-space-6); display: grid; grid-template-columns: repeat(4, 1fr) 1.6fr; gap: var(--corn-space-3); }
26
+ .hx-work-skeleton { position: absolute; left: var(--corn-space-4); right: var(--corn-space-4); top: var(--corn-space-4); bottom: var(--corn-space-6); display: grid; grid-template-columns: repeat(4, 1fr) 1.6fr; gap: var(--corn-space-3); }
34
27
  .hx-work-skel-lane { display: flex; flex-direction: column; gap: var(--corn-space-4); padding: var(--corn-space-3); border: var(--corn-border) solid var(--corn-line); border-radius: var(--corn-radius); background: color-mix(in srgb, var(--corn-surface-1) 55%, transparent); }
35
28
  .hx-work-skel-lane .hx-work-lane-title { position: static; }
36
29
  .hx-work-skel-lane i { display: block; height: 2.25rem; border-radius: var(--corn-radius-sm); background: var(--corn-surface-3); opacity: 0.7; animation: hx-work-pulse 1.6s ease-in-out infinite; }
37
30
  .hx-work-skel-lane i:nth-of-type(2) { animation-delay: 0.2s; width: 80%; }
38
31
  .hx-work-skel-lane i:nth-of-type(3) { animation-delay: 0.4s; width: 65%; }
39
32
  .hx-work-skel-lane i:nth-of-type(4) { animation-delay: 0.6s; width: 90%; }
33
+ /* The lanes' titles hold the map's top line in the Work view, where the hint would sit */
34
+ .hx-stage.is-work .hx-hint { display: none; }
40
35
  @keyframes hx-work-pulse { 0%, 100% { opacity: 0.35; } 50% { opacity: 0.8; } }
41
36
  @media (prefers-reduced-motion: reduce) { .hx-work-skel-lane i { animation: none; opacity: 0.6; } }
42
37
  .hx-work-loading-text { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(26rem, calc(100% - var(--corn-space-8))); margin: 0; padding: var(--corn-space-3) var(--corn-space-4); border-radius: var(--corn-radius); border: var(--corn-border) solid var(--corn-line); background: var(--corn-surface-1); color: var(--corn-text); font-size: var(--corn-text-sm); text-align: center; box-shadow: var(--corn-shadow); }
43
38
  @container corn-box (max-width: 767px) {
44
- /* The Layers chip and Fit sit on the map's top row (layers.css, header.css); the toggles go on the row under them, and the lanes run top to bottom */
45
- .hx-work-bar { top: calc(var(--corn-space-4) + var(--hx-control-h) + var(--corn-space-3)); }
39
+ /* The Layers chip, the view's controls and Fit sit on the map's top row (layers.css, header.css); the lanes run top to bottom under it */
46
40
  .hx-work-note { bottom: var(--corn-space-4); }
47
- .hx-stage.is-work .hx-hint { display: none; } /* the toggles' row is where the hint would sit */
48
- .hx-work-skeleton { grid-template-columns: 1fr; grid-auto-rows: min-content; top: calc(var(--corn-space-4) + var(--hx-control-h) * 2 + var(--corn-space-6)); overflow: hidden; }
41
+ .hx-work-skeleton { grid-template-columns: 1fr; grid-auto-rows: min-content; top: calc(var(--corn-space-4) + var(--hx-control-h) + var(--corn-space-4)); overflow: hidden; }
49
42
  .hx-work-skel-lane i:nth-of-type(n + 3) { display: none; }
50
43
  }
51
44
  /* The Layers menu in the Work view lists the Work view's rows; the map's keys (its kinds of line, the cloud's, the runs' and the proposal marks') are about the map */
@@ -10,13 +10,15 @@
10
10
  * followWorkAddress() `?view=work`, `?pr=`, `?issue=`, `?run=`, `?thread=` and `?spec=` (work-model.js `workAddress`): the node, or for work older than the graph's
11
11
  * 14 days the Work list and the node panel (pieces/work-list.js `showRef`)
12
12
  *
13
- * What it puts on the page: the view switch's Work button, with "waiting on you" as its badge, the toggles at the top left of the stage ("All work", "Waiting on you" and
14
- * **List**, which opens the Work list (pieces/work-list.js) where the side panel sat), the lanes' titles in screen space (the map draws the lanes' panels), the words
13
+ * What it puts on the page: the view switch's Work button, with "waiting on you" as its badge, the view's controls in the header after the View switch (spec 0015 D5:
14
+ * **Waiting on you**, a toggle, off for all the work, and **List**, which opens the Work list (pieces/work-list.js)), the lanes' titles in screen space (the map draws the lanes' panels), the words
15
15
  * and the empty lanes shown at once while the first answer is on its way (the page stays usable: the views, the Layers menu, search), "Updating…" while a refresh
16
16
  * is (the last answer stays on the map, and a refresh that fails keeps it and says so), the map's own card when the answer is refused (signed out, not a maintainer,
17
17
  * offline: pieces/status.js), and a quiet line naming what the server could not read (`problems`). It answers the node panel's `work:panel` ask with what a node says in
18
18
  * the Work view (the Work piece draws the actions into it), the Work list's `work:pick` ask by selecting that row's node, and holds the keys of the view: N and P step through
19
- * the lanes, an arrow goes to the nearest node that way. Every request goes through `credentialed`;
19
+ * the lanes, an arrow goes to the nearest node that way. The code column holds one node per area (spec 0015 D1): selecting an area opens it in place, a tap on it again
20
+ * or clearing the selection (Escape) closes it, and selecting a node of code (a search, an address, the keyboard) opens its area; a thread folded into its proposal
21
+ * (spec 0015 D2) selects the proposal. Every request goes through `credentialed`;
20
22
  * every word that comes from the forge is escaped or set as text, every link goes through `safeUrl` (work-model.js).
21
23
  *
22
24
  * The **Work layer** of the Map view (spec 0012 D4, work-badge-model.js and work-badges.js) shares this file's one read of the graph: turning the layer on asks for it only when the
@@ -45,7 +47,7 @@ import { stepFrom } from './keyboard-model.js';
45
47
  import { RUNS_POLL_MS } from './pieces/work-common.js';
46
48
  import { showWorkRef, openForge, closeForge } from './forge-panel.js';
47
49
  import {
48
- CODE_LAYER, DRAFT_LAYER, KIND_WORDS, addressOf, applyFilters, arrowTarget, landingWords, applyWorkLayout, codePanelHtml, layerRowsOf, newWorkState, nodeForAddress, openedWords, panelOf, setWorkGraph, showWork, touchedBy, workAddress, workPanelHtml,
50
+ 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,
49
51
  } from './work-model.js';
50
52
 
51
53
  const GRAPH_URL = '/api/forge/work-graph';
@@ -53,7 +55,7 @@ const $ = (id) => document.getElementById(id);
53
55
 
54
56
  let wired = false;
55
57
  let offered = false;
56
- let els = null; // { stage, bar, all, waiting, busy, note, lanes, loading }
58
+ let els = null; // { stage, bar (the header's group of the view's controls), waiting, list, busy, note, lanes, loading }
57
59
  let laneEls = []; // the lanes' titles on the stage, in screen space: [{ el, name, count }]
58
60
  let laneKey = null; // the lanes they were made for
59
61
  let offPaint = null;
@@ -90,6 +92,8 @@ export function initWorkView(opts = {}) {
90
92
  i.on('work:available', ({ on: available }) => { paintList(available); i.emit('layers:redraw'); syncBadges(); });
91
93
  i.on('work:panel', (node) => panelFor(node));
92
94
  i.on('work:pick', (ref) => pickRef(ref));
95
+ i.on('selection', onSelection);
96
+ i.on('select', onTap);
93
97
  mapStyleOf(i).onChange(() => { paintEdgeColors(); if (on()) { state.workRows = layerRowsOf(work().nodes).map(themed); i.emit('layers:redraw'); i.touchScene(); render(); } });
94
98
  }
95
99
  state.workRow = () => (offered && inst().ask('work:on') ? badgeRowOf(work(), badgeColor('pull')) : null); // the Layers menu's row under Overlays (engine/layers.js `layerRows`)
@@ -125,18 +129,27 @@ function paintBadge(total) {
125
129
  // ---------------------------------------------------------------------------
126
130
  // The page's parts
127
131
  // ---------------------------------------------------------------------------
132
+ /** The header's group for the view's own controls (index.html, spec 0015 D5); a page without it gets one after the View switch, else over the map */
133
+ function controlsSlot(stage) {
134
+ const slot = document.querySelector('[data-corn="view-controls"]');
135
+ if (slot) return slot;
136
+ const made = document.createElement('div');
137
+ made.className = 'hx-view-controls';
138
+ made.dataset.corn = 'view-controls';
139
+ made.setAttribute('role', 'group');
140
+ made.setAttribute('aria-label', 'Work view');
141
+ const view = document.querySelector('[data-corn="view-switch"]');
142
+ if (view) view.after(made); else stage.append(made);
143
+ return made;
144
+ }
145
+
128
146
  function mount() {
129
147
  const stage = state.canvas ? state.canvas.parentElement : null;
130
- if (!stage || (els && els.stage === stage && stage.contains(els.bar))) return;
131
- const bar = document.createElement('div');
132
- bar.className = 'hx-work-bar';
133
- bar.dataset.corn = 'work-bar';
134
- bar.setAttribute('role', 'group');
135
- bar.setAttribute('aria-label', 'Show');
148
+ if (!stage || (els && els.stage === stage && els.bar.isConnected && stage.contains(els.lanes))) return;
149
+ const bar = controlsSlot(stage);
136
150
  bar.hidden = true;
137
- bar.innerHTML = '<button type="button" class="hx-work-chip" data-corn="work-chip" data-corn-kind="quiet" data-work-show="all" aria-pressed="true">All work</button>'
138
- + '<button type="button" class="hx-work-chip" data-corn="work-chip" data-corn-kind="quiet" data-work-show="waiting" aria-pressed="false">Waiting on you</button>'
139
- + '<button type="button" class="hx-work-chip" data-corn="work-chip" data-corn-kind="quiet" 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>'
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>'
152
+ + '<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>'
140
153
  + '<span class="hx-work-busy" hidden>Updating…</span>';
141
154
  const note = document.createElement('p');
142
155
  note.className = 'hx-work-note';
@@ -155,8 +168,8 @@ function mount() {
155
168
  loading.hidden = true;
156
169
  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>`
157
170
  + '<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>';
158
- stage.append(lanes, loading, bar, note);
159
- els = { stage, bar, all: bar.children[0], waiting: bar.children[1], list: bar.children[2], busy: bar.children[3], note, lanes, loading };
171
+ stage.append(lanes, loading, note);
172
+ els = { stage, bar, waiting: bar.children[0], list: bar.children[1], busy: bar.children[2], note, lanes, loading };
160
173
  paintList(!!inst().ask('work:on')); // the List toggle is there while the Work piece is on: a signed-in maintainer of a forge
161
174
  if (offPaint) offPaint();
162
175
  if (badges) badges.destroy();
@@ -188,7 +201,7 @@ function watchSize(stage) {
188
201
  }).observe(stage);
189
202
  }
190
203
 
191
- /** The lanes' titles, over the map in screen space: centred over their lane and held under the toggles while the lane is in view (a phone's: at the lane's top left) */
204
+ /** The lanes' titles, over the map in screen space: centred over their lane and held at the map's top while the lane is in view (a phone's: at the lane's top left, under the controls on the map) */
192
205
  function paintLanes(scene, camera) {
193
206
  if (!els) return;
194
207
  const w = work();
@@ -212,13 +225,13 @@ function paintLanes(scene, camera) {
212
225
  });
213
226
  }
214
227
  const phone = isPhone();
215
- const top = phone ? STICKY_TOP_PHONE : STICKY_TOP;
228
+ const top = phone ? phoneTop() : STICKY_TOP;
216
229
  for (const { el, lane } of laneEls) {
217
230
  const left = camera.x + lane.x * camera.zoom;
218
231
  const right = left + lane.w * camera.zoom;
219
232
  const topPx = camera.y + lane.y * camera.zoom;
220
233
  const bottomPx = topPx + lane.h * camera.zoom;
221
- // a phone's title stays at its lane's top and goes when that is under the toggles; a desktop's is held under them while the lane is in view
234
+ // a phone's title stays at its lane's top and goes when that is under the controls on the map; a desktop's is held at the map's top while the lane is in view
222
235
  const seen = right > 0 && left < els.stage.clientWidth && bottomPx > 40 && topPx < els.stage.clientHeight && !(phone && topPx + 8 < top);
223
236
  el.style.visibility = seen ? 'visible' : 'hidden';
224
237
  if (!seen) continue;
@@ -229,18 +242,22 @@ function paintLanes(scene, camera) {
229
242
  if (phone) { el.style.left = `${Math.round(Math.max(left, 0) + 10)}px`; el.style.transform = 'none'; } else { el.style.left = `${Math.round((left + right) / 2)}px`; el.style.transform = 'translateX(-50%)'; }
230
243
  }
231
244
  }
232
- /** The line the lanes' titles hold under, in px from the top of the stage: below the toggles (a phone's are on a second row, under the Layers chip) */
233
- const STICKY_TOP = 58;
234
- const STICKY_TOP_PHONE = 108;
245
+ /** The line the lanes' titles hold under, in px from the top of the stage: the map's top, now that the view's controls are in the header (spec 0015 D5) */
246
+ const STICKY_TOP = 12;
247
+ /** A phone's: under the row the Layers chip and the view's controls sit on, on the map (measured: the controls wrap to a second row when the words are long) */
248
+ const STICKY_TOP_PHONE = 72;
249
+ function phoneTop() {
250
+ const tools = document.querySelector('.hx-view-tools');
251
+ if (!tools || !els) return STICKY_TOP_PHONE;
252
+ const bottom = tools.getBoundingClientRect().bottom - els.stage.getBoundingClientRect().top;
253
+ return bottom > 0 ? Math.round(bottom + 12) : STICKY_TOP_PHONE;
254
+ }
235
255
 
236
256
  function paintBar() {
237
257
  if (!els) return;
238
258
  const w = work();
239
- const n = w.counts.waiting;
240
259
  els.bar.hidden = !on();
241
- els.all.setAttribute('aria-pressed', String(!w.waiting));
242
- els.waiting.setAttribute('aria-pressed', String(w.waiting));
243
- els.waiting.textContent = `Waiting on you · ${n}`;
260
+ els.waiting.setAttribute('aria-pressed', String(!!w.waiting)); // the Work button's badge says how many; the toggle says only that it is on
244
261
  els.busy.hidden = !(on() && w.status === 'ok' && w.updating);
245
262
  els.loading.hidden = !(on() && w.status === 'loading');
246
263
  const lines = [...(w.stale ? [w.stale] : []), ...(w.lastError ? [w.lastError] : []), ...w.problems.map((p) => p.text)];
@@ -432,8 +449,9 @@ function arrive(body, { select, ask, quiet }) {
432
449
  const first = w.status !== 'ok';
433
450
  const before = state.selectedNode ? state.selectedNode.id : null;
434
451
  const base = state.baseNodes && state.baseNodes.length ? state.baseNodes : (w.saved ? w.saved.nodes : state.nodes);
452
+ const baseEdges = state.baseNodes && state.baseNodes.length ? state.baseEdges : (w.saved ? w.saved.edges : state.edges); // its ownership edges say which area a node is in
435
453
  const had = w.badges ? w.badges.size : -1;
436
- setWorkGraph(state, body, base);
454
+ setWorkGraph(state, body, base, baseEdges);
437
455
  w.badges = badgeIndex(w.nodes, w.edges);
438
456
  w.status = 'ok';
439
457
  w.updating = false;
@@ -495,7 +513,8 @@ function themed(row) {
495
513
  function refilter() {
496
514
  if (!on()) return;
497
515
  const w = work();
498
- applyFilters(w.nodes, w.edges, { layers: w.layers, waiting: w.waiting });
516
+ applyFilters(w.nodes, w.edges, { layers: w.layers, waiting: w.waiting, open: w.open });
517
+ state.edges = drawnEdges(w.nodes, w.edges, w.open); // an open area's ties to the nodes it shows
499
518
  const sel = state.selectedNode;
500
519
  applyWorkLayout(state, { phone: isPhone() });
501
520
  state.workRows = layerRowsOf(w.nodes).map(themed);
@@ -507,19 +526,74 @@ function refilter() {
507
526
 
508
527
  /** Selects a node of the view by id: the panel opens, the camera follows (as a search's choice does) */
509
528
  export function pick(id, { frame = true, source = 'link' } = {}) {
510
- const node = state.nodes.find((n) => n.id === id);
529
+ let node = state.nodes.find((n) => n.id === id);
530
+ if (node && node.foldedInto) node = state.nodes.find((n) => n.id === node.foldedInto); // a spec pull request's thread: its proposal (spec 0015 D2)
511
531
  if (!node) return false;
512
- if (node.hidden) { work().layers[node.draft ? DRAFT_LAYER : node.work ? `work-${node.work}` : CODE_LAYER] = true; refilter(); }
532
+ const layer = node.draft ? DRAFT_LAYER : node.work ? `work-${node.work}` : CODE_LAYER;
533
+ if (node.hidden && work().layers[layer] === false) { work().layers[layer] = true; refilter(); }
534
+ openAreaOf(node); // a node of code: its area opens in place (spec 0015 D1)
513
535
  selectNode(inst(), node, { frame, source });
514
536
  return true;
515
537
  }
516
538
 
517
- /** "Waiting on you" on or off: everything that does not wait is dimmed (spec 0012 D3) */
539
+ // ---------------------------------------------------------------------------
540
+ // The code column's areas (spec 0015 D1): one open at a time, in place
541
+ // ---------------------------------------------------------------------------
542
+
543
+ /** Opens an area (null: closes the open one) and lays the view out again where it is: the camera stays, and what is open is said */
544
+ function openArea(id, { say = true } = {}) {
545
+ if (!on() || work().status !== 'ok' || !setOpenArea(state, id)) return false;
546
+ applyWorkLayout(state, { phone: isPhone() });
547
+ state.workRows = layerRowsOf(work().nodes).map(themed);
548
+ inst().touchScene();
549
+ render();
550
+ if (say) {
551
+ const area = id ? work().nodes.find((n) => n.id === id) : null;
552
+ if (area) announce(inst(), `${area.label} open: ${area.drawn} ${area.drawn === 1 ? 'node' : 'nodes'} of code.`);
553
+ }
554
+ return true;
555
+ }
556
+
557
+ /** The area of a node of code, opened (a search's choice, an address, a step of the keyboard to it); nothing for a piece of work */
558
+ function openAreaOf(node) {
559
+ const id = areaFor(node);
560
+ if (id && id !== work().open) openArea(id, { say: false });
561
+ }
562
+
563
+ /** Moments ago, the selection opened this area: the tap that chose it is not a second press (`onTap`) */
564
+ let opened = null;
565
+
566
+ /**
567
+ * The selection changed. A node of code opens its area; nothing selected (Escape, a click on the background) closes it; a thread folded into its proposal
568
+ * selects the proposal (spec 0015 D2: it is not drawn, the proposal stands for it).
569
+ */
570
+ function onSelection({ node: picked }) {
571
+ if (!on() || work().status !== 'ok') return;
572
+ if (!picked) { openArea(null); return; }
573
+ const node = work().nodes.find((n) => n.id === picked.id); // the view's own node (a tap names the scene's)
574
+ if (!node) return;
575
+ if (node.foldedInto) { const into = state.nodes.find((n) => n.id === node.foldedInto); if (into) selectNode(inst(), into, { frame: true, source: 'link' }); return; }
576
+ const id = areaFor(node);
577
+ if (!id || id === work().open) return;
578
+ openArea(id, { say: false });
579
+ if (node.area) { opened = id; queueMicrotask(() => { opened = null; }); }
580
+ }
581
+
582
+ /** A tap on the map's node: on the area that is selected already, it opens or closes it (the first tap selected it, and the selection opened it) */
583
+ function onTap(picked) {
584
+ const node = picked && on() ? work().nodes.find((n) => n.id === picked.id) : null;
585
+ if (!node || !node.area) return;
586
+ if (opened === node.id) { opened = null; return; }
587
+ if (!state.selectedNode || state.selectedNode.id !== node.id) return; // the selection opens it
588
+ if (openArea(work().open === node.id ? null : node.id)) inst().emit('node:show', { node: state.selectedNode, frame: false }); // the panel's lines say what is drawn now
589
+ }
590
+
591
+ /** "Waiting on you" on or off (off is all the work): everything that does not wait is dimmed (spec 0012 D3, 0015 D5) */
518
592
  function setWaiting(on_) {
519
593
  const w = work();
520
594
  if (w.waiting === on_) return;
521
595
  w.waiting = on_;
522
- applyFilters(w.nodes, w.edges, { layers: w.layers, waiting: w.waiting });
596
+ applyFilters(w.nodes, w.edges, { layers: w.layers, waiting: w.waiting, open: w.open });
523
597
  inst().touchScene();
524
598
  paintBar();
525
599
  render();
@@ -588,8 +662,7 @@ function onClick(e) {
588
662
  if (!t_) return;
589
663
  if (t_.closest('[data-action="preset-work"]')) { if (on()) closeWork(); else openWork(); return; }
590
664
  if (t_.closest('[data-action="refresh-forge"]') && on()) { load({ again: true }); return; }
591
- const show = t_.closest('[data-work-show]');
592
- if (show && on()) { setWaiting(show.dataset.workShow === 'waiting'); return; }
665
+ if (t_.closest('[data-work-toggle="waiting"]') && on()) { setWaiting(!work().waiting); return; }
593
666
  const act = t_.closest('[data-work-action]');
594
667
  if (!act) return;
595
668
  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)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cornfield",
3
- "version": "0.61.0",
3
+ "version": "0.63.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)",
package/server/server.js CHANGED
@@ -89,7 +89,7 @@ import { createHistory } from '../core/history.js';
89
89
  export const CORNFIELD_DIR = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
90
90
  const EXPLORER_DIR = path.join(CORNFIELD_DIR, 'explorer');
91
91
  /** The pure core modules the explorer imports (no Node built-ins, no files): the only ones of core/ served */
92
- export const BROWSER_CORE = ['schema.js', 'proposal.js', 'personas.js', 'cloud.js', 'text.js', 'mentions.js', 'color.js', 'strings.js', 'layers.js'];
92
+ export const BROWSER_CORE = ['schema.js', 'proposal.js', 'personas.js', 'cloud.js', 'text.js', 'mentions.js', 'color.js', 'strings.js', 'layers.js', 'release-notes.js'];
93
93
  /** The explorer files the sign-in pages load: cornfield's tokens, their own stylesheet and the script that applies Light or Dark. Served without a session. */
94
94
  const SIGN_IN_FILES = new Set(['/explorer/tokens.css', '/explorer/sign-in.css', '/explorer/theme-boot.js']);
95
95
  /** cornfield's own browser sources, by request path */
@@ -17,7 +17,7 @@
17
17
  * Every node: `{ id, kind, stage, title, state, open, waiting, url, updated, ...}` and its number (`number`), slug (`slug`), run id (`runId`) or
18
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
19
19
  * `specStateOf`, explorer/runs-model.js `canAnswer`): a spec to decide, a run waiting on an answer; nothing else asks the maintainer a question.
20
- * The code a proposal adds, and the map does not hold yet, comes as `{ id, kind: 'code', planned: true, label, type }`; the code that exists is
20
+ * 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
21
  * on the map the page already has, and is only named by edges.
22
22
  *
23
23
  * Rel From -> to Comes from
@@ -115,13 +115,13 @@ const list = (v) => (Array.isArray(v) ? v : []);
115
115
  const text = (v) => (typeof v === 'string' ? v : '');
116
116
 
117
117
  /**
118
- * What a proposal does to the map: the nodes it adds (`{ id, label, type }`), and the ids it changes or removes. Anything that is not a proposal does nothing.
118
+ * What a proposal does to the map: the nodes it adds (`{ id, label, type, parent }`: the page groups a planned node under the area its parent is in), and the ids it changes or removes. Anything that is not a proposal does nothing.
119
119
  * @param {any} proposal
120
- * @returns {{ adds: { id: string, label: string, type: string | null }[], changes: string[] }}
120
+ * @returns {{ adds: { id: string, label: string, type: string | null, parent: string | null }[], changes: string[] }}
121
121
  */
122
122
  export function touchesOf(proposal) {
123
123
  const nodes = proposal !== null && typeof proposal === 'object' ? proposal.nodes : null;
124
- const adds = list(nodes && nodes.add).filter((n) => n && typeof n.id === 'string' && n.id !== '').map((n) => ({ id: n.id, label: text(n.label) || n.id, type: text(n.type) || null }));
124
+ const adds = list(nodes && nodes.add).filter((n) => n && typeof n.id === 'string' && n.id !== '').map((n) => ({ id: n.id, label: text(n.label) || n.id, type: text(n.type) || null, parent: text(n.parent) || null }));
125
125
  const changes = [...list(nodes && nodes.change), ...list(nodes && nodes.remove)].map((n) => (typeof n === 'string' ? n : n && n.id)).filter((id) => typeof id === 'string' && id !== '');
126
126
  return { adds, changes: [...new Set(changes)] };
127
127
  }
@@ -501,6 +501,6 @@ export async function workGraph(forge, config, map, { where = config, runs = nul
501
501
  return true;
502
502
  }).sort((a, b) => (a.from < b.from ? -1 : a.from > b.from ? 1 : a.to < b.to ? -1 : a.to > b.to ? 1 : a.rel < b.rel ? -1 : a.rel > b.rel ? 1 : 0));
503
503
  const out = [...nodes.values()].sort((a, b) => KINDS.indexOf(a.kind) - KINDS.indexOf(b.kind) || newest(a, b));
504
- const plannedOut = [...planned.values()].filter((p) => kept.some((e) => e.to === p.id)).sort((a, b) => (a.id < b.id ? -1 : 1)).map((p) => ({ id: p.id, kind: 'code', planned: true, label: p.label, type: p.type }));
504
+ const plannedOut = [...planned.values()].filter((p) => kept.some((e) => e.to === p.id)).sort((a, b) => (a.id < b.id ? -1 : 1)).map((p) => ({ id: p.id, kind: 'code', planned: true, label: p.label, type: p.type, parent: p.parent ?? null }));
505
505
  return { nodes: [...out, ...plannedOut], edges: kept, problems };
506
506
  }