@popcorn245/cornfield 0.34.3 → 0.36.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.
@@ -7,6 +7,7 @@
7
7
  */
8
8
 
9
9
  import { relativeTime } from './review-model.js';
10
+ import { RUN_STATES } from './corn-state.js';
10
11
 
11
12
  export const RUNS_URL = '/api/agent-runs';
12
13
  export const runsUrl = (follow) => (follow ? `${RUNS_URL}?follow=1` : RUNS_URL);
@@ -41,9 +42,32 @@ export function statusWords(run) {
41
42
  return words[run.status] || run.status;
42
43
  }
43
44
 
44
- /** The colour class (`hx-forge-state--<tone>`) of a run's state: done and merged are green, failed red, a run that is waiting on someone or has gone quiet amber, the rest in motion */
45
- export const RUN_TONE = Object.freeze({ done: 'success', merged: 'success', failed: 'failure', quiet: 'queued', 'stop-requested': 'queued', waiting: 'queued' });
46
- export const runTone = (run) => RUN_TONE[run.status] || 'running';
45
+ /**
46
+ * The tone of a run's state (the class `hx-forge-state--<tone>`, and the public `data-corn-state` through corn-state.js): each of the seven
47
+ * states of a run is its own, so none is told from another by colour alone. A run that went quiet waits on someone; one asked to stop is no
48
+ * longer under way; merged is done.
49
+ */
50
+ export const RUN_TONE = Object.freeze({ merged: 'done', closed: 'stopped', quiet: 'waiting', 'stop-requested': 'stopped' });
51
+ export const runTone = (run) => RUN_TONE[run.status] || (RUN_STATES.includes(run.status) ? run.status : 'working');
52
+
53
+ /** What a run is called where a person has to pick it out: what the card shows ("code on issue #5, profile claude, asked by maintainer-one"), never its id; `nowMs` adds how long ago it was asked, to tell two alike apart */
54
+ export function runName(run, nowMs) {
55
+ const when = nowMs != null && run.requestedAt ? relativeTime(run.requestedAt, nowMs) : '';
56
+ return [`${run.kind} on ${aboutWords(run.refs)}`, run.profile && `profile ${run.profile}`, run.requestedBy && `asked by ${run.requestedBy}`, when].filter(Boolean).join(', ');
57
+ }
58
+
59
+ /**
60
+ * Cost to two decimals with thousands separators ("1.45", "12,500.00"); '' when the runner reported none. The contract's `cost` is in the
61
+ * runner's own currency and names none (docs/agent-contract.md), so no currency sign is shown: the word "cost" is the unit. The API keeps the raw number.
62
+ */
63
+ export function formatCost(n) {
64
+ return typeof n === 'number' && Number.isFinite(n) ? n.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 }) : '';
65
+ }
66
+
67
+ /** Tokens with thousands separators and the word ("47,000 tokens"); '' when none were reported */
68
+ export function formatTokens(n) {
69
+ return typeof n === 'number' && Number.isFinite(n) ? `${n.toLocaleString('en-US')} ${n === 1 ? 'token' : 'tokens'}` : '';
70
+ }
47
71
 
48
72
  /**
49
73
  * The run to show on the row of a thread (issue #104): the run whose conversation the thread is (`thread.number`, which the server fills in;
@@ -68,10 +92,10 @@ export function runOnPull(runs, number) {
68
92
  }
69
93
 
70
94
  /** A pull request's run in one line: who is running it, its state, how long ago it was asked for, and the cost the runner reported ("bucket-bot · Working · asked 12 min ago · cost 0.84") */
71
- export function pullRunWords(run, nowMs) {
95
+ export function pullRunWords(run, nowMs, { state = true } = {}) {
72
96
  const who = (run.report && run.report.by) || (run.pull && run.pull.by) || run.requestedBy;
73
97
  const when = relativeTime(run.requestedAt, nowMs);
74
- return [who, statusWords(run), when && `asked ${when}`, run.report && run.report.cost != null && `cost ${run.report.cost}`].filter(Boolean).join(' · ');
98
+ return [who, state && statusWords(run), when && `asked ${when}`, run.report && run.report.cost != null && `cost ${formatCost(run.report.cost)}`].filter(Boolean).join(' · ');
75
99
  }
76
100
 
77
101
  /** What a thread's row says of its run, in a few words: "Run: Working" (more than one run on it: "Run: Working (+1)") */
@@ -100,11 +124,11 @@ export function runMeta(run, nowMs) {
100
124
  const parts = [`asked ${relativeTime(run.requestedAt, nowMs)} by ${run.requestedBy}${run.byHand ? ' (by hand)' : ''}`];
101
125
  if (run.profile) parts.push(`profile ${run.profile}`);
102
126
  const l = run.limits || {};
103
- const limits = [l.minutes != null && `${l.minutes} min`, l.turns != null && `${l.turns} turns`, l.cost != null && `cost ${l.cost}`].filter(Boolean);
127
+ const limits = [l.minutes != null && `${l.minutes} min`, l.turns != null && `${l.turns} turns`, l.cost != null && `cost ${formatCost(l.cost)}`].filter(Boolean);
104
128
  if (limits.length) parts.push(`limits ${limits.join(', ')}`);
105
129
  const r = run.report;
106
130
  if (r) {
107
- const said = [r.tokens != null && `${r.tokens} tokens`, r.cost != null && `cost ${r.cost}`].filter(Boolean);
131
+ const said = [r.tokens != null && formatTokens(r.tokens), r.cost != null && `cost ${formatCost(r.cost)}`].filter(Boolean);
108
132
  if (said.length) parts.push(`reported ${said.join(', ')}`);
109
133
  }
110
134
  if (run.checks && run.checks !== 'none') parts.push(`checks ${run.checks === 'success' ? 'passing' : run.checks === 'failure' ? 'failing' : 'running'}`);
@@ -159,7 +183,7 @@ export function answerBody(action, text) {
159
183
  export function answerWordsFor(status, body, runId, action) {
160
184
  if (status === null) return 'cornfield did not answer; nothing was sent.';
161
185
  if (status === 401) return 'Your sign-in has ended. Sign in again to answer a run.';
162
- if (body && body.ok) return action === 'stop' ? `Asked ${runId} to stop. The runner decides what that means.` : `Answered ${runId}: ${action}. The runner picks it up and goes on.`;
186
+ if (body && body.ok) return action === 'stop' ? `Asked ${runId} to stop. The runner decides what that means.` : action === 'reply' ? `Sent your reply to ${runId}. The runner picks it up and goes on.` : `Told ${runId} to continue. The runner picks it up and goes on.`;
163
187
  return (body && body.error) || `The answer was refused (${status}).`;
164
188
  }
165
189
 
@@ -169,9 +193,9 @@ export function runsStatus(data) {
169
193
  return `${data.open} open of ${data.maxOpen} allowed, ${n} ${n === 1 ? 'run' : 'runs'}`;
170
194
  }
171
195
 
172
- /** "1200 tokens, cost 0.42", or '' when nothing was reported: the numbers as sent, never estimated; the cost to 2 decimals (the API keeps it raw) */
196
+ /** "1,200 tokens, cost 0.42", or '' when nothing was reported: the numbers as sent, never estimated; the cost to 2 decimals (the API keeps it raw) */
173
197
  function saidWords(t) {
174
- return [t.tokens != null && `${t.tokens} tokens`, typeof t.cost === 'number' && `cost ${t.cost.toFixed(2)}`].filter(Boolean).join(', ');
198
+ return [t.tokens != null && formatTokens(t.tokens), typeof t.cost === 'number' && `cost ${formatCost(t.cost)}`].filter(Boolean).join(', ');
175
199
  }
176
200
 
177
201
  /**
@@ -349,14 +373,14 @@ export function limitRows(run) {
349
373
  const l = run.limits || {};
350
374
  const r = run.report || {};
351
375
  const rows = [];
352
- const add = (name, limit, reported) => {
376
+ const add = (name, limit, reported, show = String) => {
353
377
  if (limit == null && reported == null) return;
354
- rows.push({ name, limit: limit == null ? 'no limit asked' : String(limit), reported: reported == null ? 'not reported' : String(reported) });
378
+ rows.push({ name, limit: limit == null ? 'no limit asked' : show(limit), reported: reported == null ? 'not reported' : show(reported) });
355
379
  };
356
380
  add('Minutes', l.minutes, null);
357
381
  add('Turns', l.turns, null);
358
- add('Cost', l.cost, r.cost);
359
- add('Tokens', null, r.tokens);
382
+ add('Cost', l.cost, r.cost, formatCost);
383
+ add('Tokens', null, r.tokens, (n) => n.toLocaleString('en-US'));
360
384
  return rows;
361
385
  }
362
386
 
@@ -437,14 +461,14 @@ export function changeWords(before, after) {
437
461
  const out = [];
438
462
  for (const run of after) {
439
463
  const old = was.get(run.runId);
440
- if (!old) { out.push(`New run ${run.runId}: ${run.kind} on ${aboutWords(run.refs)}, ${statusWords(run).toLowerCase()}`); continue; }
441
- if (old.status !== run.status) out.push(`Run ${run.runId} is now ${statusWords(run).toLowerCase()}`);
464
+ if (!old) { out.push(`New run: ${runName(run)}, ${statusWords(run).toLowerCase()}`); continue; }
465
+ if (old.status !== run.status) out.push(`Run ${runName(run)} is now ${statusWords(run).toLowerCase()}`);
442
466
  const was2 = new Set(old.open ? old.collidesWith || [] : []);
443
467
  const now2 = new Set(run.open ? run.collidesWith || [] : []);
444
468
  const added = [...now2].filter((id) => !was2.has(id));
445
469
  const gone = [...was2].filter((id) => !now2.has(id));
446
- if (added.length) out.push(`Run ${run.runId} now collides with ${listWords(added)}`);
447
- if (gone.length && !now2.size) out.push(`Run ${run.runId} no longer collides`);
470
+ if (added.length) out.push(`Run ${runName(run)} now collides with ${listWords(added.map((id) => { const other = after.find((r) => r.runId === id); return other ? runName(other) : 'another run'; }))}`);
471
+ if (gone.length && !now2.size) out.push(`Run ${runName(run)} no longer collides`);
448
472
  }
449
473
  return out;
450
474
  }
@@ -9,8 +9,8 @@
9
9
  */
10
10
 
11
11
  import { relativeTime } from './review-model.js';
12
- import { runTone, canRetry, aboutWords, statusWords, statusWhy, runMeta, canStop, canAnswer, groupRuns, compareTitle, limitRows, checksWords, timelineWords, nodeLabels, collisionWords, answerWords } from './runs-model.js';
13
- import { cornStateAttr } from './corn-state.js';
12
+ import { runTone, canRetry, aboutWords, runName, statusWords, statusWhy, runMeta, canStop, canAnswer, groupRuns, compareTitle, limitRows, checksWords, timelineWords, nodeLabels, collisionWords, answerWords } from './runs-model.js';
13
+ import { cornState, cornStateAttr, stateIconHtml } from './corn-state.js';
14
14
  import { t } from './strings.js';
15
15
 
16
16
 
@@ -27,6 +27,7 @@ import { t } from './strings.js';
27
27
  * @property {Set<string>} timelines the runs whose timeline is open
28
28
  * @property {boolean} busy an action is in flight
29
29
  * @property {Map<string, string>} [replies] the reply typed so far for each waiting run, so a repaint keeps it
30
+ * @property {Map<string, { text: string, ok: boolean }>} [results] what the last action on each run came to, shown in its card by the control that was used
30
31
  */
31
32
 
32
33
  /** A link that opens a new tab, said so for a screen reader */
@@ -53,8 +54,8 @@ function linksHtml(ctx, run) {
53
54
 
54
55
  /** A run id that is another run of the list is a button that takes you to it; otherwise it is plain text */
55
56
  function runLink(ctx, runId, all) {
56
- const there = (all || []).some((r) => r.runId === runId);
57
- return there ? `<button type="button" class="hx-btn hx-forge-act" data-run-goto="${ctx.esc(runId)}" aria-label="Go to run ${ctx.esc(runId)}">${ctx.esc(runId)}</button>` : ctx.esc(runId);
57
+ const there = (all || []).find((r) => r.runId === runId);
58
+ return there ? `<button type="button" class="hx-btn hx-forge-act" data-run-goto="${ctx.esc(runId)}" title="Go to this run">${ctx.esc(runName(there))}</button>` : 'an earlier run';
58
59
  }
59
60
 
60
61
  /** Which run this one starts again, and which start it again */
@@ -67,10 +68,11 @@ function retryHtml(ctx, run, all) {
67
68
  function timelineHtml(ctx, run, all) {
68
69
  const items = (run.timeline || []).map((e) => {
69
70
  const w = timelineWords(e);
70
- const goto = (e.kind === 'retry-of' || e.kind === 'retried-by') && e.ref && (all || []).some((r) => r.runId === e.ref) ? ` <button type="button" class="hx-btn hx-forge-act" data-run-goto="${ctx.esc(e.ref)}" aria-label="Go to run ${ctx.esc(e.ref)}">Go to it</button>` : '';
71
- return `<li><time datetime="${ctx.esc(e.at)}" title="${ctx.esc(e.at)}">${ctx.esc(relativeTime(e.at, ctx.now) || e.at)}</time>${ctx.esc(w.what)}${goto}${w.note ? `<span class="hx-run-note">${ctx.esc(w.note)}</span>` : ''}</li>`;
71
+ const other = (e.kind === 'retry-of' || e.kind === 'retried-by') && e.ref ? (all || []).find((r) => r.runId === e.ref) : null;
72
+ const goto = other ? ` <button type="button" class="hx-btn hx-forge-act" data-run-goto="${ctx.esc(e.ref)}" aria-label="Go to it: ${ctx.esc(runName(other))}">Go to it</button>` : '';
73
+ return `<li><time datetime="${ctx.esc(e.at)}" title="${ctx.esc(e.at)}">${ctx.esc(relativeTime(e.at, ctx.now) || e.at)}</time>${ctx.esc(w.what.replace(/run-[0-9A-Za-z]{26}/g, (id) => { const o = (all || []).find((r) => r.runId === id); return o ? runName(o) : 'an earlier run'; }))}${goto}${w.note ? `<span class="hx-run-note">${ctx.esc(w.note)}</span>` : ''}</li>`;
72
74
  });
73
- return `<ol class="hx-run-timeline" id="run-tl-${ctx.esc(run.runId)}" aria-label="Timeline of ${ctx.esc(run.runId)}, oldest first">${items.join('')}</ol>`;
75
+ return `<ol class="hx-run-timeline" id="run-tl-${ctx.esc(run.runId)}" aria-label="Timeline of ${ctx.esc(runName(run))}, oldest first">${items.join('')}</ol>`;
74
76
  }
75
77
 
76
78
  /** What was answered, escaped: the action, a reply's words, who and when */
@@ -79,16 +81,37 @@ function answeredHtml(ctx, run) {
79
81
  return `<p class="hx-forge-meta">Answered: ${ctx.esc(answerWords(a))} · ${ctx.esc(a.by || 'a maintainer')}, ${ctx.esc(relativeTime(a.at, ctx.now) || a.at)}</p>`;
80
82
  }
81
83
 
84
+
85
+ /** The run's result line: what the last action on it came to, by the control that was used; always in the card (hidden when empty) so a card kept as it is can take a new one */
86
+ function resultHtml(ctx, run) {
87
+ const r = ctx.results && ctx.results.get(run.runId);
88
+ return `<p class="hx-forge-result" data-run-result="${ctx.esc(run.runId)}" data-corn="result"${r ? ` data-corn-state="${r.ok ? 'success' : 'failure'}"` : ' hidden'}>${r ? ctx.esc(r.text) : ''}</p>`;
89
+ }
90
+
82
91
  /** A waiting run: what was asked (the note and link are shown above) and the three answers, plain buttons and a reply field */
83
92
  function answerHtml(ctx, run) {
84
93
  const id = ctx.esc(run.runId);
94
+ const name = ctx.esc(runName(run, ctx.now));
85
95
  const off = ctx.busy ? ' disabled' : '';
86
96
  const reply = ctx.replies && ctx.replies.get(run.runId) || '';
87
- return `${run.answer ? answeredHtml(ctx, run) : ''}<div class="hx-run-actions" role="group" aria-label="Answer run ${id}">
88
- <button type="button" class="hx-btn hx-forge-act" data-run-answer="continue" data-run-id="${id}" aria-label="${ctx.esc(t('continueRun'))} run ${id}"${off}>${ctx.esc(t('continueRun'))}</button>
89
- <button type="button" class="hx-btn hx-forge-act" data-run-answer="stop" data-run-id="${id}" aria-label="${ctx.esc(t('stop'))} run ${id}"${off} data-corn-kind="danger">${ctx.esc(t('stop'))}</button></div>
90
- <label class="hx-forge-field" data-corn="field">Reply to run ${id}<input type="text" class="hx-forge-input" data-run-reply="${id}" value="${ctx.esc(reply)}" maxlength="4000" autocomplete="off" /></label>
91
- <div class="hx-run-actions"><button type="button" class="hx-btn hx-forge-act" data-run-answer="reply" data-run-id="${id}" aria-label="${ctx.esc(t('reply'))} to run ${id}"${off}>${ctx.esc(t('reply'))}</button></div>`;
97
+ return `${run.answer ? answeredHtml(ctx, run) : ''}<div class="hx-run-actions" role="group" aria-label="Answer: ${name}">
98
+ <button type="button" class="hx-btn hx-forge-act" data-run-answer="continue" data-run-id="${id}" aria-label="${ctx.esc(t('continueRun'))}: ${name}"${off}>${ctx.esc(t('continueRun'))}</button>
99
+ <button type="button" class="hx-btn hx-forge-act" data-run-answer="stop" data-run-id="${id}" aria-label="${ctx.esc(t('stop'))}: ${name}"${off} data-corn-kind="danger">${ctx.esc(t('stop'))}</button></div>
100
+ <label class="hx-forge-field" data-corn="field">Reply to ${ctx.esc(`${run.kind} on ${aboutWords(run.refs)}`)}<input type="text" class="hx-forge-input" data-run-reply="${id}" value="${ctx.esc(reply)}" maxlength="4000" autocomplete="off" /></label>
101
+ <div class="hx-run-actions"><button type="button" class="hx-btn hx-forge-act" data-run-answer="reply" data-run-id="${id}" aria-label="${ctx.esc(t('reply'))}: ${name}"${off}>${ctx.esc(t('reply'))}</button></div>`;
102
+ }
103
+
104
+ /**
105
+ * A reply typed to a run that no longer waits (it went on, or was stopped, while the person typed): it was not sent, and it is not lost. The
106
+ * field stays, with what was typed, so it can be copied, and a line says the run changed; Discard lets it go. '' when nothing was typed.
107
+ */
108
+ function unsentHtml(ctx, run) {
109
+ const reply = ctx.replies && ctx.replies.get(run.runId) || '';
110
+ if (!reply) return '';
111
+ const id = ctx.esc(run.runId);
112
+ return `<p class="hx-forge-why" data-corn="message" data-corn-state="failure">This run is now ${ctx.esc(statusWords(run).toLowerCase())} and no longer waits for a reply, so what you typed was not sent. It is kept here to copy.</p>
113
+ <label class="hx-forge-field" data-corn="field">Your reply, not sent<input type="text" class="hx-forge-input" data-run-reply="${id}" value="${ctx.esc(reply)}" maxlength="4000" autocomplete="off" /></label>
114
+ <div class="hx-run-actions"><button type="button" class="hx-btn hx-forge-act" data-run-discard="${id}" aria-label="Discard: your reply to ${ctx.esc(runName(run, ctx.now))}">Discard</button></div>`;
92
115
  }
93
116
 
94
117
  /** The totals as plain lines (see `totalsLines`), escaped; '' when there are none */
@@ -96,34 +119,49 @@ export function totalsHtml(ctx, lines) {
96
119
  return lines.map((l) => `<p class="hx-forge-meta">${ctx.esc(l)}</p>`).join('');
97
120
  }
98
121
 
122
+ /** A run's state as a pill: an icon (a shape of its own), then the word. The waiting pill is the solid one (see the CSS), the others are outlines. */
123
+ export function runPillHtml(ctx, run, words, extra = '') {
124
+ return `<span class="hx-forge-state hx-forge-state--${runTone(run)}" data-corn="state-pill"${cornStateAttr(run.status)}${extra}>${stateIconHtml(cornState(run.status))}${ctx.esc(words)}</span>`;
125
+ }
126
+
127
+ /** Placeholder rows while a list loads: they hold the height the list will have, so nothing jumps when the data arrives */
128
+ export function loadingRowsHtml(n = 3) {
129
+ return Array.from({ length: n }, () => '<li class="hx-forge-skeleton" data-corn="skeleton" aria-hidden="true"><span></span><span></span></li>').join('');
130
+ }
131
+
99
132
  /** One run */
100
133
  export function runHtml(ctx, run, all) {
101
134
  const lit = ctx.selected === run.runId;
102
135
  const open = ctx.timelines.has(run.runId);
103
- const tone = runTone(run);
104
136
  const why = statusWhy(run);
137
+ const name = ctx.esc(runName(run, ctx.now));
105
138
  const note = run.report && run.report.note ? `<p class="hx-forge-meta">Runner: ${ctx.esc(run.report.note)}</p>` : '';
106
139
  const answering = canAnswer(run);
107
- const retry = canRetry(run) ? `<button type="button" class="hx-btn hx-forge-act" data-forge-retry="${ctx.esc(run.runId)}" aria-label="${ctx.esc(t('startAgain'))} on run ${ctx.esc(run.runId)}"${ctx.busy ? ' disabled' : ''}>${ctx.esc(t('startAgain'))}</button>` : '';
108
- 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(t('stop'))} run ${ctx.esc(run.runId)}"${ctx.busy ? ' disabled' : ''} data-corn-kind="danger">${ctx.esc(t('stop'))}</button>` : '';
140
+ const off = ctx.busy ? ' disabled' : '';
141
+ const retry = canRetry(run) ? `<button type="button" class="hx-btn hx-forge-act" data-forge-retry="${ctx.esc(run.runId)}" aria-label="${ctx.esc(t('startAgain'))}: ${name}"${off}>${ctx.esc(t('startAgain'))}</button>` : '';
142
+ 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(t('stop'))}: ${name}"${off} data-corn-kind="danger">${ctx.esc(t('stop'))}</button>` : '';
109
143
  const names = nodeLabels(run.nodes, ctx.nodes);
110
144
  const collision = collisionWords(run, all, ctx.nodes);
111
145
  const limits = limitRows(run);
112
146
  const count = (run.timeline || []).length;
113
147
  const links = linksHtml(ctx, run);
148
+ const noNodes = !(run.nodes || []).length;
149
+ const lightWords = lit ? 'Lit on the map' : 'Light on the map';
150
+ const result = resultHtml(ctx, run);
114
151
  return `<li class="hx-run hx-forge-file" data-run="${ctx.esc(run.runId)}" tabindex="-1" data-corn="run"${cornStateAttr(run.status)}>
115
- <div class="hx-run-head"><span class="hx-forge-state hx-forge-state--${tone}" data-corn="state-pill"${cornStateAttr(run.status)}>${ctx.esc(statusWords(run))}</span> <span class="hx-name">${ctx.esc(run.kind)} on ${ctx.esc(aboutWords(run.refs))}</span>${run.profile ? ` <span class="hx-faint">profile ${ctx.esc(run.profile)}</span>` : ''}</div>
152
+ <div class="hx-run-head">${runPillHtml(ctx, run, statusWords(run))} <span class="hx-name">${ctx.esc(run.kind)} on ${ctx.esc(aboutWords(run.refs))}</span>${run.profile ? ` <span class="hx-faint">profile ${ctx.esc(run.profile)}</span>` : ''}</div>
116
153
  ${collision ? `<p class="hx-run-collide"><span aria-hidden="true">⚠</span> ${ctx.esc(collision)}</p>` : ''}
117
154
  <p class="hx-forge-meta">${ctx.esc(runMeta(run, ctx.now))}</p>${why ? `<p class="hx-forge-why hx-faint">${ctx.esc(why)}</p>` : ''}${note}
118
155
  <dl class="hx-run-limits" aria-label="Limits and what the runner reported">${limits.length ? limits.map((r) => `<dt>${ctx.esc(r.name)}</dt><dd>limit: ${ctx.esc(r.limit)}; reported: ${ctx.esc(r.reported)}</dd>`).join('') : '<dt>Limits</dt><dd>none asked, nothing reported</dd>'}</dl>
119
156
  <p class="hx-forge-meta">${ctx.esc(checksWords(run))}</p>
120
- <p class="hx-forge-meta">${names.length ? `Changing ${run.nodesFrom === 'files' ? '' : 'or expected to change '}${ctx.esc(names.join(', '))}` : 'No node on the map yet.'}</p>
157
+ <p class="hx-forge-meta" id="run-nodes-${ctx.esc(run.runId)}">${names.length ? `Changing ${run.nodesFrom === 'files' ? '' : 'or expected to change '}${ctx.esc(names.join(', '))}` : 'No node on the map yet.'}</p>
121
158
  ${retryHtml(ctx, run, all)}
122
159
  ${links ? `<p class="hx-forge-meta">${links}</p>` : ''}
123
- ${answering ? answerHtml(ctx, run) : ''}${run.answer && !answering ? answeredHtml(ctx, run) : ''}
160
+ ${answering ? `${answerHtml(ctx, run)}${result}` : unsentHtml(ctx, run)}${run.answer && !answering ? answeredHtml(ctx, run) : ''}
124
161
  <div class="hx-run-actions">${stop}${retry}
125
- <button type="button" class="hx-btn hx-forge-act" data-run-select="${ctx.esc(run.runId)}" aria-pressed="${lit}" aria-label="Light the nodes of ${ctx.esc(run.runId)} on the map"${(run.nodes || []).length ? '' : ' disabled'}>${lit ? 'Lit on the map' : 'Light on the map'}</button>
162
+ <button type="button" class="hx-btn hx-forge-act" data-run-select="${ctx.esc(run.runId)}" aria-pressed="${lit}" aria-label="${lightWords}: ${name}"${noNodes ? ` disabled title="No node on the map yet, so there is nothing to light" aria-describedby="run-nodes-${ctx.esc(run.runId)}"` : ''}>${lightWords}</button>
126
163
  <button type="button" class="hx-btn hx-forge-act" data-run-timeline="${ctx.esc(run.runId)}" aria-expanded="${open}" aria-controls="run-tl-${ctx.esc(run.runId)}">Timeline (${count})</button></div>
164
+ ${answering ? '' : result}
127
165
  ${open ? timelineHtml(ctx, run, all) : ''}</li>`;
128
166
  }
129
167
 
@@ -136,7 +174,7 @@ export function runsHtml(ctx, runs) {
136
174
  return groupRuns(runs).map((g) => {
137
175
  if (g.kind === 'run') return runHtml(ctx, g.run, runs);
138
176
  const id = `cmp-${g.runs[0].runId}`;
139
- return `<li class="hx-run-group"><section class="hx-run-compare" aria-labelledby="${ctx.esc(id)}">
177
+ return `<li class="hx-run-group" data-key="${ctx.esc(id)}"><section class="hx-run-compare" aria-labelledby="${ctx.esc(id)}">
140
178
  <h4 class="hx-run-compare-title" id="${ctx.esc(id)}">${ctx.esc(compareTitle(g.runs))}</h4>
141
179
  <p class="hx-forge-meta hx-faint">The same request under each profile, side by side.</p>
142
180
  <ul class="hx-run-columns" aria-label="${ctx.esc(g.runs.length)} profiles compared">${g.runs.map((r) => runHtml(ctx, r, runs)).join('')}</ul></section></li>`;
@@ -228,7 +228,7 @@ function showBar(speed) {
228
228
  <select class="hx-player-speed" data-action="scenario-speed" aria-label="Time for each step" title="Time for each step">${SPEED_CHOICES.map((c) => `<option value="${c.value}">${c.label}</option>`).join('')}</select>
229
229
  <button type="button" class="hx-close" data-action="scenario-close" aria-label="Close the scenario" data-corn-kind="icon">✕</button>
230
230
  </div>
231
- <p class="hx-player-text" aria-live="polite"><span class="hx-player-count"></span> · <span class="hx-player-step"></span></p>
231
+ <p class="hx-player-text" aria-live="polite"><span class="hx-player-count" data-corn="count"></span> · <span class="hx-player-step"></span></p>
232
232
  <div class="hx-player-controls">
233
233
  <button type="button" class="hx-btn" data-action="scenario-prev" data-peek-ok>◀ Previous</button>
234
234
  <button type="button" class="hx-btn hx-btn--active" data-action="scenario-toggle" data-peek-ok data-corn-kind="primary"></button>
@@ -0,0 +1,73 @@
1
+ /*
2
+ * The sign-in, "ask a maintainer" and 401 pages (server/auth.js), the ones a visitor sees before the explorer. Plain CSS; every colour,
3
+ * font, size, radius, border width, shadow and space is a --corn-* token from explorer/tokens.css (loaded before this file), and the
4
+ * repo's theme stylesheet is linked after it, so a brand reaches these pages as it reaches the map. Hooks: [data-corn="auth-page"] (the
5
+ * body), "auth-card", "auth-brand", "auth-reason"; the buttons carry data-corn-kind. Not loaded by the explorer. The server sends these
6
+ * files without a session (server/server.js, docs/sign-in.md), so keep nothing private in them.
7
+ */
8
+
9
+ *, *::before, *::after { box-sizing: border-box; }
10
+ [hidden] { display: none !important; }
11
+
12
+ body {
13
+ margin: 0;
14
+ min-height: 100dvh;
15
+ display: grid;
16
+ place-items: center;
17
+ padding: var(--corn-space-5);
18
+ background-color: var(--corn-ground);
19
+ background-image: var(--corn-ground-image);
20
+ background-attachment: fixed;
21
+ color: var(--corn-text-2);
22
+ font-family: var(--corn-font);
23
+ font-size: var(--corn-text-base);
24
+ line-height: 1.5;
25
+ -webkit-font-smoothing: antialiased;
26
+ }
27
+
28
+ [data-corn="auth-card"] {
29
+ width: 100%;
30
+ max-width: 420px;
31
+ padding: var(--corn-space-6);
32
+ background: var(--corn-surface-1);
33
+ border: var(--corn-border) solid var(--corn-line);
34
+ border-radius: var(--corn-radius-lg);
35
+ box-shadow: var(--corn-shadow);
36
+ }
37
+
38
+ [data-corn="auth-brand"] { display: flex; align-items: center; gap: var(--corn-space-3); margin-bottom: var(--corn-space-5); color: var(--corn-text); }
39
+ [data-corn="auth-brand"] svg { flex: none; width: 28px; height: 28px; }
40
+ [data-corn="auth-brand"] .cf-mark-bg { fill: var(--corn-accent); }
41
+ [data-corn="auth-brand"] .cf-mark-fg { fill: var(--corn-text-on-accent); }
42
+ [data-corn="auth-brand"] .cf-mark-line { fill: none; stroke: var(--corn-text-on-accent); stroke-width: 1.5; }
43
+ [data-corn="auth-brand"] img { display: block; flex: none; max-width: 100%; }
44
+ [data-corn="auth-brand"] [data-corn="brand-logo"] { width: 28px; height: 28px; }
45
+ [data-corn="auth-brand"] [data-corn="brand-wordmark"] { height: 18px; width: auto; }
46
+ .cf-app-name { font-family: var(--corn-font-display); font-size: var(--corn-text-base); font-weight: 650; }
47
+
48
+ h1 { margin: 0 0 var(--corn-space-3); font-family: var(--corn-font-display); font-size: var(--corn-text-xl); line-height: 1.25; color: var(--corn-text); overflow-wrap: anywhere; }
49
+ p { margin: 0 0 var(--corn-space-5); color: var(--corn-text-2); }
50
+ code { font-family: var(--corn-mono); font-size: var(--corn-text-sm); color: var(--corn-text); overflow-wrap: anywhere; }
51
+ [data-corn="auth-reason"] { padding: var(--corn-space-3) var(--corn-space-4); background: var(--corn-surface-2); border: var(--corn-border) solid var(--corn-line-soft); border-radius: var(--corn-radius-sm); color: var(--corn-text); }
52
+ [data-corn-state="failure"] h1 { color: var(--corn-bad); }
53
+
54
+ form { margin: 0; }
55
+ .cf-button {
56
+ display: inline-flex;
57
+ align-items: center;
58
+ justify-content: center;
59
+ min-height: 44px;
60
+ padding: var(--corn-space-3) var(--corn-space-5);
61
+ border: var(--corn-border) solid var(--corn-accent);
62
+ border-radius: var(--corn-radius-sm);
63
+ background: var(--corn-accent);
64
+ color: var(--corn-text-on-accent);
65
+ font: inherit;
66
+ font-weight: 600;
67
+ text-decoration: none;
68
+ cursor: pointer;
69
+ }
70
+ .cf-button:hover { background: var(--corn-accent-hover); border-color: var(--corn-accent-hover); }
71
+ .cf-button[data-corn-kind="quiet"] { background: transparent; border-color: var(--corn-line); color: var(--corn-accent-text); }
72
+ .cf-button[data-corn-kind="quiet"]:hover { background: var(--corn-surface-3); }
73
+ .cf-button:focus-visible { outline: var(--corn-focus-width) solid var(--corn-focus); outline-offset: var(--corn-focus-offset); }
@@ -13,8 +13,8 @@
13
13
  :root {
14
14
  /* Ground and surfaces */
15
15
  --corn-ground: #090d16;
16
- --corn-ground-image: radial-gradient(circle at 14% 18%, rgba(66, 153, 225, 0.28) 0%, transparent 45%),
17
- radial-gradient(circle at 86% 82%, rgba(229, 62, 62, 0.22) 0%, transparent 45%),
16
+ --corn-ground-image: radial-gradient(circle at 14% 18%, rgba(66, 153, 225, 0.2) 0%, transparent 45%),
17
+ radial-gradient(circle at 86% 82%, rgba(229, 62, 62, 0.16) 0%, transparent 45%),
18
18
  radial-gradient(circle at 50% 50%, rgba(66, 153, 225, 0.10) 0%, transparent 60%);
19
19
  --corn-surface-1: rgba(26, 34, 52, 0.72);
20
20
  --corn-surface-2: rgba(30, 41, 59, 0.8);
@@ -27,6 +27,8 @@
27
27
  --corn-shadow-color: rgba(0, 0, 0, 0.5);
28
28
  --corn-glow: 8px;
29
29
  --corn-scrim: rgba(0, 0, 0, 0.6);
30
+ /* The shadow of a phone's bottom sheet, cast upward: it takes --corn-shadow-color, so a flat brand sets it to a hard offset */
31
+ --corn-shadow-sheet: 0 -8px 24px color-mix(in srgb, var(--corn-shadow-color) 70%, transparent);
30
32
  --corn-blur: 16px;
31
33
 
32
34
  /* Text */
@@ -50,6 +52,16 @@
50
52
  --corn-bad: #fca5a5;
51
53
  --corn-info: #7dd3fc;
52
54
  --corn-ok-soft: color-mix(in srgb, var(--corn-ok) 15%, transparent);
55
+ /* An agent run's seven states, each its own colour for a theme to set (a pill also has a word and an icon, so none is told by colour alone).
56
+ They follow the status colours above in the light level too; a theme that sets one sets it for both levels, or leaves the alias. */
57
+ --corn-run-requested: var(--corn-text-3);
58
+ --corn-run-claimed: var(--corn-info);
59
+ --corn-run-working: var(--corn-info);
60
+ --corn-run-waiting: var(--corn-warn);
61
+ --corn-run-waiting-ink: var(--corn-ground);
62
+ --corn-run-done: var(--corn-ok);
63
+ --corn-run-failed: var(--corn-bad);
64
+ --corn-run-stopped: var(--corn-text-2);
53
65
 
54
66
  /* Diff: what a proposal adds, changes, removes and edits (the map draws the same four) */
55
67
  --corn-added: #2dd4bf;
@@ -73,6 +85,8 @@
73
85
  --corn-font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
74
86
  --corn-font-display: var(--corn-font);
75
87
  --corn-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
88
+ /* The face of numbers shown as data (counts, times, costs, PR numbers, the step counter): a pixel or display face misreads 2, 5 and 8, so a brand sets one with clear digits */
89
+ --corn-font-num: var(--corn-font);
76
90
  --corn-text-2xs: 10px;
77
91
  --corn-text-xs: 11px;
78
92
  --corn-text-sm: 12px;
@@ -90,6 +104,7 @@
90
104
  --corn-border: 1px;
91
105
  --corn-border-strong: 2px;
92
106
  --corn-focus-width: 2px;
107
+ --corn-focus-offset: 2px;
93
108
 
94
109
  /* Spacing: padding, gaps and margins are steps of this scale (or calc() over it) */
95
110
  --corn-space: 4px;
@@ -118,6 +133,10 @@
118
133
  --corn-map-label: auto;
119
134
  --corn-map-label-halo: auto;
120
135
  --corn-map-collision: var(--corn-warn);
136
+ /* The label font list (auto: the map's own stack), an ordinary line's width in px (auto: each line's own) and the glow factor (auto and 1: as drawn, 0: none) */
137
+ --corn-map-font: auto;
138
+ --corn-map-edge-width: auto;
139
+ --corn-map-glow: auto;
121
140
  /* Diff, selection and focus */
122
141
  --corn-map-added: auto;
123
142
  --corn-map-changed: auto;
@@ -185,8 +204,8 @@
185
204
  @media (prefers-color-scheme: light) {
186
205
  :root:not([data-theme="dark"]) {
187
206
  --corn-ground: #f4f6fa;
188
- --corn-ground-image: radial-gradient(circle at 14% 18%, rgba(66, 153, 225, 0.12) 0%, transparent 45%),
189
- radial-gradient(circle at 86% 82%, rgba(229, 62, 62, 0.07) 0%, transparent 45%);
207
+ --corn-ground-image: radial-gradient(circle at 14% 18%, rgba(66, 153, 225, 0.06) 0%, transparent 45%),
208
+ radial-gradient(circle at 86% 82%, rgba(229, 62, 62, 0.04) 0%, transparent 45%);
190
209
  --corn-surface-1: rgba(255, 255, 255, 0.8);
191
210
  --corn-surface-2: rgba(241, 245, 249, 0.92);
192
211
  --corn-surface-3: rgba(226, 232, 240, 0.95);
@@ -234,8 +253,8 @@
234
253
 
235
254
  :root[data-theme="light"] {
236
255
  --corn-ground: #f4f6fa;
237
- --corn-ground-image: radial-gradient(circle at 14% 18%, rgba(66, 153, 225, 0.12) 0%, transparent 45%),
238
- radial-gradient(circle at 86% 82%, rgba(229, 62, 62, 0.07) 0%, transparent 45%);
256
+ --corn-ground-image: radial-gradient(circle at 14% 18%, rgba(66, 153, 225, 0.06) 0%, transparent 45%),
257
+ radial-gradient(circle at 86% 82%, rgba(229, 62, 62, 0.04) 0%, transparent 45%);
239
258
  --corn-surface-1: rgba(255, 255, 255, 0.8);
240
259
  --corn-surface-2: rgba(241, 245, 249, 0.92);
241
260
  --corn-surface-3: rgba(226, 232, 240, 0.95);
package/explorer/view.js CHANGED
@@ -15,7 +15,7 @@ import { clearScenario } from './scenario-ui.js';
15
15
  import { measureParams } from './bench.js';
16
16
  import { mergeLive, placeLiveNodes } from './live-model.js';
17
17
  import { applyHouseLayout } from './house-model.js';
18
- import { t } from './strings.js';
18
+ import { syncHint } from './hint.js';
19
19
 
20
20
  const $ = (id) => document.getElementById(id);
21
21
 
@@ -166,6 +166,5 @@ export function syncViewUi() {
166
166
  if (layersBtn) layersBtn.classList.toggle('hx-layers-chip--dim', preset);
167
167
  const note = $('layers-preset-note');
168
168
  if (note) note.hidden = !preset;
169
- const badge = $('instruction-badge-text');
170
- if (badge) badge.textContent = preset ? t('hintDataFlow') : (state.isFreeform ? t('hintDrag') : t('hintInspect'));
169
+ syncHint(); // the hint's words for this view and pointer, and whether it shows (hint.js)
171
170
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@popcorn245/cornfield",
3
- "version": "0.34.3",
3
+ "version": "0.36.0",
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)",