cornfield 0.62.0 → 0.64.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.
Files changed (44) hide show
  1. package/core/release-notes.js +2 -2
  2. package/explorer/css/changes.css +3 -7
  3. package/explorer/css/header.css +15 -0
  4. package/explorer/css/layers.css +11 -2
  5. package/explorer/css/map.css +0 -1
  6. package/explorer/css/node-panel.css +45 -0
  7. package/explorer/css/page.css +2 -7
  8. package/explorer/css/proposal.css +2 -3
  9. package/explorer/css/work.css +7 -7
  10. package/explorer/engine/hint.js +7 -7
  11. package/explorer/engine/keyboard.js +5 -4
  12. package/explorer/engine/map-rect.js +2 -2
  13. package/explorer/engine/render.js +2 -1
  14. package/explorer/forge-panel-model.js +24 -0
  15. package/explorer/history-model.js +21 -11
  16. package/explorer/history-replay.js +13 -5
  17. package/explorer/history.js +16 -7
  18. package/explorer/inbox-model.js +180 -0
  19. package/explorer/index.html +6 -3
  20. package/explorer/page.js +1 -2
  21. package/explorer/panel-model.js +103 -0
  22. package/explorer/panel-sections.js +140 -0
  23. package/explorer/pieces/inbox.js +201 -0
  24. package/explorer/pieces/layers.js +27 -6
  25. package/explorer/pieces/node-panel.js +78 -1
  26. package/explorer/pieces/search.js +22 -9
  27. package/explorer/pieces/work-deploys.js +13 -13
  28. package/explorer/pieces/work-issues.js +10 -5
  29. package/explorer/pieces/work-list.js +72 -9
  30. package/explorer/pieces/work-paint.js +45 -10
  31. package/explorer/pieces/work-prs.js +46 -34
  32. package/explorer/pieces/work-runs.js +17 -5
  33. package/explorer/pieces/work-specs.js +24 -4
  34. package/explorer/pieces/work-threads.js +59 -15
  35. package/explorer/pieces/work.js +6 -3
  36. package/explorer/proposal-model.js +3 -6
  37. package/explorer/runs-view.js +42 -8
  38. package/explorer/scene.js +5 -1
  39. package/explorer/work-model.js +266 -55
  40. package/explorer/work-view.css +60 -16
  41. package/explorer/work-view.js +175 -35
  42. package/package.json +1 -1
  43. package/server/server.js +1 -1
  44. package/server/work-graph.js +65 -8
@@ -1,11 +1,4 @@
1
- /* The Work view (explorer/work-view.js, spec 0012): the toggles at the top left of the stage (All work, Waiting on you, List), the line of what could not be read, and the node panel's work detail. */
2
- .hx-work-bar { position: absolute; z-index: 4; left: var(--corn-space-4); top: var(--corn-space-4); display: flex; gap: var(--corn-space-2); }
3
- .hx-work-bar { align-items: center; }
4
- .hx-work-bar[hidden] { display: none; }
5
- .hx-work-chip { box-sizing: border-box; min-height: 2rem; padding: 0 var(--corn-space-4); border: var(--corn-border) solid var(--corn-line); border-radius: var(--corn-radius-pill); background: var(--corn-surface-1); color: var(--corn-text-2); font-family: inherit; font-size: var(--corn-text-xs); font-weight: 600; cursor: pointer; }
6
- .hx-work-chip[aria-pressed="true"], .hx-work-chip[aria-expanded="true"] { background: var(--corn-accent); border-color: var(--corn-accent); color: var(--corn-text-on-accent); }
7
- .hx-work-chip[hidden] { display: none; }
8
- .hx-work-chip:focus-visible { outline: var(--corn-focus-width) solid var(--corn-focus); outline-offset: var(--corn-focus-offset); }
1
+ /* The Work view (explorer/work-view.js, spec 0012): the line of what could not be read, and the node panel's work detail. Its controls (Waiting on you, List) are the header's (css/header.css, spec 0015 D5). */
9
2
  .hx-work-note { position: absolute; z-index: 3; left: var(--corn-space-4); bottom: var(--corn-space-4); max-width: min(32rem, calc(100% - var(--corn-space-8))); margin: 0; padding: var(--corn-space-2) var(--corn-space-3); border-radius: var(--corn-radius); background: var(--corn-surface-1); color: var(--corn-text-2); font-size: var(--corn-text-xs); }
10
3
  .hx-work-note[hidden] { display: none; }
11
4
  .hx-view-badge { margin-left: var(--corn-space-2); }
@@ -18,34 +11,34 @@
18
11
  .hx-work-head, .hx-work-actions { display: flex; flex-direction: column; gap: var(--corn-space-2); margin: var(--corn-space-3) 0; }
19
12
  .hx-work-pills { display: flex; flex-wrap: wrap; gap: var(--corn-space-2); margin: 0; }
20
13
  .hx-work-actions .hx-foot-btn { align-self: flex-start; }
21
- /* The lanes' titles: lines over the map, in screen space (work-view.js `paintLanes`), so they read at any zoom */
14
+ /* The lanes' titles: lines over the map, in screen space (work-view.js `paintLanes`), so they read at any zoom; held at the map's top while their lane is in view */
22
15
  .hx-work-lanes { position: absolute; inset: 0; z-index: 2; overflow: hidden; pointer-events: none; }
23
16
  .hx-work-lanes[hidden] { display: none; }
24
17
  .hx-work-lane-title { position: absolute; display: flex; gap: var(--corn-space-2); align-items: baseline; max-width: 100%; overflow: hidden; white-space: nowrap; font-size: var(--corn-text-xs); font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--corn-text-2); }
25
- .hx-work-lane-title.is-held { padding: 0 var(--corn-space-2); border-radius: var(--corn-radius-sm); background: color-mix(in srgb, var(--corn-surface-1) 85%, transparent); } /* held under the toggles over the lane's nodes: a ground of its own */
18
+ .hx-work-lane-title.is-held { padding: 0 var(--corn-space-2); border-radius: var(--corn-radius-sm); background: color-mix(in srgb, var(--corn-surface-1) 85%, transparent); } /* held at the top over the lane's nodes: a ground of its own */
26
19
  .hx-work-lane-title > :first-child { overflow: hidden; text-overflow: ellipsis; }
27
20
  .hx-work-lane-count { flex: none; font-weight: 600; letter-spacing: 0; }
28
- .hx-work-busy { margin-left: var(--corn-space-2); font-size: var(--corn-text-xs); color: var(--corn-text-2); }
21
+ .hx-work-busy { font-size: var(--corn-text-xs); color: var(--corn-text-2); white-space: nowrap; }
29
22
  .hx-work-busy[hidden] { display: none; }
30
23
  /* While the first answer is on its way: the lanes, empty, with the words; nothing on the page waits for it */
31
24
  .hx-work-loading { position: absolute; z-index: 2; inset: 0; pointer-events: none; }
32
25
  .hx-work-loading[hidden] { display: none; }
33
- .hx-work-skeleton { position: absolute; left: var(--corn-space-4); right: var(--corn-space-4); top: 3.5rem; bottom: var(--corn-space-6); display: grid; grid-template-columns: repeat(4, 1fr) 1.6fr; gap: var(--corn-space-3); }
26
+ .hx-work-skeleton { position: absolute; left: var(--corn-space-4); right: var(--corn-space-4); top: var(--corn-space-4); bottom: var(--corn-space-6); display: grid; grid-template-columns: repeat(4, 1fr) 1.6fr; gap: var(--corn-space-3); }
34
27
  .hx-work-skel-lane { display: flex; flex-direction: column; gap: var(--corn-space-4); padding: var(--corn-space-3); border: var(--corn-border) solid var(--corn-line); border-radius: var(--corn-radius); background: color-mix(in srgb, var(--corn-surface-1) 55%, transparent); }
35
28
  .hx-work-skel-lane .hx-work-lane-title { position: static; }
36
29
  .hx-work-skel-lane i { display: block; height: 2.25rem; border-radius: var(--corn-radius-sm); background: var(--corn-surface-3); opacity: 0.7; animation: hx-work-pulse 1.6s ease-in-out infinite; }
37
30
  .hx-work-skel-lane i:nth-of-type(2) { animation-delay: 0.2s; width: 80%; }
38
31
  .hx-work-skel-lane i:nth-of-type(3) { animation-delay: 0.4s; width: 65%; }
39
32
  .hx-work-skel-lane i:nth-of-type(4) { animation-delay: 0.6s; width: 90%; }
33
+ /* The lanes' titles hold the map's top line in the Work view, where the hint would sit */
34
+ .hx-stage.is-work .hx-hint { display: none; }
40
35
  @keyframes hx-work-pulse { 0%, 100% { opacity: 0.35; } 50% { opacity: 0.8; } }
41
36
  @media (prefers-reduced-motion: reduce) { .hx-work-skel-lane i { animation: none; opacity: 0.6; } }
42
37
  .hx-work-loading-text { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(26rem, calc(100% - var(--corn-space-8))); margin: 0; padding: var(--corn-space-3) var(--corn-space-4); border-radius: var(--corn-radius); border: var(--corn-border) solid var(--corn-line); background: var(--corn-surface-1); color: var(--corn-text); font-size: var(--corn-text-sm); text-align: center; box-shadow: var(--corn-shadow); }
43
38
  @container corn-box (max-width: 767px) {
44
- /* The Layers chip and Fit sit on the map's top row (layers.css, header.css); the toggles go on the row under them, and the lanes run top to bottom */
45
- .hx-work-bar { top: calc(var(--corn-space-4) + var(--hx-control-h) + var(--corn-space-3)); }
39
+ /* The Layers chip, the view's controls and Fit sit on the map's top row (layers.css, header.css); the lanes run top to bottom under it */
46
40
  .hx-work-note { bottom: var(--corn-space-4); }
47
- .hx-stage.is-work .hx-hint { display: none; } /* the toggles' row is where the hint would sit */
48
- .hx-work-skeleton { grid-template-columns: 1fr; grid-auto-rows: min-content; top: calc(var(--corn-space-4) + var(--hx-control-h) * 2 + var(--corn-space-6)); overflow: hidden; }
41
+ .hx-work-skeleton { grid-template-columns: 1fr; grid-auto-rows: min-content; top: calc(var(--corn-space-4) + var(--hx-control-h) + var(--corn-space-4)); overflow: hidden; }
49
42
  .hx-work-skel-lane i:nth-of-type(n + 3) { display: none; }
50
43
  }
51
44
  /* The Layers menu in the Work view lists the Work view's rows; the map's keys (its kinds of line, the cloud's, the runs' and the proposal marks') are about the map */
@@ -58,3 +51,54 @@ body:has(.hx-stage.is-work) .hx-layers :is([data-corn="legend-key"], [data-corn=
58
51
  .hx-work-badges[hidden] { display: none; }
59
52
  .hx-work-badge { position: absolute; box-sizing: border-box; display: inline-block; max-width: 14rem; padding: 0 var(--corn-space-1); border: var(--corn-border-strong) solid var(--hx-badge, var(--corn-line)); border-radius: var(--corn-radius-pill); background: color-mix(in srgb, var(--corn-surface-1) 92%, transparent); color: var(--corn-text); font-weight: 600; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transform: translateX(-50%); }
60
53
  .hx-work-badge.is-waiting { border-width: calc(var(--corn-border-strong) + var(--corn-border)); }
54
+ /* The Work inbox (explorer/pieces/inbox.js, spec 0016): the queue over the stage, on the page's own ground, beside the node panel (which stays over it, as over the map).
55
+ The kind is said by its tag in words; the mark beside it is its shape in the kind's colour (`--hx-glyph`, set from `--corn-work-<kind>` as the badges' is). */
56
+ .hx-work-as { display: inline-flex; gap: 0; }
57
+ .hx-work-as .hx-view-control:first-child { border-top-right-radius: 0; border-bottom-right-radius: 0; }
58
+ .hx-work-as .hx-view-control:last-child { border-top-left-radius: 0; border-bottom-left-radius: 0; border-left-width: 0; }
59
+ .hx-inbox { position: absolute; inset: 0; z-index: 4; display: grid; grid-template-columns: minmax(20rem, 28rem) 1fr; background: var(--corn-ground); color: var(--corn-text); }
60
+ .hx-inbox[hidden] { display: none; }
61
+ .hx-stage.is-inbox .hx-work-badges, .hx-stage.is-inbox .hx-work-lanes { display: none; }
62
+ .hx-inbox-queue { overflow-y: auto; min-height: 0; padding: var(--corn-space-2) 0 var(--corn-space-8); border-right: var(--corn-border) solid var(--corn-line); background: var(--corn-surface-1); }
63
+ .hx-inbox-head { display: flex; align-items: baseline; gap: var(--corn-space-2); padding: var(--corn-space-3) var(--corn-space-4) var(--corn-space-1); }
64
+ .hx-inbox-title { margin: 0; font-size: var(--corn-text-md); font-weight: 600; }
65
+ .hx-inbox-sub { color: var(--corn-text-3); font-size: var(--corn-text-sm); }
66
+ .hx-inbox-empty { margin: var(--corn-space-3) var(--corn-space-4); color: var(--corn-text-2); font-size: var(--corn-text-sm); }
67
+ .hx-inbox-empty strong { display: block; color: var(--corn-text); font-size: var(--corn-text-md); margin-bottom: var(--corn-space-1); }
68
+ .hx-inbox-group { margin-top: var(--corn-space-2); }
69
+ .hx-inbox-group-head, .hx-inbox-drafts { display: flex; align-items: center; gap: var(--corn-space-2); width: 100%; margin: 0; padding: var(--corn-space-2) var(--corn-space-4); border: 0; background: none; color: var(--corn-text-3); font-size: var(--corn-text-xs); font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; text-align: left; cursor: pointer; }
70
+ .hx-inbox-drafts { cursor: default; }
71
+ .hx-inbox-group-head::after { content: '▾'; margin-left: auto; }
72
+ .hx-inbox-group-head[aria-expanded="false"]::after { content: '▸'; }
73
+ .hx-inbox-group.is-waiting .hx-inbox-group-head { color: var(--corn-warn, var(--corn-text-2)); }
74
+ .hx-inbox-count { font-variant-numeric: tabular-nums; }
75
+ .hx-inbox-hint { font-weight: 400; letter-spacing: 0; text-transform: none; }
76
+ .hx-inbox-rows { list-style: none; margin: 0; padding: 0 var(--corn-space-2); display: grid; gap: calc(var(--corn-space-1) / 2); }
77
+ .hx-inbox-row { position: relative; display: grid; grid-template-columns: 1.25rem minmax(0, 1fr) auto; gap: calc(var(--corn-space-1) / 2) var(--corn-space-3); align-items: start; padding: var(--corn-space-2) var(--corn-space-3); border: var(--corn-border) solid transparent; border-radius: var(--corn-radius); cursor: pointer; }
78
+ .hx-inbox-row:hover { background: var(--corn-surface-2); }
79
+ .hx-inbox-row.is-selected { background: var(--corn-accent-soft, var(--corn-surface-3)); border-color: var(--corn-accent); }
80
+ .hx-inbox-glyph { grid-row: span 2; margin-top: calc(var(--corn-space-1) / 2); }
81
+ .hx-inbox-glyph > * { fill: var(--hx-glyph, var(--corn-text-3)); }
82
+ .hx-inbox-line { min-width: 0; margin: 0; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--corn-text-sm); font-weight: 500; cursor: pointer; }
83
+ /* The line is the row's button: it covers the row (its action stays over it), and its focus ring is the row's */
84
+ .hx-inbox-line::after { content: ''; position: absolute; inset: 0; border-radius: var(--corn-radius); }
85
+ .hx-inbox-line:focus-visible { outline: none; }
86
+ .hx-inbox-row:has(.hx-inbox-line:focus-visible) { outline: var(--corn-focus-width) solid var(--corn-focus); outline-offset: calc(0px - var(--corn-focus-width)); }
87
+ .hx-inbox-tag { margin-right: var(--corn-space-1); color: var(--corn-text-3); font-weight: 400; font-variant-numeric: tabular-nums; }
88
+ .hx-inbox-age { color: var(--corn-text-3); font-size: var(--corn-text-xs); white-space: nowrap; font-variant-numeric: tabular-nums; }
89
+ .hx-inbox-why { grid-column: 2; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--corn-text-2); font-size: var(--corn-text-xs); }
90
+ .hx-inbox-why.is-bad { color: var(--corn-bad); }
91
+ .hx-inbox-act { grid-column: 3; grid-row: 2; height: 1.6rem; padding: 0 var(--corn-space-3); border-radius: var(--corn-radius-sm); border: var(--corn-border) solid var(--corn-line); background: var(--corn-surface-2); color: var(--corn-text); font-size: var(--corn-text-xs); white-space: nowrap; cursor: pointer; opacity: 0; position: relative; z-index: 1; }
92
+ .hx-inbox-act.is-primary { background: var(--corn-accent); border-color: var(--corn-accent); color: var(--corn-text-on-accent); font-weight: 600; }
93
+ .hx-inbox-row:hover .hx-inbox-act, .hx-inbox-row.is-selected .hx-inbox-act, .hx-inbox-row:focus-within .hx-inbox-act { opacity: 1; }
94
+ @media (hover: none) { .hx-inbox-act { opacity: 1; } }
95
+ .hx-inbox-also { grid-column: 2 / 4; display: flex; align-items: center; gap: var(--corn-space-1); color: var(--corn-warn, var(--corn-text-2)); font-size: var(--corn-text-xs); }
96
+ .hx-inbox-also .hx-inbox-glyph { grid-row: auto; margin: 0; width: 12px; height: 12px; }
97
+ .hx-inbox-pick { align-self: center; justify-self: center; max-width: 24rem; margin: 0; color: var(--corn-text-3); font-size: var(--corn-text-sm); text-align: center; }
98
+ .hx-inbox-pick[hidden] { display: none; }
99
+ @container corn-box (max-width: 767px) {
100
+ /* The Layers chip and the view's controls float on the map's top two rows here (layers.css, header.css): the queue starts under them */
101
+ .hx-inbox { grid-template-columns: 1fr; padding-top: calc(2 * var(--hx-control-h) + 2 * var(--corn-space-4)); }
102
+ .hx-inbox-queue { border-right: 0; border-top: var(--corn-border) solid var(--corn-line); }
103
+ .hx-inbox-pick { display: none; }
104
+ }
@@ -10,13 +10,15 @@
10
10
  * followWorkAddress() `?view=work`, `?pr=`, `?issue=`, `?run=`, `?thread=` and `?spec=` (work-model.js `workAddress`): the node, or for work older than the graph's
11
11
  * 14 days the Work list and the node panel (pieces/work-list.js `showRef`)
12
12
  *
13
- * What it puts on the page: the view switch's Work button, with "waiting on you" as its badge, the toggles at the top left of the stage ("All work", "Waiting on you" and
14
- * **List**, which opens the Work list (pieces/work-list.js) where the side panel sat), the lanes' titles in screen space (the map draws the lanes' panels), the words
13
+ * What it puts on the page: the view switch's Work button, with "waiting on you" as its badge, the view's controls in the header after the View switch (spec 0015 D5:
14
+ * **Waiting on you**, a toggle, off for all the work, and **List**, which opens the Work list (pieces/work-list.js)), the lanes' titles in screen space (the map draws the lanes' panels), the words
15
15
  * and the empty lanes shown at once while the first answer is on its way (the page stays usable: the views, the Layers menu, search), "Updating…" while a refresh
16
16
  * is (the last answer stays on the map, and a refresh that fails keeps it and says so), the map's own card when the answer is refused (signed out, not a maintainer,
17
17
  * offline: pieces/status.js), and a quiet line naming what the server could not read (`problems`). It answers the node panel's `work:panel` ask with what a node says in
18
18
  * the Work view (the Work piece draws the actions into it), the Work list's `work:pick` ask by selecting that row's node, and holds the keys of the view: N and P step through
19
- * the lanes, an arrow goes to the nearest node that way. Every request goes through `credentialed`;
19
+ * the lanes, an arrow goes to the nearest node that way. The code column holds one node per area (spec 0015 D1): selecting an area opens it in place, a tap on it again
20
+ * or clearing the selection (Escape) closes it, and selecting a node of code (a search, an address, the keyboard) opens its area; a thread folded into its proposal
21
+ * (spec 0015 D2) selects the proposal. Every request goes through `credentialed`;
20
22
  * every word that comes from the forge is escaped or set as text, every link goes through `safeUrl` (work-model.js).
21
23
  *
22
24
  * The **Work layer** of the Map view (spec 0012 D4, work-badge-model.js and work-badges.js) shares this file's one read of the graph: turning the layer on asks for it only when the
@@ -44,8 +46,9 @@ import { workButtonName } from './waiting-model.js';
44
46
  import { stepFrom } from './keyboard-model.js';
45
47
  import { RUNS_POLL_MS } from './pieces/work-common.js';
46
48
  import { showWorkRef, openForge, closeForge } from './forge-panel.js';
49
+ import { mount as mountInbox } from './pieces/inbox.js';
47
50
  import {
48
- CODE_LAYER, DRAFT_LAYER, KIND_WORDS, addressOf, applyFilters, arrowTarget, landingWords, applyWorkLayout, codePanelHtml, layerRowsOf, newWorkState, nodeForAddress, openedWords, panelOf, setWorkGraph, showWork, touchedBy, workAddress, workPanelHtml,
51
+ CODE_LAYER, DRAFT_LAYER, KIND_WORDS, addressOf, applyFilters, areaFor, arrowTarget, drawnEdges, landingWords, applyWorkLayout, codePanelHtml, layerRowsOf, newWorkState, nodeForAddress, openedWords, panelOf, setOpenArea, setWorkGraph, showWork, touchedBy, workAddress, workPanelHtml,
49
52
  } from './work-model.js';
50
53
 
51
54
  const GRAPH_URL = '/api/forge/work-graph';
@@ -53,18 +56,27 @@ const $ = (id) => document.getElementById(id);
53
56
 
54
57
  let wired = false;
55
58
  let offered = false;
56
- let els = null; // { stage, bar, all, waiting, busy, note, lanes, loading }
59
+ let els = null; // { stage, bar (the header's group of the view's controls), waiting, list, busy, note, lanes, loading }
57
60
  let laneEls = []; // the lanes' titles on the stage, in screen space: [{ el, name, count }]
58
61
  let laneKey = null; // the lanes they were made for
59
62
  let offPaint = null;
60
63
  let badges = null; // the Work layer's pills over the map (work-badges.js)
61
64
  let badgeWas = false; // whether the layer wanted the graph at the last look: it asks for it when it comes on
62
65
  let card = null; // the map's own card (pieces/status.js)
66
+ let inbox = null; // the Work inbox over the stage (pieces/inbox.js, spec 0016)
63
67
  let timer = 0;
64
68
  let seq = 0; // the answer that is waited for: an older one is dropped
65
69
  let wasOn = false;
66
70
 
67
71
  const inst = () => pageInstance();
72
+
73
+ /** Inbox or Graph (spec 0016 D1): the Work view opens on the Inbox; the choice is remembered like a layer */
74
+ const AS_KEY = 'cornfield.work.as';
75
+ function rememberedAs() {
76
+ try { return localStorage.getItem(AS_KEY) === 'graph' ? 'graph' : 'inbox'; } catch { return 'inbox'; }
77
+ }
78
+ const asOf = () => { const w = work(); if (w.as !== 'inbox' && w.as !== 'graph') w.as = rememberedAs(); return w.as; };
79
+ const inInbox = () => on() && asOf() === 'inbox';
68
80
  const work = () => state.work || (state.work = newWorkState());
69
81
  const on = () => state.view === 'work';
70
82
 
@@ -90,6 +102,8 @@ export function initWorkView(opts = {}) {
90
102
  i.on('work:available', ({ on: available }) => { paintList(available); i.emit('layers:redraw'); syncBadges(); });
91
103
  i.on('work:panel', (node) => panelFor(node));
92
104
  i.on('work:pick', (ref) => pickRef(ref));
105
+ i.on('selection', onSelection);
106
+ i.on('select', onTap);
93
107
  mapStyleOf(i).onChange(() => { paintEdgeColors(); if (on()) { state.workRows = layerRowsOf(work().nodes).map(themed); i.emit('layers:redraw'); i.touchScene(); render(); } });
94
108
  }
95
109
  state.workRow = () => (offered && inst().ask('work:on') ? badgeRowOf(work(), badgeColor('pull')) : null); // the Layers menu's row under Overlays (engine/layers.js `layerRows`)
@@ -125,18 +139,28 @@ function paintBadge(total) {
125
139
  // ---------------------------------------------------------------------------
126
140
  // The page's parts
127
141
  // ---------------------------------------------------------------------------
142
+ /** The header's group for the view's own controls (index.html, spec 0015 D5); a page without it gets one after the View switch, else over the map */
143
+ function controlsSlot(stage) {
144
+ const slot = document.querySelector('[data-corn="view-controls"]');
145
+ if (slot) return slot;
146
+ const made = document.createElement('div');
147
+ made.className = 'hx-view-controls';
148
+ made.dataset.corn = 'view-controls';
149
+ made.setAttribute('role', 'group');
150
+ made.setAttribute('aria-label', 'Work view');
151
+ const view = document.querySelector('[data-corn="view-switch"]');
152
+ if (view) view.after(made); else stage.append(made);
153
+ return made;
154
+ }
155
+
128
156
  function mount() {
129
157
  const stage = state.canvas ? state.canvas.parentElement : null;
130
- if (!stage || (els && els.stage === stage && stage.contains(els.bar))) return;
131
- const bar = document.createElement('div');
132
- bar.className = 'hx-work-bar';
133
- bar.dataset.corn = 'work-bar';
134
- bar.setAttribute('role', 'group');
135
- bar.setAttribute('aria-label', 'Show');
158
+ if (!stage || (els && els.stage === stage && els.bar.isConnected && stage.contains(els.lanes))) return;
159
+ const bar = controlsSlot(stage);
136
160
  bar.hidden = true;
137
- bar.innerHTML = '<button type="button" class="hx-work-chip" data-corn="work-chip" data-corn-kind="quiet" data-work-show="all" aria-pressed="true">All work</button>'
138
- + '<button type="button" class="hx-work-chip" data-corn="work-chip" data-corn-kind="quiet" data-work-show="waiting" aria-pressed="false">Waiting on you</button>'
139
- + '<button type="button" class="hx-work-chip" data-corn="work-chip" data-corn-kind="quiet" data-action="toggle-forge" aria-expanded="false" aria-controls="forge-panel" aria-label="Work list" title="The lists of issues, pull requests, proposals, threads, runs and deploys" hidden>List</button>'
161
+ bar.innerHTML = '<span class="hx-work-as" role="group" aria-label="Show the work as"><button type="button" class="hx-view-control" data-corn="work-chip" data-corn-kind="secondary" data-work-as="inbox" aria-pressed="true" title="What needs you, in a queue (G switches)">Inbox</button><button type="button" class="hx-view-control" data-corn="work-chip" data-corn-kind="secondary" data-work-as="graph" aria-pressed="false" title="The lanes of work and the code they touch (G switches)">Graph</button></span>'
162
+ + '<button type="button" class="hx-view-control" data-corn="work-chip" data-corn-kind="secondary" data-work-toggle="waiting" aria-pressed="false" title="Show only what waits on you; the rest is dimmed">Waiting on you</button>'
163
+ + '<button type="button" class="hx-view-control" data-corn="work-chip" data-corn-kind="secondary" data-action="toggle-forge" aria-expanded="false" aria-controls="forge-panel" aria-label="Work list" title="The lists of issues, pull requests, proposals, threads, runs and deploys" hidden>List</button>'
140
164
  + '<span class="hx-work-busy" hidden>Updating…</span>';
141
165
  const note = document.createElement('p');
142
166
  note.className = 'hx-work-note';
@@ -155,8 +179,16 @@ function mount() {
155
179
  loading.hidden = true;
156
180
  loading.innerHTML = `<div class="hx-work-skeleton" aria-hidden="true">${['Talk', 'Decide', 'Build', 'Ship', 'Code it touches'].map((name) => `<div class="hx-work-skel-lane"><span class="hx-work-lane-title">${name}</span><i></i><i></i><i></i><i></i></div>`).join('')}</div>`
157
181
  + '<p class="hx-work-loading-text" role="status">Reading the work from the forge. A big repository can take several seconds the first time; the page works meanwhile.</p>';
158
- stage.append(lanes, loading, bar, note);
159
- els = { stage, bar, all: bar.children[0], waiting: bar.children[1], list: bar.children[2], busy: bar.children[3], note, lanes, loading };
182
+ stage.append(lanes, loading, note);
183
+ els = { stage, bar, as: bar.children[0], waiting: bar.children[1], list: bar.children[2], busy: bar.children[3], note, lanes, loading };
184
+ if (inbox) inbox.destroy();
185
+ inbox = mountInbox(stage, {
186
+ pick: (id) => pick(id, { frame: false, source: 'link' }),
187
+ act: (id) => actOn(id),
188
+ announce: (words) => announce(inst(), words),
189
+ colorOf: (kind) => badgeColor(kind),
190
+ refresh: () => paintInbox(),
191
+ });
160
192
  paintList(!!inst().ask('work:on')); // the List toggle is there while the Work piece is on: a signed-in maintainer of a forge
161
193
  if (offPaint) offPaint();
162
194
  if (badges) badges.destroy();
@@ -188,11 +220,11 @@ function watchSize(stage) {
188
220
  }).observe(stage);
189
221
  }
190
222
 
191
- /** The lanes' titles, over the map in screen space: centred over their lane and held under the toggles while the lane is in view (a phone's: at the lane's top left) */
223
+ /** The lanes' titles, over the map in screen space: centred over their lane and held at the map's top while the lane is in view (a phone's: at the lane's top left, under the controls on the map) */
192
224
  function paintLanes(scene, camera) {
193
225
  if (!els) return;
194
226
  const w = work();
195
- const show = on() && w.status === 'ok' && w.lanes.length > 0;
227
+ const show = on() && !inInbox() && w.status === 'ok' && w.lanes.length > 0;
196
228
  els.lanes.hidden = !show;
197
229
  if (!show) return;
198
230
  if (laneKey !== w.lanes) {
@@ -212,13 +244,13 @@ function paintLanes(scene, camera) {
212
244
  });
213
245
  }
214
246
  const phone = isPhone();
215
- const top = phone ? STICKY_TOP_PHONE : STICKY_TOP;
247
+ const top = phone ? phoneTop() : STICKY_TOP;
216
248
  for (const { el, lane } of laneEls) {
217
249
  const left = camera.x + lane.x * camera.zoom;
218
250
  const right = left + lane.w * camera.zoom;
219
251
  const topPx = camera.y + lane.y * camera.zoom;
220
252
  const bottomPx = topPx + lane.h * camera.zoom;
221
- // a phone's title stays at its lane's top and goes when that is under the toggles; a desktop's is held under them while the lane is in view
253
+ // a phone's title stays at its lane's top and goes when that is under the controls on the map; a desktop's is held at the map's top while the lane is in view
222
254
  const seen = right > 0 && left < els.stage.clientWidth && bottomPx > 40 && topPx < els.stage.clientHeight && !(phone && topPx + 8 < top);
223
255
  el.style.visibility = seen ? 'visible' : 'hidden';
224
256
  if (!seen) continue;
@@ -229,23 +261,64 @@ function paintLanes(scene, camera) {
229
261
  if (phone) { el.style.left = `${Math.round(Math.max(left, 0) + 10)}px`; el.style.transform = 'none'; } else { el.style.left = `${Math.round((left + right) / 2)}px`; el.style.transform = 'translateX(-50%)'; }
230
262
  }
231
263
  }
232
- /** The line the lanes' titles hold under, in px from the top of the stage: below the toggles (a phone's are on a second row, under the Layers chip) */
233
- const STICKY_TOP = 58;
234
- const STICKY_TOP_PHONE = 108;
264
+ /** The line the lanes' titles hold under, in px from the top of the stage: the map's top, now that the view's controls are in the header (spec 0015 D5) */
265
+ const STICKY_TOP = 12;
266
+ /** A phone's: under the row the Layers chip and the view's controls sit on, on the map (measured: the controls wrap to a second row when the words are long) */
267
+ const STICKY_TOP_PHONE = 72;
268
+ function phoneTop() {
269
+ const tools = document.querySelector('.hx-view-tools');
270
+ if (!tools || !els) return STICKY_TOP_PHONE;
271
+ const bottom = tools.getBoundingClientRect().bottom - els.stage.getBoundingClientRect().top;
272
+ return bottom > 0 ? Math.round(bottom + 12) : STICKY_TOP_PHONE;
273
+ }
235
274
 
236
275
  function paintBar() {
237
276
  if (!els) return;
238
277
  const w = work();
239
- const n = w.counts.waiting;
240
278
  els.bar.hidden = !on();
241
- els.all.setAttribute('aria-pressed', String(!w.waiting));
242
- els.waiting.setAttribute('aria-pressed', String(w.waiting));
243
- els.waiting.textContent = `Waiting on you · ${n}`;
279
+ els.waiting.setAttribute('aria-pressed', String(!!w.waiting)); // the Work button's badge says how many; the toggle says only that it is on
280
+ els.waiting.hidden = inInbox(); // the Inbox is what waits on you, in a queue: dimming is the Graph's
281
+ for (const b of els.as.querySelectorAll('[data-work-as]')) b.setAttribute('aria-pressed', String(b.dataset.workAs === asOf()));
282
+ if (els.stage) els.stage.classList.toggle('is-inbox', inInbox());
244
283
  els.busy.hidden = !(on() && w.status === 'ok' && w.updating);
245
284
  els.loading.hidden = !(on() && w.status === 'loading');
246
285
  const lines = [...(w.stale ? [w.stale] : []), ...(w.lastError ? [w.lastError] : []), ...w.problems.map((p) => p.text)];
247
286
  els.note.hidden = !on() || !lines.length;
248
287
  els.note.textContent = lines.length ? lines.slice(0, 2).join(' ') + (lines.length > 2 ? ` and ${lines.length - 2} more.` : '') : '';
288
+ paintInbox();
289
+ }
290
+
291
+ /** The Inbox drawn from the last answer, the selection marked (spec 0016); hidden in the Graph and off the Work view */
292
+ function paintInbox() {
293
+ if (!inbox) return;
294
+ const w = work();
295
+ inbox.paint(w.graph, { on: inInbox() && w.status === 'ok', selected: state.selectedNode ? state.selectedNode.id : null });
296
+ }
297
+
298
+ /** Inbox or Graph (spec 0016 D1), remembered; the Graph is fitted again as it comes back */
299
+ function setAs(as) {
300
+ const w = work();
301
+ if (asOf() === as) return;
302
+ w.as = as;
303
+ try { localStorage.setItem(AS_KEY, as); } catch { /* remembering is a convenience */ }
304
+ paintBar();
305
+ if (on() && w.status === 'ok' && as === 'graph') { applyWorkLayout(state, { phone: isPhone() }); inst().touchScene(); fitGraphToViewport(fitPadding()); render(); }
306
+ if (as === 'inbox' && inbox) inbox.focus();
307
+ announce(inst(), as === 'inbox' ? 'Inbox.' : 'Graph: the lanes of work.');
308
+ }
309
+
310
+ /** A row's action (spec 0016 D5, D6): its piece of work is selected and the node panel's own primary action is pressed, with the confirm step it has there */
311
+ function actOn(id) {
312
+ if (!pick(id, { frame: false, source: 'link' })) return;
313
+ const t0 = Date.now();
314
+ const press = () => {
315
+ const bar = document.querySelector('[data-corn="node-panel"] [data-corn="actions"]');
316
+ const btn = bar ? bar.querySelector('button:not([disabled]), a[href]') : null;
317
+ if (btn) { btn.click(); return; }
318
+ if (Date.now() - t0 < 2000) setTimeout(press, 60); // the Work piece draws a piece of work's actions once what it needs is read
319
+ else announce(inst(), 'Its actions are in the panel.');
320
+ };
321
+ setTimeout(press, 0);
249
322
  }
250
323
 
251
324
  /** The view opened or closed: the button, the bar, the stage; the map's own layers are back when it closed (work-model.js `leaveWork`) */
@@ -432,8 +505,9 @@ function arrive(body, { select, ask, quiet }) {
432
505
  const first = w.status !== 'ok';
433
506
  const before = state.selectedNode ? state.selectedNode.id : null;
434
507
  const base = state.baseNodes && state.baseNodes.length ? state.baseNodes : (w.saved ? w.saved.nodes : state.nodes);
508
+ const baseEdges = state.baseNodes && state.baseNodes.length ? state.baseEdges : (w.saved ? w.saved.edges : state.edges); // its ownership edges say which area a node is in
435
509
  const had = w.badges ? w.badges.size : -1;
436
- setWorkGraph(state, body, base);
510
+ setWorkGraph(state, body, base, baseEdges);
437
511
  w.badges = badgeIndex(w.nodes, w.edges);
438
512
  w.status = 'ok';
439
513
  w.updating = false;
@@ -495,7 +569,8 @@ function themed(row) {
495
569
  function refilter() {
496
570
  if (!on()) return;
497
571
  const w = work();
498
- applyFilters(w.nodes, w.edges, { layers: w.layers, waiting: w.waiting });
572
+ applyFilters(w.nodes, w.edges, { layers: w.layers, waiting: w.waiting, open: w.open });
573
+ state.edges = drawnEdges(w.nodes, w.edges, w.open); // an open area's ties to the nodes it shows
499
574
  const sel = state.selectedNode;
500
575
  applyWorkLayout(state, { phone: isPhone() });
501
576
  state.workRows = layerRowsOf(w.nodes).map(themed);
@@ -507,19 +582,75 @@ function refilter() {
507
582
 
508
583
  /** Selects a node of the view by id: the panel opens, the camera follows (as a search's choice does) */
509
584
  export function pick(id, { frame = true, source = 'link' } = {}) {
510
- const node = state.nodes.find((n) => n.id === id);
585
+ let node = state.nodes.find((n) => n.id === id);
586
+ if (node && node.foldedInto) node = state.nodes.find((n) => n.id === node.foldedInto); // a spec pull request's thread: its proposal (spec 0015 D2)
511
587
  if (!node) return false;
512
- if (node.hidden) { work().layers[node.draft ? DRAFT_LAYER : node.work ? `work-${node.work}` : CODE_LAYER] = true; refilter(); }
588
+ const layer = node.draft ? DRAFT_LAYER : node.work ? `work-${node.work}` : CODE_LAYER;
589
+ if (node.hidden && work().layers[layer] === false) { work().layers[layer] = true; refilter(); }
590
+ openAreaOf(node); // a node of code: its area opens in place (spec 0015 D1)
513
591
  selectNode(inst(), node, { frame, source });
514
592
  return true;
515
593
  }
516
594
 
517
- /** "Waiting on you" on or off: everything that does not wait is dimmed (spec 0012 D3) */
595
+ // ---------------------------------------------------------------------------
596
+ // The code column's areas (spec 0015 D1): one open at a time, in place
597
+ // ---------------------------------------------------------------------------
598
+
599
+ /** Opens an area (null: closes the open one) and lays the view out again where it is: the camera stays, and what is open is said */
600
+ function openArea(id, { say = true } = {}) {
601
+ if (!on() || work().status !== 'ok' || !setOpenArea(state, id)) return false;
602
+ applyWorkLayout(state, { phone: isPhone() });
603
+ state.workRows = layerRowsOf(work().nodes).map(themed);
604
+ inst().touchScene();
605
+ render();
606
+ if (say) {
607
+ const area = id ? work().nodes.find((n) => n.id === id) : null;
608
+ if (area) announce(inst(), `${area.label} open: ${area.drawn} ${area.drawn === 1 ? 'node' : 'nodes'} of code.`);
609
+ }
610
+ return true;
611
+ }
612
+
613
+ /** The area of a node of code, opened (a search's choice, an address, a step of the keyboard to it); nothing for a piece of work */
614
+ function openAreaOf(node) {
615
+ const id = areaFor(node);
616
+ if (id && id !== work().open) openArea(id, { say: false });
617
+ }
618
+
619
+ /** Moments ago, the selection opened this area: the tap that chose it is not a second press (`onTap`) */
620
+ let opened = null;
621
+
622
+ /**
623
+ * The selection changed. A node of code opens its area; nothing selected (Escape, a click on the background) closes it; a thread folded into its proposal
624
+ * selects the proposal (spec 0015 D2: it is not drawn, the proposal stands for it).
625
+ */
626
+ function onSelection({ node: picked }) {
627
+ if (!on() || work().status !== 'ok') return;
628
+ paintInbox();
629
+ if (!picked) { openArea(null); return; }
630
+ const node = work().nodes.find((n) => n.id === picked.id); // the view's own node (a tap names the scene's)
631
+ if (!node) return;
632
+ if (node.foldedInto) { const into = state.nodes.find((n) => n.id === node.foldedInto); if (into) selectNode(inst(), into, { frame: true, source: 'link' }); return; }
633
+ const id = areaFor(node);
634
+ if (!id || id === work().open) return;
635
+ openArea(id, { say: false });
636
+ if (node.area) { opened = id; queueMicrotask(() => { opened = null; }); }
637
+ }
638
+
639
+ /** A tap on the map's node: on the area that is selected already, it opens or closes it (the first tap selected it, and the selection opened it) */
640
+ function onTap(picked) {
641
+ const node = picked && on() ? work().nodes.find((n) => n.id === picked.id) : null;
642
+ if (!node || !node.area) return;
643
+ if (opened === node.id) { opened = null; return; }
644
+ if (!state.selectedNode || state.selectedNode.id !== node.id) return; // the selection opens it
645
+ if (openArea(work().open === node.id ? null : node.id)) inst().emit('node:show', { node: state.selectedNode, frame: false }); // the panel's lines say what is drawn now
646
+ }
647
+
648
+ /** "Waiting on you" on or off (off is all the work): everything that does not wait is dimmed (spec 0012 D3, 0015 D5) */
518
649
  function setWaiting(on_) {
519
650
  const w = work();
520
651
  if (w.waiting === on_) return;
521
652
  w.waiting = on_;
522
- applyFilters(w.nodes, w.edges, { layers: w.layers, waiting: w.waiting });
653
+ applyFilters(w.nodes, w.edges, { layers: w.layers, waiting: w.waiting, open: w.open });
523
654
  inst().touchScene();
524
655
  paintBar();
525
656
  render();
@@ -564,6 +695,11 @@ function pickRef(ref) {
564
695
  // Keys (the map's own are for the other views: Shift and an arrow still pan, the rest are the map's)
565
696
  // ---------------------------------------------------------------------------
566
697
  function onKey(e) {
698
+ if (on() && !e.defaultPrevented && !e.ctrlKey && !e.metaKey && !e.altKey && (e.key === 'g' || e.key === 'G') && !(e.target && e.target.closest && e.target.closest('input, textarea, select, [contenteditable="true"]'))) {
699
+ e.preventDefault();
700
+ setAs(asOf() === 'inbox' ? 'graph' : 'inbox');
701
+ return;
702
+ }
567
703
  if (!on() || e.defaultPrevented || e.ctrlKey || e.metaKey || e.altKey || !state.canvas || e.target !== state.canvas) return;
568
704
  const shown = shownInOrder();
569
705
  if (!shown.length) return;
@@ -588,8 +724,9 @@ function onClick(e) {
588
724
  if (!t_) return;
589
725
  if (t_.closest('[data-action="preset-work"]')) { if (on()) closeWork(); else openWork(); return; }
590
726
  if (t_.closest('[data-action="refresh-forge"]') && on()) { load({ again: true }); return; }
591
- const show = t_.closest('[data-work-show]');
592
- if (show && on()) { setWaiting(show.dataset.workShow === 'waiting'); return; }
727
+ if (t_.closest('[data-work-toggle="waiting"]') && on()) { setWaiting(!work().waiting); return; }
728
+ const as = t_.closest('[data-work-as]');
729
+ if (as && on()) { setAs(as.dataset.workAs); return; }
593
730
  const act = t_.closest('[data-work-action]');
594
731
  if (!act) return;
595
732
  if (act.dataset.workAction === 'open-item') { // a node panel's "Open work" link: the Work view opens on that piece of work (a new tab, by the link's own address, is left alone)
@@ -629,6 +766,7 @@ export async function followWorkAddress(search = location.search) {
629
766
  if (!ask) return false;
630
767
  if (!offered) { announce(inst(), 'The map of work needs a forge in the config.'); return false; }
631
768
  spend();
769
+ try { const as = new URLSearchParams(search).get('as'); if (as === 'graph' || as === 'inbox') work().as = as; } catch { /* the address is a convenience */ }
632
770
  return openWork({ ask: ask.kind ? ask : null });
633
771
  }
634
772
 
@@ -660,6 +798,8 @@ export function resetWorkViewForTests() {
660
798
  offered = false;
661
799
  els = null;
662
800
  card = null;
801
+ if (inbox) inbox.destroy();
802
+ inbox = null;
663
803
  seq++;
664
804
  wasOn = false;
665
805
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cornfield",
3
- "version": "0.62.0",
3
+ "version": "0.64.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)",
package/server/server.js CHANGED
@@ -89,7 +89,7 @@ import { createHistory } from '../core/history.js';
89
89
  export const CORNFIELD_DIR = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
90
90
  const EXPLORER_DIR = path.join(CORNFIELD_DIR, 'explorer');
91
91
  /** The pure core modules the explorer imports (no Node built-ins, no files): the only ones of core/ served */
92
- export const BROWSER_CORE = ['schema.js', 'proposal.js', 'personas.js', 'cloud.js', 'text.js', 'mentions.js', 'color.js', 'strings.js', 'layers.js'];
92
+ export const BROWSER_CORE = ['schema.js', 'proposal.js', 'personas.js', 'cloud.js', 'text.js', 'mentions.js', 'color.js', 'strings.js', 'layers.js', 'release-notes.js'];
93
93
  /** The explorer files the sign-in pages load: cornfield's tokens, their own stylesheet and the script that applies Light or Dark. Served without a session. */
94
94
  const SIGN_IN_FILES = new Set(['/explorer/tokens.css', '/explorer/sign-in.css', '/explorer/theme-boot.js']);
95
95
  /** cornfield's own browser sources, by request path */