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
@@ -115,8 +115,8 @@ export function mapIndex(topology) {
115
115
  return { nodes, byId, order, owner };
116
116
  }
117
117
 
118
- /** The node's area: the ancestor just below the root (the node itself when it has no owner, or the root owns it) */
119
- function areaOf(node, index) {
118
+ /** The node's area: the ancestor just below the root (the node itself when it has no owner, or the root owns it); the Work view groups the code it draws by it too (explorer/work-model.js) */
119
+ export function areaOf(node, index) {
120
120
  let at = node;
121
121
  const seen = new Set();
122
122
  while (!seen.has(at.id)) {
@@ -83,13 +83,9 @@
83
83
  @container corn-box (max-width: 1023px) {
84
84
  .hx-review-column { width: 320px; }
85
85
  }
86
- @container corn-box (min-width: 1280px) {
87
- /* The Work list: from 1280px the column moves over to make room for it; narrower, the panel lies over the column while it is open (moving it would leave the map a sliver) */
88
- .hx-stage:has(.forge-open) .hx-review-column { left: calc(var(--hx-forge-w) + 12px); }
89
- }
90
86
  @container corn-box (min-width: 768px) and (max-width: 1023px) {
91
- /* The node panel (480px) and the 320px column do not both fit under 1024px: the column gives up its width, so the panel covers none of it */
92
- .hx-stage:has(.drawer-open) .hx-review-column { width: min(320px, calc(100% - 504px)); }
87
+ /* The node panel (480px) and the 320px column do not both fit under 1024px: the column gives up its width, so the panel covers none of it (the Work list takes the panel's place) */
88
+ .hx-stage:has(.drawer-open) .hx-review-column, .hx-stage:has(.forge-open) .hx-review-column { width: min(320px, calc(100% - 504px)); }
93
89
  }
94
90
  .hx-rc-scroll { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: var(--corn-space-2); overflow: hidden; padding: var(--corn-space-3) var(--corn-space-4); }
95
91
  .hx-rc-lists { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: var(--corn-space-4); }
@@ -153,7 +149,7 @@
153
149
  .hx-step-verdict { max-width: 45%; }
154
150
  }
155
151
  @container corn-box (min-width: 768px) {
156
- .hx-stage:has(.drawer-open) .hx-player { right: 504px; }
152
+ .hx-stage:has(.drawer-open) .hx-player, .hx-stage:has(.forge-open) .hx-player { right: 504px; }
157
153
  }
158
154
  .hx-player-as, .hx-player-check { flex: 1 0 100%; }
159
155
  .hx-player-speed[data-corn="control"] { color: var(--corn-text); }
@@ -70,6 +70,21 @@
70
70
  .hx-view-btn { min-width: var(--hx-control-h); height: var(--hx-seg-inner); padding: 0 var(--corn-space-2); }
71
71
  .hx-view-fit { position: absolute; top: calc(100% + var(--corn-space-4)); right: var(--corn-space-4); width: var(--hx-control-h); height: var(--hx-control-h); margin: 0; border: var(--corn-border) solid var(--corn-line); border-radius: var(--corn-radius-pill); background: var(--corn-surface-1); color: var(--corn-text-2); box-shadow: var(--corn-shadow); }
72
72
  }
73
+ /* The view's own controls (spec 0015 D5), after the View switch and before the Layers chip: in the Work view Waiting on you (a toggle) and List (work-view.js fills the group).
74
+ From 768px the two are items of the header's row (`display: contents`); on a phone they sit on the map's top-left row, the Layers chip first, and wrap before Fit */
75
+ .hx-view-tools { display: contents; }
76
+ .hx-view-controls { display: flex; align-items: center; flex: none; gap: var(--corn-space-2); }
77
+ .hx-view-controls[hidden] { display: none; }
78
+ .hx-view-control { display: inline-flex; align-items: center; height: var(--hx-control-h); padding: 0 var(--corn-space-4); border-radius: var(--corn-radius-sm); border: var(--corn-border) solid var(--corn-line); background: var(--corn-surface-2); color: var(--corn-text-2); font-size: var(--corn-text-sm); white-space: nowrap; }
79
+ .hx-view-control:hover { background: var(--corn-surface-3); color: var(--corn-text); }
80
+ .hx-view-control[aria-pressed="true"], .hx-view-control[aria-expanded="true"] { background: var(--corn-surface-3); color: var(--corn-text); border-color: var(--corn-accent); font-weight: 600; }
81
+ .hx-view-control[hidden] { display: none; }
82
+ @container corn-box (max-width: 767px) {
83
+ .hx-header .hx-view-tools { position: absolute; top: calc(100% + var(--corn-space-4)); left: var(--corn-space-4); display: flex; flex-wrap: wrap; align-items: center; gap: var(--corn-space-2); max-width: calc(100% - var(--corn-space-4) * 2 - var(--hx-control-h) - var(--corn-space-3)); pointer-events: none; }
84
+ .hx-header .hx-view-tools > * { pointer-events: auto; }
85
+ .hx-view-tools > .hx-layers { order: -1; }
86
+ .hx-view-control { padding: 0 var(--corn-space-5); border-radius: var(--corn-radius-pill); background: var(--corn-surface-1); box-shadow: var(--corn-shadow); }
87
+ }
73
88
  /* A brand wordmark that does not fit leaves the logo (header-fit.js measures); a row that still scrolls shows it at its edge */
74
89
  .hx-header-left[data-brand-short] .hx-title { display: none; }
75
90
  .hx-header-left[data-overflow] { -webkit-mask: linear-gradient(to right, var(--corn-text) calc(100% - var(--corn-space-6)), transparent); mask: linear-gradient(to right, var(--corn-text) calc(100% - var(--corn-space-6)), transparent); }
@@ -12,7 +12,9 @@
12
12
  .hx-layers-chip--dim { border-color: var(--corn-line-soft); }
13
13
  .hx-layers-chip--dim, .hx-layers-chip--dim .hx-layers-count { color: var(--corn-text-3); }
14
14
  @container corn-box (max-width: 767px) {
15
+ /* On cornfield's page the chip sits on the map's top-left row with the view's controls (header.css `.hx-view-tools`); in a page with no such row, on the map by itself */
15
16
  .hx-header .hx-layers { position: absolute; top: calc(100% + var(--corn-space-4)); left: var(--corn-space-4); }
17
+ .hx-header .hx-view-tools > .hx-layers { position: static; }
16
18
  .hx-layers-chip { height: var(--hx-control-h); padding: 0 var(--corn-space-5); border-radius: var(--corn-radius-pill); background: var(--corn-surface-1); box-shadow: var(--corn-shadow); }
17
19
  }
18
20
  .hx-toggle-row:focus-visible { outline: var(--corn-focus-width) solid var(--corn-focus); outline-offset: var(--corn-focus-offset); }
@@ -46,11 +48,18 @@
46
48
  @media (prefers-reduced-motion: reduce) {
47
49
  .hx-dot { transition: none; animation: none; }
48
50
  }
51
+ /* A row's own button beside it (spec 0015 D6: the History row's Replay), pressed while what it opens is open */
52
+ .hx-toggle-line { display: flex; align-items: stretch; gap: var(--corn-space-1); }
53
+ .hx-toggle-line > .hx-toggle-row { flex: 1; min-width: 0; }
54
+ .hx-row-action { flex: none; padding: 0 var(--corn-space-3); border-radius: var(--corn-radius); border: var(--corn-border) solid var(--corn-line); background: var(--corn-surface-2); color: var(--corn-text-2); font-size: var(--corn-text-xs); font-weight: 600; }
55
+ .hx-row-action:hover { background: var(--corn-surface-3); color: var(--corn-text); }
56
+ .hx-row-action[aria-pressed="true"] { background: var(--corn-surface-3); color: var(--corn-text); border-color: var(--corn-accent); }
57
+ .hx-row-action:focus-visible { outline: var(--corn-focus-width) solid var(--corn-focus); outline-offset: var(--corn-focus-offset); }
49
58
  @container corn-box (max-width: 767px) {
50
- .hx-toggle-row { min-height: 44px; }
59
+ .hx-toggle-row, .hx-row-action { min-height: 44px; }
51
60
  }
52
61
  @media (pointer: coarse) {
53
- .hx-toggle-row { min-height: 44px; }
62
+ .hx-toggle-row, .hx-row-action { min-height: 44px; }
54
63
  }
55
64
  /* ---------------------------------------------------------------------------
56
65
  Project layers and finer kinds (spec 0009): the Layers menu holds its title (with All and None) while the rows scroll, the Overlays heading,
@@ -55,3 +55,30 @@
55
55
  /* The bar while a spec is picked: what it reached, and the way back to the whole map */
56
56
  .hx-history-bar { position: absolute; top: var(--corn-space-3); left: 50%; transform: translateX(-50%); z-index: 3; display: flex; align-items: center; gap: var(--corn-space-3); max-width: calc(100% - var(--corn-space-6)); padding: var(--corn-space-1) var(--corn-space-3); border-radius: var(--corn-radius-pill); font-size: var(--corn-text-sm); color: var(--corn-text); }
57
57
  .hx-history-bar-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
58
+
59
+ /* Replay (spec 0014 D1, history-replay.js): the timeline strip along the bottom of the map, and the pulse on what a commit changed */
60
+ .hx-timeline { position: absolute; left: var(--corn-space-4); right: var(--corn-space-4); bottom: var(--corn-space-4); z-index: 3; display: flex; flex-direction: column; gap: var(--corn-space-1); padding: var(--corn-space-2) var(--corn-space-3); border-radius: var(--corn-radius); color: var(--corn-text); font-size: var(--corn-text-sm); }
61
+ .hx-timeline-bar { display: flex; align-items: center; gap: var(--corn-space-2); }
62
+ .hx-timeline-btn { min-width: 28px; height: 26px; padding: 0 var(--corn-space-2); border-radius: var(--corn-radius-sm); border: var(--corn-border) solid var(--corn-line); background: var(--corn-surface-2); color: var(--corn-text); font: inherit; cursor: pointer; }
63
+ .hx-timeline-btn:hover:not(:disabled) { background: var(--corn-surface-3); }
64
+ .hx-timeline-btn:disabled { opacity: 0.4; cursor: default; }
65
+ .hx-timeline-btn:focus-visible { outline: var(--corn-focus-width) solid var(--corn-focus); outline-offset: var(--corn-focus-offset); }
66
+ .hx-timeline-count { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }
67
+ .hx-timeline-track { position: relative; height: 34px; }
68
+ .hx-timeline-marks { position: absolute; inset: 0; width: 100%; height: 100%; }
69
+ .hx-timeline-range { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; background: transparent; appearance: none; -webkit-appearance: none; cursor: pointer; }
70
+ .hx-timeline-range::-webkit-slider-runnable-track { height: 100%; background: transparent; }
71
+ .hx-timeline-range::-moz-range-track { height: 100%; background: transparent; }
72
+ .hx-timeline-range::-webkit-slider-thumb { -webkit-appearance: none; width: 3px; height: 34px; border-radius: var(--corn-radius-pill); background: var(--corn-text); }
73
+ .hx-timeline-range::-moz-range-thumb { width: 3px; height: 34px; border: 0; border-radius: var(--corn-radius-pill); background: var(--corn-text); }
74
+ .hx-timeline-range:focus-visible { outline: var(--corn-focus-width) solid var(--corn-focus); outline-offset: var(--corn-focus-offset); }
75
+ .hx-timeline-line { display: flex; flex-wrap: wrap; align-items: center; gap: var(--corn-space-2); min-width: 0; }
76
+ .hx-timeline-subject { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 50%; }
77
+ .hx-replay-pulses { position: absolute; inset: 0; z-index: 2; overflow: hidden; pointer-events: none; }
78
+ .hx-replay-pulse { position: absolute; width: 0; height: 0; --r: 12px; }
79
+ .hx-replay-pulse::before { content: ""; position: absolute; left: calc(var(--r) * -1); top: calc(var(--r) * -1); width: calc(var(--r) * 2); height: calc(var(--r) * 2); box-sizing: border-box; border-radius: 50%; border: var(--corn-border-strong) solid var(--corn-history-week); animation: hx-replay-pulse 0.9s ease-out 1 forwards; }
80
+ @keyframes hx-replay-pulse { 0% { transform: scale(0.9); opacity: 1; } 100% { transform: scale(1.7); opacity: 0; } }
81
+ .hx-replay-pulses.is-static .hx-replay-pulse::before { animation: none; }
82
+ @media (prefers-reduced-motion: reduce) {
83
+ .hx-replay-pulse::before { animation: none !important; }
84
+ }
@@ -201,3 +201,48 @@
201
201
  .hx-trail-chip { display: inline-flex; align-items: center; padding: 0 var(--corn-space-2); min-height: 22px; border: var(--corn-border) solid var(--corn-line); border-radius: var(--corn-radius-pill); color: var(--corn-text-2); font-size: var(--corn-text-xs); text-decoration: none; white-space: nowrap; }
202
202
  a.hx-trail-chip:hover { border-color: var(--corn-accent-hover); color: var(--corn-text); }
203
203
  .hx-trail-chip[data-trail="gap"] { border-style: dashed; color: var(--corn-text-3); }
204
+ .hx-history-counts { display: flex; flex-direction: column; align-items: flex-start; gap: var(--corn-space-1); }
205
+ .hx-history-counts [hidden] { display: none; }
206
+ .hx-history-count { font-size: var(--corn-text-xs); }
207
+ .hx-history-count::before, .hx-work-gtoggle::before { content: "▸ "; }
208
+ .hx-history-count[aria-expanded="true"]::before, .hx-work-gtoggle[aria-expanded="true"]::before { content: "▾ "; }
209
+
210
+ /* ---- The panel leads with its action (spec 0015 D4) ----------------------------------------------------------------------------------------------
211
+ The action bar (`actions`): the node's next action as the primary button, one or two beside it, the rest under ⋯; kept in view while the panel scrolls
212
+ (sticky in the place of a piece of work's actions, which runs to the panel's end). Under it, one "Next" line when an action cannot be taken yet. */
213
+ .hx-actions { position: sticky; top: calc(var(--corn-panel-pad) * -1); z-index: 2; display: flex; flex-direction: column; gap: var(--corn-space-2); margin: 0 calc(var(--corn-panel-pad) * -1); padding: var(--corn-space-3) var(--corn-panel-pad); border-bottom: var(--corn-border) solid var(--corn-line-soft); background: color-mix(in srgb, var(--corn-ground) 92%, transparent); backdrop-filter: blur(var(--corn-blur)); -webkit-backdrop-filter: blur(var(--corn-blur)); }
214
+ .hx-actions-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--corn-space-2); }
215
+ .hx-actions-row > .hx-btn, .hx-actions-row > a.hx-btn { flex: none; min-height: var(--hx-control-h); }
216
+ .hx-actions-row > .hx-btn--approve, .hx-actions-row > .hx-btn--primary { flex: 1 1 auto; justify-content: center; }
217
+ .hx-actions-row .hx-foot-btn { align-self: auto; }
218
+ .hx-actions-more { position: relative; flex: none; margin-left: auto; }
219
+ .hx-actions-more-btn { min-width: var(--hx-control-h); font-size: var(--corn-text-md); line-height: 1; }
220
+ .hx-actions-menu { position: absolute; top: calc(100% + var(--corn-space-1)); right: 0; z-index: 3; display: flex; flex-direction: column; align-items: stretch; gap: var(--corn-space-1); min-width: 220px; padding: var(--corn-space-2); border: var(--corn-border) solid var(--corn-line); border-radius: var(--corn-radius); box-shadow: var(--corn-shadow-lg); }
221
+ .hx-actions-menu[hidden] { display: none; }
222
+ .hx-actions-menu .hx-btn { justify-content: flex-start; text-align: left; }
223
+ .hx-next { margin: 0; color: var(--corn-text-2); font-size: var(--corn-text-sm); line-height: 1.45; }
224
+ .hx-work-bar:empty, .hx-work-notes:empty, .hx-work-sections:empty { display: none; }
225
+ .hx-work-facts { margin: 0; }
226
+ .hx-work-sum { margin: 0; color: var(--corn-text-2); line-height: 1.5; }
227
+ .hx-work-changes { margin: var(--corn-space-1) 0 0; font-variant-numeric: tabular-nums; }
228
+ .hx-work-sections { display: flex; flex-direction: column; gap: var(--corn-space-3); }
229
+ .hx-work-sub { padding-left: var(--corn-space-4); }
230
+ .hx-work-sub[hidden] { display: none; }
231
+ /* A section: its title and count open and close it; closed unless it holds the action, as it was left for this kind of node */
232
+ .hx-psec { gap: var(--corn-space-2); padding-top: var(--corn-space-3); border-top: var(--corn-border) solid var(--corn-line-soft); }
233
+ .hx-sec-toggle { display: flex; align-items: baseline; gap: var(--corn-space-2); width: 100%; min-height: 32px; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
234
+ .hx-sec-toggle::before { content: "▸"; flex: none; width: 1ch; color: var(--corn-text-3); }
235
+ .hx-sec-toggle[aria-expanded="true"]::before { content: "▾"; }
236
+ .hx-sec-toggle:hover .hx-sec-name { color: var(--corn-text); }
237
+ .hx-sec-toggle:focus-visible { outline: var(--corn-focus-width) solid var(--corn-focus); outline-offset: var(--corn-focus-offset); }
238
+ .hx-sec-count { color: var(--corn-text-2); font-variant-numeric: tabular-nums; }
239
+ .hx-sec-note { color: var(--corn-text-3); font-weight: 400; }
240
+ .hx-sec-body { display: flex; flex-direction: column; gap: var(--corn-space-2); }
241
+ .hx-sec-body[hidden] { display: none; }
242
+ .hx-panel-back[hidden], .hx-drawer-foot[hidden] { display: none; }
243
+ @container corn-box (max-width: 767px) {
244
+ .hx-actions-row > .hx-btn, .hx-actions-more-btn, .hx-sec-toggle { min-height: 44px; }
245
+ }
246
+ @media (pointer: coarse) {
247
+ .hx-actions-row > .hx-btn, .hx-actions-more-btn, .hx-sec-toggle { min-height: 44px; }
248
+ }
@@ -44,21 +44,16 @@ body {
44
44
  /* The stage: the map and what lies over it. Not a container (above): the pieces in it ask the body, which is as wide */
45
45
  .hx-stage { position: relative; flex: 1; width: 100%; min-height: 0; overflow: hidden; }
46
46
  @media (min-width: 768px) {
47
- /* The panel's width is the stage's `--hx-forge-w`, so what makes room for it reads the same number (the Runs view's compare widens it, below) */
48
- .hx-stage { --hx-forge-w: min(400px, calc(100% - 24px)); }
47
+ /* The Work list's width is the stage's `--hx-forge-w`, so what makes room for it reads the same number: the node panel's, whose place it takes (spec 0015 D3) */
48
+ .hx-stage { --hx-forge-w: min(480px, calc(100% - 24px)); }
49
49
  }
50
50
  /* The scenario player is one bar under the map (spec 0006 D6). From 768px it sits at the foot of the map area, to the right of the review column;
51
51
  the stage tells it how wide the column is */
52
52
  @media (min-width: 768px) {
53
53
  .hx-stage:has(.hx-review-column:not([hidden])) { --hx-col-w: 400px; }
54
- .hx-stage:has(.forge-open):has(.hx-review-column:not([hidden])) { --hx-col-w: max(400px, var(--hx-forge-w)); }
55
- }
56
- @media (min-width: 1280px) {
57
- .hx-stage:has(.forge-open):has(.hx-review-column:not([hidden])) { --hx-col-w: calc(400px + var(--hx-forge-w)); }
58
54
  }
59
55
  @media (min-width: 768px) and (max-width: 1023px) {
60
56
  .hx-stage:has(.hx-review-column:not([hidden])) { --hx-col-w: 320px; }
61
- .hx-stage:has(.forge-open):has(.hx-review-column:not([hidden])) { --hx-col-w: max(320px, var(--hx-forge-w)); }
62
57
  }
63
58
 
64
59
  /* /?bench=1: the run's numbers, bottom left (bench.js) */
@@ -90,9 +90,8 @@ h2.hx-proposal-name { margin: 0; }
90
90
  .hx-proposal-bar { max-height: 50cqh; overflow-y: auto; padding: 0 var(--corn-space-4) var(--corn-space-3); }
91
91
  }
92
92
  @container corn-box (min-width: 768px) {
93
- /* The proposal bar and the player make room for it: 12px past its edge, and the node panel's 480px (+24) when that is open too */
94
- .hx-stage:has(.forge-open) .hx-proposal-bar { left: calc(var(--hx-forge-w) + 12px); width: min(960px, calc(100% - var(--hx-forge-w) - 36px)); }
95
- .hx-stage:has(.forge-open):has(.drawer-open) .hx-proposal-bar { width: min(960px, calc(100% - var(--hx-forge-w) - 540px)); }
93
+ /* The Work list is in the node panel's place on the right (spec 0015 D3; the two take turns): the bar makes room for it as for the panel */
94
+ .hx-stage:has(.forge-open) .hx-proposal-bar { width: min(960px, calc(100% - var(--hx-forge-w) - 24px)); }
96
95
  }
97
96
  .hx-proposal-bar { scroll-padding-block: calc(var(--corn-focus-width) + var(--corn-focus-offset) + var(--corn-space-1)); }
98
97
  @media (forced-colors: active) {
@@ -1,14 +1,14 @@
1
1
  /*
2
2
  * work.css: the Work list
3
- * The Work list (forge-panel.js, runs-view.js) and its tabs (Specs, PRs, Issues, Threads, Runs, Deploys): the slide-over from the left from
4
- * 768px, a bottom sheet below; the Work toggle in the header; the states, results and skeletons. Read by corn-work (D4); its tabs follow as
5
- * pieces of their own.
3
+ * The Work list (forge-panel.js, runs-view.js) and its tabs (Specs, PRs, Issues, Threads, Runs, Deploys): from 768px in the node panel's place on the
4
+ * right (the two take turns: spec 0015 D3), a bottom sheet below; the Work toggle in the header; the states, results and skeletons. Read by corn-work (D4);
5
+ * its tabs follow as pieces of their own.
6
6
  * No rule here asks what the document says (`:root`, `html`, `body`, `[data-theme]`), sizes from the window (`vw`, `vh`) or is `position: fixed` unless it says why;
7
7
  * a width rule is a container query on `corn-box` (page.css), a height rule on `corn-page`. base.css loads first.
8
8
  */
9
- /* ---- the Work list (pieces/work-list.js; spec 0012 D6; first CF-07's issues and PRs panel) -------------------------------------------
10
- A slide-over from the left from 768px (the node panel is the one from the right), a bottom sheet in #sheet-dock below.
11
- Closed, it is inert, and off screen or not displayed. Only the tokens above are used, so it follows the theme. */
9
+ /* ---- the Work list (pieces/work-list.js; spec 0012 D6, spec 0015 D3; first CF-07's issues and PRs panel) ---------------------------
10
+ A slide-over from the right from 768px, in the node panel's place (one side panel at a time: a row opens its node there, with Back to the list), a bottom
11
+ sheet in #sheet-dock below. Closed, it is inert, and off screen or not displayed. Only the tokens above are used, so it follows the theme. */
12
12
  .hx-forge { --hx-forge-status-w: 56px; }
13
13
  .hx-forge { display: flex; flex-direction: column; z-index: 40; border-color: var(--corn-line); pointer-events: none; touch-action: pan-y; transition: transform 0.2s ease-out; }
14
14
  .hx-forge * { touch-action: pan-y; }
@@ -17,7 +17,7 @@
17
17
  .hx-forge.forge-open { pointer-events: auto; }
18
18
  .hx-forge:not(.forge-open) { box-shadow: none; }
19
19
  @container corn-box (min-width: 768px) {
20
- .hx-forge { position: absolute; top: 0; left: 0; bottom: 0; width: var(--hx-forge-w); border-left: 0; transform: translateX(-100%); box-shadow: var(--corn-shadow-lg); }
20
+ .hx-forge { position: absolute; top: 0; right: 0; bottom: 0; width: var(--hx-forge-w); border-right: 0; transform: translateX(100%); box-shadow: var(--corn-shadow-lg); }
21
21
  .hx-forge.forge-open { transform: translateX(0); }
22
22
  }
23
23
  @container corn-box (max-width: 767px) {
@@ -4,7 +4,7 @@
4
4
  * The hint at the map's corner ("Click a node for what it is"; CF review F56), on an instance. Three rules:
5
5
  * - its words follow the pointer: `hintInspect` / `hintDrag` for a mouse or a trackpad, `hintInspectTouch` / `hintDragTouch` where the
6
6
  * main pointer is coarse (a finger). A repo that sets only `hintInspect` (or `hintDrag`) gets its words on both;
7
- * - it goes once the person has selected a node, for the rest of the session (sessionStorage; the Flow view's own description stays,
7
+ * - it goes once the person has selected a node, and does not come back in that browser (localStorage, spec 0015 D5; the Flow view's own description stays,
8
8
  * since it says what Flow is, not how to use the map);
9
9
  * - it is never shown over an open proposal, a node panel, the Work list or a sheet.
10
10
  * The icon is `[data-corn="hint-icon"]`, so a theme can restyle or replace it. explorer/hint.js keeps the old names for the page's instance.
@@ -32,28 +32,28 @@ export function hintText(inst, coarse = coarsePointer(inst.win)) {
32
32
  : hintWords({ text: t(inst, 'hintInspect'), set: isOverridden(inst, 'hintInspect') }, { text: t(inst, 'hintInspectTouch'), set: isOverridden(inst, 'hintInspectTouch') }, coarse);
33
33
  }
34
34
 
35
- const sessionOf = (inst) => { try { return inst.win ? inst.win.sessionStorage : null; } catch { return null; } };
36
- /** Whether a node was selected in this session, for this instance */
35
+ const storeOf = (inst) => { try { return inst.win ? inst.win.localStorage : null; } catch { return null; } };
36
+ /** Whether a node was ever selected in this browser, for this instance */
37
37
  const memory = (inst) => inst.slot('hint', () => {
38
38
  const m = { dismissed: false };
39
- try { const store = sessionOf(inst); m.dismissed = !!store && store.getItem(HINT_STORAGE_KEY) === '1'; } catch { m.dismissed = false; }
39
+ try { const store = storeOf(inst); m.dismissed = !!store && store.getItem(HINT_STORAGE_KEY) === '1'; } catch { m.dismissed = false; }
40
40
  return m;
41
41
  });
42
42
 
43
- /** Remembers that a node was selected: the hint is not shown again this session */
43
+ /** Remembers that a node was selected: the hint is not shown again in this browser */
44
44
  export function dismissHint(inst) {
45
45
  const m = memory(inst);
46
46
  if (m.dismissed) return;
47
47
  m.dismissed = true;
48
48
  if (!inst.el('instruction-badge-text')) return; // an instance with no hint (a map in another app's page) writes nothing in that page's storage
49
- try { const store = sessionOf(inst); if (store) store.setItem(HINT_STORAGE_KEY, '1'); } catch { /* storage blocked: it holds for this page load */ }
49
+ try { const store = storeOf(inst); if (store) store.setItem(HINT_STORAGE_KEY, '1'); } catch { /* storage blocked: it holds for this page load */ }
50
50
  syncHint(inst);
51
51
  }
52
52
 
53
53
  /** For tests: the hint is new again */
54
54
  export function resetHint(inst) {
55
55
  memory(inst).dismissed = false;
56
- try { const store = sessionOf(inst); if (store) store.removeItem(HINT_STORAGE_KEY); } catch { /* none */ }
56
+ try { const store = storeOf(inst); if (store) store.removeItem(HINT_STORAGE_KEY); } catch { /* none */ }
57
57
  }
58
58
 
59
59
  /** What covers the map: an open proposal, the node panel, the Work list, a sheet of the dock */
@@ -59,11 +59,12 @@ export function centreTarget(inst, node, zoom = inst.state.camera.zoom) {
59
59
  const { width, height } = inst.state;
60
60
  const visibleHeight = Math.max(160, height - (inst.state.coveredBottom || 0));
61
61
  const covers = inst.ask('panel:covers'); // an open slide-over node panel covers the right of the map (pieces/node-panel.js); one in a box of its own covers nothing
62
- const visibleWidth = width >= 768 && covers ? Math.max(160, width - (covers.right || 480)) : width;
63
- // The issues and PRs panel slides in from the left (forge-panel.js)
62
+ // The Work list takes the node panel's place on the right while it is open (spec 0015 D3): it covers the same side
64
63
  const forge = inst.el('forge-panel');
65
- const left = width >= 768 && forge && forge.classList.contains('forge-open') ? Math.min(forge.offsetWidth || 400, visibleWidth - 160) : 0;
66
- return { x: left + (visibleWidth - left) / 2 - node.x * zoom, y: visibleHeight / 2 - node.y * zoom, zoom };
64
+ const list = width >= 768 && forge && forge.classList.contains('forge-open') ? forge.offsetWidth || 480 : 0;
65
+ const right = Math.max(width >= 768 && covers ? covers.right || 480 : 0, list);
66
+ const visibleWidth = right ? Math.max(160, width - right) : width;
67
+ return { x: visibleWidth / 2 - node.x * zoom, y: visibleHeight / 2 - node.y * zoom, zoom };
67
68
  }
68
69
 
69
70
  /** Moves the camera so `node` is in the middle of the part of the map not under the panels or a phone's sheets */
@@ -88,8 +88,8 @@ export function visibleMapRect(inst) {
88
88
  const panel = inst.ask('panel:covers'); // the node panel, when it slides over the map: its width, not its box (it slides in)
89
89
  if (panel && panel.right) covers.right = panel.right;
90
90
  const forge = inst.el('forge-panel');
91
- if (shown(forge) && forge.classList.contains('forge-open')) covers.left = forge.offsetWidth;
92
- // the review column (review-column.js) is docked on the left under the bar: its right edge is what it covers, past the Work list's when both are open
91
+ if (shown(forge) && forge.classList.contains('forge-open')) covers.right = Math.max(covers.right, forge.offsetWidth); // the Work list, in the node panel's place (spec 0015 D3)
92
+ // the review column (review-column.js) is docked on the left under the bar: its right edge is what it covers
93
93
  const column = inst.ask('changes:covers');
94
94
  if (column) covers.left = Math.max(covers.left, Math.max(0, column.right - c.left) + 8);
95
95
  const player = inst.ask('player:covers');
@@ -246,12 +246,13 @@ export function createMap(inst, opts = {}) {
246
246
 
247
247
  /**
248
248
  * The node the pointer is on (or null): a node with no label is named by a chip over the map while it is. Only the label layer
249
- * draws again (the map has nothing new to show), so moving across the map costs one small redraw per node entered.
249
+ * draws again (the map has nothing new to show), so moving across the map costs one small redraw per node entered; in the Work view the scene too.
250
250
  */
251
251
  function setHoverNode(id) {
252
252
  const next = id || null;
253
253
  if (state.hoverNodeId === next) return;
254
254
  state.hoverNodeId = next;
255
+ if (state.view === 'work') { inst.touchScene(); render(); return; } // the Work view draws a node's lines to code while the pointer is on it (spec 0015 D1, scene.js)
255
256
  const labels = getLabelLayer();
256
257
  if (labels && state.canvas && state.width) labels.draw(getScene(), state.camera, { hover: next });
257
258
  }
@@ -381,6 +381,30 @@ export function mergeBlock(detail) {
381
381
  return null;
382
382
  }
383
383
 
384
+ /**
385
+ * The one "Next" line under the node panel's action bar (spec 0015 D4) for a pull request that cannot land yet, or whose proposal waits on an approval: what comes before
386
+ * Land it, in one sentence ("Then: approve, and Land it once docs finishes (1 check running)."). '' when nothing stands in the way, and for one that has landed or is closed
387
+ * (its state says so). A failed check's Re-run is in Checks: the line names it, the button stays there. Only words: what Land does is `mergeBlock`'s and the server's.
388
+ * @param {{ pull: { state: string, draft?: boolean }, checks: { name: string, state: string, canRerun?: boolean }[], specs?: { slug: string, approved: boolean }[], stale?: string }} detail
389
+ * @param {{ self?: boolean }} [opts] `self`: the panel is the proposal's own, so "approve" needs no name
390
+ */
391
+ export function nextWords(detail, { self = false } = {}) {
392
+ if (!detail || !detail.pull || detail.pull.state !== 'open') return '';
393
+ const { pull, checks = [] } = detail;
394
+ const open = (detail.specs || []).filter((s) => !s.approved).map((s) => s.slug);
395
+ const steps = open.length ? [self ? 'approve' : `approve ${open.join(' and ')}`] : [];
396
+ const then = (tail) => `Then: ${steps.length ? `${steps.join(', ')}, and ` : ''}${tail}.`;
397
+ if (pull.draft) { steps.push('mark it ready for review on the forge'); return then('Land it'); }
398
+ if (!checks.length) return then('Land it once the forge has run its checks (none yet)');
399
+ const failed = checks.filter((c) => c.state === 'failure' || c.state === 'cancelled');
400
+ const waiting = checks.filter((c) => !GREEN.includes(c.state) && !failed.includes(c));
401
+ if (failed.length) steps.push(`re-run ${failed.map((c) => `${c.name}${c.canRerun ? '' : ' on the forge'}`).join(' and ')}`);
402
+ if (waiting.length) return then(`Land it once ${waiting.map((c) => c.name).join(' and ')} ${waiting.length === 1 ? 'finishes' : 'finish'} (${waiting.length} ${waiting.length === 1 ? 'check' : 'checks'} running)`);
403
+ if (failed.length) return then('Land it');
404
+ if (detail.stale) { steps.push('press Refresh (this is an older answer)'); return then('Land it'); }
405
+ return steps.length ? then('Land it') : '';
406
+ }
407
+
384
408
  /**
385
409
  * A line of warning for a spec pull request whose proposal is not approved yet ('' when it is, or the pull request is not a spec's). Only words:
386
410
  * what Land does is not changed by it.
@@ -12,15 +12,21 @@
12
12
  * specReach(history, spec) the nodes a spec's commits touched, and how many commits named it
13
13
  * heatOf(history, at) the History layer (spec 0014 D3): per node, how often it changed and how lately, as of a commit
14
14
  * haloWidth(count, max) a halo's width on screen (px) for how often its node changed
15
- * historyRowOf(status, heat) the Layers menu's row under Overlays
15
+ * historyRowOf(status, heat, color, { replaying }) the Layers menu's row under Overlays, with Replay on it (spec 0015 D6)
16
16
  * specBarHtml(pick, ctx) the bar on the map while a spec is picked: `Spec 0012 · Work as a view: 6 commits, 72 nodes`
17
+ * commitKind(subject) feat, fix, docs or other: a timeline mark's colour
18
+ * replayFrame(history, edges, at) Replay (spec 0014 D1): what the map holds at a commit, what was born at it and what it changed
19
+ * replayCount(frame, total) the count in the corner: `212 nodes · 340 edges · commit 45 of 132 · 3 born`
20
+ * stepWords(frame, ctx) what a step says to a screen reader
21
+ * speedMs(total, speed) how long a commit stays on screen while Replay plays
17
22
  */
18
23
 
19
24
  import { escapeHtml as esc } from '../core/text.js';
20
25
  import { fileUrl } from './file-url.js';
26
+ import { sectionHtml } from './panel-model.js';
21
27
 
22
- /** The most commits the section lists before "Show all N" */
23
- export const HISTORY_CAP = 12;
28
+ /** The most commits the section lists before "Show all N" (spec 0015 D4: the last five) */
29
+ export const HISTORY_CAP = 5;
24
30
 
25
31
  /** Where a commit, a pull request and an issue are on each forge's site */
26
32
  const SHAPES = {
@@ -137,14 +143,14 @@ export const dayOf = (iso, locale) => {
137
143
  * @param {{ history: object | null, status: 'off' | 'loading' | 'ready' | 'error', error?: string, links: ReturnType<typeof forgeLinks>, specs: ReturnType<typeof specFiles>, picked?: string | null, all?: boolean, locale?: string }} ctx
138
144
  */
139
145
  export function historySectionHtml(node, ctx) {
140
- const head = '<h3 class="hx-sec-title">History</h3>';
141
- const wrap = (body) => `<div class="hx-sec-block hx-history" data-corn="section" data-history>${head}${body}</div>`;
146
+ // A section of the panel (spec 0015 D4): its count is the commits, it starts closed (the browser remembers it open per kind of node: panel-sections.js)
147
+ const wrap = (body, count = null) => sectionHtml({ key: 'history', title: 'History', count, body, extra: ' data-history' }).replace('class="hx-sec-block hx-psec"', 'class="hx-sec-block hx-psec hx-history"');
142
148
  if (ctx.status === 'off') return '';
143
149
  if (ctx.status === 'loading') return wrap('<p class="hx-faint" data-corn="loading">Reading the history…</p>');
144
150
  if (ctx.status === 'error') return wrap(`<p class="hx-faint" data-corn="error">${esc(ctx.error || 'The history could not be read.')}</p>`);
145
151
  const t = nodeTrail(ctx.history, node.id);
146
152
  if (!t) return wrap('<p class="hx-faint">This node is not in the history yet: run <code class="hx-code">cornfield sync</code> and commit the map.</p>');
147
- if (!t.commits.length) return wrap('<p class="hx-faint">No commit has changed this node\'s file yet.</p>');
153
+ if (!t.commits.length) return wrap('<p class="hx-faint">No commit has changed this node\'s file yet.</p>', 0);
148
154
  const n = t.commits.length;
149
155
  const share = Math.round((t.traced / n) * 100);
150
156
  const stats = `<p class="hx-history-stats"><span><b class="hx-ms">${n}</b> ${n === 1 ? 'commit' : 'commits'}</span> · <span><b class="hx-ms">${t.pulls.length}</b> ${t.pulls.length === 1 ? 'pull request' : 'pull requests'}</span> · <span><b class="hx-ms">${share}%</b> traced to a spec or issue</span></p>`;
@@ -153,16 +159,23 @@ export function historySectionHtml(node, ctx) {
153
159
  const on = ctx.picked === s;
154
160
  return `<button type="button" class="hx-lines-kind" data-corn-kind="quiet" data-history-spec="${esc(s)}" aria-pressed="${on}" title="Light every node spec ${esc(s)} reached">Spec ${esc(s)}${spec ? ` <span class="hx-faint">${esc(spec.label)}</span>` : ''}</button>`;
155
161
  });
156
- const specs = specChips.length ? `<div class="hx-chips" role="group" aria-label="Specs behind it">${specChips.join('')}</div>` : '<p class="hx-faint">No commit to this node names a spec.</p>';
157
- const issues = t.issues.length ? `<p class="hx-history-issues">Issues: ${t.issues.map((i) => { const href = ctx.links && ctx.links.issue(i); return href ? `<a class="hx-link" data-corn="text-link" href="${esc(href)}" target="_blank" rel="noreferrer">#${esc(i)}</a>` : `#${esc(i)}`; }).join(', ')}</p>` : '';
162
+ // The specs and the issues are counts that open (never all at once: a node of code can name eighty issues); a picked spec keeps its specs open, so its chip is in view
163
+ const counted = (words, rows, open) => `<button type="button" class="hx-textbtn hx-history-count" data-sub-toggle aria-expanded="${open}" data-corn-kind="quiet">${words}</button>${rows.replace(/^<(\w+)/, `<$1${open ? '' : ' hidden'}`)}`;
164
+ const picked = !!ctx.picked && t.specs.includes(ctx.picked);
165
+ const specs = specChips.length
166
+ ? counted(`${specChips.length} ${specChips.length === 1 ? 'spec' : 'specs'} behind it`, `<div class="hx-chips" role="group" aria-label="Specs behind it">${specChips.join('')}</div>`, picked)
167
+ : '<p class="hx-faint">No commit to this node names a spec.</p>';
168
+ const issues = t.issues.length
169
+ ? counted(`${t.issues.length} ${t.issues.length === 1 ? 'issue' : 'issues'}`, `<p class="hx-history-issues">${t.issues.map((i) => { const href = ctx.links && ctx.links.issue(i); return href ? `<a class="hx-link" data-corn="text-link" href="${esc(href)}" target="_blank" rel="noreferrer">#${esc(i)}</a>` : `#${esc(i)}`; }).join(', ')}</p>`, false)
170
+ : '';
158
171
  const shown = ctx.all ? t.commits : t.commits.slice(0, HISTORY_CAP);
159
172
  const rows = shown.map((c) => `<li class="hx-history-commit" data-corn="row">`
160
- + `<div class="hx-row-meta">${esc(dayOf(c.date, ctx.locale))} · ${c.nodes.length} ${c.nodes.length === 1 ? 'node' : 'nodes'}${t.born && c.index === t.born.index ? ' · <span class="hx-history-born">born here</span>' : ''}</div>`
173
+ + `<div class="hx-row-meta">${esc(dayOf(c.date, ctx.locale))} · ${c.nodes.length} ${c.nodes.length === 1 ? 'node' : 'nodes'}${t.born && c.index === t.born.index ? ' · <span class="hx-history-born">born here</span>' : ''} · <button type="button" class="hx-textbtn" data-corn-kind="quiet" data-history-at="${c.index}" aria-label="Replay the map at this commit: ${esc(c.subject)}">Replay here</button></div>`
161
174
  + `<div class="hx-history-subject">${esc(c.subject)}</div>`
162
175
  + trailHtml(c, ctx)
163
176
  + '</li>');
164
177
  const more = shown.length < n ? `<button type="button" class="hx-btn hx-btn--quiet hx-textact" data-corn="more" data-corn-kind="quiet" data-history-all>Show all ${n}</button>` : '';
165
- return wrap(`${stats}<h4 class="hx-history-k">Specs behind it</h4>${specs}${issues}<h4 class="hx-history-k">Commits, newest first</h4><ol class="hx-history-list">${rows.join('')}</ol>${more}`);
178
+ return wrap(`${stats}<div class="hx-history-counts">${specs}${issues}</div><h4 class="hx-history-k">${shown.length < n ? `The last ${shown.length} commits` : 'Commits'}, newest first</h4><ol class="hx-history-list">${rows.join('')}</ol>${more}`, n);
166
179
  }
167
180
 
168
181
  /**
@@ -225,10 +238,12 @@ export const haloWidth = (count, max) => (max > 0 && count > 0 ? Math.round((1.5
225
238
  * @param {{ nodes: Map<string, unknown> } | null} heat
226
239
  * @param {string} color the dot's colour
227
240
  */
228
- export function historyRowOf(status, heat, color) {
241
+ export function historyRowOf(status, heat, color, { replaying = false } = {}) {
229
242
  const n = heat ? heat.nodes.size : 0;
230
243
  const countText = status === 'ready' ? `${n} ${n === 1 ? 'node' : 'nodes'}` : status === 'loading' ? 'reading…' : status === 'error' ? 'not read' : 'not read yet';
231
- return { key: HISTORY_LAYER, label: 'History', color, overlay: true, countText, desc: 'A halo round each node the history changed: the wider, the more often; pink this week, violet this month, grey before. Picking a spec in a node\'s History lights what it reached.' };
244
+ // Replay is the History layer's (spec 0015 D6): a button on its row, pressed while the timeline is open (page.js turns the layer on and opens it)
245
+ const action = { name: 'history-replay', label: 'Replay', pressed: replaying === true, title: 'Replay the map\'s history, commit by commit' };
246
+ return { key: HISTORY_LAYER, label: 'History', color, overlay: true, countText, action, desc: 'A halo round each node the history changed: the wider, the more often; pink this week, violet this month, grey before. Picking a spec in a node\'s History lights what it reached.' };
232
247
  }
233
248
 
234
249
  /**
@@ -246,3 +261,69 @@ export function specBarHtml(pick, { links, specs }) {
246
261
  return `<span class="hx-history-bar-text">${name}${label}: ${c} ${c === 1 ? 'commit' : 'commits'}, ${n} ${n === 1 ? 'node' : 'nodes'}</span>`
247
262
  + `<button type="button" class="hx-btn hx-btn--quiet hx-textact" data-corn-kind="quiet" data-history-unpick>Show the whole map</button>`;
248
263
  }
264
+
265
+ /** A commit's kind, from its conventional title: `feat`, `fix`, `docs`, or `other` */
266
+ export function commitKind(subject) {
267
+ const m = /^(\w+)(?:\([^)]*\))?!?:/.exec(String(subject || ''));
268
+ const k = m ? m[1].toLowerCase() : '';
269
+ return k === 'feat' || k === 'fix' || k === 'docs' ? k : 'other';
270
+ }
271
+
272
+ /** The parent of each node, by its ownership edge (no kind, not dashed): where a node buds from */
273
+ export function parentsOf(edges) {
274
+ const out = new Map();
275
+ for (const e of edges || []) if (e && !e.dashed && !e.kind && e.from !== e.to && !out.has(e.to)) out.set(e.to, e.from);
276
+ return out;
277
+ }
278
+
279
+ /**
280
+ * The map at a commit (spec 0014 D1): every node born by then (a node the history does not hold, newer than it, is always there), the edges
281
+ * between them, the nodes born at this commit and those it changed.
282
+ * @param {{ commits: object[], nodes: Record<string, { born: number }> }} history
283
+ * @param {{ from: string, to: string }[]} edges the map's edges
284
+ * @param {number} at a commit's index
285
+ */
286
+ export function replayFrame(history, edges, at) {
287
+ const commits = history.commits;
288
+ const i = Math.max(0, Math.min(commits.length - 1, Number.isInteger(at) ? at : commits.length - 1));
289
+ const hidden = new Set();
290
+ const born = [];
291
+ for (const [id, e] of Object.entries(history.nodes || {})) {
292
+ if (e.born > i) hidden.add(id);
293
+ else if (e.born === i) born.push(id);
294
+ }
295
+ const all = Object.keys(history.nodes || {}).length;
296
+ const shownEdges = (edges || []).filter((e) => !hidden.has(e.from) && !hidden.has(e.to)).length;
297
+ const commit = commits[i];
298
+ return { at: i, total: commits.length, commit, hidden, born: born.sort(), changed: (commit && commit.nodes) || [], nodes: all - hidden.size, edges: shownEdges };
299
+ }
300
+
301
+ /** The count in the corner of the timeline */
302
+ export function replayCount(f) {
303
+ const plural = (n, one, many) => `${n} ${n === 1 ? one : many}`;
304
+ return `${plural(f.nodes, 'node', 'nodes')} · ${plural(f.edges, 'edge', 'edges')} · commit ${f.at + 1} of ${f.total}${f.born.length ? ` · ${f.born.length} born` : ''}`;
305
+ }
306
+
307
+ /**
308
+ * What a step says to a screen reader: the commit, then what was born and what changed, by name (the first few).
309
+ * @param {ReturnType<typeof replayFrame>} f
310
+ * @param {{ labelOf: (id: string) => string, locale?: string }} ctx
311
+ */
312
+ export function stepWords(f, { labelOf, locale }) {
313
+ const c = f.commit || {};
314
+ const names = (ids) => {
315
+ const first = ids.slice(0, 3).map(labelOf);
316
+ return ids.length > 3 ? `${first.join(', ')} and ${ids.length - 3} more` : first.length > 1 ? `${first.slice(0, -1).join(', ')} and ${first[first.length - 1]}` : first.join('');
317
+ };
318
+ const parts = [`Commit ${f.at + 1} of ${f.total}, ${dayOf(c.date, locale)}: ${c.subject || ''}.`];
319
+ if (f.born.length) parts.push(`Born: ${names(f.born)}.`);
320
+ const changed = f.changed.filter((id) => !f.born.includes(id));
321
+ if (changed.length) parts.push(`Changed: ${names(changed)}.`);
322
+ parts.push(`${f.nodes} ${f.nodes === 1 ? 'node' : 'nodes'} on the map.`);
323
+ return parts.join(' ');
324
+ }
325
+
326
+ /** The speeds Replay plays at */
327
+ export const SPEEDS = Object.freeze([1, 2, 4]);
328
+ /** How long a commit stays on screen while Replay plays (ms): the whole history in about 40 seconds at 1×, never under 40 ms or over 700 ms a commit */
329
+ export const speedMs = (total, speed = 1) => Math.max(40, Math.min(700, 40_000 / Math.max(1, total))) / (SPEEDS.includes(speed) ? speed : 1);