cornfield 0.37.0 → 0.39.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.
@@ -71,7 +71,7 @@ import { render, isNodeVisible } from './render.js';
71
71
  import { selectNode, repaintThreads } from './panels.js';
72
72
  import { announce, centreOn } from './keyboard.js';
73
73
  import { trapTab } from './focusables.js';
74
- import { isPhone, registerSheet, expandSheet, collapseSheet } from './sheets.js';
74
+ import { isPhone, registerSheet, expandSheet, collapseSheet, showSheet, refreshStubs } from './sheets.js';
75
75
  import { relativeTime } from './review-model.js';
76
76
  import { LAYER_DEFS, toggleLayer } from './layers.js';
77
77
  import { WORK_URL, groupWork, filterGroups, groupWords, workStatus, markWords } from './agents-model.js';
@@ -92,8 +92,11 @@ import { cornStateAttr, markStateAttr, stateIconHtml } from './corn-state.js';
92
92
  import { sayResult, clearResult, resultOf, showResultIn, resetFeedbackForTests } from './feedback.js';
93
93
  import { isOffline, initConnection, notSentWords, resetConnectionForTests } from './connection.js';
94
94
  import { proposalListing, onProposalListing, loadProposalList, hooks as proposalHooks } from './proposal.js';
95
- import { specRowHtml, mergeSpecs } from './proposal-model.js';
95
+ import { mergeSpecs } from './proposal-model.js';
96
96
  import { t } from './strings.js';
97
+ import { waiting, specGroups, workButtonName, waitingWords, runWaitingOn } from './waiting-model.js';
98
+ import { paintWaitingLine, resetWaitingLineForTests } from './waiting-line.js';
99
+ import { specGroupsHtml } from './waiting-view.js';
97
100
 
98
101
  const $ = (id) => document.getElementById(id);
99
102
  const FORGE_NAMES = { github: 'GitHub', forgejo: 'Forgejo' };
@@ -108,6 +111,8 @@ const ui = {
108
111
  filters: defaultFilters(),
109
112
  lists: {}, // `${kind}|${server state}` -> { items, at, rate, stale }
110
113
  work: null, // { grouped, problem, at, rate, stale } of the Agents tab
114
+ specQuery: '', // the Specs tab's search (spec 0010 D5)
115
+ draftsOpen: null, // the Drafts group opened (true) or folded (false) by hand; null: as the model has it (folded past 10 rows)
111
116
  workFilters: { agentsOnly: false, finished: false },
112
117
  loading: false,
113
118
  error: '',
@@ -172,11 +177,15 @@ const forgeName = () => FORGE_NAMES[ui.config && ui.config.forge && ui.config.fo
172
177
  const listKey = () => listKeyOf(ui.kind, ui.filters.state);
173
178
  const current = () => (ui.kind === 'work' ? ui.work : ui.kind === 'specs' ? specsList() : ui.lists[listKey()]) || null;
174
179
  /** The proposals the Proposals menu lists (proposal.js reads them), as a list of the panel's own shape; null before the first answer */
180
+ let merged = { entries: null, items: [] }; // mergeSpecs of the listing last seen: it is asked for many times a paint
175
181
  function specsList() {
176
182
  const { entries, problem, forgeProblem, at } = proposalListing();
177
183
  // One row for a proposal, however many places it is in: its spec PR and the copy in a checkout or a worktree are one (mergeSpecs)
178
- return entries ? { items: mergeSpecs(entries), at: at ? new Date(at).toISOString() : '', rate: '', stale: '', problem: problem || forgeProblem || '' } : null;
184
+ if (entries && merged.entries !== entries) merged = { entries, items: mergeSpecs(entries) };
185
+ return entries ? { items: merged.items, at: at ? new Date(at).toISOString() : '', rate: '', stale: '', problem: problem || forgeProblem || '' } : null;
179
186
  }
187
+ /** What waits on the maintainer now (spec 0010 D1): the specs to decide and the runs that wait on an answer, from what has been read */
188
+ const waitingNow = () => waiting({ specs: specsList() && specsList().items, runs: ui.runs && ui.runs.data ? ui.runs.data.runs : null });
180
189
  const groupsShown = () => (ui.work ? filterGroups(ui.work.grouped.groups, ui.workFilters) : []);
181
190
  const plural = (n, word, more = `${word}s`) => `${n} ${n === 1 ? word : more}`;
182
191
  const kindWords = () => ({ specs: 'spec', pulls: 'pull request', issues: 'issue', threads: 'thread', deploys: 'deploy' })[ui.kind] || 'piece of work';
@@ -228,6 +237,7 @@ async function loadRuns(refresh, { say = true } = {}) {
228
237
  const before = ui.runs && ui.runs.data ? ui.runs.data.runs : null;
229
238
  const res = await request(runsUrl(refresh), refresh);
230
239
  ui.runs = res.ok && Array.isArray(res.body.runs) ? { data: res.body, error: '' } : { data: ui.runs && ui.runs.data, error: failWords(res, 'the runs') };
240
+ paintWaiting(); // the number follows the runs, whether or not the panel is open
231
241
  if (!(ui.runs && ui.runs.data)) return;
232
242
  // The map shows the open runs' nodes; a run lit on the map follows its nodes; what changed is said, once the first answer is in
233
243
  setRunsOnMap(ui.runs.data.runs);
@@ -308,10 +318,43 @@ async function loadSpecs(token, quiet) {
308
318
  ui.loading = false;
309
319
  const { entries, problem } = proposalListing();
310
320
  if (!entries) ui.error = `Could not load the proposals. ${problem || 'cornfield did not answer.'}`;
311
- if (!quiet) announce(ui.error || `${plural(entries.length, 'spec')} shown`);
321
+ if (!quiet) announce(ui.error || specsShownWords());
312
322
  paint();
313
323
  }
314
324
 
325
+ /** What the Specs tab says when it is read or searched: how many rows show, and how many of them wait on a decision */
326
+ function specsShownWords() {
327
+ const list = current();
328
+ if (!list) return 'Looking for proposals';
329
+ const shown = specGroups(list.items, { query: ui.specQuery }).reduce((n, g) => n + g.shown, 0);
330
+ if (ui.specQuery.trim() && !shown) return `No spec matches ${ui.specQuery.trim()}`;
331
+ const decide = waitingNow().specs;
332
+ return `${plural(shown, 'spec')} shown${decide ? `, ${decide} ${t('toDecide').toLowerCase()}` : ''}`;
333
+ }
334
+
335
+ /** How often the specs are read again for the number while the page is open (spec 0010 D2: at most every 5 minutes; the server keeps what it read by PR head) */
336
+ export const SPECS_POLL_MS = 5 * 60_000;
337
+ let specsTimer = 0;
338
+ let specsReading = false;
339
+
340
+ /** Reads the proposals now, quietly (the number and the list follow); one read at a time */
341
+ async function readSpecsQuiet() {
342
+ if (specsReading) return;
343
+ specsReading = true;
344
+ try { await loadProposalList(); } finally { specsReading = false; }
345
+ paintWaiting();
346
+ }
347
+
348
+ /** The specs part of the number is read again every `SPECS_POLL_MS`, never while the page is hidden or put away; one timer at most */
349
+ function syncSpecsPoll() {
350
+ if (specsTimer || !ui.config) return;
351
+ specsTimer = setTimeout(async () => {
352
+ specsTimer = 0;
353
+ if (!pageAway && !(typeof document !== 'undefined' && document.hidden)) await readSpecsQuiet();
354
+ syncSpecsPoll();
355
+ }, SPECS_POLL_MS);
356
+ }
357
+
315
358
  /** The counts on the tabs, read quietly the first time the panel opens: the open pull requests and issues (the Threads and Runs counts come from what those tabs read anyway) */
316
359
  function primeCounts() {
317
360
  for (const kind of ['pulls', 'issues']) {
@@ -324,7 +367,7 @@ function primeCounts() {
324
367
  });
325
368
  }
326
369
  if (!primed.has('threads')) { primed.add('threads'); ensureThreadsList(); }
327
- if (ui.kind !== 'specs' && !proposalListing().entries) loadProposalList();
370
+ if (ui.kind !== 'specs') readSpecsQuiet(); // the specs part of the number is read when Work opens (spec 0010 D2)
328
371
  }
329
372
  const primed = new Set();
330
373
 
@@ -1163,6 +1206,7 @@ function findAgain(el) {
1163
1206
  if (el.dataset.forgeDeploy) return `[data-forge-deploy="${el.dataset.forgeDeploy}"]`;
1164
1207
  if (el.dataset.forgeThread) return `[data-forge-thread="${el.dataset.forgeThread}"]`;
1165
1208
  if (el.dataset.forgeNode) return `[data-forge-node="${el.dataset.forgeNode}"]`;
1209
+ if (el.dataset.specGroupToggle) return `[data-spec-group-toggle="${el.dataset.specGroupToggle}"]`;
1166
1210
  if (el.dataset.forgeMerge) return '[data-forge-merge]';
1167
1211
  if (el.dataset.forgeSpec) return `[data-forge-spec="${el.dataset.forgeSpec}"]`;
1168
1212
  if (el.dataset.forgeBuild) return `[data-forge-build="${el.dataset.forgeBuild}"]`;
@@ -1229,15 +1273,57 @@ function paintCounts() {
1229
1273
  const specs = specsList() && specsList().items;
1230
1274
  const runs = ui.runs && ui.runs.data ? ui.runs.data.open : null;
1231
1275
  const counts = { specs: specs ? specs.length : null, pulls: open('pulls|open'), issues: open('issues|open'), threads: ui.config && ui.config.threads === false ? null : open('threads|open'), work: runs };
1276
+ // What waits on you shows as a filled badge on its tab: Specs the specs to decide, Runs the runs that need an answer (spec 0010 D2); with nothing
1277
+ // waiting, the tab shows its plain total like the others. One number a tab, and its name says so.
1278
+ const w = waitingNow();
1279
+ const share = { specs: w.specs, work: w.runs };
1232
1280
  for (const btn of document.querySelectorAll('#forge-panel [data-forge-kind]')) {
1233
- const n = counts[btn.dataset.forgeKind];
1281
+ const kind = btn.dataset.forgeKind;
1234
1282
  const el = btn.querySelector('.hx-forge-count');
1235
1283
  if (!el) continue;
1236
- el.hidden = !(btn.dataset.forgeKind in counts); // a tab with no count at all (Deploys) shows none; the others hold their width while empty
1284
+ const waits = share[kind] || 0;
1285
+ const n = waits || counts[kind];
1286
+ el.hidden = !(kind in counts); // a tab with no count at all (Deploys) shows none; the others hold their width while empty
1237
1287
  el.textContent = n ? String(n) : '';
1288
+ // The hook says which it is: a filled badge for what waits on you, a plain count for the total
1289
+ el.dataset.corn = waits ? 'waiting-badge' : 'count';
1290
+ el.classList.toggle('hx-forge-count--waiting', !!waits);
1291
+ const label = btn.querySelector('[data-corn-string]');
1292
+ if (waits && label) btn.setAttribute('aria-label', `${label.textContent}, ${waitingWords(waits)}`); else btn.removeAttribute('aria-label');
1238
1293
  }
1239
1294
  }
1240
1295
 
1296
+ /** The one number, wherever it shows: the tabs' badges, the Work button's, and the browser tab's title; called whenever the specs or the runs were read */
1297
+ function paintWaiting() {
1298
+ paintCounts();
1299
+ paintButton();
1300
+ paintTitle();
1301
+ paintBarLine();
1302
+ refreshStubs();
1303
+ }
1304
+
1305
+ /** The proposal bar's line: a run waits on the open proposal (spec 0010 D2) */
1306
+ function paintBarLine(open = !!state.proposal) {
1307
+ const run = open && state.proposalSlug && ui.runs && ui.runs.data ? runWaitingOn(ui.runs.data.runs, state.proposalSlug) : null;
1308
+ paintWaitingLine(run, `${state.proposalSource || ''}/${state.proposalSlug || ''}`);
1309
+ }
1310
+
1311
+ /** Answer, on the proposal bar's line: Work opens on Runs at that run with its reply field focused */
1312
+ async function answerFromBar(id) {
1313
+ if (!(await openRunLink(id))) return;
1314
+ const field = $('forge-runs-list').querySelector(`[data-run-reply="${id}"]`);
1315
+ if (field) field.focus();
1316
+ }
1317
+
1318
+ /** The browser tab's title starts "(3) " while something waits, then the page's own title (the app's configured name, whatever the server wrote) */
1319
+ let baseTitle = null;
1320
+ function paintTitle() {
1321
+ if (typeof document === 'undefined') return;
1322
+ if (baseTitle === null) baseTitle = document.title.replace(/^\(\d+\) /, '');
1323
+ const n = waitingNow().total;
1324
+ document.title = n > 0 ? `(${n}) ${baseTitle}` : baseTitle;
1325
+ }
1326
+
1241
1327
  /** Says (on the panel's top, for the CSS) that the tabs run on past an edge: a fade shows on that side, so Deploys is not simply missing on a phone */
1242
1328
  function paintTabsMore() {
1243
1329
  const top = document.querySelector('#forge-panel .hx-forge-top');
@@ -1274,6 +1360,8 @@ function draw(panel) {
1274
1360
  const specs = ui.kind === 'specs';
1275
1361
  const showing = detailKey();
1276
1362
  $('forge-filters').hidden = notes || ui.kind === 'work' || specs;
1363
+ const searchBox = $('forge-specs-search');
1364
+ if (searchBox) searchBox.hidden = !specs || !!showing;
1277
1365
  $('forge-work-filters').hidden = ui.kind !== 'work';
1278
1366
  $('forge-bar').hidden = !!showing;
1279
1367
  paintChip();
@@ -1294,7 +1382,7 @@ function draw(panel) {
1294
1382
  if (ui.loading && !list) status.textContent = work ? `Loading the work from ${forgeName()} …` : specs ? 'Looking for proposals …' : `Loading ${kindWords()}s from ${forgeName()} …`;
1295
1383
  else if (!list) status.textContent = '';
1296
1384
  else if (work) status.textContent = workStatus(groups, list.at, now());
1297
- else if (specs) status.textContent = `${plural(list.items.length, 'proposal')}${list.at ? `, as of ${relativeTime(list.at, now())}` : ''}`;
1385
+ else if (specs) status.textContent = `${waitingNow().specs ? `${waitingNow().specs} ${t('toDecide').toLowerCase()} \u00b7 ` : ''}${plural(list.items.length, 'proposal')}${list.at ? `, as of ${relativeTime(list.at, now())}` : ''}`;
1298
1386
  else status.textContent = `${shown.length} of ${plural(list.items.length, kindWords())}${list.at ? `, as of ${relativeTime(list.at, now())}` : ''}`;
1299
1387
 
1300
1388
  const notice = $('forge-notice');
@@ -1319,7 +1407,10 @@ function draw(panel) {
1319
1407
  if (!list) rows.innerHTML = ui.loading && !(work && !(ui.runs && ui.runs.data)) ? loadingRowsHtml(4) : '';
1320
1408
  else if (specs) {
1321
1409
  const open = state.proposal ? { slug: state.proposalSlug, source: state.proposalSource } : null;
1322
- rows.innerHTML = list.items.length ? list.items.map((e) => specRowHtml(e, { current: open })).join('') : empty(emptyWords('specs', forgeName()));
1410
+ const groups = specGroups(list.items, { query: ui.specQuery });
1411
+ rows.innerHTML = groups.length ? specGroupsHtml(groups, { current: open, nowMs: now(), draftsOpen: ui.draftsOpen })
1412
+ : list.items.length ? `<li class="hx-forge-empty hx-faint" data-corn="empty">No spec matches \u201c${escHtml(ui.specQuery.trim())}\u201d. <button type="button" class="hx-btn hx-forge-act" data-corn-kind="quiet" data-action="clear-specs-search">Clear the search</button></li>`
1413
+ : empty(emptyWords('specs', forgeName()));
1323
1414
  }
1324
1415
  else if (work) rows.innerHTML = groups.length ? groupsHtml(groups) : empty(ui.work.grouped.groups.length ? 'No work matches these filters.' : emptyWords('work', forgeName()));
1325
1416
  else rows.innerHTML = shown.length ? shown.map((i) => itemHtml(i)).join('') : empty(list.items.length ? `No ${kindWords()} matches these filters.` : emptyWords(ui.kind, forgeName()));
@@ -1526,7 +1617,13 @@ function paintButton() {
1526
1617
  tag.hidden = !lit;
1527
1618
  tag.textContent = ui.runSel ? 'run' : ui.thread !== null ? `thread #${ui.thread}` : ui.deployItem ? 'deploy' : lit ? `#${ui.selected}` : '';
1528
1619
  }
1529
- btn.setAttribute('aria-label', `${t('issuesAndPrs')}${ui.runSel ? ', a run lit on the map' : ui.thread !== null ? `, thread ${ui.thread} selected` : ui.deployItem ? ', a deploy selected' : lit ? `, pull request ${ui.selected} selected` : ''}`);
1620
+ const n = waitingNow().total;
1621
+ const badge = $('forge-btn-waiting');
1622
+ if (badge) {
1623
+ badge.hidden = n === 0;
1624
+ badge.textContent = n ? String(n) : '';
1625
+ }
1626
+ btn.setAttribute('aria-label', `${workButtonName(t('issuesAndPrs'), n)}${ui.runSel ? ', a run lit on the map' : ui.thread !== null ? `, thread ${ui.thread} selected` : ui.deployItem ? ', a deploy selected' : lit ? `, pull request ${ui.selected} selected` : ''}`);
1530
1627
  }
1531
1628
 
1532
1629
  // ---------------------------------------------------------------------------
@@ -2009,11 +2106,20 @@ export function openForge({ load = true, tab } = {}) {
2009
2106
  ui.kind = tab;
2010
2107
  ui.filters = defaultFilters(tab);
2011
2108
  ui.actNote = null;
2109
+ } else if (!tab && load && !ui.open) {
2110
+ // Opened by a toggle: on the tab with the oldest thing waiting on you, else the tab used last (spec 0010 D2)
2111
+ const oldest = waitingNow().oldest;
2112
+ if (oldest && oldest !== ui.kind) {
2113
+ ui.kind = oldest;
2114
+ ui.filters = defaultFilters(oldest);
2115
+ ui.actNote = null;
2116
+ paintFilters();
2117
+ }
2012
2118
  }
2013
2119
  ui.open = true;
2014
2120
  panel.inert = false;
2015
2121
  panel.classList.add('forge-open');
2016
- if (isPhone()) expandSheet('forge');
2122
+ if (isPhone()) { showSheet('forge'); if (tab) expandSheet('forge'); } // a peek; only a link that names a tab (a deep link, "Open the Specs list") opens it expanded
2017
2123
  paintButton();
2018
2124
  const title = $('forge-title');
2019
2125
  title.focus();
@@ -2187,6 +2293,15 @@ function onClick(e) {
2187
2293
  if (ui.kind === 'specs') { paint(); loadList(false, true); announce(current() ? `${plural(current().items.length, 'spec')} shown` : 'Looking for proposals'); } else if (current()) filtersChanged(); else { paint(); loadList(); }
2188
2294
  return;
2189
2295
  }
2296
+ const fold = t.closest('[data-spec-group-toggle]');
2297
+ if (fold) {
2298
+ // Drafts folded behind their header, opened by hand and folded again; the focus stays on the header (findAgain)
2299
+ const drafts = specGroups(specsList() ? specsList().items : [], { query: ui.specQuery }).find((g) => g.key === 'drafts');
2300
+ const folded = ui.draftsOpen === null ? !!(drafts && drafts.collapsed) : !ui.draftsOpen;
2301
+ ui.draftsOpen = folded;
2302
+ paint();
2303
+ return;
2304
+ }
2190
2305
  const pr = t.closest('[data-forge-pr]');
2191
2306
  if (pr) {
2192
2307
  const n = Number(pr.dataset.forgePr);
@@ -2247,6 +2362,14 @@ function onClick(e) {
2247
2362
  if (!action) return;
2248
2363
  if (action.dataset.action === 'close-forge') closeForge();
2249
2364
  else if (action.dataset.action === 'refresh-forge' || action.dataset.action === 'retry-forge') refreshForge();
2365
+ else if (action.dataset.action === 'clear-specs-search') {
2366
+ ui.specQuery = '';
2367
+ const box = $('specs-search');
2368
+ if (box) { box.value = ''; }
2369
+ paint();
2370
+ announce(specsShownWords());
2371
+ if (box) box.focus();
2372
+ }
2250
2373
  else if (action.dataset.action === 'copy-notes') copyNotes();
2251
2374
  else if (action.dataset.action === 'post-notes') { if (ui.notes.confirm) closeNotesConfirm(); else openNotesConfirm(); }
2252
2375
  else if (action.dataset.action === 'confirm-notes') postDraft();
@@ -2321,6 +2444,13 @@ function onInput(e) {
2321
2444
  if (said && !said.ok && e.target.value.trim()) { clearResult(id); showResultIn(e.target.closest('[data-run]') && e.target.closest('[data-run]').querySelector(`[data-run-result="${id}"]`), id); }
2322
2445
  return;
2323
2446
  }
2447
+ if (e.target.id === 'specs-search') {
2448
+ ui.specQuery = e.target.value;
2449
+ paint();
2450
+ clearTimeout(searchTimer);
2451
+ searchTimer = setTimeout(() => announce(specsShownWords()), SEARCH_ANNOUNCE_MS);
2452
+ return;
2453
+ }
2324
2454
  if (e.target.id !== 'forge-text') return;
2325
2455
  ui.filters.text = e.target.value;
2326
2456
  filtersChanged(false);
@@ -2380,13 +2510,35 @@ export function initForgePanel(config, opts = {}) {
2380
2510
  const tab = panel.querySelector('[data-forge-kind="threads"]');
2381
2511
  if (tab) tab.hidden = !threadsOn;
2382
2512
  state.threadIndex = threadsOn ? { for: threadsFor, ensure: ensureThreadsList, open: openThread, start: startThread, forge: forgeName } : null;
2383
- registerSheet('forge', panel);
2513
+ // On a phone Work is a sheet: it opens as a peek and displaces the node panel; folded to a stub it says its title and what waits on you (spec 0010 D7)
2514
+ registerSheet('forge', panel, {
2515
+ stub: () => { const n = waitingNow().total; return { title: t('issuesAndPrs'), badge: n ? String(n) : '', label: workButtonName(t('issuesAndPrs'), n) }; },
2516
+ away: () => closeForge({ restoreFocus: false }),
2517
+ });
2384
2518
  paintFilters();
2385
2519
  paint();
2386
2520
  // The map shows the open runs whether or not the panel is open: read them once now, and again now and then while any is open
2387
2521
  if (config.agents && config.agents.runs) {
2388
2522
  loadRuns(false).then(() => { if (ui.kind === 'work') paint(); }, () => {});
2389
2523
  }
2524
+ // The specs part of what waits on you is read once now and every 5 minutes after (the server keeps it by PR head), and after a review is sent
2525
+ proposalHooks.reviewed = () => { readSpecsQuiet(); };
2526
+ // The proposal bar says so when a run waits on the proposal it shows: drawn with the bar, and again as the runs are read
2527
+ if (!(proposalHooks.bar && proposalHooks.bar.waitingLine)) {
2528
+ const barBefore = proposalHooks.bar;
2529
+ proposalHooks.bar = (open) => { if (barBefore) barBefore(open); paintBarLine(open); };
2530
+ proposalHooks.bar.waitingLine = true;
2531
+ }
2532
+ const bar = $('proposal-bar');
2533
+ if (bar && !bar.dataset.waitingWired) {
2534
+ bar.dataset.waitingWired = '1';
2535
+ bar.addEventListener('click', (e) => {
2536
+ const go = e.target.closest && e.target.closest('[data-waiting-answer]');
2537
+ if (go) { e.preventDefault(); e.stopPropagation(); answerFromBar(go.dataset.waitingAnswer); }
2538
+ }, true);
2539
+ }
2540
+ readSpecsQuiet();
2541
+ syncSpecsPoll();
2390
2542
  if (!wired) {
2391
2543
  wired = true;
2392
2544
  initConnection();
@@ -2417,7 +2569,7 @@ export function initForgePanel(config, opts = {}) {
2417
2569
  }
2418
2570
  offScene = onSceneTouch(onNodesChange);
2419
2571
  // The header's Proposals menu reads the same list: when it is read again the Specs tab and its count follow
2420
- offListing = onProposalListing(() => { if (ui.open) paint(); });
2572
+ offListing = onProposalListing(() => { paintWaiting(); if (ui.open) paint(); });
2421
2573
  // A node's panel lists the threads that mention it; a click there shows one in this panel
2422
2574
  const drawer = $('spec-drawer');
2423
2575
  if (drawer) drawer.addEventListener('click', (e) => {
@@ -2459,9 +2611,16 @@ export function resetForgePanelForTests(clock = () => Date.now()) {
2459
2611
  state.threadIndex = null;
2460
2612
  clearTimeout(runsTimer);
2461
2613
  runsTimer = 0;
2614
+ clearTimeout(specsTimer);
2615
+ specsTimer = 0;
2616
+ specsReading = false;
2617
+ merged = { entries: null, items: [] };
2618
+ resetWaitingLineForTests();
2619
+ if (typeof document !== 'undefined' && baseTitle !== null) document.title = baseTitle;
2620
+ baseTitle = null;
2462
2621
  pageAway = false;
2463
2622
  clearRunsOnMap();
2464
- Object.assign(ui, { runSel: null, runTimelines: new Set(), runReplies: new Map(), thread: null, threadDetail: null, threadError: '', litThread: null, idea: freshIdea(), config: null, open: false, kind: 'specs', filtersOpen: false, filters: defaultFilters(), lists: {}, work: null, workFilters: { agentsOnly: false, finished: false }, loading: false, error: '', selected: null, selectedOn: '', detail: null, landing: null, detailError: '', lit: null, deploy: null, deployItem: null, litDeploy: null, nodesSeen: null, busy: '', note: null, confirm: null, actNote: null, notes: freshNotes(), runs: null, runnerSaid: null, runNote: null, agent: null, retrying: false });
2623
+ Object.assign(ui, { specQuery: '', draftsOpen: null, runSel: null, runTimelines: new Set(), runReplies: new Map(), thread: null, threadDetail: null, threadError: '', litThread: null, idea: freshIdea(), config: null, open: false, kind: 'specs', filtersOpen: false, filters: defaultFilters(), lists: {}, work: null, workFilters: { agentsOnly: false, finished: false }, loading: false, error: '', selected: null, selectedOn: '', detail: null, landing: null, detailError: '', lit: null, deploy: null, deployItem: null, litDeploy: null, nodesSeen: null, busy: '', note: null, confirm: null, actNote: null, notes: freshNotes(), runs: null, runnerSaid: null, runNote: null, agent: null, retrying: false });
2465
2624
  resetFeedbackForTests();
2466
2625
  resetConnectionForTests();
2467
2626
  }
@@ -123,6 +123,8 @@
123
123
  <button type="button" id="forge-btn" class="hx-work" data-action="toggle-forge" aria-expanded="false" aria-controls="forge-panel" aria-label="Work" data-corn-string-aria-label="issuesAndPrs" title="Issues, pull requests and deploys: a pull request lights the nodes it changes, a deploy the nodes it restarted" hidden data-corn="forge-button">
124
124
  <span data-corn-string="issuesAndPrs">Work</span>
125
125
  <span id="forge-btn-lit" class="hx-forge-lit" data-corn="count" hidden></span>
126
+ <!-- What waits on you (explorer/waiting-model.js): specs to decide plus runs that need an answer; hidden at 0 and for anyone not signed in -->
127
+ <span id="forge-btn-waiting" class="hx-waiting-badge" data-corn="waiting-badge" aria-hidden="true" hidden></span>
126
128
  </button>
127
129
 
128
130
  <!-- The one account menu (explorer/account-menu.js): who, Theme, Freeform layout, Review tokens, Proposals, the links, Sign out, and what powers it -->
@@ -198,10 +200,11 @@
198
200
  <div id="proposal-ways" class="hx-proposal-ways" role="group" aria-label="Ways on" data-corn="proposal-ways" hidden></div>
199
201
  <div id="proposal-body">
200
202
  <div class="hx-proposal-head" data-corn="proposal-head" role="group" aria-label="Proposal actions">
201
- <strong id="proposal-title" class="hx-proposal-name" data-corn="proposal-title"></strong>
203
+ <h2 id="proposal-title" class="hx-proposal-name" data-corn="proposal-title"></h2>
202
204
  <a id="proposal-source" class="hx-proposal-source" data-corn="proposal-source" hidden></a>
203
205
  <div class="hx-proposal-counts">
204
- <button type="button" id="proposal-chip" class="hx-proposal-chip" data-corn="proposal-counts" data-action="toggle-proposal-changes" aria-expanded="false"></button>
206
+ <div id="proposal-chip" class="hx-proposal-chip" data-corn="proposal-counts"></div>
207
+ <p id="proposal-peek" class="hx-proposal-peek"></p>
205
208
  <button type="button" id="proposal-mode" class="hx-proposal-mode" data-corn="proposal-mode" data-action="toggle-proposal-mode" data-peek-ok aria-expanded="false" aria-controls="proposal-seg" title="Before, Diff or After"></button>
206
209
  </div>
207
210
  <div id="proposal-seg" class="hx-seg" data-corn="compare" role="group" aria-label="Compare">
@@ -210,13 +213,8 @@
210
213
  <button data-corn="compare-option" type="button" class="hx-seg-btn" data-action="proposal-view" data-view="after" aria-pressed="false" data-corn-string="after">After</button>
211
214
  </div>
212
215
  <div class="hx-proposal-tools">
213
- <button data-corn-kind="secondary" type="button" id="proposal-play" class="hx-btn" aria-expanded="false" aria-controls="proposal-scenarios" title="Play one of this proposal's scenarios on the map" hidden>Play</button>
214
216
  <button data-corn-kind="secondary" type="button" id="proposal-edit" class="hx-btn" aria-expanded="false" aria-controls="whatif" title="Try a change: add a node or an edge, reword a scenario">Edit</button>
215
217
  </div>
216
- <div class="hx-proposal-actions">
217
- <button data-corn-kind="secondary" type="button" class="hx-btn" data-review="notes" data-peek-ok title="Send it back to the drafting agent with a note and your edits" data-corn-string="sendBack">Send back</button>
218
- <button type="button" class="hx-btn hx-btn--approve" data-review="approved" data-peek-ok title="Sign this proposal off" data-corn-kind="approve" data-corn-string="approve">Approve</button>
219
- </div>
220
218
  <div class="hx-proposal-more">
221
219
  <button type="button" id="proposal-more" class="hx-btn hx-btn--icon" data-action="toggle-proposal-more" aria-haspopup="menu" aria-expanded="false" aria-controls="proposal-more-menu" aria-label="More" data-corn-kind="icon"><svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><circle cx="3" cy="8" r="1.5"/><circle cx="8" cy="8" r="1.5"/><circle cx="13" cy="8" r="1.5"/></svg></button>
222
220
  <div id="proposal-more-menu" class="hx-proposal-more-menu glass" data-corn="proposal-menu" role="menu" aria-label="More" hidden>
@@ -224,16 +222,29 @@
224
222
  </div>
225
223
  </div>
226
224
  </div>
227
- <p id="proposal-summary" class="hx-proposal-summary" hidden></p>
228
225
  <details id="proposal-errors" class="hx-proposal-errors" data-corn="proposal-errors" hidden>
229
226
  <summary data-corn="summary" id="proposal-errors-count"></summary>
230
227
  <ul id="proposal-errors-list"></ul>
231
228
  <p class="hx-faint">The map shows what it can.</p>
232
229
  </details>
233
- <div id="proposal-changes" class="hx-proposal-changes" data-corn="proposal-changes" hidden></div>
234
230
  </div>
235
231
  </section>
236
232
 
233
+ <!-- The review column (review-column.js, spec 0006): what the proposal changes, and the personas and the scenarios that apply to them. Docked left of the map from 768px, the expanded proposal sheet's body on a phone -->
234
+ <aside id="review-column" class="hx-review-column glass" aria-label="Review" data-corn="review-column" hidden>
235
+ <div class="hx-rc-scroll">
236
+ <p id="proposal-summary" class="hx-proposal-summary" hidden></p>
237
+ <div id="review-lists" class="hx-rc-lists"></div>
238
+ </div>
239
+ <!-- The decision, the column's foot: Send back and Approve (review.js). Spec 0007 puts its line about what Approve does above them here. -->
240
+ <div id="review-decision" class="hx-rc-foot" data-corn="decision" role="group" aria-label="Decision">
241
+ <div class="hx-proposal-actions">
242
+ <button data-corn-kind="secondary" type="button" class="hx-btn" data-review="notes" data-peek-ok title="Send it back to the drafting agent with a note and your edits" data-corn-string="sendBack">Send back</button>
243
+ <button type="button" class="hx-btn hx-btn--approve" data-review="approved" data-peek-ok title="Sign this proposal off" data-corn-kind="approve" data-corn-string="approve">Approve</button>
244
+ </div>
245
+ </div>
246
+ </aside>
247
+
237
248
  <!-- The Work panel (forge-panel.js): Specs, PRs, Issues, Threads, Runs and Deploys, in the order of the loop. A slide-over from the left on desktop, a bottom sheet on a phone; hidden and inert until the config names a forge. `forge-panel` on the inner box is the old name of the hook, kept for one release (docs/theming.md) -->
238
249
  <p id="offline-banner" class="hx-offline" data-corn="notice" hidden></p>
239
250
  <aside id="forge-panel" class="hx-forge glass" aria-label="Work" inert hidden data-corn="work-panel">
@@ -257,6 +268,10 @@
257
268
  <p id="forge-status" class="hx-forge-status hx-faint"></p>
258
269
  <button data-corn="filter-chip" type="button" id="forge-filter-chip" class="hx-forge-chip" data-action="toggle-filters" aria-expanded="false" aria-controls="forge-filter-box" hidden>Filter<span class="hx-forge-count" data-corn="count" hidden></span></button>
259
270
  </div>
271
+ <!-- The Specs tab's one search field (spec 0010 D5): titles, slugs and summaries, as you type -->
272
+ <div id="forge-specs-search" class="hx-forge-specsearch" data-corn="specs-search" hidden>
273
+ <label class="hx-forge-field hx-forge-field--text" data-corn="field">Find a spec<input data-corn="control" type="search" id="specs-search" class="hx-forge-input" placeholder="Title, name, summary" autocomplete="off" /></label>
274
+ </div>
260
275
  <div id="forge-filter-box" class="hx-forge-controls" data-corn="filters" hidden>
261
276
  <div id="forge-work-filters" class="hx-forge-work-filters" hidden>
262
277
  <label class="hx-forge-toggle" data-corn="check-field"><input data-corn="control" type="checkbox" id="forge-work-agents" /> Agent-made only</label>
package/explorer/main.js CHANGED
@@ -32,6 +32,7 @@ import { closeLegendMenu, toggleAllLayers, toggleLayer, toggleLegendMenu } from
32
32
  import { closeDrawer, copySpec, selectNode, startRun } from './panels.js';
33
33
  import { initScenarioUi, maybeStartDemo, playOutage } from './scenario-ui.js';
34
34
  import { initSheets } from './sheets.js';
35
+ import { initReviewColumn } from './review-column.js';
35
36
  import { loadTopology, setView, syncViewUi } from './view.js';
36
37
  import { bindCanvasInput } from './input.js';
37
38
  import { initProposals } from './proposal.js';
@@ -211,6 +212,7 @@ initKeyboard(); // the map, the panel, the search and the Layers menu by keyboar
211
212
  initAccountMenu(); // the one menu at the right of the header (account-menu.js)
212
213
  initSheets();
213
214
  initScenarioUi();
215
+ initReviewColumn(); // the review column: the changes, and the personas with their scenarios (review-column.js)
214
216
  window.addEventListener('resize', resize);
215
217
  $('node-search').addEventListener('input', (e) => handleSearch(e.target.value));
216
218
  $('mobile-node-search').addEventListener('input', (e) => handleSearch(e.target.value));
@@ -12,7 +12,7 @@ import { flowSummary } from './flows.js';
12
12
  import { clearScenario } from './scenario-ui.js';
13
13
  import { kindOfMark, fieldRows, MARK_WORDS } from './proposal-model.js';
14
14
  import { nodeMockupsHtml } from './mockups-model.js';
15
- import { collapseSheet, isPhone, measureCovered, onCoveredChange } from './sheets.js';
15
+ import { collapseSheet, isPhone, measureCovered, onCoveredChange, showSheet } from './sheets.js';
16
16
  import { panIntoView } from './camera.js';
17
17
  import { liveSection, hydrateLivePhotos } from './live.js';
18
18
  import { cloudPanelHtml } from './cloud-model.js';
@@ -282,6 +282,7 @@ export async function selectNode(node) {
282
282
  $('spec-drawer').classList.add('drawer-open');
283
283
  $('spec-drawer').inert = false; // closed, it waits off screen: inert, so Tab never reaches its buttons (MAP-02)
284
284
  $('drawer-backdrop').hidden = false;
285
+ showSheet('drawer'); // on a phone it takes Work's place (the node sheet and Work take turns), and comes back from away when its node is tapped again
285
286
  keepSelectedInView();
286
287
  }
287
288
 
@@ -19,7 +19,8 @@
19
19
  */
20
20
 
21
21
  import { escHtml } from './state.js';
22
- import { markStateAttr } from './corn-state.js';
22
+ import { markStateAttr, stateIconHtml } from './corn-state.js';
23
+ import { specStateOf, specStateWords, SPEC_STATE_WORDS, SPEC_STATE_CORN } from './waiting-model.js';
23
24
 
24
25
  export const PROPOSAL_VIEWS = ['before', 'diff', 'after'];
25
26
 
@@ -221,9 +222,6 @@ export function proposalPanelHtml(item) {
221
222
  // A proposal as a row of the Work panel's Specs tab
222
223
  // ---------------------------------------------------------------------------
223
224
 
224
- /** What a listing entry's state pill says: its spec PR's state, or "Local" for a proposal that is only in a checkout or a worktree */
225
- export const specState = (entry) => (entry.pull ? (entry.pull.draft ? 'Draft' : 'Open') : 'Local');
226
-
227
225
  /** Where a listing entry is, as a line of meta: "PR #11", or the checkout or worktree it is in; a proposal that is also somewhere else says so ("PR #11, and a copy in the checkout") */
228
226
  export function specWhere(entry) {
229
227
  const place = (source) => (source === 'checkout' ? 'the checkout' : `worktree ${source}`);
@@ -260,22 +258,28 @@ export function mergeSpecs(entries) {
260
258
  }
261
259
 
262
260
  /**
263
- * One row: title, a state pill, a line of what it is for, and the meta (spec number, where it is, +added ~changed −removed, scenarios).
264
- * A proposal that could not be read is a row that says why and opens nothing. Same `open-proposal` action as the Proposals menu's row.
265
- * @param {{ slug: string, source: string, title?: string, summary?: string, spec?: string, pull?: {number: number, draft?: boolean}, counts?: {added?: number, changed?: number, removed?: number, scenarios?: number}, errors?: number, error?: string }} entry
266
- * @param {{ current?: {slug: string, source: string} | null }} [opts] the proposal that is open now
261
+ * One row: title, a pill that says its review state (To decide, Changed since approved, Sent back, Approved, Draft PR, Local, spec 0010 D4),
262
+ * who and when beside it ("Approved by maintainer-one \u00b7 2 hours ago", "Waiting 2 days"), a line of what it is for, and the meta (spec number,
263
+ * where it is, +added ~changed \u2212removed, scenarios). A review that could not be read says so, with a way to try again, and never looks
264
+ * unreviewed. A proposal that could not be read is a row that says why and opens nothing. Same `open-proposal` action as the Proposals menu's row.
265
+ * What the forge said (a login, a date) is escaped; the pill's state is one of a fixed list.
266
+ * @param {{ slug: string, source: string, title?: string, summary?: string, spec?: string, pull?: {number: number, draft?: boolean}, review?: object | null, counts?: {added?: number, changed?: number, removed?: number, scenarios?: number}, errors?: number, error?: string }} entry
267
+ * @param {{ current?: {slug: string, source: string} | null, nowMs?: number }} [opts] the proposal that is open now; the clock
267
268
  */
268
- export function specRowHtml(entry, { current = null } = {}) {
269
+ export function specRowHtml(entry, { current = null, nowMs = Date.now() } = {}) {
269
270
  const head = `<span class="hx-forge-title">${escHtml(entry.title || entry.slug)}</span>`;
270
271
  if (entry.error) {
271
272
  return `<li class="hx-forge-item"><div class="hx-forge-row hx-forge-spec" data-corn="row">${head}<span class="hx-forge-sum hx-error-text">${escHtml(entry.error)}</span><span class="hx-forge-meta">${escHtml(specWhere(entry))}</span></div></li>`;
272
273
  }
273
- const state = specState(entry);
274
- const tone = ` data-corn-state="${state === 'Open' ? 'open' : 'draft'}"`; // a proposal only in a checkout is a draft too, as a branch with no pull request is
274
+ const { state } = specStateOf(entry);
275
+ const corn = SPEC_STATE_CORN[state];
276
+ const pill = `<span class="hx-forge-state hx-forge-state--${corn}" data-corn="review-state" data-corn-state="${corn}">${stateIconHtml(corn)}${escHtml(SPEC_STATE_WORDS[state])}</span>`;
275
277
  const c = entry.counts || {};
278
+ const said = specStateWords(entry, nowMs);
276
279
  const meta = [
277
280
  entry.spec ? `<span>spec ${escHtml(entry.spec)}</span>` : '',
278
281
  `<span>${escHtml(specWhere(entry))}</span>`,
282
+ said ? `<span class="hx-forge-reviewed">${escHtml(said)}</span>` : '',
279
283
  c.added ? `<span class="hx-forge-add" title="${c.added} added">+${c.added}</span>` : '',
280
284
  c.changed ? `<span class="hx-forge-chg" title="${c.changed} changed">~${c.changed}</span>` : '',
281
285
  c.removed ? `<span class="hx-forge-del" title="${c.removed} removed">\u2212${c.removed}</span>` : '',
@@ -283,9 +287,10 @@ export function specRowHtml(entry, { current = null } = {}) {
283
287
  entry.errors ? `<span class="hx-warn">${entry.errors} ${entry.errors === 1 ? 'problem' : 'problems'}</span>` : '',
284
288
  ].filter(Boolean).join('');
285
289
  const mine = !!current && current.slug === entry.slug && (current.source === entry.source || (Array.isArray(entry.also) && entry.also.includes(current.source)));
290
+ const unread = state === 'unknown' ? `<p class="hx-forge-meta hx-forge-unread" data-corn="message" data-corn-state="failure">${escHtml(entry.review && entry.review.error ? entry.review.error : 'The forge could not be asked.')} <button type="button" class="hx-btn hx-forge-act" data-corn-kind="quiet" data-action="retry-forge" aria-label="Try again: ${escHtml(entry.title || entry.slug)}">Try again</button></p>` : '';
286
291
  return `<li class="hx-forge-item"><button type="button" class="hx-forge-row hx-forge-spec" data-action="open-proposal" data-slug="${escHtml(entry.slug)}" data-source="${escHtml(entry.source)}" aria-pressed="${mine}" data-corn="row">`
287
- + `<span class="hx-forge-line">${head}<span class="hx-forge-state hx-forge-state--${state === 'Draft' ? 'draft' : state === 'Open' ? 'open' : 'neutral'}" data-corn="state-pill"${tone}>${state}</span></span>`
288
- + `${entry.summary ? `<span class="hx-forge-sum">${escHtml(entry.summary)}</span>` : ''}<span class="hx-forge-meta hx-forge-facts">${meta}</span></button></li>`;
292
+ + `<span class="hx-forge-line">${head}${pill}</span>`
293
+ + `${entry.summary ? `<span class="hx-forge-sum">${escHtml(entry.summary)}</span>` : ''}<span class="hx-forge-meta hx-forge-facts">${meta}</span></button>${unread}</li>`;
289
294
  }
290
295
 
291
296
  // ---------------------------------------------------------------------------