@popcorn245/cornfield 0.54.0 → 0.55.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
@@ -24,6 +24,7 @@ import { fileURLToPath } from 'node:url';
24
24
  import { MAX_MIX_DEPTH, readColor, over, toHex, luminance, ratio, splitTop } from './color.js';
25
25
  import { MAX_THEME_BYTES, cssProblems, withoutComments } from './theme.js';
26
26
  import { MIN_SHAPE_DELTA_E, NODE_SHAPES, NODE_THEMES } from './schema.js';
27
+ import { WORK_KINDS, WORK_THEMES } from './schema.js';
27
28
  import { deltaE2000 } from './delta-e.js';
28
29
  import { LAYER_KEY_RE, MAX_KEY, mapFillNames, parseKindToken } from './layers.js';
29
30
  import { DIFF_MARK_COLORS, DIFF_LABEL_ALPHA, GREY_ALPHA, GREY_LABEL_ALPHA, GREY_MIN_RATIO, markOpacity } from '../explorer/diff-marks.js';
@@ -556,6 +557,22 @@ function mapFindings(props, theme, mode, grounds, extra = []) {
556
557
  out.push({ ...base, fg: '--corn-map-stroke', bg: weakest.on, min: MAP_FILL_MIN, kind: 'ui', use: `the outline that carries the fill of ${anOf(label)} ${label} node, which is ${fmt(f.ratio)} on its own`, fgValue: onGround.fgValue, bgValue: weakest.value, ratio: weakest.r });
557
558
  }
558
559
  }
560
+ // The fill of each kind of work in the Work view (spec 0012 D2): the kind's token, else its own colour (deepened for the light ground), against the ground
561
+ for (const kind of WORK_KINDS) {
562
+ const name = `--corn-work-${kind}`;
563
+ const t = mapToken(props, name);
564
+ const use = `the fill of ${anOf(kind)} ${kind} node in the Work view`;
565
+ if (t.problem) { out.push({ ...base, fg: name, bg: GROUND, min: MAP_FILL_MIN, kind: 'ui', use, problem: t.problem }); continue; }
566
+ const own = !t.color;
567
+ const fill = own ? readColor(mode === 'light' ? lightColor(WORK_THEMES[kind].color) : WORK_THEMES[kind].color) : t.color;
568
+ const f = worstOnGrounds(fill, grounds);
569
+ const finding = { ...base, fg: own ? `${name}, auto: the node's own colour` : name, bg: GROUND, min: MAP_FILL_MIN, kind: 'ui', use, fgValue: f.fgValue, bgValue: f.bgValue, ratio: f.ratio, ...(f.image ? { groundImage: true } : {}) };
570
+ if (f.ratio >= MAP_FILL_MIN || !strokeOn) { out.push(f.ratio >= MAP_FILL_MIN ? finding : { ...finding, use: `${use}; set --corn-map-stroke, an outline at ${MAP_FILL_MIN}:1 on the fill and on the ground, or a deeper fill` }); continue; }
571
+ const onGround = worstOnGrounds(stroke.color, grounds);
572
+ const onFill = ratio(luminance(over(stroke.color, over(fill, ground))), luminance(over(fill, ground)));
573
+ const weakest = onGround.ratio <= onFill ? { r: onGround.ratio, on: '--corn-ground', value: onGround.bgValue } : { r: onFill, on: name, value: toHex(over(fill, ground)) };
574
+ out.push({ ...base, fg: '--corn-map-stroke', bg: weakest.on, min: MAP_FILL_MIN, kind: 'ui', use: `the outline that carries ${use}, which is ${fmt(f.ratio)} on its own`, fgValue: onGround.fgValue, bgValue: weakest.value, ratio: weakest.r });
575
+ }
559
576
  // The ink of a glyph and of a finer kind's letters (spec 0008 D8), when the theme sets one: against every fill it can sit on (`auto` picks white or dark per fill, which a test holds)
560
577
  const glyph = mapToken(props, '--corn-map-glyph');
561
578
  if (glyph.problem) out.push({ ...base, fg: '--corn-map-glyph', bg: GROUND, min: MAP_FILL_MIN, kind: 'ui', use: 'the ink of a node\'s glyph', problem: glyph.problem });
package/core/schema.js CHANGED
@@ -48,6 +48,24 @@ export const NODE_SHAPES = Object.freeze({
48
48
  stack: 'square', machine: 'square', container: 'square', device: 'square', floor: 'square', room: 'square',
49
49
  persona: 'diamond',
50
50
  });
51
+ /**
52
+ * The six kinds of work the Work view draws as nodes (spec 0012 D2): their default colour (written for the dark ground, deepened for the light one as the
53
+ * map's are), the silhouette (the same five the map has, core/schema.js NODE_SHAPES; an issue is a circle with a mark, its letters), the letters in the node's core,
54
+ * and its radius. A theme sets the colour with `--corn-work-<kind>` (explorer/tokens.css, docs/theming.md); the silhouette says what the node is, so it is not a token.
55
+ * The list is its own export so the map's bundle carries the six names and not the table.
56
+ */
57
+ export const WORK_KINDS = Object.freeze(['thread', 'issue', 'proposal', 'run', 'pull', 'deploy']);
58
+ export const WORK_THEMES = Object.freeze({
59
+ thread: Object.freeze({ color: '#a78bfa', shape: 'circle', letters: 'T', r: 20 }),
60
+ issue: Object.freeze({ color: '#fbbf24', shape: 'circle', letters: '!', r: 20 }),
61
+ proposal: Object.freeze({ color: '#2dd4bf', shape: 'diamond', letters: 'S', r: 20 }),
62
+ run: Object.freeze({ color: '#818cf8', shape: 'hexagon', letters: 'R', r: 20 }),
63
+ pull: Object.freeze({ color: '#60a5fa', shape: 'rounded-square', letters: 'PR', r: 20 }),
64
+ deploy: Object.freeze({ color: '#4ade80', shape: 'square', letters: 'D', r: 20 }),
65
+ });
66
+ /** The node type a kind of work has in the Work view (`work-pull`): never in topology.json */
67
+ export const workType = (kind) => `work-${kind}`;
68
+
51
69
  /** The silhouettes, in the order the renderers number them (0 is the circle) */
52
70
  export const SHAPES = Object.freeze(['circle', 'rounded-square', 'hexagon', 'square', 'diamond']);
53
71
  /** The silhouette of a node type: `circle` for one the table does not know (a type is project data, so it only selects from the table) */
package/core/strings.js CHANGED
@@ -21,6 +21,7 @@ export const STRINGS = Object.freeze({
21
21
  house: 'House',
22
22
  proposals: 'Proposals',
23
23
  issuesAndPrs: 'Work',
24
+ workPanel: 'Work panel',
24
25
  searchPlaceholder: 'Search...',
25
26
  searchNoMatch: 'No match for',
26
27
  signOut: 'Sign out',
@@ -75,6 +75,7 @@ const typeOfRow = (inst, l) => { const types = typesOf(l); return (types.length
75
75
  */
76
76
  export function layerRows(inst) {
77
77
  const { state } = inst;
78
+ if (state.workRows) return { layers: state.workRows, overlays: [] }; // the Work view: the six kinds of work and the code they touch (work-model.js)
78
79
  const dotted = (l) => { const type = typeOfRow(inst, l); return { ...l, color: rowColor(inst, { type, group: l.key }, NODE_THEMES[type] ? NODE_THEMES[type].color : l.color) }; };
79
80
  const held = new Set();
80
81
  const left = new Set(); // starting layers a project layer took nodes from
@@ -191,7 +192,9 @@ function changed(inst) {
191
192
  export function setLayer(inst, key, on, { viewer = false, scenario = false } = {}) {
192
193
  const { state } = inst;
193
194
  const review = state.review && state.proposal ? state.review : null;
194
- if (review) {
195
+ if (state.workLayers) {
196
+ state.workLayers[key] = on; // the Work view's own: never kept in the browser, and the map's are not touched
197
+ } else if (review) {
195
198
  (scenario ? review.step : review.manual)[key] = on;
196
199
  review.rev++;
197
200
  } else {
@@ -218,7 +221,7 @@ export function toggleAllLayers(inst, on, { viewer = false } = {}) {
218
221
  const { layers } = layerRows(inst);
219
222
  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)]);
220
223
  const review = state.review && state.proposal ? state.review : null;
221
- if (review) { keys.forEach((k) => { review.manual[k] = on; }); review.rev++; } else {
224
+ if (state.workLayers) { state.workRows.forEach((r) => { state.workLayers[r.key] = on; }); } else if (review) { keys.forEach((k) => { review.manual[k] = on; }); review.rev++; } else {
222
225
  keys.forEach((k) => { state.activeLayers[k] = on; if (viewer) keep(inst, k, on); });
223
226
  if (viewer) writeChanges(inst);
224
227
  }
@@ -36,6 +36,7 @@
36
36
  */
37
37
 
38
38
  import { NODE_THEMES } from '../../core/schema.js';
39
+ import { WORK_KINDS } from '../../core/schema.js';
39
40
  import { parseColor } from '../theme-model.js';
40
41
  import { cssColor, rgbaText } from '../css-color.js';
41
42
  export { cssColor };
@@ -85,6 +86,8 @@ export const ICON_RATIO = 1.2;
85
86
  export const ICON_URL_PREFIX = '/cornfield/theme/assets/';
86
87
 
87
88
  export const nodeToken = (kind) => `--corn-map-node-${kind}`;
89
+ /** The fill token of a kind of work in the Work view (spec 0012 D2) */
90
+ export const workToken = (kind) => `--corn-work-${kind}`;
88
91
  export const groupToken = (group) => `--corn-map-group-${group}`;
89
92
  /** The fill token of a finer kind: `--corn-map-kind-service-timer`, or null for a kind that cannot be a part of a name (core/layers.js) */
90
93
  export const kindToken = (type, kind) => mapKindToken(type, kind);
@@ -95,6 +98,7 @@ export const stateToken = (name) => `--corn-map-${name}`;
95
98
  export const MAP_COLOR_TOKENS = Object.freeze([
96
99
  ...MAP_KINDS.map(nodeToken),
97
100
  ...MAP_GROUPS.map(groupToken),
101
+ ...WORK_KINDS.map(workToken),
98
102
  STROKE_TOKEN,
99
103
  LABEL_TOKEN,
100
104
  LABEL_HALO_TOKEN,
@@ -481,7 +485,7 @@ function compute(scene, style) {
481
485
  const painted = scene.painted || { nodes: new Set(), edges: new Set() };
482
486
  const nodes = scene.nodes.map((n) => {
483
487
  // Which fill wins, most specific first (spec 0009 D6): the finer kind, the project layer, the type, the starting layer
484
- const fill = !painted.nodes.has(n.id) && fillOf(values, n);
488
+ const fill = !painted.nodes.has(n.id) && (n.work ? values[workToken(n.work)] : fillOf(values, n));
485
489
  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
486
490
  const glows = style.glow != null && style.glow !== 1 && n.glow > 0;
487
491
  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
@@ -173,6 +173,7 @@ export function createMap(inst, opts = {}) {
173
173
  });
174
174
  if (state.view === 'dataflow' && state.flow) minY = Math.min(minY, state.flow.top - 10); // and the tier titles above
175
175
  if (state.view === 'house' && state.house && state.house.fit && !only) ({ minX, maxX, minY, maxY } = state.house.fit); // the House view fits its plan and bands (house-model.js)
176
+ if (state.view === 'work' && state.work && state.work.fit && !only) ({ minX, maxX, minY, maxY } = state.work.fit); // the Work view fits its lanes, and the room its names and toggles need (work-model.js)
176
177
 
177
178
  const availWidth = Math.max(160, width - padding * 2);
178
179
  const availHeight = Math.max(160, mapHeight - padding * 2);
@@ -217,7 +218,7 @@ export function createMap(inst, opts = {}) {
217
218
  render();
218
219
  }
219
220
 
220
- const fitPadding = () => (state.width < 640 ? 24 : 48);
221
+ const fitPadding = () => (state.view === 'work' ? (state.width < 640 ? 44 : 96) : state.width < 640 ? 24 : 48); // the Work view leaves room for the names under the nodes at the edge, in a fit and in a selection's framing
221
222
 
222
223
  const screenToWorld = (sx, sy) => ({ x: (sx - state.camera.x) / state.camera.zoom, y: (sy - state.camera.y) / state.camera.zoom });
223
224
 
@@ -52,4 +52,5 @@ export const selectDeploy = (id) => { const p = piece(); if (p) p.selectDeploy(i
52
52
  export const openRunLink = (id) => { const p = piece(); return p && p.isOn() ? p.openRunLink(id) : Promise.resolve(false); };
53
53
  export const openIssueLink = (n) => { const p = piece(); return p && p.isOn() ? p.openIssueLink(n) : Promise.resolve(false); };
54
54
  export const openProposalStart = (slug, opener) => { const p = piece(); return p && p.isOn() ? p.openProposalStart(slug, opener) : Promise.resolve(false); };
55
+ export const openWorkAt = (item) => { const p = piece(); return p && p.isOn() ? p.openWorkAt(item) : Promise.resolve(false); };
55
56
  export const canStartAgent = () => { const p = piece(); return !!p && p.canStartAgent(); };
@@ -26,6 +26,8 @@
26
26
  <link rel="stylesheet" href="/explorer/css/work.css" />
27
27
  <link rel="stylesheet" href="/explorer/css/page.css" />
28
28
  <link rel="stylesheet" href="/explorer/house.css" />
29
+ <link rel="stylesheet" href="/explorer/work-view.css" />
30
+ <link rel="stylesheet" href="/explorer/pieces/status.css" />
29
31
  <!-- The config's brand (server/server.js puts it here): the favicon, the web app manifest and the tab colour -->
30
32
  <!--@brand-->
31
33
  <!-- The config's theme (server/server.js puts it here, so it comes after cornfield's own CSS): font stylesheets, the repo's theme.css, a named theme -->
@@ -54,6 +56,8 @@
54
56
  <button type="button" id="preset-dataflow-btn" class="hx-view-btn" data-action="preset-dataflow" aria-pressed="false" data-corn-string="dataFlow" title="Show only how data moves: browser, app servers, API, tables, services, outside systems" data-corn="preset-dataflow">Flow</button>
55
57
  <!-- The House preset (explorer/house.js, spec 0029): the floor plan with its devices, machines and people, the software around it -->
56
58
  <button type="button" id="preset-house-btn" class="hx-view-btn" data-action="preset-house" aria-pressed="false" data-corn-string="house" title="Show the house: each floor's rooms with their devices and machines, the people beside it, the software around it" data-corn="preset-house">House</button>
59
+ <!-- The Work view (explorer/work-view.js, spec 0012): the map of issues, pull requests, proposals, runs, threads and deploys; its badge is what waits on you -->
60
+ <button type="button" id="preset-work-btn" class="hx-view-btn" data-action="preset-work" aria-pressed="false" data-corn="preset-work" hidden title="Work: issues, pull requests, proposals, agent runs, threads and deploys, and the code they touch"><span data-corn-string="issuesAndPrs">Work</span><span class="hx-waiting-badge hx-view-badge" data-corn="waiting-badge" aria-hidden="true" hidden></span></button>
57
61
  <button type="button" id="fit-btn" class="hx-view-fit" data-corn="fit-button" data-action="fit" title="Fit to the screen" aria-label="Fit to the screen" data-corn-kind="icon">
58
62
  <svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><path d="M2 6V2h4M10 2h4v4M14 10v4h-4M6 14H2v-4" /></svg>
59
63
  </button>
@@ -129,11 +133,10 @@
129
133
 
130
134
  <!-- The Work toggle (explorer/pieces/work.js): opens the Work panel; shown only when the config names a forge. It is a piece: page.js mounts it here, and until then this stand-in keeps its place (the piece's markup without ids) -->
131
135
  <!--corn-placeholder:work/button-->
132
- <button type="button" class="hx-work" data-action="toggle-forge" aria-expanded="false" aria-label="Work" data-corn-string-aria-label="issuesAndPrs" title="Issues, pull requests and deploys: a pull request lights the nodes it changes, a deploy the nodes it restarted" hidden data-corn="forge-button" part="forge-button">
133
- <span data-corn-string="issuesAndPrs">Work</span>
136
+ <button type="button" class="hx-work" data-action="toggle-forge" aria-expanded="false" aria-label="Work panel" data-corn-string-aria-label="workPanel" title="Issues, pull requests and deploys: a pull request lights the nodes it changes, a deploy the nodes it restarted" hidden data-corn="forge-button" part="forge-button">
137
+ <span data-corn-string="workPanel">Work panel</span>
134
138
  <span class="hx-forge-lit" data-corn="count" part="count" hidden></span>
135
139
  <span class="hx-runner-dot" aria-hidden="true" title="No runner online" hidden></span>
136
- <span class="hx-waiting-badge" data-corn="waiting-badge" part="waiting-badge" aria-hidden="true" hidden></span>
137
140
  </button>
138
141
  <!--corn-piece:work/button-->
139
142
 
@@ -124,6 +124,7 @@ const layersMemo = new WeakMap();
124
124
  * state for what is drawn goes through this, so the review's hiding is decided in one place.
125
125
  */
126
126
  export function layersOf(state) {
127
+ if (state.workLayers) return state.workLayers; // the Work view has its own layers, and leaves the map's as they were (work-model.js)
127
128
  const review = state.review;
128
129
  if (!review || !state.proposal) return state.activeLayers;
129
130
  const hit = layersMemo.get(review);
package/explorer/page.js CHANGED
@@ -50,6 +50,7 @@ import { initMockups } from './mockups.js';
50
50
  import { benchMeta, measureParams, readoutLines, resultLine, runBench, showReadout } from './bench.js';
51
51
  import { initLive } from './live.js';
52
52
  import { initHouse } from './house.js';
53
+ import { initWorkView, followWorkAddress, asksForWork } from './work-view.js';
53
54
  import { houseOffered } from './house-model.js';
54
55
  import { initKeyboard } from './keyboard.js';
55
56
  import { initForgePanel } from './forge-panel.js';
@@ -207,10 +208,11 @@ export function startPage() {
207
208
  initLive({ source: liveSource, onSelectionGone: closeDrawer });
208
209
  // The House view (house.js): a source's floor renderer draws the plan under the map (plain room boxes without one); /?view=house opens it
209
210
  initHouse({ floor: floorRenderer, offered: houseOffered(houseSource, state.nodes) }); // no house source and no house in the map: no House button
211
+ initWorkView({ offered: !!config.forge }); // the Work view (work-view.js): offered when the config names a forge
210
212
  mergePagePieceOptions('changes', { checker }); // scenarios ask the source's checker, when there is one (pieces/changes.js)
211
213
  if (new URLSearchParams(window.location.search).get("view") === "dataflow") setView("dataflow");
212
214
  // /?run=, /?issue= and /?proposal=…&start=1 land on a run, an issue's Start button and a proposal's Start dialog (deep-link.js)
213
- followDeepLink({ proposalOpened, forgeOn }).catch((err) => console.error('Following the link failed', err));
215
+ (asksForWork(window.location.search) ? followWorkAddress() : followDeepLink({ proposalOpened, forgeOn })).catch((err) => console.error('Following the link failed', err));
214
216
  // /?scenario-demo=1 plays a small scenario over real nodes, to look at the player
215
217
  maybeStartDemo();
216
218
  // /?bench=1 runs the stopwatch (bench.js) once the map is up
@@ -223,7 +223,7 @@ export function mount(root, inst, options = {}) {
223
223
  ${hid ? `<span class="hx-toggle-text">${name}${hid}</span>` : name}${layer.live ? '<span class="hx-live-tag" data-corn="live-tag">live</span>' : ''}
224
224
  </span>
225
225
  <span class="hx-toggle-meta">${shown}
226
- <span class="hx-count" data-corn="count">${(UNIT[layer.key] || String)(counts[layer.key] || 0)}</span>
226
+ <span class="hx-count" data-corn="count">${layer.countText || (UNIT[layer.key] || String)(counts[layer.key] || 0)}</span>
227
227
  <span class="hx-tick">${on ? '✓' : '—'}</span>
228
228
  </span>
229
229
  </button>${kindsHtml(layer, kinds.get(layer.key), surface)}`;
@@ -436,6 +436,24 @@ export function mount(root, inst, options = {}) {
436
436
  openBtn.textContent = `${t(inst, 'openRoute')} ↗`;
437
437
  fileBtn.textContent = `${t(inst, 'openFile')} ↗`;
438
438
  own('drawer-run-btn').hidden = !(state.proposalSlug && inst.ask('forge:can-start'));
439
+ // The Work view (spec 0012 D5): a piece of work is shown by the page's own answer (work-view.js); a node of code in it keeps its own sections, with the work touching it first
440
+ const work = state.view === 'work' ? inst.ask('work:panel', node) : null;
441
+ if (work && work.replace) {
442
+ title.textContent = work.title;
443
+ title.classList.remove('hx-mono');
444
+ own('drawer-badge').textContent = work.badge;
445
+ own('drawer-host').textContent = '';
446
+ pillEl.hidden = true;
447
+ lead.hidden = true;
448
+ metaList.innerHTML = work.html;
449
+ addParts(metaList);
450
+ fileBtn.hidden = true;
451
+ openBtn.hidden = true;
452
+ own('drawer-run-btn').hidden = true;
453
+ } else if (work) {
454
+ metaList.insertAdjacentHTML('afterbegin', work.html);
455
+ addParts(metaList);
456
+ }
439
457
 
440
458
  drawer.classList.add('drawer-open');
441
459
  drawer.inert = false; // closed, it waits off screen: inert, so Tab never reaches its buttons (MAP-02)
@@ -147,11 +147,16 @@ export function mount(root, inst, options = {}) {
147
147
  return (node) => { const p = byId.get(parentOf.get(node.id)); return p ? String(p.label || '') : ''; };
148
148
  }
149
149
 
150
+ /** A match Frame all takes in: on the map, and not a piece of work found from another view (its node is the Work view's) */
151
+ const framed = (m) => m.on && !(m.node.work && state.view !== 'work');
152
+
150
153
  /** What the current query finds (kept until the query, the nodes or the scene change) */
151
154
  function currentResult() {
152
- const key = `${state.searchQuery}|${state.sceneVersion}|${state.nodes.length}`;
155
+ const more = state.view === 'work' ? null : inst.ask('search:more'); // the work the page knows, found from the map too (the Work view, spec 0012)
156
+ const key = `${state.searchQuery}|${state.sceneVersion}|${state.nodes.length}|${more ? more.length : 0}`;
153
157
  if (memo && memo.key === key && memo.nodes === state.nodes) return memo.result;
154
- const result = searchNodes(state.nodes, state.searchQuery, { visible: (n) => inst.map.isNodeVisible(n), parentLabel: parentLabeller() });
158
+ const result = searchNodes(more && more.length ? state.nodes.concat(more) : state.nodes, state.searchQuery, { visible: (n) => inst.map.isNodeVisible(n), parentLabel: parentLabeller() });
159
+ if (more) result.onMap = result.matches.filter(framed).length; // the work found from another view is not on its map: Frame all counts what it frames
155
160
  memo = { key, nodes: state.nodes, result };
156
161
  return result;
157
162
  }
@@ -255,6 +260,7 @@ export function mount(root, inst, options = {}) {
255
260
  /** Selects a match and flies the camera to it (zoom 1 or closer): what Enter, a row and N do */
256
261
  async function chooseMatch(match, { say = true } = {}) {
257
262
  const node = match.node;
263
+ if (node.work && state.view !== 'work') { inst.emit('work:open', { id: node.id }); return; } // a piece of work: the Work view opens on it
258
264
  const mine = ++chosen;
259
265
  if (!inst.map.isNodeVisible(node)) showLayerOf(node);
260
266
  state.searchCurrent = node.id;
@@ -284,7 +290,7 @@ export function mount(root, inst, options = {}) {
284
290
  /** Fits the camera to every match on the map ("Frame all") */
285
291
  function frameAll() {
286
292
  const result = currentResult();
287
- const ids = new Set(result.matches.filter((m) => m.on).map((m) => m.node.id));
293
+ const ids = new Set(result.matches.filter(framed).map((m) => m.node.id));
288
294
  if (!ids.size) return;
289
295
  inst.map.fitGraphToViewport(inst.map.fitPadding(), ids);
290
296
  showSearchStatus(inst, '');
@@ -13,11 +13,10 @@ export const markup = () => Object.fromEntries(Object.entries(markupOf()).map(([
13
13
 
14
14
  const markupOf = () => ({
15
15
  /** The Work toggle: opens the panel; hidden until the config names a forge and somebody is signed in */
16
- button: `<button type="button" id="forge-btn" class="hx-work" data-action="toggle-forge" aria-expanded="false" aria-controls="forge-panel" aria-label="Work" data-corn-string-aria-label="issuesAndPrs" title="Issues, pull requests and deploys: a pull request lights the nodes it changes, a deploy the nodes it restarted" hidden data-corn="forge-button">
17
- <span data-corn-string="issuesAndPrs">Work</span>
16
+ button: `<button type="button" id="forge-btn" class="hx-work" data-action="toggle-forge" aria-expanded="false" aria-controls="forge-panel" aria-label="Work panel" data-corn-string-aria-label="workPanel" title="Issues, pull requests and deploys: a pull request lights the nodes it changes, a deploy the nodes it restarted" hidden data-corn="forge-button">
17
+ <span data-corn-string="workPanel">Work panel</span>
18
18
  <span id="forge-btn-lit" class="hx-forge-lit" data-corn="count" hidden></span>
19
19
  <span id="forge-btn-dot" class="hx-runner-dot" aria-hidden="true" title="No runner online" hidden></span>
20
- <span id="forge-btn-waiting" class="hx-waiting-badge" data-corn="waiting-badge" aria-hidden="true" hidden></span>
21
20
  </button>`,
22
21
  /** Specs, PRs, Issues, Threads, Runs and Deploys, in the order of the loop: a slide-over from the left on desktop, a bottom sheet on a phone; hidden and inert until the config names a forge. `forge-panel` on the inner box is the old name of the hook, kept for one release (docs/theming.md) */
23
22
  panel: `<aside id="forge-panel" class="hx-forge glass" aria-label="Work" inert hidden data-corn="work-panel">
@@ -10,7 +10,7 @@ import { workStatus } from '../agents-model.js';
10
10
  import { loadingRowsHtml } from '../runs-view.js';
11
11
  import { STATES, defaultFilters, filterItems, facetsOf, emptyWords } from '../forge-panel-model.js';
12
12
  import { relativeTime } from '../review-model.js';
13
- import { waiting, specGroups, workButtonName, waitingWords, runWaitingOn } from '../waiting-model.js';
13
+ import { waiting, specGroups, waitingWords, runWaitingOn } from '../waiting-model.js';
14
14
  import { specGroupsHtml } from '../waiting-view.js';
15
15
  import { escapeHtml as escHtml } from '../../core/text.js';
16
16
  import { plural, safeUrl, option } from './work-common.js';
@@ -247,17 +247,12 @@ export function install(ctx) {
247
247
  tag.hidden = !lit;
248
248
  tag.textContent = ui.runSel ? 'run' : ui.thread !== null ? `thread #${ui.thread}` : ui.deployItem ? 'deploy' : lit ? `#${ui.selected}` : '';
249
249
  }
250
- const n = fn.waitingNow().total;
251
250
  // A run would wait for a runner that is not there: a dot, and the name says so (issue #183); it sits beside the waiting badge, not on it
252
251
  const away = fn.runnerAway();
253
252
  const dot = $('forge-btn-dot');
254
253
  if (dot) dot.hidden = !away;
255
- const badge = $('forge-btn-waiting');
256
- if (badge) {
257
- badge.hidden = n === 0;
258
- badge.textContent = n ? String(n) : '';
259
- }
260
- btn.setAttribute('aria-label', `${workButtonName(t('issuesAndPrs'), n, t)}${away ? ', no runner online' : ''}${ui.runSel ? ', a run lit on the map' : ui.thread !== null ? `, thread ${ui.thread} selected` : ui.deployItem ? ', a deploy selected' : lit ? `, pull request ${ui.selected} selected` : ''}`);
254
+ // What waits on the maintainer is the badge of the view switch's Work (work-view.js): this button opens the panel, and says so while both exist (spec 0012 D1, until step 3)
255
+ btn.setAttribute('aria-label', `${t('workPanel')}${away ? ', no runner online' : ''}${ui.runSel ? ', a run lit on the map' : ui.thread !== null ? `, thread ${ui.thread} selected` : ui.deployItem ? ', a deploy selected' : lit ? `, pull request ${ui.selected} selected` : ''}`);
261
256
  }
262
257
 
263
258
  /** Whether the Filter chip applies to the view: the proposals and the release notes have nothing to filter */
@@ -90,7 +90,7 @@ export function install(ctx) {
90
90
  ui.actNote = null;
91
91
  ui.filters = defaultFilters('threads');
92
92
  }
93
- fn.openForge();
93
+ fn.openForge({ tab: 'threads' }); // named, so a closed panel does not open on the tab with the oldest thing waiting instead
94
94
  fn.paintFilters();
95
95
  selectThread(n);
96
96
  }
@@ -139,7 +139,7 @@ export function install(ctx) {
139
139
  ui.actNote = null;
140
140
  ui.filters = defaultFilters('threads');
141
141
  }
142
- fn.openForge();
142
+ fn.openForge({ tab: 'threads' });
143
143
  fn.paintFilters();
144
144
  ui.idea.open = true;
145
145
  ui.idea.message = '';
@@ -278,6 +278,18 @@ export function mount(root, inst, options = {}) {
278
278
  openRunLink: (id) => fn.openRunLink(id),
279
279
  openIssueLink: (n) => fn.openIssueLink(n),
280
280
  openProposalStart: (slug, opener) => fn.openProposalStart(slug, opener),
281
+ /** The panel at a piece of work from the Work view (spec 0012, step 2): its tab, and the item open in it. `item` is a node of the work graph */
282
+ openWorkAt: async (item) => {
283
+ if (item.kind === 'run') return fn.openRunLink(item.runId);
284
+ if (item.kind === 'issue') return fn.openIssueLink(item.number);
285
+ if (item.kind === 'thread') { fn.openThread(item.number); return true; }
286
+ const tab = { pull: 'pulls', proposal: 'specs', deploy: 'deploys' }[item.kind]; // the panel's own tab names (work-common.js TABS)
287
+ if (!tab) return false;
288
+ await fn.openTab(tab); // the list is in before a row of it is selected (a deploy is found in it)
289
+ if (item.kind === 'pull') fn.selectPull(item.number);
290
+ else if (item.kind === 'deploy') fn.selectDeploy(item.deployId);
291
+ return true;
292
+ },
281
293
  canStartAgent: () => fn.canStartAgent(),
282
294
  /** For tests: force reduced motion on or off for the runs' marks (null: follow the viewer's setting) */
283
295
  setReducedMotion: (v) => runsMap.setReducedMotion(v),
package/explorer/scene.js CHANGED
@@ -174,6 +174,7 @@ import { paintVerdict } from './verdict-paint.js';
174
174
  import { externalLayer, whenTicks } from './cloud-model.js';
175
175
  import { greying, lettersOf, projectLayerKey, shownByProposal, layersOf } from './layer-model.js';
176
176
  import { NODE_THEMES, shapeOf } from '../core/schema.js';
177
+ import { WORK_KINDS } from '../core/schema.js';
177
178
  import { hasGlyph } from './glyphs.js';
178
179
  import { outageFor, paintOutage } from './outage-model.js';
179
180
  import { paintForge } from './forge-panel-model.js';
@@ -287,6 +288,7 @@ export { GREY_ALPHA }; // how much of a greyed node is left (diff-marks.js): its
287
288
  */
288
289
  export function isNodeVisible(state, node, { viewer = false } = {}) {
289
290
  if (state.proposal && !showsNode(state.proposalView || 'diff', node)) return false; // Before hides what is added, After what is removed
291
+ if (state.view === 'work') return node.hidden !== true; // the Work view (spec 0012): its layers set `hidden` on the nodes (work-view.js)
290
292
  if (state.view === 'dataflow') return !!state.flow && state.flow.ids.has(node.id);
291
293
  if (state.view === 'house') return houseShowsNode(state, node); // the House view (spec 0029, PHY-11) draws its own set: house-model.js
292
294
  if (node.type === 'root') return true;
@@ -498,6 +500,7 @@ function buildEdges(state, subgraph, reduceMotion) {
498
500
  const target = byId.get(edge.to);
499
501
  if (!source || !target || !isNodeVisible(state, source) || !isNodeVisible(state, target)) return;
500
502
 
503
+ if (state.view === 'work') { out.push(state.workEdge(edge, source, target, subgraph ? subgraph.connectedEdgeKeys.has(focusKey(edge)) : true, !!subgraph, edgeKeyOf(edge), { PROPOSED_DASH, USAGE_DASH })); return; } // the Work view's lines are work-model.js's (the page installs `workEdge`)
501
504
  if (preset) return flow(edge, source, target);
502
505
  if (state.view === 'house') { const how = houseEdgeStyle(edge, source, target); if (how === 'flow') flow(edge, source, target); else if (how === 'link') out.push(linkEdge(edge, source, target, subgraph)); return; }
503
506
 
@@ -581,27 +584,32 @@ function buildNodes(state, subgraph) {
581
584
  const selected = !!selectedNode && selectedNode.id === node.id;
582
585
  const connected = subgraph ? subgraph.connectedNodeIds.has(node.id) : true;
583
586
  const child = subgraph && subgraph.childIds ? subgraph.childIds.has(node.id) : false;
584
- const mark = view ? markIn(view, node) : 'none';
587
+ const mark = node.planned === true ? 'added' : view ? markIn(view, node) : 'none'; // a node a proposal adds that the map does not hold yet is drawn as planned (spec 0012 D2)
585
588
  const look = MARK[mark];
586
589
  const gone = mark === 'edit' && node.editOp === 'removed'; // a node a what-if edit removes: violet ring, faded, label struck through
587
590
  // 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
588
591
  // 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)
589
- let alpha = subgraph && !connected && !(searching && match) ? DIM_ALPHA : 1;
590
- if (searching && !match && !selected && !(subgraph && connected)) alpha = DIM_ALPHA; // a search dims what it did not find, as a focus does
592
+ const dimmed = state.view === 'work' ? PROPOSAL_DIM_ALPHA : DIM_ALPHA; // the Work view dims to what the mock shows: the rest is still readable
593
+ let alpha = subgraph && !connected && !(searching && match) ? dimmed : 1;
594
+ if (searching && !match && !selected && !(subgraph && connected)) alpha = dimmed; // a search dims what it did not find, as a focus does
595
+ if (node.dim === true) alpha = Math.min(alpha, dimmed); // "Waiting on you" (work-view.js)
591
596
  const greyed = grey && !!focus && !focus.touched.has(node.id);
592
597
  if (focus && !focus.touched.has(node.id)) alpha = Math.min(alpha, greyed ? GREY_ALPHA : PROPOSAL_DIM_ALPHA);
593
598
  if (look) alpha *= gone ? MARK.removed.alpha : look.alpha;
594
599
  const big = shown.type === 'root' || shown.type === 'app';
595
600
  // 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
596
- const letters = lettersOf(state, shown);
601
+ const work = WORK_KINDS.includes(shown.work) ? shown.work : ''; // a kind of work carries its own shape and letters (work-model.js)
602
+ const shape = work && Object.hasOwn(SHAPE_REACH, shown.shape) ? shown.shape : shapeOf(shown.type);
603
+ const letters = work ? String(shown.letters || '') : lettersOf(state, shown);
597
604
  const layer = projectLayerKey(state, shown);
598
605
 
599
606
  out.push({
600
607
  id: node.id, type: shown.type, group: groupOf(shown),
601
608
  ...(typeof shown.kind === 'string' && shown.kind ? { kind: shown.kind } : {}),
602
609
  ...(letters ? { letters } : {}),
603
- shape: shapeOf(shown.type), // the silhouette of the node's family (spec 0008 D8): circle, rounded-square, hexagon, square, diamond
604
- hitR: shown.r * SHAPE_REACH[shapeOf(shown.type)], // the disc a click or tap hits: as far as the silhouette reaches (spatial.js)
610
+ ...(work ? { work } : {}), // a kind of work (the Work view): its colour is its own token (map-style.js)
611
+ shape, // the silhouette of the node's family (spec 0008 D8): circle, rounded-square, hexagon, square, diamond
612
+ hitR: shown.r * SHAPE_REACH[shape], // the disc a click or tap hits: as far as the silhouette reaches (spatial.js)
605
613
  ...(hasGlyph(shown.type) ? { glyph: shown.type } : {}), // its built-in glyph, drawn where the core dot is once the node is wide enough (glyphs.js)
606
614
  ...(layer ? { layer } : {}),
607
615
  x: node.x, y: node.y, r: shown.r, color: fillOfNode(shown),
@@ -612,13 +620,13 @@ function buildNodes(state, subgraph) {
612
620
  ...(greyed ? { greyed: true } : {}), // not involved in the change: its colour is taken away at draw time, glyph and letters stay (map-style.js)
613
621
  selected, match, current, connected,
614
622
  degree: node.degree || 0,
615
- label: shown.label,
623
+ label: shown.labelText || shown.label, // a node of the Work view is drawn as the start of its name; the whole of it is the node panel's (work-model.js)
616
624
  labelSize: big && !greyed ? 12 : 11, // a greyed node's label recedes (issue #232): plain, at the least size, placed last (labels.js)
617
625
  labelBold: big && !greyed,
618
626
  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
619
627
  : focus && !focus.touched.has(node.id) && !(subgraph && !connected) ? Math.max(alpha, DIFF_LABEL_ALPHA) : alpha, // a label the diff dims stays 3:1
620
628
  labelColor: connected ? '#f8fafc' : 'rgba(255, 255, 255, 0.3)',
621
- labelKeep: (LANDMARK_TYPES.includes(shown.type) && !greyed) || selected || match || mark !== 'none' || !!(subgraph && connected),
629
+ labelKeep: (LANDMARK_TYPES.includes(shown.type) && !greyed) || (!!work && shown.waiting === true) || selected || match || mark !== 'none' || !!(subgraph && connected),
622
630
  labelStrike: !!look && (look.strike || gone),
623
631
  live: !!node.live,
624
632
  box: node.box || null,
@@ -744,6 +752,7 @@ export function buildScene(state, opts = {}) {
744
752
  version: state.sceneVersion || 0,
745
753
  };
746
754
  if (state.view === 'house') decorateHouseScene(scene, state); // its bands and tray as lanes, rooms unlabelled (house-model.js)
755
+ if (state.view === 'work' && state.workLanes) scene.decor.lanes = state.workLanes; // its lanes and their titles (work-model.js)
747
756
  if (state.scenario) emphasiseScenario(scene, state.scenario, opts);
748
757
  scene.greying = scene.nodes.some((n) => n.greyed) || scene.edges.some((e) => e.greyed);
749
758
  const colours = { nodes: scene.nodes.map((n) => n.color), edges: scene.edges.map((e) => e.color) };
@@ -21,7 +21,7 @@ export const TYPE_NAMES = Object.freeze({
21
21
  const capital = (s) => (s ? s.charAt(0).toUpperCase() + s.slice(1) : s);
22
22
 
23
23
  /** The name of the group a node is listed under: its layer's name */
24
- export const groupName = (node) => TYPE_NAMES[node.type] || capital(String(node.type || ''));
24
+ export const groupName = (node) => (typeof node.groupName === 'string' && node.groupName) || TYPE_NAMES[node.type] || capital(String(node.type || '')); // a piece of work names its own group (the Work view)
25
25
 
26
26
  const lower = (s) => (typeof s === 'string' ? s.toLowerCase() : '');
27
27
  const WORD_BREAK = /[^\p{L}\p{N}]+/u;
@@ -38,7 +38,8 @@ export function rankOf(node, query) {
38
38
  if (label.startsWith(term)) return RANK.labelStart;
39
39
  if (label.split(WORD_BREAK).some((w) => w && w.startsWith(term))) return RANK.wordStart;
40
40
  if (label.includes(term)) return RANK.label;
41
- if (lower(node.id).includes(term) || lower(node.file).includes(term)) return RANK.idOrFile;
41
+ if (Array.isArray(node.terms) && node.terms.some((x) => lower(x) === term)) return RANK.labelStart; // what a piece of work is also called: `#21`, `pr 21`, its slug (the Work view)
42
+ if (lower(node.id).includes(term) || lower(node.file).includes(term) || (Array.isArray(node.terms) && node.terms.some((x) => lower(x).includes(term)))) return RANK.idOrFile;
42
43
  if (lower(node.type).includes(term) || lower(groupName(node)).includes(term) || lower(node.kind).includes(term)) return RANK.typeOrKind;
43
44
  return -1;
44
45
  }
@@ -192,6 +192,13 @@
192
192
  --corn-map-node-device: auto;
193
193
  --corn-map-node-floor: auto;
194
194
  --corn-map-node-room: auto;
195
+ /* The Work view's nodes (spec 0012 D2): the fill of each kind of work; auto is the kind's own colour (core/schema.js WORK_THEMES) */
196
+ --corn-work-thread: auto;
197
+ --corn-work-issue: auto;
198
+ --corn-work-proposal: auto;
199
+ --corn-work-run: auto;
200
+ --corn-work-pull: auto;
201
+ --corn-work-deploy: auto;
195
202
  /* Node fill by group */
196
203
  --corn-map-group-app: auto;
197
204
  --corn-map-group-pkg: auto;
package/explorer/view.js CHANGED
@@ -16,6 +16,9 @@ import { clearScenario } from './scenario-ui.js';
16
16
  import { measureParams } from './bench.js';
17
17
  import { mergeLive, placeLiveNodes } from './live-model.js';
18
18
  import { applyHouseLayout } from './house-model.js';
19
+ import { applyWorkLayout, enterWork, leaveWork } from './work-model.js';
20
+ import { isPhone } from './sheets.js';
21
+ import { clearSelection } from './engine/selection.js';
19
22
  import { syncHint } from './hint.js';
20
23
  import { ensurePagePieces } from './page-pieces.js';
21
24
  import { TOPOLOGY_PATH, fetchTopology } from './engine/source.js';
@@ -84,13 +87,17 @@ export function setMap(nodes, edges) {
84
87
  /** Where the nodes sit: the House view's plan here (house-model.js, PHY-11), every other view the engine's one layout (engine/topology.js `layoutMap`) */
85
88
  function applyLayout() {
86
89
  if (state.view === 'house') { computeDegreeCentrality(); applyHouseLayout(state); return; }
90
+ if (state.view === 'work') { applyWorkLayout(state, { phone: isPhone() }); return; } // the Work view's lanes (work-model.js)
87
91
  layoutMap(pageInstance(), { placeLive: placeLiveNodes }); // the live layer is the page's (live-model.js): the engine places it with this
88
92
  }
89
93
 
90
94
  /** Switches between 'orbit' and 'dataflow'; the camera refits and the preset button follows */
91
95
  export function setView(view) {
92
96
  if (state.view === view) return;
97
+ if ((state.view === 'work' || view === 'work') && state.selectedNode) clearSelection(pageInstance(), { source: 'api' }); // a selection belongs to the view it was made in
98
+ if (state.view === 'work') leaveWork(state); // the map's nodes come back before the next view is laid out
93
99
  state.view = view;
100
+ if (view === 'work') enterWork(state); // the Work view's nodes (work-view.js loads them)
94
101
  clearScenario();
95
102
  touchScene();
96
103
  if (state.nodes.length) {
@@ -105,7 +112,7 @@ export function syncViewUi() {
105
112
  const preset = state.view === 'dataflow';
106
113
  // The View switch: the Map button is on for the map itself; Flow and House say theirs (house.js) in aria-pressed too
107
114
  const map = $('preset-map-btn');
108
- if (map) map.setAttribute('aria-pressed', String(state.view !== 'dataflow' && state.view !== 'house'));
115
+ if (map) map.setAttribute('aria-pressed', String(state.view !== 'dataflow' && state.view !== 'house' && state.view !== 'work'));
109
116
  const btn = $('preset-dataflow-btn');
110
117
  if (btn) btn.setAttribute('aria-pressed', String(preset));
111
118
  ensurePagePieces(); // the Layers menu, if the page has its place