@popcorn245/cornfield 0.57.0 → 0.57.1

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.
@@ -385,11 +385,12 @@ export function mergeBlock(detail) {
385
385
  * 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
386
  * what Land does is not changed by it.
387
387
  * @param {{ pull: { state: string }, specs?: { slug: string, approved: boolean }[] }} detail
388
+ * @param {{ review?: 'node' | 'here' | 'list' }} [opts] where Review is: 'node' (the default: the node panel of the proposal), 'here' (a button above the warning in this panel, for a pull request older than the graph's days), 'list' (some proposal is not in the proposals list, so a button cannot open it)
388
389
  */
389
- export function approvalWarning(detail) {
390
+ export function approvalWarning(detail, { review = 'node' } = {}) {
390
391
  if (!detail || detail.pull.state !== 'open') return '';
391
392
  const open = (detail.specs || []).filter((s) => !s.approved).map((s) => s.slug);
392
- return open.length ? `Its proposal${open.length > 1 ? 's' : ''} ${open.join(', ')} ${open.length > 1 ? 'are' : 'is'} not approved yet. Next: approve ${open.length > 1 ? 'them' : 'it'} first (Review in the node panel, then Approve), then land this.` : '';
393
+ return open.length ? `Its proposal${open.length > 1 ? 's' : ''} ${open.join(', ')} ${open.length > 1 ? 'are' : 'is'} not approved yet. Next: approve ${open.length > 1 ? 'them' : 'it'} first (${review === 'here' ? 'Review above, then Approve' : review === 'list' ? `Review ${open.length > 1 ? 'them' : 'it'} from the Proposals list, then Approve` : 'Review in the node panel, then Approve'}), then land this.` : '';
393
394
  }
394
395
 
395
396
  /**
@@ -58,7 +58,7 @@ export function install(ctx) {
58
58
  $('agent-start-msg').textContent = '';
59
59
  $('agent-start-words').textContent = confirmStartWords(refs, fn.forgeName());
60
60
  const go = $('agent-start-go');
61
- go.disabled = false;
61
+ go.removeAttribute('aria-disabled');
62
62
  go.removeAttribute('aria-busy');
63
63
  go.textContent = fn.askRunnerWords();
64
64
  m.agentTrap = trapFocus(keepFocusInAgent);
@@ -129,7 +129,7 @@ export function install(ctx) {
129
129
  if (!ui.agent || ui.agent.posting) return;
130
130
  ui.agent.posting = true;
131
131
  const go = $('agent-start-go');
132
- go.disabled = true;
132
+ go.setAttribute('aria-disabled', 'true'); // not `disabled`: the focus stays on it while the request runs (`ui.agent.posting` guards a second press)
133
133
  go.setAttribute('aria-busy', 'true');
134
134
  go.textContent = 'Asking …';
135
135
  $('agent-start-msg').hidden = true;
@@ -144,7 +144,7 @@ export function install(ctx) {
144
144
  }
145
145
  if (limits === null) {
146
146
  ui.agent.posting = false;
147
- go.disabled = false;
147
+ go.removeAttribute('aria-disabled');
148
148
  go.removeAttribute('aria-busy');
149
149
  go.textContent = fn.askRunnerWords();
150
150
  const bad = $('agent-start-msg');
@@ -170,7 +170,7 @@ export function install(ctx) {
170
170
  fn.paint();
171
171
  return;
172
172
  }
173
- go.disabled = false;
173
+ go.removeAttribute('aria-disabled');
174
174
  go.removeAttribute('aria-busy');
175
175
  go.textContent = fn.askRunnerWords();
176
176
  const msg = $('agent-start-msg');
@@ -32,7 +32,7 @@ export function install(ctx) {
32
32
  ${(what.previews || []).map((pv) => `<p class="hx-confirm-label">${escHtml(pv.label)}</p><pre class="hx-confirm-pre" data-corn="confirm-preview" tabindex="0" role="region" aria-label="${escHtml(pv.label)}">${escHtml(pv.text)}</pre>`).join('')}
33
33
  <p class="hx-confirm-note">${escHtml(what.note)}</p>`);
34
34
  const go = el.querySelector('[data-action="forge-confirm-go"]');
35
- go.disabled = false;
35
+ go.removeAttribute('aria-disabled');
36
36
  go.textContent = goLabel;
37
37
  go.removeAttribute('aria-busy');
38
38
  // The scrim covers the page for the pointer, aria-modal tells a reader the rest is out of play, and the focus stays in
@@ -100,7 +100,7 @@ export function install(ctx) {
100
100
  ui.busy = kind;
101
101
  ui.actNote = null;
102
102
  const go = confirmEl().querySelector('[data-action="forge-confirm-go"]');
103
- go.disabled = true;
103
+ go.setAttribute('aria-disabled', 'true'); // not `disabled`: the focus stays on it while the request runs (the guards are `ui.busy`)
104
104
  go.setAttribute('aria-busy', 'true');
105
105
  go.textContent = 'Working …';
106
106
  announce(kind === 'spec' ? `Starting the spec for issue ${n}` : `Opening the build issue for ${plan.slug}`);
@@ -138,7 +138,7 @@ export function install(ctx) {
138
138
  ui.busy = 'merge';
139
139
  ui.note = null;
140
140
  const go = confirmEl().querySelector('[data-action="forge-confirm-go"]');
141
- go.disabled = true;
141
+ go.setAttribute('aria-disabled', 'true');
142
142
  go.setAttribute('aria-busy', 'true');
143
143
  go.textContent = 'Landing …';
144
144
  announce(`Landing pull request ${pull.number}`);
@@ -18,7 +18,7 @@ export function install(ctx) {
18
18
  const n = item.number;
19
19
  if (!item.open) return `<p class="hx-faint">${escHtml(specBlock({ state: 'closed' }))}</p>`;
20
20
  const spec = specBlock({ state: 'open' }) === null
21
- ? `<button data-corn-kind="secondary" type="button" class="hx-btn hx-forge-act hx-forge-startspec" data-forge-spec="${n}" aria-label="Start a spec for issue ${n}"${ui.busy ? ' disabled' : ''}>Start a spec …</button>`
21
+ ? `<button data-corn-kind="secondary" type="button" class="hx-btn hx-forge-act hx-forge-startspec" data-forge-spec="${n}" aria-label="Start a spec for issue ${n}"${ui.busy ? ' aria-disabled="true"' : ''}>Start a spec …</button>`
22
22
  : '';
23
23
  const agent = `<button data-corn-kind="secondary" type="button" class="hx-btn hx-forge-act hx-forge-startspec" data-forge-agent="issue:${n}" aria-label="${escHtml(t('startAgent'))} on issue ${n}">${escHtml(t('startAgent'))} …</button>`;
24
24
  return `<div class="hx-forge-cta">${agent}${spec}</div>`;
@@ -168,6 +168,8 @@ export function install(ctx) {
168
168
  function onDetailClick(e) {
169
169
  const t = e.target;
170
170
  if (!t.closest) return;
171
+ // A button that waits on its request is `aria-disabled`, not `disabled` (it keeps the focus): a press on it does nothing, so a second press is never a second request
172
+ if (t.closest('button[aria-disabled="true"]')) return;
171
173
  const nodeBtn = t.closest('[data-forge-node]');
172
174
  if (nodeBtn) {
173
175
  const node = nodeById(nodeBtn.dataset.forgeNode);
@@ -84,6 +84,12 @@ export function install(ctx) {
84
84
  }
85
85
  const back = again && box.querySelector(again);
86
86
  if (back && back !== inst.active() && !back.closest('[hidden]') && !back.disabled) back.focus();
87
+ // The control that had the focus is gone (Land it, once the pull request has landed; a Stop that was asked for) and the page has it: it goes to the actions' own place, which a keyboard
88
+ // user continues from with Tab, never to the page. (A pressed button that is still there keeps it: `aria-disabled`, not `disabled`.)
89
+ // (the page's own root is the document: its `activeElement` is then the body, not null)
90
+ const now = inst.active();
91
+ const lost = had && !had.isConnected && (!now || now === inst.doc.body);
92
+ if (lost && !(kind === 'run' && had.closest('[data-run]'))) { box.setAttribute('tabindex', '-1'); box.focus(); }
87
93
  // A control of a run card that is no longer drawn (the run went on): the focus goes to that run's card, never to the page
88
94
  const hadRun = had && !had.isConnected && had.closest('[data-run]');
89
95
  if (hadRun && !box.contains(inst.active())) {
@@ -124,7 +124,7 @@ export function install(ctx) {
124
124
  const name = safeUrl(c.url) ? `<a data-corn="text-link" class="hx-link" href="${escHtml(c.url)}" target="_blank" rel="noreferrer">${escHtml(c.name)}</a>` : `<span class="hx-name">${escHtml(c.name)}</span>`;
125
125
  const why = rerunWhy(c, fn.forgeName());
126
126
  const again = c.state === 'failure' && c.canRerun
127
- ? `<button data-corn-kind="secondary" type="button" class="hx-btn hx-forge-act" data-forge-rerun="${escHtml(c.id)}" aria-label="Re-run ${escHtml(c.name)}"${ui.busy ? ' disabled' : ''}>Re-run</button>`
127
+ ? `<button data-corn-kind="secondary" type="button" class="hx-btn hx-forge-act" data-forge-rerun="${escHtml(c.id)}" aria-label="Re-run ${escHtml(c.name)}"${ui.busy ? ' aria-disabled="true"' : ''}>Re-run</button>`
128
128
  : '';
129
129
  const whyNot = why ? `<span class="hx-faint hx-forge-lights">${escHtml(why)}</span>` : '';
130
130
  return `<li class="hx-forge-check"><span class="hx-forge-state hx-forge-state--${escHtml(c.state)}" data-corn="state-pill"${cornStateAttr(c.state)}>${stateIconHtml(c.state)}${escHtml(checkWords(c))}</span> ${name}${again}${lights}${whyNot}</li>`;
@@ -142,18 +142,28 @@ export function install(ctx) {
142
142
  const block = mergeBlock(ui.detail);
143
143
  const land = block
144
144
  ? `<button type="button" class="hx-btn hx-btn--approve" disabled data-corn-kind="approve">${escHtml(t('landIt'))}</button>`
145
- : `<button type="button" class="hx-btn hx-btn--approve hx-forge-act" data-forge-merge="${escHtml(String(pull.number))}"${ui.busy ? ' disabled' : ''} data-corn-kind="approve">${escHtml(t('landIt'))} …</button>`;
146
- const act = `<div class="hx-forge-cta">${land}${url ? `<a data-corn="open-link" data-corn-kind="secondary" class="hx-btn hx-forge-open" href="${escHtml(url)}" target="_blank" rel="noreferrer">Open on ${escHtml(fn.forgeName())} ↗</a>` : ''}</div>${block ? `<p class="hx-forge-why hx-faint">${escHtml(block)}</p>` : ''}${approvalWarning(ui.detail) ? `<p class="hx-forge-why hx-faint" data-corn="notice" data-corn-state="waiting">${escHtml(approvalWarning(ui.detail))}</p>` : ''}`;
145
+ : `<button type="button" class="hx-btn hx-btn--approve hx-forge-act" data-forge-merge="${escHtml(String(pull.number))}"${ui.busy ? ' aria-disabled="true"' : ''} data-corn-kind="approve">${escHtml(t('landIt'))} …</button>`;
146
+ // A spec pull request older than the graph's 14 days is a plain pull request here, with no Review of its own: its proposals that are not approved get one, found by their slug in the
147
+ // proposals list (the node panel of one the graph holds has it already: pieces/work-specs.js). A proposal the list does not hold is named in the warning instead.
148
+ // Only this pull request's own copy: another pull request may hold a file of the same slug (anyone can open one), and approving that copy would approve, and with
149
+ // `approveLands` land, the other pull request
150
+ const ownCopy = (slug) => { const e = fn.specEntry({ slug, number: pull.number }); return e && e.pull && e.pull.number === pull.number ? e : null; };
151
+ const reviewable = ui.item && ui.item.kind === 'pull' && pull.state === 'open'
152
+ ? (ui.detail.specs || []).filter((x) => !x.approved).map((x) => ({ slug: x.slug, entry: ownCopy(x.slug) }))
153
+ : [];
154
+ const review = reviewable.filter((x) => x.entry).map((x) => `<button type="button" class="hx-btn hx-forge-act" data-corn-kind="secondary" data-work-action="review" data-slug="${escHtml(x.slug)}" data-source="${escHtml(x.entry.source || '')}" aria-label="Review proposal ${escHtml(x.slug)}">Review ${escHtml(x.slug)} …</button>`).join('');
155
+ const warning = approvalWarning(ui.detail, { review: !reviewable.length ? 'node' : reviewable.every((x) => x.entry) ? 'here' : 'list' });
156
+ const act = `<div class="hx-forge-cta">${land}${review}${url ? `<a data-corn="open-link" data-corn-kind="secondary" class="hx-btn hx-forge-open" href="${escHtml(url)}" target="_blank" rel="noreferrer">Open on ${escHtml(fn.forgeName())} ↗</a>` : ''}</div>${block ? `<p class="hx-forge-why hx-faint">${escHtml(block)}</p>` : ''}${warning ? `<p class="hx-forge-why hx-faint" data-corn="notice" data-corn-state="waiting">${escHtml(warning)}</p>` : ''}`;
147
157
  // A spec approved with `proposals.approveLands` waits for its checks: said here, with a way to stop it
148
158
  const waiting = ui.landing && pull.state === 'open'
149
- ? `<div class="hx-forge-step"><p class="hx-forge-notice hx-forge-notice--ok" role="status" data-corn="notice" data-corn-state="success">${escHtml(landingWords(ui.landing, m.now()))}</p><button data-corn-kind="secondary" type="button" class="hx-btn hx-forge-act" data-forge-landing-cancel="${pull.number}"${ui.busy ? ' disabled' : ''}>Cancel</button></div>`
159
+ ? `<div class="hx-forge-step"><p class="hx-forge-notice hx-forge-notice--ok" role="status" data-corn="notice" data-corn-state="success">${escHtml(landingWords(ui.landing, m.now()))}</p><button data-corn-kind="secondary" type="button" class="hx-btn hx-forge-act" data-forge-landing-cancel="${pull.number}"${ui.busy ? ' aria-disabled="true"' : ''}>Cancel</button></div>`
150
160
  : '';
151
161
  const note = ui.note ? `<p class="hx-forge-notice${ui.note.ok ? ' hx-forge-notice--ok' : ''}" data-corn="notice"${ui.note.ok ? ' data-corn-state="success"' : ''}>${escHtml(ui.note.text)}</p>` : '';
152
162
  // Step 2 of the pipeline: a spec pull request with an approved proposal opens its build issue
153
163
  const offers = buildOffers(ui.detail);
154
164
  const build = offers.length
155
165
  ? `<h3 class="hx-forge-subact">Build issue</h3>${offers.map((o) => (o.offer
156
- ? `<div class="hx-forge-step"><button type="button" class="hx-btn hx-btn--approve hx-forge-act" data-forge-build="${escHtml(o.slug)}" aria-label="Open the build issue for ${escHtml(o.slug)}"${ui.busy ? ' disabled' : ''} data-corn-kind="approve">Open the build issue …</button><p class="hx-forge-why hx-faint"><code class="hx-code">${escHtml(o.slug)}</code> is approved. Opens a confirm step that shows the issue. Nothing is built.</p></div>`
166
+ ? `<div class="hx-forge-step"><button type="button" class="hx-btn hx-btn--approve hx-forge-act" data-forge-build="${escHtml(o.slug)}" aria-label="Open the build issue for ${escHtml(o.slug)}"${ui.busy ? ' aria-disabled="true"' : ''} data-corn-kind="approve">Open the build issue …</button><p class="hx-forge-why hx-faint"><code class="hx-code">${escHtml(o.slug)}</code> is approved. Opens a confirm step that shows the issue. Nothing is built.</p></div>`
157
167
  : `<p class="hx-forge-why hx-faint"><code class="hx-code">${escHtml(o.slug)}</code>: ${escHtml(o.why)}</p>`)).join('')}`
158
168
  : '';
159
169
 
@@ -215,7 +215,7 @@ export function install(ctx) {
215
215
  $('idea-open').setAttribute('aria-expanded', String(ui.idea.open));
216
216
  $('idea-form').hidden = !ui.idea.open;
217
217
  $('idea-send').textContent = ui.idea.busy ? 'Opening …' : 'Open the idea';
218
- $('idea-send').disabled = ui.idea.busy;
218
+ if (ui.idea.busy) $('idea-send').setAttribute('aria-disabled', 'true'); else $('idea-send').removeAttribute('aria-disabled'); // not `disabled`: the focus stays (`sendIdea` ignores a press while busy)
219
219
  if (ui.idea.open) {
220
220
  const label = (ui.config && ui.config.threads && ui.config.threads.label) || 'idea';
221
221
  $('idea-words').textContent = `This opens an issue labelled "${label}" on ${fn.forgeName()}, as you. The conversation lives there; cornfield keeps no copy of it.`;
@@ -94,7 +94,7 @@ function answerHtml(ctx, run) {
94
94
  const say = ctx.t || t; // the words of the instance that draws it (the Work piece hands its own), else the page's
95
95
  const id = ctx.esc(run.runId);
96
96
  const name = ctx.esc(runName(run, ctx.now));
97
- const off = ctx.busy ? ' disabled' : '';
97
+ 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
98
  const reply = ctx.replies && ctx.replies.get(run.runId) || '';
99
99
  return `${run.answer ? answeredHtml(ctx, run) : ''}<div class="hx-run-actions" data-corn="run-actions" role="group" aria-label="Answer: ${name}">
100
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>
@@ -147,7 +147,7 @@ export function runHtml(ctx, run, all) {
147
147
  const name = ctx.esc(runName(run, ctx.now));
148
148
  const note = run.report && run.report.note ? `<p class="hx-forge-meta">Runner: ${ctx.esc(run.report.note)}</p>` : '';
149
149
  const answering = canAnswer(run);
150
- const off = ctx.busy ? ' disabled' : '';
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
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
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>` : '';
153
153
  const names = nodeLabels(run.nodes, ctx.nodes);
@@ -306,8 +306,9 @@ const cut = (n, cap) => { const cols = Math.max(1, Math.ceil(n / cap)); return {
306
306
 
307
307
  function layoutDesk(stages, drafts, code, v, p) {
308
308
  const c = DESK;
309
- // Left to right: Talk, Decide, the drafts (when they are shown), Build, Ship, then the code
310
- const lanes = [stages[0], stages[1], ...(drafts.length ? [{ key: 'drafts', title: DRAFT_LANE_TITLE, nodes: drafts }] : []), stages[2], stages[3], ...(code.length ? [{ key: 'code', title: CODE_LANE_TITLE, nodes: code, code: true }] : [])];
309
+ // Left to right: Talk, Decide, Build, Ship, then the code. The drafts (when they are shown) are not a lane of this row: their own band under it, as wide as the row, so that they never
310
+ // widen what the first fit has to show and take the names' room from the lanes of work (turning them on left 1 of 9 Talk names placed): the fit is the row's, and the band is panned to
311
+ const lanes = [stages[0], stages[1], stages[2], stages[3], ...(code.length ? [{ key: 'code', title: CODE_LANE_TITLE, nodes: code, code: true }] : [])];
311
312
  const plan = (z, cap) => {
312
313
  const room = TITLE_PX / z;
313
314
  const below = NAME_PX / z;
@@ -350,7 +351,24 @@ function layoutDesk(stages, drafts, code, v, p) {
350
351
  });
351
352
  out.push(lane(l.key, l.title, l.nodes.length, part.x, 0, part.w, g.h));
352
353
  }
353
- return { lanes: out, order: g.parts.flatMap((part) => part.l.nodes.map((n) => n.id)), bounds: { x: 0, y: 0, w: g.w, h: g.h }, fit: fitBoxOf(g.w, g.h, z, c.margin, p, v) };
354
+ const order = g.parts.flatMap((part) => part.l.nodes.map((n) => n.id));
355
+ let bottom = g.h;
356
+ if (drafts.length) {
357
+ // the band: columns of the lanes' own cell, as many as the row is wide, staggered as the lanes' are; it starts a gap under the row
358
+ const top = g.h + c.gap;
359
+ const room = TITLE_PX / z;
360
+ const cols = Math.max(1, Math.floor((g.w - 2 * c.pad) / c.cell));
361
+ const rows = Math.ceil(drafts.length / cols);
362
+ drafts.forEach((n, j) => {
363
+ const col = j % cols;
364
+ n.x = c.pad + (col + 0.5) * c.cell + (g.w - 2 * c.pad - cols * c.cell) / 2;
365
+ n.y = top + room + 20 + (Math.floor(j / cols) + (col % 2) * 0.5) * c.row;
366
+ });
367
+ bottom = top + room + 40 + (rows - 0.5) * c.row + NAME_PX / z + 8;
368
+ out.push(lane('drafts', DRAFT_LANE_TITLE, drafts.length, 0, top, g.w, bottom - top));
369
+ order.push(...drafts.map((n) => n.id));
370
+ }
371
+ return { lanes: out, order, bounds: { x: 0, y: 0, w: g.w, h: bottom }, fit: fitBoxOf(g.w, g.h, z, c.margin, p, v) };
354
372
  }
355
373
 
356
374
  function layoutPhone(stages, drafts, code, v, p) {
@@ -11,6 +11,8 @@
11
11
  .hx-view-badge { margin-left: var(--corn-space-2); }
12
12
  .hx-work-links { list-style: none; margin: 0; padding: 0; }
13
13
  .hx-work-links li { display: flex; align-items: center; gap: var(--corn-space-2); min-height: 2.25rem; border-bottom: var(--corn-border) solid var(--corn-line); }
14
+ .hx-work-links, .hx-work-links li { min-width: 0; max-width: 100%; }
15
+ .hx-work-links li > a, .hx-work-links li > button { min-width: 0; overflow-wrap: anywhere; text-align: left; } /* a title with no spaces breaks anywhere rather than run past the panel */
14
16
  .hx-work-rel { flex: none; width: 6.5rem; color: var(--corn-text-3); font-size: var(--corn-text-xs); }
15
17
  .hx-work-dot { flex: none; width: 0.6rem; height: 0.6rem; border-radius: var(--corn-radius-sm); background: var(--corn-text-3); }
16
18
  .hx-work-head, .hx-work-actions { display: flex; flex-direction: column; gap: var(--corn-space-2); margin: var(--corn-space-3) 0; }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@popcorn245/cornfield",
3
- "version": "0.57.0",
3
+ "version": "0.57.1",
4
4
  "description": "A self-hostable dev dashboard with the topology map at its centre: proposals on the map, scenarios, outages and what-if edits, for any repo.",
5
5
  "license": "MIT",
6
6
  "author": "popcorn245 (https://github.com/popcorn245)",