cornfield 0.29.0 → 0.30.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/mentions.js CHANGED
@@ -2,7 +2,7 @@
2
2
  * @module core/mentions
3
3
  *
4
4
  * How a thread points at the map (spec 0005, D7). Pure: no I/O, no DOM, no Node built-ins, so the server (a hook's
5
- * payload) and the explorer (the lights, a node's "Mentioned in") load the same file.
5
+ * payload) and the explorer (the lights, a node's "Threads") load the same file.
6
6
  *
7
7
  * - **Mentions.** People write `[[core-server-auth]]` (a node's id) or `[[server/auth.js]]` (a repo path) in prose.
8
8
  * `parseMentions` reads them outside code: a fenced block and an inline code span are text about code, not links.
package/core/strings.js CHANGED
@@ -48,9 +48,8 @@ export const STRINGS = Object.freeze({
48
48
  continueRun: 'Continue',
49
49
  reply: 'Reply',
50
50
  // The node panel
51
- propsTitle: 'Properties & Attributes',
52
- detailsTitle: 'Details',
53
- openRoute: 'Open Live Route',
51
+ openRoute: 'Open route',
52
+ startRun: 'Start a run',
54
53
  copySpec: 'Copy Spec',
55
54
  // The hint, loading and errors
56
55
  hintInspect: 'Tap node to inspect live spec',
@@ -0,0 +1,33 @@
1
+ /**
2
+ * @module explorer/capped
3
+ *
4
+ * A long list in the node panel shows its first few items and a quiet "and 15 more" button that opens the rest in place
5
+ * (a disclosure: `aria-expanded`). `toggleCapped` is the click handler panels.js binds once on the panel.
6
+ */
7
+
8
+ /** Items shown before the rest folds away */
9
+ export const CAP = 5;
10
+ let counter = 0;
11
+
12
+ /**
13
+ * The items as HTML, folded after CAP when there are more.
14
+ * @param {string[]} items already-escaped HTML, one per item
15
+ */
16
+ export function capped(items) {
17
+ if (items.length <= CAP + 1) return items.join(''); // "and 1 more" saves nothing
18
+ const id = `hx-more-${++counter}`;
19
+ const rest = items.length - CAP;
20
+ return `${items.slice(0, CAP).join('')}<div class="hx-more" id="${id}" hidden>${items.slice(CAP).join('')}</div><button type="button" class="hx-btn hx-btn--quiet hx-textact hx-more-btn" data-more="${id}" data-rest="${rest}" aria-expanded="false" aria-controls="${id}">and ${rest} more</button>`;
21
+ }
22
+
23
+ /** Opens or folds the list a "more" button belongs to; true when the click was one */
24
+ export function toggleCapped(target) {
25
+ const button = target.closest && target.closest('[data-more]');
26
+ if (!button) return false;
27
+ const list = button.ownerDocument.getElementById(button.dataset.more);
28
+ const open = button.getAttribute('aria-expanded') !== 'true';
29
+ if (list) list.hidden = !open;
30
+ button.setAttribute('aria-expanded', String(open));
31
+ button.textContent = open ? 'Show fewer' : `and ${button.dataset.rest} more`;
32
+ return true;
33
+ }
@@ -128,7 +128,6 @@ h1, h2, h3, p { margin: 0; }
128
128
  .hx-btn--preset.hx-btn--active { background: var(--corn-hue-orange); border-color: var(--corn-hue-orange); color: var(--corn-ground); }
129
129
  .hx-btn--rom { width: 100%; justify-content: center; margin-top: var(--corn-space-1); padding: var(--corn-space-2); background: color-mix(in srgb, var(--corn-hue-fuchsia) 20%, transparent); border-color: color-mix(in srgb, var(--corn-hue-fuchsia) 40%, transparent); color: color-mix(in srgb, var(--corn-hue-fuchsia) 60%, var(--corn-text)); font-weight: 700; }
130
130
  .hx-btn--rom:hover { background: color-mix(in srgb, var(--corn-hue-fuchsia) 30%, transparent); }
131
- .hx-btn--copy { padding: var(--corn-space-3) var(--corn-space-4); border-radius: var(--corn-radius); border: 0; }
132
131
 
133
132
  .hx-dots { display: inline-flex; }
134
133
  .hx-dots span { width: 8px; height: 8px; border-radius: 50%; box-shadow: 0 0 0 var(--corn-border) var(--corn-ground); margin-left: calc(var(--corn-space-1) * -1); }
@@ -267,22 +266,16 @@ h1, h2, h3, p { margin: 0; }
267
266
  .hx-drawer-handle span { width: 48px; height: 6px; border-radius: var(--corn-radius-pill); background: var(--corn-surface-3); }
268
267
  .hx-drawer-body { flex: 1; display: flex; flex-direction: column; gap: var(--corn-space-5); padding: calc(var(--corn-space-5) + var(--corn-space-1)); overflow-y: auto; user-select: text; }
269
268
  @media (min-width: 640px) { .hx-drawer-body { padding: var(--corn-space-6); } }
270
- .hx-drawer-head { display: flex; align-items: center; justify-content: space-between; padding-bottom: var(--corn-space-4); border-bottom: var(--corn-border) solid var(--corn-surface-2); }
271
- .hx-drawer-title-wrap { display: flex; align-items: center; gap: var(--corn-space-3); min-width: 0; }
269
+ .hx-drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--corn-space-3); }
272
270
  .hx-drawer-title { font-size: var(--corn-text-lg); font-weight: 700; color: var(--corn-text); overflow-wrap: anywhere; }
273
- .hx-badge { flex: none; padding: calc(var(--corn-space-1) / 2) var(--corn-space-3); border-radius: var(--corn-radius-xs); border: var(--corn-border) solid color-mix(in srgb, var(--corn-accent-hover) 30%, transparent); background: var(--corn-accent-soft); color: var(--corn-accent-text); font-size: var(--corn-text-2xs); font-weight: 700; letter-spacing: 0.025em; }
274
271
  .hx-close { width: 32px; height: 32px; flex: none; border: 0; border-radius: var(--corn-radius-sm); background: var(--corn-surface-2); color: var(--corn-text-3); font-weight: 700; font-size: var(--corn-text-base); }
275
272
  .hx-close:hover { color: var(--corn-text); }
276
- .hx-lead { font-size: var(--corn-text-sm); line-height: 1.6; }
273
+ .hx-lead { font-size: var(--corn-text-base); line-height: 1.5; color: var(--corn-text-2); }
277
274
 
278
275
  .hx-block { display: flex; flex-direction: column; gap: var(--corn-space-3); }
279
276
  .hx-block-title { font-size: var(--corn-text-sm); font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--corn-text-2); }
280
- .hx-props { display: flex; flex-direction: column; gap: var(--corn-space-2); font-family: var(--corn-mono); font-size: var(--corn-text-xs); }
281
- .hx-prop { padding: var(--corn-space-3); border-radius: var(--corn-radius-sm); border: var(--corn-border) solid var(--corn-line); background: color-mix(in srgb, var(--corn-ground) 80%, transparent); }
282
- .hx-prop-head { display: flex; align-items: center; justify-content: space-between; gap: var(--corn-space-3); }
283
- .hx-prop-head .hx-faint { font-size: var(--corn-text-2xs); }
284
- .hx-prop > .hx-faint { font-size: var(--corn-text-2xs); margin-top: calc(var(--corn-space-1) / 2); }
285
- .hx-meta { display: flex; flex-direction: column; gap: var(--corn-space-1); padding: var(--corn-space-4); border-radius: var(--corn-radius-sm); border: var(--corn-border) solid var(--corn-line); background: color-mix(in srgb, var(--corn-ground) 55%, transparent); font-family: var(--corn-mono); font-size: var(--corn-text-xs); color: var(--corn-text-3); overflow-wrap: anywhere; }
277
+ .hx-meta { display: flex; flex-direction: column; gap: var(--corn-space-5); font-size: var(--corn-text-md); color: var(--corn-text-2); overflow-wrap: anywhere; }
278
+ .hx-meta > :empty { display: none; } /* no live data, no threads: no gap where they would be */
286
279
 
287
280
  .hx-sec { margin-top: var(--corn-space-2); padding-top: var(--corn-space-2); border-top: var(--corn-border) solid var(--corn-line); }
288
281
  .hx-line { display: flex; align-items: flex-start; gap: var(--corn-space-2); padding: calc(var(--corn-space-1) / 2) 0; }
@@ -312,10 +305,9 @@ h1, h2, h3, p { margin: 0; }
312
305
  .hx-chip--warning { background: var(--corn-warn); }
313
306
  .hx-chip--danger, .hx-chip--success, .hx-chip--warning { color: var(--corn-ground); }
314
307
 
315
- .hx-drawer-foot { display: flex; gap: var(--corn-space-3); flex: none; padding: var(--corn-space-5) var(--corn-space-5) calc(var(--corn-space-5) + env(safe-area-inset-bottom, 0px)); border-top: var(--corn-border) solid var(--corn-surface-2); background: color-mix(in srgb, var(--corn-ground) 80%, transparent); }
316
- .hx-open { flex: 1; display: flex; align-items: center; justify-content: center; gap: var(--corn-space-2); padding: var(--corn-space-3) var(--corn-space-4); border-radius: var(--corn-radius); background: var(--corn-accent); color: var(--corn-text-on-accent); font-size: var(--corn-text-sm); font-weight: 600; text-align: center; text-decoration: none; box-shadow: var(--corn-shadow-sm); transition: background 0.15s; }
308
+ .hx-drawer-foot { display: flex; align-items: stretch; gap: var(--corn-space-3); flex: none; padding: var(--corn-space-4) var(--corn-space-5) calc(var(--corn-space-4) + env(safe-area-inset-bottom, 0px)); border-top: var(--corn-border) solid var(--corn-surface-2); }
309
+ .hx-open { flex: 1 1 auto; display: flex; align-items: center; justify-content: center; gap: var(--corn-space-2); min-height: 36px; padding: 0 var(--corn-space-4); border-radius: var(--corn-radius-sm); background: var(--corn-accent); color: var(--corn-text-on-accent); font-size: var(--corn-text-sm); font-weight: 600; text-align: center; text-decoration: none; transition: background 0.15s; }
317
310
  .hx-open:hover { background: var(--corn-accent-hover); }
318
- .hx-open:not([href]) { background: var(--corn-surface-2); color: var(--corn-text-3); }
319
311
 
320
312
  /* ---- proposals (proposal.js): picker, bar, marks, panel rows ----------------------------------- */
321
313
  .hx-btn--proposal { border-color: color-mix(in srgb, var(--corn-added) 35%, transparent); color: var(--corn-added-text); }
@@ -577,9 +569,7 @@ button.hx-proposal-item:focus-visible { outline: var(--corn-focus-width) solid v
577
569
  .hx-drawer { max-height: 60dvh; }
578
570
  .hx-drawer[data-sheet-state="peek"] .hx-drawer-body { flex: none; padding: 0 var(--corn-space-5) var(--corn-space-3); gap: 0; overflow: hidden; }
579
571
  .hx-drawer[data-sheet-state="peek"] .hx-drawer-body > :not(.hx-drawer-head), .hx-drawer[data-sheet-state="peek"] .hx-drawer-foot { display: none; }
580
- .hx-drawer[data-sheet-state="peek"] .hx-drawer-head { padding-bottom: 0; border-bottom: 0; }
581
572
  .hx-drawer[data-sheet-state="peek"] .hx-drawer-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
582
- .hx-drawer[data-sheet-state="peek"] .hx-drawer-title-wrap { flex: 1; }
583
573
  }
584
574
 
585
575
  @media (prefers-reduced-motion: reduce) {
@@ -831,7 +821,7 @@ a.hx-forge-row:hover, button.hx-forge-row:hover { background: var(--corn-surface
831
821
  .hx-forge-runs { display: flex; flex-direction: column; gap: var(--corn-space-2); margin: var(--corn-space-1) 0 var(--corn-space-3); }
832
822
  .hx-forge-runs[hidden] { display: none; }
833
823
 
834
- /* Threads (forge-panel.js, docs/threads.md): messages as written, read-only; a node's "Mentioned in" opens one */
824
+ /* Threads (forge-panel.js, docs/threads.md): messages as written, read-only; a node's "Threads" opens one */
835
825
  .hx-thread-msgs { display: flex; flex-direction: column; gap: var(--corn-space-3); margin: 0; padding: 0; list-style: none; }
836
826
  .hx-thread-msg { display: flex; flex-direction: column; gap: var(--corn-space-1); padding: var(--corn-space-3) var(--corn-space-3); border: var(--corn-border) solid var(--corn-line); border-radius: var(--corn-radius); background: var(--corn-surface-2); }
837
827
  .hx-thread-body { margin: 0; color: var(--corn-text); line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; user-select: text; }
@@ -885,3 +875,58 @@ a.hx-forge-row:hover, button.hx-forge-row:hover { background: var(--corn-surface
885
875
 
886
876
  /* theme.pixelated (docs/config.md#theme): small pixel-art images are sampled without smoothing, in the page as on the map (map-style.js) */
887
877
  :root[data-pixelated] img { image-rendering: pixelated; }
878
+
879
+ /* ---- the node panel (panels.js, #138): type · name · one line · facts · mockups · threads · the diff · the actions ------------ */
880
+ .hx-drawer-id { flex: 1; min-width: 0; }
881
+ .hx-kicker { display: flex; flex-wrap: wrap; align-items: center; margin: 0 0 var(--corn-space-2); font-size: var(--corn-text-sm); color: var(--corn-text-3); }
882
+ .hx-diffpill { margin-left: var(--corn-space-3); padding: 0 var(--corn-space-3); border-radius: var(--corn-radius-pill); border: var(--corn-border) dashed var(--corn-added); color: var(--corn-added-text); font-size: var(--corn-text-xs); }
883
+ .hx-drawer-id .hx-drawer-title { font-size: var(--corn-text-xl); font-weight: 650; letter-spacing: -0.01em; line-height: 1.25; }
884
+ .hx-drawer-id .hx-drawer-title.hx-mono { font-family: var(--corn-mono); }
885
+ .hx-facts { display: flex; flex-direction: column; gap: var(--corn-space-2); }
886
+ .hx-fact { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: var(--corn-space-4); }
887
+ .hx-fact-k { color: var(--corn-text-3); }
888
+ .hx-fact-v { min-width: 0; color: var(--corn-text); }
889
+ .hx-fact-v .hx-line { padding: 0; }
890
+ .hx-fact-v .hx-name { color: var(--corn-text); }
891
+ .hx-fact-v .hx-code { color: var(--corn-text-2); font-size: var(--corn-text-sm); }
892
+ .hx-fact-v .hx-chips { padding-top: 0; }
893
+ .hx-sec-block { display: flex; flex-direction: column; gap: var(--corn-space-3); }
894
+ .hx-sec-title { margin: 0; font-size: var(--corn-text-sm); font-weight: 600; color: var(--corn-text-3); }
895
+ .hx-drawer .hx-mockups { margin: 0; padding: 0; border: 0; }
896
+ .hx-rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--corn-space-2); }
897
+ .hx-row { display: flex; align-items: center; gap: var(--corn-space-4); width: 100%; min-height: 36px; padding: var(--corn-space-3) var(--corn-space-4); border: var(--corn-border) solid var(--corn-line); border-radius: var(--corn-radius-sm); background: var(--corn-surface-2); color: var(--corn-text); font: inherit; text-align: left; }
898
+ .hx-row:hover { background: var(--corn-accent-soft); }
899
+ .hx-row:focus-visible { outline: var(--corn-focus-width) solid var(--corn-focus); outline-offset: 2px; }
900
+ .hx-row-title { flex: 1; min-width: 0; overflow-wrap: anywhere; }
901
+ .hx-row-meta { flex: none; font-size: var(--corn-text-sm); color: var(--corn-text-3); font-variant-numeric: tabular-nums; }
902
+ .hx-drawer .hx-mockup-list { margin: var(--corn-space-3) 0 0; }
903
+ .hx-drawer .hx-mockup-item { flex-wrap: nowrap; gap: var(--corn-space-4); padding: var(--corn-space-1) var(--corn-space-1) var(--corn-space-1) 0; border: var(--corn-border) solid var(--corn-line); border-radius: var(--corn-radius-sm); background: var(--corn-surface-2); }
904
+ .hx-drawer .hx-mockup-open { flex: 1; min-width: 0; min-height: 36px; border: 0; background: none; color: var(--corn-text); font-weight: 400; }
905
+ .hx-drawer .hx-mockup-state { flex: none; padding-right: var(--corn-space-3); color: var(--corn-text-3); }
906
+ .hx-drawer .hx-mockup-state--approved { color: var(--corn-added-text); }
907
+ .hx-drawer .hx-mockup-state--changed { color: var(--corn-warn); }
908
+ .hx-drawer .hx-mockup-state--missing { color: var(--corn-bad); }
909
+ .hx-textact { align-self: flex-start; background: none; border: 0; padding-left: 0; }
910
+ .hx-diff { display: grid; grid-template-columns: 70px minmax(0, 1fr); gap: var(--corn-space-1) var(--corn-space-4); padding: var(--corn-space-1) 0 var(--corn-space-1) var(--corn-space-4); border-left: var(--corn-border-strong) solid var(--corn-changed); font-family: var(--corn-mono); font-size: var(--corn-text-sm); color: var(--corn-text-2); }
911
+ .hx-diff--added { border-left-color: var(--corn-added); }
912
+ .hx-diff--removed { border-left-color: var(--corn-removed); }
913
+ .hx-diff--edit { border-left-color: var(--corn-edit); }
914
+ .hx-diff-k { color: var(--corn-text-3); }
915
+ .hx-diff-v { min-width: 0; overflow-wrap: anywhere; }
916
+ .hx-drawer .hx-why { margin: 0; }
917
+ .hx-drawer-foot .hx-open[hidden], .hx-drawer-foot .hx-foot-btn[hidden] { display: none; }
918
+ .hx-foot-btn { min-height: 36px; padding: 0 var(--corn-space-4); justify-content: center; }
919
+ @media (max-width: 767px) {
920
+ /* a phone: the sheet's actions are full width at the foot, each a 44px target */
921
+ .hx-drawer-foot { flex-direction: column; }
922
+ .hx-drawer-foot .hx-open, .hx-foot-btn { min-height: 44px; }
923
+ .hx-drawer .hx-row, .hx-drawer .hx-mockup-open, .hx-textact { min-height: 44px; }
924
+ .hx-drawer .hx-close { width: 44px; height: 44px; }
925
+ }
926
+ .hx-drawer .hx-whatif-drawer { font-size: var(--corn-text-md); color: var(--corn-text-2); }
927
+ .hx-drawer .hx-whatif-drawer select { max-width: 100%; }
928
+ .hx-drawer-foot .hx-btn--quiet { border-color: transparent; background: none; }
929
+ .hx-more { display: contents; }
930
+ .hx-more[hidden] { display: none; }
931
+ .hx-more-btn { display: block; margin-top: var(--corn-space-1); min-height: 0; padding: 0; font-size: var(--corn-text-sm); }
932
+ @media (max-width: 767px) { .hx-more-btn { min-height: 44px; } }
package/explorer/flows.js CHANGED
@@ -14,6 +14,7 @@
14
14
 
15
15
  import { state, nameOf, escHtml } from './state.js';
16
16
  import { themed } from './theme-model.js';
17
+ import { capped } from './capped.js';
17
18
 
18
19
  export const FLOW_STYLES = {
19
20
  outbox: { color: '#f59e0b', label: 'Outbox → API (writes)' },
@@ -148,11 +149,8 @@ export function renderFlowLegend() {
148
149
 
149
150
  export function flowSummary(node) {
150
151
  const flows = state.edges.filter((e) => e.kind === 'flow' && (e.from === node.id || e.to === node.id));
151
- if (flows.length === 0) return '';
152
- return `<div class="hx-sec" data-corn="section"><strong class="hx-strong">Data flows:</strong>
153
- ${flows.map((e) => {
154
- const out = e.from === node.id;
155
- const s = FLOW_STYLES[e.flow] || FLOW_STYLES.sync;
156
- return `<div class="hx-line"><span class="hx-glyph" style="--glyph:${s.color}">${out ? '→' : '←'}</span><span><span class="hx-name">${escHtml(nameOf(out ? e.to : e.from))}</span> · ${escHtml(e.label)}${e.status === 'live' ? '' : ' <span class="hx-warn">(proposed)</span>'}</span></div>`;
157
- }).join('')}</div>`;
152
+ const fact = (key, list, out) => (list.length
153
+ ? `<div class="hx-fact" data-corn="section"><div class="hx-fact-k">${key}</div><div class="hx-fact-v">${capped(list.map((e) => `<div class="hx-line"><span><span class="hx-name">${escHtml(nameOf(out ? e.to : e.from))}</span> · ${escHtml(e.label)}${e.status === 'live' ? '' : ' <span class="hx-warn">(proposed)</span>'}</span></div>`))}</div></div>`
154
+ : '');
155
+ return fact('Sends to', flows.filter((e) => e.from === node.id), true) + fact('Gets from', flows.filter((e) => e.to === node.id && e.from !== node.id), false);
158
156
  }
@@ -627,7 +627,7 @@ async function afterIdea(res) {
627
627
  const shown = ui.thread === n && ui.threadDetail && ui.threadDetail.thread ? ` ${threadSelectionWords()}` : ui.thread === n && ui.threadError ? ` ${ui.threadError}` : '';
628
628
  // Opened from a node: say that its "Mentioned in" lists the new thread
629
629
  const listed = about && (threadsFor(about.id) || []).some((t) => t.number === n);
630
- announce(`${ui.idea.message}${shown}${listed ? ` It is listed under Mentioned in for ${about.label}.` : ''}${trouble}`);
630
+ announce(`${ui.idea.message}${shown}${listed ? ` It is listed under Threads for ${about.label}.` : ''}${trouble}`);
631
631
  }
632
632
 
633
633
  /** The New idea bar and form, from `ui.idea`; typed text and the focus are left alone */
@@ -1561,7 +1561,7 @@ function closeAgent({ restoreFocus = true } = {}) {
1561
1561
  el.hidden = true;
1562
1562
  document.removeEventListener('focusin', keepFocusInAgent);
1563
1563
  if (!restoreFocus) return;
1564
- const back = $('forge-panel').querySelector(opener) || $('forge-title');
1564
+ const back = document.querySelector(opener) || $('forge-title'); // the node panel's Start a run is an opener too
1565
1565
  if (back && !back.disabled) back.focus();
1566
1566
  }
1567
1567
 
@@ -1787,10 +1787,13 @@ async function issueNotListed(n) {
1787
1787
  return linkMissing(res.status === 404 ? `There is no issue ${n}.` : errorWords(res.status, res.body));
1788
1788
  }
1789
1789
 
1790
+ /** Whether the Start dialog can open now: the server runs agents and the page has the dialog (the node panel's "Start a run" asks) */
1791
+ export const canStartAgent = () => !!(ui.config && ui.config.agents && agentEl());
1792
+
1790
1793
  /** `?proposal=<slug>&start=1`: the Start dialog on that proposal (the proposal itself is opened by proposal.js) */
1791
- export async function openProposalStart(slug) {
1794
+ export async function openProposalStart(slug, opener = '#forge-title') {
1792
1795
  if (!ui.config || !agentEl()) return false;
1793
- await openAgent(`proposal:${slug}`, '#forge-title');
1796
+ await openAgent(`proposal:${slug}`, opener);
1794
1797
  return !!ui.agent;
1795
1798
  }
1796
1799
 
@@ -321,29 +321,24 @@
321
321
  <aside id="spec-drawer" class="hx-drawer glass" aria-label="Node details" inert data-corn="node-panel">
322
322
  <div class="hx-drawer-body">
323
323
  <div class="hx-drawer-head">
324
- <span class="hx-drawer-title-wrap">
325
- <span id="drawer-badge" class="hx-badge" data-corn="badge">ATOM</span>
324
+ <div class="hx-drawer-id">
325
+ <p class="hx-kicker"><span id="drawer-badge" data-corn="badge">Atom</span><span id="drawer-host"></span><span id="drawer-diff" class="hx-diffpill" hidden></span></p>
326
326
  <h2 id="drawer-title" class="hx-drawer-title">&lt;pop-button&gt;</h2>
327
- </span>
327
+ </div>
328
328
  <button type="button" class="hx-close" data-action="close-drawer" aria-label="Close" data-corn-kind="icon">✕</button>
329
329
  </div>
330
330
 
331
- <p id="drawer-description" class="hx-faint hx-lead"></p>
332
-
333
- <div class="hx-block">
334
- <h3 class="hx-block-title" data-corn-string="propsTitle">Properties &amp; Attributes</h3>
335
- <div id="drawer-props-list" class="hx-props"></div>
336
- </div>
331
+ <p id="drawer-description" class="hx-lead" hidden></p>
337
332
 
338
333
  <div class="hx-block">
339
- <h3 class="hx-block-title" data-corn-string="detailsTitle">Details</h3>
340
334
  <div id="drawer-meta-list" class="hx-meta"></div>
341
335
  </div>
342
336
  </div>
343
337
 
344
338
  <div class="hx-drawer-foot">
345
- <a id="drawer-open-btn" class="hx-open" href="#" target="_blank" rel="noreferrer">Open ↗</a>
346
- <button type="button" class="hx-btn hx-btn--copy" data-action="copy-spec" data-corn-string="copySpec">Copy Spec</button>
339
+ <a id="drawer-open-btn" class="hx-open" href="#" target="_blank" rel="noreferrer" hidden>Open route ↗</a>
340
+ <button type="button" id="drawer-run-btn" class="hx-btn hx-foot-btn" data-action="start-run" data-corn-string="startRun" hidden>Start a run</button>
341
+ <button type="button" class="hx-btn hx-btn--quiet hx-foot-btn" data-action="copy-spec" data-corn-string="copySpec">Copy Spec</button>
347
342
  </div>
348
343
  </aside>
349
344
  </div>
package/explorer/main.js CHANGED
@@ -28,7 +28,7 @@ import { render, resize, zoomBy, fitGraphToViewport, fitPadding, isNodeVisible,
28
28
  import { createRenderer } from './renderer.js';
29
29
  import { clearFreeformPositions, layoutOrbit, loadFreeformPositions } from './layout.js';
30
30
  import { closeLegendMenu, toggleAllLayers, toggleLayer, toggleLegendMenu } from './layers.js';
31
- import { closeDrawer, copySpec, selectNode } from './panels.js';
31
+ import { closeDrawer, copySpec, selectNode, startRun } from './panels.js';
32
32
  import { initScenarioUi, maybeStartDemo, playOutage } from './scenario-ui.js';
33
33
  import { initSheets } from './sheets.js';
34
34
  import { loadTopology, setView, syncViewUi } from './view.js';
@@ -134,6 +134,7 @@ const ACTIONS = {
134
134
  'clear-search': () => handleSearch(''),
135
135
  'close-drawer': () => closeDrawer(),
136
136
  'copy-spec': (el) => copySpec(el),
137
+ 'start-run': () => startRun(),
137
138
  'select-node': (el) => selectNode(nodeById(el.dataset.id)),
138
139
  'play-outage': (el) => playOutage(el.dataset.id), // the cloud panel's Play button (spec 0031 section 8)
139
140
  'retry': () => loadTopology(),
@@ -61,7 +61,7 @@ export function mockupsSectionHtml(items) {
61
61
  <span class="hx-mockup-state hx-mockup-state--${escHtml(m.state)}" data-corn="state-pill"${cornStateAttr(m.state)}>${escHtml(stateWords(m.state))}</span>
62
62
  </li>`).join('');
63
63
  return `<div class="hx-sec hx-mockups" data-mockups data-corn="section">
64
- <strong class="hx-strong" id="hx-mockups-h">${items.length === 1 ? 'Mockup' : 'Mockups'}</strong>
64
+ <h3 class="hx-sec-title" id="hx-mockups-h">${items.length === 1 ? 'Mockup' : 'Mockups'}</h3>
65
65
  <ul class="hx-mockup-list" aria-labelledby="hx-mockups-h">${rows}</ul>
66
66
  </div>`;
67
67
  }
@@ -8,14 +8,16 @@
8
8
 
9
9
  import { state, nodeById, nameOf, escHtml, touchScene } from './state.js';
10
10
  import { render } from './render.js';
11
- import { FLOW_STYLES, flowSummary } from './flows.js';
11
+ import { flowSummary } from './flows.js';
12
12
  import { clearScenario } from './scenario-ui.js';
13
- import { proposalPanelHtml } from './proposal-model.js';
13
+ import { kindOfMark, fieldRows, MARK_WORDS } from './proposal-model.js';
14
14
  import { nodeMockupsHtml } from './mockups-model.js';
15
15
  import { collapseSheet } from './sheets.js';
16
16
  import { liveSection, hydrateLivePhotos } from './live.js';
17
17
  import { cloudPanelHtml } from './cloud-model.js';
18
18
  import { t } from './strings.js';
19
+ import { capped, toggleCapped } from './capped.js';
20
+ import { canStartAgent, openProposalStart } from './forge-panel.js';
19
21
 
20
22
  const $ = (id) => document.getElementById(id);
21
23
 
@@ -24,9 +26,23 @@ const $ = (id) => document.getElementById(id);
24
26
  // ---------------------------------------------------------------------------
25
27
  const code = (s) => `<code class="hx-code">${escHtml(s)}</code>`;
26
28
  const nm = (id) => `<span class="hx-name">${escHtml(nameOf(id))}</span>`;
27
- const line = (color, arrow, body) => `<div class="hx-line"><span class="hx-glyph" style="--glyph:${color}">${arrow}</span><span>${body}</span></div>`;
28
- const section = (title, rows) => (rows.length ? `<div class="hx-sec" data-corn="section"><strong class="hx-strong">${title}</strong>${rows.join('')}</div>` : '');
29
- const varList = (vars) => `<div class="hx-chips">${vars.map((v) => `<code class="hx-var">${escHtml(v)}</code>`).join('')}</div>`;
29
+ const line = (body) => `<div class="hx-line">${body}</div>`;
30
+ /** The words a fact goes by in the panel: short nouns, whatever the longer sentence it was built from */
31
+ const FACT_KEYS = {
32
+ 'Uses design tokens': 'Tokens', 'Loaded by the server per request': 'Loaded by', 'Domains served (Caddyfile → service)': 'Domains', 'Compose file': 'File',
33
+ 'Baked pages': 'Baked', 'Reads tables': 'Reads', 'Writes tables': 'Writes', 'Self-hosted': 'Role', 'Pushes to (webhook)': 'Pushes to',
34
+ 'Calls outside': 'Calls', 'Client modules': 'Modules', 'Data flows': 'Flows',
35
+ };
36
+ const FACT_COUNTED = /^(?:Defines )?\d+ (?:CSS )?(variable|service)\(s\)$/;
37
+ const factKey = (title) => {
38
+ const plain = title.replace(/:$/, '');
39
+ const counted = FACT_COUNTED.exec(plain);
40
+ if (counted) return counted[1] === 'service' ? 'Services' : plain.startsWith('Defines') ? 'Defines' : 'Variables';
41
+ return FACT_KEYS[plain] || plain;
42
+ };
43
+ /** One fact: its name, and what it says. A fact with nothing in it is not shown. */
44
+ const section = (title, rows) => (rows.length ? `<div class="hx-fact" data-corn="section"><div class="hx-fact-k">${escHtml(factKey(title))}</div><div class="hx-fact-v">${capped(rows)}</div></div>` : '');
45
+ const varList = (vars) => `<div class="hx-chips">${capped(vars.map((v) => `<code class="hx-var">${escHtml(v)}</code>`))}</div>`;
30
46
  const edgesOf = (kind, side, id) => state.edges.filter((e) => e.kind === kind && e[side] === id);
31
47
 
32
48
  /** Table <-> page data: which keys a page's render reads, which forms write, what ROM re-bakes */
@@ -35,93 +51,93 @@ function dataSummary(node) {
35
51
  const writes = state.edges.filter((e) => e.kind === 'writes');
36
52
  const usesOut = state.edges.filter((e) => e.kind === 'uses' && e.from === node.id);
37
53
  const extendsOut = state.edges.filter((e) => e.kind === 'extends' && e.from === node.id);
38
- const common = section('Extends:', extendsOut.map((e) => line(FLOW_STYLES.extends.color, '↑', nm(e.to))))
39
- + section('Uses design tokens:', usesOut.map((e) => line(FLOW_STYLES.uses.color, '→', `${nm(e.to)} · ${e.vars.length}${varList(e.vars)}`)))
54
+ const common = section('Extends:', extendsOut.map((e) => line(nm(e.to))))
55
+ + section('Uses design tokens:', usesOut.map((e) => line(`${nm(e.to)} · ${e.vars.length}${varList(e.vars)}`)))
40
56
  + (node.type !== 'token' && node.vars ? section(`Defines ${node.vars.length} CSS variable(s):`, [varList(node.vars)]) : '');
41
57
 
42
58
  if (node.type === 'app') {
43
59
  const served = node.deployed
44
- ? line('#93c5fd', '⇢', `<a class="hx-link" href="${escHtml(node.url)}" target="_blank" rel="noreferrer">${escHtml(node.url)}</a> → ${(node.upstreams || []).map(code).join(' ')}${node.stack ? ` <span class="hx-faint">[${escHtml(node.stack)}]</span>` : ''}`)
45
- : line('#f87171', '✕', 'Not deployed by any stack in this repo');
60
+ ? line(`${/^https?:\/\//.test(node.url) ? `<a class="hx-link" href="${escHtml(node.url)}" target="_blank" rel="noreferrer">${escHtml(node.url)}</a>` : code(node.url)} → ${(node.upstreams || []).map(code).join(' ')}${node.stack ? ` <span class="hx-faint">[${escHtml(node.stack)}]</span>` : ''}`)
61
+ : line('Not deployed by any stack in this repo');
46
62
  const runsOn = state.edges.filter((e) => e.kind === 'runs-on' && e.from === node.id)
47
- .map((e) => line(FLOW_STYLES['runs-on'].color, '⇢', `${nm(e.to)}${(e.mappings || []).map((m) => `<div class="hx-faint">${code(m.host)} → ${code(m.upstream)}${m.service ? ` = ${code(m.service)}` : ''}</div>`).join('')}`));
63
+ .map((e) => line(`${nm(e.to)}${(e.mappings || []).map((m) => `<div class="hx-faint">${code(m.host)} → ${code(m.upstream)}${m.service ? ` = ${code(m.service)}` : ''}</div>`).join('')}`));
48
64
  return section('Served:', [served])
49
65
  + section('Runs on:', runsOn)
50
- + section('Loaded by the server per request:', reads.filter((e) => e.to === node.id).map((e) => line(FLOW_STYLES.reads.color, '←', nm(e.from))))
66
+ + section('Loaded by the server per request:', reads.filter((e) => e.to === node.id).map((e) => line(nm(e.from))))
51
67
  + common;
52
68
  }
53
69
  if (node.type === 'token') {
54
70
  const users = state.edges.filter((e) => e.kind === 'uses' && e.to === node.id);
55
71
  return section(`${node.vars.length} variable(s):`, [varList(node.vars)])
56
- + section('Used by:', users.map((e) => line(FLOW_STYLES.uses.color, '←', `${nm(e.from)} · ${escHtml(e.vars.join(' '))}`)));
72
+ + section('Used by:', users.map((e) => line(`${nm(e.from)} · ${escHtml(e.vars.join(' '))}`)));
57
73
  }
58
74
  if (['atom', 'molecule', 'core'].includes(node.type)) {
59
- const pages = state.edges.filter((e) => e.dashed && e.to === node.id).map((e) => line('#818cf8', '←', nm(e.from)));
60
- return (node.table ? section('Record of:', [line(FLOW_STYLES.reads.color, '◆', `${escHtml(node.model)} · table ${code(node.table)}`)]) : '')
75
+ const pages = state.edges.filter((e) => e.dashed && e.to === node.id).map((e) => line(nm(e.from)));
76
+ return (node.table ? section('Record of:', [line(`${escHtml(node.model)} · table ${code(node.table)}`)]) : '')
61
77
  + section('Rendered by:', pages) + common;
62
78
  }
63
79
  if (node.type === 'stack') {
64
80
  const served = state.edges.filter((e) => e.kind === 'runs-on' && e.to === node.id);
65
- return section('Domains served (Caddyfile → service):', served.flatMap((e) => (e.mappings || []).map((m) => line(FLOW_STYLES['runs-on'].color, '←', `<span class="hx-name">${escHtml(m.host)}</span> → ${code(m.upstream)}${m.service ? ` = ${code(m.service)}` : ''}`))))
66
- + section(`${(node.services || []).length} service(s):`, (node.services || []).map((s) => line('#a8a29e', '▣', `<span class="hx-name">${escHtml(s.name)}</span>${s.image ? ` <span class="hx-faint">${escHtml(s.image)}</span>` : ''}${s.ports.length ? `<div>${s.ports.map(code).join(' ')}</div>` : ''}${s.volumes.length ? `<div class="hx-faint">${s.volumes.map(escHtml).join('<br>')}</div>` : ''}`)))
67
- + section('Compose file:', [line('#93c5fd', '📄', code(node.file))]);
81
+ return section('Domains served (Caddyfile → service):', served.flatMap((e) => (e.mappings || []).map((m) => line(`<span class="hx-name">${escHtml(m.host)}</span> → ${code(m.upstream)}${m.service ? ` = ${code(m.service)}` : ''}`))))
82
+ + section(`${(node.services || []).length} service(s):`, (node.services || []).map((s) => line(`<span class="hx-name">${escHtml(s.name)}</span>${s.image ? ` <span class="hx-faint">${escHtml(s.image)}</span>` : ''}${s.ports.length ? `<div>${s.ports.map(code).join(' ')}</div>` : ''}${s.volumes.length ? `<div class="hx-faint">${s.volumes.map(escHtml).join('<br>')}</div>` : ''}`)))
83
+ + section('Compose file:', [line(code(node.file))]);
68
84
  }
69
85
  if (node.type === 'table') {
70
86
  const readers = reads.filter((e) => e.from === node.id);
71
87
  const writers = writes.filter((e) => e.to === node.id);
72
88
  const baked = readers.filter((e) => (nodeById(e.to) || {}).render?.rom === 'bake');
73
- return (node.model ? section('Model:', [line(FLOW_STYLES.reads.color, '◆', escHtml(node.model))]) : '')
74
- + section('Read by:', readers.map((e) => line(FLOW_STYLES.reads.color, '→', `${nm(e.to)} · ${e.keys.map(code).join(' ')}`)))
75
- + section('Written by:', writers.map((e) => line(FLOW_STYLES.writes.color, '←', `${nm(e.from)} · ${escHtml(e.label)}`)))
76
- + (baked.length ? section('Baked pages:', [line(FLOW_STYLES.rom.color, '♻', `a write here re-bakes <span class="hx-rom hx-bold">${baked.length}</span> file(s): ${baked.map((e) => escHtml(nameOf(e.to))).join(', ')}`)]) : '');
89
+ return (node.model ? section('Model:', [line(escHtml(node.model))]) : '')
90
+ + section('Read by:', readers.map((e) => line(`${nm(e.to)} · ${e.keys.map(code).join(' ')}`)))
91
+ + section('Written by:', writers.map((e) => line(`${nm(e.from)} · ${escHtml(e.label)}`)))
92
+ + (baked.length ? section('Baked pages:', [line(`a write here re-bakes <span class="hx-rom hx-bold">${baked.length}</span> file(s): ${baked.map((e) => escHtml(nameOf(e.to))).join(', ')}`)]) : '');
77
93
  }
78
94
  if (node.type === 'service') {
79
95
  const row = (e, side) => `${nm(e[side])}${e.label && e.label !== 'imports' ? ` · ${escHtml(e.label)}` : ''}`;
80
- return section('Kind:', [line(FLOW_STYLES.triggers.color, '◆', `${code(node.kind)}${node.summary ? `<div class="hx-faint">${escHtml(node.summary)}</div>` : ''}`)])
81
- + section('Started by:', [...(node.triggers || []).map((t) => line(FLOW_STYLES.triggers.color, '⏱', escHtml(t))), ...edgesOf('triggers', 'to', node.id).map((e) => line(FLOW_STYLES.triggers.color, '←', row(e, 'from')))])
82
- + section('Jobs:', (node.jobs || []).map((j) => line(FLOW_STYLES.triggers.color, '↻', `${code(j.name)} · cron ${code(j.cron)}`)))
83
- + section('Runs:', edgesOf('triggers', 'from', node.id).map((e) => line(FLOW_STYLES.triggers.color, '→', row(e, 'to'))))
84
- + section('Calls:', edgesOf('calls', 'from', node.id).map((e) => line(FLOW_STYLES.calls.color, '→', row(e, 'to'))))
85
- + section('Called by:', edgesOf('calls', 'to', node.id).map((e) => line(FLOW_STYLES.calls.color, '←', row(e, 'from'))))
86
- + section('Reads tables:', reads.filter((e) => e.to === node.id).map((e) => line(FLOW_STYLES.reads.color, '←', nm(e.from))))
87
- + section('Writes tables:', writes.filter((e) => e.from === node.id).map((e) => line(FLOW_STYLES.writes.color, '→', nm(e.to))))
88
- + section('Mechanisms:', (node.mechanisms || []).map((m) => line('#93c5fd', '◆', escHtml(m))));
96
+ return section('Kind:', [line(`${code(node.kind)}${node.summary ? `<div class="hx-faint">${escHtml(node.summary)}</div>` : ''}`)])
97
+ + section('Started by:', [...(node.triggers || []).map((t) => line(escHtml(t))), ...edgesOf('triggers', 'to', node.id).map((e) => line(row(e, 'from')))])
98
+ + section('Jobs:', (node.jobs || []).map((j) => line(`${code(j.name)} · cron ${code(j.cron)}`)))
99
+ + section('Runs:', edgesOf('triggers', 'from', node.id).map((e) => line(row(e, 'to'))))
100
+ + section('Calls:', edgesOf('calls', 'from', node.id).map((e) => line(row(e, 'to'))))
101
+ + section('Called by:', edgesOf('calls', 'to', node.id).map((e) => line(row(e, 'from'))))
102
+ + section('Reads tables:', reads.filter((e) => e.to === node.id).map((e) => line(nm(e.from))))
103
+ + section('Writes tables:', writes.filter((e) => e.from === node.id).map((e) => line(nm(e.to))))
104
+ + section('Mechanisms:', (node.mechanisms || []).map((m) => line(escHtml(m))));
89
105
  }
90
106
  if (node.type === 'container' && node.selfHosted) {
91
107
  // A self-hosted service is the container that runs it (spec 0031 section 3): what the API uses it for, who calls it, its webhook
92
108
  const row = (e, side) => `${nm(e[side])}${e.label && e.label !== 'calls' ? ` · ${escHtml(e.label)}` : ''}`;
93
109
  const into = state.edges.filter((e) => e.to === node.id && (e.kind === 'calls' || (e.kind === 'flow' && e.flow === 'api')));
94
- const calledBy = (type) => into.filter((e) => nodeById(e.from)?.type === type).map((e) => line(FLOW_STYLES.calls.color, '←', row(e, 'from')));
110
+ const calledBy = (type) => into.filter((e) => nodeById(e.from)?.type === type).map((e) => line(row(e, 'from')));
95
111
  const stackmates = new Set(state.nodes.filter((n) => n.type === 'container' && n.stack === node.stack).map((n) => n.id));
96
- return section('Self-hosted:', [line(FLOW_STYLES.calls.color, '◆', escHtml(node.summary || ''))])
112
+ return section('Self-hosted:', [line(escHtml(node.summary || ''))])
97
113
  + section('Called by services:', calledBy('service'))
98
114
  + section('Called by endpoints:', calledBy('page'))
99
115
  + section('Called by apps:', calledBy('app'))
100
- + section('Pushes to (webhook):', state.edges.filter((e) => e.kind === 'delivers' && stackmates.has(e.from) && nodeById(e.to)?.type === 'page').map((e) => line(FLOW_STYLES.delivers.color, '→', `${nm(e.to)}${e.from === node.id ? '' : ` <span class="hx-faint">from ${escHtml(nameOf(e.from))}</span>`}`)));
116
+ + section('Pushes to (webhook):', state.edges.filter((e) => e.kind === 'delivers' && stackmates.has(e.from) && nodeById(e.to)?.type === 'page').map((e) => line(`${nm(e.to)}${e.from === node.id ? '' : ` <span class="hx-faint">from ${escHtml(nameOf(e.from))}</span>`}`)));
101
117
  }
102
118
  if (node.type === 'external' && node.kind) { // a cloud node or the public web (spec 0031 section 6)
103
119
  return cloudPanelHtml(node, state.nodes, state.edges); // its File line is the registry
104
120
  }
105
121
  if (node.type === 'external') {
106
122
  const calledBy = (type) => edgesOf('calls', 'to', node.id).filter((e) => nodeById(e.from)?.type === type);
107
- return section('System:', [line(FLOW_STYLES.calls.color, '◆', `${escHtml(node.summary || '')}${node.host ? `<div class="hx-faint">Runs here as ${code(node.host)}</div>` : '<div class="hx-faint">Not run by this stack</div>'}`)])
108
- + section('Client modules:', (node.modules || []).map((m) => line('#fbbf24', 'ƒ', code(m))))
109
- + section('Called by services:', calledBy('service').map((e) => line(FLOW_STYLES.calls.color, '←', nm(e.from))))
110
- + section('Called by endpoints:', calledBy('page').map((e) => line(FLOW_STYLES.calls.color, '←', nm(e.from))))
111
- + section('Pushes to (webhook):', edgesOf('delivers', 'from', node.id).map((e) => line(FLOW_STYLES.delivers.color, '→', nm(e.to))));
123
+ return section('System:', [line(`${escHtml(node.summary || '')}${node.host ? `<div class="hx-faint">Runs here as ${code(node.host)}</div>` : '<div class="hx-faint">Not run by this stack</div>'}`)])
124
+ + section('Client modules:', (node.modules || []).map((m) => line(code(m))))
125
+ + section('Called by services:', calledBy('service').map((e) => line(nm(e.from))))
126
+ + section('Called by endpoints:', calledBy('page').map((e) => line(nm(e.from))))
127
+ + section('Pushes to (webhook):', edgesOf('delivers', 'from', node.id).map((e) => line(nm(e.to))));
112
128
  }
113
129
  if (node.type === 'page') {
114
130
  const r = node.render;
115
- const components = state.edges.filter((e) => e.dashed && e.from === node.id).map((e) => line('#818cf8', '→', nm(e.to)));
116
- return (node.methods ? section('Methods:', [line('#93c5fd', '⇢', node.methods.map(code).join(' '))]) : '')
117
- + (node.render_fn ? section('Rendered by:', [line('#93c5fd', 'ƒ', `${code(node.render_fn)} · ${escHtml(node.file)}`)]) : '')
118
- + section('Calls outside:', edgesOf('calls', 'from', node.id).map((e) => line(FLOW_STYLES.calls.color, '→', nm(e.to))))
119
- + section('Pushed to by:', edgesOf('delivers', 'to', node.id).map((e) => line(FLOW_STYLES.delivers.color, '←', `${nm(e.from)} · ${escHtml(e.label)}`)))
120
- + section('Starts:', edgesOf('triggers', 'from', node.id).map((e) => line(FLOW_STYLES.triggers.color, '→', `${nm(e.to)} · ${escHtml(e.label)}`)))
131
+ const components = state.edges.filter((e) => e.dashed && e.from === node.id).map((e) => line(nm(e.to)));
132
+ return (node.methods ? section('Methods:', [line(node.methods.map(code).join(' '))]) : '')
133
+ + (node.render_fn ? section('Rendered by:', [line(`${code(node.render_fn)} · ${escHtml(node.file)}`)]) : '')
134
+ + section('Calls outside:', edgesOf('calls', 'from', node.id).map((e) => line(nm(e.to))))
135
+ + section('Pushed to by:', edgesOf('delivers', 'to', node.id).map((e) => line(`${nm(e.from)} · ${escHtml(e.label)}`)))
136
+ + section('Starts:', edgesOf('triggers', 'from', node.id).map((e) => line(`${nm(e.to)} · ${escHtml(e.label)}`)))
121
137
  + section('Renders:', components)
122
- + section('Reads:', reads.filter((e) => e.to === node.id).map((e) => line(FLOW_STYLES.reads.color, '←', `${nm(e.from)} · ${e.keys.map(code).join(' ')}`)))
123
- + section('Writes:', writes.filter((e) => e.from === node.id).map((e) => line(FLOW_STYLES.writes.color, '→', `${nm(e.to)} · ${escHtml(e.label)}`)))
124
- + (r ? section('Render:', [line(FLOW_STYLES.rom.color, '◆', `today: ${code(r.now)} · ROM: ${r.rom === 'bake' ? '<span class="hx-rom hx-bold">bake</span>' : '<span class="hx-faint">skip (per request)</span>'}${r.note ? `<div class="hx-faint">${escHtml(r.note)}</div>` : ''}`)]) : '');
138
+ + section('Reads:', reads.filter((e) => e.to === node.id).map((e) => line(`${nm(e.from)} · ${e.keys.map(code).join(' ')}`)))
139
+ + section('Writes:', writes.filter((e) => e.from === node.id).map((e) => line(`${nm(e.to)} · ${escHtml(e.label)}`)))
140
+ + (r ? section('Render:', [line(`today: ${code(r.now)} · ROM: ${r.rom === 'bake' ? '<span class="hx-rom hx-bold">bake</span>' : '<span class="hx-faint">skip (per request)</span>'}${r.note ? `<div class="hx-faint">${escHtml(r.note)}</div>` : ''}`)]) : '');
125
141
  }
126
142
  return '';
127
143
  }
@@ -130,25 +146,71 @@ function dataSummary(node) {
130
146
  // Threads that mention the node
131
147
  // ---------------------------------------------------------------------------
132
148
 
133
- /** "Mentioned in": the threads whose text names the node (an idea, or a spec PR's conversation); each opens in the issues and PRs panel */
149
+ /** "Threads": the threads whose text names the node (an idea, or a spec PR's conversation); each opens in the Work panel */
134
150
  function threadsSection(node) {
135
151
  const index = state.threadIndex;
136
152
  if (!index) return '';
137
153
  const threads = index.for(node.id);
138
154
  // "Start a thread about this" shows whenever threads are on and a maintainer is signed in (the panel only sets `start` then)
139
- const start = index.start ? `<div class="hx-line"><button type="button" class="hx-btn" data-thread-start="${escHtml(node.id)}" aria-label="Start a thread about this: opens the New idea form for ${escHtml(index.forge())}, with this node mentioned">Start a thread about this</button></div>` : '';
155
+ const start = index.start ? `<button type="button" class="hx-btn hx-btn--quiet hx-textact" data-thread-start="${escHtml(node.id)}" aria-label="Start a thread about this: opens the New idea form for ${escHtml(index.forge())}, with this node mentioned">Start a thread about this</button>` : '';
140
156
  if (!threads || !threads.length) return start;
141
- const rows = threads.map((t) => `<div class="hx-line"><span class="hx-glyph" style="--glyph:#fbbf24">◆</span><span><button type="button" class="hx-btn hx-thread-open" data-thread-open="${t.number}" aria-label="Open thread #${t.number}, ${escHtml(t.title)}, in the issues and pull requests panel">#${t.number} ${escHtml(t.title)}</button> <span class="hx-faint">${t.kind === 'proposal' ? 'proposal' : 'idea'}</span></span></div>`);
142
- return section(`Mentioned in ${threads.length} ${threads.length === 1 ? 'thread' : 'threads'}:`, rows) + start;
157
+ const rows = threads.map((th) => {
158
+ const count = Number(th.comments) || 0;
159
+ return `<li><button type="button" class="hx-row hx-thread-open" data-thread-open="${escHtml(th.number)}" data-corn="row" aria-label="Open thread #${escHtml(th.number)}, ${escHtml(th.title)}, ${count} ${count === 1 ? 'comment' : 'comments'}, in the issues and pull requests panel"><span class="hx-row-title">${escHtml(th.title)}</span><span class="hx-row-meta">#${escHtml(th.number)} · ${count}</span></button></li>`;
160
+ });
161
+ return `<div class="hx-sec-block" data-corn="section"><h3 class="hx-sec-title">Threads</h3><ul class="hx-rows">${rows.join('')}</ul>${start}</div>`;
143
162
  }
144
163
 
145
- /** Draws "Mentioned in" again in the open panel (the list was just read, or the map changed); nothing else in the panel moves */
164
+ /** Draws "Threads" again in the open panel (the list was just read, or the map changed); nothing else in the panel moves */
146
165
  export function repaintThreads() {
147
166
  const box = $('drawer-threads');
148
167
  if (!box || !state.selectedNode) return;
149
168
  box.innerHTML = threadsSection(state.selectedNode);
150
169
  }
151
170
 
171
+ // ---------------------------------------------------------------------------
172
+ // The head: type · host, and what the open proposal does to the node
173
+ // ---------------------------------------------------------------------------
174
+
175
+ /** "Page", "Cloud", "Public web": the kind of node, in words */
176
+ function typeWords(node) {
177
+ if (node.type === 'external' && node.kind) return node.kind === 'web' ? 'Public web' : 'Cloud';
178
+ return node.type.charAt(0).toUpperCase() + node.type.slice(1);
179
+ }
180
+
181
+ /** The host a node answers on, when it has one */
182
+ function hostOf(node) {
183
+ if (node.url) { try { return new URL(node.url).host; } catch { /* not a URL: no host */ } }
184
+ return node.host || '';
185
+ }
186
+
187
+ /** "Added by Checkout": the pill for a node the open proposal touches; '' for one it leaves alone */
188
+ export function diffPillWords(node) {
189
+ const mark = node && node.mark;
190
+ if (!mark || mark === 'none') return '';
191
+ if (mark === 'edit') return `${node.editOp === 'removed' ? 'Removed' : 'Added'} by your edit`;
192
+ const title = state.proposal && typeof state.proposal.title === 'string' ? state.proposal.title : '';
193
+ return title ? `${MARK_WORDS[mark] || mark} by ${title}` : `${MARK_WORDS[mark] || mark} by this proposal`;
194
+ }
195
+
196
+ /** "In this proposal": the diff for a changed node as key/value rows (id, parent, edges +2; a change shows each field before and after) */
197
+ function diffSection(node) {
198
+ const kind = kindOfMark(node);
199
+ if (!diffPillWords(node)) return '';
200
+ const row = (k, v) => `<div class="hx-diff-k">${escHtml(k)}</div><div class="hx-diff-v">${v}</div>`;
201
+ const rows = [row('id', escHtml(node.id))];
202
+ const parent = state.edges.find((e) => !e.kind && !e.dashed && e.to === node.id);
203
+ if (parent) rows.push(row('parent', escHtml(parent.from)));
204
+ const touching = state.edges.filter((e) => e.from === node.id || e.to === node.id);
205
+ const added = touching.filter((e) => kindOfMark(e) === 'added').length;
206
+ const removed = touching.filter((e) => kindOfMark(e) === 'removed').length;
207
+ if (added || removed) rows.push(row('edges', escHtml([added ? `+${added}` : '', removed ? `−${removed}` : ''].filter(Boolean).join(' '))));
208
+ if (kind === 'changed') {
209
+ for (const r of fieldRows(node)) rows.push(row(r.field, `<span class="hx-change-before">${escHtml(r.before) || '<em>nothing</em>'}</span> <span aria-hidden="true">→</span><span class="hx-sr-only"> became </span> <span class="hx-change-after">${escHtml(r.after) || '<em>nothing</em>'}</span>`));
210
+ }
211
+ return `<div class="hx-sec-block" data-proposal-mark="${escHtml(node.mark)}" data-corn="section"><h3 class="hx-sec-title">In this proposal</h3>${node.why ? `<p class="hx-why">${escHtml(node.why)}</p>` : ''}<div class="hx-diff hx-diff--${escHtml(kind)}">${rows.join('')}</div></div>`;
212
+ }
213
+
152
214
  // ---------------------------------------------------------------------------
153
215
  // The drawer
154
216
  // ---------------------------------------------------------------------------
@@ -164,58 +226,55 @@ export async function selectNode(node) {
164
226
  touchScene();
165
227
  render();
166
228
 
167
- const propsList = $('drawer-props-list');
168
229
  const metaList = $('drawer-meta-list');
230
+ if (!metaList.dataset.moreBound) { metaList.dataset.moreBound = '1'; metaList.addEventListener('click', (e) => { toggleCapped(e.target); }); }
169
231
  const openBtn = $('drawer-open-btn');
232
+ const title = $('drawer-title');
170
233
 
171
- $('drawer-title').textContent = node.tag ? `<${node.tag}>` : node.label;
172
- $('drawer-badge').textContent = node.type === 'external' && node.kind ? (node.kind === 'web' ? 'PUBLIC WEB' : 'CLOUD') : node.type.toUpperCase();
173
- $('drawer-description').textContent = node.desc || '';
234
+ title.textContent = node.tag ? `<${node.tag}>` : node.label;
235
+ title.classList.toggle('hx-mono', node.type === 'page' || !!node.tag); // a route or a tag reads as code
236
+ $('drawer-badge').textContent = typeWords(node);
237
+ const host = hostOf(node);
238
+ $('drawer-host').textContent = host ? ` · ${host}` : '';
239
+ const pill = diffPillWords(node);
240
+ $('drawer-diff').textContent = pill;
241
+ $('drawer-diff').hidden = !pill;
242
+ const lead = $('drawer-description');
243
+ lead.textContent = node.desc || '';
244
+ lead.hidden = !node.desc;
174
245
  if (token !== selectToken) return;
175
246
 
176
- propsList.innerHTML = `
177
- <div class="hx-prop">
178
- <div class="hx-prop-head">
179
- <span class="hx-accent hx-bold">Node Degree</span>
180
- <span class="hx-good hx-bold">${node.degree || 0} edges</span>
181
- </div>
182
- <div class="hx-faint">Radius: ${node.r}px (${node.scaleDelta > 0 ? '+' : ''}${(node.scaleDelta || 0).toFixed(1)}px subtle degree sizing)</div>
183
- </div>`;
184
- metaList.innerHTML = `
185
- <div><strong class="hx-strong">ID:</strong> ${escHtml(node.id)}</div>
186
- <div><strong class="hx-strong">Category:</strong> ${escHtml(node.type)}</div>
187
- <div><strong class="hx-strong">Connected Edges:</strong> <span class="hx-accent hx-bold">${node.degree || 0}</span></div>
188
- ${node.file ? `<div><strong class="hx-strong">File:</strong> <code class="hx-code">${escHtml(node.file)}</code></div>` : ''}
189
- ${flowSummary(node)}
190
- ${dataSummary(node)}`;
247
+ const facts = `${node.file ? section('File', [code(node.file)]) : ''}${flowSummary(node)}${dataSummary(node)}`;
248
+ metaList.innerHTML = `${facts ? `<div class="hx-facts">${facts}</div>` : ''}
249
+ <div id="drawer-live">${liveSection(node)}</div>
250
+ ${nodeMockupsHtml(node.id)}
251
+ <div id="drawer-threads">${threadsSection(node)}</div>
252
+ ${diffSection(node)}`;
253
+ if (state.threadIndex) state.threadIndex.ensure();
254
+ hydrateLivePhotos($('drawer-live'));
255
+
256
+ // The actions: Open (when the node has an address) is the primary one; Start a run, when the open proposal can be handed to an agent
191
257
  if (node.url && /^https?:\/\//.test(node.url)) {
192
258
  openBtn.href = node.url;
193
259
  openBtn.textContent = `${t('openRoute')} ↗`;
260
+ openBtn.hidden = false;
194
261
  } else {
195
262
  openBtn.removeAttribute('href');
196
- openBtn.textContent = 'Internal Workspace Node';
263
+ openBtn.hidden = true;
197
264
  }
198
-
199
- // A node a proposal touches: why, and what changes (before and after), above the rest
200
- const proposed = proposalPanelHtml(node);
201
- if (proposed) metaList.insertAdjacentHTML('afterbegin', proposed);
202
- // The screens the proposal lists for it, which open from here (mockups.js)
203
- const mockups = nodeMockupsHtml(node.id);
204
- if (mockups) (proposed ? metaList.firstElementChild : metaList).insertAdjacentHTML(proposed ? 'afterend' : 'afterbegin', mockups);
205
-
206
- // The threads that mention it (docs/threads.md): filled in place once the list is read
207
- metaList.insertAdjacentHTML('beforeend', `<div id="drawer-threads">${threadsSection(node)}</div>`);
208
- if (state.threadIndex) state.threadIndex.ensure();
209
-
210
- // What the live layer knows of it (spec 0029): a count, a linked machine's item, contents and sets; repainted in place by live.js
211
- metaList.insertAdjacentHTML('beforeend', `<div id="drawer-live">${liveSection(node)}</div>`);
212
- hydrateLivePhotos($('drawer-live'));
265
+ const run = $('drawer-run-btn');
266
+ run.hidden = !(state.proposalSlug && canStartAgent());
213
267
 
214
268
  $('spec-drawer').classList.add('drawer-open');
215
269
  $('spec-drawer').inert = false; // closed, it waits off screen: inert, so Tab never reaches its buttons (MAP-02)
216
270
  $('drawer-backdrop').hidden = false;
217
271
  }
218
272
 
273
+ /** Start a run: the Start dialog of the Work panel, on the proposal that is open */
274
+ export function startRun() {
275
+ if (state.proposalSlug) openProposalStart(state.proposalSlug, '#drawer-run-btn');
276
+ }
277
+
219
278
  export function closeDrawer() {
220
279
  selectToken++;
221
280
  state.selectedEdge = null;
@@ -462,18 +462,23 @@ export function markedEdgeAt(x, y, tolerance) {
462
462
  export function showEdgePanel(edge) {
463
463
  closeDrawer(); // clears a node selection and any panel still loading
464
464
  state.selectedEdge = edge;
465
- const row = (label, value) => (value ? `<div class="hx-prop"><div class="hx-prop-head"><span class="hx-accent hx-bold">${escHtml(label)}</span><span>${escHtml(value)}</span></div></div>` : '');
465
+ const row = (label, value) => (value ? `<div class="hx-fact"><div class="hx-fact-k">${escHtml(label)}</div><div class="hx-fact-v">${escHtml(value)}</div></div>` : '');
466
+ const facts = row('Kind', kindOf(edge)) + row('Flow', edge.flow) + row('Label', edge.label) + row('Reads', Array.isArray(edge.keys) ? edge.keys.join(', ') : '');
466
467
 
467
468
  $('drawer-title').textContent = `${nameOf(edge.from)} → ${nameOf(edge.to)}`;
468
- $('drawer-badge').textContent = 'EDGE';
469
- $('drawer-description').textContent = edge.label || '';
470
- $('drawer-props-list').innerHTML = row('Kind', kindOf(edge)) + row('Flow', edge.flow) + row('Label', edge.label) + row('Reads', Array.isArray(edge.keys) ? edge.keys.join(', ') : '');
471
- $('drawer-meta-list').innerHTML = `${proposalPanelHtml(edge)}
472
- <div><strong class="hx-strong">From:</strong> <button type="button" class="hx-linkbtn" data-action="select-node" data-id="${escHtml(edge.from)}">${escHtml(nameOf(edge.from))}</button></div>
473
- <div><strong class="hx-strong">To:</strong> <button type="button" class="hx-linkbtn" data-action="select-node" data-id="${escHtml(edge.to)}">${escHtml(nameOf(edge.to))}</button></div>`;
474
- const open = $('drawer-open-btn');
475
- open.removeAttribute('href');
476
- open.textContent = 'A link between two nodes';
469
+ $('drawer-title').classList.remove('hx-mono');
470
+ $('drawer-badge').textContent = 'Edge';
471
+ $('drawer-host').textContent = '';
472
+ $('drawer-diff').hidden = true;
473
+ $('drawer-description').textContent = '';
474
+ $('drawer-description').hidden = true;
475
+ $('drawer-meta-list').innerHTML = `${facts ? `<div class="hx-facts">${facts}</div>` : ''}
476
+ <div class="hx-facts">
477
+ <div class="hx-fact"><div class="hx-fact-k">From</div><div class="hx-fact-v"><button type="button" class="hx-linkbtn" data-action="select-node" data-id="${escHtml(edge.from)}">${escHtml(nameOf(edge.from))}</button></div></div>
478
+ <div class="hx-fact"><div class="hx-fact-k">To</div><div class="hx-fact-v"><button type="button" class="hx-linkbtn" data-action="select-node" data-id="${escHtml(edge.to)}">${escHtml(nameOf(edge.to))}</button></div></div>
479
+ </div>${proposalPanelHtml(edge)}`;
480
+ $('drawer-open-btn').hidden = true;
481
+ $('drawer-run-btn').hidden = true;
477
482
  $('spec-drawer').classList.add('drawer-open');
478
483
  $('drawer-backdrop').hidden = false;
479
484
  touchScene();
package/explorer/state.js CHANGED
@@ -128,7 +128,7 @@ export const state = {
128
128
  /**
129
129
  * Which threads mention which nodes (forge-panel.js, docs/threads.md), for a node's panel: `{ for(nodeId) -> thread[] | null,
130
130
  * ensure(), open(number) }`, or null when threads are off or there is no forge. `for` answers null until the list has been
131
- * read; `ensure` reads it (once) and repaints the panel's "Mentioned in"; `open` shows a thread in the issues and PRs panel.
131
+ * read; `ensure` reads it (once) and repaints the panel's "Threads"; `open` shows a thread in the issues and PRs panel.
132
132
  */
133
133
  threadIndex: null,
134
134
 
@@ -82,6 +82,7 @@
82
82
  --corn-text-md: 13px;
83
83
  --corn-text-base: 14px;
84
84
  --corn-text-lg: 15px;
85
+ --corn-text-xl: 20px;
85
86
 
86
87
  /* Shape */
87
88
  --corn-radius-xs: 3px;
@@ -535,7 +535,7 @@ function mountDrawerBox() {
535
535
  drawerBox.id = 'whatif-drawer';
536
536
  drawerBox.className = 'hx-block hx-whatif-drawer';
537
537
  drawerBox.hidden = true;
538
- block.parentElement.insertBefore(drawerBox, block);
538
+ block.after(drawerBox); // under the facts, the mockups and the threads: the node comes first, the tools to edit it after
539
539
  drawerBox.addEventListener('click', onClick);
540
540
  return drawerBox;
541
541
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cornfield",
3
- "version": "0.29.0",
3
+ "version": "0.30.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)",