cornfield 0.23.0 → 0.25.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.
package/core/brand.js ADDED
@@ -0,0 +1,182 @@
1
+ /**
2
+ * @module core/brand
3
+ *
4
+ * The `brand` key of cornfield.config.js (docs/config.md#brand), and the rules a brand asset must keep.
5
+ * `brandAssetFile` is the one place that looks at an asset on disk, so the server and `cornfield validate` judge a file by the same rule.
6
+ *
7
+ * brand: {
8
+ * logo: './tools/cornfield/logo.svg', // replaces the brand mark in the header
9
+ * wordmark: './tools/cornfield/word.svg', // replaces the title text in the header
10
+ * favicon: './tools/cornfield/favicon.png', // <link rel="icon">
11
+ * appName: 'Acme', // replaces "cornfield" where cornfield names itself (tab title, heading, manifest)
12
+ * color: '#e53e3e', // the manifest's theme_color (and the tab's theme-color)
13
+ * background: '#ffffff', // the manifest's background_color
14
+ * }
15
+ *
16
+ * Images only, from the repo only, served same-origin and never inlined into the page.
17
+ */
18
+
19
+ import fs from 'node:fs';
20
+ import path from 'node:path';
21
+
22
+ export const BRAND_KEYS = Object.freeze(['logo', 'wordmark', 'favicon', 'appName', 'color', 'background']);
23
+ /** The keys that name an image file */
24
+ export const BRAND_IMAGE_KEYS = Object.freeze(['logo', 'wordmark', 'favicon']);
25
+ /** The largest a brand asset may be, in bytes */
26
+ export const MAX_BRAND_BYTES = 512 * 1024;
27
+ export const MAX_APP_NAME = 64;
28
+ /** Where the brand images are served (server/server.js): `/cornfield/brand/<key>.<ext>`, only for a key the config sets */
29
+ export const BRAND_PREFIX = '/cornfield/brand/';
30
+ export const MANIFEST_PATH = '/manifest.webmanifest';
31
+ /** The only brand image types, by lower-case extension */
32
+ export const BRAND_TYPES = Object.freeze({ '.svg': 'image/svg+xml', '.png': 'image/png' });
33
+ /** An SVG is an image here, never a page: opened on its own it may not run or load anything */
34
+ export const BRAND_SVG_CSP = "default-src 'none'; style-src 'unsafe-inline'";
35
+ const PNG_MAGIC = Buffer.from('89504e470d0a1a0a', 'hex');
36
+ const HEX_COLOR = /^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;
37
+
38
+ const isObject = (v) => v !== null && typeof v === 'object' && !Array.isArray(v);
39
+ const isText = (v) => typeof v === 'string' && v.trim() !== '';
40
+ const unset = (v) => v === undefined || v === null;
41
+ /** A path inside the repo, relative, ending in .svg or .png */
42
+ const imagePathInRepo = (p) => isText(p) && !path.isAbsolute(p) && !/^[a-z]:/i.test(p) && !p.split(/[\\/]/).includes('..') && !p.includes('\0') && Boolean(BRAND_TYPES[path.extname(p).toLowerCase()]);
43
+
44
+ /**
45
+ * What is wrong with a `brand` value (as the config file wrote it).
46
+ * @param {unknown} b
47
+ * @returns {string[]}
48
+ */
49
+ export function brandProblems(b) {
50
+ if (b === undefined) return [];
51
+ if (!isObject(b)) return ['"brand" is { logo?, wordmark?, favicon?, appName?, color?, background? }.'];
52
+ const out = [];
53
+ for (const k of Object.keys(b)) if (!BRAND_KEYS.includes(k)) out.push(`brand.${k}: the keys are ${BRAND_KEYS.join(', ')}.`);
54
+ for (const k of BRAND_IMAGE_KEYS) {
55
+ if (!unset(b[k]) && !imagePathInRepo(b[k])) out.push(`brand.${k} is one image (an .svg or .png file) inside the repo, written relative to it, like "./tools/cornfield/${k}.svg".`);
56
+ }
57
+ if (!unset(b.appName) && (typeof b.appName !== 'string' || !b.appName.trim() || b.appName.length > MAX_APP_NAME || /[\u0000-\u001f\u007f]/.test(b.appName))) {
58
+ out.push(`brand.appName is text of at most ${MAX_APP_NAME} characters, on one line.`);
59
+ }
60
+ for (const k of ['color', 'background']) {
61
+ if (!unset(b[k]) && !(typeof b[k] === 'string' && HEX_COLOR.test(b[k]))) out.push(`brand.${k} is a hex colour, like "#e53e3e" or "#e33".`);
62
+ }
63
+ return out;
64
+ }
65
+
66
+ /** A brand colour as it may reach the page and the manifest: a hex colour, else null (configProblems refuses anything else; this is the second lock) */
67
+ export const colorOf = (v) => (typeof v === 'string' && HEX_COLOR.test(v) ? v : null);
68
+
69
+ /** Whether the brand sets anything at all */
70
+ export const brandOn = (brand) => Boolean(brand) && BRAND_KEYS.some((k) => !unset(brand[k]));
71
+
72
+ /** The name chrome shows: the brand's `appName`, else null (the caller falls back to the repo's title or "cornfield") */
73
+ export const appNameOf = (brand) => (brand && typeof brand.appName === 'string' && brand.appName.trim() ? brand.appName.trim() : null);
74
+
75
+ /**
76
+ * The images a brand names, `[{ key, rel, url, type }]`: the url is where the server serves it (`/cornfield/brand/<key>.<ext>`).
77
+ * @param {object} brand
78
+ */
79
+ export function brandImages(brand) {
80
+ const out = [];
81
+ for (const key of BRAND_IMAGE_KEYS) {
82
+ const rel = brand && brand[key];
83
+ if (!imagePathInRepo(rel)) continue;
84
+ const ext = path.extname(rel).toLowerCase();
85
+ out.push({ key, rel, url: `${BRAND_PREFIX}${key}${ext}`, type: BRAND_TYPES[ext] });
86
+ }
87
+ return out;
88
+ }
89
+
90
+ /**
91
+ * The brand as the browser is told it: URLs and the name, never a path on this machine. null when nothing is set.
92
+ * @param {object} brand
93
+ * @param {string} poweredBy where "powered by cornfield" leads
94
+ */
95
+ export function clientBrand(brand, poweredBy) {
96
+ if (!brandOn(brand)) return null;
97
+ const urls = Object.fromEntries(brandImages(brand).map((i) => [i.key, i.url]));
98
+ return { logo: urls.logo || null, wordmark: urls.wordmark || null, favicon: urls.favicon || null, appName: appNameOf(brand), poweredBy };
99
+ }
100
+
101
+ /** Whether the first bytes of an SVG file are an SVG document: optional BOM, space, an xml declaration, comments and a doctype, then `<svg` */
102
+ function looksLikeSvg(buf) {
103
+ let s = buf.toString('utf8').replace(/^/, '');
104
+ for (;;) {
105
+ s = s.replace(/^\s+/, '');
106
+ const skip = /^(?:<\?xml[\s\S]*?\?>|<!--[\s\S]*?-->|<!DOCTYPE[^>[]*(?:\[[\s\S]*?\])?\s*>)/i.exec(s);
107
+ if (!skip) break;
108
+ s = s.slice(skip[0].length);
109
+ }
110
+ return /^<svg[\s>/]/.test(s);
111
+ }
112
+
113
+ /** Whether a file's bytes are what its extension says (`.png`: the PNG signature, then the IHDR chunk a PNG must start with; `.svg`: an SVG document) */
114
+ export function magicMatches(ext, buf) {
115
+ if (ext === '.png') return buf.length >= 33 && buf.subarray(0, PNG_MAGIC.length).equals(PNG_MAGIC) && buf.readUInt32BE(8) === 13 && buf.toString('latin1', 12, 16) === 'IHDR';
116
+ if (ext === '.svg') return !buf.includes(0) && looksLikeSvg(buf);
117
+ return false;
118
+ }
119
+
120
+ /** A PNG's width and height from its header, or null */
121
+ export function pngSize(buf) {
122
+ if (!magicMatches('.png', buf)) return null;
123
+ const w = buf.readUInt32BE(16);
124
+ const h = buf.readUInt32BE(20);
125
+ return w > 0 && h > 0 ? { width: w, height: h } : null;
126
+ }
127
+
128
+ /**
129
+ * The file on disk a brand image names, or why there is none: a plain file whose real path is inside the repo (a link out is
130
+ * refused), with an allowed extension and bytes that match it, at most MAX_BRAND_BYTES.
131
+ * @param {string} root the repo
132
+ * @param {string} rel the path as the config wrote it
133
+ * @returns {{ file: string, size: number, type: string, ext: string, body: Buffer } | { problem: string }}
134
+ */
135
+ export function brandAssetFile(root, rel) {
136
+ const ext = typeof rel === 'string' ? path.extname(rel).toLowerCase() : '';
137
+ const type = BRAND_TYPES[ext];
138
+ if (!type) return { problem: 'is not an .svg or .png file.' };
139
+ let base;
140
+ let real;
141
+ try { base = fs.realpathSync(root); } catch { return { problem: 'the repo does not exist.' }; }
142
+ try { real = fs.realpathSync(path.resolve(root, rel)); } catch { return { problem: 'does not exist.' }; }
143
+ if (!real.startsWith(base + path.sep)) return { problem: 'leaves the repo (a link or a path that resolves outside it).' };
144
+ const stats = fs.statSync(real);
145
+ if (!stats.isFile()) return { problem: 'is not a file.' };
146
+ if (stats.size > MAX_BRAND_BYTES) return { problem: `is ${Math.ceil(stats.size / 1024)} KB; a brand image is at most ${MAX_BRAND_BYTES / 1024} KB.` };
147
+ const body = fs.readFileSync(real);
148
+ if (body.length > MAX_BRAND_BYTES) return { problem: `is over ${MAX_BRAND_BYTES / 1024} KB; a brand image is at most that.` };
149
+ if (!magicMatches(ext, body)) return { problem: `is not really ${ext === '.png' ? 'a PNG' : 'an SVG'} (its first bytes do not match its ${ext} extension).` };
150
+ return { file: real, size: body.length, type, ext, body };
151
+ }
152
+
153
+ /**
154
+ * The web app manifest (served at MANIFEST_PATH, with or without a brand, so any cornfield can be installed on a phone): name and
155
+ * short name from `appName` or the repo's title, the favicon and the logo as icons, the colours when the config sets them,
156
+ * standalone, starting at `/`. Without a brand: the repo's title and no icons (cornfield ships no favicon of its own).
157
+ * @param {object | null | undefined} brand
158
+ * @param {string} title the repo's title
159
+ * @param {(rel: string) => { body: Buffer } | { problem: string }} readImage
160
+ */
161
+ export function manifestOf(brand, title, readImage) {
162
+ const name = appNameOf(brand) || title;
163
+ const icons = [];
164
+ const seen = new Set();
165
+ for (const img of brandImages(brand).filter((i) => i.key !== 'wordmark').sort((a, b) => a.key.localeCompare(b.key))) { // favicon, then logo
166
+ if (seen.has(img.rel)) continue;
167
+ seen.add(img.rel);
168
+ const found = readImage(img.rel);
169
+ if ('problem' in found) continue;
170
+ const size = img.type === 'image/png' ? pngSize(found.body) : null;
171
+ icons.push({ src: img.url, type: img.type, sizes: img.type === 'image/png' ? (size ? `${size.width}x${size.height}` : '') : 'any', purpose: 'any' });
172
+ }
173
+ return {
174
+ name,
175
+ short_name: [...name].slice(0, 12).join(''),
176
+ start_url: '/',
177
+ display: 'standalone',
178
+ ...(colorOf(brand && brand.color) ? { theme_color: brand.color } : {}),
179
+ ...(colorOf(brand && brand.background) ? { background_color: brand.background } : {}),
180
+ icons: icons.map((i) => (i.sizes ? i : { src: i.src, type: i.type, purpose: i.purpose })),
181
+ };
182
+ }
package/core/config.js CHANGED
@@ -27,6 +27,7 @@
27
27
  * threads: { label: 'idea' }, // an idea is an issue with this label, its thread the issue's comments; false turns threads off (docs/threads.md)
28
28
  * links: [], // [{ label, href }] shown in the explorer's header
29
29
  * theme: {}, // { css, fonts, fontHosts, names, default }: a repo's own look, CSS only (docs/config.md#theme)
30
+ * brand: {}, // { logo, wordmark, favicon, appName, color, background }: a repo's own logo and name, images from the repo (docs/config.md#brand)
30
31
  * proxy: {}, // { '/api/': 'http://127.0.0.1:3245' }: same-origin paths for a live source
31
32
  * importMap: {}, // bare imports a repo-local browser module needs: { name: '/repo/path.js' }
32
33
  * dataDir: null, // where cornfield keeps its own state (reviews; the SQLite file in v1)
@@ -42,6 +43,7 @@ import os from 'node:os';
42
43
  import path from 'node:path';
43
44
  import { pathToFileURL, fileURLToPath } from 'node:url';
44
45
  import { themeProblems } from './theme.js';
46
+ import { brandProblems } from './brand.js';
45
47
  import { PROFILE_SOURCE, MAX_NUMBER, MAX_BRIEF_CHARS, RUN_KINDS, TRIGGER_EVENTS, CREDENTIAL_VALUE_SOURCE } from './agent-contract.js';
46
48
 
47
49
  export { TRIGGER_EVENTS };
@@ -167,6 +169,7 @@ export const DEFAULTS = Object.freeze({
167
169
  threads: { label: 'idea' },
168
170
  links: [],
169
171
  theme: { css: null, fonts: [], fontHosts: [], names: {}, default: null },
172
+ brand: { logo: null, wordmark: null, favicon: null, appName: null, color: null, background: null },
170
173
  proxy: {},
171
174
  importMap: {},
172
175
  dataDir: null,
@@ -340,6 +343,7 @@ export function configProblems(c) {
340
343
  });
341
344
  }
342
345
  out.push(...themeProblems(c.theme));
346
+ out.push(...brandProblems(c.brand));
343
347
  if (c.proxy !== undefined) {
344
348
  if (!isObject(c.proxy)) out.push('"proxy" is { "/path/": "http://upstream" }.');
345
349
  else for (const [p, t] of Object.entries(c.proxy)) {
@@ -527,6 +531,7 @@ export async function loadConfig(root, { env = process.env, file } = {}) {
527
531
  agents: { ...DEFAULTS.agents, ...(raw.agents || {}) },
528
532
  };
529
533
  config.theme = { ...structuredClone(DEFAULTS.theme), ...(raw.theme || {}) };
534
+ config.brand = { ...DEFAULTS.brand, ...(raw.brand || {}) };
530
535
  // `threads: false` stays false; an object is read over the default
531
536
  config.threads = raw.threads === false ? false : { ...DEFAULTS.threads, ...(raw.threads || {}) };
532
537
  // `hookPoll: false` is `{ specs: false }`; an object is read over the default
package/core/validate.js CHANGED
@@ -23,6 +23,7 @@ import { CLOUD_FILE, cloudNodeProblems } from './cloud.js';
23
23
  import { deriveTopology } from './derive.js';
24
24
  import { missingPaths, planSync } from './sync.js';
25
25
  import { repoPaths, repoReader } from './repo.js';
26
+ import { BRAND_IMAGE_KEYS, brandAssetFile } from './brand.js';
26
27
  import { MAX_THEME_BYTES, cssProblems, cssUrls, themeAssetFile, themeFileUrl, themeFiles, themeUrlTarget } from './theme.js';
27
28
 
28
29
  /** How a page is produced today, and whether it is baked to a file */
@@ -66,6 +67,23 @@ export function validateThemeFiles(config) {
66
67
  return errors;
67
68
  }
68
69
 
70
+ /**
71
+ * The config's brand images (docs/config.md#brand): each one exists, is a plain file inside the repo (a link out of it is refused),
72
+ * has an allowed extension (.svg, .png) and first bytes that match it, and is at most MAX_BRAND_BYTES (core/brand.js `brandAssetFile`).
73
+ * @param {{ root: string, brand?: object }} config
74
+ * @returns {string[]}
75
+ */
76
+ export function validateBrandFiles(config) {
77
+ const errors = [];
78
+ for (const key of BRAND_IMAGE_KEYS) {
79
+ const rel = config.brand && config.brand[key];
80
+ if (typeof rel !== 'string') continue;
81
+ const found = brandAssetFile(config.root, rel);
82
+ if ('problem' in found) errors.push(`brand.${key} (${rel}) ${found.problem}`);
83
+ }
84
+ return errors;
85
+ }
86
+
69
87
  /**
70
88
  * The schema checks: no files, no derivers.
71
89
  * @param {{ nodes: any[], edges: any[] }} topology
@@ -257,6 +275,7 @@ export async function validateRepo({ config, derivers, topology = readTopology(c
257
275
  }
258
276
  errors.push(...validatePersonasFile(config.root, config.personas.roles));
259
277
  errors.push(...validateThemeFiles(config));
278
+ errors.push(...validateBrandFiles(config));
260
279
  errors.push(...validateCloudNodes(topology, config.root));
261
280
  errors.push(...validateProposalFiles(topology, path.join(config.root, config.proposals), config.root));
262
281
  const io = repoReader(config.root);
package/explorer/check.js CHANGED
@@ -25,6 +25,7 @@
25
25
  import { state, escHtml } from './state.js';
26
26
  import { toggleLayer } from './layers.js';
27
27
  import { mapIndex, personaLabel, planChecks, runChecks, stepVerdict, verdictWords } from './check-model.js';
28
+ import { cornState } from './corn-state.js';
28
29
 
29
30
  let checker = null;
30
31
  let current = null; // { scenario, as, nodes, plan, answer, controller, onChange }
@@ -128,6 +129,7 @@ function mountControls(bar) {
128
129
  const title = bar.querySelector('.hx-player-title');
129
130
  const pill = document.createElement('span');
130
131
  pill.className = 'hx-player-verdict';
132
+ pill.dataset.corn = 'state-pill';
131
133
  pill.hidden = true;
132
134
  if (head && title) title.after(pill); else bar.prepend(pill);
133
135
 
@@ -208,6 +210,7 @@ export function paintChecks(bar, snap) {
208
210
  line.hidden = !words;
209
211
  if (words) {
210
212
  pill.dataset.tone = words.tone;
213
+ if (cornState(words.tone)) pill.dataset.cornState = cornState(words.tone); else delete pill.dataset.cornState;
211
214
  pill.textContent = words.pill;
212
215
  pill.title = words.line;
213
216
  line.dataset.tone = words.tone;
@@ -95,7 +95,7 @@ export function cloudUsedBy(node, nodes, edges) {
95
95
  /** More users of one kind than this, in one group, fold into a count ("42 containers") with the list behind it */
96
96
  export const FOLD_AT = 8;
97
97
 
98
- const sec = (title, body) => `<div class="hx-sec"><strong class="hx-strong">${title}</strong>${body}</div>`;
98
+ const sec = (title, body) => `<div class="hx-sec" data-corn="section"><strong class="hx-strong">${title}</strong>${body}</div>`;
99
99
  const row = (color, arrow, body) => `<div class="hx-line"><span class="hx-glyph" style="--glyph:${color}">${arrow}</span><span>${body}</span></div>`;
100
100
  const name = (label) => `<span class="hx-name">${esc(label)}</span>`;
101
101
 
@@ -116,7 +116,7 @@ function groupHtml(group) {
116
116
  }
117
117
 
118
118
  /** The Play button (spec 0031 section 8, CLOUD-07): main.js plays outage-model.js `outageScenario` for the node */
119
- const playButton = (node) => `<div class="hx-sec"><button type="button" class="hx-btn hx-cloud-play" data-action="play-outage" data-id="${esc(node.id)}">▶ Play: ${esc(String(node.label || node.id))} is down</button></div>`;
119
+ const playButton = (node) => `<div class="hx-sec" data-corn="section"><button type="button" class="hx-btn hx-cloud-play" data-action="play-outage" data-id="${esc(node.id)}">▶ Play: ${esc(String(node.label || node.id))} is down</button></div>`;
120
120
 
121
121
  /**
122
122
  * The node panel's section for a cloud node (kind `cloud`) or the public web (kind `web`): badges and plan,
@@ -128,8 +128,8 @@ export function cloudPanelHtml(node, nodes, edges) {
128
128
  const label = (id) => String((byId.get(id) || { label: id }).label || id);
129
129
  const [kind, ...roles] = cloudBadges(node);
130
130
  const tier = node.kind === 'web' ? null : (node.plan && TIER_WORDS[node.plan.tier] ? node.plan.tier : 'unknown');
131
- const badges = `<div class="hx-cloud-badges"><span class="hx-cloud-badge hx-cloud-badge--${node.kind === 'web' ? 'web' : 'kind'}">${esc(kind)}</span>`
132
- + roles.map((r) => `<span class="hx-cloud-badge">${esc(r)}</span>`).join('')
131
+ const badges = `<div class="hx-cloud-badges"><span class="hx-cloud-badge hx-cloud-badge--${node.kind === 'web' ? 'web' : 'kind'}" data-corn="badge">${esc(kind)}</span>`
132
+ + roles.map((r) => `<span class="hx-cloud-badge" data-corn="badge">${esc(r)}</span>`).join('')
133
133
  + (tier ? `<span class="hx-cloud-plan hx-cloud-plan--${tier}">${esc(TIER_WORDS[tier])}</span>` : '')
134
134
  + '</div>'
135
135
  + (tier && node.plan && node.plan.note ? `<div class="hx-faint hx-cloud-plan-note">${esc(node.plan.note)}</div>` : '');
@@ -0,0 +1,34 @@
1
+ /**
2
+ * The public `data-corn-state` values (docs/theming.md, "States"): a small fixed set a theme can rely on, whatever word the
3
+ * forge, the runner or the model uses. A pill, a run card, a notice or a message carries one of these; a word with no
4
+ * public meaning (a verdict not checked yet, say) carries none.
5
+ */
6
+
7
+ /** Every value `data-corn-state` can take */
8
+ export const CORN_STATES = Object.freeze(['open', 'merged', 'closed', 'draft', 'queued', 'running', 'waiting', 'done', 'failed', 'stopped', 'success', 'failure']);
9
+
10
+ /** The internal words that map onto a public one: a run's status, a check's or deploy's conclusion, a mockup's review, a verdict, a notice */
11
+ const WORDS = Object.freeze({
12
+ // A run's status: it is waiting to start, it is running, it waits on someone, or it ended
13
+ requested: 'queued', claimed: 'queued', working: 'running', quiet: 'waiting', 'stop-requested': 'stopped',
14
+ // A check's or deploy's conclusion
15
+ neutral: 'done', skipped: 'done', cancelled: 'stopped',
16
+ // A mockup's review state
17
+ approved: 'success', unreviewed: 'waiting', changed: 'waiting', missing: 'failure',
18
+ // The scenario player's verdict
19
+ allowed: 'success', refused: 'failure', mismatch: 'failure', pending: 'running',
20
+ // A notice that went well, a message about a problem
21
+ ok: 'success', bad: 'failure',
22
+ });
23
+
24
+ /** The public state for an internal word, or '' when it has none */
25
+ export function cornState(word) {
26
+ const w = String(word || '');
27
+ return CORN_STATES.includes(w) ? w : WORDS[w] || '';
28
+ }
29
+
30
+ /** The `data-corn-state` attribute for markup (with its leading space), or nothing when the word has no public state */
31
+ export function cornStateAttr(word) {
32
+ const s = cornState(word);
33
+ return s ? ` data-corn-state="${s}"` : '';
34
+ }
package/explorer/flows.js CHANGED
@@ -149,7 +149,7 @@ export function renderFlowLegend() {
149
149
  export function flowSummary(node) {
150
150
  const flows = state.edges.filter((e) => e.kind === 'flow' && (e.from === node.id || e.to === node.id));
151
151
  if (flows.length === 0) return '';
152
- return `<div class="hx-sec"><strong class="hx-strong">Data flows:</strong>
152
+ return `<div class="hx-sec" data-corn="section"><strong class="hx-strong">Data flows:</strong>
153
153
  ${flows.map((e) => {
154
154
  const out = e.from === node.id;
155
155
  const s = FLOW_STYLES[e.flow] || FLOW_STYLES.sync;
@@ -81,6 +81,7 @@ import {
81
81
  DRAFTS_URL, notesUrl, sinceChoices, notesSummary, validTag, confirmWords, postedWords, draftRequest,
82
82
  threadsUrl, threadUrl, issueUrl, IDEAS_URL, threadKindWords, threadMeta, litForThread, mentionsIndex, ideaRequest, ideaWords,
83
83
  } from './forge-panel-model.js';
84
+ import { cornStateAttr } from './corn-state.js';
84
85
 
85
86
  const $ = (id) => document.getElementById(id);
86
87
  const FORGE_NAMES = { github: 'GitHub', forgejo: 'Forgejo' };
@@ -644,6 +645,7 @@ function paintIdea() {
644
645
  const message = $('idea-message');
645
646
  message.hidden = !ui.idea.message;
646
647
  message.classList.toggle('hx-forge-msg--bad', ui.idea.bad);
648
+ if (ui.idea.bad) message.dataset.cornState = 'failure'; else delete message.dataset.cornState;
647
649
  message.textContent = ui.idea.message;
648
650
  if (ui.idea.message && ui.idea.link && safeUrl(ui.idea.link)) {
649
651
  const link = document.createElement('a');
@@ -795,6 +797,7 @@ function paintNotes() {
795
797
  const message = $('notes-message');
796
798
  message.hidden = !n.message;
797
799
  message.classList.toggle('hx-forge-msg--bad', n.bad);
800
+ if (n.bad) message.dataset.cornState = 'failure'; else delete message.dataset.cornState;
798
801
  message.textContent = n.message;
799
802
  if (n.message && n.link && safeUrl(n.link)) {
800
803
  const link = document.createElement('a');
@@ -844,9 +847,9 @@ function lightsWords(deploy) {
844
847
  function deployHtml(d) {
845
848
  const link = safeUrl(d.url);
846
849
  const out = link ? `<a class="hx-forge-out" href="${escHtml(link)}" target="_blank" rel="noreferrer" aria-label="Open deploy ${escHtml(d.name)} on ${escHtml(forgeName())} (new tab)">↗</a>` : '';
847
- return `<li class="hx-forge-item"><button type="button" class="hx-forge-row" data-forge-deploy="${escHtml(d.id)}" aria-pressed="${ui.deploy === d.id}">
850
+ return `<li class="hx-forge-item"><button type="button" class="hx-forge-row" data-forge-deploy="${escHtml(d.id)}" aria-pressed="${ui.deploy === d.id}" data-corn="row">
848
851
  <span class="hx-forge-title">${escHtml(d.name)}${d.title && d.title !== d.name ? `<span class="hx-faint"> · ${escHtml(d.title)}</span>` : ''}</span>
849
- <span class="hx-forge-meta"><span class="hx-forge-state hx-forge-state--${escHtml(d.state)}">${escHtml(deployWords(d))}</span> ${escHtml(deployMeta(d, now()))}</span>
852
+ <span class="hx-forge-meta"><span class="hx-forge-state hx-forge-state--${escHtml(d.state)}" data-corn="state-pill"${cornStateAttr(d.state)}>${escHtml(deployWords(d))}</span> ${escHtml(deployMeta(d, now()))}</span>
850
853
  <span class="hx-forge-labels"><span class="hx-forge-label">${escHtml(lightsWords(d))}</span></span></button>${out}</li>`;
851
854
  }
852
855
 
@@ -858,10 +861,10 @@ function threadHtml(t) {
858
861
  // The run that is about this thread, as a word (issue #104): the Agents tab's list, read for every tab, says it; the row only names its state
859
862
  const runs = ui.runs && ui.runs.data ? ui.runs.data.runs : null;
860
863
  const run = runOnThread(runs, t.number);
861
- const runWord = run ? `<span class="hx-forge-state hx-forge-state--${runTone(run)}" data-thread-run="${escHtml(run.runId)}">${escHtml(threadRunWords(runs, t.number))}</span> ` : '';
862
- return `<li class="hx-forge-item"><button type="button" class="hx-forge-row" data-forge-thread="${t.number}" aria-pressed="${ui.thread === t.number}">
864
+ const runWord = run ? `<span class="hx-forge-state hx-forge-state--${runTone(run)}" data-thread-run="${escHtml(run.runId)}" data-corn="state-pill"${cornStateAttr(run.status)}>${escHtml(threadRunWords(runs, t.number))}</span> ` : '';
865
+ return `<li class="hx-forge-item"><button type="button" class="hx-forge-row" data-forge-thread="${t.number}" aria-pressed="${ui.thread === t.number}" data-corn="row">
863
866
  <span class="hx-forge-title">${escHtml(t.title)}</span>
864
- <span class="hx-forge-meta"><span class="hx-forge-state hx-forge-state--${escHtml(t.state)}">${escHtml(t.state === 'open' ? 'Open' : 'Closed')}</span> ${runWord}<span class="hx-forge-label">${escHtml(threadKindWords(t))}</span> ${escHtml(threadMeta(t, now()))}</span>${note ? `<span class="hx-forge-meta">${escHtml(note)}</span>` : ''}</button>${out}</li>`;
867
+ <span class="hx-forge-meta"><span class="hx-forge-state hx-forge-state--${escHtml(t.state)}" data-corn="state-pill"${cornStateAttr(t.state)}>${escHtml(t.state === 'open' ? 'Open' : 'Closed')}</span> ${runWord}<span class="hx-forge-label">${escHtml(threadKindWords(t))}</span> ${escHtml(threadMeta(t, now()))}</span>${note ? `<span class="hx-forge-meta">${escHtml(note)}</span>` : ''}</button>${out}</li>`;
865
868
  }
866
869
 
867
870
  function itemHtml(item, before = '', after = '') {
@@ -870,10 +873,10 @@ function itemHtml(item, before = '', after = '') {
870
873
  const link = safeUrl(item.url);
871
874
  const labels = item.labels.length ? `<span class="hx-forge-labels">${item.labels.map((l) => `<span class="hx-forge-label">${escHtml(l)}</span>`).join('')}</span>` : '';
872
875
  const inner = `<span class="hx-forge-title">${escHtml(item.title)}</span>
873
- <span class="hx-forge-meta"><span class="hx-forge-state hx-forge-state--${escHtml(item.draft ? 'draft' : item.state)}">${escHtml(stateWords(item))}</span> ${escHtml(metaWords(item, now()))}</span>${before}${after}${labels}`;
876
+ <span class="hx-forge-meta"><span class="hx-forge-state hx-forge-state--${escHtml(item.draft ? 'draft' : item.state)}" data-corn="state-pill"${cornStateAttr(item.draft ? 'draft' : item.state)}>${escHtml(stateWords(item))}</span> ${escHtml(metaWords(item, now()))}</span>${before}${after}${labels}`;
874
877
  const out = link ? `<a class="hx-forge-out" href="${escHtml(link)}" target="_blank" rel="noreferrer" aria-label="Open ${escHtml(item.head ? 'pull request' : 'issue')} ${item.number} on ${escHtml(forgeName())} (new tab)">↗</a>` : '';
875
878
  if (ui.kind !== 'issues') {
876
- return `<li class="hx-forge-item"><button type="button" class="hx-forge-row" data-forge-pr="${item.number}" aria-pressed="${ui.selected === item.number}">${inner}</button>${out}</li>`;
879
+ return `<li class="hx-forge-item"><button type="button" class="hx-forge-row" data-forge-pr="${item.number}" aria-pressed="${ui.selected === item.number}" data-corn="row">${inner}</button>${out}</li>`;
877
880
  }
878
881
  // An issue has no more to show here: its row is the link out; an open one also starts its spec (step 1 of the pipeline)
879
882
  const spec = specBlock(item) === null
@@ -883,19 +886,19 @@ function itemHtml(item, before = '', after = '') {
883
886
  ? `<button type="button" class="hx-btn hx-forge-act hx-forge-startspec" data-forge-agent="issue:${item.number}" aria-label="Start an agent on issue ${item.number}">Start an agent …</button>`
884
887
  : '';
885
888
  return link
886
- ? `<li class="hx-forge-item"><a class="hx-forge-row" href="${escHtml(link)}" target="_blank" rel="noreferrer">${inner}<span class="hx-sr-only"> (opens ${escHtml(forgeName())} in a new tab)</span></a>${spec}${agent}</li>`
887
- : `<li class="hx-forge-item"><div class="hx-forge-row">${inner}</div>${spec}${agent}</li>`;
889
+ ? `<li class="hx-forge-item"><a class="hx-forge-row" href="${escHtml(link)}" target="_blank" rel="noreferrer" data-corn="row">${inner}<span class="hx-sr-only"> (opens ${escHtml(forgeName())} in a new tab)</span></a>${spec}${agent}</li>`
890
+ : `<li class="hx-forge-item"><div class="hx-forge-row" data-corn="row">${inner}</div>${spec}${agent}</li>`;
888
891
  }
889
892
 
890
893
  /** One piece of work in a group: a pull request (a row that selects it, as in the Pull requests tab) or a branch with none */
891
894
  function workHtml(e) {
892
- const mark = e.mark ? `<span class="hx-forge-agentline"><span class="hx-forge-agent" title="Agent-made: ${escHtml(markWords(e.mark))}">Agent</span><span class="hx-forge-why hx-faint">${escHtml(markWords(e.mark))}</span></span>` : '';
895
+ const mark = e.mark ? `<span class="hx-forge-agentline"><span class="hx-forge-agent" title="Agent-made: ${escHtml(markWords(e.mark))}" data-corn="badge">Agent</span><span class="hx-forge-why hx-faint">${escHtml(markWords(e.mark))}</span></span>` : '';
893
896
  if (e.type === 'pull') {
894
897
  const also = e.issues.slice(1);
895
898
  const note = [e.proposal ? `Spec PR for ${e.proposal}` : '', also.length ? `Also closes ${also.map((n) => `#${n}`).join(', ')}` : ''].filter(Boolean);
896
899
  return itemHtml(e.pull, mark, note.length ? `<span class="hx-forge-meta">${escHtml(note.join(' · '))}</span>` : '');
897
900
  }
898
- return `<li class="hx-forge-item"><div class="hx-forge-row hx-forge-branch"><span class="hx-forge-title"><span class="hx-sr-only">Branch </span><code class="hx-code">${escHtml(e.branch.name)}</code></span><span class="hx-forge-meta"><span class="hx-forge-state hx-forge-state--draft">Branch</span> no pull request yet</span>${mark}</div></li>`;
901
+ return `<li class="hx-forge-item"><div class="hx-forge-row hx-forge-branch" data-corn="row"><span class="hx-forge-title"><span class="hx-sr-only">Branch </span><code class="hx-code">${escHtml(e.branch.name)}</code></span><span class="hx-forge-meta"><span class="hx-forge-state hx-forge-state--draft" data-corn="state-pill" data-corn-state="draft">Branch</span> no pull request yet</span>${mark}</div></li>`;
899
902
  }
900
903
 
901
904
  /** The Agents tab's groups, each a heading and its work */
@@ -914,19 +917,19 @@ function deployDetailHtml() {
914
917
  const d = ui.deployItem;
915
918
  const lit = ui.litDeploy;
916
919
  const url = safeUrl(d.url);
917
- const head = `<div class="hx-forge-detail-head"><h3 class="hx-forge-detail-title">${escHtml(d.name)}</h3><button type="button" class="hx-btn hx-btn--quiet" data-action="clear-forge-deploy">Clear</button></div>
918
- <p class="hx-forge-meta"><span class="hx-forge-state hx-forge-state--${escHtml(d.state)}">${escHtml(deployWords(d))}</span> ${escHtml(deployMeta(d, now()))}${url ? ` · <a class="hx-link" href="${escHtml(url)}" target="_blank" rel="noreferrer">Open on ${escHtml(forgeName())} ↗</a>` : ''}</p>`;
920
+ const head = `<div class="hx-forge-detail-head"><h3 class="hx-forge-detail-title">${escHtml(d.name)}</h3><button type="button" class="hx-btn hx-btn--quiet" data-action="clear-forge-deploy" data-corn-kind="quiet">Clear</button></div>
921
+ <p class="hx-forge-meta"><span class="hx-forge-state hx-forge-state--${escHtml(d.state)}" data-corn="state-pill"${cornStateAttr(d.state)}>${escHtml(deployWords(d))}</span> ${escHtml(deployMeta(d, now()))}${url ? ` · <a class="hx-link" href="${escHtml(url)}" target="_blank" rel="noreferrer">Open on ${escHtml(forgeName())} ↗</a>` : ''}</p>`;
919
922
  const stale = ui.lists.deploys && ui.lists.deploys.stale;
920
923
  let body;
921
924
  if (!d.restarts.length) {
922
- body = '<p class="hx-forge-notice">No node is mapped to this deploy, so nothing is lit. Say what it restarts under <code class="hx-code">deploys.restarts</code> in cornfield.config.js (docs/deploys.md).</p>';
925
+ body = '<p class="hx-forge-notice" data-corn="notice">No node is mapped to this deploy, so nothing is lit. Say what it restarts under <code class="hx-code">deploys.restarts</code> in cornfield.config.js (docs/deploys.md).</p>';
923
926
  } else {
924
927
  const rows = lit.nodes.map((n) => `<li class="hx-forge-file"><button type="button" class="hx-forge-node" data-forge-node="${escHtml(n.id)}" aria-label="Show ${escHtml(n.label)} on the map${isNodeVisible(n) ? '' : ' (its layer is off)'}">${escHtml(n.label)}${isNodeVisible(n) ? '' : ' · layer off'}</button> <span class="hx-faint">${escHtml(n.type)}</span></li>`).join('');
925
- const missing = lit.missing.length ? `<p class="hx-forge-notice">${escHtml(lit.missing.join(', '))} ${lit.missing.length === 1 ? 'is' : 'are'} named in the config but not on the map.</p>` : '';
928
+ const missing = lit.missing.length ? `<p class="hx-forge-notice" data-corn="notice">${escHtml(lit.missing.join(', '))} ${lit.missing.length === 1 ? 'is' : 'are'} named in the config but not on the map.</p>` : '';
926
929
  const key = lit.nodes.length ? `<p class="hx-forge-key hx-faint"><span class="hx-mark-dot hx-mark-dot--${d.state === 'failure' ? 'removed' : 'changed'}" aria-hidden="true"></span>${d.state === 'failure' ? 'restarted by a deploy that failed' : 'restarted by this deploy'}</p>` : '';
927
930
  body = `<h4 class="hx-forge-sub">${escHtml(`Restarted: ${plural(lit.nodes.length, 'node')} on the map`)}</h4>${key}${rows ? `<ul class="hx-forge-files">${rows}</ul>` : ''}${missing}`;
928
931
  }
929
- return `${head}${stale ? `<p class="hx-forge-notice">${escHtml(`This is an older answer. ${stale}`)}</p>` : ''}${body}`;
932
+ return `${head}${stale ? `<p class="hx-forge-notice" data-corn="notice">${escHtml(`This is an older answer. ${stale}`)}</p>` : ''}${body}`;
930
933
  }
931
934
 
932
935
  /** A node button, as in a pull request's files: it selects the node on the map */
@@ -934,8 +937,8 @@ const nodeButton = (n) => `<button type="button" class="hx-forge-node" data-forg
934
937
 
935
938
  /** The selected thread: read-only, its messages as written, a way to reply on the forge, and the nodes its text lights */
936
939
  function threadDetailHtml() {
937
- const head = (title) => `<div class="hx-forge-detail-head"><h3 class="hx-forge-detail-title">${title}</h3><button type="button" class="hx-btn hx-btn--quiet" data-action="clear-forge-thread">Clear</button></div>`;
938
- if (ui.threadError) return `${head(`Thread ${ui.thread}`)}<p class="hx-forge-notice">${escHtml(ui.threadError)}</p>`;
940
+ const head = (title) => `<div class="hx-forge-detail-head"><h3 class="hx-forge-detail-title">${title}</h3><button type="button" class="hx-btn hx-btn--quiet" data-action="clear-forge-thread" data-corn-kind="quiet">Clear</button></div>`;
941
+ if (ui.threadError) return `${head(`Thread ${ui.thread}`)}<p class="hx-forge-notice" data-corn="notice">${escHtml(ui.threadError)}</p>`;
939
942
  if (!ui.threadDetail) return `${head(`Thread ${ui.thread}`)}<p class="hx-faint">Loading its messages …</p>`;
940
943
  const { thread: t, stale } = ui.threadDetail;
941
944
  const lit = ui.litThread;
@@ -956,14 +959,14 @@ function threadDetailHtml() {
956
959
  }).join('');
957
960
  const key = lit.nodes.length ? `<p class="hx-forge-key hx-faint"><span class="hx-mark-dot hx-mark-dot--changed" aria-hidden="true"></span>a node this thread mentions</p>` : '';
958
961
  return `${head(`#${t.number} ${escHtml(t.title)}`)}
959
- <p class="hx-forge-meta"><span class="hx-forge-state hx-forge-state--${escHtml(t.state)}">${t.state === 'open' ? 'Open' : 'Closed'}</span> ${escHtml(threadKindWords(t))} · ${escHtml(threadMeta({ ...t, comments: t.messages.length - (t.kind === 'idea' ? 1 : 0) + (t.hidden || 0) }, now()))}</p>
962
+ <p class="hx-forge-meta"><span class="hx-forge-state hx-forge-state--${escHtml(t.state)}" data-corn="state-pill"${cornStateAttr(t.state)}>${t.state === 'open' ? 'Open' : 'Closed'}</span> ${escHtml(threadKindWords(t))} · ${escHtml(threadMeta({ ...t, comments: t.messages.length - (t.kind === 'idea' ? 1 : 0) + (t.hidden || 0) }, now()))}</p>
960
963
  <p class="hx-forge-why hx-faint">Read-only here: a thread is a conversation on ${escHtml(forgeName())}, so you reply there. ${reply}</p>
961
964
  ${named.length ? `<p class="hx-forge-meta">${named.join(' · ')}</p>` : ''}
962
- ${stale ? `<p class="hx-forge-notice">${escHtml(`This is an older answer. ${stale}`)}</p>` : ''}
965
+ ${stale ? `<p class="hx-forge-notice" data-corn="notice">${escHtml(`This is an older answer. ${stale}`)}</p>` : ''}
963
966
  <h4 class="hx-forge-sub">${escHtml(`Mentions: ${plural(lit.nodes.length, 'node')} on the map`)}</h4>
964
967
  ${key}
965
968
  ${lit.nodes.length ? `<span class="hx-forge-nodes hx-thread-nodes">${lit.nodes.map(nodeButton).join('')}</span>` : '<p class="hx-faint">No message mentions a node. Write [[node-id]] or [[repo/path]] in a message to point at the map.</p>'}
966
- ${lit.unresolved.length ? `<p class="hx-forge-notice">${escHtml(lit.unresolved.join(', '))} ${lit.unresolved.length === 1 ? 'is' : 'are'} mentioned but not on the map, so ${lit.unresolved.length === 1 ? 'it stays' : 'they stay'} text.</p>` : ''}
969
+ ${lit.unresolved.length ? `<p class="hx-forge-notice" data-corn="notice">${escHtml(lit.unresolved.join(', '))} ${lit.unresolved.length === 1 ? 'is' : 'are'} mentioned but not on the map, so ${lit.unresolved.length === 1 ? 'it stays' : 'they stay'} text.</p>` : ''}
967
970
  <h4 class="hx-forge-sub">${escHtml(plural(t.messages.length, 'message'))}</h4>
968
971
  ${t.hidden ? `<p class="hx-forge-why hx-faint">${escHtml(plural(t.hidden, 'earlier message'))} not shown; they are on ${escHtml(forgeName())}.</p>` : ''}
969
972
  <ol class="hx-thread-msgs" aria-label="Messages">${msgs}</ol>`;
@@ -973,8 +976,8 @@ function detailHtml() {
973
976
  if (ui.thread !== null) return threadDetailHtml();
974
977
  if (ui.deployItem) return deployDetailHtml();
975
978
  if (ui.selected === null) return '';
976
- const head = (title, link) => `<div class="hx-forge-detail-head"><h3 class="hx-forge-detail-title">${title}</h3><button type="button" class="hx-btn hx-btn--quiet" data-action="clear-forge-pr">Clear</button></div>${link || ''}`;
977
- if (ui.detailError) return `${head(`Pull request ${ui.selected}`)}<p class="hx-forge-notice">${escHtml(ui.detailError)}</p>`;
979
+ const head = (title, link) => `<div class="hx-forge-detail-head"><h3 class="hx-forge-detail-title">${title}</h3><button type="button" class="hx-btn hx-btn--quiet" data-action="clear-forge-pr" data-corn-kind="quiet">Clear</button></div>${link || ''}`;
980
+ if (ui.detailError) return `${head(`Pull request ${ui.selected}`)}<p class="hx-forge-notice" data-corn="notice">${escHtml(ui.detailError)}</p>`;
978
981
  if (!ui.detail) return `${head(`Pull request ${ui.selected}`)}<p class="hx-faint">Loading its files and checks …</p>`;
979
982
  const { pull, checks, stale } = ui.detail;
980
983
  const lit = ui.lit;
@@ -995,7 +998,7 @@ function detailHtml() {
995
998
  ? `<button 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>`
996
999
  : '';
997
1000
  const whyNot = why ? `<span class="hx-faint hx-forge-lights">${escHtml(why)}</span>` : '';
998
- return `<li class="hx-forge-check"><span class="hx-forge-state hx-forge-state--${escHtml(c.state)}">${escHtml(checkWords(c))}</span> ${name}${again}${lights}${whyNot}</li>`;
1001
+ return `<li class="hx-forge-check"><span class="hx-forge-state hx-forge-state--${escHtml(c.state)}" data-corn="state-pill"${cornStateAttr(c.state)}>${escHtml(checkWords(c))}</span> ${name}${again}${lights}${whyNot}</li>`;
999
1002
  }).join('');
1000
1003
 
1001
1004
  const fileRows = lit.files.map((f) => {
@@ -1009,25 +1012,25 @@ function detailHtml() {
1009
1012
  const block = mergeBlock(ui.detail);
1010
1013
  const act = block
1011
1014
  ? `<p class="hx-forge-why hx-faint">${pull.state === 'merged' ? '' : 'Cannot be landed from here. '}${escHtml(block)}</p>`
1012
- : `<button type="button" class="hx-btn hx-btn--approve hx-forge-act" data-forge-merge="${pull.number}"${ui.busy ? ' disabled' : ''}>Land it …</button><p class="hx-forge-why hx-faint">Opens a confirm step that shows what will land. Never forced, never deployed.</p>`;
1015
+ : `<button type="button" class="hx-btn hx-btn--approve hx-forge-act" data-forge-merge="${pull.number}"${ui.busy ? ' disabled' : ''} data-corn-kind="approve">Land it …</button><p class="hx-forge-why hx-faint">Opens a confirm step that shows what will land. Never forced, never deployed.</p>`;
1013
1016
  // A spec approved with `proposals.approveLands` waits for its checks: said here, with a way to stop it
1014
1017
  const waiting = ui.landing && pull.state === 'open'
1015
- ? `<div class="hx-forge-step"><p class="hx-forge-notice hx-forge-notice--ok" role="status">${escHtml(landingWords(ui.landing, now()))}</p><button type="button" class="hx-btn hx-forge-act" data-forge-landing-cancel="${pull.number}"${ui.busy ? ' disabled' : ''}>Cancel</button></div>`
1018
+ ? `<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, now()))}</p><button type="button" class="hx-btn hx-forge-act" data-forge-landing-cancel="${pull.number}"${ui.busy ? ' disabled' : ''}>Cancel</button></div>`
1016
1019
  : '';
1017
- const note = ui.note ? `<p class="hx-forge-notice${ui.note.ok ? ' hx-forge-notice--ok' : ''}">${escHtml(ui.note.text)}</p>` : '';
1020
+ 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>` : '';
1018
1021
  // Step 2 of the pipeline: a spec pull request with an approved proposal opens its build issue
1019
1022
  const offers = buildOffers(ui.detail);
1020
1023
  const build = offers.length
1021
1024
  ? `<h4 class="hx-forge-subact">Build issue</h4>${offers.map((o) => (o.offer
1022
- ? `<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' : ''}>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>`
1025
+ ? `<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>`
1023
1026
  : `<p class="hx-forge-why hx-faint"><code class="hx-code">${escHtml(o.slug)}</code>: ${escHtml(o.why)}</p>`)).join('')}`
1024
1027
  : '';
1025
1028
 
1026
1029
  const key = lit.changed.size || lit.failing.size
1027
1030
  ? `<p class="hx-forge-key hx-faint"><span class="hx-mark-dot hx-mark-dot--changed" aria-hidden="true"></span>a file this pull request changes <span class="hx-mark-dot hx-mark-dot--removed" aria-hidden="true"></span>a test a failing check names</p>`
1028
1031
  : '';
1029
- return `${head(`#${pull.number} ${escHtml(pull.title)}`, `<p class="hx-forge-meta"><span class="hx-forge-state hx-forge-state--${escHtml(pull.draft ? 'draft' : pull.state)}">${escHtml(stateWords(pull))}</span> ${escHtml(pull.head.ref)} → ${escHtml(pull.base.ref)}${url ? ` · <a class="hx-link" href="${escHtml(url)}" target="_blank" rel="noreferrer">Open on ${escHtml(forgeName())} ↗</a>` : ''}</p>`)}
1030
- ${stale ? `<p class="hx-forge-notice">${escHtml(`This is an older answer. ${stale}`)}</p>` : ''}
1032
+ return `${head(`#${pull.number} ${escHtml(pull.title)}`, `<p class="hx-forge-meta"><span class="hx-forge-state hx-forge-state--${escHtml(pull.draft ? 'draft' : pull.state)}" data-corn="state-pill"${cornStateAttr(pull.draft ? 'draft' : pull.state)}>${escHtml(stateWords(pull))}</span> ${escHtml(pull.head.ref)} → ${escHtml(pull.base.ref)}${url ? ` · <a class="hx-link" href="${escHtml(url)}" target="_blank" rel="noreferrer">Open on ${escHtml(forgeName())} ↗</a>` : ''}</p>`)}
1033
+ ${stale ? `<p class="hx-forge-notice" data-corn="notice">${escHtml(`This is an older answer. ${stale}`)}</p>` : ''}
1031
1034
  <h4 class="hx-forge-sub">Checks: ${escHtml(checksWords(checks))}</h4>
1032
1035
  ${checks.length ? `<ul class="hx-forge-checks">${checkRows}</ul>` : ''}
1033
1036
  ${build}
@@ -1103,6 +1106,7 @@ function draw(panel) {
1103
1106
  act.hidden = !ui.actNote;
1104
1107
  const link = ui.actNote && safeUrl(ui.actNote.url);
1105
1108
  act.className = `hx-forge-notice${ui.actNote && ui.actNote.ok ? ' hx-forge-notice--ok' : ''}`;
1109
+ if (ui.actNote && ui.actNote.ok) act.dataset.cornState = 'success'; else delete act.dataset.cornState;
1106
1110
  act.innerHTML = ui.actNote ? `${escHtml(ui.actNote.text)}${link ? ` <a class="hx-link" href="${escHtml(link)}" target="_blank" rel="noreferrer">Open on ${escHtml(forgeName())} ↗</a>` : ''}` : '';
1107
1111
  }
1108
1112
 
@@ -1135,6 +1139,7 @@ function paintRuns() {
1135
1139
  const words = (ui.runs && ui.runs.error) || (ui.runNote ? ui.runNote.text : '');
1136
1140
  note.hidden = !words;
1137
1141
  note.className = `hx-forge-notice${!(ui.runs && ui.runs.error) && ui.runNote && ui.runNote.ok ? ' hx-forge-notice--ok' : ''}`;
1142
+ if (!(ui.runs && ui.runs.error) && ui.runNote && ui.runNote.ok) note.dataset.cornState = 'success'; else delete note.dataset.cornState;
1138
1143
  note.textContent = words;
1139
1144
  paintRunner('forge-runs-runner', data);
1140
1145
  const trig = $('forge-runs-trigger');
@@ -1299,7 +1304,7 @@ function showConfirm(what, goLabel, state) {
1299
1304
  const asCode = ['Commit', 'At commit', 'Branch', 'File', 'Proposal'];
1300
1305
  $('forge-confirm-title').textContent = what.title;
1301
1306
  $('forge-confirm-body').innerHTML = `<dl class="hx-confirm-facts">${what.lines.map(([k, v]) => `<dt>${escHtml(k)}</dt><dd>${asCode.includes(k) ? `<code class="hx-code">${escHtml(v)}</code>` : escHtml(v)}</dd>`).join('')}</dl>
1302
- ${(what.checks || []).length ? `<ul class="hx-confirm-checks">${what.checks.map((c) => `<li><span class="hx-forge-state hx-forge-state--success">${escHtml(c.words)}</span> ${escHtml(c.name)}</li>`).join('')}</ul>` : ''}
1307
+ ${(what.checks || []).length ? `<ul class="hx-confirm-checks">${what.checks.map((c) => `<li><span class="hx-forge-state hx-forge-state--success" data-corn="state-pill" data-corn-state="success">${escHtml(c.words)}</span> ${escHtml(c.name)}</li>`).join('')}</ul>` : ''}
1303
1308
  ${(what.previews || []).map((pv) => `<p class="hx-confirm-label">${escHtml(pv.label)}</p><pre class="hx-confirm-pre" tabindex="0" role="region" aria-label="${escHtml(pv.label)}">${escHtml(pv.text)}</pre>`).join('')}
1304
1309
  <p class="hx-confirm-note">${escHtml(what.note)}</p>`;
1305
1310
  const go = el.querySelector('[data-action="forge-confirm-go"]');