@popcorn245/cornfield 0.55.0 → 0.57.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 (60) hide show
  1. package/core/contrast.js +12 -1
  2. package/core/schema.js +6 -0
  3. package/core/strings.js +1 -2
  4. package/explorer/css/account.css +1 -1
  5. package/explorer/css/changes.css +1 -1
  6. package/explorer/css/dialogs.css +1 -1
  7. package/explorer/css/node-panel.css +1 -1
  8. package/explorer/css/page.css +0 -8
  9. package/explorer/css/sheets.css +1 -1
  10. package/explorer/css/work.css +9 -30
  11. package/explorer/deep-link.js +11 -24
  12. package/explorer/engine/hint.js +2 -2
  13. package/explorer/engine/keyboard.js +1 -1
  14. package/explorer/engine/layers.js +4 -2
  15. package/explorer/engine/map-rect.js +2 -2
  16. package/explorer/engine/map-style.js +4 -1
  17. package/explorer/engine/proposal.js +3 -3
  18. package/explorer/engine/sheets.js +3 -3
  19. package/explorer/focus-room.js +1 -1
  20. package/explorer/forge-panel-model.js +2 -36
  21. package/explorer/forge-panel.js +4 -9
  22. package/explorer/index.html +2 -11
  23. package/explorer/instance-state.js +0 -6
  24. package/explorer/instance.js +15 -9
  25. package/explorer/page-pieces.js +1 -1
  26. package/explorer/page.js +5 -4
  27. package/explorer/pieces/decision.js +3 -3
  28. package/explorer/pieces/layers.js +1 -1
  29. package/explorer/pieces/node-panel.js +38 -14
  30. package/explorer/pieces/proposal.js +6 -6
  31. package/explorer/pieces/review.js +2 -2
  32. package/explorer/pieces/work-agent.js +3 -2
  33. package/explorer/pieces/work-common.js +14 -15
  34. package/explorer/pieces/work-confirm.js +11 -10
  35. package/explorer/pieces/work-data.js +24 -31
  36. package/explorer/pieces/work-deploys.js +42 -41
  37. package/explorer/pieces/work-issues.js +32 -29
  38. package/explorer/pieces/work-list.js +406 -0
  39. package/explorer/pieces/work-markup.js +9 -14
  40. package/explorer/pieces/work-notes.js +0 -1
  41. package/explorer/pieces/work-paint.js +74 -62
  42. package/explorer/pieces/work-prs.js +25 -66
  43. package/explorer/pieces/work-runs.js +47 -57
  44. package/explorer/pieces/work-specs.js +19 -2
  45. package/explorer/pieces/work-threads.js +28 -48
  46. package/explorer/pieces/work.js +38 -40
  47. package/explorer/proposal-model.js +6 -6
  48. package/explorer/proposal.js +1 -1
  49. package/explorer/runs-view.js +10 -18
  50. package/explorer/scene.js +1 -3
  51. package/explorer/sheets.js +1 -1
  52. package/explorer/tokens.css +6 -2
  53. package/explorer/waiting-view.js +3 -3
  54. package/explorer/work-badge-model.js +161 -0
  55. package/explorer/work-badges.js +143 -0
  56. package/explorer/work-model.js +80 -39
  57. package/explorer/work-view.css +11 -4
  58. package/explorer/work-view.js +193 -68
  59. package/package.json +1 -1
  60. package/explorer/pieces/work-events.js +0 -285
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @module explorer/pieces/work-paint
3
3
  *
4
- * Drawing the panel from its state: tabs, counts, filters, the list, the detail, the Work button. Part of the Work piece (pieces/work.js): `install(ctx)` makes this part's functions for one mount, and hands the ones other parts call
4
+ * Drawing the Work list from its state (tabs, counts, filters, the rows) and the node panel's actions for the piece of work it shows. Part of the Work piece (pieces/work.js): `install(ctx)` makes this part's functions for one mount, and hands the ones other parts call
5
5
  * to `ctx.fn`; nothing is shared between two mounts.
6
6
  */
7
7
 
@@ -10,7 +10,7 @@ import { workStatus } from '../agents-model.js';
10
10
  import { loadingRowsHtml } from '../runs-view.js';
11
11
  import { STATES, defaultFilters, filterItems, facetsOf, emptyWords } from '../forge-panel-model.js';
12
12
  import { relativeTime } from '../review-model.js';
13
- import { waiting, specGroups, waitingWords, runWaitingOn } from '../waiting-model.js';
13
+ 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';
@@ -19,13 +19,10 @@ export function install(ctx) {
19
19
  const { inst, ui, m, fn, state, root, $ } = ctx;
20
20
  const { t, refreshStubs, paintWaitingLine } = ctx.h;
21
21
 
22
- /** How to find an element of the panel again after it is drawn anew, or null */
22
+ /** How to find an element of the list or of the node panel's actions again after it is drawn anew, or null */
23
23
  function findAgain(el) {
24
24
  if (!el || !el.dataset) return null;
25
- if (el.classList.contains('hx-forge-back') && el.closest('#forge-detail')) return '#forge-detail .hx-forge-back'; // the detail is drawn anew as its answer comes in
26
- if (el.dataset.forgePr) return `[data-forge-pr="${el.dataset.forgePr}"]`;
27
- if (el.dataset.forgeDeploy) return `[data-forge-deploy="${el.dataset.forgeDeploy}"]`;
28
- if (el.dataset.forgeThread) return `[data-forge-thread="${el.dataset.forgeThread}"]`;
25
+ if (el.dataset.workRef) return `[data-work-ref="${el.dataset.workRef}"]`;
29
26
  if (el.dataset.forgeNode) return `[data-forge-node="${el.dataset.forgeNode}"]`;
30
27
  if (el.dataset.specGroupToggle) return `[data-spec-group-toggle="${el.dataset.specGroupToggle}"]`;
31
28
  if (el.dataset.forgeMerge) return '[data-forge-merge]';
@@ -35,16 +32,14 @@ export function install(ctx) {
35
32
  if (el.dataset.forgeAgent) return `[data-forge-agent="${el.dataset.forgeAgent}"]`;
36
33
  if (el.dataset.forgeStop) return `[data-forge-stop="${el.dataset.forgeStop}"]`;
37
34
  if (el.dataset.forgeRetry) return `[data-forge-retry="${el.dataset.forgeRetry}"]`;
35
+ if (el.dataset.forgeLandingCancel) return '[data-forge-landing-cancel]';
38
36
  if (el.dataset.runReply) return `[data-run-reply="${el.dataset.runReply}"]`;
39
37
  if (el.dataset.runAnswer) return `[data-run-answer="${el.dataset.runAnswer}"][data-run-id="${el.dataset.runId}"]`;
40
- if (el.dataset.runSelect) return `[data-run-select="${el.dataset.runSelect}"]`;
41
38
  if (el.dataset.runTimeline) return `[data-run-timeline="${el.dataset.runTimeline}"]`;
42
39
  return null;
43
40
  }
44
41
 
45
- const key0 = () => fn.detailKey();
46
-
47
- /** Everything the panel shows, from `ui` (a row or node button that had the focus has it again) */
42
+ /** Everything the list shows, from `ui` (a row that had the focus has it again), and the node panel's actions */
48
43
  function paint() {
49
44
  const panel = $('forge-panel');
50
45
  if (!panel) return;
@@ -53,35 +48,57 @@ export function install(ctx) {
53
48
  // A list drawn again must not move what the person is looking at: the scroll of the panel stays where it was
54
49
  const scroller = panel.querySelector('.hx-forge-body');
55
50
  const scrolled = scroller ? scroller.scrollTop : 0;
56
- const keyBefore = m.shownKey;
57
51
  draw(panel);
58
52
  addParts(panel); // the hooks the panel was just drawn with are parts too
59
- if (scroller && scrolled && key0() === keyBefore && scroller.scrollTop !== scrolled) scroller.scrollTop = scrolled;
53
+ if (scroller && scrolled && scroller.scrollTop !== scrolled) scroller.scrollTop = scrolled;
60
54
  const back = again && panel.querySelector(again);
61
55
  if (back && back !== inst.active() && !back.closest('[hidden]')) back.focus();
62
- // Retry was pressed and its notice is gone (the list is being read again): the focus goes to the panel's title, never to the page
56
+ // 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
63
57
  if (had && had.dataset && had.dataset.action === 'retry-forge' && !panel.contains(inst.active())) $('forge-title').focus();
58
+ paintDetail();
59
+ }
60
+
61
+ /** What the last drawing of each place of actions was, so a repaint that changes nothing leaves it (and the focus in it) alone */
62
+ const drawn = new WeakMap();
63
+
64
+ /**
65
+ * The node panel's actions (`forge-detail`, work-model.js `workPanelHtml`) for the piece of work it shows: a pull request's Land it and checks, a thread's messages, a deploy's
66
+ * restarts, an issue's Start an agent, a proposal's Review, a run's card with its answer field. The focus stays on the control that had it; a reply being typed is kept.
67
+ */
68
+ function paintDetail() {
69
+ const box = $('forge-detail');
70
+ if (!box || !ui.item) return;
71
+ const kind = box.dataset.workKind;
72
+ 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
+ const had = box.contains(inst.active()) ? inst.active() : null;
74
+ 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
+ }
84
+ }
85
+ const back = again && box.querySelector(again);
86
+ if (back && back !== inst.active() && !back.closest('[hidden]') && !back.disabled) back.focus();
64
87
  // A control of a run card that is no longer drawn (the run went on): the focus goes to that run's card, never to the page
65
88
  const hadRun = had && !had.isConnected && had.closest('[data-run]');
66
- if (hadRun && !panel.contains(inst.active())) {
67
- const card = [...panel.querySelectorAll('[data-run]')].find((c) => c.dataset.run === hadRun.dataset.run);
89
+ if (hadRun && !box.contains(inst.active())) {
90
+ const card = [...box.querySelectorAll('[data-run]')].find((c) => c.dataset.run === hadRun.dataset.run);
68
91
  if (card) card.focus();
69
92
  }
70
- // A selection replaces the list: the focus goes to its back control, and returns to the row when it is let go of
71
- // (a tab changed leaves the focus on the tab)
72
- const key = fn.detailKey();
73
- if (key !== m.shownKey && m.shownKind === ui.kind) {
74
- if (key) {
75
- const target = panel.querySelector('#forge-detail .hx-forge-back');
76
- if (target && (had || !m.shownKey)) target.focus();
77
- } else {
78
- const row = m.returnTo && panel.querySelector(m.returnTo);
79
- if (row && !row.closest('[hidden]')) row.focus(); else $('forge-title').focus();
80
- m.returnTo = null;
81
- }
82
- }
83
- m.shownKey = key;
84
- m.shownKind = ui.kind;
93
+ }
94
+
95
+ /** 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 */
96
+ function noteHtml(kind) {
97
+ 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)
98
+ const link = note && safeUrl(note.url);
99
+ const done = note ? `<p class="hx-forge-notice${note.ok ? ' hx-forge-notice--ok' : ''}" data-corn="notice"${note.ok ? ' data-corn-state="success"' : ''}>${escHtml(note.text)}${link ? ` <a data-corn="text-link" class="hx-link" href="${escHtml(link)}" target="_blank" rel="noreferrer">Open on ${escHtml(fn.forgeName())} ↗</a>` : ''}</p>` : '';
100
+ const started = ui.runNote && ui.runNote.ref === ui.ref && (kind === 'issue' || kind === 'proposal') ? `<p class="hx-forge-notice${ui.runNote.ok ? ' hx-forge-notice--ok' : ''}" data-corn="notice"${ui.runNote.ok ? ' data-corn-state="success"' : ''}>${escHtml(ui.runNote.text)}</p>` : '';
101
+ return done + started;
85
102
  }
86
103
 
87
104
  /** The tabs' counts, where there is one: the proposals, the open pull requests and issues and threads, the runs still open */
@@ -132,10 +149,27 @@ export function install(ctx) {
132
149
  }
133
150
 
134
151
  /** Says (on the panel's top, for the CSS) that the tabs run on past an edge: a fade shows on that side, so Deploys is not simply missing on a phone */
152
+ let tabsFor = null; // the tab the strip was last scrolled to show: the strip follows the tab that is on (and is left alone while the viewer scrolls it)
135
153
  function paintTabsMore() {
136
154
  const top = root.querySelector('#forge-panel .hx-forge-top');
137
155
  const tabs = top && top.querySelector('.hx-forge-tabs');
138
156
  if (!tabs) return;
157
+ // The tab that is on is brought into the strip (Deploys is the sixth: a list opened on it, or a tab pressed, must not leave it under the edge). A strip that is not laid out
158
+ // (the list shut, a phone's sheet in its peek) is asked again when it is
159
+ const active = tabs.clientWidth ? tabs.querySelector('[aria-pressed="true"]') : null;
160
+ if (!tabs.clientWidth) tabsFor = null;
161
+ else if (active && tabsFor !== ui.kind) {
162
+ tabsFor = ui.kind;
163
+ const box = tabs.getBoundingClientRect();
164
+ const at = active.getBoundingClientRect();
165
+ // Clear of the fade the strip puts on an edge it runs on past (css/work.css: one and a half `--corn-space-6`); the first and the last tab go to their end of the strip
166
+ const room = 1.5 * (parseFloat(inst.win.getComputedStyle(tabs).getPropertyValue('--corn-space-6')) || 24);
167
+ const shown = [...tabs.children].filter((c) => !c.hidden);
168
+ if (active === shown[0]) tabs.scrollLeft = 0;
169
+ else if (active === shown[shown.length - 1]) tabs.scrollLeft = tabs.scrollWidth;
170
+ else if (at.left < box.left + room) tabs.scrollLeft += at.left - box.left - room;
171
+ else if (at.right > box.right - room) tabs.scrollLeft += at.right - box.right + room;
172
+ }
139
173
  const more = [];
140
174
  if (tabs.scrollLeft > 1) more.push('start');
141
175
  if (tabs.scrollWidth - tabs.clientWidth - tabs.scrollLeft > 1) more.push('end');
@@ -165,17 +199,15 @@ export function install(ctx) {
165
199
  paintCounts();
166
200
  const notes = ui.kind === 'notes';
167
201
  const specs = ui.kind === 'specs';
168
- const showing = fn.detailKey();
169
202
  $('forge-filters').hidden = notes || ui.kind === 'work' || specs;
170
203
  const searchBox = $('forge-specs-search');
171
- if (searchBox) searchBox.hidden = !specs || !!showing;
204
+ if (searchBox) searchBox.hidden = !specs;
172
205
  $('forge-work-filters').hidden = ui.kind !== 'work';
173
- $('forge-bar').hidden = !!showing;
174
206
  paintChip();
175
- $('forge-list').hidden = notes || !!showing;
207
+ $('forge-list').hidden = notes;
176
208
  $('forge-notes').hidden = !notes;
177
- $('notes-open').hidden = ui.kind !== 'pulls' || !!showing;
178
- $('forge-foot').hidden = notes || !!showing;
209
+ $('notes-open').hidden = ui.kind !== 'pulls';
210
+ $('forge-foot').hidden = notes;
179
211
  if (notes) {
180
212
  fn.drawNotes();
181
213
  return;
@@ -213,46 +245,26 @@ export function install(ctx) {
213
245
  // are drawn with the work's answer all the same, which loadWork paints only once the runs are read too, failed or not.)
214
246
  if (!list) rows.innerHTML = ui.loading && !(work && !(ui.runs && ui.runs.data)) ? loadingRowsHtml(4) : '';
215
247
  else if (specs) {
216
- const open = state.proposal ? { slug: state.proposalSlug, source: state.proposalSource } : null;
217
248
  const groups = specGroups(list.items, { query: ui.specQuery });
218
- rows.innerHTML = groups.length ? specGroupsHtml(groups, { current: open, nowMs: m.now(), draftsOpen: ui.draftsOpen, say: t })
249
+ rows.innerHTML = groups.length ? specGroupsHtml(groups, { shown: ui.ref, nowMs: m.now(), draftsOpen: ui.draftsOpen, say: t })
219
250
  : list.items.length ? `<li class="hx-forge-empty hx-faint" data-corn="empty">No spec matches \u201c${escHtml(ui.specQuery.trim())}\u201d. <button type="button" class="hx-btn hx-forge-act" data-corn-kind="quiet" data-action="clear-specs-search">Clear the search</button></li>`
220
251
  : empty(emptyWords('specs', fn.forgeName()));
221
252
  }
222
253
  else if (work) rows.innerHTML = groups.length ? fn.groupsHtml(groups) : empty(ui.work.grouped.groups.length ? 'No work matches these filters.' : emptyWords('work', fn.forgeName()));
223
254
  else rows.innerHTML = shown.length ? shown.map((i) => fn.itemHtml(i)).join('') : empty(list.items.length ? `No ${fn.kindWords()} matches these filters.` : emptyWords(ui.kind, fn.forgeName()));
224
255
 
225
- const detail = $('forge-detail');
226
- detail.hidden = !showing;
227
- detail.setAttribute('aria-label', showing.startsWith('thread:') ? 'Selected thread' : showing.startsWith('deploy:') ? 'Selected deploy' : 'Selected pull request');
228
- detail.innerHTML = fn.detailHtml();
229
-
230
256
  fn.paintIdea();
231
257
  $('forge-foot').hidden = $('notes-open').hidden && $('forge-idea').hidden;
232
- const rate = (showing && ((ui.threadDetail && ui.threadDetail.rate) || (ui.detail && ui.detail.rate))) || (list && list.rate) || '';
258
+ const rate = (list && list.rate) || '';
233
259
  $('forge-rate').textContent = rate;
234
260
  fn.paintRuns();
235
261
  paintButton();
236
262
  paintTabsMore();
237
263
  }
238
264
 
239
- /** The toggles that open the panel (`data-action="toggle-forge"`: the header's, whatever it calls it) say whether it is open, and the old button which selection is lit */
265
+ /** The toggles that open the list (`data-action="toggle-forge"`: the Work view's List) say whether it is open */
240
266
  function paintButton() {
241
267
  for (const toggle of root.querySelectorAll('[data-action="toggle-forge"]')) toggle.setAttribute('aria-expanded', String(ui.open));
242
- const btn = $('forge-btn');
243
- if (!btn) return;
244
- const lit = ui.selected !== null || !!ui.deployItem || ui.thread !== null || !!ui.runSel;
245
- const tag = $('forge-btn-lit');
246
- if (tag) {
247
- tag.hidden = !lit;
248
- tag.textContent = ui.runSel ? 'run' : ui.thread !== null ? `thread #${ui.thread}` : ui.deployItem ? 'deploy' : lit ? `#${ui.selected}` : '';
249
- }
250
- // A run would wait for a runner that is not there: a dot, and the name says so (issue #183); it sits beside the waiting badge, not on it
251
- const away = fn.runnerAway();
252
- const dot = $('forge-btn-dot');
253
- if (dot) dot.hidden = !away;
254
- // What waits on the maintainer is the badge of the view switch's Work (work-view.js): this button opens the panel, and says so while both exist (spec 0012 D1, until step 3)
255
- btn.setAttribute('aria-label', `${t('workPanel')}${away ? ', no runner online' : ''}${ui.runSel ? ', a run lit on the map' : ui.thread !== null ? `, thread ${ui.thread} selected` : ui.deployItem ? ', a deploy selected' : lit ? `, pull request ${ui.selected} selected` : ''}`);
256
268
  }
257
269
 
258
270
  /** Whether the Filter chip applies to the view: the proposals and the release notes have nothing to filter */
@@ -270,7 +282,7 @@ export function install(ctx) {
270
282
  function paintChip() {
271
283
  const chip = $('forge-filter-chip');
272
284
  const box = $('forge-filter-box');
273
- const on = filterable() && !fn.detailKey();
285
+ const on = filterable();
274
286
  const n = activeFilters();
275
287
  chip.hidden = !on;
276
288
  chip.setAttribute('aria-expanded', String(on && ui.filtersOpen));
@@ -303,5 +315,5 @@ export function install(ctx) {
303
315
  $('forge-text').placeholder = ui.kind === 'deploys' ? 'Workflow, branch, commit, who' : ui.kind === 'threads' ? 'Title, number, author' : 'Title, number, label';
304
316
  }
305
317
 
306
- Object.assign(fn, { findAgain, key0, paint, paintCounts, paintWaiting, paintBarLine, paintTitle, paintTabsMore, setNotice, draw, paintButton, filterable, activeFilters, paintChip, paintFilters });
318
+ Object.assign(fn, { findAgain, paint, paintDetail, paintCounts, paintWaiting, paintBarLine, paintTitle, paintTabsMore, setNotice, draw, paintButton, filterable, activeFilters, paintChip, paintFilters });
307
319
  }
@@ -1,25 +1,24 @@
1
1
  /**
2
2
  * @module explorer/pieces/work-prs
3
3
  *
4
- * The PRs tab: the list rows, a pull request's detail (files, checks, merge, rerun, landing) and the lights it puts on the map. Part of the Work piece (pieces/work.js): `install(ctx)` makes this part's functions for one mount, and hands the ones other parts call
4
+ * The PRs tab: the list rows, and a pull request's detail in the node panel (its files, checks, Land it, Re-run, landing). Part of the Work piece (pieces/work.js): `install(ctx)` makes this part's functions for one mount, and hands the ones other parts call
5
5
  * to `ctx.fn`; nothing is shared between two mounts.
6
6
  */
7
7
 
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, specBlock, buildOffers, approvalWarning } from '../forge-panel-model.js';
11
+ import { pullUrl, stateWords, metaWords, checkWords, checksWords, landingUrl, cancelLandingUrl, landingWords, mergeBlock, rerunWhy, actionUrl, actionWords, buildOffers, approvalWarning } from '../forge-panel-model.js';
12
12
  import { cornStateAttr, stateIconHtml } from '../corn-state.js';
13
- import { relativeTime } from '../review-model.js';
14
13
  import { waiting } from '../waiting-model.js';
15
14
  import { escapeHtml as escHtml } from '../../core/text.js';
16
- import { plural, safeUrl, backHtml } from './work-common.js';
15
+ import { plural, safeUrl } from './work-common.js';
17
16
 
18
17
  export function install(ctx) {
19
18
  const { ui, m, fn, state, $ } = ctx;
20
- const { announce, t, render, touchScene, isNodeVisible } = ctx.h;
19
+ const { announce, t, isNodeVisible } = ctx.h;
21
20
 
22
- /** Selects a pull request: asks for its files and checks, then lights what they are on the map */
21
+ /** Shows a pull request in the node panel: asks for its files and checks (the node panel's own line of checks is read from the same route) */
23
22
  async function selectPull(n) {
24
23
  const token = ++m.pullToken;
25
24
  fn.dropThread();
@@ -27,17 +26,13 @@ export function install(ctx) {
27
26
  ui.deployItem = null;
28
27
  ui.litDeploy = null;
29
28
  ui.selected = n;
30
- ui.selectedOn = ui.kind; // the PRs list or the Runs tab's groups: its detail replaces that list only
31
29
  ui.detail = null;
32
30
  ui.landing = null;
33
31
  ui.detailError = '';
34
32
  ui.lit = null;
35
33
  ui.note = null;
36
- state.forgeLit = null;
37
- touchScene();
38
- render();
39
34
  fn.paint();
40
- const res = await fn.request(pullUrl(n), false);
35
+ const res = fn.preloaded('pull', n) || await fn.request(pullUrl(n), false);
41
36
  if (token !== m.pullToken) return;
42
37
  if (!res.ok) {
43
38
  ui.detailError = fn.failWords(res, `pull request ${n}`);
@@ -46,12 +41,11 @@ export function install(ctx) {
46
41
  return;
47
42
  }
48
43
  ui.detail = { pull: res.body.pull, files: res.body.files || [], checks: res.body.checks || [], specs: res.body.specs || [], at: res.body.at, rate: res.body.rate || '', stale: res.body.stale || '' };
49
- fn.relight();
44
+ fn.figure();
50
45
  // The run that made it is on the detail: the runs are read once, if the config has any
51
46
  if (!ui.runs && ui.config.agents && ui.config.agents.runs) fn.loadRuns(false, { say: false }).then(() => { if (ui.selected === n) fn.paint(); }, () => {});
52
47
  await loadLanding(n, token);
53
- $('forge-panel').querySelector('.hx-forge-body').scrollTop = 0; // the pull request's files are what was asked for, not the row that was tapped
54
- announce(selectionWords());
48
+ fn.sayDetail(selectionWords());
55
49
  }
56
50
 
57
51
  /** Asks the server whether the selected pull request waits to land on its approval (a read of the server's own state, not of the forge); nothing is shown when it does not */
@@ -78,10 +72,9 @@ export function install(ctx) {
78
72
  if (ui.selected === n) await fn.refreshForge({ quiet: true });
79
73
  }
80
74
 
81
- /** Lets go of the selected pull request: nothing is lit any more */
75
+ /** Lets go of the pull request in the node panel (another node was chosen, or the panel closed) */
82
76
  function clearPull() {
83
77
  m.pullToken++;
84
- const had = ui.selected;
85
78
  if (ui.confirm) fn.closeConfirm({ restoreFocus: false });
86
79
  ui.selected = null;
87
80
  ui.note = null;
@@ -89,21 +82,16 @@ export function install(ctx) {
89
82
  ui.landing = null;
90
83
  ui.detailError = '';
91
84
  ui.lit = null;
92
- state.forgeLit = null;
93
- touchScene();
94
- render();
95
- fn.paint();
96
- if (had !== null) announce(`Pull request ${had} cleared`);
97
85
  }
98
86
 
99
87
  /** What a screen reader hears when a pull request is selected */
100
88
  function selectionWords() {
101
89
  const { pull, files, checks } = ui.detail;
102
90
  const mapped = ui.lit ? ui.lit.files.filter((f) => f.nodes.length).length : 0;
103
- const lit = ui.lit ? new Set([...ui.lit.changed, ...ui.lit.failing]).size : 0;
104
- return `Pull request ${pull.number}, ${pull.title}: ${plural(files.length, 'file')}, ${mapped} on the map${lit ? `, ${plural(lit, 'node')} lit` : ''}. ${checksWords(checks)}.`;
91
+ return `Pull request ${pull.number}, ${pull.title}: ${plural(files.length, 'file')}, ${mapped} on the map. ${checksWords(checks)}.`;
105
92
  }
106
93
 
94
+ /** A row of the PRs, Issues and Runs lists: it selects its node (the node panel shows the rest); a link out to the forge beside it */
107
95
  function itemHtml(item, before = '', after = '') {
108
96
  if (ui.kind === 'deploys') return fn.deployHtml(item);
109
97
  if (ui.kind === 'threads') return fn.threadHtml(item);
@@ -112,37 +100,14 @@ export function install(ctx) {
112
100
  const inner = `<span class="hx-forge-title">${escHtml(item.title)}</span>
113
101
  <span class="hx-forge-meta"><span class="hx-forge-state hx-forge-state--${escHtml(item.draft ? 'draft' : item.state)}" data-corn="state-pill"${cornStateAttr(item.draft ? 'draft' : item.state)}>${escHtml(stateWords(item))}</span> ${escHtml(metaWords(item, m.now()))}</span>${before}${after}${labels}`;
114
102
  const out = link ? `<a data-corn="out-link" class="hx-forge-out" href="${escHtml(link)}" target="_blank" rel="noreferrer" aria-label="Open ${escHtml(item.head ? 'pull request' : 'issue')} ${item.number} on ${escHtml(fn.forgeName())} (new tab)">↗</a>` : '';
115
- if (ui.kind !== 'issues') {
116
- return `<li class="hx-forge-item"><button type="button" class="hx-forge-row" data-forge-pr="${item.number}" aria-pressed="${ui.selected === item.number}" data-corn="row">${inner}</button>${out}</li>`;
117
- }
118
- // An issue has no more to show here: its row is the link out; an open one also starts its spec (step 1 of the pipeline)
119
- const spec = specBlock(item) === null
120
- ? `<button data-corn-kind="secondary" type="button" class="hx-btn hx-forge-act hx-forge-startspec" data-forge-spec="${item.number}" aria-label="Start a spec for issue ${item.number}"${ui.busy ? ' disabled' : ''}>Start a spec …</button>`
121
- : '';
122
- const agent = item.state === 'open'
123
- ? `<button data-corn-kind="secondary" type="button" class="hx-btn hx-forge-act hx-forge-startspec" data-forge-agent="issue:${item.number}" aria-label="${escHtml(t('startAgent'))} on issue ${item.number}">${escHtml(t('startAgent'))} …</button>`
124
- : '';
125
- return link
126
- ? `<li class="hx-forge-item"><a class="hx-forge-row" href="${escHtml(link)}" target="_blank" rel="noreferrer" data-corn="row">${inner}<span class="hx-sr-only"> (opens ${escHtml(fn.forgeName())} in a new tab)</span></a>${spec}${agent}</li>`
127
- : `<li class="hx-forge-item"><div class="hx-forge-row" data-corn="row">${inner}</div>${spec}${agent}</li>`;
128
- }
129
-
130
- /** Which selection replaces the list now, as a key ('pr:12', 'thread:3', 'deploy:9004'), or '' while the list shows. A selection stays lit on the map but shows only on the tab it belongs to. */
131
- function detailKey() {
132
- if (ui.kind === 'threads' && ui.thread !== null) return `thread:${ui.thread}`;
133
- if (ui.kind === 'deploys' && ui.deployItem) return `deploy:${ui.deploy}`;
134
- if (ui.selected !== null && ui.kind === ui.selectedOn) return `pr:${ui.selected}`;
135
- return '';
103
+ const ref = `${item.head ? 'pull' : 'issue'}:${item.number}`;
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>`;
136
105
  }
137
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. */
138
108
  function detailHtml() {
139
- const shown = detailKey();
140
- if (shown.startsWith('thread:')) return fn.threadDetailHtml();
141
- if (shown.startsWith('deploy:')) return fn.deployDetailHtml();
142
- if (!shown) return '';
143
- const head = (title, meta) => `${backHtml('clear-forge-pr', ui.kind === 'work' ? 'All work' : 'All pull requests')}${meta || ''}<h3 class="hx-forge-detail-title" data-corn="detail-title">${title}</h3>`;
144
- if (ui.detailError) return `${head(`Pull request ${ui.selected}`)}<p class="hx-forge-notice" data-corn="notice">${escHtml(ui.detailError)}</p>`;
145
- if (!ui.detail) return `${head(`Pull request ${ui.selected}`)}<p class="hx-faint">Loading its files and checks …</p><ul class="hx-forge-list" aria-hidden="true">${loadingRowsHtml(4)}</ul>`;
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>`;
146
111
  const { pull, checks, stale } = ui.detail;
147
112
  const lit = ui.lit;
148
113
  const mapped = lit.files.filter((f) => f.nodes.length).length;
@@ -153,8 +118,8 @@ export function install(ctx) {
153
118
  const failed = failing.get(c.id);
154
119
  const lights = failed
155
120
  ? `<span class="hx-faint hx-forge-lights">${failed.tests.length
156
- ? `Lights ${failed.tests.map((t) => `<code class="hx-code">${escHtml(t.path)}</code>${t.nodes.length ? '' : ' (not on the map)'}`).join(', ')}`
157
- : 'Names no test file, so lights nothing'}</span>`
121
+ ? `Names ${failed.tests.map((t) => `<code class="hx-code">${escHtml(t.path)}</code>${t.nodes.length ? '' : ' (not on the map)'}`).join(', ')}`
122
+ : 'Names no test file'}</span>`
158
123
  : '';
159
124
  const name = safeUrl(c.url) ? `<a data-corn="text-link" class="hx-link" href="${escHtml(c.url)}" target="_blank" rel="noreferrer">${escHtml(c.name)}</a>` : `<span class="hx-name">${escHtml(c.name)}</span>`;
160
125
  const why = rerunWhy(c, fn.forgeName());
@@ -187,31 +152,25 @@ export function install(ctx) {
187
152
  // Step 2 of the pipeline: a spec pull request with an approved proposal opens its build issue
188
153
  const offers = buildOffers(ui.detail);
189
154
  const build = offers.length
190
- ? `<h4 class="hx-forge-subact">Build issue</h4>${offers.map((o) => (o.offer
155
+ ? `<h3 class="hx-forge-subact">Build issue</h3>${offers.map((o) => (o.offer
191
156
  ? `<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 ? ' disabled' : ''} 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>`
192
157
  : `<p class="hx-forge-why hx-faint"><code class="hx-code">${escHtml(o.slug)}</code>: ${escHtml(o.why)}</p>`)).join('')}`
193
158
  : '';
194
159
 
195
- const key = lit.changed.size || lit.failing.size
196
- ? `<p class="hx-forge-key hx-faint">${lit.changed.size ? '<span class="hx-mark-dot hx-mark-dot--changed" data-corn="mark-dot" data-corn-state="changed" aria-hidden="true"></span>a file this pull request changes ' : ''}${lit.failing.size ? '<span class="hx-mark-dot hx-mark-dot--removed" data-corn="mark-dot" data-corn-state="removed" aria-hidden="true"></span>a test a failing check names' : ''}</p>`
197
- : '';
198
160
  // 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)
199
161
  const runs = ui.runs && ui.runs.data ? ui.runs.data.runs : null;
200
162
  const made = runOnPull(runs, pull.number);
201
163
  const runSection = made
202
- ? `<h4 class="hx-forge-sub">Run</h4><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>`
164
+ ? `<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>`
203
165
  : '';
204
- const meta = `<p class="hx-forge-meta hx-forge-dmeta"><span class="hx-forge-state hx-forge-state--${escHtml(pull.draft ? 'draft' : pull.state)}" data-corn="state-pill"${cornStateAttr(pull.draft ? 'draft' : pull.state)}>${escHtml(stateWords(pull))}</span> <span data-corn="count">#${escHtml(String(pull.number))}</span> <span>${escHtml(pull.head.ref)} → ${escHtml(pull.base.ref)}</span> <span>${escHtml(pull.author ? pull.author.login : 'someone')}</span> <span>${escHtml(relativeTime(pull.createdAt || pull.updatedAt, m.now()))}</span></p>`;
205
- return `${head(escHtml(pull.title), meta)}
206
- ${act}
166
+ return `${act}
207
167
  ${stale ? `<p class="hx-forge-notice" data-corn="notice">${escHtml(`This is an older answer. ${stale}`)}</p>` : ''}
208
168
  ${note}
209
169
  ${waiting}
210
170
  ${build}
211
- <h4 class="hx-forge-sub">Checks: ${escHtml(checksWords(checks))}</h4>
171
+ <h3 class="hx-forge-sub">Checks: ${escHtml(checksWords(checks))}</h3>
212
172
  ${checks.length ? `<ul class="hx-forge-checks">${checkRows}</ul>` : ''}
213
- <h4 class="hx-forge-sub">${escHtml(plural(lit.files.length, 'file'))} changed, ${mapped} on the map</h4>
214
- ${key}
173
+ <h3 class="hx-forge-sub">${escHtml(plural(lit.files.length, 'file'))} changed, ${mapped} on the map</h3>
215
174
  <ul class="hx-forge-files">${fileRows}</ul>
216
175
  ${runSection}`;
217
176
  }
@@ -223,7 +182,7 @@ export function install(ctx) {
223
182
  async function finishAction(action, res, n) {
224
183
  const text = actionWords(action, res.status, res.body, n);
225
184
  ui.busy = '';
226
- ui.note = { text, ok: res.ok };
185
+ if (ui.selected === n) ui.note = { text, ok: res.ok }; // shown with its pull request only: another chosen while it was sent does not carry it (it is said all the same)
227
186
  announce(text);
228
187
  fn.paint();
229
188
  if (res.status === null) return;
@@ -249,5 +208,5 @@ export function install(ctx) {
249
208
  }
250
209
 
251
210
  // what other parts put in the panel gets its parts (a hook is a part of the same name)
252
- Object.assign(fn, { selectPull, loadLanding, cancelLanding, clearPull, selectionWords, itemHtml: (...a) => withParts(itemHtml(...a)), detailKey, detailHtml: (...a) => withParts(detailHtml(...a)), nodeButton: (n) => withParts(nodeButton(n)), finishAction, rerunCheck });
211
+ 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 });
253
212
  }