cornfield 0.61.0 → 0.63.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/core/release-notes.js +2 -2
  2. package/explorer/css/changes.css +3 -7
  3. package/explorer/css/header.css +15 -0
  4. package/explorer/css/layers.css +11 -2
  5. package/explorer/css/map.css +27 -0
  6. package/explorer/css/node-panel.css +45 -0
  7. package/explorer/css/page.css +2 -7
  8. package/explorer/css/proposal.css +2 -3
  9. package/explorer/css/work.css +7 -7
  10. package/explorer/engine/hint.js +7 -7
  11. package/explorer/engine/keyboard.js +5 -4
  12. package/explorer/engine/map-rect.js +2 -2
  13. package/explorer/engine/render.js +2 -1
  14. package/explorer/forge-panel-model.js +24 -0
  15. package/explorer/history-model.js +93 -12
  16. package/explorer/history-replay.js +318 -0
  17. package/explorer/history.js +40 -9
  18. package/explorer/index.html +7 -1
  19. package/explorer/instance-state.js +1 -0
  20. package/explorer/page.js +3 -0
  21. package/explorer/panel-model.js +103 -0
  22. package/explorer/panel-sections.js +140 -0
  23. package/explorer/pieces/layers.js +27 -6
  24. package/explorer/pieces/node-panel.js +80 -1
  25. package/explorer/pieces/search.js +22 -9
  26. package/explorer/pieces/work-deploys.js +13 -13
  27. package/explorer/pieces/work-issues.js +10 -5
  28. package/explorer/pieces/work-list.js +72 -9
  29. package/explorer/pieces/work-paint.js +45 -10
  30. package/explorer/pieces/work-prs.js +46 -34
  31. package/explorer/pieces/work-runs.js +17 -5
  32. package/explorer/pieces/work-specs.js +24 -4
  33. package/explorer/pieces/work-threads.js +59 -15
  34. package/explorer/pieces/work.js +6 -3
  35. package/explorer/proposal-model.js +3 -6
  36. package/explorer/runs-view.js +42 -8
  37. package/explorer/scene.js +35 -1
  38. package/explorer/work-model.js +266 -55
  39. package/explorer/work-view.css +9 -16
  40. package/explorer/work-view.js +107 -34
  41. package/package.json +1 -1
  42. package/server/server.js +1 -1
  43. package/server/work-graph.js +5 -5
@@ -84,7 +84,7 @@ export function mount(root, inst, options = {}) {
84
84
  const m = {
85
85
  runsTimer: 0, threadToken: 0, indexToken: 0, indexLoading: false, indexCache: null, listToken: 0, pullToken: 0, notesToken: 0,
86
86
  searchTimer: null, now: options.clock || (() => Date.now()), pageAway: false, specsTimer: 0, specsReading: false, primed: new Set(),
87
- shownKey: '', shownKind: '', returnTo: null, openerEl: null, merged: { entries: null, items: [] }, redrawRuns: new Set(), agentTrap: null, confirmTrap: null,
87
+ shownKey: '', shownKind: '', returnTo: null, openerEl: null, merged: { entries: null, items: [] }, redrawRuns: new Set(), agentTrap: null, confirmTrap: null, behind: false, markRow: false,
88
88
  };
89
89
  const timers = new Set();
90
90
  /** Timers that end with the piece, and do nothing once it has */
@@ -187,9 +187,12 @@ export function mount(root, inst, options = {}) {
187
187
  scope.on('threads:ensure', () => { if (ui.config && ui.threadsOn) fn.ensureThreadsList(); });
188
188
  scope.on('thread:open', ({ number }) => { if (ui.threadsOn) fn.openThread(number).catch(() => {}); });
189
189
  // The node panel shows a piece of work (the Work view's node, or one the lists read): its actions are drawn into it; anything else, or closed, lets go of it
190
- scope.on('node:painted', ({ node }) => { m.shown = node && node.work && node.item ? fn.showDetail(node) : (fn.dropDetail(), Promise.resolve()); });
191
- scope.on('node:close', () => fn.dropDetail());
190
+ // On a desktop the list and the node panel take one place in turns (spec 0015 D3): a node shown while the list is open puts the list behind it, the panel's Back
191
+ // (`panel:back`) brings the list again, and the panel closing closes both
192
+ scope.on('node:painted', ({ node }) => { m.shown = node && node.work && node.item ? fn.showDetail(node) : (fn.dropDetail(), Promise.resolve()); if (node) fn.goBehind(); });
193
+ scope.on('node:close', () => { fn.dropDetail(); if (m.behind) fn.closeForge({ restoreFocus: false }); });
192
194
  scope.on('node:back', () => fn.rowBack()); // the node panel closing gives the focus back to the row that chose it
195
+ scope.on('panel:back', () => fn.panelBack());
193
196
  scope.on('thread:start', ({ node }) => { if (ui.threadsOn && node) fn.startThread(node); });
194
197
  // The map or the proposal changed the nodes: the lights follow them. The header's Proposals menu reads the same list: the Specs tab and its count follow
195
198
  scope.on('scene', fn.onNodesChange);
@@ -225,23 +225,20 @@ export function specRowHtml(entry, { shown = null, nowMs = Date.now() } = {}) {
225
225
  const { state } = specStateOf(entry);
226
226
  const corn = SPEC_STATE_CORN[state];
227
227
  const pill = `<span class="hx-forge-state hx-forge-state--${corn}" data-corn="review-state" data-corn-state="${corn}">${stateIconHtml(corn)}${escHtml(SPEC_STATE_WORDS[state])}</span>`;
228
- const c = entry.counts || {};
228
+ // The card keeps its title, its state and who must act (its group, and the words of its review); the summary, what it adds, changes and removes, and its
229
+ // scenarios are the node panel's (spec 0015 D3)
229
230
  const said = specStateWords(entry, nowMs);
230
231
  const meta = [
231
232
  entry.spec ? `<span>spec ${escHtml(entry.spec)}</span>` : '',
232
233
  `<span>${escHtml(specWhere(entry))}</span>`,
233
234
  said ? `<span class="hx-forge-reviewed">${escHtml(said)}</span>` : '',
234
- c.added ? `<span class="hx-forge-add" title="${c.added} added">+${c.added}</span>` : '',
235
- c.changed ? `<span class="hx-forge-chg" title="${c.changed} changed">~${c.changed}</span>` : '',
236
- c.removed ? `<span class="hx-forge-del" title="${c.removed} removed">\u2212${c.removed}</span>` : '',
237
- c.scenarios ? `<span>${c.scenarios} ${c.scenarios === 1 ? 'scenario' : 'scenarios'}</span>` : '',
238
235
  entry.errors ? `<span class="hx-warn">${entry.errors} ${entry.errors === 1 ? 'problem' : 'problems'}</span>` : '',
239
236
  ].filter(Boolean).join('');
240
237
  const mine = shown === `proposal:${entry.slug}`;
241
238
  const unread = state === 'unknown' ? `<p class="hx-forge-meta hx-forge-unread" data-corn="message" data-corn-state="failure">${escHtml(entry.review && entry.review.error ? entry.review.error : 'The forge could not be asked.')} <button type="button" class="hx-btn hx-forge-act" data-corn-kind="quiet" data-action="retry-forge" aria-label="Try again: ${escHtml(entry.title || entry.slug)}">Try again</button></p>` : '';
242
239
  return `<li class="hx-forge-item"><button type="button" class="hx-forge-row hx-forge-spec" data-work-ref="proposal:${escHtml(entry.slug)}" aria-pressed="${mine}" data-corn="row">`
243
240
  + `<span class="hx-forge-line">${head}${pill}</span>`
244
- + `${entry.summary ? `<span class="hx-forge-sum">${escHtml(entry.summary)}</span>` : ''}<span class="hx-forge-meta hx-forge-facts">${meta}</span></button>${unread}</li>`;
241
+ + `<span class="hx-forge-meta hx-forge-facts">${meta}</span></button>${unread}</li>`;
245
242
  }
246
243
 
247
244
  // ---------------------------------------------------------------------------
@@ -89,6 +89,42 @@ function resultHtml(ctx, run) {
89
89
  return `<p class="hx-forge-result" data-run-result="${ctx.esc(run.runId)}" data-corn="result"${r ? ` data-corn-state="${r.ok ? 'success' : 'failure'}"` : ' hidden'}>${r ? ctx.esc(r.text) : ''}</p>`;
90
90
  }
91
91
 
92
+ /** A waiting run's Continue (the node panel's primary action: `kind` "approve"; in a card of its own, "secondary") */
93
+ function continueHtml(ctx, run, kind) {
94
+ const say = ctx.t || t;
95
+ const off = ctx.busy ? ' aria-disabled="true"' : '';
96
+ return `<button data-corn-kind="${kind}" type="button" class="hx-btn${kind === 'approve' ? ' hx-btn--approve' : ''} hx-forge-act" data-run-answer="continue" data-run-id="${ctx.esc(run.runId)}" aria-label="${ctx.esc(say('continueRun'))}: ${ctx.esc(runName(run, ctx.now))}"${off}>${ctx.esc(say('continueRun'))}</button>`;
97
+ }
98
+
99
+ /** A waiting run's Stop, an answer */
100
+ function answerStopHtml(ctx, run) {
101
+ const say = ctx.t || t;
102
+ const off = ctx.busy ? ' aria-disabled="true"' : '';
103
+ return `<button type="button" class="hx-btn hx-forge-act" data-run-answer="stop" data-run-id="${ctx.esc(run.runId)}" aria-label="${ctx.esc(say('stop'))}: ${ctx.esc(runName(run, ctx.now))}"${off} data-corn-kind="danger">${ctx.esc(say('stop'))}</button>`;
104
+ }
105
+
106
+ /** Start again and Stop (a run that does not wait on an answer), as the card has them */
107
+ function againHtml(ctx, run, kind = 'secondary') {
108
+ const say = ctx.t || t;
109
+ const off = ctx.busy ? ' aria-disabled="true"' : '';
110
+ return canRetry(run) ? `<button data-corn-kind="${kind}" type="button" class="hx-btn${kind === 'approve' ? ' hx-btn--approve' : ''} hx-forge-act" data-forge-retry="${ctx.esc(run.runId)}" aria-label="${ctx.esc(say('startAgain'))}: ${ctx.esc(runName(run, ctx.now))}"${off}>${ctx.esc(say('startAgain'))}</button>` : '';
111
+ }
112
+ function stopHtml(ctx, run) {
113
+ const say = ctx.t || t;
114
+ const off = ctx.busy ? ' aria-disabled="true"' : '';
115
+ return canStop(run) && !canAnswer(run) ? `<button type="button" class="hx-btn hx-forge-act" data-forge-stop="${ctx.esc(run.runId)}" aria-label="${ctx.esc(say('stop'))}: ${ctx.esc(runName(run, ctx.now))}"${off} data-corn-kind="danger">${ctx.esc(say('stop'))}</button>` : '';
116
+ }
117
+
118
+ /**
119
+ * A run's actions as the node panel's bar puts them (spec 0015 D4): Continue is the primary action of a run that waits on an answer, Stop beside it; a run that can start again
120
+ * has Start again; one at work has Stop. The card drawn with `bar: true` in its context leaves these out (its reply field and its Reply stay in it).
121
+ */
122
+ export function runBarParts(ctx, run) {
123
+ if (canAnswer(run)) return { primary: continueHtml(ctx, run, 'approve'), others: [answerStopHtml(ctx, run)] };
124
+ const again = againHtml(ctx, run, 'approve');
125
+ return { primary: again, others: [stopHtml(ctx, run)] };
126
+ }
127
+
92
128
  /** A waiting run: what was asked (the note and link are shown above) and the three answers, plain buttons and a reply field */
93
129
  function answerHtml(ctx, run) {
94
130
  const say = ctx.t || t; // the words of the instance that draws it (the Work piece hands its own), else the page's
@@ -96,9 +132,10 @@ function answerHtml(ctx, run) {
96
132
  const name = ctx.esc(runName(run, ctx.now));
97
133
  const off = ctx.busy ? ' aria-disabled="true"' : ''; // not `disabled`: the pressed button keeps the focus (a click on it is dropped: pieces/work-list.js `onDetailClick`)
98
134
  const reply = ctx.replies && ctx.replies.get(run.runId) || '';
99
- return `${run.answer ? answeredHtml(ctx, run) : ''}<div class="hx-run-actions" data-corn="run-actions" role="group" aria-label="Answer: ${name}">
100
- <button data-corn-kind="secondary" type="button" class="hx-btn hx-forge-act" data-run-answer="continue" data-run-id="${id}" aria-label="${ctx.esc(say('continueRun'))}: ${name}"${off}>${ctx.esc(say('continueRun'))}</button>
101
- <button type="button" class="hx-btn hx-forge-act" data-run-answer="stop" data-run-id="${id}" aria-label="${ctx.esc(say('stop'))}: ${name}"${off} data-corn-kind="danger">${ctx.esc(say('stop'))}</button></div>
135
+ // In the node panel Continue and Stop are its action bar's (`runBarParts`): the card keeps the reply field and its Reply
136
+ return `${run.answer ? answeredHtml(ctx, run) : ''}${ctx.bar ? '' : `<div class="hx-run-actions" data-corn="run-actions" role="group" aria-label="Answer: ${name}">
137
+ ${continueHtml(ctx, run, 'secondary')}
138
+ ${answerStopHtml(ctx, run)}</div>`}
102
139
  <label class="hx-forge-field" data-corn="field">Reply to ${ctx.esc(`${run.kind} on ${aboutWords(run.refs)}`)}<input data-corn="control" type="text" class="hx-forge-input" data-run-reply="${id}" value="${ctx.esc(reply)}" maxlength="4000" autocomplete="off" /></label>
103
140
  <div class="hx-run-actions" data-corn="run-actions"><button data-corn-kind="secondary" type="button" class="hx-btn hx-forge-act" data-run-answer="reply" data-run-id="${id}" aria-label="${ctx.esc(say('reply'))}: ${name}"${off}>${ctx.esc(say('reply'))}</button></div>`;
104
141
  }
@@ -141,15 +178,12 @@ export function loadingLinesHtml(n = 1) {
141
178
 
142
179
  /** One run */
143
180
  export function runHtml(ctx, run, all) {
144
- const say = ctx.t || t;
145
181
  const open = ctx.timelines.has(run.runId);
146
182
  const why = statusWhy(run);
147
- const name = ctx.esc(runName(run, ctx.now));
148
183
  const note = run.report && run.report.note ? `<p class="hx-forge-meta">Runner: ${ctx.esc(run.report.note)}</p>` : '';
149
184
  const answering = canAnswer(run);
150
- const off = ctx.busy ? ' aria-disabled="true"' : ''; // not `disabled`: the pressed button keeps the focus (a click on it is dropped: pieces/work-list.js `onDetailClick`)
151
- const retry = canRetry(run) ? `<button data-corn-kind="secondary" type="button" class="hx-btn hx-forge-act" data-forge-retry="${ctx.esc(run.runId)}" aria-label="${ctx.esc(say('startAgain'))}: ${name}"${off}>${ctx.esc(say('startAgain'))}</button>` : '';
152
- const stop = canStop(run) && !answering ? `<button type="button" class="hx-btn hx-forge-act" data-forge-stop="${ctx.esc(run.runId)}" aria-label="${ctx.esc(say('stop'))}: ${name}"${off} data-corn-kind="danger">${ctx.esc(say('stop'))}</button>` : '';
185
+ const retry = ctx.bar ? '' : againHtml(ctx, run); // in the node panel, Start again and Stop are its action bar's (`runBarParts`)
186
+ const stop = ctx.bar ? '' : stopHtml(ctx, run);
153
187
  const names = nodeLabels(run.nodes, ctx.nodes);
154
188
  const collision = collisionWords(run, all, ctx.nodes);
155
189
  const limits = limitRows(run);
package/explorer/scene.js CHANGED
@@ -290,6 +290,7 @@ export function isNodeVisible(state, node, { viewer = false } = {}) {
290
290
  if (state.view === 'work') return node.hidden !== true; // the Work view (spec 0012): its layers set `hidden` on the nodes (work-view.js)
291
291
  if (state.view === 'dataflow') return !!state.flow && state.flow.ids.has(node.id);
292
292
  if (state.view === 'house') return houseShowsNode(state, node); // the House view (spec 0029, PHY-11) draws its own set: house-model.js
293
+ if (state.replay && state.replay.hidden.has(node.id)) return false; // Replay (history-replay.js, spec 0014 D1): a node not yet born at the timeline's commit
293
294
  if (node.type === 'root') return true;
294
295
  return layerShows(state, node, viewer ? state.activeLayers : layersOf(state)) || shownByProposal(state, node); // a proposal's own nodes are drawn whatever their layer says (spec 0009 D3)
295
296
  }
@@ -499,7 +500,11 @@ function buildEdges(state, subgraph, reduceMotion) {
499
500
  const target = byId.get(edge.to);
500
501
  if (!source || !target || !isNodeVisible(state, source) || !isNodeVisible(state, target)) return;
501
502
 
502
- if (state.view === 'work') { out.push(state.workEdge(edge, source, target, subgraph ? subgraph.connectedEdgeKeys.has(focusKey(edge)) : true, !!subgraph, edgeKeyOf(edge), { PROPOSED_DASH, USAGE_DASH }, state.workEdgeColors)); return; } // the Work view's lines are work-model.js's (the page installs `workEdge`)
503
+ if (state.view === 'work') { // the Work view's lines are work-model.js's (the page installs `workEdge`): a line to code only for the selection and the node under the pointer (spec 0015 D1)
504
+ const line = state.workEdge(edge, source, target, subgraph ? subgraph.connectedEdgeKeys.has(focusKey(edge)) : true, !!subgraph, edgeKeyOf(edge), { PROPOSED_DASH, USAGE_DASH }, state.workEdgeColors, { selected: state.selectedNode ? state.selectedNode.id : null, hover: state.hoverNodeId || null });
505
+ if (line) out.push(line);
506
+ return;
507
+ }
503
508
  if (preset) return flow(edge, source, target);
504
509
  if (state.view === 'house') { const how = houseEdgeStyle(edge, source, target); if (how === 'flow') flow(edge, source, target); else if (how === 'link') out.push(linkEdge(edge, source, target, subgraph)); return; }
505
510
 
@@ -736,6 +741,34 @@ export function emphasiseScenario(scene, scn, opts = {}) {
736
741
  * @param {{reduceMotion?: boolean}} [opts] `reduceMotion`: describe no packets (prefers-reduced-motion)
737
742
  * @returns {Scene}
738
743
  */
744
+ /**
745
+ * Replay's budding (spec 0014 D1): a node being born grows out of its parent and settles into its place. `bud` holds, by node id, where it buds
746
+ * from and how far it has come (`t`, 0 to 1, eased); its lines follow it. The layout itself never moves.
747
+ * @param {{ nodes: object[], edges: object[] }} scene
748
+ * @param {Map<string, { x: number, y: number, t: number }>} bud
749
+ */
750
+ export function budScene(scene, bud) {
751
+ const at = new Map();
752
+ for (const n of scene.nodes) {
753
+ const b = bud.get(n.id);
754
+ if (!b) continue;
755
+ const t = Math.max(0, Math.min(1, b.t));
756
+ n.x = b.x + (n.x - b.x) * t;
757
+ n.y = b.y + (n.y - b.y) * t;
758
+ n.r *= Math.max(0.15, t);
759
+ n.alpha *= Math.max(0.2, t);
760
+ at.set(n.id, n);
761
+ }
762
+ for (const e of scene.edges) {
763
+ const a = at.get(e.from);
764
+ const z = at.get(e.to);
765
+ if (!a && !z) continue;
766
+ if (a) { e.x1 = a.x; e.y1 = a.y; e.r1 = a.r; }
767
+ if (z) { e.x2 = z.x; e.y2 = z.y; e.r2 = z.r; }
768
+ if (e.curve) e.curve = { cx: (e.x1 + e.x2) / 2, cy: (e.y1 + e.y2) / 2 };
769
+ }
770
+ }
771
+
739
772
  export function buildScene(state, opts = {}) {
740
773
  const preset = state.view === 'dataflow';
741
774
  const subgraph = state.scenario ? scenarioSubgraph(state) : state.selectedNode ? getActiveSubgraph(state.selectedNode, viewEdgesOf(state), { throughChildren: !!state.throughChildren, kind: state.selectedKind || null }) : null;
@@ -752,6 +785,7 @@ export function buildScene(state, opts = {}) {
752
785
  theme: 'dark',
753
786
  version: state.sceneVersion || 0,
754
787
  };
788
+ if (state.replay && state.replay.bud && state.replay.bud.size) budScene(scene, state.replay.bud);
755
789
  if (state.view === 'house') decorateHouseScene(scene, state); // its bands and tray as lanes, rooms unlabelled (house-model.js)
756
790
  if (state.view === 'work' && state.workLanes) scene.decor.lanes = state.workLanes; // its lanes and their titles (work-model.js)
757
791
  if (state.scenario) emphasiseScenario(scene, state.scenario, opts);