cornfield 0.40.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 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'],
@@ -1,19 +1,20 @@
1
1
  /**
2
2
  * @module core/map-tokens
3
3
  *
4
- * The map's non-colour tokens, as `cornfield validate` reads them: `--corn-map-font`, `--corn-map-edge-width` and `--corn-map-glow`. The
4
+ * The map's non-colour tokens, as `cornfield validate` reads them: `--corn-map-font`, `--corn-map-edge-width`, `--corn-map-glow` and `--corn-map-label-min`. The
5
5
  * map reads each with the same parser (explorer/map-style.js `readMapTokens`), and one it cannot read is drawn as if it were `auto`; this
6
6
  * says so before the theme ships, as a warning naming the token, the theme, the level and what it may hold (docs/theming.md, The map).
7
7
  */
8
8
 
9
9
  import { declaredProps, expand, projectGroupOf, resolveProps, themesToCheck } from './contrast.js';
10
10
  import { iconKeyShape, parseKindToken } from './layers.js';
11
- import { EDGE_WIDTH_TOKEN, FONT_TOKEN, GLOW_TOKEN, MAX_EDGE_WIDTH, MAX_GLOW, readMapTokens } from '../explorer/map-style.js';
11
+ import { EDGE_WIDTH_TOKEN, FONT_TOKEN, GLOW_TOKEN, LABEL_MIN_TOKEN, MAX_EDGE_WIDTH, MAX_GLOW, MAX_LABEL_MIN, readMapTokens } from '../explorer/map-style.js';
12
12
 
13
13
  const WANTS = {
14
14
  [FONT_TOKEN]: ['font', 'a list of font families (quoted names or plain words, at most 8; no url(), and no punctuation but commas and quotes)'],
15
15
  [EDGE_WIDTH_TOKEN]: ['edgeWidth', `a width in px over 0 and at most ${MAX_EDGE_WIDTH}`],
16
16
  [GLOW_TOKEN]: ['glow', `a factor from 0 (no glow) to ${MAX_GLOW}`],
17
+ [LABEL_MIN_TOKEN]: ['labelMin', `a size in px from 9 to ${MAX_LABEL_MIN} (11px is the default and the least it draws at; under 9px is ignored)`],
17
18
  };
18
19
 
19
20
  /**
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',
@@ -64,7 +64,7 @@ export function pinchCamera(start, dist, mid, min = ZOOM_MIN) {
64
64
  // Framing: put these nodes in the part of the map nothing covers
65
65
  // ---------------------------------------------------------------------------
66
66
 
67
- /** The zoom at which a node's label is about 11px on screen (labels are 11px in world units from LABEL_ZOOM up, scene.js): where a step or a picked change is shown */
67
+ /** The zoom at which a node's label is about 11px on screen (a label is never drawn under 11px, labels.js): where a step or a picked change is shown */
68
68
  export const READ_ZOOM = 1.0;
69
69
  /**
70
70
  * The lowest zoom a change is framed at when it opens (proposal.js `fitToChange`): below it node discs and marks run together, so a change
@@ -0,0 +1,26 @@
1
+ /**
2
+ * @module explorer/cluster
3
+ *
4
+ * A cluster is a hub and what hangs under it (spec 0008 D1): an app and its pages, a store and its tables. A click or tap on a cluster's title
5
+ * (its hub's label) frames the cluster: the camera fits to all of it. Pure: nodes and edges in, ids out.
6
+ */
7
+
8
+ /**
9
+ * The ids of a hub and everything under it, by ownership edges (no kind, not dashed).
10
+ * @param {string} hubId
11
+ * @param {{from: string, to: string, kind?: string, dashed?: boolean}[]} edges
12
+ * @returns {Set<string>}
13
+ */
14
+ export function clusterIds(hubId, edges) {
15
+ const kids = new Map();
16
+ for (const e of edges) {
17
+ if (e.kind || e.dashed || !e.from || !e.to) continue;
18
+ (kids.get(e.from) || kids.set(e.from, []).get(e.from)).push(e.to);
19
+ }
20
+ const out = new Set([hubId]);
21
+ const todo = [hubId];
22
+ while (todo.length) {
23
+ for (const k of kids.get(todo.pop()) || []) if (!out.has(k)) { out.add(k); todo.push(k); }
24
+ }
25
+ return out;
26
+ }
@@ -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')}`;
@@ -177,7 +177,11 @@ h1, h2, h3, p { margin: 0; }
177
177
  .hx-brand { min-width: 0; min-height: 0; }
178
178
  .hx-only-wide { display: inline; }
179
179
  .hx-only-mobile { display: none; }
180
- .hx-search { display: flex; }
180
+ .hx-search { display: flex; flex: 0 1 260px; width: auto; }
181
+ /* A narrow desktop (768 to about 900 px, signed in): the search gives up width before it runs over the Layers chip; the left group
182
+ keeps its own (the right group shrinks, the search down to its min-width) */
183
+ .hx-header-left { flex: none; }
184
+ .hx-header-right { flex: 0 1 auto; min-width: 0; }
181
185
  }
182
186
  /* Not for a desktop: the brand keeps its logo and shows its wordmark; with no wordmark the logo stands alone (the button keeps its name) */
183
187
  @media (max-width: 767px) {
@@ -638,7 +642,7 @@ h2.hx-proposal-name { margin: 0; }
638
642
  .hx-proposal-bar[data-sheet-state="peek"] > :not(.hx-sheet-handle):not(#proposal-message):not(#proposal-ways):not(#proposal-body),
639
643
  .hx-proposal-bar[data-sheet-state="peek"] #proposal-body > :not(.hx-proposal-head),
640
644
  .hx-proposal-bar[data-sheet-state="peek"] .hx-proposal-head > :is(.hx-proposal-tools, .hx-proposal-more, .hx-proposal-more-menu) { display: none; }
641
- .hx-proposal-bar[data-sheet-state="peek"] .hx-review > :not([data-review-hint]):not([data-review-msg]) { display: none; } /* the peek keeps the reason Approve is off, and a refusal */
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 */
642
646
  .hx-proposal-bar[data-sheet-state="expanded"] .hx-whatif-panel { max-height: none; overflow: visible; }
643
647
 
644
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 */
@@ -1094,11 +1098,10 @@ a.hx-proposal-source:focus-visible { outline: var(--corn-focus-width) solid var(
1094
1098
  .hx-drawer[data-sheet-state="peek"] .hx-drawer-title { overflow: visible; text-overflow: clip; white-space: normal; }
1095
1099
  }
1096
1100
 
1097
- /* Search with no match (F24): one line under the field, a polite live region. Empty it takes no room. */
1101
+ /* Search status (F24, spec 0008): the polite live region by each search field. The count and the list say it on the screen (below), so
1102
+ the region itself is only for a screen reader: it stays in the page, out of sight. */
1098
1103
  .hx-search { position: relative; }
1099
- .hx-search-status { position: absolute; top: calc(100% + var(--corn-space-2)); left: 0; right: 0; z-index: 40; padding: var(--corn-space-2) var(--corn-space-3); border-radius: var(--corn-radius-sm); border: var(--corn-border) solid var(--corn-line); background: var(--corn-surface-2); color: var(--corn-text); font-size: var(--corn-text-sm); overflow-wrap: anywhere; }
1100
- .hx-search-status:empty { display: none; }
1101
- .hx-mobile-search .hx-search-status { top: calc(100% - var(--corn-space-1)); left: var(--corn-space-3); right: var(--corn-space-3); }
1104
+ .hx-search-status { position: absolute; width: 1px; height: 1px; margin: 0; padding: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }
1102
1105
 
1103
1106
  /* The node panel's facts break at word boundaries only (F60): "hook" is never "hoo / k". A long path or name still wraps, at its slashes and dashes, and only as a last resort anywhere. */
1104
1107
  .hx-fact-v { overflow-wrap: break-word; word-break: normal; }
@@ -1175,6 +1178,51 @@ a.hx-proposal-source:focus-visible { outline: var(--corn-focus-width) solid var(
1175
1178
  .hx-offline[hidden] { display: none; }
1176
1179
  .hx-offline[data-corn-state="success"] { border-color: var(--corn-ok); }
1177
1180
 
1181
+ /* ---------------------------------------------------------------------------
1182
+ Search: the count, the step buttons and the list of what was found (spec 0008 D4)
1183
+ --------------------------------------------------------------------------- */
1184
+ .hx-search-steps { display: flex; align-items: center; flex: none; gap: var(--corn-space-1); }
1185
+ .hx-search-steps[hidden] { display: none; }
1186
+ .hx-search-count { padding: 0 var(--corn-space-2); font-size: var(--corn-text-2xs); color: var(--corn-text-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
1187
+ .hx-search-count[data-empty="true"] { color: var(--corn-text); font-weight: 600; }
1188
+ .hx-search-btn { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; padding: 0; border: 0; border-radius: var(--corn-radius-xs); background: none; color: var(--corn-text-3); }
1189
+ .hx-search-btn:hover { background: var(--corn-surface-3); color: var(--corn-text); }
1190
+ .hx-search-btn:focus-visible, .hx-search-row:focus-visible { outline: var(--corn-focus-width) solid var(--corn-focus); outline-offset: calc(var(--corn-focus-offset) * -1); }
1191
+ .hx-search:has(.hx-search-steps:not([hidden])) { flex-basis: 340px; }
1192
+ /* A narrow desktop leaves the field too little room for the count and three buttons: Previous and Next go (Enter and Shift+Enter, N and P
1193
+ and the list's rows still step), the count and Clear stay */
1194
+ @media (min-width: 768px) and (max-width: 959px) {
1195
+ .hx-search [data-action="search-prev"], .hx-search [data-action="search-next"] { display: none; }
1196
+ }
1197
+ .hx-search-results { position: absolute; top: calc(100% + var(--corn-space-2)); right: 0; z-index: 40; width: min(440px, 92vw); max-height: min(60vh, 560px); overflow-y: auto; padding: var(--corn-space-1) 0; border-radius: var(--corn-radius-sm); border: var(--corn-border) solid var(--corn-line); background: var(--corn-ground); box-shadow: var(--corn-shadow); color: var(--corn-text); font-size: var(--corn-text-sm); } /* the ground itself, not a surface: a surface is see-through, and the panel under the list would show in it */
1198
+ .hx-search-results[hidden] { display: none; }
1199
+ /* The list is part of the header, which sits under the node panel (40): while the list is open the header is over it, so a row is never half under the panel */
1200
+ .hx-header:has(.hx-search-results:not([hidden])) { z-index: 46; }
1201
+ /* On a phone the list is in the search bar, under the sheets (the dock, 45): while it is open the bar is over them, so a proposal's or the
1202
+ Work sheet never covers rows of it. Without :has() the list stays under the sheets, as the bar always was */
1203
+ .hx-mobile-search:has(.hx-search-results:not([hidden])) { z-index: 46; }
1204
+ .hx-search-group-title { position: sticky; top: 0; display: flex; justify-content: space-between; gap: var(--corn-space-3); padding: var(--corn-space-2) var(--corn-space-3) var(--corn-space-1); background: var(--corn-ground); color: var(--corn-text-3); font-size: var(--corn-text-2xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
1205
+ .hx-search-row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--corn-space-3); width: 100%; min-height: 28px; padding: var(--corn-space-1) var(--corn-space-3); border: 0; border-left: var(--corn-border-strong) solid transparent; background: none; color: var(--corn-text); font: inherit; text-align: left; cursor: pointer; }
1206
+ .hx-search-row:hover, .hx-search-row:focus-visible { background: var(--corn-surface-3); }
1207
+ .hx-search-row[aria-current="true"] { border-left-color: var(--corn-accent); background: var(--corn-accent-soft); }
1208
+ .hx-search-row-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
1209
+ .hx-search-row-parent { flex: none; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--corn-text-3); font-size: var(--corn-text-xs); }
1210
+ .hx-search-frame { font-weight: 600; color: var(--corn-text); }
1211
+ .hx-search-empty, .hx-search-more { margin: 0; padding: var(--corn-space-2) var(--corn-space-3); color: var(--corn-text-2); overflow-wrap: anywhere; }
1212
+ .hx-mobile-search { flex-wrap: wrap; }
1213
+ .hx-mobile-search .hx-input { flex: 1 1 0; min-width: 0; }
1214
+ .hx-mobile-search::before { top: calc(var(--corn-space-3) + 22px); } /* the magnifier stays by the field when the bar wraps to a second row of steps */
1215
+ .hx-mobile-search .hx-search-steps { flex: 1 0 100%; justify-content: flex-end; gap: var(--corn-space-1); }
1216
+ .hx-mobile-search .hx-search-count { margin-right: auto; font-size: var(--corn-text-xs); }
1217
+ .hx-mobile-search .hx-search-results { top: 100%; left: 0; right: 0; width: auto; max-height: 50vh; border-radius: 0; border-left: 0; border-right: 0; }
1218
+ @media (max-width: 767px), (pointer: coarse) {
1219
+ .hx-search-btn { min-width: 44px; min-height: 44px; }
1220
+ .hx-search-row { min-height: 44px; }
1221
+ }
1222
+ @media (forced-colors: active) {
1223
+ .hx-search-row[aria-current="true"] { border-left-color: Highlight; }
1224
+ }
1225
+
1178
1226
  /* ==== the review column (spec 0006, review-column.js): the changes, and the personas with the scenarios that apply to them ==============
1179
1227
  From 768px it is docked on the left of the map under the proposal bar (the free map is what it leaves: sheets.js visibleMapRect);
1180
1228
  on a phone it is the expanded proposal sheet's body, a two-part switch at its top, its foot (the decision) always in view. */
@@ -1372,3 +1420,30 @@ a.hx-proposal-source:focus-visible { outline: var(--corn-focus-width) solid var(
1372
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); }
1373
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); }
1374
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; }
@@ -0,0 +1,48 @@
1
+ /**
2
+ * @module explorer/fly
3
+ *
4
+ * The camera flying to a place: a short glide to `{ x, y, zoom }`, as the scenario player's steps do, so a match chosen in a search
5
+ * is not a jump the eye has to find again. Under reduced motion the camera jumps. A new flight replaces the one in the air, and a
6
+ * hand on the map (a pan, a wheel) is not fought: `stopFlight()` ends it (input.js calls it when the pointer takes the camera).
7
+ * It is a frame client of render.js's loop, so it asks for frames only while it flies.
8
+ */
9
+
10
+ import { state } from './state.js';
11
+ import { render, ensureFlowLoop, addFrameClient } from './render.js';
12
+ import { flowReduceMotion } from './flows.js';
13
+
14
+ /** How quickly the camera closes on the target: the time constant of the glide (ms) */
15
+ export const FLY_MS = 120;
16
+ let glide = null; // { to: {x, y, zoom}, last: nowMs|null }
17
+
18
+ /** Flies the camera to `target` (jumps there when motion is reduced) */
19
+ export function flyTo(target) {
20
+ if (!target) return;
21
+ if (flowReduceMotion || !state.width) { Object.assign(state.camera, target); glide = null; render(); return; }
22
+ glide = { to: { ...target }, last: null };
23
+ ensureFlowLoop();
24
+ }
25
+
26
+ /** Ends a flight where it is */
27
+ export function stopFlight() { glide = null; }
28
+
29
+ /** Whether the camera is in the air */
30
+ export const flying = () => !!glide;
31
+
32
+ /** One frame of the glide (exported so a test can be the loop) */
33
+ export function tickFlight(now) {
34
+ if (!glide) return;
35
+ const dt = glide.last === null ? 16 : Math.min(now - glide.last, 100);
36
+ glide.last = now;
37
+ const k = 1 - Math.exp(-dt / FLY_MS);
38
+ const cam = state.camera;
39
+ cam.x += (glide.to.x - cam.x) * k;
40
+ cam.y += (glide.to.y - cam.y) * k;
41
+ cam.zoom += (glide.to.zoom - cam.zoom) * k;
42
+ if (Math.abs(glide.to.x - cam.x) < 0.5 && Math.abs(glide.to.y - cam.y) < 0.5 && Math.abs(glide.to.zoom - cam.zoom) < 0.002) {
43
+ Object.assign(cam, glide.to);
44
+ glide = null;
45
+ }
46
+ }
47
+
48
+ addFrameClient({ wants: flying, tick: tickFlight });
@@ -1538,13 +1538,32 @@ function graftAround(root, keep, twin) {
1538
1538
  }
1539
1539
  }
1540
1540
 
1541
- /** 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 */
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 = t('askRunner');
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 = t('askRunner');
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 = t('askRunner');
2013
+ go.textContent = askRunnerWords();
1991
2014
  const msg = $('agent-start-msg');
1992
2015
  msg.textContent = text;
1993
2016
  msg.hidden = false;