cornfield 0.44.0 → 0.45.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
@@ -26,7 +26,7 @@ import { MAX_THEME_BYTES, cssProblems, withoutComments } from './theme.js';
26
26
  import { MIN_SHAPE_DELTA_E, NODE_SHAPES, NODE_THEMES } from './schema.js';
27
27
  import { deltaE2000 } from './delta-e.js';
28
28
  import { LAYER_KEY_RE, MAX_KEY, mapFillNames, parseKindToken } from './layers.js';
29
- import { DIFF_MARK_COLORS, DIFF_LABEL_ALPHA, markOpacity } from '../explorer/diff-marks.js';
29
+ import { DIFF_MARK_COLORS, DIFF_LABEL_ALPHA, GREY_ALPHA, GREY_LABEL_ALPHA, GREY_MIN_RATIO, markOpacity } from '../explorer/diff-marks.js';
30
30
  import { lightColor } from '../explorer/theme-model.js';
31
31
 
32
32
  /** WCAG 2.1 AA: text, and large text and user-interface parts */
@@ -586,6 +586,15 @@ function mapFindings(props, theme, mode, grounds, extra = []) {
586
586
  out.push({ ...base, fg: '--corn-map-stroke', bg: weakest.on, min: MAP_FILL_MIN, kind: 'ui', use: `the outline that carries ${what}, which is ${fmt(f.ratio)} on its own`, fgValue: onGround.fgValue, bgValue: weakest.value, ratio: weakest.r });
587
587
  }
588
588
  // Labels are text: the colour against the ground, and against the halo under it (the halo is the ground's own colour at `auto`)
589
+ // What a review greys, when the theme sets the colour (issue #232): readable as a colour, and at its faded strength still told from the ground. `auto` is each tone with its hue taken away (a test holds it)
590
+ const grey = mapToken(props, '--corn-map-grey');
591
+ if (grey.problem) out.push({ ...base, fg: '--corn-map-grey', bg: GROUND, min: GREY_MIN_RATIO, kind: 'ui', use: 'a node the review greys', problem: grey.problem });
592
+ else if (grey.color) {
593
+ const alphaText = props.has('--corn-map-grey-alpha') ? substitute(props.get('--corn-map-grey-alpha'), props).trim() : '';
594
+ const a = /^\d*\.?\d+$/.test(alphaText) && +alphaText >= 0.1 && +alphaText <= 1 ? +alphaText : GREY_ALPHA;
595
+ const w = worstOnGrounds([grey.color[0], grey.color[1], grey.color[2], grey.color[3] * a], grounds);
596
+ out.push({ ...base, fg: '--corn-map-grey', bg: GROUND, min: GREY_MIN_RATIO, kind: 'ui', use: `a node the review greys, left at ${Math.round(a * 100)}% opacity`, fgValue: w.fgValue, bgValue: w.bgValue, ratio: w.ratio, ...(w.image ? { groundImage: true } : {}) });
597
+ }
589
598
  const label = mapToken(props, '--corn-map-label');
590
599
  const haloTok = mapToken(props, '--corn-map-label-halo');
591
600
  const labelColor = label.color || (label.problem ? null : readColor(mode === 'light' ? lightColor('#f8fafc') : '#f8fafc'));
@@ -670,6 +679,8 @@ function mapGrounds(grounds, base, props) {
670
679
  const DIFF_MAP_PAIRS = (mode) => [
671
680
  ...['added', 'changed', 'removed', 'edit'].map((m) => [`--corn-map-${m}`, DIFF_MARK_COLORS[mode][m], markOpacity(m), `the ${m} mark on the map, drawn at ${Math.round(markOpacity(m) * 100)}% opacity`]),
672
681
  ['--corn-map-label', mode === 'light' ? lightColor('#f8fafc', 'text') : '#f8fafc', DIFF_LABEL_ALPHA, `a label the diff dims, drawn at ${Math.round(DIFF_LABEL_ALPHA * 100)}% opacity`],
682
+ // a label a review greys (issue #232), where it is fainter than a dimmed one (the dark ground)
683
+ ...(GREY_LABEL_ALPHA[mode] !== DIFF_LABEL_ALPHA ? [['--corn-map-label', mode === 'light' ? lightColor('#f8fafc', 'text') : '#f8fafc', GREY_LABEL_ALPHA[mode], `a label a review greys, drawn at ${Math.round(GREY_LABEL_ALPHA[mode] * 100)}% opacity`]] : []),
673
684
  ];
674
685
 
675
686
  function diffMapFindings(props, theme, mode, grounds, base) {
@@ -1,7 +1,7 @@
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`, `--corn-map-glow` and `--corn-map-label-min`. The
4
+ * The map's non-colour tokens, as `cornfield validate` reads them: `--corn-map-font`, `--corn-map-edge-width`, `--corn-map-glow`, `--corn-map-label-min` and `--corn-map-grey-alpha`. 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
  */
@@ -10,12 +10,13 @@ import { declaredProps, expand, projectGroupOf, resolveProps, themesToCheck } fr
10
10
  import { iconKeyShape, parseKindToken } from './layers.js';
11
11
  import { readColor } from './color.js';
12
12
  import { MAX_NODE_COLOR_CHARS } from '../explorer/css-color.js';
13
- 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';
13
+ import { EDGE_WIDTH_TOKEN, FONT_TOKEN, GLOW_TOKEN, GREY_ALPHA_TOKEN, LABEL_MIN_TOKEN, MAX_EDGE_WIDTH, MAX_GLOW, MAX_LABEL_MIN, readMapTokens } from '../explorer/map-style.js';
14
14
 
15
15
  const WANTS = {
16
16
  [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)'],
17
17
  [EDGE_WIDTH_TOKEN]: ['edgeWidth', `a width in px over 0 and at most ${MAX_EDGE_WIDTH}`],
18
18
  [GLOW_TOKEN]: ['glow', `a factor from 0 (no glow) to ${MAX_GLOW}`],
19
+ [GREY_ALPHA_TOKEN]: ['greyAlpha', 'a number from 0.1 to 1 (0.45 is the default; a greyed node under 0.1 would vanish)'],
19
20
  [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)`],
20
21
  };
21
22
 
package/core/strings.js CHANGED
@@ -39,6 +39,9 @@ export const STRINGS = Object.freeze({
39
39
  undo: 'Undo',
40
40
  approved: 'Approved',
41
41
  myEdits: 'My edits',
42
+ showWholeMap: 'Show the whole map',
43
+ wholeMap: 'Whole map',
44
+ hiddenWhileReviewing: 'hidden while reviewing',
42
45
  yourEdits: 'Your edits',
43
46
  cancelLanding: 'Cancel landing',
44
47
  queueIt: 'Queue it',
package/explorer/check.js CHANGED
@@ -23,7 +23,8 @@
23
23
  */
24
24
 
25
25
  import { state, escHtml } from './state.js';
26
- import { toggleLayer } from './layers.js';
26
+ import { setLayer } from './layers.js';
27
+ import { layersOf } from './layer-model.js';
27
28
  import { mapIndex, personaLabel, planChecks, runChecks, stepVerdict, verdictWords } from './check-model.js';
28
29
  import { cornState } from './corn-state.js';
29
30
 
@@ -53,7 +54,7 @@ export function openChecks(scenario, onChange = () => {}) {
53
54
  if (current && current.scenario && scenario && current.scenario.id === scenario.id) { current.onChange = onChange; replan(scenario); return; }
54
55
  closeChecks();
55
56
  current = { scenario: null, as: null, nodes: null, plan: null, answer: { status: 'idle' }, controller: null, onChange };
56
- if (namesActor(scenario) && state.activeLayers.persona !== true) toggleLayer('persona');
57
+ if (namesActor(scenario) && layersOf(state).persona !== true) setLayer('persona', true, { scenario: true });
57
58
  replan(scenario);
58
59
  }
59
60
 
@@ -26,6 +26,18 @@ export const markOpacity = (mark) => EDGE_MIN_ALPHA * (mark === 'removed' || mar
26
26
  /** The opacity of the label of a node a diff dims (the node itself is at PROPOSAL_DIM_ALPHA) */
27
27
  export const DIFF_LABEL_ALPHA = 0.6;
28
28
 
29
+ /**
30
+ * How much of a node a review greys (issue #232) is left (`--corn-map-grey-alpha: auto`), and the least a greyed disc may differ from the ground it sits on
31
+ * (core/contrast.js checks a theme's `--corn-map-grey` against it): faded, but the map still reads as a map. Its label is at GREY_LABEL_ALPHA (below).
32
+ */
33
+ export const GREY_ALPHA = 0.45;
34
+ export const GREY_MIN_RATIO = 1.5;
35
+ /**
36
+ * The opacity of a greyed node's label, by ground: near the dimmed-label floor (4.4:1 on the default light ground, 5.2:1 on the dark, 4.75:1 on retro's navy),
37
+ * so the change's labels are the strongest text on the map. On the dark ground DIFF_LABEL_ALPHA would leave it near 7:1. core/contrast.js checks both.
38
+ */
39
+ export const GREY_LABEL_ALPHA = Object.freeze({ light: DIFF_LABEL_ALPHA, dark: 0.5 });
40
+
29
41
  /** How a mark differs without colour: the ring's dash (`null` is solid) and whether it is struck through. Four marks, four styles. */
30
42
  export const MARK_SHAPES = Object.freeze({
31
43
  added: Object.freeze({ ringDash: Object.freeze([5, 4]), edgeDash: Object.freeze([7, 5]), strike: false }), // a dashed ring
@@ -1462,7 +1462,7 @@ a.hx-proposal-source:focus-visible { outline: var(--corn-focus-width) solid var(
1462
1462
  @media (prefers-reduced-motion: reduce) { .hx-hold { display: none; } .hx-hold-fill { animation: none; } } /* only the words count down */
1463
1463
  .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); }
1464
1464
  .hx-proposal-yours { display: inline-flex; align-items: center; gap: var(--corn-space-1); color: var(--corn-text-2); }
1465
- .hx-proposal-tools [aria-pressed="false"] { opacity: 0.8; }
1465
+ .hx-proposal-tools [aria-pressed="false"]:not([data-corn="whole-map"]) { opacity: 0.8; } /* My edits off; "Whole map" off is the review's own view, not a faded choice */
1466
1466
  .hx-whatif-row [aria-disabled="true"] { opacity: 0.55; cursor: default; }
1467
1467
  .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; }
1468
1468
  .hx-runner-dot[hidden] { display: none; }
@@ -1499,3 +1499,14 @@ a.hx-proposal-source:focus-visible { outline: var(--corn-focus-width) solid var(
1499
1499
  /* (the waiting line's Answer is in the proposal bar too, so it is the bar's height; it is a strip's action elsewhere, at its own size) */
1500
1500
  :where(.hx-forge-head, .hx-player-controls, .hx-player-as, .hx-proposal-bar .hx-waiting-line) .hx-btn, :where(.hx-header) .hx-live-chip { height: var(--hx-control-h); }
1501
1501
  /* ==== end of the panel head and control height ============================================================================================ */
1502
+
1503
+ /* ---- The review narrows the map to the change (issue #232) ---- */
1504
+ /* A Layers row the review hid: its name with "hidden while reviewing" under it */
1505
+ .hx-toggle-text { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; }
1506
+ /* On a desk "Whole map" sits on the title's row, beside the source, so the row of counts, Compare, Edit and More keeps the one line it had: at the
1507
+ control height, drawn over the row's own 24px (the source's; --corn-space-6) so the bar is no taller. On a phone it stays with Edit, 44px */
1508
+ @media (min-width: 768px) {
1509
+ .hx-proposal-tools { display: contents; }
1510
+ .hx-proposal-name, .hx-proposal-source { order: -2; }
1511
+ :where(.hx-proposal-head) [data-corn="whole-map"] { order: -1; margin-block: calc((var(--corn-space-6) - var(--hx-control-h)) / 2); } /* the row is 24px (--corn-space-6 by default), the source's height */
1512
+ }
package/explorer/flows.js CHANGED
@@ -15,6 +15,7 @@
15
15
  import { state, nameOf, escHtml } from './state.js';
16
16
  import { themed } from './theme-model.js';
17
17
  import { capped } from './capped.js';
18
+ import { layersOf } from './layer-model.js';
18
19
 
19
20
  export const FLOW_STYLES = {
20
21
  outbox: { color: '#f59e0b', label: 'Outbox → API (writes)' },
@@ -132,7 +133,7 @@ export function buildDataFlow(nodes, edges) {
132
133
  export function renderFlowLegend() {
133
134
  const el = document.getElementById('flow-legend');
134
135
  if (!el) return;
135
- const { activeLayers } = state;
136
+ const activeLayers = layersOf(state);
136
137
  if (activeLayers.flow === false && activeLayers.table === false) { el.innerHTML = ''; el.hidden = true; return; }
137
138
  el.hidden = false;
138
139
  const row = (swatch, text) => `<div class="hx-legend-row"><span class="hx-legend-swatch">${swatch}</span><span>${text}</span></div>`;
@@ -74,6 +74,7 @@ import { trapTab } from './focusables.js';
74
74
  import { isPhone, registerSheet, expandSheet, collapseSheet, showSheet, refreshStubs } from './sheets.js';
75
75
  import { relativeTime } from './review-model.js';
76
76
  import { LAYER_DEFS, toggleLayer } from './layers.js';
77
+ import { layerOn } from './layer-model.js';
77
78
  import { WORK_URL, groupWork, filterGroups, groupWords, workStatus, markWords } from './agents-model.js';
78
79
  import {
79
80
  RUNS_URL, runsUrl, stopUrl, runOnThread, threadRunWords, runOnPull, pullRunWords, canRetry, retryRefs, retryWords, limitsFromFields, defaultLimits, LIMIT_KEYS, briefUrl, answerUrl, answerBody, answerWordsFor, KINDS, aboutWords, statusWords, statusWhy, runMeta, canStop, runsStatus, runnerState, runnerWords, triggerNotice, totalsLines, handLines, startBody, startWords, stopWords, confirmStartWords, litOfRun, changeWords,
@@ -494,7 +495,7 @@ export function selectDeploy(id) {
494
495
  const turnedOn = [];
495
496
  for (const n of litForDeploy(found, state.nodes).nodes) {
496
497
  const layer = LAYER_DEFS.find((l) => l.key === n.type);
497
- if (layer && state.activeLayers[layer.key] === false) { toggleLayer(layer.key); turnedOn.push(layer.label); }
498
+ if (layer && !layerOn(state, layer.key)) { toggleLayer(layer.key); turnedOn.push(layer.label); }
498
499
  }
499
500
  relight();
500
501
  $('forge-panel').querySelector('.hx-forge-body').scrollTop = 0; // the deploy's nodes are what was asked for, not the row that was tapped
@@ -216,6 +216,9 @@
216
216
  </div>
217
217
  <div class="hx-proposal-tools">
218
218
  <!-- 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) -->
219
+ <!-- The review narrows the map to the change; this puts the whole map back, as Diff always was (layers.js setWholeMap). Off at every opening -->
220
+ <!-- Its words are "Whole map", which read right pressed or not; its name and tooltip are the full "Show the whole map". On a desk it sits beside the title, so the bar keeps its rows (explorer.css) -->
221
+ <button data-corn="whole-map" data-corn-kind="secondary" type="button" id="proposal-whole" class="hx-btn" data-action="proposal-whole" aria-pressed="false" aria-label="Show the whole map" title="Show the whole map" data-peek-ok data-corn-string="wholeMap" data-corn-string-aria-label="showWholeMap">Whole map</button>
219
222
  <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>
220
223
  <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>
221
224
  </div>
@@ -69,8 +69,10 @@ const REF = 100;
69
69
  /** The grid the placing looks for neighbours in (px) */
70
70
  const CELL = 64;
71
71
 
72
- /** Priority tiers, best first */
73
- const TIER = { selected: 0, current: 1, match: 2, lit: 3, marked: 4, hub: 5, rest: 6 };
72
+ /** Priority tiers, best first. `greyed`: a node a review greys (issue #232), after everything else, a hub's title included */
73
+ const TIER = { selected: 0, current: 1, match: 2, lit: 3, marked: 4, hub: 5, rest: 6, greyed: 7 };
74
+ /** A greyed node's label keeps this many of its own heights clear on every side: the change's labels stand out, and the greyed map is named sparsely */
75
+ export const GREYED_ROOM = 1.5;
74
76
 
75
77
  /**
76
78
  * The smallest label size on screen (px) for a theme's `--corn-map-label-min` (a number, or null for `auto`): a theme may raise the 11 px,
@@ -82,14 +84,16 @@ export const labelMinPx = (value) => (Number.isFinite(value) && value >= LABEL_M
82
84
  /** The smallest label size on screen (px) for a scene: the theme's `--corn-map-label-min`, never under 11 */
83
85
  export const labelMinOf = (scene) => labelMinPx(scene.labelMin);
84
86
 
85
- const isHub = (node) => LANDMARK_TYPES.includes(node.type);
87
+ /** A cluster's title: bigger and bold, unless a review greys it (then it is a plain label, placed last) */
88
+ const isHub = (node) => LANDMARK_TYPES.includes(node.type) && !node.greyed;
86
89
 
87
90
  const tierOf = (node, focused) => (node.selected ? TIER.selected
88
91
  : node.current ? TIER.current
89
92
  : node.match ? TIER.match
90
93
  : focused && node.connected ? TIER.lit
91
94
  : (node.mark && node.mark !== 'none') || (node.labelKeep && !isHub(node)) ? TIER.marked
92
- : isHub(node) ? TIER.hub : TIER.rest);
95
+ : node.greyed ? TIER.greyed
96
+ : isHub(node) ? TIER.hub : TIER.rest);
93
97
 
94
98
  /**
95
99
  * Which node labels fit at `zoom`, and where. The whole map, not the view: a box is in zoom-scaled world coordinates (`x * zoom`, no
@@ -118,15 +122,16 @@ export function placeLabels(scene, zoom, opts = {}) {
118
122
  const gap = Math.max(GAP_PX, GAP_PX * zoom);
119
123
  for (const { node, index, tier } of cands) {
120
124
  const hub = isHub(node);
121
- const bold = !!node.labelBold || hub;
125
+ const bold = !node.greyed && (!!node.labelBold || hub); // a greyed node's label is plain, whatever asked for bold
122
126
  const px = Math.max(hub ? min + HUB_LABEL_EXTRA_PX : min, node.labelSize * zoom);
123
127
  const w = measure ? (measure(node.label, REF, bold) * px) / REF : node.label.length * px * GLYPH;
124
128
  const cx = node.x * zoom;
125
129
  const baseline = node.y * zoom + node.r * zoom + gap + px;
126
130
  const l = cx - w / 2, r = cx + w / 2, t = baseline - px * ASCENT, b = baseline + px * DESCENT;
127
- // Touching a placed box, give or take LABEL_PAD: skipped
128
- const i0 = Math.floor((l - LABEL_PAD) / CELL), i1 = Math.floor((r + LABEL_PAD) / CELL);
129
- const j0 = Math.floor((t - LABEL_PAD) / CELL), j1 = Math.floor((b + LABEL_PAD) / CELL);
131
+ // Touching a placed box, give or take LABEL_PAD (a greyed node's: GREYED_ROOM of its heights): skipped
132
+ const pad = tier === TIER.greyed ? LABEL_PAD + px * GREYED_ROOM : LABEL_PAD;
133
+ const i0 = Math.floor((l - pad) / CELL), i1 = Math.floor((r + pad) / CELL);
134
+ const j0 = Math.floor((t - pad) / CELL), j1 = Math.floor((b + pad) / CELL);
130
135
  let hit = false;
131
136
  for (let i = i0; i <= i1 && !hit; i++) {
132
137
  for (let j = j0; j <= j1 && !hit; j++) {
@@ -134,7 +139,7 @@ export function placeLabels(scene, zoom, opts = {}) {
134
139
  if (!cell) continue;
135
140
  for (let k = 0; k < cell.length; k++) {
136
141
  const o = cell[k];
137
- if (l - LABEL_PAD < o.r && r + LABEL_PAD > o.l && t - LABEL_PAD < o.b && b + LABEL_PAD > o.t) { hit = true; break; }
142
+ if (l - pad < o.r && r + pad > o.l && t - pad < o.b && b + pad > o.t) { hit = true; break; }
138
143
  }
139
144
  }
140
145
  }
@@ -9,10 +9,13 @@
9
9
  * - `shownByProposal(state, node)`: a node the open proposal touches is always drawn, whatever its layer says, so a review never hides its
10
10
  * own change.
11
11
  *
12
+ * - `touchedLayerKeys`, `reviewLayers`, `layersOf`, `layerOn`, `reviewHides` (issue #232): while a proposal is under review the map is narrowed to the
13
+ * change. The layers the proposal does not touch are off for the review; the viewer's own state (`state.activeLayers`) is never written.
14
+ *
12
15
  * The matching itself is core/layers.js (data only); this file only hands it the map's ownership line.
13
16
  */
14
17
 
15
- import { kindLetters, layerKeyOf, parentIndex, projectLayerOf } from '../core/layers.js';
18
+ import { STARTING_LAYERS, kindLetters, layerKeyOf, parentIndex, projectLayerOf } from '../core/layers.js';
16
19
  import { touchedIds } from './proposal-model.js';
17
20
 
18
21
  /** Asks the ownership line of the map the state holds, only when a layer matches by `parent` */
@@ -57,3 +60,90 @@ export function lettersOf(state, node) {
57
60
  const t = hit.map.get(node.type);
58
61
  return (t && t.get(node.kind)) || '';
59
62
  }
63
+
64
+ // ---------------------------------------------------------------------------
65
+ // The review narrows the map to the change (issue #232)
66
+ // ---------------------------------------------------------------------------
67
+
68
+ /** Layers a touched layer cannot show without (scene.js `layerShows`): Core needs Packages, Stores and ROM need Data Flow */
69
+ const NEEDS = Object.freeze({ core: ['pkg'], store: ['flow'], rom: ['flow'] });
70
+ const marked = (item) => !!item && !!item.mark && item.mark !== 'none';
71
+
72
+ /**
73
+ * The keys of the layers a proposal touches: the layer of every node it marks (added, changed, removed, or a what-if edit) and of both ends of an
74
+ * edge it marks, the Data Flow overlay when a marked edge is a flow, the Runs overlay when a touched node has a run in flight, and what a touched
75
+ * layer cannot be drawn without (`NEEDS`). The root has no layer. Pure: the map, what the layers are, the runs.
76
+ * @param {{ nodes: {id: string, mark?: string}[], edges: {from: string, to: string, kind?: string, mark?: string}[], rowOf: (node: object) => string | null, flight?: { has(id: string): boolean } | null }} map
77
+ * @returns {Set<string>}
78
+ */
79
+ export function touchedLayerKeys({ nodes, edges, rowOf, flight = null }) {
80
+ const { touched } = touchedIds(nodes, edges);
81
+ const keys = new Set();
82
+ for (const n of nodes) {
83
+ if (!touched.has(n.id)) continue;
84
+ const key = rowOf(n);
85
+ if (key) { keys.add(key); for (const need of NEEDS[key] || []) keys.add(need); }
86
+ if (flight && flight.has(n.id)) keys.add('runs');
87
+ }
88
+ for (const e of edges) if (marked(e) && e.kind === 'flow') keys.add('flow');
89
+ return keys;
90
+ }
91
+
92
+ /**
93
+ * The layers a review shows, from the viewer's own (`active`), as a new map. Untouched layers are off and touched ones on (a layer the viewer had
94
+ * off comes on for the review); then what the reviewer did by hand (`manual`) and what a playing scenario turned on (`step`). With `whole` the map
95
+ * is the viewer's as it always was, with only the hand and the scenario laid over it. `universe`: every layer key the menu knows.
96
+ * @param {{ active: Record<string, boolean>, touched: Set<string>, universe: Iterable<string>, review: { whole?: boolean, manual?: Record<string, boolean>, step?: Record<string, boolean> } }} a
97
+ * @returns {Record<string, boolean>}
98
+ */
99
+ export function reviewLayers({ active, touched, universe, review }) {
100
+ const out = { ...active };
101
+ if (!review.whole && touched.size) for (const key of universe) out[key] = touched.has(key); // a proposal that touches no layer has nothing to narrow the map to: it is left whole
102
+ Object.assign(out, review.manual || {}, review.step || {});
103
+ return out;
104
+ }
105
+
106
+ const layerKeysMemo = new WeakMap();
107
+ /** The touched layer keys of the open proposal's map: kept while the map, the runs and the layers' ownership are the same */
108
+ function touchedLayers(state) {
109
+ const nodes = state.nodes;
110
+ const edges = state.edges || [];
111
+ const flight = state.runsMap ? state.runsMap.flight : null;
112
+ const hit = layerKeysMemo.get(nodes);
113
+ if (hit && hit.edges === edges && hit.n === nodes.length && hit.e === edges.length && hit.flight === flight && hit.project === state.projectLayers) return hit;
114
+ const touched = touchedLayerKeys({ nodes, edges, rowOf: (n) => rowKeyOf(state, n), flight });
115
+ const universe = new Set([...STARTING_LAYERS.map((l) => l.key), ...(state.projectLayers || []).map((l) => l.key), ...nodes.map((n) => rowKeyOf(state, n)).filter(Boolean)]);
116
+ const made = { edges, n: nodes.length, e: edges.length, flight, project: state.projectLayers, touched, universe };
117
+ layerKeysMemo.set(nodes, made);
118
+ return made;
119
+ }
120
+
121
+ const layersMemo = new WeakMap();
122
+ /**
123
+ * The layers the map is drawn with: `state.activeLayers` itself with no review open, else the review's (`reviewLayers`). Every reader of a layer's
124
+ * state for what is drawn goes through this, so the review's hiding is decided in one place.
125
+ */
126
+ export function layersOf(state) {
127
+ const review = state.review;
128
+ if (!review || !state.proposal) return state.activeLayers;
129
+ const hit = layersMemo.get(review);
130
+ if (hit && hit.rev === review.rev && hit.version === state.sceneVersion && hit.active === state.activeLayers && hit.nodes === state.nodes) return hit.out;
131
+ const { touched, universe } = touchedLayers(state);
132
+ const out = reviewLayers({ active: state.activeLayers, touched, universe, review });
133
+ layersMemo.set(review, { rev: review.rev, version: state.sceneVersion, active: state.activeLayers, nodes: state.nodes, out });
134
+ return out;
135
+ }
136
+
137
+ /** Whether a layer is on for what is drawn (a layer with no entry is on, as the menu shows it) */
138
+ export const layerOn = (state, key) => layersOf(state)[key] !== false;
139
+
140
+ /** Whether the review hid this layer, which the viewer has on: the row says so, and the reviewer may turn it on for the review */
141
+ export function reviewHides(state, key) {
142
+ const r = state.review;
143
+ if (!r || !state.proposal || r.whole) return false;
144
+ if (state.activeLayers[key] === false || Object.hasOwn(r.manual || {}, key) || Object.hasOwn(r.step || {}, key)) return false;
145
+ return layersOf(state)[key] === false;
146
+ }
147
+
148
+ /** Whether the greying is on: a review is open, the whole map is not asked for, and the proposal involves something (a proposal that changes nothing greys nothing: scene.js, map-style.js) */
149
+ export const greying = (state) => !!state.review && !!state.proposal && !state.review.whole && touchedBy(state).size > 0;
@@ -15,7 +15,7 @@ import { themed } from './theme-model.js';
15
15
  import { onThemeChange } from './theme.js';
16
16
  import { NODE_THEMES } from '../core/schema.js';
17
17
  import { STARTING_LAYERS, clientLayers, kindLetters, orderRows, startingLayerOf } from '../core/layers.js';
18
- import { rowKeyOf, shownByProposal } from './layer-model.js';
18
+ import { layerOn, reviewHides, rowKeyOf, shownByProposal } from './layer-model.js';
19
19
  import { fillOfNode, groupOf, layerShows } from './scene.js';
20
20
  import { STROKE_TOKEN, cssColor, fillOf, getMapStyle, kindToken, onMapStyleChange, pageReader, setMapSubjects } from './map-style.js';
21
21
  import { over, parseColor, contrast } from '../core/color.js';
@@ -79,7 +79,8 @@ export function clickWithLegendMenu(target, act) {
79
79
 
80
80
  /** What a layer is when the viewer has not touched it: the config's `off`, else a starting layer's own default, else on */
81
81
  const defaultOf = (key) => (Object.hasOwn(state.layerDefaults, key) ? state.layerDefaults[key] : !STARTS_OFF.has(key));
82
- const isOn = (key) => state.activeLayers[key] !== false;
82
+ /** Whether a layer is on for what is drawn: the viewer's, or the review's while a proposal is under review (layer-model.js) */
83
+ const isOn = (key) => layerOn(state, key);
83
84
 
84
85
  const NO_COLOR = '#94a3b8';
85
86
  /** A colour as the dot's style may hold it: a hex or an rgb()/rgba() of numbers, else the plain grey. A node's colour is the map's data
@@ -299,11 +300,14 @@ export function renderLayerToggles() {
299
300
  const row = (layer) => {
300
301
  const on = isOn(layer.key);
301
302
  const shown = byProposal[layer.key] ? `<span class="hx-faint hx-layer-note" data-corn="layer-note">+${byProposal[layer.key]} shown by the proposal</span>` : '';
303
+ // A row the review hid says so under its name (there is no room beside it): it can still be turned on, for the review
304
+ const hid = !shown && counts[layer.key] && reviewHides(state, layer.key) ? `<span class="hx-faint hx-layer-note" data-corn="layer-note">${escHtml(t('hiddenWhileReviewing'))}</span>` : '';
305
+ const name = `<span class="hx-toggle-name">${escHtml(layer.label)}</span>`;
302
306
  return `
303
307
  <button type="button" class="hx-toggle-row${on ? '' : ' is-off'}" data-action="toggle-layer" data-layer="${escHtml(layer.key)}" aria-pressed="${on}" title="${escHtml(layer.desc)}" data-corn="row">
304
308
  <span class="hx-toggle-label">
305
309
  ${dot(swatch(layer.color), on, surface)}
306
- <span class="hx-toggle-name">${escHtml(layer.label)}</span>${layer.live ? '<span class="hx-live-tag" data-corn="live-tag">live</span>' : ''}
310
+ ${hid ? `<span class="hx-toggle-text">${name}${hid}</span>` : name}${layer.live ? '<span class="hx-live-tag" data-corn="live-tag">live</span>' : ''}
307
311
  </span>
308
312
  <span class="hx-toggle-meta">${shown}
309
313
  <span class="hx-count" data-corn="count">${(UNIT[layer.key] || String)(counts[layer.key] || 0)}</span>
@@ -336,7 +340,7 @@ export function renderEdgeKey() {
336
340
  export function renderCloudLegend() {
337
341
  const el = document.getElementById('cloud-legend');
338
342
  if (!el) return;
339
- if (state.activeLayers.cloud === false) { el.innerHTML = ''; el.hidden = true; return; }
343
+ if (!layerOn(state, 'cloud')) { el.innerHTML = ''; el.hidden = true; return; }
340
344
  el.hidden = false;
341
345
  el.innerHTML = `
342
346
  <div class="hx-menu-title" data-corn="menu-title"><span>Cloud: when an outage bites</span></div>
@@ -361,35 +365,98 @@ function say(text) {
361
365
  }
362
366
 
363
367
  /**
364
- * Turns a layer on or off. `viewer`: the person chose it in the menu, so it is kept in their browser; a layer another part of the app
365
- * turns on (a deploy that lights a stack) is not a choice of theirs and is not kept.
368
+ * Sets a layer on or off. `viewer`: the person chose it in the menu, so it is kept in their browser; a layer another part of the app
369
+ * turns on (a deploy that lights a stack) is not a choice of theirs and is not kept. While a proposal is under review the choice is the review's:
370
+ * kept for the review only (`state.review.manual`, or `.step` when a playing scenario needs the layer: `scenario`), never in `activeLayers` or the browser.
366
371
  */
367
- export function toggleLayer(key, { viewer = false } = {}) {
368
- const on = state.activeLayers[key] === false; // a layer with no entry yet is on, as the toggles show it
369
- state.activeLayers[key] = on;
370
- if (viewer) { keep(key, on); writeChanges(); }
372
+ export function setLayer(key, on, { viewer = false, scenario = false } = {}) {
373
+ const review = state.review && state.proposal ? state.review : null;
374
+ if (review) {
375
+ (scenario ? review.step : review.manual)[key] = on;
376
+ review.rev++;
377
+ } else {
378
+ state.activeLayers[key] = on;
379
+ if (viewer) { keep(key, on); writeChanges(); }
380
+ }
371
381
  changed();
372
382
  if (viewer) {
373
383
  const { layers, overlays } = layerRows();
374
384
  const layer = [...layers, ...overlays].find((l) => l.key === key);
375
385
  const n = state.nodes.filter((x) => isNodeVisible(x)).length;
376
- say(`${layer ? layer.label : key} ${on ? 'on' : 'off'}. ${n} ${n === 1 ? 'node' : 'nodes'} shown.`);
386
+ say(`${layer ? layer.label : key} ${on ? 'on' : 'off'}${review ? ' for this review' : ''}. ${n} ${n === 1 ? 'node' : 'nodes'} shown.`);
377
387
  }
378
388
  }
379
389
 
380
- /** All / None: every layer on or off, never an overlay; the root stays drawn */
390
+ /** Flips a layer (what a click on its row does); see `setLayer` */
391
+ export function toggleLayer(key, opts = {}) {
392
+ setLayer(key, !layerOn(state, key), opts);
393
+ }
394
+
395
+ /** All / None: every layer on or off, never an overlay; the root stays drawn. During a review it is the review's state that changes, not the viewer's */
381
396
  export function toggleAllLayers(on, { viewer = false } = {}) {
382
397
  const { layers } = layerRows();
383
398
  const keys = new Set([...LAYER_DEFS.filter((l) => !l.overlay).map((l) => l.key), ...state.projectLayers.map((l) => l.key), ...layers.map((l) => l.key)]);
384
- keys.forEach((k) => { state.activeLayers[k] = on; if (viewer) keep(k, on); });
385
- if (viewer) writeChanges();
399
+ const review = state.review && state.proposal ? state.review : null;
400
+ if (review) { keys.forEach((k) => { review.manual[k] = on; }); review.rev++; } else {
401
+ keys.forEach((k) => { state.activeLayers[k] = on; if (viewer) keep(k, on); });
402
+ if (viewer) writeChanges();
403
+ }
386
404
  changed();
387
405
  if (viewer) {
388
406
  const n = state.nodes.filter((x) => isNodeVisible(x)).length;
389
- say(`${on ? 'All' : 'No'} layers on. ${n} ${n === 1 ? 'node' : 'nodes'} shown.`);
407
+ say(`${on ? 'All' : 'No'} layers on${review ? ' for this review' : ''}. ${n} ${n === 1 ? 'node' : 'nodes'} shown.`);
390
408
  }
391
409
  }
392
410
 
411
+ // ---------------------------------------------------------------------------
412
+ // The review narrows the map to the change (issue #232)
413
+ // The hiding is the review's, never the viewer's: `state.review` holds it (layer-model.js `layersOf` reads it), `activeLayers` and the saved choices are not touched.
414
+ // ---------------------------------------------------------------------------
415
+
416
+ /** A proposal is opened: a fresh review ("Show the whole map" off, nothing turned on by hand yet), also when one was already open */
417
+ export function beginReview() {
418
+ state.review = { whole: false, manual: {}, step: {}, rev: 0 }; // the map and the menu are drawn by the caller, once the proposal is on the map (proposal.js rebuildProposalMap)
419
+ }
420
+
421
+ /** The proposal is closed: the viewer's own layers are what is drawn again, exactly as they were */
422
+ export function endReview() {
423
+ if (!state.review) return;
424
+ state.review = null;
425
+ touchScene();
426
+ renderLayerToggles();
427
+ }
428
+
429
+ /** What a screen reader hears when a review opens and hid layers: "Showing 4 of 22 layers: the ones this proposal changes." Nothing when no layer was hidden */
430
+ export function reviewLayersLine() {
431
+ if (!state.review || !state.proposal || state.review.whole) return '';
432
+ const { layers } = layerRows();
433
+ const held = new Set(state.nodes.map((n) => rowKeyOf(state, n))); // a layer that holds no node has nothing to hide
434
+ if (!layers.some((l) => held.has(l.key) && reviewHides(state, l.key))) return '';
435
+ const on = layers.filter((l) => isOn(l.key)).length;
436
+ return `Showing ${on} of ${layers.length} layers: the ones this proposal changes.`;
437
+ }
438
+
439
+ /** "Show the whole map": on brings back every layer the viewer has on and the proposal's dimming of the rest (Diff as it always was); off narrows to the change again. Said once, here */
440
+ export function setWholeMap(on) {
441
+ const review = state.review && state.proposal ? state.review : null;
442
+ if (!review || review.whole === on) return;
443
+ review.whole = on;
444
+ review.rev++;
445
+ changed();
446
+ say(on ? 'Showing the whole map.' : (reviewLayersLine() || 'Showing the change: the rest of the map is greyed.'));
447
+ }
448
+
449
+ /** A scenario ended: the layers it turned on for the review go off again (the focused view comes back). True when there were any */
450
+ export function clearStepLayers() {
451
+ const review = state.review;
452
+ if (!review || !Object.keys(review.step).length) return false;
453
+ review.step = {};
454
+ review.rev++;
455
+ touchScene();
456
+ renderLayerToggles();
457
+ return true;
458
+ }
459
+
393
460
  /** Opens or closes the kinds of one row ("5 kinds"); the focus stays on its button */
394
461
  export function toggleLayerKinds(key) {
395
462
  if (openKinds.has(key)) openKinds.delete(key); else openKinds.add(key);
@@ -16,6 +16,8 @@
16
16
  * --corn-map-font the font list of every label on the map (a list of families, `auto` for the map's own)
17
17
  * --corn-map-edge-width the width of an ordinary line, in map px (`auto` keeps each line's own; the focus's and the marks' keep their proportion)
18
18
  * --corn-map-label-min the smallest a label is drawn on screen, in px (11 by default; below 9px it is ignored; a hub's title is 2 more)
19
+ * --corn-map-grey what a review greys (the nodes and lines a proposal does not involve) is drawn in: a colour, or `auto` for each one's own tone with its hue taken away
20
+ * --corn-map-grey-alpha how much of a greyed node is left: a number from 0.1 to 1 (`auto` is 0.45); its lines are faded in the same proportion
19
21
  * --corn-map-glow the soft glow round nodes, lines and packets: a factor (`0` none, `1` as drawn, `auto` as drawn)
20
22
  *
21
23
  * `auto` (the default of every one of them but the width and the collision) means "keep what the map draws without a theme": the
@@ -37,7 +39,7 @@ import { NODE_THEMES } from '../core/schema.js';
37
39
  import { parseColor } from './theme-model.js';
38
40
  import { cssColor, rgbaText } from './css-color.js';
39
41
  export { cssColor };
40
- import { LABEL_MIN_FLOOR, looksFor } from './scene.js';
42
+ import { GREY_ALPHA, LABEL_MIN_FLOOR, looksFor } from './scene.js';
41
43
  import { iconKeyShape, iconKeysFor, mapFillNames, mapGroupToken, mapKindToken } from '../core/layers.js';
42
44
 
43
45
  /** The node kinds (topology types) and the groups (layers a node can belong to) the tokens exist for */
@@ -57,6 +59,10 @@ export const FONT_TOKEN = '--corn-map-font';
57
59
  export const EDGE_WIDTH_TOKEN = '--corn-map-edge-width';
58
60
  export const GLOW_TOKEN = '--corn-map-glow';
59
61
  export const LABEL_MIN_TOKEN = '--corn-map-label-min';
62
+ export const GREY_TOKEN = '--corn-map-grey';
63
+ export const GREY_ALPHA_TOKEN = '--corn-map-grey-alpha';
64
+ /** The least a greyed node may be left at: under it the map would vanish (a value below is read as `auto`) */
65
+ export const MIN_GREY_ALPHA = 0.1;
60
66
  /** The ink of a node's glyph and of a finer kind's letters (spec 0008 D8); `auto` is the white or the dark that reads on the node's fill (glyphs.js) */
61
67
  export const GLYPH_TOKEN = '--corn-map-glyph';
62
68
  /** The largest label minimum a theme may ask for: bigger text would leave no room for another label */
@@ -91,12 +97,13 @@ export const MAP_COLOR_TOKENS = Object.freeze([
91
97
  LABEL_TOKEN,
92
98
  LABEL_HALO_TOKEN,
93
99
  GLYPH_TOKEN,
100
+ GREY_TOKEN,
94
101
  ...MAP_EDGE_KINDS.map(edgeToken),
95
102
  ...MAP_MARKS.map(stateToken),
96
103
  ...MAP_STATES.map(stateToken),
97
104
  ]);
98
105
  /** Every map token */
99
- export const mapTokenNames = () => [...MAP_COLOR_TOKENS, STROKE_WIDTH_TOKEN, COLLISION_TOKEN, FONT_TOKEN, EDGE_WIDTH_TOKEN, GLOW_TOKEN, LABEL_MIN_TOKEN];
106
+ export const mapTokenNames = () => [...MAP_COLOR_TOKENS, STROKE_WIDTH_TOKEN, COLLISION_TOKEN, FONT_TOKEN, EDGE_WIDTH_TOKEN, GLOW_TOKEN, LABEL_MIN_TOKEN, GREY_ALPHA_TOKEN];
100
107
 
101
108
  // ---------------------------------------------------------------------------
102
109
  // Reading a token
@@ -161,12 +168,19 @@ function factorOf(value) {
161
168
  return Number.isFinite(n) && n >= 0 && n <= MAX_GLOW ? n : null;
162
169
  }
163
170
 
171
+ /** The greyed node's opacity: a number from MIN_GREY_ALPHA to 1, or null for `auto` and anything else */
172
+ function greyAlphaOf(value) {
173
+ const m = /^\s*(\d*\.?\d+)\s*$/.exec(String(value ?? ''));
174
+ const n = m ? parseFloat(m[1]) : NaN;
175
+ return Number.isFinite(n) && n >= MIN_GREY_ALPHA && n <= 1 ? n : null;
176
+ }
177
+
164
178
  /**
165
179
  * The tokens as the page computes them.
166
180
  * @param {(name: string) => string} read the value of a custom property
167
181
  * @param {string[]} [extra] more colour tokens to read: those of the finer kinds and project layers on the map (`setMapSubjects`)
168
- * @returns {{values: Record<string, string>, strokeWidth: number, font: string | null, edgeWidth: number | null, glow: number | null, labelMin: number | null}}
169
- * `values` holds only the tokens that are a colour (not `auto`); `font`, `edgeWidth`, `glow` and `labelMin` are null at `auto` or when the value is not one
182
+ * @returns {{values: Record<string, string>, strokeWidth: number, font: string | null, edgeWidth: number | null, glow: number | null, labelMin: number | null, greyAlpha: number | null}}
183
+ * `values` holds only the tokens that are a colour (not `auto`); `font`, `edgeWidth`, `glow`, `labelMin` and `greyAlpha` are null at `auto` or when the value is not one
170
184
  */
171
185
  export function readMapTokens(read, extra = []) {
172
186
  const values = {};
@@ -182,6 +196,7 @@ export function readMapTokens(read, extra = []) {
182
196
  edgeWidth: pxOf(read(EDGE_WIDTH_TOKEN), MAX_EDGE_WIDTH),
183
197
  glow: factorOf(read(GLOW_TOKEN)),
184
198
  labelMin: labelMinOf(read(LABEL_MIN_TOKEN)),
199
+ greyAlpha: greyAlphaOf(read(GREY_ALPHA_TOKEN)),
185
200
  };
186
201
  }
187
202
 
@@ -251,12 +266,13 @@ export function createIconStore(urls, { load = loadImage, onChange = () => {}, w
251
266
  * @property {number | null} edgeWidth an ordinary line's width in px (`--corn-map-edge-width`), null at `auto`
252
267
  * @property {number | null} glow the glow factor (`--corn-map-glow`), null at `auto`
253
268
  * @property {number | null} labelMin the smallest label size in px (`--corn-map-label-min`), null at `auto` or under 9px
269
+ * @property {number | null} greyAlpha how much of a greyed node is left (`--corn-map-grey-alpha`), null at `auto` or when it is not a number from 0.1 to 1
254
270
  * @property {ReturnType<typeof createIconStore> | null} icons
255
271
  * @property {boolean} pixelated sample icons without smoothing
256
272
  * @property {boolean} plain nothing to apply: no colour set, no icon loaded (the scene is drawn as it is)
257
273
  */
258
274
 
259
- const NO_TOKENS = { values: {}, strokeWidth: DEFAULT_STROKE_WIDTH, font: null, edgeWidth: null, glow: null, labelMin: null };
275
+ const NO_TOKENS = { values: {}, strokeWidth: DEFAULT_STROKE_WIDTH, font: null, edgeWidth: null, glow: null, labelMin: null, greyAlpha: null };
260
276
  let tokens = NO_TOKENS;
261
277
  let icons = null;
262
278
  let pixelated = false;
@@ -265,8 +281,8 @@ let current = compose();
265
281
  const listeners = new Set();
266
282
 
267
283
  function compose() {
268
- const plain = !Object.keys(tokens.values).length && !(icons && icons.anyReady()) && tokens.font === null && tokens.edgeWidth === null && tokens.glow === null && tokens.labelMin === null;
269
- return Object.freeze({ version, values: tokens.values, strokeWidth: tokens.strokeWidth, font: tokens.font, edgeWidth: tokens.edgeWidth, glow: tokens.glow, labelMin: tokens.labelMin, icons, pixelated, plain });
284
+ const plain = !Object.keys(tokens.values).length && !(icons && icons.anyReady()) && tokens.font === null && tokens.edgeWidth === null && tokens.glow === null && tokens.labelMin === null && tokens.greyAlpha === null;
285
+ return Object.freeze({ version, values: tokens.values, strokeWidth: tokens.strokeWidth, font: tokens.font, edgeWidth: tokens.edgeWidth, glow: tokens.glow, labelMin: tokens.labelMin, greyAlpha: tokens.greyAlpha, icons, pixelated, plain });
270
286
  }
271
287
 
272
288
  function changed() {
@@ -421,8 +437,18 @@ function styleEdge(e, style, painted) {
421
437
  return shapeEdge(out, style);
422
438
  }
423
439
 
440
+ /** A colour with its hue taken away: the grey of the same lightness, alpha kept. Both renderers read the same `rgb()` */
441
+ export function greyOf(color) {
442
+ const [r, g, b, a] = parseColor(color);
443
+ const l = Math.round(0.2126 * r + 0.7152 * g + 0.0722 * b);
444
+ return a >= 1 ? `rgb(${l}, ${l}, ${l})` : rgbaText(l, l, l, a);
445
+ }
446
+
424
447
  function compute(scene, style) {
425
448
  const { values } = style;
449
+ const greyToken = values[GREY_TOKEN];
450
+ const fade = style.greyAlpha == null ? 1 : style.greyAlpha / GREY_ALPHA;
451
+ const toGrey = (c) => (greyToken ? withAlphaOf(greyToken, c) : greyOf(c));
426
452
  const label = values[LABEL_TOKEN];
427
453
  const stroke = values[STROKE_TOKEN];
428
454
  const painted = scene.painted || { nodes: new Set(), edges: new Set() };
@@ -431,16 +457,23 @@ function compute(scene, style) {
431
457
  const fill = !painted.nodes.has(n.id) && fillOf(values, n);
432
458
  const icon = style.icons ? iconKeysFor(n.type, n.kind, n.layer).find((k) => style.icons.get(k)) || null : null; // the same order: kind, layer, type
433
459
  const glows = style.glow != null && style.glow !== 1 && n.glow > 0;
434
- if (!fill && !label && !stroke && !icon && !glows) return n;
460
+ const grey = !!n.greyed && !painted.nodes.has(n.id); // a review greys what the change does not involve; a colour a painter gave means something and stays
461
+ if (!fill && !label && !stroke && !icon && !glows && !grey) return n;
435
462
  const out = { ...n };
436
463
  if (glows) out.glow = n.glow * style.glow;
437
464
  if (fill) out.color = fill;
438
465
  if (label) out.labelColor = withAlphaOf(label, n.labelColor);
439
- if (stroke && style.strokeWidth > 0) out.stroke = { color: stroke, width: style.strokeWidth };
440
- if (icon) out.icon = icon;
466
+ if (stroke && style.strokeWidth > 0) out.stroke = { color: grey ? toGrey(stroke) : stroke, width: style.strokeWidth };
467
+ if (icon && !grey) out.icon = icon; // a picture has its own hues: a greyed node keeps its silhouette, glyph and letters
468
+ if (grey) { out.color = toGrey(out.color); out.alpha = Math.min(1, n.alpha * fade); }
441
469
  return out;
442
470
  });
443
- const out = { ...scene, nodes, edges: scene.edges.map((e) => styleEdge(e, style, painted.edges)) };
471
+ const edges = scene.edges.map((e) => {
472
+ const styled = styleEdge(e, style, painted.edges);
473
+ if (!e.greyed || painted.edges.has(e.key)) return styled;
474
+ return { ...styled, color: toGrey(styled.color), glowColor: null, alpha: Math.min(1, styled.alpha * fade) };
475
+ });
476
+ const out = { ...scene, nodes, edges };
444
477
  if (style.font) out.labelFont = style.font; // every label's font list (labels.js reads `scene.labelFont`)
445
478
  if (style.labelMin != null) out.labelMin = style.labelMin; // the smallest label on screen (labels.js reads `scene.labelMin`)
446
479
  const halo = values[LABEL_HALO_TOKEN];
@@ -460,7 +493,7 @@ const sceneMemo = new WeakMap();
460
493
  * @param {MapStyle} [style]
461
494
  */
462
495
  export function styledScene(scene, style = current) {
463
- if (!style || style.plain) return scene;
496
+ if (!style || (style.plain && !scene.greying)) return scene; // a review's greying is applied even with no theme
464
497
  const hit = sceneMemo.get(scene);
465
498
  if (hit && hit.version === style.version) return hit.out;
466
499
  const out = compute(scene, style);
@@ -23,6 +23,7 @@ import { render, getScene, fitGraphToViewport, fitPadding, isNodeVisible, ensure
23
23
  import { frameNodes, largestGroup, READ_ZOOM, FRAME_ZOOM_MIN } from './camera.js';
24
24
  import { setMap } from './view.js';
25
25
  import { closeDrawer, selectNode } from './panels.js';
26
+ import { beginReview, endReview, renderLayerToggles, reviewLayersLine, setWholeMap } from './layers.js';
26
27
  import { edgePoint, looksFor } from './scene.js';
27
28
  import { onThemeChange } from './theme.js';
28
29
  import { looksWith, onMapStyleChange } from './map-style.js';
@@ -126,7 +127,7 @@ export async function openProposal(slug, source = null) {
126
127
  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
128
  showProposal(item, { slug, source: source || (found ? decodeURIComponent(found) : null), pinSource: !!source, view: 'diff', fit: true, sha256 });
128
129
  // said once, here: a proposal opens on a person's asking, never on a background refresh
129
- announce(reviewOpenedLine($('proposal-title').textContent));
130
+ announce([reviewOpenedLine($('proposal-title').textContent), reviewLayersLine()].filter(Boolean).join(' ')); // and, once, which layers the review hid
130
131
  return true;
131
132
  } catch (err) {
132
133
  console.error('Opening the proposal failed', err);
@@ -157,6 +158,7 @@ let openToken = 0;
157
158
  */
158
159
  export function showProposal(proposal, { slug = null, source = null, pinSource = false, view, fit = true, sha256 = null } = {}) {
159
160
  state.proposal = proposal;
161
+ beginReview(); // the map narrows to the change: a review of its own, the viewer's layers untouched (layers.js, layer-model.js)
160
162
  state.proposalSlug = slug;
161
163
  state.proposalSource = source;
162
164
  state.proposalSha256 = typeof sha256 === 'string' && /^[0-9a-f]{64}$/.test(sha256) ? sha256 : null;
@@ -190,6 +192,7 @@ export function rebuildProposalMap(effective = hooks.effective ? hooks.effective
190
192
  }
191
193
  swapMap(applied.nodes, applied.edges);
192
194
  renderBar(); // first: the fit below leaves out what the bar covers, so the bar must be laid out
195
+ renderLayerToggles(); // the menu follows the layers the change touches
193
196
  if (fit) fitToChange();
194
197
  render();
195
198
  ensureFlowLoop();
@@ -204,6 +207,7 @@ export function closeProposal() {
204
207
  state.proposalSource = null;
205
208
  state.proposalSha256 = null;
206
209
  state.proposalErrors = [];
210
+ endReview(); // the viewer's own layers are what is drawn again, exactly as they were
207
211
  swapMap(state.baseNodes.map((n) => ({ ...n })), state.baseEdges);
208
212
  fitGraphToViewport(fitPadding());
209
213
  render();
@@ -387,6 +391,14 @@ export function renderBar() {
387
391
  btn.classList.toggle('is-on', on);
388
392
  }
389
393
 
394
+ const whole = $('proposal-whole'); // the switch is the review's: off at every opening, kept across Before, Diff and After
395
+ if (whole) { // the pressed look is the one the bar's other chosen buttons have (it holds on hover)
396
+ const on = !!(state.review && state.review.whole);
397
+ whole.setAttribute('aria-pressed', String(on));
398
+ whole.title = t('showWholeMap'); // the words are short ("Whole map"); the tooltip says it in full, as its name does
399
+ whole.classList.toggle('hx-btn--active', on);
400
+ }
401
+
390
402
  const errors = state.proposalErrors || [];
391
403
  const box = $('proposal-errors');
392
404
  box.hidden = errors.length === 0;
@@ -611,6 +623,7 @@ const ACTIONS = {
611
623
  'toggle-proposals-menu': () => toggleMenu(),
612
624
  'open-proposal': (el) => openProposal(el.dataset.slug, el.dataset.source || null),
613
625
  'close-proposal': () => closeProposal(),
626
+ 'proposal-whole': () => { setWholeMap(!(state.review && state.review.whole)); renderBar(); }, // "Show the whole map": announced by layers.js, the focus stays on the switch
614
627
  'proposal-view': (el) => { setProposalView(el.dataset.view); toggleMode(false); },
615
628
  'toggle-proposal-mode': () => toggleMode(),
616
629
  'toggle-proposal-more': () => (moreOpen() ? closeMore() : openMore()),
@@ -21,6 +21,8 @@ import { ZOOM_MIN, ZOOM_FLOOR } from './camera.js';
21
21
  // Visibility and focus (decided in scene.js, kept here under their old names)
22
22
  // ---------------------------------------------------------------------------
23
23
  export const isNodeVisible = (node) => nodeVisible(state, node);
24
+ /** Whether the viewer's own layers show the node, whatever a review has hidden (what-if's list of the other end of an edge) */
25
+ export const isNodeVisibleToViewer = (node) => nodeVisible(state, node, { viewer: true });
24
26
 
25
27
  /** The focus subgraph: the selected node and every node one edge away (selection-model.js); the switch and the kind come from the state */
26
28
  export const getActiveSubgraph = (selected, edges = viewEdges(), opts = { throughChildren: !!state.throughChildren, kind: state.selectedKind || null }) => activeSubgraph(selected, edges, opts);
@@ -14,6 +14,7 @@
14
14
  */
15
15
 
16
16
  import { state } from './state.js';
17
+ import { layerOn } from './layer-model.js';
17
18
  import { render, onPaint } from './render.js';
18
19
  import { overlayOf } from './runs-model.js';
19
20
  import { flowReduceMotion } from './flows.js';
@@ -40,7 +41,7 @@ const reducedMotion = () => (reduce === null ? flowReduceMotion : reduce);
40
41
  export function setReducedMotionForTests(on) { reduce = on; }
41
42
 
42
43
  /** Whether the layer is on */
43
- export const runsLayerOn = () => state.activeLayers[RUNS_LAYER] !== false;
44
+ export const runsLayerOn = () => layerOn(state, RUNS_LAYER); // the viewer's layer, or the review's (layer-model.js)
44
45
 
45
46
  /** Hands the map the runs the API listed: what pulses and what collides is worked out here, and the map is drawn again */
46
47
  export function setRunsOnMap(runs) {
@@ -30,9 +30,9 @@ import { createPlayer, cameraFor, parseSpeed, SPEED_CHOICES, SPEED_KEY } from '.
30
30
  import { edgeKey } from '../core/proposal.js';
31
31
  import { checksVersion, closeChecks, decorateSnapshot, openChecks, paintChecks } from './check.js';
32
32
  import { blastRadius, outageLayers, outageScenario } from './outage-model.js';
33
- import { toggleLayer, LAYER_DEFS } from './layers.js';
33
+ import { setLayer, clearStepLayers, LAYER_DEFS } from './layers.js';
34
34
  import { externalLayer } from './cloud-model.js';
35
- import { projectLayerKey, shownByProposal } from './layer-model.js';
35
+ import { layerOn, layersOf, projectLayerKey, shownByProposal } from './layer-model.js';
36
36
  import { announce } from './keyboard.js';
37
37
  import { t } from './strings.js';
38
38
  import { currentStepSentence } from './scenario-list-model.js';
@@ -135,7 +135,7 @@ function giveFocusBack() {
135
135
  function showOutageLayers(scenario) {
136
136
  if (!scenario || !Array.isArray(scenario.down) || !scenario.down.length) return;
137
137
  outageLayers(blastRadius(scenario.down, state.nodes, state.edges), state.nodes)
138
- .forEach((key) => { if (state.activeLayers[key] === false) toggleLayer(key); });
138
+ .forEach((key) => { if (!layerOn(state, key)) setLayer(key, true, { scenario: true }); });
139
139
  }
140
140
 
141
141
  /**
@@ -144,12 +144,13 @@ function showOutageLayers(scenario) {
144
144
  */
145
145
  export function layersHiding(node) {
146
146
  if (!node || state.view === 'dataflow' || state.view === 'house') return [];
147
- const on = (key) => state.activeLayers[key] !== false;
147
+ const layers = layersOf(state); // what is drawn: the viewer's layers, or the review's (layer-model.js)
148
+ const on = (key) => layers[key] !== false;
148
149
  const t = node.type;
149
150
  if (t === 'root' || shownByProposal(state, node)) return []; // a proposal's own nodes are drawn whatever their layer says (spec 0009 D3)
150
151
  const project = projectLayerKey(state, node); // a project layer that takes the node decides alone (spec 0009 D3), as scene.js layerShows has it
151
152
  if (project) return on(project) ? [] : [project];
152
- if (t === 'core') return [...(on('core') ? [] : ['core']), ...(state.activeLayers.pkg || state.activeLayers.atom ? [] : ['pkg'])];
153
+ if (t === 'core') return [...(on('core') ? [] : ['core']), ...(layers.pkg || layers.atom ? [] : ['pkg'])];
153
154
  if (t === 'store') return ['flow', 'store'].filter((k) => !on(k));
154
155
  if (t === 'rom') return ['rom', 'flow'].filter((k) => !on(k));
155
156
  if (t === 'floor' || t === 'room') return on('house') ? [] : ['house'];
@@ -169,7 +170,7 @@ function showStepLayers(scenario) {
169
170
  const keys = [];
170
171
  for (const id of stepNodeIds(scenario)) for (const key of layersHiding(byId.get(id))) if (!keys.includes(key)) keys.push(key);
171
172
  if (!keys.length) return;
172
- for (const key of keys) { if (key === 'pkg') state.activeLayers.pkg = false; toggleLayer(key); }
173
+ for (const key of keys) setLayer(key, true, { scenario: true }); // on, for the review too (state.review.step): stopping the scenario takes it off again
173
174
  const names = keys.map((key) => (LAYER_DEFS.find((l) => l.key === key) || (state.projectLayers || []).find((l) => l.key === key) || { label: key }).label);
174
175
  announce(`Turned on ${names.length > 1 ? `${names.slice(0, -1).join(', ')} and ${names[names.length - 1]}` : names[0]} to show this scenario's steps.`);
175
176
  }
@@ -187,6 +188,7 @@ export const getPlayer = () => player;
187
188
  /** Ends the scenario without touching the picture: for callers that rebuild it themselves (selecting a node, switching view). `keepChecks` while another scenario is about to start */
188
189
  export function clearScenario({ keepChecks = false, closing = false } = {}) {
189
190
  const had = !!player || !!state.scenario;
191
+ if (had) clearStepLayers(); // the layers this scenario turned on for a review go off with it: the focused view comes back
190
192
  player = null;
191
193
  glide = null;
192
194
  signature = '';
package/explorer/scene.js CHANGED
@@ -171,7 +171,7 @@ import { beforeOf, markIn, showsEdge, showsNode, touchedIds } from './proposal-m
171
171
  import { decorateHouseScene, houseEdgeStyle, houseShowsNode, houseViewEdges } from './house-model.js';
172
172
  import { paintVerdict } from './check-model.js';
173
173
  import { externalLayer, whenTicks } from './cloud-model.js';
174
- import { lettersOf, projectLayerKey, shownByProposal } from './layer-model.js';
174
+ import { greying, lettersOf, projectLayerKey, shownByProposal, layersOf } from './layer-model.js';
175
175
  import { NODE_THEMES, shapeOf } from '../core/schema.js';
176
176
  import { hasGlyph } from './glyphs.js';
177
177
  import { outageFor, paintOutage } from './outage-model.js';
@@ -180,7 +180,7 @@ import { lightColor, lightenScene, parseColor } from './theme-model.js';
180
180
  import { matchIds } from './search-model.js';
181
181
  import { nodeColor } from './css-color.js';
182
182
  import { activeSubgraph, kindEdgeWord } from './selection-model.js';
183
- import { DIFF_MARK_COLORS, DIFF_LABEL_ALPHA, EDGE_MIN_ALPHA, MARK_SHAPES, REMOVED_ALPHA } from './diff-marks.js';
183
+ import { DIFF_MARK_COLORS, DIFF_LABEL_ALPHA, GREY_ALPHA, GREY_LABEL_ALPHA, EDGE_MIN_ALPHA, MARK_SHAPES, REMOVED_ALPHA } from './diff-marks.js';
184
184
 
185
185
  // ---------------------------------------------------------------------------
186
186
  // Constants every renderer shares, so the looks cannot drift apart
@@ -275,21 +275,25 @@ const LIGHT_LOOKS = Object.freeze({
275
275
  export const MARK_MIN_PX = { ring: 1.8, edge: 1.6, gap: 4 };
276
276
  /** How bright what a proposal does not touch is in the Diff view: dim, but still plainly there */
277
277
  export const PROPOSAL_DIM_ALPHA = 0.28;
278
+ export { GREY_ALPHA }; // how much of a greyed node is left (diff-marks.js): its colour is taken away at draw time (map-style.js `--corn-map-grey`), a greyed line is faded as Diff fades one (PROPOSAL_DIM_ALPHA)
278
279
 
279
280
  // ---------------------------------------------------------------------------
280
281
  // Visibility and focus (moved unchanged from render.js)
281
282
  // ---------------------------------------------------------------------------
282
- export function isNodeVisible(state, node) {
283
+ /**
284
+ * Whether the map draws a node. `viewer`: as the viewer's own layers say, whatever a review has hidden (a list of what could be picked while the review
285
+ * narrows the map, such as the other end of a what-if edge: the edge, once drawn, brings its two ends' layers on).
286
+ */
287
+ export function isNodeVisible(state, node, { viewer = false } = {}) {
283
288
  if (state.proposal && !showsNode(state.proposalView || 'diff', node)) return false; // Before hides what is added, After what is removed
284
289
  if (state.view === 'dataflow') return !!state.flow && state.flow.ids.has(node.id);
285
290
  if (state.view === 'house') return houseShowsNode(state, node); // the House view (spec 0029, PHY-11) draws its own set: house-model.js
286
291
  if (node.type === 'root') return true;
287
- return layerShows(state, node) || shownByProposal(state, node); // a proposal's own nodes are drawn whatever their layer says (spec 0009 D3)
292
+ return layerShows(state, node, viewer ? state.activeLayers : layersOf(state)) || shownByProposal(state, node); // a proposal's own nodes are drawn whatever their layer says (spec 0009 D3)
288
293
  }
289
294
 
290
295
  /** Whether the Layers menu has the node's layer on: a project layer that takes it decides alone, else its starting layer, with the rules each type has */
291
- export function layerShows(state, node) {
292
- const { activeLayers } = state;
296
+ export function layerShows(state, node, activeLayers = layersOf(state)) { // the viewer's layers, or a review's (layer-model.js `layersOf`): the one place that decides
293
297
  const project = projectLayerKey(state, node);
294
298
  if (project) return activeLayers[project] !== false;
295
299
  if (node.type === 'core') return (activeLayers.pkg || activeLayers.atom) && activeLayers.core !== false; // its own row in Layers, and Packages or Atoms
@@ -462,10 +466,11 @@ const FLOW_LIKE = ['flow', 'reads', 'writes', 'runs-on', 'calls', 'triggers', 'd
462
466
  const proposalView = (state) => (state.proposal ? state.proposalView || 'diff' : null);
463
467
 
464
468
  /** Puts a proposal mark on a scene edge: its colour, dash and weight; in Diff what is not marked fades back */
465
- function styleForProposal(edge, mark, view, gone = false) {
469
+ function styleForProposal(edge, mark, view, gone = false, grey = false) {
466
470
  edge.mark = mark;
467
471
  if (mark === 'none') {
468
- if (view === 'diff') { edge.alpha *= PROPOSAL_DIM_ALPHA; edge.glow = 0; edge.packet = null; }
472
+ if (view === 'diff' || grey) { edge.alpha *= PROPOSAL_DIM_ALPHA; edge.glow = 0; edge.packet = null; } // Before and After fade it too while a review greys it
473
+ if (grey) edge.greyed = true; // its colour is taken away at draw time (map-style.js)
469
474
  return;
470
475
  }
471
476
  const look = MARK[mark];
@@ -477,7 +482,9 @@ function styleForProposal(edge, mark, view, gone = false) {
477
482
  }
478
483
 
479
484
  function buildEdges(state, subgraph, reduceMotion) {
480
- const { nodes, activeLayers } = state;
485
+ const { nodes } = state;
486
+ const activeLayers = layersOf(state);
487
+ const grey = greying(state);
481
488
  const byId = new Map(nodes.map((n) => [n.id, n]));
482
489
  const preset = state.view === 'dataflow';
483
490
  const out = [];
@@ -537,7 +544,7 @@ function buildEdges(state, subgraph, reduceMotion) {
537
544
  if (preset || FLOW_LIKE.includes(edge.kind)) flow(edge, source, target);
538
545
  else out.push(linkEdge(edge, source, target, subgraph));
539
546
  }
540
- for (let i = first; i < out.length; i++) styleForProposal(out[i], mark, view, mark === 'edit' && applied.editOp === 'removed');
547
+ for (let i = first; i < out.length; i++) styleForProposal(out[i], mark, view, mark === 'edit' && applied.editOp === 'removed', grey);
541
548
  });
542
549
  return out;
543
550
  }
@@ -561,7 +568,8 @@ function buildNodes(state, subgraph) {
561
568
  const searching = !!found && nodes.some((n) => found.has(n.id) && isNodeVisible(state, n)); // with no match on the map nothing dims: it would only be a blank map
562
569
  const out = [];
563
570
  const view = proposalView(state);
564
- const focus = view === 'diff' ? touchedIds(nodes, viewEdgesOf(state)) : null;
571
+ const grey = greying(state); // a review greys what the change does not involve, in Before and After as in Diff
572
+ const focus = view === 'diff' || (view && grey) ? touchedIds(nodes, viewEdgesOf(state)) : null;
565
573
 
566
574
  nodes.forEach((node) => {
567
575
  if (!isNodeVisible(state, node)) return;
@@ -579,7 +587,8 @@ function buildNodes(state, subgraph) {
579
587
  // 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)
580
588
  let alpha = subgraph && !connected && !(searching && match) ? DIM_ALPHA : 1;
581
589
  if (searching && !match && !selected && !(subgraph && connected)) alpha = DIM_ALPHA; // a search dims what it did not find, as a focus does
582
- if (focus && !focus.touched.has(node.id)) alpha = Math.min(alpha, PROPOSAL_DIM_ALPHA);
590
+ const greyed = grey && !!focus && !focus.touched.has(node.id);
591
+ if (focus && !focus.touched.has(node.id)) alpha = Math.min(alpha, greyed ? GREY_ALPHA : PROPOSAL_DIM_ALPHA);
583
592
  if (look) alpha *= gone ? MARK.removed.alpha : look.alpha;
584
593
  const big = shown.type === 'root' || shown.type === 'app';
585
594
  // A finer kind (spec 0009): its letters, drawn in the node's core by the renderers (kind-letters.js), and the project layer that takes the node
@@ -599,14 +608,16 @@ function buildNodes(state, subgraph) {
599
608
  glow: connected && alpha >= 0.5 ? (big ? 15 : 9) : 0,
600
609
  halo: match ? 'match' : selected ? 'selected' : child ? 'child' : 'none',
601
610
  mark,
611
+ ...(greyed ? { greyed: true } : {}), // not involved in the change: its colour is taken away at draw time, glyph and letters stay (map-style.js)
602
612
  selected, match, current, connected,
603
613
  degree: node.degree || 0,
604
614
  label: shown.label,
605
- labelSize: big ? 12 : 11,
606
- labelBold: big,
607
- labelAlpha: focus && !focus.touched.has(node.id) && !(subgraph && !connected) ? Math.max(alpha, DIFF_LABEL_ALPHA) : alpha, // a label the diff dims stays 3:1
615
+ labelSize: big && !greyed ? 12 : 11, // a greyed node's label recedes (issue #232): plain, at the least size, placed last (labels.js)
616
+ labelBold: big && !greyed,
617
+ labelAlpha: greyed && !(subgraph && !connected) ? GREY_LABEL_ALPHA[state.theme === 'light' ? 'light' : 'dark'] // a greyed node's label: at the dimmed-label floor on either ground
618
+ : focus && !focus.touched.has(node.id) && !(subgraph && !connected) ? Math.max(alpha, DIFF_LABEL_ALPHA) : alpha, // a label the diff dims stays 3:1
608
619
  labelColor: connected ? '#f8fafc' : 'rgba(255, 255, 255, 0.3)',
609
- labelKeep: LANDMARK_TYPES.includes(shown.type) || selected || match || mark !== 'none' || !!(subgraph && connected),
620
+ labelKeep: (LANDMARK_TYPES.includes(shown.type) && !greyed) || selected || match || mark !== 'none' || !!(subgraph && connected),
610
621
  labelStrike: !!look && (look.strike || gone),
611
622
  live: !!node.live,
612
623
  box: node.box || null,
@@ -733,6 +744,7 @@ export function buildScene(state, opts = {}) {
733
744
  };
734
745
  if (state.view === 'house') decorateHouseScene(scene, state); // its bands and tray as lanes, rooms unlabelled (house-model.js)
735
746
  if (state.scenario) emphasiseScenario(scene, state.scenario, opts);
747
+ scene.greying = scene.nodes.some((n) => n.greyed) || scene.edges.some((e) => e.greyed);
736
748
  const colours = { nodes: scene.nodes.map((n) => n.color), edges: scene.edges.map((e) => e.color) };
737
749
  if (state.scenario) paintOutage(scene, outageFor(state.scenario, state.nodes, state.edges)); // CLOUD-07: red, amber, violet by when the outage bites
738
750
  if (state.scenario) paintVerdict(scene, state.scenario); // PHY-10: red, green or amber by the step's permission check
@@ -23,7 +23,7 @@ import { isPhone, visibleMapRect } from './sheets.js';
23
23
  import { announce } from './keyboard.js';
24
24
  import { flyTo } from './fly.js';
25
25
  import { groupOf } from './scene.js';
26
- import { projectLayerKey } from './layer-model.js';
26
+ import { layerOn, projectLayerKey } from './layer-model.js';
27
27
  import { noMatchText, showSearchStatus, updateSearchStatus } from './search-status.js';
28
28
  import { countText, moreLine, noMatchLine, searchNodes, stepIndex } from './search-model.js';
29
29
 
@@ -176,7 +176,7 @@ function showLayerOf(node) {
176
176
  const tries = [projectLayerKey(state, node), groupOf(node), node.type === 'store' || node.type === 'rom' ? 'flow' : null, node.type === 'core' ? 'pkg' : null, node.type === 'core' ? 'core' : null];
177
177
  for (const key of tries) {
178
178
  if (isNodeVisible(node)) return;
179
- if (key && state.activeLayers[key] === false) toggleLayer(key);
179
+ if (key && !layerOn(state, key)) toggleLayer(key);
180
180
  }
181
181
  }
182
182
 
package/explorer/state.js CHANGED
@@ -71,6 +71,14 @@ export const state = {
71
71
  layerOrder: [],
72
72
  layerDefaults: {},
73
73
 
74
+ /**
75
+ * The review of the open proposal, which narrows the map to the change (issue #232; explorer/layer-model.js `layersOf`): null with no proposal open,
76
+ * else `{ whole, manual, step, rev }`. `whole`: "Show the whole map" is on, the map is as Diff always was. `manual`: layers the reviewer turned on or
77
+ * off by hand in this review, `step`: the ones a playing scenario turned on (both `{ key: boolean }`). `rev` moves with each change.
78
+ * None of it is the viewer's: `activeLayers` and the saved choices (layers.js) are never written while it is set.
79
+ */
80
+ review: null,
81
+
74
82
  /**
75
83
  * The map as the last `setMap` (view.js) was handed it, before the live layer is laid in: the base
76
84
  * copies, or a proposal applied over them. `nodes` and `edges` are these plus the live ones.
@@ -147,6 +147,9 @@
147
147
  /* The smallest a map label is drawn on screen (spec 0008): auto is 11px; a theme may raise it, not lower it. A hub's title is 2px more */
148
148
  --corn-map-label-min: auto;
149
149
  --corn-map-glyph: auto;
150
+ /* What a review greys (the nodes and lines a proposal does not involve): a colour (auto: each one's own tone, its hue taken away) and how much of a node is left (auto: 0.45; 0.1 to 1) */
151
+ --corn-map-grey: auto;
152
+ --corn-map-grey-alpha: auto;
150
153
  /* Diff, selection and focus */
151
154
  --corn-map-added: auto;
152
155
  --corn-map-changed: auto;
@@ -21,7 +21,7 @@
21
21
  */
22
22
 
23
23
  import { state, touchScene, onSceneTouch, nameOf, nodeById, escHtml } from './state.js';
24
- import { render, isNodeVisible } from './render.js';
24
+ import { render, isNodeVisible, isNodeVisibleToViewer } from './render.js';
25
25
  import { hooks, rebuildProposalMap, closeProposal, focusChange } from './proposal.js';
26
26
  import { t } from './strings.js';
27
27
  import { getPlayer, playScenario, stopScenario, tickScenario } from './scenario-ui.js';
@@ -637,7 +637,7 @@ function removalIndex(op, match) {
637
637
  const EDGE_TO_MAX = 300;
638
638
  function edgeToHtml(n) {
639
639
  const others = state.nodes
640
- .filter((o) => o.id !== n.id && isNodeVisible(o) && kindOfMark(o) !== 'removed')
640
+ .filter((o) => o.id !== n.id && isNodeVisibleToViewer(o) && kindOfMark(o) !== 'removed') // a review narrows the map, but what the viewer has on can be picked: the edge brings its ends' layers on
641
641
  .sort((a, b) => String(a.label).localeCompare(String(b.label)))
642
642
  .slice(0, EDGE_TO_MAX);
643
643
  if (!others.length) return '';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cornfield",
3
- "version": "0.44.0",
3
+ "version": "0.45.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)",