cornfield 0.55.0 → 0.56.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 (39) hide show
  1. package/core/contrast.js +12 -1
  2. package/core/schema.js +6 -0
  3. package/core/strings.js +0 -1
  4. package/explorer/css/page.css +0 -8
  5. package/explorer/css/work.css +3 -26
  6. package/explorer/deep-link.js +11 -24
  7. package/explorer/engine/map-style.js +4 -1
  8. package/explorer/forge-panel-model.js +2 -36
  9. package/explorer/forge-panel.js +3 -8
  10. package/explorer/index.html +1 -10
  11. package/explorer/instance-state.js +0 -6
  12. package/explorer/instance.js +9 -5
  13. package/explorer/page.js +5 -4
  14. package/explorer/pieces/node-panel.js +9 -5
  15. package/explorer/pieces/work-agent.js +3 -2
  16. package/explorer/pieces/work-common.js +14 -15
  17. package/explorer/pieces/work-confirm.js +11 -10
  18. package/explorer/pieces/work-data.js +24 -31
  19. package/explorer/pieces/work-deploys.js +42 -41
  20. package/explorer/pieces/work-issues.js +32 -29
  21. package/explorer/pieces/work-list.js +406 -0
  22. package/explorer/pieces/work-markup.js +9 -14
  23. package/explorer/pieces/work-notes.js +0 -1
  24. package/explorer/pieces/work-paint.js +57 -62
  25. package/explorer/pieces/work-prs.js +25 -66
  26. package/explorer/pieces/work-runs.js +47 -57
  27. package/explorer/pieces/work-specs.js +19 -2
  28. package/explorer/pieces/work-threads.js +28 -48
  29. package/explorer/pieces/work.js +28 -40
  30. package/explorer/proposal-model.js +5 -5
  31. package/explorer/runs-view.js +10 -18
  32. package/explorer/scene.js +1 -3
  33. package/explorer/tokens.css +4 -0
  34. package/explorer/waiting-view.js +3 -3
  35. package/explorer/work-model.js +79 -38
  36. package/explorer/work-view.css +3 -4
  37. package/explorer/work-view.js +77 -49
  38. package/package.json +1 -1
  39. 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 */
@@ -165,17 +182,15 @@ export function install(ctx) {
165
182
  paintCounts();
166
183
  const notes = ui.kind === 'notes';
167
184
  const specs = ui.kind === 'specs';
168
- const showing = fn.detailKey();
169
185
  $('forge-filters').hidden = notes || ui.kind === 'work' || specs;
170
186
  const searchBox = $('forge-specs-search');
171
- if (searchBox) searchBox.hidden = !specs || !!showing;
187
+ if (searchBox) searchBox.hidden = !specs;
172
188
  $('forge-work-filters').hidden = ui.kind !== 'work';
173
- $('forge-bar').hidden = !!showing;
174
189
  paintChip();
175
- $('forge-list').hidden = notes || !!showing;
190
+ $('forge-list').hidden = notes;
176
191
  $('forge-notes').hidden = !notes;
177
- $('notes-open').hidden = ui.kind !== 'pulls' || !!showing;
178
- $('forge-foot').hidden = notes || !!showing;
192
+ $('notes-open').hidden = ui.kind !== 'pulls';
193
+ $('forge-foot').hidden = notes;
179
194
  if (notes) {
180
195
  fn.drawNotes();
181
196
  return;
@@ -213,46 +228,26 @@ export function install(ctx) {
213
228
  // are drawn with the work's answer all the same, which loadWork paints only once the runs are read too, failed or not.)
214
229
  if (!list) rows.innerHTML = ui.loading && !(work && !(ui.runs && ui.runs.data)) ? loadingRowsHtml(4) : '';
215
230
  else if (specs) {
216
- const open = state.proposal ? { slug: state.proposalSlug, source: state.proposalSource } : null;
217
231
  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 })
232
+ rows.innerHTML = groups.length ? specGroupsHtml(groups, { shown: ui.ref, nowMs: m.now(), draftsOpen: ui.draftsOpen, say: t })
219
233
  : 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
234
  : empty(emptyWords('specs', fn.forgeName()));
221
235
  }
222
236
  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
237
  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
238
 
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
239
  fn.paintIdea();
231
240
  $('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) || '';
241
+ const rate = (list && list.rate) || '';
233
242
  $('forge-rate').textContent = rate;
234
243
  fn.paintRuns();
235
244
  paintButton();
236
245
  paintTabsMore();
237
246
  }
238
247
 
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 */
248
+ /** The toggles that open the list (`data-action="toggle-forge"`: the Work view's List) say whether it is open */
240
249
  function paintButton() {
241
250
  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
251
  }
257
252
 
258
253
  /** Whether the Filter chip applies to the view: the proposals and the release notes have nothing to filter */
@@ -270,7 +265,7 @@ export function install(ctx) {
270
265
  function paintChip() {
271
266
  const chip = $('forge-filter-chip');
272
267
  const box = $('forge-filter-box');
273
- const on = filterable() && !fn.detailKey();
268
+ const on = filterable();
274
269
  const n = activeFilters();
275
270
  chip.hidden = !on;
276
271
  chip.setAttribute('aria-expanded', String(on && ui.filtersOpen));
@@ -303,5 +298,5 @@ export function install(ctx) {
303
298
  $('forge-text').placeholder = ui.kind === 'deploys' ? 'Workflow, branch, commit, who' : ui.kind === 'threads' ? 'Title, number, author' : 'Title, number, label';
304
299
  }
305
300
 
306
- Object.assign(fn, { findAgain, key0, paint, paintCounts, paintWaiting, paintBarLine, paintTitle, paintTabsMore, setNotice, draw, paintButton, filterable, activeFilters, paintChip, paintFilters });
301
+ Object.assign(fn, { findAgain, paint, paintDetail, paintCounts, paintWaiting, paintBarLine, paintTitle, paintTabsMore, setNotice, draw, paintButton, filterable, activeFilters, paintChip, paintFilters });
307
302
  }
@@ -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
  }
@@ -1,14 +1,14 @@
1
1
  /**
2
2
  * @module explorer/pieces/work-runs
3
3
  *
4
- * The Runs tab: the groups, a run, Stop, answer, the brief, the poll, and the runs 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 Runs tab: the groups and the runs' rows; a run in the node panel (its card: Stop, answer, Start again, the timeline); the poll, and the runs 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
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 { 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 { runsHtml, totalsHtml, loadingRowsHtml, loadingLinesHtml } from '../runs-view.js';
11
+ import { runHtml, 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';
@@ -20,7 +20,7 @@ export function install(ctx) {
20
20
  const groupsShown = () => (ui.work ? filterGroups(ui.work.grouped.groups, ui.workFilters) : []);
21
21
 
22
22
  /** Loads the Agents tab: everything it groups, in one answer */
23
- async function loadWork(refresh, token) {
23
+ async function loadWork(refresh, token, quiet = false) {
24
24
  ui.loading = true;
25
25
  ui.error = '';
26
26
  fn.paint();
@@ -30,10 +30,10 @@ export function install(ctx) {
30
30
  if (res.ok) {
31
31
  const b = res.body;
32
32
  ui.work = { grouped: groupWork(b), problem: b.specsProblem || '', at: b.at, rate: b.rate || '', stale: b.stale || '' };
33
- announce(`${workStatus(groupsShown(), '', m.now())}${ui.work.stale ? '. This is an older answer' : ''}`);
33
+ if (!quiet) announce(`${workStatus(groupsShown(), '', m.now())}${ui.work.stale ? '. This is an older answer' : ''}`);
34
34
  } else {
35
35
  ui.error = fn.failWords(res, 'the work');
36
- announce(ui.error);
36
+ if (!quiet) announce(ui.error);
37
37
  }
38
38
  fn.paint();
39
39
  }
@@ -48,7 +48,6 @@ export function install(ctx) {
48
48
  // The map shows the open runs' nodes; a run lit on the map follows its nodes; what changed is said, once the first answer is in
49
49
  setRunsOnMap(ui.runs.data.runs);
50
50
  syncRunsPoll();
51
- if (ui.runSel) relightRun();
52
51
  const said = say ? changeWords(before, ui.runs.data.runs) : [];
53
52
  // A runner appearing or going quiet is said once, when the state changes (the line itself is plain text, not a live region). The state last
54
53
  // shown is kept, not worked out again from the last listing: a runner that goes quiet is the same listing judged later
@@ -102,9 +101,7 @@ export function install(ctx) {
102
101
  function groupsHtml(groups) {
103
102
  return groups.map((g, i) => {
104
103
  const link = g.issue && safeUrl(g.issue.url) ? ` <a data-corn="text-link" class="hx-link hx-forge-gout" href="${escHtml(g.issue.url)}" target="_blank" rel="noreferrer" aria-label="Open issue ${g.number} on ${escHtml(fn.forgeName())} (new tab)">↗</a>` : '';
105
- const startRef = g.kind === 'issue' && g.issue && g.issue.state === 'open' ? `issue:${g.number}` : g.kind === 'proposal' ? `proposal:${g.slug}` : null;
106
- const start = startRef ? ` <button data-corn-kind="secondary" type="button" class="hx-btn hx-forge-act" data-forge-agent="${escHtml(startRef)}" aria-label="${escHtml(t('startAgent'))} on ${escHtml(g.kind === 'issue' ? `issue ${g.number}` : `proposal ${g.slug}`)}">${escHtml(t('startAgent'))} …</button>` : '';
107
- return `<li class="hx-forge-group"><h3 class="hx-forge-gtitle" id="forge-group-${i}">${escHtml(g.title)}${link}</h3>${start}<p class="hx-forge-meta">${escHtml(groupWords(g))}</p><ul class="hx-forge-list" aria-labelledby="forge-group-${i}">${g.entries.map(workHtml).join('')}</ul></li>`;
104
+ return `<li class="hx-forge-group"><h3 class="hx-forge-gtitle" id="forge-group-${i}">${escHtml(g.title)}${link}</h3><p class="hx-forge-meta">${escHtml(groupWords(g))}</p><ul class="hx-forge-list" aria-labelledby="forge-group-${i}">${g.entries.map(workHtml).join('')}</ul></li>`;
108
105
  }).join('');
109
106
  }
110
107
 
@@ -112,7 +109,7 @@ export function install(ctx) {
112
109
  function paintRuns() {
113
110
  const box = $('forge-runs');
114
111
  if (!box) return;
115
- box.hidden = ui.kind !== 'work' || !!fn.detailKey();
112
+ box.hidden = ui.kind !== 'work';
116
113
  if (box.hidden) return;
117
114
  const data = ui.runs && ui.runs.data;
118
115
  $('forge-runs-status').textContent = data ? runsStatus(data) : ui.loading ? 'Loading the runs …' : '';
@@ -146,7 +143,25 @@ export function install(ctx) {
146
143
  const list = $('forge-runs-list');
147
144
  list.setAttribute('aria-busy', String(!data && !!ui.loading));
148
145
  if (!data) { list.innerHTML = ui.loading ? loadingRowsHtml(3) : ''; return; }
149
- patchList(list, data.runs.length ? runsHtml(viewContext(), data.runs) : '<li class="hx-forge-empty hx-faint" data-corn="empty">No agent has been asked for yet. Start one from an issue or a proposal: Issues, then Start an agent.</li>');
146
+ patchList(list, data.runs.length ? runRowsHtml({ ...viewContext(), shown: ui.runShown }, data.runs) : '<li class="hx-forge-empty hx-faint" data-corn="empty">No agent has been asked for yet. Start one from an issue or a proposal: select it on the map, then Start an agent.</li>');
147
+ }
148
+
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
+ function paintRunCard() {
151
+ const box = $('forge-detail');
152
+ if (!box) return;
153
+ let list = box.querySelector('#forge-run-card');
154
+ if (!list) {
155
+ list = inst.doc.createElement('ul');
156
+ list.id = 'forge-run-card';
157
+ list.className = 'hx-forge-files';
158
+ list.setAttribute('aria-label', 'Run');
159
+ box.replaceChildren(list);
160
+ }
161
+ const run = runById(ui.runShown);
162
+ const data = ui.runs && ui.runs.data;
163
+ if (run) patchList(list, runHtml(viewContext(), run, data.runs));
164
+ 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>`);
150
165
  }
151
166
 
152
167
  /**
@@ -251,37 +266,29 @@ export function install(ctx) {
251
266
  const base = f && safeUrl(f.url) ? f.url.replace(/\/+$/, '') : null;
252
267
  return {
253
268
  esc: escHtml, t, safeUrl, forgeName: fn.forgeName(), forgeType: f ? f.type : 'github', repoUrl: base && f.repo ? `${base}/${f.repo}` : null,
254
- now: m.now(), nodes: state.nodes, selected: ui.runSel, timelines: ui.runTimelines, replies: ui.runReplies, busy: !!ui.busy,
269
+ now: m.now(), nodes: state.nodes, timelines: ui.runTimelines, replies: ui.runReplies, busy: !!ui.busy,
255
270
  results: { get: (id) => resultOf(id) },
256
271
  };
257
272
  }
258
273
 
259
274
  const runById = (id) => ((ui.runs && ui.runs.data && ui.runs.data.runs) || []).find((r) => r.runId === id) || null;
260
275
 
261
- /** The nodes of a selected run, worked out again (the runs were read again, or the map changed) */
262
- function relightRun() {
263
- if (!runById(ui.runSel)) ui.runSel = null;
264
- fn.relight();
265
- }
266
-
267
- /** Lights the nodes of a run on the map, like a pull request; the same button lets go of it */
268
- function selectRun(id) {
269
- const run = runById(id);
270
- if (!run) return;
271
- if (ui.runSel === id) {
272
- ui.runSel = null;
273
- fn.relight();
274
- announce(`Run ${id} no longer lit on the map`);
275
- return;
276
- }
277
- const had = ui.runSel;
276
+ /** Shows a run in the node panel: the runs are read once if they have not been (the graph holds the run's state, not its answer field or its brief) */
277
+ async function showRun(id) {
278
+ ui.runShown = id;
278
279
  m.pullToken++;
279
280
  fn.dropThread();
281
+ ui.runShown = id; // dropThread forgets the one it replaced
280
282
  Object.assign(ui, { selected: null, detail: null, detailError: '', lit: null, landing: null, note: null, deploy: null, deployItem: null, litDeploy: null });
281
- ui.runSel = id;
282
- fn.relight();
283
- const n = (run.nodes || []).length;
284
- announce(n ? `Run ${id}: ${n} ${n === 1 ? 'node' : 'nodes'} lit on the map${had ? '' : ''}` : `Run ${id} has no node on the map yet`);
283
+ fn.paint();
284
+ if (!(ui.runs && ui.runs.data)) await loadRuns(false, { say: false });
285
+ if (ui.runShown !== id) return;
286
+ const run = runById(id);
287
+ // A run asked for a moment ago may not be in what was read before: ask once more, past the cache
288
+ if (!run && ui.runs && ui.runs.data) await loadRuns(true, { say: false });
289
+ if (ui.runShown !== id) return;
290
+ fn.paint();
291
+ fn.sayDetail(runById(id) ? `Run ${id}` : ui.runs && ui.runs.data ? `There is no run ${id} in what the runners reported.` : (ui.runs && ui.runs.error) || 'The runs could not be read.');
285
292
  }
286
293
 
287
294
  /** Opens or closes the timeline of a run (it stays open when the list is drawn again) */
@@ -292,8 +299,7 @@ export function install(ctx) {
292
299
 
293
300
  /** Gives the focus to the first of `selectors` that is there and not disabled, inside the card of a run (else the card itself) */
294
301
  function focusInRun(runId, selectors) {
295
- const panel = $('forge-panel');
296
- const card = panel && [...panel.querySelectorAll('[data-run]')].find((c) => c.dataset.run === runId);
302
+ const card = [...root.querySelectorAll('#forge-run-card [data-run]')].find((c) => c.dataset.run === runId);
297
303
  if (!card) return;
298
304
  const to = selectors.map((sel) => card.querySelector(sel)).find((el) => el && !el.disabled) || card;
299
305
  if (to !== inst.active()) to.focus();
@@ -355,33 +361,17 @@ export function install(ctx) {
355
361
  focusInRun(runId, [back, `[data-run-timeline="${runId}"]`]);
356
362
  }
357
363
 
358
- /** Answer, on the proposal bar's line: Work opens on Runs at that run with its reply field focused */
364
+ /** Answer, on the proposal bar's line: the run is shown in the node panel with its reply field focused */
359
365
  async function answerFromBar(id) {
360
- if (!(await openRunLink(id))) return;
361
- const field = $('forge-runs-list').querySelector(`[data-run-reply="${id}"]`);
366
+ if (!(await fn.showRef('run', id))) return;
367
+ const field = $('forge-detail') && $('forge-detail').querySelector(`[data-run-reply="${id}"]`);
362
368
  if (field) field.focus();
363
369
  }
364
370
 
365
- /** Takes the person to another run of the list: the row scrolls into view and has the focus */
371
+ /** Takes the person to another run (a collision names it, a timeline entry does): its node */
366
372
  function goToRun(runId) {
367
- fn.bringIntoView([...root.querySelectorAll('#forge-runs-list [data-run]')].find((r) => r.dataset.run === runId));
368
- }
369
-
370
- /** `?run=<runId>`: the Agents tab with that run lit and in view. A run that is not there is said, never a blank panel. */
371
- async function openRunLink(id) {
372
- if (!ui.config) return false;
373
- await fn.openTab('work');
374
- if (!(ui.runs && ui.runs.data)) await loadRuns(false, { say: false });
375
- let run = runById(id);
376
- // A run asked for a moment ago may not be in what was read before: ask once more, past the cache
377
- if (!run && ui.runs && ui.runs.data) { await loadRuns(true, { say: false }); run = runById(id); }
378
- if (!run) return fn.linkMissing(ui.runs && ui.runs.data ? `There is no run ${id}.` : (ui.runs && ui.runs.error) || 'The runs could not be read.');
379
- if (ui.runSel !== id) selectRun(id);
380
- fn.paint();
381
- fn.bringIntoView($('forge-runs-list').querySelector(`[data-run="${id}"]`));
382
- announce(`Run ${id}, in the Runs view`);
383
- return true;
373
+ fn.showRef('run', runId);
384
374
  }
385
375
 
386
- Object.assign(fn, { groupsShown, loadWork, loadRuns, syncRunsPoll, onPageHide, onPageShow, workHtml: (...a) => withParts(workHtml(...a)), groupsHtml: (...a) => withParts(groupsHtml(...a)), paintRuns, patchList, graftAround, runnerAway, askRunnerWords, paintRunner, viewContext, runById, relightRun, selectRun, toggleTimeline, focusInRun, discardReply, stopRun, answerRun, answerFromBar, goToRun, openRunLink });
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 });
387
377
  }