@popcorn245/cornfield 0.34.2 → 0.35.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/contrast.js +65 -1
- package/core/proposal.js +10 -3
- package/explorer/check.js +6 -1
- package/explorer/connection.js +62 -0
- package/explorer/corn-state.js +34 -2
- package/explorer/diff-marks.js +35 -0
- package/explorer/explorer.css +78 -5
- package/explorer/feedback.js +49 -0
- package/explorer/focusables.js +35 -0
- package/explorer/forge-panel-model.js +41 -7
- package/explorer/forge-panel.js +226 -70
- package/explorer/index.html +7 -3
- package/explorer/mockups.js +3 -9
- package/explorer/panels.js +10 -4
- package/explorer/plugins.js +11 -2
- package/explorer/proposal-model.js +61 -8
- package/explorer/proposal.js +42 -14
- package/explorer/renderer-canvas2d.js +23 -5
- package/explorer/review-model.js +8 -3
- package/explorer/review-tokens.js +2 -7
- package/explorer/review.js +56 -11
- package/explorer/runs-model.js +42 -18
- package/explorer/runs-view.js +58 -20
- package/explorer/scenario-ui.js +7 -3
- package/explorer/scene.js +8 -7
- package/explorer/theme-model.js +13 -6
- package/explorer/tokens.css +20 -10
- package/explorer/whatif.js +10 -3
- package/package.json +1 -1
- package/server/forge-http.js +1 -1
- package/server/proposals.js +1 -1
package/explorer/review.js
CHANGED
|
@@ -28,8 +28,9 @@ import { expandSheet, isPhone } from './sheets.js';
|
|
|
28
28
|
import { hooks } from './proposal.js';
|
|
29
29
|
import { refreshMockups } from './mockups.js';
|
|
30
30
|
import { getEdits, clearEdits } from './whatif.js';
|
|
31
|
-
import {
|
|
31
|
+
import { reviewParts, sendBackProblem, reviewBody, editsHint, isReviewable, NOT_ON_A_PR } from './review-model.js';
|
|
32
32
|
import { t } from './strings.js';
|
|
33
|
+
import { isOffline, notSentWords } from './connection.js';
|
|
33
34
|
|
|
34
35
|
const $ = (id) => document.getElementById(id);
|
|
35
36
|
|
|
@@ -40,6 +41,7 @@ const ui = {
|
|
|
40
41
|
key: null, // `${source}/${slug}` of the proposal the review below belongs to
|
|
41
42
|
reviewable: false, // whether it is on a spec PR
|
|
42
43
|
review: null, // { verdict, at } | null: the last review of it
|
|
44
|
+
loadFailed: false, // the past reviews could not be read: the bar must not look as if there were none
|
|
43
45
|
busy: false,
|
|
44
46
|
noting: false, // the note field is open (Send back was pressed)
|
|
45
47
|
message: '', // an inline refusal or failure
|
|
@@ -69,7 +71,7 @@ function mount() {
|
|
|
69
71
|
root.className = 'hx-review';
|
|
70
72
|
root.dataset.corn = 'review-bar';
|
|
71
73
|
root.innerHTML = `
|
|
72
|
-
<p class="hx-review-status" data-review-status role="status"
|
|
74
|
+
<p class="hx-review-status" data-review-status hidden><span data-review-verdict role="status"></span><span data-review-when></span></p>
|
|
73
75
|
<div class="hx-review-form" id="review-form" data-review-form hidden>
|
|
74
76
|
<label class="hx-review-label" for="review-note"></label>
|
|
75
77
|
<textarea id="review-note" class="hx-review-note" rows="2" maxlength="20000"></textarea>
|
|
@@ -77,6 +79,7 @@ function mount() {
|
|
|
77
79
|
<button type="button" class="hx-btn hx-btn--quiet" data-review-cancel data-corn-kind="quiet">Cancel</button>
|
|
78
80
|
</div>
|
|
79
81
|
</div>
|
|
82
|
+
<p class="hx-review-msg" data-review-loadfail role="alert" hidden data-corn="message" data-corn-state="failure"><span data-review-loadfail-text></span> <button type="button" class="hx-btn hx-btn--quiet" data-review-retry data-corn-kind="quiet">Retry</button></p>
|
|
80
83
|
<p class="hx-review-msg" data-review-msg role="alert" hidden></p>
|
|
81
84
|
<p class="hx-review-line" id="review-hint" data-review-hint role="status" hidden></p>
|
|
82
85
|
`;
|
|
@@ -96,9 +99,17 @@ function mount() {
|
|
|
96
99
|
/** Everything the review shows, from `ui` */
|
|
97
100
|
function paint() {
|
|
98
101
|
if (!root) return;
|
|
102
|
+
// Only the verdict is a live region, written when it changes: the time beside it ticks every TICK_MS and is never said again
|
|
99
103
|
const status = q('[data-review-status]');
|
|
100
|
-
|
|
101
|
-
|
|
104
|
+
const { verdict, when } = reviewParts(ui.review, now());
|
|
105
|
+
const said = q('[data-review-verdict]');
|
|
106
|
+
if (said.textContent !== verdict) said.textContent = verdict;
|
|
107
|
+
q('[data-review-when]').textContent = when ? ` ${when}` : '';
|
|
108
|
+
status.hidden = !verdict;
|
|
109
|
+
// A failed read of the past reviews says so: an approved proposal must not look as if nobody had reviewed it
|
|
110
|
+
const failed = q('[data-review-loadfail]');
|
|
111
|
+
failed.hidden = !ui.loadFailed;
|
|
112
|
+
q('[data-review-loadfail-text]').textContent = ui.loadFailed ? `Could not load this proposal's reviews.${isOffline() ? ' You are offline.' : ''} It may already be approved or sent back; try again before you decide.` : '';
|
|
102
113
|
// Off for good (not a spec PR's copy) is `disabled`, and the reason is the line next to it, which the buttons point at. While a review is being posted the button
|
|
103
114
|
// only says it is busy (`aria-disabled`): a `disabled` button drops the focus to the page.
|
|
104
115
|
for (const btn of document.querySelectorAll('#proposal-bar [data-review]')) {
|
|
@@ -155,6 +166,7 @@ function onBar(open) {
|
|
|
155
166
|
ui.key = key;
|
|
156
167
|
ui.reviewable = !!key && isReviewable(state.proposalSource);
|
|
157
168
|
ui.review = null;
|
|
169
|
+
ui.loadFailed = false;
|
|
158
170
|
ui.busy = false;
|
|
159
171
|
ui.noting = false;
|
|
160
172
|
ui.message = ui.hint = '';
|
|
@@ -165,20 +177,41 @@ function onBar(open) {
|
|
|
165
177
|
}
|
|
166
178
|
|
|
167
179
|
/** The latest admin review on the proposal's PR, as the server reads it from the comments (none yet is a 404) */
|
|
180
|
+
/** The reviews were read: the failure line goes, and Retry, if it had the focus, hands it to the proposal's name (the status line is a live region: it says the review itself, and is not a place for the focus) */
|
|
181
|
+
function readAgain() {
|
|
182
|
+
const retried = !!root && root.contains(document.activeElement) && document.activeElement.matches('[data-review-retry]');
|
|
183
|
+
ui.loadFailed = false;
|
|
184
|
+
paint();
|
|
185
|
+
const title = $('proposal-title');
|
|
186
|
+
if (!retried || !title) return;
|
|
187
|
+
title.tabIndex = -1;
|
|
188
|
+
title.focus();
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function readOnline() {
|
|
192
|
+
if (ui.loadFailed && ui.key) loadReview(ui.key);
|
|
193
|
+
}
|
|
194
|
+
|
|
168
195
|
async function loadReview(key) {
|
|
169
196
|
try {
|
|
170
197
|
const res = await fetch(reviewUrl(), { cache: 'no-store' });
|
|
171
|
-
if (
|
|
198
|
+
if (key !== ui.key) return; // another proposal has opened since
|
|
199
|
+
if (res.status === 404) { readAgain(); return; } // none yet: the server says so with a 404
|
|
200
|
+
if (!res.ok) throw new Error(`The server answered ${res.status}.`);
|
|
172
201
|
const found = await res.json();
|
|
173
|
-
if (key !== ui.key
|
|
174
|
-
ui.review = { verdict: found.verdict, at: found.at };
|
|
175
|
-
|
|
176
|
-
} catch {
|
|
202
|
+
if (key !== ui.key) return;
|
|
203
|
+
if (found && typeof found.verdict === 'string') ui.review = { verdict: found.verdict, at: found.at };
|
|
204
|
+
readAgain();
|
|
205
|
+
} catch {
|
|
206
|
+
// Not "no review": the read failed, so the bar says it could not look (with Retry), and the buttons stay as they were
|
|
207
|
+
if (key === ui.key) { ui.loadFailed = true; paint(); }
|
|
208
|
+
}
|
|
177
209
|
}
|
|
178
210
|
|
|
179
211
|
function onClick(e) {
|
|
180
212
|
if (ui.busy || !e.target.closest) return;
|
|
181
213
|
if (e.target.closest('[data-review-cancel]')) { closeNote(); return; }
|
|
214
|
+
if (e.target.closest('[data-review-retry]')) { q('[data-review-loadfail-text]').textContent = 'Reading the reviews again …'; loadReview(ui.key); return; }
|
|
182
215
|
const btn = e.target.closest('[data-review]');
|
|
183
216
|
if (!btn || btn.disabled) return;
|
|
184
217
|
if (btn.dataset.review === 'notes' && !ui.noting) openNote(); // the first press opens the field, the second sends
|
|
@@ -212,8 +245,18 @@ export async function sendReview(verdict) {
|
|
|
212
245
|
const key = ui.key;
|
|
213
246
|
const body = reviewBody(verdict, note, getEdits());
|
|
214
247
|
let saved;
|
|
248
|
+
const what = verdict === 'approved' ? 'Your approval' : 'Your send back';
|
|
249
|
+
let res;
|
|
250
|
+
try {
|
|
251
|
+
res = await fetch(reviewUrl(), { method: 'PUT', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) });
|
|
252
|
+
} catch {
|
|
253
|
+
// No answer at all: offline, or the server is not there. Said so, not as a server's error; the note and the edits are kept, and it says it was not sent
|
|
254
|
+
ui.busy = false;
|
|
255
|
+
ui.message = notSentWords(what);
|
|
256
|
+
paint();
|
|
257
|
+
return false;
|
|
258
|
+
}
|
|
215
259
|
try {
|
|
216
|
-
const res = await fetch(reviewUrl(), { method: 'PUT', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) });
|
|
217
260
|
let answer = null;
|
|
218
261
|
try { answer = await res.json(); } catch { /* no body */ }
|
|
219
262
|
if (!res.ok) throw new Error((answer && answer.error) || `The server answered ${res.status}.`);
|
|
@@ -254,6 +297,8 @@ export function initReview() {
|
|
|
254
297
|
if (barBefore) barBefore(open);
|
|
255
298
|
onBar(open);
|
|
256
299
|
};
|
|
300
|
+
// Back online after a failed read: the reviews are read again (the same function each time, so it is added once)
|
|
301
|
+
if (typeof window !== 'undefined') window.addEventListener('online', readOnline);
|
|
257
302
|
// "3 minutes ago" moves on without the bar being drawn again
|
|
258
303
|
timer = setInterval(() => { if (ui.review) paint(); }, TICK_MS);
|
|
259
304
|
onBar(!!state.proposal);
|
|
@@ -267,5 +312,5 @@ export function resetReviewForTests(clock = () => Date.now()) {
|
|
|
267
312
|
wired = false;
|
|
268
313
|
root = null;
|
|
269
314
|
now = clock;
|
|
270
|
-
Object.assign(ui, { key: null, reviewable: false, review: null, busy: false, noting: false, message: '', hint: '' });
|
|
315
|
+
Object.assign(ui, { key: null, reviewable: false, review: null, loadFailed: false, busy: false, noting: false, message: '', hint: '' });
|
|
271
316
|
}
|
package/explorer/runs-model.js
CHANGED
|
@@ -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
|
-
/**
|
|
45
|
-
|
|
46
|
-
|
|
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 &&
|
|
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.` : `
|
|
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
|
-
/** "
|
|
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 &&
|
|
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' :
|
|
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
|
|
441
|
-
if (old.status !== run.status) out.push(`Run ${run
|
|
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
|
|
447
|
-
if (gone.length && !now2.size) out.push(`Run ${run
|
|
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
|
}
|
package/explorer/runs-view.js
CHANGED
|
@@ -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 || []).
|
|
57
|
-
return there ? `<button type="button" class="hx-btn hx-forge-act" data-run-goto="${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
|
|
71
|
-
|
|
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
|
|
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
|
|
88
|
-
<button type="button" class="hx-btn hx-forge-act" data-run-answer="continue" data-run-id="${id}" aria-label="${ctx.esc(t('continueRun'))}
|
|
89
|
-
<button type="button" class="hx-btn hx-forge-act" data-run-answer="stop" data-run-id="${id}" aria-label="${ctx.esc(t('stop'))}
|
|
90
|
-
<label class="hx-forge-field" data-corn="field">Reply to run ${
|
|
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'))}
|
|
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
|
|
108
|
-
const
|
|
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"
|
|
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) :
|
|
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="
|
|
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>`;
|
package/explorer/scenario-ui.js
CHANGED
|
@@ -32,6 +32,7 @@ import { edgeKey } from '../core/proposal.js';
|
|
|
32
32
|
import { checksVersion, closeChecks, decorateSnapshot, openChecks, paintChecks } from './check.js';
|
|
33
33
|
import { blastRadius, outageLayers, outageScenario } from './outage-model.js';
|
|
34
34
|
import { toggleLayer } from './layers.js';
|
|
35
|
+
import { announce } from './keyboard.js';
|
|
35
36
|
|
|
36
37
|
/** A frame that arrives later than this (a tab that was hidden) counts as this long */
|
|
37
38
|
const MAX_FRAME_MS = 250;
|
|
@@ -272,6 +273,7 @@ function act(action) {
|
|
|
272
273
|
if (action === 'scenario-toggle') {
|
|
273
274
|
const s = player.snapshot();
|
|
274
275
|
if (s.playing) player.pause(); else player.play();
|
|
276
|
+
announce(s.playing ? 'Paused' : s.done ? 'Playing again' : s.index > 0 || s.progress > 0 ? 'Resumed' : 'Playing');
|
|
275
277
|
} else if (action === 'scenario-prev') player.prev();
|
|
276
278
|
else if (action === 'scenario-next') player.next();
|
|
277
279
|
else return;
|
|
@@ -284,9 +286,11 @@ let lastFill = -1;
|
|
|
284
286
|
function updateBar(snap) {
|
|
285
287
|
if (!bar) return;
|
|
286
288
|
const q = (cls) => bar.querySelector(cls);
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
289
|
+
// this runs every frame: a live region is written only when its words change, so a step is said once, not once a frame
|
|
290
|
+
const put = (cls, text) => { const el = q(cls); if (el.textContent !== text) el.textContent = text; };
|
|
291
|
+
put('.hx-player-title', snap.title);
|
|
292
|
+
put('.hx-player-count', `${Math.min(snap.index + 1, Math.max(snap.total, 1))} of ${snap.total}`);
|
|
293
|
+
put('.hx-player-step', snap.current.text);
|
|
290
294
|
const toggle = q('[data-action=scenario-toggle]');
|
|
291
295
|
toggle.textContent = snap.playing ? 'Pause' : snap.done ? 'Play again' : 'Play';
|
|
292
296
|
toggle.disabled = snap.total === 0 || snap.manual;
|
package/explorer/scene.js
CHANGED
|
@@ -166,6 +166,7 @@ import { externalLayer, whenDash } from './cloud-model.js';
|
|
|
166
166
|
import { outageFor, paintOutage } from './outage-model.js';
|
|
167
167
|
import { paintForge } from './forge-panel-model.js';
|
|
168
168
|
import { lightColor, lightenScene, parseColor } from './theme-model.js';
|
|
169
|
+
import { DIFF_MARK_COLORS, DIFF_LABEL_ALPHA, EDGE_MIN_ALPHA, MARK_SHAPES, REMOVED_ALPHA } from './diff-marks.js';
|
|
169
170
|
|
|
170
171
|
// ---------------------------------------------------------------------------
|
|
171
172
|
// Constants every renderer shares, so the looks cannot drift apart
|
|
@@ -200,10 +201,10 @@ const PACKET = { color: '#ffffff', radius: 3.5, glow: 10, cycleMs: 2600 };
|
|
|
200
201
|
* `alpha` fades a removed node and its edge; `strike` strikes its label through (`labelStrike`).
|
|
201
202
|
*/
|
|
202
203
|
export const MARK = {
|
|
203
|
-
added: { color:
|
|
204
|
-
changed: { color:
|
|
205
|
-
removed: { color:
|
|
206
|
-
edit: { color:
|
|
204
|
+
added: { ...MARK_SHAPES.added, color: DIFF_MARK_COLORS.dark.added, ringR: 9, ringWidth: 2, edgeWidth: 2.2, alpha: 1 },
|
|
205
|
+
changed: { ...MARK_SHAPES.changed, color: DIFF_MARK_COLORS.dark.changed, ringR: 9, ringWidth: 2.5, edgeWidth: 2.4, alpha: 1 },
|
|
206
|
+
removed: { ...MARK_SHAPES.removed, color: DIFF_MARK_COLORS.dark.removed, ringR: 9, ringWidth: 2, edgeWidth: 2, alpha: REMOVED_ALPHA },
|
|
207
|
+
edit: { ...MARK_SHAPES.edit, color: DIFF_MARK_COLORS.dark.edit, ringR: 9, ringWidth: 3, edgeWidth: 2.4, alpha: 1 }, // dotted: not the same ring as a change
|
|
207
208
|
};
|
|
208
209
|
/**
|
|
209
210
|
* The looks a renderer draws itself, per theme (MAP-01): the halos, the mark rings, the core dot and the
|
|
@@ -224,7 +225,7 @@ const lightLook = (look) => {
|
|
|
224
225
|
const DARK_LOOKS = Object.freeze({ halo: HALO, mark: MARK, core: CORE_COLOR, labelOutline: LABEL_OUTLINE });
|
|
225
226
|
const LIGHT_LOOKS = Object.freeze({
|
|
226
227
|
halo: Object.fromEntries(Object.entries(HALO).map(([k, v]) => [k, lightLook(v)])),
|
|
227
|
-
mark: Object.fromEntries(Object.entries(MARK).map(([k, v]) => [k,
|
|
228
|
+
mark: Object.fromEntries(Object.entries(MARK).map(([k, v]) => [k, { ...v, color: DIFF_MARK_COLORS.light[k] }])), // chosen to be 3:1 over the light ground and its glow (diff-marks.js)
|
|
228
229
|
core: CORE_COLOR, // the white dot stays white: it sits on the node's own (deepened) colour, not on the ground
|
|
229
230
|
labelOutline: { node: { color: 'rgba(244, 246, 250, 0.9)', width: 3.5 }, edge: { color: 'rgba(244, 246, 250, 0.92)', width: 3 } },
|
|
230
231
|
});
|
|
@@ -467,7 +468,7 @@ function styleForProposal(edge, mark, view, gone = false) {
|
|
|
467
468
|
edge.color = look.color;
|
|
468
469
|
edge.dash = gone ? MARK.removed.edgeDash : look.edgeDash; // an edge a what-if edit removes: violet, but dotted and faded like any removal
|
|
469
470
|
edge.width = Math.max(edge.width, look.edgeWidth);
|
|
470
|
-
if (edge.alpha >= 0.1) edge.alpha = Math.max(edge.alpha,
|
|
471
|
+
if (edge.alpha >= 0.1) edge.alpha = Math.max(edge.alpha, EDGE_MIN_ALPHA) * (gone ? MARK.removed.alpha : look.alpha); // not under the selection's deep dimming
|
|
471
472
|
if (edge.glow) edge.glowColor = look.color;
|
|
472
473
|
}
|
|
473
474
|
|
|
@@ -578,7 +579,7 @@ function buildNodes(state, subgraph) {
|
|
|
578
579
|
label: shown.label,
|
|
579
580
|
labelSize: big ? 12 : 11,
|
|
580
581
|
labelBold: big,
|
|
581
|
-
labelAlpha: alpha,
|
|
582
|
+
labelAlpha: focus && !focus.touched.has(node.id) && !(subgraph && !connected) ? Math.max(alpha, DIFF_LABEL_ALPHA) : alpha, // a label the diff dims stays 3:1
|
|
582
583
|
labelColor: connected ? '#f8fafc' : 'rgba(255, 255, 255, 0.3)',
|
|
583
584
|
labelKeep: LANDMARK_TYPES.includes(shown.type) || selected || match || mark !== 'none' || !!(subgraph && connected),
|
|
584
585
|
labelStrike: !!look && (look.strike || gone),
|
package/explorer/theme-model.js
CHANGED
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
*/
|
|
29
29
|
|
|
30
30
|
import { parseColor, luminance, ratio, contrast } from '../core/color.js';
|
|
31
|
+
import { DIFF_MARK_COLORS } from './diff-marks.js';
|
|
31
32
|
|
|
32
33
|
export const THEME_CHOICES = ['system', 'light', 'dark'];
|
|
33
34
|
/** Where the choice is kept in the browser (theme.js); `?theme=` in the address wins over it, without being kept */
|
|
@@ -186,12 +187,18 @@ export function lightenScene(scene) {
|
|
|
186
187
|
n.labelColor = lightColor(n.labelColor, 'text');
|
|
187
188
|
}
|
|
188
189
|
for (const e of scene.edges) {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
190
|
+
if (e.mark && e.mark !== 'none') {
|
|
191
|
+
// A proposal's mark keeps the light colour chosen for it (diff-marks.js) and the opacity scene.js gave it, with no gain:
|
|
192
|
+
// those were chosen together to be 3:1 at that opacity, and the contrast check (markOpacity) measures exactly that
|
|
193
|
+
e.color = DIFF_MARK_COLORS.dark[e.mark] === e.color ? DIFF_MARK_COLORS.light[e.mark] : lightColor(e.color);
|
|
194
|
+
} else {
|
|
195
|
+
// A thin dark line on a light ground reads weaker than a thin light one on a dark ground at the same
|
|
196
|
+
// alpha (the contrast ratio is lower): a faded or translucent line gets LINE_GAIN more, capped at opaque
|
|
197
|
+
if (e.alpha < 1) e.alpha = Math.min(1, e.alpha * LINE_GAIN);
|
|
198
|
+
e.color = lightColor(e.color);
|
|
199
|
+
const [r, g, b, a] = parseColor(e.color);
|
|
200
|
+
if (a > 0 && a < 1) e.color = css([r, g, b], Math.min(1, a * LINE_GAIN));
|
|
201
|
+
}
|
|
195
202
|
if (e.glowColor) e.glowColor = lightColor(e.glowColor);
|
|
196
203
|
if (e.label) e.label = { ...e.label, color: lightColor(e.label.color, 'text') };
|
|
197
204
|
if (e.packet) e.packet = { ...e.packet, color: lightColor(e.packet.color), glowColor: lightColor(e.packet.glowColor) };
|
package/explorer/tokens.css
CHANGED
|
@@ -50,12 +50,22 @@
|
|
|
50
50
|
--corn-bad: #fca5a5;
|
|
51
51
|
--corn-info: #7dd3fc;
|
|
52
52
|
--corn-ok-soft: color-mix(in srgb, var(--corn-ok) 15%, transparent);
|
|
53
|
+
/* 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).
|
|
54
|
+
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. */
|
|
55
|
+
--corn-run-requested: var(--corn-text-3);
|
|
56
|
+
--corn-run-claimed: var(--corn-info);
|
|
57
|
+
--corn-run-working: var(--corn-info);
|
|
58
|
+
--corn-run-waiting: var(--corn-warn);
|
|
59
|
+
--corn-run-waiting-ink: var(--corn-ground);
|
|
60
|
+
--corn-run-done: var(--corn-ok);
|
|
61
|
+
--corn-run-failed: var(--corn-bad);
|
|
62
|
+
--corn-run-stopped: var(--corn-text-2);
|
|
53
63
|
|
|
54
64
|
/* Diff: what a proposal adds, changes, removes and edits (the map draws the same four) */
|
|
55
65
|
--corn-added: #2dd4bf;
|
|
56
66
|
--corn-changed: #fbbf24;
|
|
57
|
-
--corn-removed: #
|
|
58
|
-
--corn-edit: #
|
|
67
|
+
--corn-removed: #fa9292;
|
|
68
|
+
--corn-edit: #b49cfb;
|
|
59
69
|
/* The same as text: mixed toward the text colour, so it reads on either ground */
|
|
60
70
|
--corn-added-text: color-mix(in srgb, var(--corn-added) 60%, var(--corn-text));
|
|
61
71
|
--corn-edit-text: color-mix(in srgb, var(--corn-edit) 60%, var(--corn-text));
|
|
@@ -212,10 +222,10 @@
|
|
|
212
222
|
--corn-bad: #b91c1c;
|
|
213
223
|
--corn-info: #03679e;
|
|
214
224
|
|
|
215
|
-
--corn-added: #
|
|
216
|
-
--corn-changed: #
|
|
217
|
-
--corn-removed: #
|
|
218
|
-
--corn-edit: #
|
|
225
|
+
--corn-added: #197c6f;
|
|
226
|
+
--corn-changed: #8f6703;
|
|
227
|
+
--corn-removed: #e20b0b;
|
|
228
|
+
--corn-edit: #6839f6;
|
|
219
229
|
|
|
220
230
|
--corn-hue-orange: #c2410c;
|
|
221
231
|
--corn-hue-fuchsia: #a21caf;
|
|
@@ -261,10 +271,10 @@
|
|
|
261
271
|
--corn-bad: #b91c1c;
|
|
262
272
|
--corn-info: #03679e;
|
|
263
273
|
|
|
264
|
-
--corn-added: #
|
|
265
|
-
--corn-changed: #
|
|
266
|
-
--corn-removed: #
|
|
267
|
-
--corn-edit: #
|
|
274
|
+
--corn-added: #197c6f;
|
|
275
|
+
--corn-changed: #8f6703;
|
|
276
|
+
--corn-removed: #e20b0b;
|
|
277
|
+
--corn-edit: #6839f6;
|
|
268
278
|
|
|
269
279
|
--corn-hue-orange: #c2410c;
|
|
270
280
|
--corn-hue-fuchsia: #a21caf;
|