@popcorn245/cornfield 0.62.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 (42) 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 +0 -1
  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 +21 -11
  16. package/explorer/history-replay.js +13 -5
  17. package/explorer/history.js +16 -7
  18. package/explorer/index.html +6 -3
  19. package/explorer/page.js +1 -2
  20. package/explorer/panel-model.js +103 -0
  21. package/explorer/panel-sections.js +140 -0
  22. package/explorer/pieces/layers.js +27 -6
  23. package/explorer/pieces/node-panel.js +78 -1
  24. package/explorer/pieces/search.js +22 -9
  25. package/explorer/pieces/work-deploys.js +13 -13
  26. package/explorer/pieces/work-issues.js +10 -5
  27. package/explorer/pieces/work-list.js +72 -9
  28. package/explorer/pieces/work-paint.js +45 -10
  29. package/explorer/pieces/work-prs.js +46 -34
  30. package/explorer/pieces/work-runs.js +17 -5
  31. package/explorer/pieces/work-specs.js +24 -4
  32. package/explorer/pieces/work-threads.js +59 -15
  33. package/explorer/pieces/work.js +6 -3
  34. package/explorer/proposal-model.js +3 -6
  35. package/explorer/runs-view.js +42 -8
  36. package/explorer/scene.js +5 -1
  37. package/explorer/work-model.js +266 -55
  38. package/explorer/work-view.css +9 -16
  39. package/explorer/work-view.js +107 -34
  40. package/package.json +1 -1
  41. package/server/server.js +1 -1
  42. package/server/work-graph.js +5 -5
@@ -10,6 +10,7 @@ import { nodesForRestarts, deployWords, deployMeta, listUrl } from '../forge-pan
10
10
  import { cornStateAttr, stateIconHtml } from '../corn-state.js';
11
11
  import { escapeHtml as escHtml } from '../../core/text.js';
12
12
  import { plural, safeUrl } from './work-common.js';
13
+ import { sectionHtml } from '../panel-model.js';
13
14
 
14
15
  export function install(ctx) {
15
16
  const { ui, m, fn, state } = ctx;
@@ -71,24 +72,23 @@ export function install(ctx) {
71
72
  }
72
73
 
73
74
  /** The deploy in the node panel: what it was, its logs on the forge, and the nodes it restarted (each a button that selects it on the map) */
74
- function deployDetailHtml() {
75
- if (ui.detailError && !ui.deployItem) return `<p class="hx-forge-notice" data-corn="notice">${escHtml(ui.detailError)}</p>`;
75
+ function deployParts() {
76
+ if (ui.detailError && !ui.deployItem) return { notes: `<p class="hx-forge-notice" data-corn="notice">${escHtml(ui.detailError)}</p>` };
76
77
  const d = ui.deployItem;
77
- if (!d) return '<p class="hx-faint">Loading what it restarted …</p>';
78
+ if (!d) return { notes: '<p class="hx-faint">Loading what it restarted …</p>' };
78
79
  const lit = ui.litDeploy;
79
80
  const url = safeUrl(d.url);
80
- const head = `<p class="hx-forge-meta"><span class="hx-forge-state hx-forge-state--${escHtml(d.state)}" data-corn="state-pill"${cornStateAttr(d.state)}>${stateIconHtml(d.state)}${escHtml(deployWords(d))}</span> ${escHtml(deployMeta(d, m.now()))}</p>
81
- ${url ? `<div class="hx-forge-cta"><a data-corn="open-link" data-corn-kind="secondary" class="hx-btn hx-forge-open" href="${escHtml(url)}" target="_blank" rel="noreferrer">Open the logs on ${escHtml(fn.forgeName())} ↗</a></div>` : ''}`;
81
+ // Its logs are its one action (spec 0015 D4); its state and when are the panel's head, its run's words a line under the bar
82
+ const logs = url ? `<a data-corn="open-link" data-corn-kind="primary" class="hx-btn hx-btn--primary hx-forge-open" href="${escHtml(url)}" target="_blank" rel="noreferrer">Open the logs on ${escHtml(fn.forgeName())} ↗</a>` : '';
83
+ const head = `<p class="hx-forge-meta">${escHtml(deployMeta(d, m.now()))}</p>`; // its state is the panel's one pill
82
84
  const stale = ui.lists.deploys && ui.lists.deploys.stale;
83
- let body;
85
+ const notes = `${head}${stale ? `<p class="hx-forge-notice" data-corn="notice">${escHtml(`This is an older answer. ${stale}`)}</p>` : ''}`;
84
86
  if (!d.restarts.length) {
85
- body = '<p class="hx-forge-notice" data-corn="notice">No node is mapped to this deploy. Say what it restarts under <code class="hx-code">deploys.restarts</code> in cornfield.config.js (docs/deploys.md).</p>';
86
- } else {
87
- const rows = lit.nodes.map((n) => `<li class="hx-forge-file" data-corn="file"><button data-corn="node-chip" type="button" class="hx-forge-node" data-forge-node="${escHtml(n.id)}" aria-label="Show ${escHtml(n.label)} on the map${isNodeVisible(n) ? '' : ' (its layer is off)'}">${escHtml(n.label)}${isNodeVisible(n) ? '' : ' · layer off'}</button> <span class="hx-faint">${escHtml(n.type)}</span></li>`).join('');
88
- const missing = lit.missing.length ? `<p class="hx-forge-notice" data-corn="notice">${escHtml(lit.missing.join(', '))} ${lit.missing.length === 1 ? 'is' : 'are'} named in the config but not on the map.</p>` : '';
89
- body = `<h3 class="hx-forge-sub">${escHtml(`Restarted: ${plural(lit.nodes.length, 'node')} on the map`)}</h3>${rows ? `<ul class="hx-forge-files">${rows}</ul>` : ''}${missing}`;
87
+ return { primary: logs, notes: `${notes}<p class="hx-forge-notice" data-corn="notice">No node is mapped to this deploy. Say what it restarts under <code class="hx-code">deploys.restarts</code> in cornfield.config.js (docs/deploys.md).</p>`, sections: [] };
90
88
  }
91
- return `${head}${stale ? `<p class="hx-forge-notice" data-corn="notice">${escHtml(`This is an older answer. ${stale}`)}</p>` : ''}${body}`;
89
+ const rows = lit.nodes.map((n) => `<li class="hx-forge-file" data-corn="file"><button data-corn="node-chip" type="button" class="hx-forge-node" data-forge-node="${escHtml(n.id)}" aria-label="Show ${escHtml(n.label)} on the map${isNodeVisible(n) ? '' : ' (its layer is off)'}">${escHtml(n.label)}${isNodeVisible(n) ? '' : ' · layer off'}</button> <span class="hx-faint">${escHtml(n.type)}</span></li>`).join('');
90
+ const missing = lit.missing.length ? `<p class="hx-forge-notice" data-corn="notice">${escHtml(lit.missing.join(', '))} ${lit.missing.length === 1 ? 'is' : 'are'} named in the config but not on the map.</p>` : '';
91
+ return { primary: logs, notes, sections: [sectionHtml({ key: 'restarted', title: 'Restarted', count: lit.nodes.length, body: `${rows ? `<ul class="hx-forge-files">${rows}</ul>` : `<p class="hx-faint">${escHtml(plural(0, 'node'))} on the map.</p>`}${missing}` })] };
92
92
  }
93
93
 
94
94
  /** What a screen reader hears when a deploy is selected */
@@ -101,5 +101,5 @@ export function install(ctx) {
101
101
  }
102
102
 
103
103
  // what other parts put in the panel gets its parts (a hook is a part of the same name)
104
- Object.assign(fn, { selectDeploy, showDeploy, clearDeploy, restartWords, deployHtml: (...a) => withParts(deployHtml(...a)), deployDetailHtml: (...a) => withParts(deployDetailHtml(...a)), deploySelectionWords });
104
+ Object.assign(fn, { selectDeploy, showDeploy, clearDeploy, restartWords, deployHtml: (...a) => withParts(deployHtml(...a)), deployParts, deploySelectionWords });
105
105
  }
@@ -8,20 +8,25 @@
8
8
 
9
9
  import { escapeHtml as escHtml } from '../../core/text.js';
10
10
  import { issueUrl, listUrl, listKeyOf, specBlock } from '../forge-panel-model.js';
11
+ import { safeUrl } from './work-common.js';
12
+ import { withParts } from '../engine/piece.js';
11
13
 
12
14
  export function install(ctx) {
13
15
  const { ui, fn } = ctx;
14
16
  const { t } = ctx.h;
15
17
 
16
18
  /** An issue's actions in the node panel: Start a spec (step 1 of the pipeline) and Start an agent, each opening its confirm step; a closed issue has none */
17
- function issueActionsHtml(item) {
19
+ // (spec 0015 D4: Start an agent is the primary action of an open issue, Start a spec and Open on the forge beside it; a closed one has only its link, and the Next line says why)
20
+ function issueParts(item) {
18
21
  const n = item.number;
19
- if (!item.open) return `<p class="hx-faint">${escHtml(specBlock({ state: 'closed' }))}</p>`;
22
+ const url = safeUrl(item.url);
23
+ const out = url ? withParts(`<a class="hx-btn hx-btn--quiet hx-foot-btn" data-corn-kind="quiet" data-corn="open-link" href="${escHtml(url)}" target="_blank" rel="noreferrer">Open on the forge ↗</a>`) : '';
24
+ if (!item.open) return { primary: '', others: [out], next: specBlock({ state: 'closed' }) };
20
25
  const spec = specBlock({ state: 'open' }) === null
21
26
  ? `<button data-corn-kind="secondary" type="button" class="hx-btn hx-forge-act hx-forge-startspec" data-forge-spec="${n}" aria-label="Start a spec for issue ${n}"${ui.busy ? ' aria-disabled="true"' : ''}>Start a spec …</button>`
22
27
  : '';
23
- const agent = `<button data-corn-kind="secondary" type="button" class="hx-btn hx-forge-act hx-forge-startspec" data-forge-agent="issue:${n}" aria-label="${escHtml(t('startAgent'))} on issue ${n}">${escHtml(t('startAgent'))} …</button>`;
24
- return `<div class="hx-forge-cta">${agent}${spec}</div>`;
28
+ const agent = `<button data-corn-kind="approve" type="button" class="hx-btn hx-btn--approve hx-forge-act hx-forge-startspec" data-forge-agent="issue:${n}" aria-label="${escHtml(t('startAgent'))} on issue ${n}">${escHtml(t('startAgent'))} …</button>`;
29
+ return { primary: agent, others: [spec, out] };
25
30
  }
26
31
 
27
32
  /**
@@ -42,5 +47,5 @@ export function install(ctx) {
42
47
  return null;
43
48
  }
44
49
 
45
- Object.assign(fn, { issueActionsHtml, oldIssue });
50
+ Object.assign(fn, { issueParts, oldIssue });
46
51
  }
@@ -21,6 +21,8 @@ export function install(ctx) {
21
21
  const { announce, isPhone, expandSheet, collapseSheet, showSheet, nodeById, selectNode, clearResult, resultOf, showResultIn, setT, clearT } = ctx.h;
22
22
 
23
23
  const isForgeOpen = () => ui.open;
24
+ /** The list's tab for a kind of work */
25
+ const LIST_TAB = { pull: 'pulls', issue: 'issues', thread: 'threads', run: 'work', deploy: 'deploys', proposal: 'specs' };
24
26
 
25
27
  /**
26
28
  * Opens the list with the focus on its title; the first time, loads what its tab shows (the proposals, to start with).
@@ -30,6 +32,9 @@ export function install(ctx) {
30
32
  function openForge({ load = true, tab, quiet = false } = {}) {
31
33
  const panel = $('forge-panel');
32
34
  if (!panel || panel.hidden) return;
35
+ if (m.behind) { backToList(); return; } // it is open, behind the node it opened
36
+ // Opened by a toggle with a piece of work in the node panel (spec 0015 D3): on that piece's tab, its row marked and scrolled to; the selection stays
37
+ if (!tab && load && !ui.open && ui.item && LIST_TAB[ui.item.kind]) { tab = LIST_TAB[ui.item.kind]; m.markRow = true; }
33
38
  if (tab && tab !== (ui.kind === 'notes' ? 'pulls' : ui.kind) && TABS.includes(tab)) { // the Release notes are one level down on PRs
34
39
  ui.kind = tab;
35
40
  ui.filters = defaultFilters(tab);
@@ -50,7 +55,7 @@ export function install(ctx) {
50
55
  if (isPhone()) { showSheet('forge'); if (tab) expandSheet('forge'); } // a peek (it takes the place of the node panel's sheet: spec 0010 D7); only a link that names a tab opens it expanded
51
56
  fn.paintButton();
52
57
  const title = $('forge-title');
53
- title.focus();
58
+ title.focus({ preventScroll: true }); // the list slides in from the right edge (spec 0015 D3): a scroll to it would shift the whole stage
54
59
  announce('Work list');
55
60
  inst.emit('work:list', { open: true });
56
61
  if (!load) return; // a deep link loads the list it wants itself
@@ -67,12 +72,16 @@ export function install(ctx) {
67
72
  return false;
68
73
  }
69
74
 
70
- /** Closes the list. The node panel keeps what it shows. */
71
- function closeForge({ restoreFocus = true } = {}) {
75
+ /**
76
+ * Closes the list. Called by the list's own ✕, Escape or toggle (`both`), it is the one side panel closing (spec 0015 D3): on a desktop the node it set aside is let go of
77
+ * too. Otherwise (the view was left, a phone's sheet gave way) the node panel keeps what it shows.
78
+ */
79
+ function closeForge({ restoreFocus = true, both = false } = {}) {
72
80
  const panel = $('forge-panel');
73
81
  if (!panel || !ui.open) return;
74
82
  const hadFocus = panel.contains(inst.active());
75
83
  ui.open = false;
84
+ m.behind = false;
76
85
  panel.classList.remove('forge-open');
77
86
  panel.inert = true;
78
87
  collapseSheet('forge');
@@ -80,10 +89,60 @@ export function install(ctx) {
80
89
  const back = m.openerEl && m.openerEl.isConnected ? m.openerEl : ctx.root.querySelector('[data-action="toggle-forge"]');
81
90
  if (restoreFocus && hadFocus && back) back.focus();
82
91
  inst.emit('work:list', { open: false });
92
+ // Closing closes both (spec 0015 D3): the selection, else the piece of work the panel shows without one (older than the map of work)
93
+ if (both && !isPhone()) { m.rowRef = null; if (inst.state.selectedNode) clearSelection(inst, { source: 'api' }); else inst.emit('node:close'); }
83
94
  announce('Work list closed');
84
95
  }
85
96
 
86
- const toggleForge = () => (ui.open ? closeForge() : openForge());
97
+ const toggleForge = () => (m.behind ? backToList() : ui.open ? closeForge({ both: true }) : openForge());
98
+
99
+ // ---------------------------------------------------------------------------
100
+ // One side panel at a time (spec 0015 D3): on a desktop the list and the node panel take the same place, in turns. A phone has its two sheets (spec 0010 D7)
101
+ // ---------------------------------------------------------------------------
102
+
103
+ /** The node panel opened while the list is open: the list waits behind it (still open: the panel's Back, Escape or the toggle bring it again) */
104
+ function goBehind() {
105
+ const panel = $('forge-panel');
106
+ if (!panel || !ui.open || m.behind || isPhone()) return;
107
+ m.behind = true;
108
+ panel.classList.remove('forge-open');
109
+ panel.inert = true;
110
+ fn.paintButton();
111
+ }
112
+
113
+ /** Back to the list from the node it opened: the node stays selected, the node panel steps aside, its row is marked and has the focus */
114
+ function backToList() {
115
+ const panel = $('forge-panel');
116
+ if (!panel || !m.behind) return false;
117
+ m.behind = false;
118
+ panel.classList.add('forge-open');
119
+ panel.inert = false;
120
+ inst.emit('work:list', { open: true });
121
+ fn.paint();
122
+ announce('Work list');
123
+ const row = markRow();
124
+ if (row) row.focus({ preventScroll: true }); else $('forge-title').focus({ preventScroll: true }); // (the list is still sliding in: a scroll would move the stage, not the list)
125
+ return true;
126
+ }
127
+
128
+ /** The row of what the node panel shows, scrolled into the list's view; null when the list does not show it */
129
+ function markRow() {
130
+ const panel = $('forge-panel');
131
+ const row = panel && [...panel.querySelectorAll('[data-work-ref][aria-pressed="true"]')].find((r) => !r.closest('[hidden]'));
132
+ if (!row) return null;
133
+ // Only the list's own body scrolls: `scrollIntoView` would also scroll the stage while the list slides in, and leave the page shifted
134
+ const box = row.closest('.hx-forge-body');
135
+ if (box) {
136
+ const r = row.getBoundingClientRect();
137
+ const b = box.getBoundingClientRect();
138
+ if (r.top < b.top) box.scrollTop -= b.top - r.top;
139
+ else if (r.bottom > b.bottom) box.scrollTop += r.bottom - b.bottom;
140
+ }
141
+ return row;
142
+ }
143
+
144
+ /** What the node panel's Back does while the list is open on a desktop (`panel:back`): the list again; nothing on a phone, or with the list shut */
145
+ const panelBack = () => (ui.open && !isPhone() ? backToList : undefined);
87
146
 
88
147
  /** After a filter changes: the list again, and how many it holds */
89
148
  function filtersChanged(announceNow = true) {
@@ -121,7 +180,8 @@ export function install(ctx) {
121
180
  if (row) {
122
181
  const ref = row.dataset.workRef;
123
182
  // A row already shown goes into the node panel, as Enter on the map does: the focus otherwise stays on the row, so the list can be read down
124
- if (m.rowRef === ref && isShown(ref)) { inst.emit('node:focus'); return; }
183
+ // On a desktop the node panel stepped aside for the list (spec 0015 D3): it comes back in the list's place first
184
+ if (m.rowRef === ref && isShown(ref)) { if (!isPhone() && !m.behind) inst.emit('panel:return'); inst.emit('node:focus'); return; }
125
185
  m.rowRef = ref; // the row the node panel's Escape gives the focus back to (`rowBack`)
126
186
  const at = ref.indexOf(':');
127
187
  fn.showRef(ref.slice(0, at), ref.slice(at + 1)).then((shown) => {
@@ -133,7 +193,7 @@ export function install(ctx) {
133
193
  }
134
194
  const action = t.closest('[data-action]');
135
195
  if (!action) return;
136
- if (action.dataset.action === 'close-forge') closeForge();
196
+ if (action.dataset.action === 'close-forge') closeForge({ both: true });
137
197
  else if (action.dataset.action === 'refresh-forge' || action.dataset.action === 'retry-forge') fn.refreshForge();
138
198
  else if (action.dataset.action === 'clear-specs-search') {
139
199
  ui.specQuery = '';
@@ -178,6 +238,9 @@ export function install(ctx) {
178
238
  announce(`${node.label}, ${node.type}`);
179
239
  return;
180
240
  }
241
+ // A thread folded into the proposal shown (spec 0015 D2): the thread in the panel, the proposal still selected on the map
242
+ const folded = t.closest('[data-work-folded]');
243
+ if (folded) { fn.showFolded(Number(folded.dataset.workFolded), folded.dataset.id).catch(() => {}); return; }
181
244
  const agent = t.closest('[data-forge-agent]');
182
245
  if (agent) { fn.openAgent(agent.dataset.forgeAgent, `[data-forge-agent="${agent.dataset.forgeAgent}"]`); return; }
183
246
  const stop = t.closest('[data-forge-stop]');
@@ -270,7 +333,7 @@ export function install(ctx) {
270
333
  if (e.key !== 'Escape' || e.defaultPrevented) return;
271
334
  if (e.target.closest && e.target.closest('select, input, textarea')) return;
272
335
  e.preventDefault();
273
- closeForge();
336
+ closeForge({ both: true });
274
337
  }
275
338
 
276
339
  // ---------------------------------------------------------------------------
@@ -383,7 +446,7 @@ export function install(ctx) {
383
446
  const ref = m.rowRef;
384
447
  if (!ui.open || !ref || !isShown(ref)) return undefined;
385
448
  return () => {
386
- const row = ui.open && [...$('forge-panel').querySelectorAll('[data-work-ref]')].find((r) => r.dataset.workRef === ref);
449
+ const row = ui.open && !m.behind && [...$('forge-panel').querySelectorAll('[data-work-ref]')].find((r) => r.dataset.workRef === ref);
387
450
  if (!row || row.closest('[hidden]')) return false;
388
451
  row.focus();
389
452
  return true;
@@ -404,5 +467,5 @@ export function install(ctx) {
404
467
  fn.paint();
405
468
  }
406
469
 
407
- Object.assign(fn, { isForgeOpen, openForge, linkMissing, closeForge, toggleForge, filtersChanged, onClick, onDetailClick, onChange, onInput, onDetailInput, onDetailKey, onKey, refOf, isShown, sayDetail, showRef, showDetail, rowBack, dropDetail });
470
+ Object.assign(fn, { goBehind, backToList, markRow, panelBack, isForgeOpen, openForge, linkMissing, closeForge, toggleForge, filtersChanged, onClick, onDetailClick, onChange, onInput, onDetailInput, onDetailKey, onKey, refOf, isShown, sayDetail, showRef, showDetail, rowBack, dropDetail });
408
471
  }
@@ -14,6 +14,8 @@ import { specGroups, waitingWords, runWaitingOn } from '../waiting-model.js';
14
14
  import { specGroupsHtml } from '../waiting-view.js';
15
15
  import { escapeHtml as escHtml } from '../../core/text.js';
16
16
  import { plural, safeUrl, option } from './work-common.js';
17
+ import { actionBarHtml } from '../panel-model.js';
18
+ import { applySections, menuOpen, reopenMenu } from '../panel-sections.js';
17
19
 
18
20
  export function install(ctx) {
19
21
  const { inst, ui, m, fn, state, root, $ } = ctx;
@@ -36,6 +38,9 @@ export function install(ctx) {
36
38
  if (el.dataset.runReply) return `[data-run-reply="${el.dataset.runReply}"]`;
37
39
  if (el.dataset.runAnswer) return `[data-run-answer="${el.dataset.runAnswer}"][data-run-id="${el.dataset.runId}"]`;
38
40
  if (el.dataset.runTimeline) return `[data-run-timeline="${el.dataset.runTimeline}"]`;
41
+ if (el.dataset.secToggle) return `[data-sec-toggle="${el.dataset.secToggle}"]`;
42
+ if (el.dataset.workFolded) return `[data-work-folded="${el.dataset.workFolded}"]`;
43
+ if (el.hasAttribute && el.hasAttribute('data-more-toggle')) return '[data-more-toggle]';
39
44
  return null;
40
45
  }
41
46
 
@@ -55,6 +60,7 @@ export function install(ctx) {
55
60
  if (back && back !== inst.active() && !back.closest('[hidden]')) back.focus();
56
61
  // Retry was pressed and its notice is gone (the list is being read again): the focus goes to the list's title, never to the page
57
62
  if (had && had.dataset && had.dataset.action === 'retry-forge' && !panel.contains(inst.active())) $('forge-title').focus();
63
+ if (m.markRow && ui.open && !m.behind && fn.markRow()) m.markRow = false; // opened with a node selected: its row, once the list has it (spec 0015 D3)
58
64
  paintDetail();
59
65
  }
60
66
 
@@ -72,16 +78,32 @@ export function install(ctx) {
72
78
  if (kind !== ui.item.kind) return; // the node panel shows another piece of work than the one read: its own draw comes with `node:painted`
73
79
  const had = box.contains(inst.active()) ? inst.active() : null;
74
80
  const again = had ? findAgain(had) : null;
75
- if (kind === 'run') fn.paintRunCard();
76
- else {
77
- const body = kind === 'pull' ? fn.detailHtml() : kind === 'thread' ? fn.threadDetailHtml() : kind === 'deploy' ? fn.deployDetailHtml() : kind === 'issue' ? fn.issueActionsHtml(ui.item) : kind === 'proposal' ? `${fn.proposalActionsHtml(ui.item)}${Number.isInteger(ui.item.number) ? fn.detailHtml() : ''}` : '';
78
- const html = `${noteHtml(kind)}${body}`;
79
- if (drawn.get(box) !== html) {
80
- box.innerHTML = html;
81
- drawn.set(box, html);
82
- addParts(box);
83
- }
81
+ const inMenu = !!(had && had.closest('[data-more-menu]'));
82
+ // Spec 0015 D4's order: the action bar (the primary action, one or two beside it, the rest under ⋯) with its Next line, the notices, (Connected, the panel's), the sections
83
+ const parts = partsOf(kind) || {};
84
+ // A place the box was given without its three places (a host's own box, or one drawn before spec 0015): they are made, in their order
85
+ for (const place of ['bar', 'notes', 'sections']) {
86
+ if (box.querySelector(`[data-work-place="${place}"]`)) continue;
87
+ const el = inst.doc.createElement('div');
88
+ el.className = `hx-work-${place}`;
89
+ el.dataset.workPlace = place;
90
+ box.append(el);
84
91
  }
92
+ const put = (place, html) => {
93
+ const el = box.querySelector(`[data-work-place="${place}"]`);
94
+ if (!el || drawn.get(el) === html) return false;
95
+ el.innerHTML = html;
96
+ drawn.set(el, html);
97
+ addParts(el);
98
+ return true;
99
+ };
100
+ put('bar', actionBarHtml(parts));
101
+ put('notes', `${noteHtml(kind)}${parts.notes || ''}`);
102
+ if (kind === 'run') fn.paintRunCard();
103
+ else put('sections', (parts.sections || []).filter(Boolean).join(''));
104
+ applySections(inst, box, kind); // the sections as they were left for this kind of node
105
+ fn.paintFoldedCounts(box);
106
+ if (inMenu && !menuOpen(box)) reopenMenu(box);
85
107
  const back = again && box.querySelector(again);
86
108
  if (back && back !== inst.active() && !back.closest('[hidden]') && !back.disabled) back.focus();
87
109
  // The control that had the focus is gone (Land it, once the pull request has landed; a Stop that was asked for) and the page has it: it goes to the actions' own place, which a keyboard
@@ -98,6 +120,19 @@ export function install(ctx) {
98
120
  }
99
121
  }
100
122
 
123
+ /** A kind's part of the node panel: `{ primary, others, next, notes, sections }` (each its part's own markup: pieces/work-prs.js, work-specs.js, work-issues.js ...) */
124
+ function partsOf(kind) {
125
+ switch (kind) {
126
+ case 'pull': return fn.pullParts();
127
+ case 'proposal': return fn.proposalParts(ui.item);
128
+ case 'issue': return fn.issueParts(ui.item);
129
+ case 'thread': return fn.threadParts();
130
+ case 'deploy': return fn.deployParts();
131
+ case 'run': return fn.runParts();
132
+ default: return null;
133
+ }
134
+ }
135
+
101
136
  /** What the last step the actions took came to (a spec started, a build issue opened: with a link to it), and what the last request of a run said */
102
137
  function noteHtml(kind) {
103
138
  const note = ui.actNote && ui.actNote.ref === ui.ref && kind !== 'thread' && kind !== 'deploy' && kind !== 'run' ? ui.actNote : null; // a step's note is its piece of work's (a link that found nothing says so in the list)
@@ -270,7 +305,7 @@ export function install(ctx) {
270
305
 
271
306
  /** The toggles that open the list (`data-action="toggle-forge"`: the Work view's List) say whether it is open */
272
307
  function paintButton() {
273
- for (const toggle of root.querySelectorAll('[data-action="toggle-forge"]')) toggle.setAttribute('aria-expanded', String(ui.open));
308
+ for (const toggle of root.querySelectorAll('[data-action="toggle-forge"]')) toggle.setAttribute('aria-expanded', String(ui.open && !m.behind)); // behind the node it opened, it is not shown
274
309
  }
275
310
 
276
311
  /** Whether the Filter chip applies to the view: the proposals and the release notes have nothing to filter */
@@ -8,9 +8,9 @@
8
8
  import { withParts } from '../engine/piece.js';
9
9
  import { runOnPull, pullRunWords, statusWords } from '../runs-model.js';
10
10
  import { loadingRowsHtml, runPillHtml } from '../runs-view.js';
11
- import { pullUrl, stateWords, metaWords, checkWords, checksWords, landingUrl, cancelLandingUrl, landingWords, mergeBlock, rerunWhy, actionUrl, actionWords, buildOffers, approvalWarning } from '../forge-panel-model.js';
11
+ import { pullUrl, stateWords, metaWords, checkWords, checksWords, landingUrl, cancelLandingUrl, landingWords, mergeBlock, rerunWhy, actionUrl, actionWords, buildOffers, approvalWarning, nextWords } from '../forge-panel-model.js';
12
+ import { sectionHtml } from '../panel-model.js';
12
13
  import { cornStateAttr, stateIconHtml } from '../corn-state.js';
13
- import { waiting } from '../waiting-model.js';
14
14
  import { escapeHtml as escHtml } from '../../core/text.js';
15
15
  import { plural, safeUrl } from './work-common.js';
16
16
 
@@ -104,10 +104,17 @@ export function install(ctx) {
104
104
  return `<li class="hx-forge-item"><button type="button" class="hx-forge-row" data-work-ref="${ref}" aria-pressed="${fn.isShown(ref)}" data-corn="row">${inner}</button>${out}</li>`;
105
105
  }
106
106
 
107
- /** The pull request's detail for the node panel: Land it and Open on the forge, the checks with Re-run, what the head changes. Nothing here repeats the node panel's title and state. */
108
- function detailHtml() {
109
- if (ui.detailError) return `<p class="hx-forge-notice" data-corn="notice">${escHtml(ui.detailError)}</p>`;
110
- if (!ui.detail) return `<p class="hx-faint">Loading its files and checks …</p><ul class="hx-forge-list" aria-hidden="true">${loadingRowsHtml(4)}</ul>`;
107
+ /**
108
+ * The pull request's part of the node panel (spec 0015 D4), as the pieces the bar and the sections are made of: Land it (the primary action of a green pull request), Review for a
109
+ * spec pull request older than the graph's days, Open on the forge; the one Next line when it cannot land yet; the notices (a landing that waits on its checks, with Cancel, what
110
+ * the last action came to); and its sections, each with its count: the build issue (open while it is offered), the checks (open while a failed one can be run again: its Re-run is
111
+ * there), the files. Nothing here repeats the node panel's title and state. `self`: the panel is a proposal's, whose own Review is the proposal's part.
112
+ * @returns {{ land: string, review: string[], open: string, next: string, notes: string, sections: string[], build: string, green: boolean }}
113
+ */
114
+ function detailParts({ self = false } = {}) {
115
+ const none = { land: '', review: [], open: '', next: '', sections: [], build: '', green: false };
116
+ if (ui.detailError) return { ...none, notes: `<p class="hx-forge-notice" data-corn="notice">${escHtml(ui.detailError)}</p>` };
117
+ if (!ui.detail) return { ...none, notes: `<p class="hx-faint">Loading its files and checks …</p><ul class="hx-forge-list" aria-hidden="true">${loadingRowsHtml(4)}</ul>` };
111
118
  const { pull, checks, stale } = ui.detail;
112
119
  const lit = ui.lit;
113
120
  const mapped = lit.files.filter((f) => f.nodes.length).length;
@@ -138,51 +145,56 @@ export function install(ctx) {
138
145
  return `<li class="hx-forge-file" data-corn="file"><span class="hx-forge-fstatus">${escHtml(f.status)}</span> <code class="hx-code">${escHtml(f.path)}</code>${renamed} <span class="hx-good">+${f.additions}</span> <span class="hx-forge-del">−${f.deletions}</span><span class="hx-forge-nodes">${nodes}</span></li>`;
139
146
  }).join('');
140
147
 
141
- // Land it is the one primary action, with Open on the forge beside it; a pull request that cannot land says why in one line
148
+ // Land it, with Open on the forge beside it; one that cannot land is a dashed Land it, and the Next line says what comes first (`mergeBlock` is its title)
142
149
  const block = mergeBlock(ui.detail);
143
- const land = block
144
- ? `<button type="button" class="hx-btn hx-btn--approve" disabled data-corn-kind="approve">${escHtml(t('landIt'))}</button>`
145
- : `<button type="button" class="hx-btn hx-btn--approve hx-forge-act" data-forge-merge="${escHtml(String(pull.number))}"${ui.busy ? ' aria-disabled="true"' : ''} data-corn-kind="approve">${escHtml(t('landIt'))} …</button>`;
150
+ const land = pull.state !== 'open' ? ''
151
+ : block
152
+ ? `<button type="button" class="hx-btn hx-btn--approve" disabled data-corn-kind="approve" title="${escHtml(block)}">${escHtml(t('landIt'))}</button>`
153
+ : `<button type="button" class="hx-btn hx-btn--approve hx-forge-act" data-forge-merge="${escHtml(String(pull.number))}"${ui.busy ? ' aria-disabled="true"' : ''} data-corn-kind="approve">${escHtml(t('landIt'))} …</button>`;
146
154
  // A spec pull request older than the graph's 14 days is a plain pull request here, with no Review of its own: its proposals that are not approved get one, found by their slug in the
147
- // proposals list (the node panel of one the graph holds has it already: pieces/work-specs.js). A proposal the list does not hold is named in the warning instead.
155
+ // proposals list (the node panel of one the graph holds has it already: pieces/work-specs.js). A proposal the list does not hold is named in a notice instead.
148
156
  // Only this pull request's own copy: another pull request may hold a file of the same slug (anyone can open one), and approving that copy would approve, and with
149
157
  // `approveLands` land, the other pull request
150
158
  const ownCopy = (slug) => { const e = fn.specEntry({ slug, number: pull.number }); return e && e.pull && e.pull.number === pull.number ? e : null; };
151
159
  const reviewable = ui.item && ui.item.kind === 'pull' && pull.state === 'open'
152
160
  ? (ui.detail.specs || []).filter((x) => !x.approved).map((x) => ({ slug: x.slug, entry: ownCopy(x.slug) }))
153
161
  : [];
154
- const review = reviewable.filter((x) => x.entry).map((x) => `<button type="button" class="hx-btn hx-forge-act" data-corn-kind="secondary" data-work-action="review" data-slug="${escHtml(x.slug)}" data-source="${escHtml(x.entry.source || '')}" aria-label="Review proposal ${escHtml(x.slug)}">Review ${escHtml(x.slug)} …</button>`).join('');
155
- const warning = approvalWarning(ui.detail, { review: !reviewable.length ? 'node' : reviewable.every((x) => x.entry) ? 'here' : 'list' });
156
- const act = `<div class="hx-forge-cta">${land}${review}${url ? `<a data-corn="open-link" data-corn-kind="secondary" class="hx-btn hx-forge-open" href="${escHtml(url)}" target="_blank" rel="noreferrer">Open on ${escHtml(fn.forgeName())} ↗</a>` : ''}</div>${block ? `<p class="hx-forge-why hx-faint">${escHtml(block)}</p>` : ''}${warning ? `<p class="hx-forge-why hx-faint" data-corn="notice" data-corn-state="waiting">${escHtml(warning)}</p>` : ''}`;
162
+ const review = reviewable.filter((x) => x.entry).map((x) => `<button type="button" class="hx-btn hx-forge-act" data-corn-kind="secondary" data-work-action="review" data-slug="${escHtml(x.slug)}" data-source="${escHtml(x.entry.source || '')}" aria-label="Review proposal ${escHtml(x.slug)}">Review ${escHtml(x.slug)} …</button>`);
163
+ const missing = reviewable.length && !reviewable.every((x) => x.entry) ? approvalWarning(ui.detail, { review: 'list' }) : '';
164
+ const open = url ? `<a data-corn="open-link" data-corn-kind="secondary" class="hx-btn hx-forge-open" href="${escHtml(url)}" target="_blank" rel="noreferrer">Open on ${escHtml(fn.forgeName())} ↗</a>` : '';
157
165
  // A spec approved with `proposals.approveLands` waits for its checks: said here, with a way to stop it
158
166
  const waiting = ui.landing && pull.state === 'open'
159
167
  ? `<div class="hx-forge-step"><p class="hx-forge-notice hx-forge-notice--ok" role="status" data-corn="notice" data-corn-state="success">${escHtml(landingWords(ui.landing, m.now()))}</p><button data-corn-kind="secondary" type="button" class="hx-btn hx-forge-act" data-forge-landing-cancel="${pull.number}"${ui.busy ? ' aria-disabled="true"' : ''}>Cancel</button></div>`
160
168
  : '';
161
169
  const note = ui.note ? `<p class="hx-forge-notice${ui.note.ok ? ' hx-forge-notice--ok' : ''}" data-corn="notice"${ui.note.ok ? ' data-corn-state="success"' : ''}>${escHtml(ui.note.text)}</p>` : '';
170
+ const notes = `${stale ? `<p class="hx-forge-notice" data-corn="notice">${escHtml(`This is an older answer. ${stale}`)}</p>` : ''}${note}${waiting}${missing ? `<p class="hx-forge-why hx-faint" data-corn="notice" data-corn-state="waiting">${escHtml(missing)}</p>` : ''}`;
171
+
162
172
  // Step 2 of the pipeline: a spec pull request with an approved proposal opens its build issue
163
173
  const offers = buildOffers(ui.detail);
164
- const build = offers.length
165
- ? `<h3 class="hx-forge-subact">Build issue</h3>${offers.map((o) => (o.offer
166
- ? `<div class="hx-forge-step"><button type="button" class="hx-btn hx-btn--approve hx-forge-act" data-forge-build="${escHtml(o.slug)}" aria-label="Open the build issue for ${escHtml(o.slug)}"${ui.busy ? ' aria-disabled="true"' : ''} data-corn-kind="approve">Open the build issue …</button><p class="hx-forge-why hx-faint"><code class="hx-code">${escHtml(o.slug)}</code> is approved. Opens a confirm step that shows the issue. Nothing is built.</p></div>`
167
- : `<p class="hx-forge-why hx-faint"><code class="hx-code">${escHtml(o.slug)}</code>: ${escHtml(o.why)}</p>`)).join('')}`
168
- : '';
169
-
174
+ const sections = [];
175
+ let build = '';
176
+ if (offers.length) {
177
+ build = sectionHtml({
178
+ key: 'build', title: 'Build issue', count: offers.length, open: offers.some((o) => o.offer),
179
+ body: offers.map((o) => (o.offer
180
+ ? `<div class="hx-forge-step"><button type="button" class="hx-btn hx-btn--approve hx-forge-act" data-forge-build="${escHtml(o.slug)}" aria-label="Open the build issue for ${escHtml(o.slug)}"${ui.busy ? ' aria-disabled="true"' : ''} data-corn-kind="approve">Open the build issue …</button><p class="hx-forge-why hx-faint"><code class="hx-code">${escHtml(o.slug)}</code> is approved. Opens a confirm step that shows the issue. Nothing is built.</p></div>`
181
+ : `<p class="hx-forge-why hx-faint"><code class="hx-code">${escHtml(o.slug)}</code>: ${escHtml(o.why)}</p>`)).join(''),
182
+ });
183
+ }
184
+ const rerunnable = checks.some((c) => c.state === 'failure' && c.canRerun);
185
+ sections.push(sectionHtml({ key: 'checks', title: 'Checks', count: checks.length, note: checksWords(checks), open: rerunnable, body: checks.length ? `<ul class="hx-forge-checks">${checkRows}</ul>` : '<p class="hx-faint">No checks have run on this head.</p>' }));
186
+ sections.push(sectionHtml({ key: 'files', title: 'Files', count: lit.files.length, note: `${mapped} on the map`, body: lit.files.length ? `<ul class="hx-forge-files">${fileRows}</ul>` : '<p class="hx-faint">It changes no file.</p>' }));
170
187
  // Its run: who is running it, their state, the time and the cost (the runs are read for the Runs tab, and once for the first PR selected)
171
188
  const runs = ui.runs && ui.runs.data ? ui.runs.data.runs : null;
172
189
  const made = runOnPull(runs, pull.number);
173
- const runSection = made
174
- ? `<h3 class="hx-forge-sub">Run</h3><p class="hx-forge-runline"${cornStateAttr(made.status)} data-corn="run">${runPillHtml({ esc: escHtml }, made, statusWords(made))} ${escHtml(pullRunWords(made, m.now(), { state: false }))}</p>`
175
- : '';
176
- return `${act}
177
- ${stale ? `<p class="hx-forge-notice" data-corn="notice">${escHtml(`This is an older answer. ${stale}`)}</p>` : ''}
178
- ${note}
179
- ${waiting}
180
- ${build}
181
- <h3 class="hx-forge-sub">Checks: ${escHtml(checksWords(checks))}</h3>
182
- ${checks.length ? `<ul class="hx-forge-checks">${checkRows}</ul>` : ''}
183
- <h3 class="hx-forge-sub">${escHtml(plural(lit.files.length, 'file'))} changed, ${mapped} on the map</h3>
184
- <ul class="hx-forge-files">${fileRows}</ul>
185
- ${runSection}`;
190
+ if (made) sections.push(`<div class="hx-sec-block" data-corn="section"><h3 class="hx-sec-title">Run</h3><p class="hx-forge-runline"${cornStateAttr(made.status)} data-corn="run">${runPillHtml({ esc: escHtml }, made, statusWords(made))} ${escHtml(pullRunWords(made, m.now(), { state: false }))}</p></div>`);
191
+ return { land, review, open, next: nextWords(ui.detail, { self }), notes, sections, build, green: !block };
192
+ }
193
+
194
+ /** A pull request's actions as the node panel's bar puts them: Land it first, then its Reviews, then Open on the forge */
195
+ function pullParts() {
196
+ const d = detailParts();
197
+ return { primary: d.land, others: [...d.review, d.open], next: d.next, notes: d.notes, sections: [...d.sections, d.build] };
186
198
  }
187
199
 
188
200
  /** A node button, as in a pull request's files: it selects the node on the map */
@@ -218,5 +230,5 @@ export function install(ctx) {
218
230
  }
219
231
 
220
232
  // what other parts put in the panel gets its parts (a hook is a part of the same name)
221
- Object.assign(fn, { selectPull, loadLanding, cancelLanding, clearPull, selectionWords, itemHtml: (...a) => withParts(itemHtml(...a)), detailHtml: (...a) => withParts(detailHtml(...a)), nodeButton: (n) => withParts(nodeButton(n)), finishAction, rerunCheck });
233
+ Object.assign(fn, { selectPull, loadLanding, cancelLanding, clearPull, selectionWords, itemHtml: (...a) => withParts(itemHtml(...a)), detailParts, pullParts, nodeButton: (n) => withParts(nodeButton(n)), finishAction, rerunCheck });
222
234
  }
@@ -8,7 +8,7 @@
8
8
  import { withParts } from '../engine/piece.js';
9
9
  import { WORK_URL, groupWork, filterGroups, groupWords, workStatus, markWords } from '../agents-model.js';
10
10
  import { runsUrl, stopUrl, answerUrl, answerBody, answerWordsFor, runsStatus, runnerState, runnerWords, triggerNotice, totalsLines, handLines, stopWords, changeWords } from '../runs-model.js';
11
- import { runHtml, runRowsHtml, totalsHtml, loadingRowsHtml, loadingLinesHtml } from '../runs-view.js';
11
+ import { runHtml, runBarParts, runRowsHtml, totalsHtml, loadingRowsHtml, loadingLinesHtml } from '../runs-view.js';
12
12
  import { waiting } from '../waiting-model.js';
13
13
  import { escapeHtml as escHtml } from '../../core/text.js';
14
14
  import { safeUrl, RUNS_POLL_MS } from './work-common.js';
@@ -148,7 +148,8 @@ export function install(ctx) {
148
148
 
149
149
  /** The run in the node panel: its card (state, what it changes, Stop, the answer field, Start again, the timeline). Drawn with `patchList`, so a reply being typed stays. */
150
150
  function paintRunCard() {
151
- const box = $('forge-detail');
151
+ const detail = $('forge-detail');
152
+ const box = detail && (detail.querySelector('[data-work-place="sections"]') || detail);
152
153
  if (!box) return;
153
154
  let list = box.querySelector('#forge-run-card');
154
155
  if (!list) {
@@ -160,10 +161,20 @@ export function install(ctx) {
160
161
  }
161
162
  const run = runById(ui.runShown);
162
163
  const data = ui.runs && ui.runs.data;
163
- if (run) patchList(list, runHtml(viewContext(), run, data.runs));
164
+ if (run) patchList(list, runHtml({ ...viewContext(), bar: true }, run, data.runs)); // its Continue, Stop and Start again are the bar's (`runParts`)
164
165
  else patchList(list, `<li class="hx-forge-empty hx-faint" data-corn="empty">${escHtml(ui.runs && ui.runs.error ? ui.runs.error : data ? 'This run is not in what the runners reported.' : 'Reading the run …')}</li>`);
165
166
  }
166
167
 
168
+ /** The run's actions in the node panel's bar (spec 0015 D4): Continue first while it waits on an answer, Stop beside it; Start again, or Stop, otherwise (runs-view.js `runBarParts`) */
169
+ function runParts() {
170
+ const run = runById(ui.runShown);
171
+ const url = ui.item && safeUrl(ui.item.url);
172
+ const out = url ? `<a class="hx-btn hx-btn--quiet hx-foot-btn" data-corn-kind="quiet" data-corn="open-link" href="${escHtml(url)}" target="_blank" rel="noreferrer">Open on the forge ↗</a>` : '';
173
+ if (!run) return { others: [out] };
174
+ const bar = runBarParts(viewContext(), run);
175
+ return { primary: bar.primary, others: [...bar.others, out] };
176
+ }
177
+
167
178
  /**
168
179
  * Draws a list again without disturbing what the person is doing in it. The new rows are made first and set against the old by their key
169
180
  * (a run's id, a compare group's): a row that has not changed is left alone, a row that has is replaced, and **a row that holds the focus in
@@ -301,7 +312,8 @@ export function install(ctx) {
301
312
  function focusInRun(runId, selectors) {
302
313
  const card = [...root.querySelectorAll('#forge-run-card [data-run]')].find((c) => c.dataset.run === runId);
303
314
  if (!card) return;
304
- const to = selectors.map((sel) => card.querySelector(sel)).find((el) => el && !el.disabled) || card;
315
+ const bar = $('forge-detail') && $('forge-detail').querySelector('[data-work-place="bar"]'); // Continue, Stop and Start again are in the node panel's action bar
316
+ const to = selectors.map((sel) => card.querySelector(sel) || (bar && bar.querySelector(sel))).find((el) => el && !el.disabled) || card;
305
317
  if (to !== inst.active()) to.focus();
306
318
  if (to.matches('input') && typeof to.setSelectionRange === 'function') to.setSelectionRange(to.value.length, to.value.length); // typing goes on at the end of what is there
307
319
  }
@@ -373,5 +385,5 @@ export function install(ctx) {
373
385
  fn.showRef('run', runId);
374
386
  }
375
387
 
376
- Object.assign(fn, { groupsShown, loadWork, loadRuns, syncRunsPoll, onPageHide, onPageShow, workHtml: (...a) => withParts(workHtml(...a)), groupsHtml: (...a) => withParts(groupsHtml(...a)), paintRuns, paintRunCard, patchList, graftAround, runnerAway, askRunnerWords, paintRunner, viewContext, runById, showRun, toggleTimeline, focusInRun, discardReply, stopRun, answerRun, answerFromBar, goToRun });
388
+ Object.assign(fn, { runParts, groupsShown, loadWork, loadRuns, syncRunsPoll, onPageHide, onPageShow, workHtml: (...a) => withParts(workHtml(...a)), groupsHtml: (...a) => withParts(groupsHtml(...a)), paintRuns, paintRunCard, patchList, graftAround, runnerAway, askRunnerWords, paintRunner, viewContext, runById, showRun, toggleTimeline, focusInRun, discardReply, stopRun, answerRun, answerFromBar, goToRun });
377
389
  }
@@ -9,6 +9,7 @@ import { mergeSpecs } from '../proposal-model.js';
9
9
  import { waiting, specGroups } from '../waiting-model.js';
10
10
  import { plural, SPECS_POLL_MS } from './work-common.js';
11
11
  import { escapeHtml as escHtml } from '../../core/text.js';
12
+ import { sectionHtml } from '../panel-model.js';
12
13
 
13
14
  export function install(ctx) {
14
15
  const { inst, ui, m, fn, $ } = ctx;
@@ -75,14 +76,33 @@ export function install(ctx) {
75
76
  return items.find((e) => e.slug === item.slug && (item.number ? e.pull && e.pull.number === item.number : !e.pull)) || items.find((e) => e.slug === item.slug) || null;
76
77
  }
77
78
 
78
- /** A proposal's actions in the node panel: Review (opens it over the map; Approve and Send back are the review's), and Start an agent on it when the config lets a run start */
79
- function proposalActionsHtml(item) {
79
+ /**
80
+ * A proposal's part of the node panel (spec 0015 D4): Review (opens it over the map; Approve and Send back are the review's) is the primary action while it waits on you, Land it
81
+ * while its green spec pull request is all that is left; Start an agent on it when the config lets a run start. Its spec pull request's Land it, Next line, checks, files and build
82
+ * issue follow (pieces/work-prs.js), and what the Work list's card used to say of it: its summary, what it adds, changes and removes, and its scenarios.
83
+ */
84
+ function proposalParts(item) {
80
85
  const entry = specEntry(item);
81
86
  const source = (entry && entry.source) || item.source || '';
87
+ const pull = Number.isInteger(item.number) ? fn.detailParts({ self: true }) : null;
82
88
  const review = `<button type="button" class="hx-btn hx-btn--approve hx-forge-act" data-corn-kind="approve" data-work-action="review" data-slug="${escHtml(item.slug)}" data-source="${escHtml(source)}">Review …</button>`;
89
+ const quietReview = review.replace('hx-btn hx-btn--approve hx-forge-act" data-corn-kind="approve"', 'hx-btn hx-forge-act" data-corn-kind="secondary"');
83
90
  const agent = fn.canStartAgent() ? `<button data-corn-kind="secondary" type="button" class="hx-btn hx-forge-act" data-forge-agent="proposal:${escHtml(item.slug)}" aria-label="${escHtml(t('startAgent'))} on proposal ${escHtml(item.slug)}">${escHtml(t('startAgent'))} …</button>` : '';
84
- return `<div class="hx-forge-cta">${review}${agent}</div>`;
91
+ // Land it leads once nothing is left to decide and its checks are green; until then Review does, and Land it waits beside it
92
+ const landFirst = !!(pull && pull.land && pull.green && !item.waiting && !pull.next);
93
+ const primary = landFirst ? pull.land : review;
94
+ const others = landFirst ? [quietReview, agent, pull.open] : [pull ? pull.land : '', agent, pull ? pull.open : ''];
95
+ const c = (entry && entry.counts) || {};
96
+ const changes = [c.added ? `+${c.added} added` : '', c.changed ? `~${c.changed} changed` : '', c.removed ? `−${c.removed} removed` : ''].filter(Boolean).join(' · ');
97
+ const lead = entry && (entry.summary || changes)
98
+ ? `<div class="hx-work-lead">${entry.summary ? `<p class="hx-work-sum">${escHtml(entry.summary)}</p>` : ''}${changes ? `<p class="hx-faint hx-work-changes">${escHtml(changes)}</p>` : ''}</div>`
99
+ : '';
100
+ const scenarios = Number.isInteger(c.scenarios)
101
+ ? sectionHtml({ key: 'scenarios', title: 'Scenarios', count: c.scenarios, body: `<p class="hx-faint">${c.scenarios ? `${plural(c.scenarios, 'scenario')} to play. Review plays ${c.scenarios === 1 ? 'it' : 'them'} over the map, step by step.` : 'It has no scenario yet.'}</p>` })
102
+ : '';
103
+ // In spec 0015 D4's order: (Connected is the panel's) its pull request's checks and files, the scenarios, the build issue
104
+ return { primary, others, next: pull ? pull.next : '', notes: `${lead}${pull ? pull.notes : ''}`, sections: [...(pull ? pull.sections : []), scenarios, pull ? pull.build : ''] };
85
105
  }
86
106
 
87
- Object.assign(fn, { specsList, waitingNow, loadSpecs, specsShownWords, readSpecsQuiet, syncSpecsPoll, specEntry, proposalActionsHtml });
107
+ Object.assign(fn, { specsList, waitingNow, loadSpecs, specsShownWords, readSpecsQuiet, syncSpecsPoll, specEntry, proposalParts });
88
108
  }