cornfield 0.41.0 → 0.42.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 +1 -0
- package/core/strings.js +9 -0
- package/explorer/decision-model.js +231 -0
- package/explorer/explorer.css +28 -1
- package/explorer/forge-panel.js +28 -5
- package/explorer/index.html +4 -1
- package/explorer/proposal-model.js +24 -0
- package/explorer/proposal.js +13 -6
- package/explorer/review-column.js +22 -4
- package/explorer/review.js +413 -44
- package/explorer/runs-model.js +1 -1
- package/explorer/state.js +4 -0
- package/explorer/whatif.js +84 -7
- package/package.json +1 -1
- package/server/decision.js +117 -0
- package/server/proposal-pulls.js +1 -1
- package/server/proposals.js +58 -9
- package/server/server.js +19 -2
- package/server/submit-review.js +52 -7
package/core/contrast.js
CHANGED
|
@@ -381,6 +381,7 @@ export const PAINTED_TEXT = Object.freeze([
|
|
|
381
381
|
['--corn-bad', tint('--corn-removed', 12), 'a What-if or review message'],
|
|
382
382
|
['--corn-bad', tint('--corn-removed', 16), 'a refused check'],
|
|
383
383
|
['--corn-warn', tint('--corn-changed', 16), 'a mismatched check'],
|
|
384
|
+
['--corn-text', tint('--corn-warn', 14), 'the question Approve asks in place (spec 0007)'],
|
|
384
385
|
['--corn-text-2', tint('--corn-text-3', 12), 'a verdict, a cloud badge'], ['--corn-text-3', tint('--corn-text-3', 12), 'a cloud plan not known'],
|
|
385
386
|
['--corn-text-2', tint('--corn-text-3', 10), 'a check'],
|
|
386
387
|
['--corn-text-2', tint('--corn-text-2', 12), 'a web badge'],
|
package/core/strings.js
CHANGED
|
@@ -33,6 +33,15 @@ export const STRINGS = Object.freeze({
|
|
|
33
33
|
approve: 'Approve',
|
|
34
34
|
sendBack: 'Send back',
|
|
35
35
|
sendBackWithNote: 'Send back with this note',
|
|
36
|
+
// The decision (spec 0007): asking in place, the hold, what an approval reads afterwards, the toggle for your edits, a landing that waits, a run that will wait
|
|
37
|
+
approveAnyway: 'Approve anyway',
|
|
38
|
+
sendBackAnyway: 'Send back anyway',
|
|
39
|
+
undo: 'Undo',
|
|
40
|
+
approved: 'Approved',
|
|
41
|
+
myEdits: 'My edits',
|
|
42
|
+
yourEdits: 'Your edits',
|
|
43
|
+
cancelLanding: 'Cancel landing',
|
|
44
|
+
queueIt: 'Queue it',
|
|
36
45
|
reviewNoteLabel: 'Note for the drafting agent',
|
|
37
46
|
reviewNotePlaceholder: 'What should change?',
|
|
38
47
|
openSpecsList: 'Open the Specs list',
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module explorer/decision-model
|
|
3
|
+
*
|
|
4
|
+
* The pure half of the decision (spec 0007): what the line above Approve says in this exact state (D1), whether a press is allowed, asks first
|
|
5
|
+
* or is refused (D2), the words of the hold (D3) and of what is sent with a review (D4). No DOM, no `window`, no clock (the time is passed in).
|
|
6
|
+
* review.js is the half that touches the page; the words and the choices are here so each row of the spec's two tables is a test.
|
|
7
|
+
*
|
|
8
|
+
* The facts come from `GET /proposals/<slug>/decision` (server/decision.js): `{ pull: { number, draft, head }, checks: { total, passed, running,
|
|
9
|
+
* failed: [names] } | null, lands, landing, run: null | { kind, transport, runner, lastSeen, open, fired } }`. Everything in them from the forge (names) is text,
|
|
10
|
+
* and it only ever becomes text: this module builds strings, never markup. The server decides; these words are a courtesy before the click.
|
|
11
|
+
*
|
|
12
|
+
* decide(input) { line, approve: 'allowed' | 'asks' | 'done' | 'refused' | 'reading', reasons, ask, askButton }
|
|
13
|
+
* sendBackLine(...) the line under the note: "Posts your note and 2 edits on PR #23 for the drafting agent. No run is asked for."
|
|
14
|
+
* sendBackDecision(...) whether Send back asks (an open form), and the words
|
|
15
|
+
* newReasons(...) the reasons to ask that the maintainer has not already answered (the end of the hold reads the facts again)
|
|
16
|
+
* refusalWords(...) the server's 401 and 403 at the press, in words
|
|
17
|
+
* holdWords / HOLD_MS "Approving in 5 s", and the hold itself (one constant)
|
|
18
|
+
* editsSentWords(n) "Sent with 2 edits"
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { agoShort } from './runs-model.js';
|
|
22
|
+
import { pullNumberOf } from './proposal-model.js';
|
|
23
|
+
|
|
24
|
+
/** The hold between a press and anything leaving the page (D3), in milliseconds: one constant */
|
|
25
|
+
export const HOLD_MS = 5000;
|
|
26
|
+
/** How long a landing waits for the PR to be ready and green, in minutes (server/lander.js TIMEOUT_MS; test/server/decision.test.js holds them equal) */
|
|
27
|
+
export const LAND_MINUTES = 60;
|
|
28
|
+
/** The most check names a line spells out; the rest is "and N more" */
|
|
29
|
+
const NAMES_SHOWN = 3;
|
|
30
|
+
/** The longest a check's name is in a line (the forge's text, cut) */
|
|
31
|
+
const NAME_CHARS = 40;
|
|
32
|
+
|
|
33
|
+
const plural = (n, word) => `${n} ${word}${n === 1 ? '' : 's'}`;
|
|
34
|
+
const oneLine = (s) => String(s).replace(/\s+/g, ' ').trim();
|
|
35
|
+
const cut = (s) => { const t = oneLine(s); return t.length > NAME_CHARS ? `${t.slice(0, NAME_CHARS - 1)}…` : t; };
|
|
36
|
+
|
|
37
|
+
/** "lint", "lint and test", "lint, test and e2e", "lint, test, e2e and 2 more": names from the forge, as text */
|
|
38
|
+
export function nameList(names) {
|
|
39
|
+
const shown = names.slice(0, NAMES_SHOWN).map(cut);
|
|
40
|
+
const more = names.length - shown.length;
|
|
41
|
+
if (more > 0) return `${shown.join(', ')} and ${more} more`;
|
|
42
|
+
return shown.length < 2 ? shown.join('') : `${shown.slice(0, -1).join(', ')} and ${shown[shown.length - 1]}`;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const failedOf = (facts) => (facts && facts.checks && Array.isArray(facts.checks.failed) ? facts.checks.failed : []);
|
|
46
|
+
const runningOf = (facts) => (facts && facts.checks ? facts.checks.running || 0 : 0);
|
|
47
|
+
|
|
48
|
+
/** "lint failed", "lint and test failed", "3 checks failed"-less: always the names */
|
|
49
|
+
const failedWords = (names) => `${nameList(names)} failed`;
|
|
50
|
+
|
|
51
|
+
// ---------------------------------------------------------------------------
|
|
52
|
+
// The line (D1)
|
|
53
|
+
// ---------------------------------------------------------------------------
|
|
54
|
+
|
|
55
|
+
/** What an approval asks for besides posting, and whether the runner is there: the parts after the PR's (D1's last four rows) */
|
|
56
|
+
export function runWords(run, nowMs) {
|
|
57
|
+
if (!run) return '';
|
|
58
|
+
const kind = ['code', 'summary', 'brief', 'proposal'].includes(run.kind) ? run.kind : 'code';
|
|
59
|
+
const what = kind === 'code' ? 'a code run' : `a ${kind} run`;
|
|
60
|
+
// The trigger skips a run while one is open on the PR or the proposal, and asks once per head: the line must not promise one
|
|
61
|
+
if (run.open) return `No new run is asked for: ${typeof run.open === 'string' ? `run ${oneLine(run.open).slice(0, 40)} is` : 'one is'} still open on it.`;
|
|
62
|
+
if (run.fired) return `No new run is asked for: ${what} was asked for at this head already.`;
|
|
63
|
+
const asked = `Then ${what} is asked for.`;
|
|
64
|
+
if (run.transport !== 'pull') return `${asked} The request is posted for your runner.`;
|
|
65
|
+
if (run.runner === 'online') return `${asked} A runner is online.`;
|
|
66
|
+
const seen = typeof run.lastSeen === 'string' ? Date.parse(run.lastSeen) : NaN;
|
|
67
|
+
if (run.runner === 'quiet' && Number.isFinite(seen)) return `${asked} No runner has polled for ${agoShort(nowMs - seen)}: the run will wait.`;
|
|
68
|
+
return `${asked} No runner has polled yet: the run will wait.`;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Whether a run would wait for a runner that is not there: the Work button's dot and the notices say so (#183) */
|
|
72
|
+
export const runWaits = (run) => !!run && run.transport === 'pull' && (run.runner === 'quiet' || run.runner === 'never');
|
|
73
|
+
|
|
74
|
+
/** "Your 2 edits go in the comment, for the agent to fold in." */
|
|
75
|
+
export const editsWords = (edits) => (edits > 0 ? `Your ${plural(edits, 'edit')} ${edits === 1 ? 'goes' : 'go'} in the comment, for the agent to fold in.` : '');
|
|
76
|
+
|
|
77
|
+
/** The PR and its checks, and what landing does about them: the first parts of the line (D1's first nine rows) */
|
|
78
|
+
function pullWords(facts) {
|
|
79
|
+
const n = facts.pull.number;
|
|
80
|
+
const lands = !!facts.lands;
|
|
81
|
+
if (facts.pull.draft) {
|
|
82
|
+
return lands
|
|
83
|
+
? `PR #${n} is a draft. Approve posts an approval; it lands only if the PR is marked ready within ${LAND_MINUTES} minutes.`
|
|
84
|
+
: `PR #${n} is a draft. Approve posts an approval on it.`;
|
|
85
|
+
}
|
|
86
|
+
const head = `Approve posts an approval on PR #${n}.`;
|
|
87
|
+
const checks = facts.checks;
|
|
88
|
+
const failed = failedOf(facts);
|
|
89
|
+
const running = runningOf(facts);
|
|
90
|
+
if (failed.length) return lands ? `${head} It will not land: ${failedWords(failed)}.` : `${head} ${failedWords(failed)}.`;
|
|
91
|
+
if (checks && checks.total === 0) return lands ? `${head} It will not land: the PR has no checks.` : `${head} It does not land it.`;
|
|
92
|
+
if (running) {
|
|
93
|
+
if (!lands) return `${head} ${running === 1 ? '1 check is' : `${running} checks are`} still running.`;
|
|
94
|
+
return `${head} It lands once ${running === 1 ? '1 running check passes' : `${running} running checks pass`}.`;
|
|
95
|
+
}
|
|
96
|
+
if (checks && !checks.passed) return lands ? `${head} It will not land: no check has passed.` : `${head} It does not land it.`; // all skipped or neutral
|
|
97
|
+
return lands ? `Approve posts an approval on PR #${n} and lands it.` : `${head} It does not land it.`;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** The line while Approve reads Approved: what stands, and what makes it live again */
|
|
101
|
+
function doneWords(n, facts) {
|
|
102
|
+
const landing = facts && facts.landing ? ' Its landing waits for the checks.' : '';
|
|
103
|
+
return `An approval of this version of PR #${n} stands.${landing} A push makes Approve live again.`;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Why a press asks first, in the order of D2's table (checks failed, a draft, an open form, edits with landing). Each is `{ key, text }` where
|
|
108
|
+
* `text` is the reason as a sentence; the question follows it.
|
|
109
|
+
* @param {{ facts: object|null, edits: number, form: { name: string } | null }} input
|
|
110
|
+
*/
|
|
111
|
+
export function askReasons({ facts, edits = 0, form = null }) {
|
|
112
|
+
const out = [];
|
|
113
|
+
if (facts && facts.pull) {
|
|
114
|
+
const failed = failedOf(facts);
|
|
115
|
+
if (failed.length) out.push({ key: 'failed', text: `${failedWords(failed)} on PR #${facts.pull.number}.` });
|
|
116
|
+
if (facts.pull.draft) out.push({ key: 'draft', text: `PR #${facts.pull.number} is a draft: its author has not marked it ready.` });
|
|
117
|
+
}
|
|
118
|
+
if (form) out.push({ key: 'form', text: `Your ${oneLine(form.name)} form is not added.` });
|
|
119
|
+
if (facts && facts.pull && facts.lands && edits > 0) out.push({ key: 'edits', text: `PR #${facts.pull.number} lands as written; your ${plural(edits, 'edit')} only go${edits === 1 ? 'es' : ''} in the comment.` });
|
|
120
|
+
return out;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** The question for the reasons that ask: one reason ends as D2's table does, several are said together and end "Approve anyway?" */
|
|
124
|
+
export function askWords(reasons, verb = 'Approve') {
|
|
125
|
+
if (!reasons.length) return '';
|
|
126
|
+
const only = reasons.length === 1 ? reasons[0] : null;
|
|
127
|
+
const last = only && only.key === 'form' ? `${verb} without it?` : `${verb} anyway?`;
|
|
128
|
+
return `${reasons.map((r) => r.text).join(' ')} ${last}`;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** The reasons that ask now and the maintainer has not answered yet (`answered`: the keys confirmed with "Approve anyway"): at the end of the hold, only a new one asks again */
|
|
132
|
+
export const newReasons = (reasons, answered) => reasons.filter((r) => !answered.includes(r.key));
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* The line above Approve and what a press of it does, from the facts and the page's own state.
|
|
136
|
+
* @param {object} input
|
|
137
|
+
* @param {string|null} input.source the proposal's source: `pull/<n>`, `checkout` or a worktree
|
|
138
|
+
* @param {object|null} input.facts the route's answer, or null
|
|
139
|
+
* @param {'loading'|'ready'|'unread'} input.factsState `loading` before the first answer, `unread` when it could not be read
|
|
140
|
+
* @param {{ verdict: string, current?: boolean }|null} [input.review] the last review of the proposal
|
|
141
|
+
* @param {number} [input.edits] the applied what-if edits
|
|
142
|
+
* @param {{ name: string }|null} [input.form] a what-if form that is open with something in it
|
|
143
|
+
* @param {string} [input.played] "2 of 3 scenarios played", when there is a record
|
|
144
|
+
* @param {number} [input.now]
|
|
145
|
+
* @returns {{ line: string, approve: 'allowed'|'asks'|'done'|'refused'|'reading', reasons: {key:string,text:string}[], ask: string }}
|
|
146
|
+
*/
|
|
147
|
+
export function decide({ source, facts, factsState, review = null, edits = 0, form = null, played = '', now = Date.now() }) {
|
|
148
|
+
const n = pullNumberOf(source);
|
|
149
|
+
const tail = (...parts) => parts.filter(Boolean).join(' ');
|
|
150
|
+
if (!n) {
|
|
151
|
+
const where = !source || source === 'checkout' ? 'the checkout' : `worktree ${oneLine(source)}`;
|
|
152
|
+
return { line: `Draft in ${where}: push it as a spec PR to review it here.`, approve: 'refused', reasons: [], ask: '' };
|
|
153
|
+
}
|
|
154
|
+
const done = !!review && review.verdict === 'approved' && review.current === true;
|
|
155
|
+
if (factsState === 'loading' || (!facts && factsState !== 'unread')) {
|
|
156
|
+
return { line: tail(`Reading PR #${n} …`, played), approve: done ? 'done' : 'reading', reasons: [], ask: '' };
|
|
157
|
+
}
|
|
158
|
+
if (!facts || factsState === 'unread') {
|
|
159
|
+
return { line: tail(`Could not read PR #${n}'s checks. Approve posts an approval on it.`, editsWords(edits), played), approve: done ? 'done' : 'allowed', reasons: askReasons({ facts: null, edits, form }), ask: '' };
|
|
160
|
+
}
|
|
161
|
+
const reasons = askReasons({ facts, edits, form });
|
|
162
|
+
const run = facts.run ? runWords(facts.run, now) : '';
|
|
163
|
+
const line = tail(pullWords(facts), run, editsWords(edits), played);
|
|
164
|
+
// Approve does nothing now (an approval of this version stands): the line says that, not what a press would post
|
|
165
|
+
if (done) return { line: tail(doneWords(n, facts), played), approve: 'done', reasons, ask: '' };
|
|
166
|
+
return { line, approve: reasons.length ? 'asks' : 'allowed', reasons, ask: askWords(reasons) };
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// ---------------------------------------------------------------------------
|
|
170
|
+
// Send back (D4)
|
|
171
|
+
// ---------------------------------------------------------------------------
|
|
172
|
+
|
|
173
|
+
/** The line under the note: what Send back posts, and that it asks for no run */
|
|
174
|
+
export function sendBackLine({ source, edits = 0 }) {
|
|
175
|
+
const n = pullNumberOf(source);
|
|
176
|
+
if (!n) return '';
|
|
177
|
+
const what = edits > 0 ? `your note and ${plural(edits, 'edit')}` : 'your note';
|
|
178
|
+
return `Posts ${what} on PR #${n} for the drafting agent. No run is asked for.`;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/** Whether Send back asks first: only an open form that holds input does (D4). `{ asks, ask }` */
|
|
182
|
+
export function sendBackDecision({ form = null }) {
|
|
183
|
+
const reasons = askReasons({ facts: null, edits: 0, form });
|
|
184
|
+
return { asks: reasons.length > 0, reasons, ask: askWords(reasons, 'Send back') };
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// ---------------------------------------------------------------------------
|
|
188
|
+
// The server's refusals at the press (D2), in words
|
|
189
|
+
// ---------------------------------------------------------------------------
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* What a refused review says. 401: the sign-in has ended; 403: the server's own words (a maintainer who is one no longer, a page that is not
|
|
193
|
+
* cornfield's own); 409: what stands already. Anything else is the server's words with the plain statement that nothing was posted.
|
|
194
|
+
* @param {number} status
|
|
195
|
+
* @param {string} [error] the server's words
|
|
196
|
+
*/
|
|
197
|
+
export function refusalWords(status, error = '') {
|
|
198
|
+
if (status === 401) return 'Your sign-in has ended. Sign in again: your edits are kept here.';
|
|
199
|
+
const said = oneLine(error);
|
|
200
|
+
if (status === 403 || status === 409) return said || 'The review was not posted.';
|
|
201
|
+
return `The review was not posted. ${said || `The server answered ${status}.`}`;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// ---------------------------------------------------------------------------
|
|
205
|
+
// The hold (D3)
|
|
206
|
+
// ---------------------------------------------------------------------------
|
|
207
|
+
|
|
208
|
+
/** The button's words while the hold runs: "Approving in 5 s", "Sending back in 4 s" */
|
|
209
|
+
export const holdWords = (verdict, seconds) => `${verdict === 'approved' ? 'Approving' : 'Sending back'} in ${Math.max(0, Math.ceil(seconds))} s`;
|
|
210
|
+
|
|
211
|
+
/** What is said once when the hold starts (a live region): not every second */
|
|
212
|
+
export const holdStartWords = (verdict, seconds) => `${verdict === 'approved' ? 'Approving' : 'Sending back'} in ${plural(Math.ceil(seconds), 'second')}. Undo to stop it; nothing has been sent.`;
|
|
213
|
+
|
|
214
|
+
/** What is said when a hold is cancelled, and why: it always ends "Nothing was sent." */
|
|
215
|
+
export function holdCancelledWords(verdict, why) {
|
|
216
|
+
const what = verdict === 'approved' ? 'The approval' : 'The send back';
|
|
217
|
+
const because = {
|
|
218
|
+
undo: `${what} was undone.`,
|
|
219
|
+
escape: `${what} was undone.`,
|
|
220
|
+
closed: `${what} was stopped: the proposal was closed.`,
|
|
221
|
+
other: `${what} was stopped: another proposal was opened.`,
|
|
222
|
+
hidden: `${what} was stopped: this tab was hidden.`,
|
|
223
|
+
offline: `${what} was stopped: you are offline.`,
|
|
224
|
+
edits: `${what} was stopped: your edits changed.`,
|
|
225
|
+
pushed: `${what} was stopped: the PR was pushed to while it was held, so it is not what you looked at. Look again before you decide.`,
|
|
226
|
+
}[why] || `${what} was stopped.`;
|
|
227
|
+
return `${because} Nothing was sent.`;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/** What a send back leaves readable: "Sent with 2 edits" (D4) */
|
|
231
|
+
export const editsSentWords = (count) => `Sent with ${plural(count, 'edit')}`;
|
package/explorer/explorer.css
CHANGED
|
@@ -642,7 +642,7 @@ h2.hx-proposal-name { margin: 0; }
|
|
|
642
642
|
.hx-proposal-bar[data-sheet-state="peek"] > :not(.hx-sheet-handle):not(#proposal-message):not(#proposal-ways):not(#proposal-body),
|
|
643
643
|
.hx-proposal-bar[data-sheet-state="peek"] #proposal-body > :not(.hx-proposal-head),
|
|
644
644
|
.hx-proposal-bar[data-sheet-state="peek"] .hx-proposal-head > :is(.hx-proposal-tools, .hx-proposal-more, .hx-proposal-more-menu) { display: none; }
|
|
645
|
-
.hx-proposal-bar[data-sheet-state="peek"] .hx-review > :not([data-review-hint]):not([data-review-msg]) { display: none; } /* the peek keeps the
|
|
645
|
+
.hx-proposal-bar[data-sheet-state="peek"] .hx-review > :not([data-review-hint]):not([data-review-msg]):not([data-review-line]):not([data-review-ask]):not([data-review-hold]):not([data-review-hold-live]):not([data-review-landing]) { display: none; } /* the peek keeps the line Approve points at, the question, the hold, a landing that waits, and a refusal */
|
|
646
646
|
.hx-proposal-bar[data-sheet-state="expanded"] .hx-whatif-panel { max-height: none; overflow: visible; }
|
|
647
647
|
|
|
648
648
|
/* The scenario player: one row (Previous, Pause, Next, the counter and Close) in the peek; the text, the speed and the checks when it is open */
|
|
@@ -1420,3 +1420,30 @@ a.hx-proposal-source:focus-visible { outline: var(--corn-focus-width) solid var(
|
|
|
1420
1420
|
.hx-dock > .hx-proposal-bar[data-sheet-state="expanded"], .hx-dock > .hx-player[data-sheet-state="expanded"] { max-height: min(var(--hx-sheet-cap, 50dvh), 50dvh); }
|
|
1421
1421
|
.hx-dock > .hx-drawer[data-sheet-state="expanded"], .hx-dock > .hx-forge[data-sheet-state="expanded"] { max-height: min(var(--hx-sheet-cap, 60dvh), 60dvh); }
|
|
1422
1422
|
}
|
|
1423
|
+
|
|
1424
|
+
/* ===== Spec 0007: the decision. The line above Approve, the question asked in place, the hold with Undo, a landing that waits, what a send back carried ===== */
|
|
1425
|
+
.hx-decision-line { margin: 0; color: var(--corn-text-2); font-size: var(--corn-text-sm); line-height: 1.45; }
|
|
1426
|
+
.hx-decision-line[hidden], .hx-review-ask[hidden], .hx-hold[hidden], .hx-review-landing[hidden], .hx-sent-edits[hidden] { display: none; }
|
|
1427
|
+
.hx-review-ask { margin: 0; padding: var(--corn-space-2) var(--corn-space-3); border-radius: var(--corn-radius-sm); border: var(--corn-border) solid color-mix(in srgb, var(--corn-warn) 55%, transparent); background: color-mix(in srgb, var(--corn-warn) 14%, transparent); color: var(--corn-text); line-height: 1.4; }
|
|
1428
|
+
.hx-review-landing { display: flex; align-items: center; justify-content: space-between; gap: var(--corn-space-3); padding: var(--corn-space-2) var(--corn-space-3); border-radius: var(--corn-radius-sm); border: var(--corn-border) solid var(--corn-line); color: var(--corn-text-2); }
|
|
1429
|
+
.hx-review-landing p { margin: 0; line-height: 1.4; }
|
|
1430
|
+
.hx-sent-edits { color: var(--corn-text-2); }
|
|
1431
|
+
.hx-sent-edits summary { cursor: pointer; min-height: 24px; }
|
|
1432
|
+
.hx-hold { height: 3px; border-radius: var(--corn-radius-sm); background: color-mix(in srgb, var(--corn-accent) 22%, transparent); overflow: hidden; }
|
|
1433
|
+
.hx-hold-fill { display: block; height: 100%; width: 100%; background: var(--corn-accent); transform-origin: left center; animation-name: hx-hold-drain; animation-timing-function: linear; animation-fill-mode: forwards; }
|
|
1434
|
+
@keyframes hx-hold-drain { from { transform: scaleX(1); } to { transform: scaleX(0); } }
|
|
1435
|
+
.hx-proposal-actions .hx-btn[aria-disabled="true"] { opacity: 0.55; cursor: default; }
|
|
1436
|
+
.hx-proposal-actions .hx-btn[data-holding="true"] { opacity: 1; font-variant-numeric: tabular-nums; }
|
|
1437
|
+
.hx-review-undo[hidden] { display: none; }
|
|
1438
|
+
@media (max-width: 767px) {
|
|
1439
|
+
.hx-review-undo { min-height: 44px; min-width: 44px; order: 1; grid-column: 1 / -1; } /* a row of its own under Send back and Approve: never where the finger that pressed is */
|
|
1440
|
+
.hx-review-landing .hx-btn { min-height: 44px; }
|
|
1441
|
+
.hx-proposal-bar:has(.hx-review-form:not([hidden])) .hx-decision-line { display: none; } /* the note's sheet shows the send back line under the note, not Approve's */
|
|
1442
|
+
}
|
|
1443
|
+
@media (prefers-reduced-motion: reduce) { .hx-hold { display: none; } .hx-hold-fill { animation: none; } } /* only the words count down */
|
|
1444
|
+
.hx-rc-sub { margin: var(--corn-space-2) 0 var(--corn-space-1); font-size: var(--corn-text-sm); font-weight: 600; color: var(--corn-text); }
|
|
1445
|
+
.hx-proposal-yours { display: inline-flex; align-items: center; gap: var(--corn-space-1); color: var(--corn-text-2); }
|
|
1446
|
+
.hx-proposal-tools [aria-pressed="false"] { opacity: 0.8; }
|
|
1447
|
+
.hx-whatif-row [aria-disabled="true"] { opacity: 0.55; cursor: default; }
|
|
1448
|
+
.hx-runner-dot { display: inline-block; width: 8px; height: 8px; margin-left: var(--corn-space-1); border-radius: 50%; background: var(--corn-warn); vertical-align: middle; }
|
|
1449
|
+
.hx-runner-dot[hidden] { display: none; }
|
package/explorer/forge-panel.js
CHANGED
|
@@ -1538,13 +1538,32 @@ function graftAround(root, keep, twin) {
|
|
|
1538
1538
|
}
|
|
1539
1539
|
}
|
|
1540
1540
|
|
|
1541
|
-
/**
|
|
1541
|
+
/** Whether a run would wait for a runner that is not there (pull transport only; issue #183, spec 0007 D1) */
|
|
1542
|
+
function runnerAway() {
|
|
1543
|
+
const data = ui.runs && ui.runs.data;
|
|
1544
|
+
const state = data ? runnerState(data.runnerPresence, now()) : null;
|
|
1545
|
+
return state === 'offline' || state === 'none';
|
|
1546
|
+
}
|
|
1547
|
+
|
|
1548
|
+
/** The Start dialog's button: "Ask the runner", or "Queue it (no runner online)" while no runner polls, so the click says what it does */
|
|
1549
|
+
function askRunnerWords() {
|
|
1550
|
+
return runnerAway() ? `${t('queueIt')} (no runner online)` : t('askRunner');
|
|
1551
|
+
}
|
|
1552
|
+
|
|
1553
|
+
/**
|
|
1554
|
+
* The one line on whether a runner is polling (pull transport only), in the Runs view and the Start dialog; hidden where it does not apply.
|
|
1555
|
+
* While no runner is online it is a notice at the top of the view, not the faint line: a run asked for would wait (issue #183).
|
|
1556
|
+
*/
|
|
1542
1557
|
function paintRunner(id, data) {
|
|
1543
1558
|
const el = $(id);
|
|
1544
1559
|
if (!el) return;
|
|
1545
1560
|
const words = data ? runnerWords(data.runnerPresence, now()) : '';
|
|
1546
1561
|
el.hidden = !words;
|
|
1547
1562
|
el.textContent = words;
|
|
1563
|
+
const state = data ? runnerState(data.runnerPresence, now()) : null;
|
|
1564
|
+
const away = state === 'offline' || state === 'none';
|
|
1565
|
+
el.className = away ? 'hx-forge-notice' : 'hx-forge-meta';
|
|
1566
|
+
if (away) { el.dataset.corn = 'notice'; el.dataset.cornState = 'waiting'; } else { delete el.dataset.corn; delete el.dataset.cornState; }
|
|
1548
1567
|
}
|
|
1549
1568
|
|
|
1550
1569
|
/** What the Runs view needs to know of the page */
|
|
@@ -1618,12 +1637,16 @@ function paintButton() {
|
|
|
1618
1637
|
tag.textContent = ui.runSel ? 'run' : ui.thread !== null ? `thread #${ui.thread}` : ui.deployItem ? 'deploy' : lit ? `#${ui.selected}` : '';
|
|
1619
1638
|
}
|
|
1620
1639
|
const n = waitingNow().total;
|
|
1640
|
+
// A run would wait for a runner that is not there: a dot, and the name says so (issue #183); it sits beside the waiting badge, not on it
|
|
1641
|
+
const away = runnerAway();
|
|
1642
|
+
const dot = $('forge-btn-dot');
|
|
1643
|
+
if (dot) dot.hidden = !away;
|
|
1621
1644
|
const badge = $('forge-btn-waiting');
|
|
1622
1645
|
if (badge) {
|
|
1623
1646
|
badge.hidden = n === 0;
|
|
1624
1647
|
badge.textContent = n ? String(n) : '';
|
|
1625
1648
|
}
|
|
1626
|
-
btn.setAttribute('aria-label', `${workButtonName(t('issuesAndPrs'), n)}${ui.runSel ? ', a run lit on the map' : ui.thread !== null ? `, thread ${ui.thread} selected` : ui.deployItem ? ', a deploy selected' : lit ? `, pull request ${ui.selected} selected` : ''}`);
|
|
1649
|
+
btn.setAttribute('aria-label', `${workButtonName(t('issuesAndPrs'), n)}${away ? ', no runner online' : ''}${ui.runSel ? ', a run lit on the map' : ui.thread !== null ? `, thread ${ui.thread} selected` : ui.deployItem ? ', a deploy selected' : lit ? `, pull request ${ui.selected} selected` : ''}`);
|
|
1627
1650
|
}
|
|
1628
1651
|
|
|
1629
1652
|
// ---------------------------------------------------------------------------
|
|
@@ -1872,7 +1895,7 @@ async function openAgent(ref, opener, again = null, brief = null) {
|
|
|
1872
1895
|
const go = $('agent-start-go');
|
|
1873
1896
|
go.disabled = false;
|
|
1874
1897
|
go.removeAttribute('aria-busy');
|
|
1875
|
-
go.textContent =
|
|
1898
|
+
go.textContent = askRunnerWords();
|
|
1876
1899
|
document.addEventListener('focusin', keepFocusInAgent);
|
|
1877
1900
|
agentEl().hidden = false;
|
|
1878
1901
|
$('agent-kind').focus();
|
|
@@ -1962,7 +1985,7 @@ async function submitAgent(e) {
|
|
|
1962
1985
|
ui.agent.posting = false;
|
|
1963
1986
|
go.disabled = false;
|
|
1964
1987
|
go.removeAttribute('aria-busy');
|
|
1965
|
-
go.textContent =
|
|
1988
|
+
go.textContent = askRunnerWords();
|
|
1966
1989
|
const bad = $('agent-start-msg');
|
|
1967
1990
|
bad.textContent = `A limit is a number above zero, or blank for the config's (${wrong.join(', ')}).`;
|
|
1968
1991
|
bad.hidden = false;
|
|
@@ -1987,7 +2010,7 @@ async function submitAgent(e) {
|
|
|
1987
2010
|
}
|
|
1988
2011
|
go.disabled = false;
|
|
1989
2012
|
go.removeAttribute('aria-busy');
|
|
1990
|
-
go.textContent =
|
|
2013
|
+
go.textContent = askRunnerWords();
|
|
1991
2014
|
const msg = $('agent-start-msg');
|
|
1992
2015
|
msg.textContent = text;
|
|
1993
2016
|
msg.hidden = false;
|
package/explorer/index.html
CHANGED
|
@@ -133,6 +133,7 @@
|
|
|
133
133
|
<span data-corn-string="issuesAndPrs">Work</span>
|
|
134
134
|
<span id="forge-btn-lit" class="hx-forge-lit" data-corn="count" hidden></span>
|
|
135
135
|
<!-- What waits on you (explorer/waiting-model.js): specs to decide plus runs that need an answer; hidden at 0 and for anyone not signed in -->
|
|
136
|
+
<span id="forge-btn-dot" class="hx-runner-dot" aria-hidden="true" title="No runner online" hidden></span>
|
|
136
137
|
<span id="forge-btn-waiting" class="hx-waiting-badge" data-corn="waiting-badge" aria-hidden="true" hidden></span>
|
|
137
138
|
</button>
|
|
138
139
|
|
|
@@ -228,6 +229,8 @@
|
|
|
228
229
|
<button data-corn="compare-option" type="button" class="hx-seg-btn" data-action="proposal-view" data-view="after" aria-pressed="false" data-corn-string="after">After</button>
|
|
229
230
|
</div>
|
|
230
231
|
<div class="hx-proposal-tools">
|
|
232
|
+
<!-- Shown only while there are what-if edits: off, the map is the proposal as written; the edits are kept and still go with a review (whatif.js) -->
|
|
233
|
+
<button data-corn-kind="secondary" type="button" id="proposal-myedits" class="hx-btn" aria-pressed="true" data-peek-ok data-corn-string="myEdits" hidden>My edits</button>
|
|
231
234
|
<button data-corn-kind="secondary" type="button" id="proposal-edit" class="hx-btn" aria-expanded="false" aria-controls="whatif" title="Try a change: add a node or an edge, reword a scenario">Edit</button>
|
|
232
235
|
</div>
|
|
233
236
|
<div class="hx-proposal-more">
|
|
@@ -325,8 +328,8 @@
|
|
|
325
328
|
<!-- Agent runs (forge-panel.js, runs-model.js): shown on the Runs tab; each run's state, what it is about, links, and Stop -->
|
|
326
329
|
<section id="forge-runs" class="hx-forge-runs" aria-labelledby="forge-runs-title" hidden>
|
|
327
330
|
<h3 id="forge-runs-title" class="hx-forge-runs-title">Agent runs</h3>
|
|
328
|
-
<p id="forge-runs-status" class="hx-forge-meta hx-faint"></p>
|
|
329
331
|
<p id="forge-runs-runner" class="hx-forge-meta" hidden></p>
|
|
332
|
+
<p id="forge-runs-status" class="hx-forge-meta hx-faint"></p>
|
|
330
333
|
<p id="forge-runs-note" class="hx-forge-notice" hidden data-corn="notice"></p>
|
|
331
334
|
<p id="forge-runs-trigger" class="hx-forge-notice" hidden data-corn="notice"></p>
|
|
332
335
|
<div id="forge-runs-totals" data-corn="run-totals" role="group" aria-label="Tokens and cost the runners reported" hidden></div>
|
|
@@ -541,3 +541,27 @@ export function pinLanes(flow, baseFlow) {
|
|
|
541
541
|
flow.top = top;
|
|
542
542
|
return true;
|
|
543
543
|
}
|
|
544
|
+
|
|
545
|
+
/**
|
|
546
|
+
* The reviewer's own what-if edits, counted apart from the proposal's (spec 0007 D5): "yours: +1 node, 1 step changed". Never added to the proposal's
|
|
547
|
+
* numbers, so the reviewer can still tell what the agent proposed. Empty for no edits.
|
|
548
|
+
* @param {{ op?: string }[]} edits the applied edits (whatif-model.js)
|
|
549
|
+
* @param {boolean} [hidden] My edits is off: the map does not show them
|
|
550
|
+
* @returns {string}
|
|
551
|
+
*/
|
|
552
|
+
export function yoursText(edits, hidden = false) {
|
|
553
|
+
const list = Array.isArray(edits) ? edits : [];
|
|
554
|
+
if (!list.length) return '';
|
|
555
|
+
const n = (ops) => list.filter((e) => e && ops.includes(e.op)).length;
|
|
556
|
+
const unit = (k, word) => `${k} ${word}${k === 1 ? '' : 's'}`;
|
|
557
|
+
const parts = [];
|
|
558
|
+
if (n(['add-node'])) parts.push(`+${unit(n(['add-node']), 'node')}`);
|
|
559
|
+
if (n(['add-edge'])) parts.push(`+${unit(n(['add-edge']), 'edge')}`);
|
|
560
|
+
if (n(['remove-node'])) parts.push(`\u2212${unit(n(['remove-node']), 'node')}`);
|
|
561
|
+
if (n(['remove-edge'])) parts.push(`\u2212${unit(n(['remove-edge']), 'edge')}`);
|
|
562
|
+
const steps = n(['add-step', 'reword-step', 'delete-step', 'move-step']);
|
|
563
|
+
if (steps) parts.push(`${unit(steps, 'step')} changed`);
|
|
564
|
+
const rest = list.length - n(['add-node', 'add-edge', 'remove-node', 'remove-edge', 'add-step', 'reword-step', 'delete-step', 'move-step']);
|
|
565
|
+
if (rest > 0) parts.push(unit(rest, 'other edit'));
|
|
566
|
+
return `yours: ${parts.join(', ')}${hidden ? ' (hidden)' : ''}`;
|
|
567
|
+
}
|
package/explorer/proposal.js
CHANGED
|
@@ -29,6 +29,7 @@ import { looksWith, onMapStyleChange } from './map-style.js';
|
|
|
29
29
|
import {
|
|
30
30
|
PROPOSAL_VIEWS, MARK_WORDS, chipText, barCounts, parseProposalQuery, proposalPanelHtml, touchedIds, viewWords, jumpWords,
|
|
31
31
|
sourceChip, pullNumberOf, notFoundWords, otherCopies, malformedLinkWords,
|
|
32
|
+
yoursText,
|
|
32
33
|
} from './proposal-model.js';
|
|
33
34
|
import { renderReviewColumn, reviewOpenedLine, showSection, setPullHead } from './review-column.js';
|
|
34
35
|
import { applyProposal, edgeKey, proposalProblems, summarize } from '../core/proposal.js';
|
|
@@ -122,7 +123,8 @@ export async function openProposal(slug, source = null) {
|
|
|
122
123
|
const found = res.headers.get('X-Proposal-Source');
|
|
123
124
|
let item;
|
|
124
125
|
try { item = await res.json(); } catch { throw new Error(`${slug} could not be opened: cornfield sent a file this page could not read.`); }
|
|
125
|
-
|
|
126
|
+
const sha256 = res.headers.get('X-Proposal-Sha256'); // the version on screen: a review names it, so a push since is refused, not approved unseen
|
|
127
|
+
showProposal(item, { slug, source: source || (found ? decodeURIComponent(found) : null), pinSource: !!source, view: 'diff', fit: true, sha256 });
|
|
126
128
|
// said once, here: a proposal opens on a person's asking, never on a background refresh
|
|
127
129
|
announce(reviewOpenedLine($('proposal-title').textContent));
|
|
128
130
|
return true;
|
|
@@ -148,14 +150,16 @@ let openToken = 0;
|
|
|
148
150
|
/**
|
|
149
151
|
* Puts a parsed proposal on the map. The map's nodes and edges become `applyProposal(base, proposal)`.
|
|
150
152
|
* @param {object} proposal
|
|
151
|
-
* @param {{slug?: string|null, source?: string|null, pinSource?: boolean, view?: 'before'|'diff'|'after', fit?: boolean}} [opts]
|
|
153
|
+
* @param {{slug?: string|null, source?: string|null, pinSource?: boolean, view?: 'before'|'diff'|'after', fit?: boolean, sha256?: string|null}} [opts]
|
|
154
|
+
* `sha256`: the file's SHA-256 as the server sent it (X-Proposal-Sha256): a review names it (spec 0007)
|
|
152
155
|
* `fit`: fit the camera to what the proposal touches and what it connects to (default true).
|
|
153
156
|
* `pinSource`: put `&source=` in the address (it was asked for by name; otherwise `/?proposal=<slug>` finds the same one)
|
|
154
157
|
*/
|
|
155
|
-
export function showProposal(proposal, { slug = null, source = null, pinSource = false, view, fit = true } = {}) {
|
|
158
|
+
export function showProposal(proposal, { slug = null, source = null, pinSource = false, view, fit = true, sha256 = null } = {}) {
|
|
156
159
|
state.proposal = proposal;
|
|
157
160
|
state.proposalSlug = slug;
|
|
158
161
|
state.proposalSource = source;
|
|
162
|
+
state.proposalSha256 = typeof sha256 === 'string' && /^[0-9a-f]{64}$/.test(sha256) ? sha256 : null;
|
|
159
163
|
pinnedSource = pinSource;
|
|
160
164
|
if (view) state.proposalView = view;
|
|
161
165
|
else if (!PROPOSAL_VIEWS.includes(state.proposalView)) state.proposalView = 'diff';
|
|
@@ -198,6 +202,7 @@ export function closeProposal() {
|
|
|
198
202
|
state.effectiveProposal = null;
|
|
199
203
|
state.proposalSlug = null;
|
|
200
204
|
state.proposalSource = null;
|
|
205
|
+
state.proposalSha256 = null;
|
|
201
206
|
state.proposalErrors = [];
|
|
202
207
|
swapMap(state.baseNodes.map((n) => ({ ...n })), state.baseEdges);
|
|
203
208
|
fitGraphToViewport(fitPadding());
|
|
@@ -371,6 +376,9 @@ export function renderBar() {
|
|
|
371
376
|
if (!c.mark && /scenarios?$/.test(c.text)) return `<button type="button" class="hx-proposal-count" data-action="review-show-scenarios" data-corn-kind="quiet" title="Show the personas and their scenarios">${escHtml(c.text)}</button>`;
|
|
372
377
|
return `<button type="button" class="hx-proposal-count" data-action="review-show-changes" data-corn-kind="quiet" title="Show the list of changes">${dot}${escHtml(c.text)}</button>`;
|
|
373
378
|
}).join('<span class="hx-proposal-sep" aria-hidden="true"> · </span>');
|
|
379
|
+
// The reviewer's own edits are a part of their own, never added to the proposal's numbers (spec 0007 D5)
|
|
380
|
+
const yours = yoursText(state.whatIf && state.whatIf.edits, !!state.whatIfOff);
|
|
381
|
+
if (yours) chip.insertAdjacentHTML('beforeend', `<span class="hx-proposal-sep" aria-hidden="true"> · </span><span class="hx-proposal-count hx-proposal-yours"><span class="hx-mark-dot hx-mark-dot--edit" data-corn="mark-dot" data-corn-state="edit" aria-hidden="true"></span>${escHtml(yours)}</span>`);
|
|
374
382
|
$('proposal-mode').textContent = t(state.proposalView);
|
|
375
383
|
|
|
376
384
|
for (const btn of bar.querySelectorAll('[data-action="proposal-view"]')) {
|
|
@@ -394,14 +402,13 @@ export function renderBar() {
|
|
|
394
402
|
* Picks a row of the changes list: select it, centre it in the part of the map the review column, the node panel and (on a phone) the sheets leave free,
|
|
395
403
|
* at a zoom where its label reads, and make sure the current view shows it
|
|
396
404
|
*/
|
|
397
|
-
function focusChange(kind, key) {
|
|
405
|
+
export function focusChange(kind, key, { select = true } = {}) {
|
|
398
406
|
const item = kind === 'edge' ? state.edges.find((e) => edgeKey(e) === key) : state.nodes.find((n) => n.id === key);
|
|
399
407
|
if (!item) return;
|
|
400
408
|
const ends = (kind === 'edge' ? [state.nodes.find((n) => n.id === item.from), state.nodes.find((n) => n.id === item.to)] : [item]).filter(Boolean);
|
|
401
409
|
if (!ends.length) return;
|
|
402
410
|
if (state.proposalView !== 'diff' && ends.some((n) => !isNodeVisible(n))) setProposalView('diff', { quiet: true }); // Before or After hides what it removes or adds
|
|
403
|
-
if (kind === 'edge') showEdgePanel(item);
|
|
404
|
-
else selectNode(item);
|
|
411
|
+
if (select) { if (kind === 'edge') showEdgePanel(item); else selectNode(item); }
|
|
405
412
|
// The panel is open now, so what it covers is known
|
|
406
413
|
const cam = frameNodes(ends, visibleMapRect(), { padding: fitPadding(), maxZoom: Math.max(READ_ZOOM, state.camera.zoom), minZoom: getMinZoom() });
|
|
407
414
|
if (cam) Object.assign(state.camera, cam);
|
|
@@ -111,16 +111,19 @@ function model() {
|
|
|
111
111
|
return buildScenarioList({ scenarios: scenariosNow(), nodes: state.nodes, edges: state.edges, proposal, verdicts, seen: ui.seen, words, hidden });
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
+
/** The proposal's own changes: the reviewer's what-if edits are a group of their own (spec 0007 D5), never counted into them */
|
|
115
|
+
const theirRows = (proposal) => changeRows(state.nodes, state.edges, proposal).filter((r) => r.mark !== 'edit');
|
|
116
|
+
|
|
114
117
|
/** What opening a proposal says: "Opened Checkout: 6 changes, 3 scenarios for 2 personas." */
|
|
115
118
|
export function reviewOpenedLine(title) {
|
|
116
119
|
const proposal = state.effectiveProposal || state.proposal;
|
|
117
|
-
return reviewOpenedWords(title,
|
|
120
|
+
return reviewOpenedWords(title, theirRows(proposal).length, model());
|
|
118
121
|
}
|
|
119
122
|
|
|
120
123
|
/** The phone's peek line: "6 changes · 3 scenarios for 2 personas" */
|
|
121
124
|
export function reviewPeekLine() {
|
|
122
125
|
const proposal = state.effectiveProposal || state.proposal;
|
|
123
|
-
return reviewCounts(
|
|
126
|
+
return reviewCounts(theirRows(proposal).length, model());
|
|
124
127
|
}
|
|
125
128
|
|
|
126
129
|
// ---------------------------------------------------------------------------
|
|
@@ -167,7 +170,9 @@ function groupHtml(g) {
|
|
|
167
170
|
/** Everything the two lists say, as markup (the foot is static in index.html) */
|
|
168
171
|
function listsHtml() {
|
|
169
172
|
const proposal = state.effectiveProposal || state.proposal;
|
|
170
|
-
const
|
|
173
|
+
const everyRow = changeRows(state.nodes, state.edges, proposal);
|
|
174
|
+
const rows = everyRow.filter((r) => r.mark !== 'edit');
|
|
175
|
+
const mine = everyRow.filter((r) => r.mark === 'edit'); // "Your edits · 1": the first group, not the last row
|
|
171
176
|
const list = model();
|
|
172
177
|
const phone = isPhone();
|
|
173
178
|
// the phone's tab: the reviewer's last choice, or Scenarios when there are any; a proposal with none opens on its changes
|
|
@@ -181,6 +186,7 @@ function listsHtml() {
|
|
|
181
186
|
|
|
182
187
|
const changes = `<section id="rc-changes" class="hx-rc-section" data-corn="proposal-changes"${phone ? ` role="tabpanel" aria-labelledby="rc-tab-changes"${tab === 'changes' ? '' : ' hidden'}` : ' aria-labelledby="rc-changes-h"'}>`
|
|
183
188
|
+ `<h3 id="rc-changes-h" class="hx-rc-h" tabindex="-1">${countHeading(t('changes'), rows.length)}</h3>`
|
|
189
|
+
+ (mine.length ? `<h4 class="hx-rc-sub">${countHeading(t('yourEdits'), mine.length)}</h4><ul class="hx-change-list">${mine.map(changeRowHtml).join('')}</ul>` : '')
|
|
184
190
|
+ (rows.length ? `<ul class="hx-change-list">${rows.map(changeRowHtml).join('')}</ul>` : '<p class="hx-faint hx-rc-empty">This proposal changes nothing on the map.</p>')
|
|
185
191
|
+ '</section>';
|
|
186
192
|
|
|
@@ -190,7 +196,6 @@ function listsHtml() {
|
|
|
190
196
|
body = list.groups.map(groupHtml).join('');
|
|
191
197
|
if (!personas) body += `<p class="hx-faint hx-rc-note">This map has no personas (topology.personas.json), so every scenario is listed under ${escHtml(t('anyone'))}.</p>`;
|
|
192
198
|
if (list.coverage) body += `<p class="hx-rc-coverage" data-corn="notice">${escHtml(t('notInAnyScenario'))}: ${list.notInAny.map(escHtml).join(', ')}</p>`;
|
|
193
|
-
if (list.playedLine) body += `<p class="hx-faint hx-rc-note" data-corn="notice">${escHtml(list.playedLine)}</p>`;
|
|
194
199
|
}
|
|
195
200
|
const scenarios = `<section id="rc-scenarios" class="hx-rc-section" data-corn="scenario-list"${phone ? ` role="tabpanel" aria-labelledby="rc-tab-scenarios"${tab === 'scenarios' ? '' : ' hidden'}` : ' aria-labelledby="rc-scenarios-h"'}>`
|
|
196
201
|
+ `<h3 id="rc-scenarios-h" class="hx-rc-h" tabindex="-1">${countHeading(t('personasAndScenarios'), list.total)}</h3><div class="hx-rc-sbody">${body}</div></section>`;
|
|
@@ -254,6 +259,18 @@ export function shareRoom() {
|
|
|
254
259
|
col.style.setProperty('--hx-changes-max', `${Math.floor(Math.max(0.4 * h, h - need - gap))}px`);
|
|
255
260
|
}
|
|
256
261
|
|
|
262
|
+
/** "2 of 3 scenarios played", or '': the decision line says it (spec 0007 D1; it used to sit under the scenario list) */
|
|
263
|
+
export function playedLine() {
|
|
264
|
+
return state.proposal ? model().playedLine : '';
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
const paintWatchers = new Set();
|
|
268
|
+
/** `fn()` after the lists are drawn again: the decision line follows what was played */
|
|
269
|
+
export function onReviewColumnPaint(fn) {
|
|
270
|
+
paintWatchers.add(fn);
|
|
271
|
+
return () => paintWatchers.delete(fn);
|
|
272
|
+
}
|
|
273
|
+
|
|
257
274
|
function repaint() {
|
|
258
275
|
const lists = $('review-lists');
|
|
259
276
|
const col = $('review-column');
|
|
@@ -277,6 +294,7 @@ function repaint() {
|
|
|
277
294
|
if (again) again.focus();
|
|
278
295
|
}
|
|
279
296
|
shareRoom();
|
|
297
|
+
for (const fn of paintWatchers) fn();
|
|
280
298
|
}
|
|
281
299
|
|
|
282
300
|
// ---------------------------------------------------------------------------
|