@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
@@ -131,15 +131,6 @@
131
131
  </div>
132
132
  <!--corn-piece:search/field-->
133
133
 
134
- <!-- The Work toggle (explorer/pieces/work.js): opens the Work panel; shown only when the config names a forge. It is a piece: page.js mounts it here, and until then this stand-in keeps its place (the piece's markup without ids) -->
135
- <!--corn-placeholder:work/button-->
136
- <button type="button" class="hx-work" data-action="toggle-forge" aria-expanded="false" aria-label="Work panel" data-corn-string-aria-label="workPanel" title="Issues, pull requests and deploys: a pull request lights the nodes it changes, a deploy the nodes it restarted" hidden data-corn="forge-button" part="forge-button">
137
- <span data-corn-string="workPanel">Work panel</span>
138
- <span class="hx-forge-lit" data-corn="count" part="count" hidden></span>
139
- <span class="hx-runner-dot" aria-hidden="true" title="No runner online" hidden></span>
140
- </button>
141
- <!--corn-piece:work/button-->
142
-
143
134
  <!-- The one account menu (explorer/account-menu.js): who, Theme, Freeform layout, Review tokens, Proposals, the links, Sign out, and what powers it -->
144
135
  <div class="hx-menu-wrap hx-account">
145
136
  <button type="button" id="account-btn" class="hx-account-btn" aria-expanded="false" aria-controls="account-menu" aria-label="Account menu" data-corn="account-button">
@@ -171,7 +162,7 @@
171
162
  <!-- Review tokens (explorer/review-tokens.js): shown only when somebody is signed in to a forge -->
172
163
  <button type="button" id="tokens-btn" class="hx-account-item" aria-haspopup="dialog" aria-expanded="false" aria-controls="tokens-dialog" title="Review tokens: let a script or a chat bot approve or send back a proposal as you" hidden data-corn="tokens-button">Review tokens</button>
173
164
 
174
- <!-- Proposals: what a change would add, change and remove, drawn on the map. It is part of the proposal piece (explorer/pieces/proposal.js): page.js mounts it here. Only without the Work panel (no forge, or no sign-in): with it, its Specs tab lists them and forge-panel.js hides this -->
165
+ <!-- Proposals: what a change would add, change and remove, drawn on the map. It is part of the proposal piece (explorer/pieces/proposal.js): page.js mounts it here. Only without the Work list (no forge, or no sign-in): with it, its Specs tab lists them and forge-panel.js hides this -->
175
166
  <!--corn-piece:proposal/menu-->
176
167
 
177
168
  <!-- The config's links (cornfield.config.js `links`), the forge and Docs, then Sign out: filled by explorer/plugins.js -->
@@ -200,7 +191,7 @@
200
191
  <!-- The review column (explorer/pieces/changes.js, spec 0006): what the proposal changes, and the personas and the scenarios that apply to them. Docked left of the map from 768px, the expanded proposal sheet's body on a phone. The decision (explorer/pieces/decision.js, spec 0007) is its foot: the column keeps its place -->
201
192
  <!--corn-piece:changes/column-->
202
193
 
203
- <!-- The Work panel (explorer/pieces/work.js): Specs, PRs, Issues, Threads, Runs and Deploys, in the order of the loop. A slide-over from the left on desktop, a bottom sheet on a phone; hidden and inert until the config names a forge. It is a piece: page.js mounts it here -->
194
+ <!-- The Work list (explorer/pieces/work-list.js, part of the Work piece): Specs, PRs, Issues, Threads, Runs and Deploys, in the order of the loop. A slide-over from the left on desktop, a bottom sheet on a phone; hidden and inert until the Work view's List toggle opens it. A row selects its node; the detail is the node panel's. The Work piece mounts it here -->
204
195
  <p id="offline-banner" class="hx-offline" data-corn="notice" hidden></p>
205
196
  <!--corn-piece:work/panel-->
206
197
 
@@ -144,12 +144,6 @@ export function createState() {
144
144
  */
145
145
  scenario: null,
146
146
 
147
- /**
148
- * What the selected pull request lights (forge-panel.js, forge-panel-model.js `litFor`): `{ changed, failing }`, sets of
149
- * node ids (the nodes its files are; the nodes of the tests a failing check names), or null with none selected.
150
- */
151
- forgeLit: null,
152
-
153
147
  /**
154
148
  * The runs on the map (explorer/runs-map.js): `{ flight: Map<nodeId, runId[]>, collide: Map<nodeId, runId[]>, runs }` for the open runs'
155
149
  * nodes, or null when there are none. The map's marks over the nodes are drawn from it.
@@ -13,7 +13,7 @@
13
13
  * inst.touchScene / onSceneTouch a change the picture is built from, and who follows it
14
14
  * inst.on / emit what a piece tells its neighbours, per instance: `emit(name, detail)` calls every `on(name, fn)`, and `on` returns how to stop.
15
15
  * inst.ask what a piece asks of a neighbour that may or may not be there: the first answer other than `undefined` from the
16
- * handlers of `on(name, ...)`, else `undefined`. A piece that finds no answer does without (the Work panel is not part of every page)
16
+ * handlers of `on(name, ...)`, else `undefined`. A piece that finds no answer does without (the Work list is not part of every page)
17
17
  * inst.setSelection(node, edge, { source, quiet }) the one way the converted pieces change what is selected (explorer/engine/selection.js);
18
18
  * returns the change, whose `announce()` says it when `quiet` held it back (the caller touches the scene first)
19
19
  * inst.offline() whether the browser has no network; inst.onNetwork(fn(offline)), inst.onWindowFocus(fn), inst.onPageHide(fn), inst.onPageShow(fn), inst.onResize(fn), inst.onHide(fn): the few window facts the review needs;
@@ -39,7 +39,7 @@
39
39
  * scene (none) touchScene(): what the picture is built from changed (`onSceneTouch`)
40
40
  * layers (none) a layer went on or off, or the layers were set (engine/layers.js): live.js starts or stops the live layer, a search moves its matches
41
41
  * search { query, current } the search's query or its current match changed (pieces/search.js)
42
- * node:painted { node } the node panel was filled for this node (pieces/node-panel.js)
42
+ * node:painted { node } the node panel was filled for this node (pieces/node-panel.js); the Work piece draws a piece of work's actions into it, or lets go of what it held
43
43
  * proposal { change: 'opened' | 'view' | 'closed', slug, source, pinSource, view, proposal } the open proposal changed (engine/proposal.js; the page writes the address from it)
44
44
  * proposal:draw { open } the bar and the review column draw again; proposal:bar { open }: they have, so what sits on the bar draws again
45
45
  * proposal:mark { applied, effective, proposal } before the map is laid out (the what-if editor marks its edits)
@@ -59,9 +59,9 @@
59
59
  * and tells `host` to ask again when the root is free
60
60
  * attach:released (none) the piece that had the instance's root (`attach`) gave it back
61
61
  * work:waiting { total } what waits on the maintainer changed (specs to decide plus runs that need an answer; pieces/work.js): the page puts the number before its title
62
- * work:available { on } the Work panel started (a forge in the config and somebody signed in), or ended: the account menu's Proposals entry is only for a cornfield without it
62
+ * work:available { on } the Work piece started (a forge in the config and somebody signed in), or ended: the Work view's List toggle shows, and the account menu's Proposals entry is only for a cornfield without it
63
63
  * runs:map { active } runs are on the map, or none is (pieces/work.js, runs-map.js): the Layers menu shows its legend while there are
64
- * thread:open { number } a thread listed in the node panel was chosen; thread:start { node }: "Start a thread about this" (pieces/node-panel.js; the Work panel opens the thread, or its New idea form)
64
+ * thread:open { number } a thread listed in the node panel was chosen; thread:start { node }: "Start a thread about this" (pieces/node-panel.js; the Work list opens the thread, or its New idea form)
65
65
  * announce text what a screen reader is told (engine/keyboard.js `announce`; the piece that owns a live region writes it: `announce:write`)
66
66
  * root:changed (none) the primary root moved (`attach`) or a root joined or left (engine/roots.js): what listens on every root puts itself right
67
67
  * map:ready (none) the map piece is mounted and has its topology (pieces/map.js); map:gone: it ended. The pieces around it (pieces/around.js) mount and unmount with it
@@ -97,11 +97,17 @@
97
97
  * proposal:seat-column { column, phone } -> true the bar seats the review column: under it, or in its body on a phone (pieces/proposal.js); proposal:bar-bottom (none) -> px,
98
98
  * how far down the bar reaches, and proposal:bar-resize (emit): the bar's height changed, so the column starts under it again
99
99
  * player:seat bar -> true the dock's owner (engine/sheets.js) seats the scenario player's bar as a sheet above the node panel's
100
- * threads:index nodeId -> { threads: thread[] | null, forge: string, start: true } | undefined the Work panel's list of the threads that mention a node, for the node panel's "Threads"; `threads` is null until the list was read; no answer: no Threads section
101
- * threads:ensure (none) (emit) the node panel was filled: the Work panel reads the threads list once; threads:changed: it was read, or the map changed, so the node panel draws "Threads" again
102
- * work:on (none) -> boolean whether the Work panel has started (a piece mounted after it asks rather than waits for `work:available`)
103
- * work:answer { run } (emit) "Answer" on the proposal bar's line: the Work panel opens on Runs at that run, its reply field focused
104
- * work:open-specs (none) -> true the Work panel's Specs tab opened for a bad link's way on; map:set { nodes, edges } -> true the page (or the review, or a scope's map: pieces/map.js) laid the map out from these
100
+ * threads:index nodeId -> { threads: thread[] | null, forge: string, start: true } | undefined the Work list's list of the threads that mention a node, for the node panel's "Threads"; `threads` is null until the list was read; no answer: no Threads section
101
+ * threads:ensure (none) (emit) the node panel was filled: the Work list reads the threads list once; threads:changed: it was read, or the map changed, so the node panel draws "Threads" again
102
+ * work:list { open } the Work list opened or closed (pieces/work-list.js)
103
+ * work:pick { kind, key } -> true (ask, answered by the Work view: explorer/work-view.js) select the node of that piece of work (`pull`, `issue`, `thread`, `run`, `deploy`, `proposal`, and its number, id or slug) on the map; no answer: the Work piece shows it in the node panel alone, as it shows work older than the graph's 14 days
104
+ * work:panel node -> { replace, badge, title, html } | undefined (ask, answered by the Work view) what the node panel shows for a piece of work or, in the Work view, a node of code; the html holds `forge-detail`, where the Work piece draws the actions
105
+ * work:changed (none) (emit) the work changed (the Work layer came on or went off, or the graph was read again): the open node panel asks `work:panel` again for its node of code and draws that section again
106
+ * node:words node -> string | undefined (ask, answered by the Work view) what the keyboard adds to its words on landing on a node: the Work layer's ", 2 open: PR #27, Issue #14"
107
+ * node:back (none) -> (() => boolean) | undefined (ask, answered by the Work list) the node panel is about to close: what gives the focus back to the row of the open list that chose what it shows (true when it did); else the map has it
108
+ * work:on (none) -> boolean whether the Work piece has started (a piece mounted after it asks rather than waits for `work:available`)
109
+ * work:answer { run } (emit) "Answer" on the proposal bar's line: the run is shown in the node panel, its reply field focused
110
+ * work:open-specs (none) -> true the Work list opened on Specs for a bad link's way on; map:set { nodes, edges } -> true the page (or the review, or a scope's map: pieces/map.js) laid the map out from these
105
111
  * changes:opened-line title -> string, changes:played-line -> string what the review column says of an opening, and how many scenarios were played
106
112
  * whatif:edits -> edits[], whatif:form -> { name } | null, whatif:describe -> string[] what the decision asks of the what-if editor
107
113
  *
@@ -41,7 +41,7 @@ function markersOf(doc, name) {
41
41
  }
42
42
 
43
43
  /**
44
- * The Work panel says what waits on the maintainer (`work:waiting`); the browser tab's title is the page's, so the page puts "(3) " before its own
44
+ * The Work list says what waits on the maintainer (`work:waiting`); the browser tab's title is the page's, so the page puts "(3) " before its own
45
45
  * title while something waits. A host app keeps its own title and does not listen.
46
46
  */
47
47
  let titleOff = null;
package/explorer/page.js CHANGED
@@ -19,14 +19,15 @@
19
19
  * page-address.js ?proposal=, ?source= and ?proposalView= in the address bar
20
20
  * whatif.js what-if edits on an open proposal (add, remove, draw, steps, undo); whatif-model.js its pure half
21
21
  * review-model.js, decision-model.js the words and the choices of the decision (pure)
22
- * deep-link.js ?run=, ?issue= and ?proposal=…&start=1 land on a run, an issue and a Start dialog
22
+ * deep-link.js ?proposal=…&start=1 lands on a proposal's Start dialog (?run=, ?issue= and the other work addresses are work-view.js's)
23
23
  * scenario.js the player's pure core
24
24
  * bench.js /?bench=1 stopwatch and /?fixture=5k (the generated topology, from the server)
25
25
  * keyboard.js the map by keyboard and the screen reader's announcer; keyboard-model.js its pure half
26
26
  * live.js the live layer: the chip, polling, laying a live source's answer over the map; live-model.js its pure half
27
27
  * review-tokens.js review tokens for the review API, when somebody is signed in: make one (shown once), list, revoke; review-tokens-model.js its pure half
28
- * pieces/work.js the Work panel (a piece, with a part per tab in pieces/work-*.js), when the config names a forge: a PR lights the nodes it changes; forge-panel-model.js its pure half;
29
- * forge-panel.js is the page's way in to it (initForgePanel, the deep links)
28
+ * pieces/work.js the Work piece (with a part per tab in pieces/work-*.js; the Work list is pieces/work-list.js), when the config names a forge: the lists a row of which selects its node,
29
+ * and a piece of work's actions in the node panel; forge-panel-model.js its pure half; forge-panel.js is the page's way in to it (initForgePanel)
30
+ * work-view.js the Work view: the map of work, its List toggle, and the addresses (?view=work, ?pr=, ?issue=, ?run=, ?thread=, ?spec=); work-model.js its pure half
30
31
  * theme.js light or dark: the system setting and the header toggle; theme-model.js the colours (theme-boot.js before the first paint)
31
32
  */
32
33
 
@@ -211,7 +212,7 @@ export function startPage() {
211
212
  initWorkView({ offered: !!config.forge }); // the Work view (work-view.js): offered when the config names a forge
212
213
  mergePagePieceOptions('changes', { checker }); // scenarios ask the source's checker, when there is one (pieces/changes.js)
213
214
  if (new URLSearchParams(window.location.search).get("view") === "dataflow") setView("dataflow");
214
- // /?run=, /?issue= and /?proposal=…&start=1 land on a run, an issue's Start button and a proposal's Start dialog (deep-link.js)
215
+ // /?view=work, /?pr=, /?issue=, /?run=, /?thread=, /?spec= land on the Work view (work-view.js); /?proposal=…&start=1 on a proposal's Start dialog (deep-link.js)
215
216
  (asksForWork(window.location.search) ? followWorkAddress() : followDeepLink({ proposalOpened, forgeOn })).catch((err) => console.error('Following the link failed', err));
216
217
  // /?scenario-demo=1 plays a small scenario over real nodes, to look at the player
217
218
  maybeStartDemo();
@@ -248,7 +248,7 @@ export function mount(root, inst, options = {}) {
248
248
  list.replaceChildren(...ui.sent.lines.map((text) => { const li = inst.doc.createElement('li'); li.className = 'hx-whatif-edit'; li.textContent = text; return li; }));
249
249
  }
250
250
  }
251
- // A landing that waits on this PR: Cancel landing, brought here from the Work panel (D3)
251
+ // A landing that waits on this PR: Cancel landing, brought here from the Work list (D3)
252
252
  const landing = q('[data-review-landing]');
253
253
  const landingNow = ui.reviewable && ui.facts && ui.facts.landing ? ui.facts.landing : null;
254
254
  landing.hidden = !landingNow;
@@ -513,7 +513,7 @@ export function mount(root, inst, options = {}) {
513
513
  await sendReview(hold.verdict, { body: hold.body });
514
514
  }
515
515
 
516
- /** Cancel landing (D3): the Work panel's Cancel, here; a POST from this page, then the facts are read again */
516
+ /** Cancel landing (D3): the Work list's Cancel, here; a POST from this page, then the facts are read again */
517
517
  async function cancelLanding() {
518
518
  const n = pullNumberOf(state.proposalSource);
519
519
  if (!n) return;
@@ -597,7 +597,7 @@ export function mount(root, inst, options = {}) {
597
597
  return false;
598
598
  }
599
599
  ui.busy = false;
600
- if (key !== ui.key) { inst.emit('decision', { outcome: verdict, review: saved, slug, source, open: false }); return true; } // another proposal opened while it was being saved: it is saved, the foot is not this one's any more (`open: false`: the page's Work panel does not read its list again then, as before)
600
+ if (key !== ui.key) { inst.emit('decision', { outcome: verdict, review: saved, slug, source, open: false }); return true; } // another proposal opened while it was being saved: it is saved, the foot is not this one's any more (`open: false`: the page's Work list does not read its list again then, as before)
601
601
  ui.review = { verdict: saved.verdict, at: saved.at, current: saved.verdict === 'approved' };
602
602
  ui.hint = verdict === 'approved' ? editsHint(verdict, body.edits.length) : '';
603
603
  // The same approval stood already (another tab, or a send that was retried): the server posted nothing, and the page says so
@@ -316,7 +316,7 @@ export function mount(root, inst, options = {}) {
316
316
  scope.on('layers:redraw', renderLayerToggles);
317
317
  scope.on('theme', renderLayerToggles); // the dots and the legends are drawn in the theme's colours
318
318
  scope.on('view', syncView);
319
- scope.on('runs:map', ({ active }) => { const legend = own('runs-legend'); if (legend) legend.hidden = !active; }); // runs are on the map (the Work panel): the legend says what each mark is
319
+ scope.on('runs:map', ({ active }) => { const legend = own('runs-legend'); if (legend) legend.hidden = !active; }); // runs are on the map (the Work list): the legend says what each mark is
320
320
  // The marks legend is there while a proposal is open (the proposal's bar says so: engine/proposal.js)
321
321
  const showLegend = (open) => { const legend = own('proposal-legend'); if (legend) legend.hidden = !open; };
322
322
  scope.on('proposal:draw', ({ open }) => showLegend(open));
@@ -110,7 +110,7 @@ export const markup = () => ({
110
110
  + '<a data-corn="open-link" id="drawer-file-btn" data-corn-kind="primary" class="hx-open" href="#" target="_blank" rel="noreferrer" hidden>Open file ↗</a>'
111
111
  + '<a data-corn="open-link" id="drawer-open-btn" data-corn-kind="primary" class="hx-open" href="#" target="_blank" rel="noreferrer" hidden>Open route ↗</a>'
112
112
  + '<button data-corn-kind="secondary" type="button" id="drawer-run-btn" class="hx-btn hx-foot-btn" data-action="start-run" data-corn-string="startRun" hidden>Start a run</button>'
113
- + '<button data-corn-kind="quiet" type="button" class="hx-btn hx-btn--quiet hx-foot-btn" data-action="copy-spec" data-corn-string="copySpec">Copy Spec</button>'
113
+ + '<button data-corn-kind="quiet" type="button" id="drawer-copy-btn" class="hx-btn hx-btn--quiet hx-foot-btn" data-action="copy-spec" data-corn-string="copySpec">Copy Spec</button>'
114
114
  + '<p id="copy-spec-result" class="hx-forge-result" data-corn="result" hidden></p>'
115
115
  + '</div>'
116
116
  + '</aside>',
@@ -252,9 +252,9 @@ function sectionsOf(inst) {
252
252
  return '';
253
253
  }
254
254
 
255
- /** "Threads": the threads whose text names the node (an idea, or a spec PR's conversation); each opens in the Work panel */
255
+ /** "Threads": the threads whose text names the node (an idea, or a spec PR's conversation); each opens in the Work list */
256
256
  function threadsSection(node) {
257
- // The Work panel answers (threads:index) when threads are on and a maintainer is signed in; nobody answering is no Threads section
257
+ // The Work list answers (threads:index) when threads are on and a maintainer is signed in; nobody answering is no Threads section
258
258
  const index = inst.ask('threads:index', node.id);
259
259
  if (!index) return '';
260
260
  const threads = index.threads;
@@ -391,6 +391,27 @@ export function mount(root, inst, options = {}) {
391
391
  addParts(box);
392
392
  }
393
393
 
394
+ /** What the Work view put first in the panel for a node of code (the Work layer's "Open work", or the work touching it in the Work view): its elements and its markup */
395
+ let workShown = { node: null, html: '', els: [] };
396
+ function putWork(node, html) {
397
+ for (const el of workShown.els) el.remove();
398
+ const before = metaList.firstChild;
399
+ if (html) metaList.insertAdjacentHTML('afterbegin', html);
400
+ const els = [];
401
+ for (let el = metaList.firstChild; el && el !== before; el = el.nextSibling) els.push(el);
402
+ if (html) addParts(metaList);
403
+ workShown = { node, html, els };
404
+ }
405
+ /** The work changed (`work:changed`: the Work layer came on or went off, or a new answer): the open panel's section for it is drawn again, and nothing else in it moves */
406
+ function repaintWork() {
407
+ const node = state.selectedNode;
408
+ if (gone || !node || !workShown.node || node.id !== workShown.node.id || !drawer.classList.contains('drawer-open')) return;
409
+ const work = inst.ask('work:panel', node);
410
+ if (work && work.replace) return; // a piece of work is drawn whole when it is shown
411
+ const html = work ? work.html : '';
412
+ if (html !== workShown.html) putWork(node, html); // the same markup: left alone, with the focus in it
413
+ }
414
+
394
415
  /** Fills the panel for a node and opens it. The selection itself is the instance's (engine/selection.js); this is what is shown for it. */
395
416
  function show(node, { frame = false } = {}) {
396
417
  if (!node || gone) return;
@@ -418,7 +439,7 @@ export function mount(root, inst, options = {}) {
418
439
  <div id="drawer-threads">${sections.threadsSection(node)}</div>
419
440
  ${sections.diffSection(node)}`;
420
441
  addParts(metaList);
421
- inst.emit('threads:ensure'); // the Work panel reads the threads once, for "Mentioned in"
442
+ inst.emit('threads:ensure'); // the Work list reads the threads once, for "Mentioned in"
422
443
  inst.emit('live:hydrate', own('drawer-live'));
423
444
 
424
445
  // The actions: Open file (the node's file on the forge) is the primary one; with an address too, Open route is the quiet one.
@@ -437,7 +458,9 @@ export function mount(root, inst, options = {}) {
437
458
  fileBtn.textContent = `${t(inst, 'openFile')} ↗`;
438
459
  own('drawer-run-btn').hidden = !(state.proposalSlug && inst.ask('forge:can-start'));
439
460
  // The Work view (spec 0012 D5): a piece of work is shown by the page's own answer (work-view.js); a node of code in it keeps its own sections, with the work touching it first
440
- const work = state.view === 'work' ? inst.ask('work:panel', node) : null;
461
+ const work = inst.ask('work:panel', node);
462
+ own('drawer-copy-btn').hidden = !!(work && work.replace); // a piece of work is no spec to copy: its JSON is the forge's, not the map's
463
+ workShown = { node: null, html: '', els: [] }; // the markup above replaced what was there
441
464
  if (work && work.replace) {
442
465
  title.textContent = work.title;
443
466
  title.classList.remove('hx-mono');
@@ -450,10 +473,7 @@ export function mount(root, inst, options = {}) {
450
473
  fileBtn.hidden = true;
451
474
  openBtn.hidden = true;
452
475
  own('drawer-run-btn').hidden = true;
453
- } else if (work) {
454
- metaList.insertAdjacentHTML('afterbegin', work.html);
455
- addParts(metaList);
456
- }
476
+ } else putWork(node, work ? work.html : '');
457
477
 
458
478
  drawer.classList.add('drawer-open');
459
479
  drawer.inert = false; // closed, it waits off screen: inert, so Tab never reaches its buttons (MAP-02)
@@ -519,7 +539,7 @@ export function mount(root, inst, options = {}) {
519
539
  if (!inline) collapseSheet(inst, 'drawer'); // the next node opens as a peek on a phone
520
540
  }
521
541
 
522
- /** Start a run: the Start dialog of the Work panel, on the proposal that is open */
542
+ /** Start a run: the Start dialog of the Work list, on the proposal that is open */
523
543
  function startRun() {
524
544
  if (state.proposalSlug) inst.emit('forge:start', { slug: state.proposalSlug, returnTo: '#drawer-run-btn' });
525
545
  }
@@ -537,12 +557,14 @@ export function mount(root, inst, options = {}) {
537
557
  scope.listen(drawer, 'click', (e) => {
538
558
  const target = e.target.closest && e.target.closest('[data-action]');
539
559
  if (!target) return;
560
+ const shut = target.dataset.action === 'close-drawer';
561
+ const back = shut && inst.ask('node:back'); // the Work list's row that chose the node, asked before the panel lets go
540
562
  const action = ACTIONS[target.dataset.action];
541
563
  if (action) action(target);
542
- // The panel's ✕: the focus would be left on a hidden button, so it goes back to the map
543
- if (target.dataset.action === 'close-drawer' && state.canvas) scope.timeout(() => state.canvas.focus(), 0);
564
+ // The panel's ✕: the focus would be left on a hidden button, so it goes back to that row, else to the map
565
+ if (shut) scope.timeout(() => { if (!(back && back()) && state.canvas) state.canvas.focus(); }, 0);
544
566
  });
545
- // A thread listed in the panel opens in the Work panel, and "Start a thread about this" opens its New idea form (the Work panel hears both)
567
+ // A thread listed in the panel opens in the Work list, and "Start a thread about this" opens its New idea form (the Work list hears both)
546
568
  scope.listen(drawer, 'click', (e) => {
547
569
  const open = e.target.closest && e.target.closest('[data-thread-open]');
548
570
  if (open) { inst.emit('thread:open', { number: Number(open.dataset.threadOpen) }); return; }
@@ -551,6 +573,7 @@ export function mount(root, inst, options = {}) {
551
573
  });
552
574
  // The threads that mention nodes changed (the list was read, or the map changed): the section is drawn again
553
575
  scope.on('threads:changed', () => repaintThreads());
576
+ scope.on('work:changed', () => repaintWork());
554
577
  // The dim layer behind the panel: on a phone a tap there folds the panel to its peek; elsewhere it closes it
555
578
  if (!inline) {
556
579
  scope.listen(backdrop, 'click', (e) => {
@@ -563,8 +586,9 @@ export function mount(root, inst, options = {}) {
563
586
  if (e.key !== 'Escape' || e.defaultPrevented) return;
564
587
  if (e.target.closest && e.target.closest('select, input, textarea')) return; // a field's own Escape first
565
588
  e.preventDefault();
589
+ const back = inst.ask('node:back');
566
590
  clearSelection(inst, { source: 'keyboard' });
567
- if (state.canvas) state.canvas.focus();
591
+ if (!(back && back()) && state.canvas) state.canvas.focus();
568
592
  announce(inst, 'Panel closed');
569
593
  });
570
594
 
@@ -130,7 +130,7 @@ export function mount(root, inst, options = {}) {
130
130
  ...place(inst, root, html.bar, options.slots, 'bar'),
131
131
  ...(inline ? [] : place(inst, root, html.menu, options.slots, 'menu')),
132
132
  ];
133
- /** What hears the clicks and keys of this piece: the instance's root, which holds the Work panel's Specs list too (cornfield's page), or the box's own root */
133
+ /** What hears the clicks and keys of this piece: the instance's root, which holds the Work list's Specs list too (cornfield's page), or the box's own root */
134
134
  const hear = inline ? root : inst.root;
135
135
  /** An element of this piece by id (the piece's own, whatever else the root holds) */
136
136
  const own = (id) => {
@@ -391,7 +391,7 @@ export function mount(root, inst, options = {}) {
391
391
  if (state.canvas) state.canvas.focus();
392
392
  }
393
393
 
394
- /** A bad link's way on: the Work panel's Specs tab when there is one, else the header's Proposals menu */
394
+ /** A bad link's way on: the Work list's Specs tab when there is one, else the header's Proposals menu */
395
395
  function openSpecs() {
396
396
  if (inst.ask('work:open-specs') === true) return;
397
397
  if (!menuOpen()) toggleMenu();
@@ -410,7 +410,7 @@ export function mount(root, inst, options = {}) {
410
410
  'proposal-way': (el) => (el.dataset.way === 'open' ? openProposal(inst, el.dataset.slug, el.dataset.source || null) : el.dataset.way === 'retry' ? retryOpen(el.dataset.slug, el.dataset.source || null) : el.dataset.way === 'close' ? closeAfterFailure() : openSpecs()),
411
411
  };
412
412
 
413
- // The root hears every control: the bar's, the menu's and a row of the Work panel's Specs list (`open-proposal`), as the document did
413
+ // The root hears every control: the bar's, the menu's and a row of the Work list's Specs list (`open-proposal`), as the document did
414
414
  scope.listen(hear, 'click', (e) => {
415
415
  const target = e.target.closest ? e.target.closest('[data-action]') : null;
416
416
  const action = target && Object.hasOwn(ACTIONS, target.dataset.action) && ACTIONS[target.dataset.action];
@@ -425,15 +425,15 @@ export function mount(root, inst, options = {}) {
425
425
  // too, as it does on cornfield's page. The open menu holds the focus (on an item), and such a click takes it out of the bar: the menu closes when the focus
426
426
  // leaves the bar (to nothing, or to anything outside it), which holds in a host's closed shadow root too and needs no listener on the page
427
427
  if (inline) scope.listen(bar, 'focusout', (e) => { if (moreOpen() && !(e.relatedTarget && bar.contains(e.relatedTarget))) closeMore(); });
428
- // Answer, on the bar's line (a run waits on this proposal): the Work panel opens on that run with its reply field focused (work:answer)
428
+ // Answer, on the bar's line (a run waits on this proposal): the Work list opens on that run with its reply field focused (work:answer)
429
429
  scope.listen(bar, 'click', (e) => {
430
430
  const go = e.target.closest && e.target.closest('[data-waiting-answer]');
431
431
  if (go) { e.preventDefault(); e.stopPropagation(); inst.emit('work:answer', { run: go.dataset.waitingAnswer }); }
432
432
  }, true);
433
- // With the Work panel on, its Specs tab lists the proposals: the account menu's Proposals entry is only for a cornfield without it (no forge, or no sign-in)
433
+ // With the Work list on, its Specs tab lists the proposals: the account menu's Proposals entry is only for a cornfield without it (no forge, or no sign-in)
434
434
  const proposalsEntry = (workOn) => { const wrap = own('proposal-wrap'); if (wrap) wrap.hidden = !!workOn; };
435
435
  scope.on('work:available', ({ on }) => proposalsEntry(on));
436
- if (inst.ask('work:on')) proposalsEntry(true); // the Work panel started before this piece was mounted: it said so to nobody
436
+ if (inst.ask('work:on')) proposalsEntry(true); // the Work list started before this piece was mounted: it said so to nobody
437
437
  scope.listen(hear, 'keydown', (e) => {
438
438
  if (e.key === 'Escape' && menuOpen()) closeMenu();
439
439
  onMoreKey(e);
@@ -5,7 +5,7 @@
5
5
  * review needs, and mounts the pieces of the explorer into it through their own `mount(root, inst, { slots })`: the map (pieces/map.js), the proposal's
6
6
  * bar (pieces/proposal.js, without the what-if editor's buttons: the editor is not converted), the change list with the scenario player
7
7
  * (pieces/changes.js), the decision's foot (pieces/decision.js, in the column's foot) and the node panel (pieces/node-panel.js). It is not cornfield's
8
- * page: no header, Work panel, search, Layers chip, account menu or hint, and cornfield's page does not use it (it keeps its own layout).
8
+ * page: no header, Work list, search, Layers chip, account menu or hint, and cornfield's page does not use it (it keeps its own layout).
9
9
  *
10
10
  * const review = mount(root, inst, options) -> { update, destroy, ... }
11
11
  *
@@ -53,7 +53,7 @@
53
53
  * Nothing leaves the box: no listener on `document` or `window`, nothing appended outside it, no id looked up outside it, keys act only with the focus
54
54
  * inside, no `location`, no `history`; the wheel is the page's until the map has the focus or Ctrl or Cmd is held (input.js).
55
55
  *
56
- * Not in it: the what-if editor, the mockups, the Work panel, search, the Layers menu, the Proposals menu (its markup is kept in a spare, hidden place: the
56
+ * Not in it: the what-if editor, the mockups, the Work list, search, the Layers menu, the Proposals menu (its markup is kept in a spare, hidden place: the
57
57
  * proposal piece makes it), signing in (the decision says `auth`).
58
58
  *
59
59
  * @param {Element|ShadowRoot} root
@@ -32,7 +32,7 @@ export function install(ctx) {
32
32
  const type = ref.slice(0, at);
33
33
  const value = ref.slice(at + 1);
34
34
  const refs = again ? retryRefs(again) : type === 'proposal' ? { proposal: value } : { issue: Number(value) };
35
- ui.agent = { opener, refs, posting: false, retryOf: again ? again.runId : null };
35
+ ui.agent = { opener, refs, posting: false, retryOf: again ? again.runId : null, ref: ui.ref }; // `ref`: the piece of work in the node panel, the one its note is shown with
36
36
  // The profiles the config lists come with the runs: asked for if the Agents tab has not been opened yet
37
37
  if (!ui.runs) { await fn.loadRuns(false); if (ui.kind === 'work') fn.paint(); }
38
38
  if (!ui.agent) return;
@@ -162,8 +162,9 @@ export function install(ctx) {
162
162
  ui.agent.posting = false;
163
163
  const text = startWords(res.status, res.body);
164
164
  if (res.ok) {
165
+ const { ref } = ui.agent;
165
166
  closeAgent();
166
- ui.runNote = { text, ok: true };
167
+ ui.runNote = { text, ok: true, ref };
167
168
  announce(text);
168
169
  await fn.loadRuns(false);
169
170
  fn.paint();
@@ -7,7 +7,6 @@
7
7
 
8
8
  import { escapeHtml as escHtml } from '../../core/text.js';
9
9
  import { defaultFilters } from '../forge-panel-model.js';
10
- import { withParts } from '../engine/piece.js';
11
10
 
12
11
  export const FORGE_NAMES = { github: 'GitHub', forgejo: 'Forgejo' };
13
12
  export const SEARCH_ANNOUNCE_MS = 500;
@@ -24,8 +23,6 @@ export const plural = (n, word, more = `${word}s`) => `${n} ${n === 1 ? word : m
24
23
  /** A link only if it is the forge's web address: a forge's JSON is data, not trusted markup */
25
24
  export const safeUrl = (u) => (typeof u === 'string' && /^https?:\/\//i.test(u) ? u : null);
26
25
  export const option = (value, label, on) => `<option value="${escHtml(value)}"${on ? ' selected' : ''}>${escHtml(label)}</option>`;
27
- /** The back control of a detail: an arrow and the name of the list it returns to ("All pull requests") */
28
- export const backHtml = (action, words) => withParts(`<button data-corn="back" type="button" class="hx-forge-back" data-action="${action}"><svg width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6" aria-hidden="true"><path d="M10 3L5 8l5 5"/></svg><span class="hx-forge-back-text">${escHtml(words)}</span></button>`);
29
26
  /** The thread a successful answer holds, or null (a failure, or an answer without one) */
30
27
  export const threadOf = (res) => (res && res.ok && res.body && res.body.thread && typeof res.body.thread === 'object' && Array.isArray(res.body.thread.messages) ? res.body.thread : null);
31
28
 
@@ -49,27 +46,29 @@ export function freshUi() {
49
46
  filtersOpen: false, // the Filter chip's box
50
47
  filters: defaultFilters(),
51
48
  lists: {}, // `${kind}|${server state}` -> { items, at, rate, stale }
52
- work: null, // { grouped, problem, at, rate, stale } of the Agents tab
49
+ work: null, // { grouped, problem, at, rate, stale } of the Runs tab
53
50
  specQuery: '', // the Specs tab's search (spec 0010 D5)
54
51
  draftsOpen: null, // the Drafts group opened (true) or folded (false) by hand; null: as the model has it (folded past 10 rows)
55
52
  workFilters: { agentsOnly: false, finished: false },
56
53
  loading: false,
57
54
  error: '',
58
- selected: null, // the pull request's number
59
- selectedOn: '', // the tab it was selected on ('pulls' or 'work')
60
- detail: null, // { pull, files, checks, at, rate, stale } of the selected one
55
+ node: '', // the id of the piece of work the node panel shows (`pull:27`), or '' while it shows none
56
+ ref: '', // …and its row's name in the lists (`pull:27`, `proposal:<slug>`, `run:<id>`): a row that names it is pressed
57
+ item: null, // …and what the graph, or the lists, say of it (work-model.js `workNode`'s `item`)
58
+ selected: null, // the pull request's number in the node panel
59
+ detail: null, // { pull, files, checks, at, rate, stale } of the pull request in the node panel
61
60
  landing: null, // what waits to land on its approval for the selected pull request ({ slug, by, since }), or null
62
61
  detailError: '',
63
- lit: null, // litFor(detail, nodes)
64
- thread: null, // the selected thread's number (Threads tab)
65
- threadDetail: null, // { thread, at, rate, stale } of the selected one: its messages, as written
62
+ lit: null, // litFor(detail, nodes): its files on the map's nodes
63
+ thread: null, // the number of the thread in the node panel
64
+ threadDetail: null, // { thread, at, rate, stale } of the one in the node panel: its messages, as written
66
65
  threadError: '',
67
- litThread: null, // litForThread(thread, nodes)
66
+ litThread: null, // litForThread(thread, nodes): the nodes its text names
68
67
  idea: freshIdea(), // the New idea form
69
- deploy: null, // the selected deploy's id; the deploy itself is `deployItem`
68
+ deploy: null, // the id of the deploy in the node panel; the deploy itself is `deployItem`
70
69
  deployItem: null,
71
- litDeploy: null, // litForDeploy(deployItem, nodes)
72
- nodesSeen: null, // the `state.nodes` the lights were worked out for
70
+ litDeploy: null, // litForDeploy(deployItem, nodes): the nodes it restarted
71
+ nodesSeen: null, // the `state.nodes` those were worked out for
73
72
  busy: '', // the action in flight ('merge', or 'rerun:<check id>'), so a second click does nothing
74
73
  note: null, // { text, ok }: what the last action came to, for the selected pull request
75
74
  confirm: null, // { opener: selector, kind: 'merge' | 'spec' | 'build', plan?, n?, slug? } while the confirm dialog is open
@@ -77,7 +76,7 @@ export function freshUi() {
77
76
  notes: freshNotes(), // the Release notes view
78
77
  runs: null, // { data, error } of the Agents tab's runs: what /api/agent-runs answered
79
78
  runNote: null, // { text, ok }: what the last Stop came to
80
- runSel: null, // the run lit on the map (Light on the map), by id
79
+ runShown: null, // the run in the node panel, by id
81
80
  runnerSaid: null, // the runner state last shown ('online', 'offline', 'none'; null off the pull transport), so a change is said once
82
81
  runTimelines: new Set(), // the runs whose timeline is open
83
82
  runReplies: new Map(), // the reply typed so far for each waiting run, so a repaint (the runs are looked at again) keeps it
@@ -11,7 +11,7 @@ import { trapTab } from '../focusables.js';
11
11
  import { escapeHtml as escHtml } from '../../core/text.js';
12
12
 
13
13
  export function install(ctx) {
14
- const { inst, ui, m, fn, $ } = ctx;
14
+ const { inst, ui, m, fn, root, $ } = ctx;
15
15
  const { announce, t, trapFocus } = ctx.h;
16
16
 
17
17
  const confirmEl = () => $('forge-confirm');
@@ -50,8 +50,8 @@ export function install(ctx) {
50
50
  }
51
51
 
52
52
  /** What a pipeline step came to, on the panel (with a link to what it made) and through the live region */
53
- function stepNote(text, ok, url = null) {
54
- ui.actNote = { text, ok, url };
53
+ function stepNote(text, ok, url = null, ref = ui.ref) {
54
+ ui.actNote = { text, ok, url, ref }; // `ref`: the piece of work it is about, the only one whose node panel shows it
55
55
  announce(text);
56
56
  fn.paint();
57
57
  }
@@ -67,6 +67,7 @@ export function install(ctx) {
67
67
  */
68
68
  async function askPlan(action, n, slug, opener) {
69
69
  if (ui.busy || ui.confirm || ui.agent || !confirmEl()) return;
70
+ const ref = ui.ref; // the node panel may show another piece of work by the time the plan is read
70
71
  ui.busy = `plan:${action}`;
71
72
  ui.actNote = null;
72
73
  announce(action === 'spec' ? `Looking at what a spec for issue ${n} would make` : `Looking at the build issue for ${slug}`);
@@ -74,28 +75,28 @@ export function install(ctx) {
74
75
  const res = await fn.request(planUrl(action, n, slug), true);
75
76
  ui.busy = '';
76
77
  // The button was off while it asked; it has the focus again whatever the answer is
77
- const refocus = () => { const back = $('forge-panel').querySelector(opener); if (back && !back.disabled && !ui.confirm) back.focus(); };
78
+ const refocus = () => { const back = root.querySelector(opener); if (back && !back.disabled && !ui.confirm) back.focus(); };
78
79
  if (!res.ok || !res.body || !res.body.plan) {
79
- stepNote(actionWords(action, res.status, res.body, n), false);
80
+ stepNote(actionWords(action, res.status, res.body, n), false, null, ref);
80
81
  refocus();
81
82
  return;
82
83
  }
83
84
  const { plan } = res.body;
84
85
  if (plan.existing) {
85
- stepNote(existingWords(action, plan), true, plan.existing.url);
86
+ stepNote(existingWords(action, plan), true, plan.existing.url, ref);
86
87
  refocus();
87
88
  return;
88
89
  }
89
90
  fn.paint();
90
91
  if (ui.agent) return; // Start an agent was opened while the plan was read: one dialog at a time, and that one has the focus
91
92
  const what = action === 'spec' ? confirmSpec(plan, fn.forgeName()) : confirmBuild(plan, fn.forgeName());
92
- showConfirm(what, what.go, { opener, kind: action, plan, n, slug });
93
+ showConfirm(what, what.go, { opener, kind: action, plan, n, slug, ref });
93
94
  }
94
95
 
95
96
  /** A pipeline step, second half: the plan that was shown is confirmed; the server plans again and must find the same */
96
97
  async function confirmedStep() {
97
98
  if (ui.busy || !ui.confirm || !ui.confirm.plan) return;
98
- const { kind, plan, n } = ui.confirm;
99
+ const { kind, plan, n, ref } = ui.confirm;
99
100
  ui.busy = kind;
100
101
  ui.actNote = null;
101
102
  const go = confirmEl().querySelector('[data-action="forge-confirm-go"]');
@@ -107,7 +108,7 @@ export function install(ctx) {
107
108
  closeConfirm();
108
109
  ui.busy = '';
109
110
  const made = res.body && (kind === 'spec' ? res.body.pull : res.body.issue);
110
- stepNote(actionWords(kind, res.status, res.body, n), res.ok, res.ok && made ? made.url : null);
111
+ stepNote(actionWords(kind, res.status, res.body, n), res.ok, res.ok && made ? made.url : null, ref);
111
112
  // Whatever it came to, it is read again: a refusal says the issue or the pull request is not what was shown
112
113
  if (res.status !== null) {
113
114
  forgetOtherLists();
@@ -125,7 +126,7 @@ export function install(ctx) {
125
126
  el.hidden = true;
126
127
  if (m.confirmTrap) { m.confirmTrap(); m.confirmTrap = null; }
127
128
  if (!restoreFocus) return;
128
- const back = $('forge-panel').querySelector(opener) || $('forge-title');
129
+ const back = root.querySelector(opener) || $('forge-title');
129
130
  if (back && !back.disabled) back.focus();
130
131
  }
131
132