cornfield 0.59.0 → 0.61.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.
@@ -41,3 +41,17 @@
41
41
  .hx-run-tag { position: absolute; left: 0; top: calc(var(--r) + 4px); transform: translateX(-50%); white-space: nowrap; padding: calc(var(--corn-space-1) / 2) var(--corn-space-2); border-radius: var(--corn-radius-pill); border: var(--corn-border) solid var(--corn-map-collision); background: color-mix(in srgb, var(--corn-ground) 80%, transparent); color: var(--corn-map-collision); font-size: var(--corn-text-xs); font-weight: 700; }
42
42
  .hx-run-swatch { display: inline-block; width: 14px; height: 14px; flex: none; box-sizing: border-box; border-radius: 50%; border: var(--corn-border-strong) solid var(--corn-added); }
43
43
  .hx-run-swatch--collision { border: var(--corn-border-strong) dashed var(--corn-map-collision); }
44
+
45
+ /* The History layer (spec 0014 D3, history.js): a halo round each node the history changed; its width how often (--w), its colour how lately */
46
+ .hx-history-halos { position: absolute; inset: 0; z-index: 1; overflow: hidden; pointer-events: none; }
47
+ .hx-history-halos[hidden] { display: none; }
48
+ .hx-history-halo { position: absolute; width: 0; height: 0; --r: 12px; --w: 2px; --halo: var(--corn-history-old); }
49
+ .hx-history-halo::before { content: ""; position: absolute; left: calc(var(--r) * -1); top: calc(var(--r) * -1); width: calc(var(--r) * 2); height: calc(var(--r) * 2); box-sizing: border-box; border-radius: 50%; border: var(--w) solid var(--halo); opacity: 0.7; }
50
+ .hx-history-halo[data-band="week"], .hx-history-swatch[data-band="week"] { --halo: var(--corn-history-week); }
51
+ .hx-history-halo[data-band="month"], .hx-history-swatch[data-band="month"] { --halo: var(--corn-history-month); }
52
+ .hx-history-halo[data-band="old"], .hx-history-swatch[data-band="old"] { --halo: var(--corn-history-old); }
53
+ .hx-history-swatch { --halo: var(--corn-text-3); display: inline-block; width: 14px; height: 14px; flex: none; box-sizing: border-box; border-radius: 50%; border: var(--corn-border-strong) solid var(--halo); }
54
+ .hx-history-swatch--wide { border-width: calc(var(--corn-border-strong) * 2); }
55
+ /* The bar while a spec is picked: what it reached, and the way back to the whole map */
56
+ .hx-history-bar { position: absolute; top: var(--corn-space-3); left: 50%; transform: translateX(-50%); z-index: 3; display: flex; align-items: center; gap: var(--corn-space-3); max-width: calc(100% - var(--corn-space-6)); padding: var(--corn-space-1) var(--corn-space-3); border-radius: var(--corn-radius-pill); font-size: var(--corn-text-sm); color: var(--corn-text); }
57
+ .hx-history-bar-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@@ -188,3 +188,16 @@
188
188
  /* The head never shrinks: the body is a flex column that scrolls, and a short box (a panel in a host's 200px place, a short window) would squash the head to its
189
189
  min-height, laying a title that wraps, or a kicker that does ("Added by" a proposal), over the line under it */
190
190
  .hx-drawer-head { min-height: var(--corn-panel-head-height); flex-shrink: 0; }
191
+
192
+ /* History (spec 0014 D2): a node's commits, each with its trail from spec to issue to pull request to commit; a gap is dashed */
193
+ .hx-history-stats { margin: 0; color: var(--corn-text-2); font-size: var(--corn-text-sm); }
194
+ .hx-history-k { margin: var(--corn-space-3) 0 var(--corn-space-1); font-size: var(--corn-text-xs); font-weight: 600; color: var(--corn-text-3); text-transform: uppercase; letter-spacing: 0.04em; }
195
+ .hx-history-issues { margin: var(--corn-space-2) 0 0; font-size: var(--corn-text-sm); color: var(--corn-text-2); }
196
+ .hx-history-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--corn-space-2); }
197
+ .hx-history-commit { display: flex; flex-direction: column; gap: var(--corn-space-1); padding: var(--corn-space-3) var(--corn-space-4); border: var(--corn-border) solid var(--corn-line-soft); border-radius: var(--corn-radius-sm); background: var(--corn-surface-2); }
198
+ .hx-history-subject { color: var(--corn-text); overflow-wrap: anywhere; }
199
+ .hx-trail { display: flex; flex-wrap: wrap; align-items: center; gap: var(--corn-space-1); }
200
+ .hx-trail-arrow { color: var(--corn-text-3); font-size: var(--corn-text-xs); }
201
+ .hx-trail-chip { display: inline-flex; align-items: center; padding: 0 var(--corn-space-2); min-height: 22px; border: var(--corn-border) solid var(--corn-line); border-radius: var(--corn-radius-pill); color: var(--corn-text-2); font-size: var(--corn-text-xs); text-decoration: none; white-space: nowrap; }
202
+ a.hx-trail-chip:hover { border-color: var(--corn-accent-hover); color: var(--corn-text); }
203
+ .hx-trail-chip[data-trail="gap"] { border-style: dashed; color: var(--corn-text-3); }
@@ -93,6 +93,7 @@ export function layerRows(inst) {
93
93
  const project = state.projectLayers.filter((l) => held.has(l.key)).map((l) => ({ key: l.key, label: l.label, desc: l.desc || '', project: true, ...projectDot(l) }));
94
94
  // A starting row a project layer has taken every node from goes (spec 0009 D7, example 3); with no project layer, every starting row stays, as it always was
95
95
  const starting = LAYER_DEFS.filter((l) => !l.overlay && (held.has(l.key) || !left.has(l.key))).map(dotted);
96
+ const halos = state.historyRow && state.historyRow(); // the History layer's row, when the config has history on (history.js): an overlay, off to start
96
97
  const badges = state.workRow && state.workRow(); // the Work layer's row, when the page has a forge and somebody is signed in (work-view.js): an overlay, off to start
97
98
  const known = new Set([...LAYER_DEFS.map((l) => l.key), ...state.projectLayers.map((l) => l.key)]);
98
99
  const extra = [];
@@ -101,7 +102,7 @@ export function layerRows(inst) {
101
102
  known.add(key);
102
103
  extra.push({ key, label: key.charAt(0).toUpperCase() + key.slice(1), color: rowColor(inst, { type: key, group: key }, NO_COLOR), desc: `Nodes of the type ${key}` });
103
104
  });
104
- return { layers: [...orderRows(project, starting, state.layerOrder), ...extra], overlays: [...LAYER_DEFS.filter((l) => l.overlay).map(dotted), ...(badges ? [badges] : [])] };
105
+ return { layers: [...orderRows(project, starting, state.layerOrder), ...extra], overlays: [...LAYER_DEFS.filter((l) => l.overlay).map(dotted), ...(badges ? [badges] : []), ...(halos ? [halos] : [])] };
105
106
  }
106
107
 
107
108
  // ---------------------------------------------------------------------------
@@ -141,6 +142,7 @@ export function setProjectLayers(inst, raw) {
141
142
  for (const l of LAYER_DEFS) defaults[l.key] = !STARTS_OFF.has(l.key);
142
143
  for (const l of cfg.add) defaults[l.key] = true;
143
144
  defaults['work-badges'] = false;
145
+ defaults['history-halos'] = false; // the History layer (history-model.js HISTORY_LAYER)
144
146
  for (const k of cfg.off) defaults[k] = false;
145
147
  state.layerDefaults = defaults;
146
148
  const mem = memoryOf(inst);
@@ -0,0 +1,248 @@
1
+ /**
2
+ * @module explorer/history-model
3
+ *
4
+ * The pure half of a node's history (spec 0014 D2): the links of a commit's trail on the forge, and the node panel's History section.
5
+ * No DOM, no state, no fetch; explorer/history.js holds the answer of `GET /api/history` (core/history.js) and asks these.
6
+ *
7
+ * forgeLinks(forge) { commit(sha), pull(n), issue(n) }: where each is on the forge's site, or null (only https; GitHub and Forgejo)
8
+ * specFiles(nodes) spec number -> its file (`docs/specs/0012-work-as-a-view.md`), from the map's doc pages
9
+ * nodeTrail(history, nodeId) a node's commits, newest first, with what the History section counts
10
+ * trailHtml(commit, ctx) a commit's trail: `Spec 0012 → Issue #283 → PR #284 → 0281cba`, a gap dashed (`no spec`, `no issue`)
11
+ * historySectionHtml(node, ctx) the node panel's History section
12
+ * specReach(history, spec) the nodes a spec's commits touched, and how many commits named it
13
+ * heatOf(history, at) the History layer (spec 0014 D3): per node, how often it changed and how lately, as of a commit
14
+ * haloWidth(count, max) a halo's width on screen (px) for how often its node changed
15
+ * historyRowOf(status, heat) the Layers menu's row under Overlays
16
+ * specBarHtml(pick, ctx) the bar on the map while a spec is picked: `Spec 0012 · Work as a view: 6 commits, 72 nodes`
17
+ */
18
+
19
+ import { escapeHtml as esc } from '../core/text.js';
20
+ import { fileUrl } from './file-url.js';
21
+
22
+ /** The most commits the section lists before "Show all N" */
23
+ export const HISTORY_CAP = 12;
24
+
25
+ /** Where a commit, a pull request and an issue are on each forge's site */
26
+ const SHAPES = {
27
+ github: { commit: 'commit', pull: 'pull', issue: 'issues' },
28
+ forgejo: { commit: 'commit', pull: 'pulls', issue: 'issues' },
29
+ };
30
+
31
+ /**
32
+ * The links of a trail on the forge, or null when there is no forge cornfield can link to. Built like file-url.js: `URL`, each segment encoded,
33
+ * only `https:`, no user name and no backslash in `forge.url`.
34
+ * @param {{ type: string, url: string, repo: string, baseBranch?: string } | null} forge the client config's
35
+ */
36
+ export function forgeLinks(forge) {
37
+ const shape = forge && Object.hasOwn(SHAPES, forge.type) ? SHAPES[forge.type] : null;
38
+ const repo = forge && typeof forge.repo === 'string' ? forge.repo.split('/') : [];
39
+ if (!shape || repo.length !== 2 || !repo.every((s) => /^[A-Za-z0-9_.-]+$/.test(s) && s !== '.' && s !== '..')) return null;
40
+ let base;
41
+ try {
42
+ base = new URL(forge.url);
43
+ if (base.protocol !== 'https:' || base.username || base.password || String(forge.url).includes('\\')) return null;
44
+ } catch {
45
+ return null;
46
+ }
47
+ const at = (...segs) => {
48
+ const u = new URL(base.href);
49
+ u.pathname = `${u.pathname.replace(/\/+$/, '')}/${[...repo, ...segs].map(encodeURIComponent).join('/')}`;
50
+ u.search = '';
51
+ u.hash = '';
52
+ return u.href;
53
+ };
54
+ const num = (n) => Number.isInteger(n) && n > 0;
55
+ return {
56
+ commit: (sha) => (typeof sha === 'string' && /^[0-9a-f]{7,40}$/.test(sha) ? at(shape.commit, sha) : null),
57
+ pull: (n) => (num(n) ? at(shape.pull, String(n)) : null),
58
+ issue: (n) => (num(n) ? at(shape.issue, String(n)) : null),
59
+ file: (path) => fileUrl(forge, path, forge.baseBranch),
60
+ };
61
+ }
62
+
63
+ /** A spec's short title from its doc page: "Work as a view" from "Spec 0012: Work as a view (issues, …)"; else its number */
64
+ const titleOf = (n, num) => {
65
+ const m = typeof n.desc === 'string' && /^Spec \d{4}:\s*([^(]+?)\s*(?:\(|$)/.exec(n.desc);
66
+ return m ? m[1] : `Spec ${num}`;
67
+ };
68
+
69
+ /** Spec number -> its file, from the map's pages of `docs/specs/NNNN-*.md` (the docs deriver puts each doc on the map) */
70
+ export function specFiles(nodes) {
71
+ const out = new Map();
72
+ for (const n of nodes || []) {
73
+ const m = n && typeof n.file === 'string' && /^docs\/specs\/(\d{4})-[^/]+\.md$/.exec(n.file);
74
+ if (m && !out.has(m[1])) out.set(m[1], { file: n.file, label: titleOf(n, m[1]), id: n.id });
75
+ }
76
+ return out;
77
+ }
78
+
79
+ /**
80
+ * A node's commits, newest first, and what the section counts of them: pull requests, the specs and issues they name, and how many name a spec or an issue.
81
+ * @param {{ commits: object[], nodes: Record<string, { born: number, commits: number[] }> } | null} history
82
+ * @param {string} nodeId
83
+ */
84
+ export function nodeTrail(history, nodeId) {
85
+ const entry = history && history.nodes && Object.hasOwn(history.nodes, nodeId) ? history.nodes[nodeId] : null;
86
+ if (!entry) return null;
87
+ const commits = entry.commits.map((i) => ({ ...history.commits[i], index: i })).filter((c) => c.sha).reverse();
88
+ const uniq = (xs) => [...new Set(xs)];
89
+ return {
90
+ commits,
91
+ born: history.commits[entry.born] ? { ...history.commits[entry.born], index: entry.born } : null,
92
+ pulls: uniq(commits.map((c) => c.pr).filter((n) => n != null)),
93
+ specs: uniq(commits.flatMap((c) => c.specs || [])),
94
+ issues: uniq(commits.flatMap((c) => c.issues || [])),
95
+ traced: commits.filter((c) => (c.specs && c.specs.length) || (c.issues && c.issues.length) || (c.keys && c.keys.length)).length,
96
+ };
97
+ }
98
+
99
+ const chip = (kind, href, words, title) => (href
100
+ ? `<a class="hx-trail-chip" data-corn="text-link" data-trail="${kind}" href="${esc(href)}" target="_blank" rel="noreferrer"${title ? ` title="${esc(title)}"` : ''}>${words}</a>`
101
+ : `<span class="hx-trail-chip" data-trail="${kind}"${title ? ` title="${esc(title)}"` : ''}>${words}</span>`);
102
+ const gap = (what) => `<span class="hx-trail-chip" data-trail="gap">no ${what}</span>`;
103
+ const ARROW = '<span class="hx-trail-arrow" aria-hidden="true">→</span>';
104
+
105
+ /**
106
+ * A commit's trail, from spec to issue to pull request to commit. Each a link on the forge when there is one (a spec to its file); what the commit does not name is a dashed gap.
107
+ * @param {{ sha: string, pr: number | null, issues: number[], specs: string[], keys?: string[] }} c
108
+ * @param {{ links: ReturnType<typeof forgeLinks>, specs: ReturnType<typeof specFiles> }} ctx
109
+ */
110
+ export function trailHtml(c, { links, specs }) {
111
+ const parts = [];
112
+ if (c.specs && c.specs.length) {
113
+ for (const s of c.specs) {
114
+ const spec = specs.get(s);
115
+ parts.push(chip('spec', spec && links ? links.file(spec.file) : null, `Spec ${esc(s)}`, spec ? spec.label : ''));
116
+ }
117
+ } else parts.push(gap('spec'));
118
+ if (c.issues && c.issues.length) for (const n of c.issues) parts.push(chip('issue', links && links.issue(n), `Issue #${esc(n)}`));
119
+ else if (c.keys && c.keys.length) for (const k of c.keys) parts.push(chip('issue', null, esc(k)));
120
+ else parts.push(gap('issue'));
121
+ if (c.pr != null) parts.push(chip('pull', links && links.pull(c.pr), `PR #${esc(c.pr)}`));
122
+ else parts.push(gap('pull request'));
123
+ parts.push(chip('commit', links && links.commit(c.sha), `<span class="hx-mono">${esc(String(c.sha).slice(0, 7))}</span>`, 'The commit on the forge'));
124
+ return `<span class="hx-trail" role="group" aria-label="Spec, issue, pull request and commit">${parts.join(ARROW)}</span>`;
125
+ }
126
+
127
+ /** "26 Nov 2026": a commit's day, in the viewer's own words for it */
128
+ export const dayOf = (iso, locale) => {
129
+ const d = new Date(iso);
130
+ return Number.isNaN(d.getTime()) ? '' : d.toLocaleDateString(locale, { day: 'numeric', month: 'short', year: 'numeric' });
131
+ };
132
+
133
+ /**
134
+ * The node panel's History section (spec 0014 D2): counts, the specs behind the node (each picks what the spec reached on the map), the issues, and its commits newest first
135
+ * with their trails. Every word from git and the forge is escaped; only https links are made.
136
+ * @param {{ id: string }} node
137
+ * @param {{ history: object | null, status: 'off' | 'loading' | 'ready' | 'error', error?: string, links: ReturnType<typeof forgeLinks>, specs: ReturnType<typeof specFiles>, picked?: string | null, all?: boolean, locale?: string }} ctx
138
+ */
139
+ export function historySectionHtml(node, ctx) {
140
+ const head = '<h3 class="hx-sec-title">History</h3>';
141
+ const wrap = (body) => `<div class="hx-sec-block hx-history" data-corn="section" data-history>${head}${body}</div>`;
142
+ if (ctx.status === 'off') return '';
143
+ if (ctx.status === 'loading') return wrap('<p class="hx-faint" data-corn="loading">Reading the history…</p>');
144
+ if (ctx.status === 'error') return wrap(`<p class="hx-faint" data-corn="error">${esc(ctx.error || 'The history could not be read.')}</p>`);
145
+ const t = nodeTrail(ctx.history, node.id);
146
+ if (!t) return wrap('<p class="hx-faint">This node is not in the history yet: run <code class="hx-code">cornfield sync</code> and commit the map.</p>');
147
+ if (!t.commits.length) return wrap('<p class="hx-faint">No commit has changed this node\'s file yet.</p>');
148
+ const n = t.commits.length;
149
+ const share = Math.round((t.traced / n) * 100);
150
+ const stats = `<p class="hx-history-stats"><span><b class="hx-ms">${n}</b> ${n === 1 ? 'commit' : 'commits'}</span> · <span><b class="hx-ms">${t.pulls.length}</b> ${t.pulls.length === 1 ? 'pull request' : 'pull requests'}</span> · <span><b class="hx-ms">${share}%</b> traced to a spec or issue</span></p>`;
151
+ const specChips = t.specs.map((s) => {
152
+ const spec = ctx.specs.get(s);
153
+ const on = ctx.picked === s;
154
+ return `<button type="button" class="hx-lines-kind" data-corn-kind="quiet" data-history-spec="${esc(s)}" aria-pressed="${on}" title="Light every node spec ${esc(s)} reached">Spec ${esc(s)}${spec ? ` <span class="hx-faint">${esc(spec.label)}</span>` : ''}</button>`;
155
+ });
156
+ const specs = specChips.length ? `<div class="hx-chips" role="group" aria-label="Specs behind it">${specChips.join('')}</div>` : '<p class="hx-faint">No commit to this node names a spec.</p>';
157
+ const issues = t.issues.length ? `<p class="hx-history-issues">Issues: ${t.issues.map((i) => { const href = ctx.links && ctx.links.issue(i); return href ? `<a class="hx-link" data-corn="text-link" href="${esc(href)}" target="_blank" rel="noreferrer">#${esc(i)}</a>` : `#${esc(i)}`; }).join(', ')}</p>` : '';
158
+ const shown = ctx.all ? t.commits : t.commits.slice(0, HISTORY_CAP);
159
+ const rows = shown.map((c) => `<li class="hx-history-commit" data-corn="row">`
160
+ + `<div class="hx-row-meta">${esc(dayOf(c.date, ctx.locale))} · ${c.nodes.length} ${c.nodes.length === 1 ? 'node' : 'nodes'}${t.born && c.index === t.born.index ? ' · <span class="hx-history-born">born here</span>' : ''}</div>`
161
+ + `<div class="hx-history-subject">${esc(c.subject)}</div>`
162
+ + trailHtml(c, ctx)
163
+ + '</li>');
164
+ const more = shown.length < n ? `<button type="button" class="hx-btn hx-btn--quiet hx-textact" data-corn="more" data-corn-kind="quiet" data-history-all>Show all ${n}</button>` : '';
165
+ return wrap(`${stats}<h4 class="hx-history-k">Specs behind it</h4>${specs}${issues}<h4 class="hx-history-k">Commits, newest first</h4><ol class="hx-history-list">${rows.join('')}</ol>${more}`);
166
+ }
167
+
168
+ /**
169
+ * What a spec reached: the nodes its commits touched, and how many commits named it (spec 0014 D3: picking a spec lights them).
170
+ * @param {{ commits: { specs: string[], nodes: string[] }[] } | null} history
171
+ * @param {string} spec
172
+ */
173
+ export function specReach(history, spec) {
174
+ const nodes = new Set();
175
+ let commits = 0;
176
+ for (const c of (history && history.commits) || []) {
177
+ if (!c.specs || !c.specs.includes(spec)) continue;
178
+ commits++;
179
+ for (const id of c.nodes) nodes.add(id);
180
+ }
181
+ return { nodes, commits };
182
+ }
183
+
184
+ /** The History layer's key in the Layers menu and `state.activeLayers` (spec 0014 D3): an overlay, off to start */
185
+ export const HISTORY_LAYER = 'history-halos';
186
+ /** The most halos drawn at once */
187
+ export const MAX_HALOS = 600;
188
+ /** How lately a node changed, as of the timeline's commit: within a week, within a month (30 days), or before */
189
+ export const HALO_BANDS = Object.freeze(['week', 'month', 'old']);
190
+ const DAY_MS = 86_400_000;
191
+ const bandOf = (days) => (days <= 7 ? 'week' : days <= 30 ? 'month' : 'old');
192
+
193
+ /**
194
+ * Each node's heat as of a commit: how many commits up to it changed the node, the last of them, and how many days before the commit that was.
195
+ * The age is counted from the commit's own date, not today's, so a replay reads as it did then.
196
+ * @param {{ commits: { date: string }[], nodes: Record<string, { commits: number[] }> } | null} history
197
+ * @param {number | null} [at] a commit's index; the newest when it is left out or out of range
198
+ * @returns {{ at: number, nodes: Map<string, { count: number, last: number, days: number, band: 'week' | 'month' | 'old' }>, max: number }}
199
+ */
200
+ export function heatOf(history, at = null) {
201
+ const commits = (history && history.commits) || [];
202
+ const nodes = new Map();
203
+ if (!commits.length) return { at: -1, nodes, max: 0 };
204
+ const i = Number.isInteger(at) && at >= 0 && at < commits.length ? at : commits.length - 1;
205
+ const now = Date.parse(commits[i].date);
206
+ let max = 0;
207
+ for (const [id, e] of Object.entries(history.nodes || {})) {
208
+ let count = 0;
209
+ let last = -1;
210
+ for (const k of (e && e.commits) || []) { if (k > i) break; count++; last = k; }
211
+ if (!count) continue;
212
+ const days = Math.max(0, (now - Date.parse(commits[last].date)) / DAY_MS);
213
+ nodes.set(id, { count, last, days, band: bandOf(days) });
214
+ if (count > max) max = count;
215
+ }
216
+ return { at: i, nodes, max };
217
+ }
218
+
219
+ /** A halo's width on screen (px): from 1.5 for a node changed once to 6 for the most changed on the map (by the square root, so a few busy nodes do not flatten the rest) */
220
+ export const haloWidth = (count, max) => (max > 0 && count > 0 ? Math.round((1.5 + 4.5 * Math.sqrt(Math.min(count, max) / max)) * 10) / 10 : 0);
221
+
222
+ /**
223
+ * The Layers menu's row for the History layer: its count in words while the history is read.
224
+ * @param {'idle' | 'loading' | 'ready' | 'error'} status
225
+ * @param {{ nodes: Map<string, unknown> } | null} heat
226
+ * @param {string} color the dot's colour
227
+ */
228
+ export function historyRowOf(status, heat, color) {
229
+ const n = heat ? heat.nodes.size : 0;
230
+ const countText = status === 'ready' ? `${n} ${n === 1 ? 'node' : 'nodes'}` : status === 'loading' ? 'reading…' : status === 'error' ? 'not read' : 'not read yet';
231
+ return { key: HISTORY_LAYER, label: 'History', color, overlay: true, countText, desc: 'A halo round each node the history changed: the wider, the more often; pink this week, violet this month, grey before. Picking a spec in a node\'s History lights what it reached.' };
232
+ }
233
+
234
+ /**
235
+ * The bar on the map while a spec is picked (spec 0014 D3): the spec, a link to its file on the forge when there is one, what it reached, and how to show the whole map again.
236
+ * @param {{ spec: string, nodes: Set<string>, commits: number }} pick
237
+ * @param {{ links: ReturnType<typeof forgeLinks>, specs: ReturnType<typeof specFiles> }} ctx
238
+ */
239
+ export function specBarHtml(pick, { links, specs }) {
240
+ const spec = specs && specs.get(pick.spec);
241
+ const href = spec && links ? links.file(spec.file) : null;
242
+ const name = href ? `<a class="hx-link" data-corn="text-link" href="${esc(href)}" target="_blank" rel="noreferrer">Spec ${esc(pick.spec)}</a>` : `<b>Spec ${esc(pick.spec)}</b>`;
243
+ const label = spec ? ` · ${esc(spec.label)}` : '';
244
+ const c = pick.commits;
245
+ const n = pick.nodes.size;
246
+ return `<span class="hx-history-bar-text">${name}${label}: ${c} ${c === 1 ? 'commit' : 'commits'}, ${n} ${n === 1 ? 'node' : 'nodes'}</span>`
247
+ + `<button type="button" class="hx-btn hx-btn--quiet hx-textact" data-corn-kind="quiet" data-history-unpick>Show the whole map</button>`;
248
+ }
@@ -0,0 +1,203 @@
1
+ /**
2
+ * @module explorer/history
3
+ *
4
+ * A node's history on an instance (spec 0014 D2): reads `GET /api/history` (core/history.js) once, the first time the node panel asks, and
5
+ * answers the panel's History section; picking a spec lights every node its commits touched (`state.historyPick`, which scene.js dims around).
6
+ * Nothing is fetched while the config says `history: false`, and the panel then has no History section, the Layers menu no History row.
7
+ *
8
+ * The History layer (spec 0014 D3): a row under Overlays, off to start and remembered like the others. While it is on, each node the history changed
9
+ * wears a halo, its width how often and its colour how lately (as of the timeline's commit, `state.historyAt`, else the newest). A DOM layer over the map,
10
+ * like the runs' marks, decoration for the eye (`aria-hidden`): the words are the node panel's History section. While a spec is picked a bar on the map
11
+ * names it, what it reached, and how to show the whole map again.
12
+ *
13
+ * initHistory(inst, config) once, with the client config (`history`, `forge`); returns how to stop
14
+ *
15
+ * What it answers and hears (instance.js lists them):
16
+ * history:section node -> HTML | undefined the node panel's History section; asking starts the one read
17
+ * history:pick spec | null (emit) light what that spec reached, or nothing; picking the lit spec again ends it
18
+ * history:all (none) (emit) the section lists every commit, not only the newest
19
+ * history:changed (none) (emitted) the read ended, or a pick changed: the open panel draws its History section again
20
+ * history:legend { active } (emitted) the History layer is drawn: the Layers menu shows its legend
21
+ */
22
+
23
+ import { credentialed } from './engine/connection.js';
24
+ import { announce } from './engine/keyboard.js';
25
+ import { onLayersChange, redrawLayers } from './engine/layers.js';
26
+ import { layerOn } from './layer-model.js';
27
+ import { HISTORY_LAYER, MAX_HALOS, forgeLinks, haloWidth, heatOf, historyRowOf, historySectionHtml, specBarHtml, specFiles, specReach } from './history-model.js';
28
+
29
+ /** Where the server answers the history (server/server.js) */
30
+ export const HISTORY_PATH = '/api/history';
31
+
32
+ /**
33
+ * @param {ReturnType<typeof import('./instance.js').createInstance>} inst
34
+ * @param {{ history?: boolean, forge?: object | null }} config the client config (/cornfield/config.json)
35
+ * @returns {() => void}
36
+ */
37
+ export function initHistory(inst, config) {
38
+ /** The dot of the Layers menu's row: this week's halo colour, as the theme has it */
39
+ const haloColor = () => {
40
+ const root = inst.doc && inst.doc.documentElement;
41
+ const view = inst.doc && inst.doc.defaultView;
42
+ const v = root && view && view.getComputedStyle ? view.getComputedStyle(root).getPropertyValue('--corn-history-week').trim() : '';
43
+ return v || 'currentColor';
44
+ };
45
+ const { state } = inst;
46
+ const on = !!(config && config.history === true);
47
+ const mem = { status: on ? 'idle' : 'off', history: null, error: '', all: false, node: null, links: forgeLinks(config && config.forge), specs: null };
48
+ const stops = [];
49
+ const halos = new Map(); // the halo elements by node id, kept between frames
50
+ let heat = null; // heatOf, for the history and the commit it was worked out for
51
+ let placed = '';
52
+ let layerEl = null;
53
+ let barEl = null;
54
+
55
+ const stage = () => (state.canvas && state.canvas.parentElement) || null;
56
+ // Off until the layers have their defaults (a layer with no entry reads as on), and never in the Work view
57
+ const haloOn = () => mem.status !== 'off' && !state.workRows && Object.hasOwn(state.layerDefaults || {}, HISTORY_LAYER) && layerOn(state, HISTORY_LAYER);
58
+ const heatNow = () => {
59
+ if (mem.status !== 'ready') return null;
60
+ const at = Number.isInteger(state.historyAt) ? state.historyAt : null;
61
+ if (!heat || heat.of !== mem.history || heat.asked !== at) heat = { of: mem.history, asked: at, ...heatOf(mem.history, at) };
62
+ return heat;
63
+ };
64
+
65
+ function clearHalos() {
66
+ for (const el of halos.values()) el.remove();
67
+ halos.clear();
68
+ placed = '';
69
+ if (layerEl) layerEl.hidden = true;
70
+ }
71
+
72
+ /** Puts a halo on each node the history changed, at the camera: only their place changes on a pan */
73
+ function syncHalos(scene, camera) {
74
+ const h = haloOn() ? heatNow() : null;
75
+ if (!h || !h.nodes.size) { if (halos.size || (layerEl && !layerEl.hidden)) clearHalos(); return; }
76
+ const key = `${scene.version}|${camera.x}|${camera.y}|${camera.zoom}|${h.at}`;
77
+ if (key === placed && layerEl && layerEl.isConnected) return;
78
+ const host = stage();
79
+ if (!host) return;
80
+ if (!layerEl || !layerEl.isConnected) {
81
+ layerEl = inst.doc.createElement('div');
82
+ layerEl.className = 'hx-history-halos';
83
+ layerEl.setAttribute('aria-hidden', 'true');
84
+ host.append(layerEl);
85
+ halos.clear();
86
+ }
87
+ placed = key;
88
+ layerEl.hidden = false;
89
+ const seen = new Set();
90
+ for (const node of scene.nodes) {
91
+ if (seen.size >= MAX_HALOS) break;
92
+ const it = h.nodes.get(node.id);
93
+ if (!it || !(node.alpha > 0.2)) continue;
94
+ seen.add(node.id);
95
+ let el = halos.get(node.id);
96
+ if (!el) {
97
+ el = inst.doc.createElement('span');
98
+ el.className = 'hx-history-halo';
99
+ el.dataset.node = node.id;
100
+ layerEl.append(el);
101
+ halos.set(node.id, el);
102
+ }
103
+ const w = haloWidth(it.count, h.max);
104
+ el.dataset.band = it.band;
105
+ el.style.left = `${(node.x * camera.zoom + camera.x).toFixed(1)}px`;
106
+ el.style.top = `${(node.y * camera.zoom + camera.y).toFixed(1)}px`;
107
+ el.style.setProperty('--r', `${(Math.max(6, node.r * camera.zoom) + 3 + w / 2).toFixed(1)}px`);
108
+ el.style.setProperty('--w', `${w}px`);
109
+ }
110
+ for (const [id, el] of halos) if (!seen.has(id)) { el.remove(); halos.delete(id); }
111
+ }
112
+
113
+ /** The bar on the map while a spec is picked */
114
+ function paintBar() {
115
+ const pickNow = state.historyPick;
116
+ if (!pickNow) { if (barEl) { barEl.remove(); barEl = null; } return; }
117
+ const host = stage();
118
+ if (!host) return;
119
+ if (!barEl || !barEl.isConnected) {
120
+ barEl = inst.doc.createElement('div');
121
+ barEl.className = 'hx-history-bar glass';
122
+ barEl.setAttribute('role', 'group');
123
+ barEl.setAttribute('aria-label', 'Picked spec');
124
+ barEl.addEventListener('click', (e) => { if (e.target.closest('[data-history-unpick]')) pick(null); });
125
+ host.append(barEl);
126
+ }
127
+ if (!mem.specs) mem.specs = specFiles(state.nodes);
128
+ barEl.innerHTML = specBarHtml(pickNow, { links: mem.links, specs: mem.specs });
129
+ }
130
+
131
+ /** The layer went on or off, or the read ended: the row's count, the legend and the halos follow */
132
+ function layerChanged() {
133
+ const on = haloOn();
134
+ if (on && mem.status === 'idle') load();
135
+ inst.emit('history:legend', { active: on && mem.status === 'ready' });
136
+ if (!on) clearHalos();
137
+ placed = '';
138
+ if (inst.map) inst.map.render();
139
+ }
140
+
141
+ async function load() {
142
+ if (mem.status !== 'idle') return;
143
+ mem.status = 'loading';
144
+ try {
145
+ const res = await credentialed(inst)(HISTORY_PATH);
146
+ const body = await res.json().catch(() => null);
147
+ if (!res.ok || !body || body.ok !== true) throw new Error(body && typeof body.error === 'string' ? body.error : `The history could not be read (${res.status}).`);
148
+ mem.history = body;
149
+ mem.status = 'ready';
150
+ } catch (err) {
151
+ mem.status = 'error';
152
+ mem.error = inst.offline() ? 'You are offline, so the history could not be read.' : String(err && err.message ? err.message : err);
153
+ }
154
+ inst.emit('history:changed');
155
+ redrawLayers(inst); // the row's count
156
+ layerChanged();
157
+ }
158
+
159
+ function pick(spec) {
160
+ if (!spec || (state.historyPick && state.historyPick.spec === spec) || mem.status !== 'ready') {
161
+ if (!state.historyPick) return;
162
+ state.historyPick = null;
163
+ announce(inst, 'Showing the whole map again');
164
+ } else {
165
+ const { nodes, commits } = specReach(mem.history, spec);
166
+ state.historyPick = { spec, nodes, commits };
167
+ announce(inst, `Spec ${spec}: ${commits} ${commits === 1 ? 'commit' : 'commits'} reached ${nodes.size} ${nodes.size === 1 ? 'node' : 'nodes'}; the rest is dimmed`);
168
+ }
169
+ inst.touchScene();
170
+ paintBar();
171
+ if (inst.map) inst.map.render();
172
+ inst.emit('history:changed');
173
+ }
174
+
175
+ if (mem.status !== 'off') {
176
+ // The Layers menu's row under Overlays (engine/layers.js `layerRows`), in the colour of this week's halo
177
+ state.historyRow = () => historyRowOf(mem.status, mem.status === 'ready' ? heatNow() : null, haloColor());
178
+ stops.push(onLayersChange(inst, layerChanged));
179
+ if (inst.map) stops.push(inst.map.onPaint((scene, camera) => syncHalos(scene, camera)));
180
+ stops.push(inst.on('history:at', () => { placed = ''; if (inst.map) inst.map.render(); redrawLayers(inst); }));
181
+ if (haloOn()) layerChanged();
182
+ }
183
+
184
+ stops.push(inst.on('history:section', (node) => {
185
+ if (mem.status === 'off' || !node || typeof node.id !== 'string') return undefined;
186
+ if (mem.node !== node.id) { mem.node = node.id; mem.all = false; } // "Show all" is for the node it was pressed on
187
+ if (mem.status === 'idle') load();
188
+ if (!mem.specs) mem.specs = specFiles(state.nodes);
189
+ return historySectionHtml(node, { history: mem.history, status: mem.status === 'idle' ? 'loading' : mem.status, error: mem.error, links: mem.links, specs: mem.specs, picked: state.historyPick ? state.historyPick.spec : null, all: mem.all });
190
+ }));
191
+ stops.push(inst.on('history:pick', (spec) => pick(typeof spec === 'string' ? spec : null)));
192
+ // A selection cleared (the bare map, Escape, Close) ends a pick too: nothing on screen would say why the map is dim
193
+ stops.push(inst.on('selection', () => { if (!state.selectedNode && state.historyPick) pick(null); }));
194
+ stops.push(inst.on('history:all', () => { mem.all = true; inst.emit('history:changed'); }));
195
+ return () => {
196
+ stops.forEach((s) => s());
197
+ clearHalos();
198
+ if (layerEl) layerEl.remove();
199
+ if (barEl) barEl.remove();
200
+ state.historyRow = null;
201
+ if (state.historyPick) { state.historyPick = null; inst.touchScene(); }
202
+ };
203
+ }
@@ -87,6 +87,13 @@
87
87
  <div class="hx-legend-row"><span class="hx-run-swatch hx-run-swatch--flight" aria-hidden="true"></span><span>In flight: a pulsing ring (still under reduced motion)</span></div>
88
88
  <div class="hx-legend-row"><span class="hx-run-swatch hx-run-swatch--collision" aria-hidden="true"></span><span>Collision: dashed ring, ⚠ and the words, where two open runs change one node</span></div>
89
89
  </div>
90
+ <div class="hx-menu-section" data-corn="menu-section" part="menu-section" hidden>
91
+ <div class="hx-menu-title" data-corn="menu-title" part="menu-title"><span>History</span></div>
92
+ <div class="hx-legend-row"><span class="hx-history-swatch hx-history-swatch--wide" aria-hidden="true"></span><span>A wider halo: changed more often</span></div>
93
+ <div class="hx-legend-row"><span class="hx-history-swatch" data-band="week" aria-hidden="true"></span><span>Changed this week</span></div>
94
+ <div class="hx-legend-row"><span class="hx-history-swatch" data-band="month" aria-hidden="true"></span><span>Changed this month</span></div>
95
+ <div class="hx-legend-row"><span class="hx-history-swatch" data-band="old" aria-hidden="true"></span><span>Not for over a month (as of the timeline's commit)</span></div>
96
+ </div>
90
97
  <div class="hx-menu-section" data-corn="menu-section" part="menu-section" hidden>
91
98
  <div class="hx-menu-title" data-corn="menu-title" part="menu-title"><span>Proposal marks</span></div>
92
99
  <div class="hx-legend-row"><span class="hx-mark-dot hx-mark-dot--added" data-corn="mark-dot" part="mark-dot" data-corn-state="added"></span><span>Added: dashed ring</span></div>
@@ -43,6 +43,10 @@ export function createState() {
43
43
  /** The config's `forge` (`{ type, url, repo, baseBranch? }`), or null: where a node's file is opened (file-url.js) */
44
44
  forge: null,
45
45
  searchQuery: '',
46
+ /** The spec picked in a node's History (history.js, spec 0014 D3): `{ spec, nodes }`, the nodes its commits touched, lit while the rest dims; or null */
47
+ historyPick: null,
48
+ historyAt: null, // the timeline's commit (spec 0014 D1), an index into the history; null is the newest
49
+ historyRow: null, // the History layer's row in the Layers menu (history.js), while the config has history on
46
50
  /** The id of the search match the stepping is on (search.js), or null: the map draws its halo and places its label first of the matches */
47
51
  searchCurrent: null,
48
52
  /** The id of the node the pointer is on (input.js): a node with no label is named by a chip while it is */
@@ -99,6 +99,8 @@
99
99
  * player:seat bar -> true the dock's owner (engine/sheets.js) seats the scenario player's bar as a sheet above the node panel's
100
100
  * threads:index nodeId -> { threads: thread[] | null, forge: string, start: true } | undefined the Work list's list of the threads that mention a node, for the node panel's "Threads"; `threads` is null until the list was read; no answer: no Threads section
101
101
  * threads:ensure (none) (emit) the node panel was filled: the Work list reads the threads list once; threads:changed: it was read, or the map changed, so the node panel draws "Threads" again
102
+ * history:section node -> HTML | undefined (ask, answered by history.js when the config says `history: true`) the node panel's History section (spec 0014 D2); history:pick spec | null
103
+ * (emit): light what a spec's commits reached; history:all (emit): list every commit; history:changed (emit): the panel draws History again
102
104
  * work:list { open } the Work list opened or closed (pieces/work-list.js)
103
105
  * work:pick { kind, key } -> true (ask, answered by the Work view: explorer/work-view.js) select the node of that piece of work (`pull`, `issue`, `thread`, `run`, `deploy`, `proposal`, and its number, id or slug) on the map; no answer: the Work piece shows it in the node panel alone, as it shows work older than the graph's 14 days
104
106
  * work:panel node -> { replace, badge, title, html } | undefined (ask, answered by the Work view) what the node panel shows for a piece of work or, in the Work view, a node of code; the html holds `forge-detail`, where the Work piece draws the actions
package/explorer/page.js CHANGED
@@ -62,6 +62,7 @@ import { initTheme, setThemeChoice } from './theme.js';
62
62
  import { initAccountMenu } from './account-menu.js';
63
63
  import { watchHeaderFit } from './header-fit.js';
64
64
  import { watchHint } from './hint.js';
65
+ import { initHistory } from './history.js';
65
66
 
66
67
  /** The instance and its map: made by `startPage`, the one of this document */
67
68
  let inst;
@@ -203,6 +204,7 @@ export function startPage() {
203
204
  initWhatIf(); // before a proposal can open, so its edits come with it
204
205
  initReview(); // the decision follows the what-if editor's edits
205
206
  initMockups(); // a proposal's screens open from the node they name
207
+ initHistory(inst, config); // a node's commits and their trails in the node panel, read when first shown (history.js; only with `history: true`)
206
208
  // /?proposal=<slug> (&source=, &proposalView=) opens a proposal, as a host would ask for one (page-address.js)
207
209
  const proposalOpened = await openFromAddress(inst, window.location.search);
208
210
  // The live layer (live.js): loads only once a live layer goes on in the Layers menu; with no source it stays off
@@ -61,6 +61,13 @@ export const markup = () => ({
61
61
  <div class="hx-legend-row"><span class="hx-run-swatch hx-run-swatch--flight" aria-hidden="true"></span><span>In flight: a pulsing ring (still under reduced motion)</span></div>
62
62
  <div class="hx-legend-row"><span class="hx-run-swatch hx-run-swatch--collision" aria-hidden="true"></span><span>Collision: dashed ring, ⚠ and the words, where two open runs change one node</span></div>
63
63
  </div>
64
+ <div id="history-legend" class="hx-menu-section" data-corn="menu-section" hidden>
65
+ <div class="hx-menu-title" data-corn="menu-title"><span>History</span></div>
66
+ <div class="hx-legend-row"><span class="hx-history-swatch hx-history-swatch--wide" aria-hidden="true"></span><span>A wider halo: changed more often</span></div>
67
+ <div class="hx-legend-row"><span class="hx-history-swatch" data-band="week" aria-hidden="true"></span><span>Changed this week</span></div>
68
+ <div class="hx-legend-row"><span class="hx-history-swatch" data-band="month" aria-hidden="true"></span><span>Changed this month</span></div>
69
+ <div class="hx-legend-row"><span class="hx-history-swatch" data-band="old" aria-hidden="true"></span><span>Not for over a month (as of the timeline's commit)</span></div>
70
+ </div>
64
71
  <div id="proposal-legend" class="hx-menu-section" data-corn="menu-section" hidden>
65
72
  <div class="hx-menu-title" data-corn="menu-title"><span>Proposal marks</span></div>
66
73
  <div class="hx-legend-row"><span class="hx-mark-dot hx-mark-dot--added" data-corn="mark-dot" data-corn-state="added"></span><span>Added: dashed ring</span></div>
@@ -316,7 +323,8 @@ export function mount(root, inst, options = {}) {
316
323
  scope.on('layers:redraw', renderLayerToggles);
317
324
  scope.on('theme', renderLayerToggles); // the dots and the legends are drawn in the theme's colours
318
325
  scope.on('view', syncView);
319
- scope.on('runs:map', ({ active }) => { const legend = own('runs-legend'); if (legend) legend.hidden = !active; }); // runs are on the map (the Work list): the legend says what each mark is
326
+ scope.on('runs:map', ({ active }) => { const legend = own('runs-legend'); if (legend) legend.hidden = !active; });
327
+ scope.on('history:legend', ({ active }) => { const legend = own('history-legend'); if (legend) legend.hidden = !active; }); // the History layer is drawn (history.js): what a halo's width and colour say // runs are on the map (the Work list): the legend says what each mark is
320
328
  // The marks legend is there while a proposal is open (the proposal's bar says so: engine/proposal.js)
321
329
  const showLegend = (open) => { const legend = own('proposal-legend'); if (legend) legend.hidden = !open; };
322
330
  scope.on('proposal:draw', ({ open }) => showLegend(open));
@@ -370,7 +370,7 @@ export function mount(root, inst, options = {}) {
370
370
  }
371
371
 
372
372
  const metaList = own('drawer-meta-list');
373
- scope.listen(metaList, 'click', (e) => { if (!onLinesClick(e)) toggleCapped(e.target); });
373
+ scope.listen(metaList, 'click', (e) => { if (!onLinesClick(e) && !onHistoryClick(e)) toggleCapped(e.target); });
374
374
  scope.listen(metaList, 'change', onLinesChange);
375
375
 
376
376
  /** Keeps "9 connected · 3 off screen" true as the camera moves (after every draw, while a node is selected and its panel is open) */
@@ -391,6 +391,26 @@ export function mount(root, inst, options = {}) {
391
391
  addParts(box);
392
392
  }
393
393
 
394
+ /** Draws "History" again in the open panel (spec 0014 D2: the history was read, a spec was picked, or Show all); nothing else in the panel moves */
395
+ function repaintHistory() {
396
+ const box = own('drawer-history');
397
+ const node = state.selectedNode;
398
+ if (!box || !node || gone) return;
399
+ const active = inst.active();
400
+ const key = active && box.contains(active) ? (active.dataset.historySpec ? `spec:${active.dataset.historySpec}` : active.hasAttribute('data-history-all') ? 'all' : '') : '';
401
+ box.innerHTML = inst.ask('history:section', node) || '';
402
+ addParts(box);
403
+ if (key.startsWith('spec:')) { const el = [...box.querySelectorAll('[data-history-spec]')].find((x) => `spec:${x.dataset.historySpec}` === key); if (el) el.focus(); }
404
+ else if (key === 'all') { const first = box.querySelector('.hx-history-commit a'); if (first) first.focus(); }
405
+ }
406
+ /** A spec's chip in "History" picks it (or ends the pick); "Show all" lists every commit */
407
+ function onHistoryClick(e) {
408
+ const spec = e.target.closest && e.target.closest('[data-history-spec]');
409
+ if (spec) { inst.emit('history:pick', spec.dataset.historySpec); return true; }
410
+ if (e.target.closest && e.target.closest('[data-history-all]')) { inst.emit('history:all'); return true; }
411
+ return false;
412
+ }
413
+
394
414
  /** What the Work view put first in the panel for a node of code (the Work layer's "Open work", or the work touching it in the Work view): its elements and its markup */
395
415
  let workShown = { node: null, html: '', els: [] };
396
416
  function putWork(node, html) {
@@ -437,6 +457,7 @@ export function mount(root, inst, options = {}) {
437
457
  <div id="drawer-live">${live}</div>
438
458
  ${nodeMockupsHtml(state, node.id)}
439
459
  <div id="drawer-threads">${sections.threadsSection(node)}</div>
460
+ <div id="drawer-history">${inst.ask('history:section', node) || ''}</div>
440
461
  ${sections.diffSection(node)}`;
441
462
  addParts(metaList);
442
463
  inst.emit('threads:ensure'); // the Work list reads the threads once, for "Mentioned in"
@@ -573,6 +594,7 @@ export function mount(root, inst, options = {}) {
573
594
  });
574
595
  // The threads that mention nodes changed (the list was read, or the map changed): the section is drawn again
575
596
  scope.on('threads:changed', () => repaintThreads());
597
+ scope.on('history:changed', () => repaintHistory());
576
598
  scope.on('work:changed', () => repaintWork());
577
599
  // The dim layer behind the panel: on a phone a tap there folds the panel to its peek; elsewhere it closes it
578
600
  if (!inline) {
package/explorer/scene.js CHANGED
@@ -589,9 +589,11 @@ function buildNodes(state, subgraph) {
589
589
  // deep dimming for what is not connected; a proposal's Diff view fades what it does not touch, less deeply, and a removed node is faded too
590
590
  // A search's matches are what the reader asked for: a selection's focus does not dim them, so each keeps its label (spec 0008 D4)
591
591
  const dimmed = state.view === 'work' ? PROPOSAL_DIM_ALPHA : DIM_ALPHA; // the Work view dims to what the mock shows: the rest is still readable
592
- let alpha = subgraph && !connected && !(searching && match) ? dimmed : 1;
592
+ const picked = !!state.historyPick && state.historyPick.nodes.has(node.id); // a picked spec's nodes are what the reader asked for, as a search's matches are
593
+ let alpha = subgraph && !connected && !(searching && match) && !picked ? dimmed : 1;
593
594
  if (searching && !match && !selected && !(subgraph && connected)) alpha = dimmed; // a search dims what it did not find, as a focus does
594
595
  if (node.dim === true) alpha = Math.min(alpha, dimmed); // "Waiting on you" (work-view.js)
596
+ if (state.historyPick && !picked && !selected) alpha = Math.min(alpha, dimmed); // a picked spec lights what it reached (history.js, spec 0014 D3)
595
597
  const greyed = grey && !!focus && !focus.touched.has(node.id);
596
598
  if (focus && !focus.touched.has(node.id)) alpha = Math.min(alpha, greyed ? GREY_ALPHA : PROPOSAL_DIM_ALPHA);
597
599
  if (look) alpha *= gone ? MARK.removed.alpha : look.alpha;
@@ -203,6 +203,10 @@
203
203
  --corn-work-edge-work: auto;
204
204
  --corn-work-edge-code: auto;
205
205
  --corn-work-edge-adds: auto;
206
+ /* The History layer (spec 0014 D3): a node's halo, by how lately it changed as of the timeline's commit */
207
+ --corn-history-week: #f472b6;
208
+ --corn-history-month: #a78bfa;
209
+ --corn-history-old: #94a3b8;
206
210
  /* Node fill by group */
207
211
  --corn-map-group-app: auto;
208
212
  --corn-map-group-pkg: auto;
@@ -256,6 +260,9 @@
256
260
  --corn-info: #03679e;
257
261
 
258
262
  --corn-added: #197c6f;
263
+ --corn-history-week: #be185d;
264
+ --corn-history-month: #6d28d9;
265
+ --corn-history-old: #64748b;
259
266
  --corn-changed: #8f6703;
260
267
  --corn-removed: #e20b0b;
261
268
  --corn-edit: #6839f6;
@@ -305,6 +312,9 @@
305
312
  --corn-info: #03679e;
306
313
 
307
314
  --corn-added: #197c6f;
315
+ --corn-history-week: #be185d;
316
+ --corn-history-month: #6d28d9;
317
+ --corn-history-old: #64748b;
308
318
  --corn-changed: #8f6703;
309
319
  --corn-removed: #e20b0b;
310
320
  --corn-edit: #6839f6;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cornfield",
3
- "version": "0.59.0",
3
+ "version": "0.61.0",
4
4
  "description": "A self-hostable dev dashboard with the topology map at its centre: proposals on the map, scenarios, outages and what-if edits, for any repo.",
5
5
  "license": "MIT",
6
6
  "author": "popcorn245 (https://github.com/popcorn245)",