@popcorn245/cornfield 0.54.0 → 0.56.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/contrast.js +28 -0
- package/core/schema.js +24 -0
- package/explorer/css/page.css +0 -8
- package/explorer/css/work.css +3 -26
- package/explorer/deep-link.js +11 -24
- package/explorer/engine/layers.js +5 -2
- package/explorer/engine/map-style.js +8 -1
- package/explorer/engine/render.js +2 -1
- package/explorer/forge-panel-model.js +2 -36
- package/explorer/forge-panel.js +3 -7
- package/explorer/index.html +5 -11
- package/explorer/instance-state.js +0 -6
- package/explorer/instance.js +9 -5
- package/explorer/layer-model.js +1 -0
- package/explorer/page.js +8 -5
- package/explorer/pieces/layers.js +1 -1
- package/explorer/pieces/node-panel.js +26 -4
- package/explorer/pieces/search.js +9 -3
- package/explorer/pieces/work-agent.js +3 -2
- package/explorer/pieces/work-common.js +14 -15
- package/explorer/pieces/work-confirm.js +11 -10
- package/explorer/pieces/work-data.js +24 -31
- package/explorer/pieces/work-deploys.js +42 -41
- package/explorer/pieces/work-issues.js +32 -29
- package/explorer/pieces/work-list.js +406 -0
- package/explorer/pieces/work-markup.js +9 -15
- package/explorer/pieces/work-notes.js +0 -1
- package/explorer/pieces/work-paint.js +57 -67
- package/explorer/pieces/work-prs.js +25 -66
- package/explorer/pieces/work-runs.js +47 -57
- package/explorer/pieces/work-specs.js +19 -2
- package/explorer/pieces/work-threads.js +29 -49
- package/explorer/pieces/work.js +28 -28
- package/explorer/proposal-model.js +5 -5
- package/explorer/runs-view.js +10 -18
- package/explorer/scene.js +17 -10
- package/explorer/search-match.js +3 -2
- package/explorer/tokens.css +11 -0
- package/explorer/view.js +8 -1
- package/explorer/waiting-view.js +3 -3
- package/explorer/work-model.js +722 -0
- package/explorer/work-view.css +50 -0
- package/explorer/work-view.js +570 -0
- package/package.json +1 -1
- package/explorer/pieces/work-events.js +0 -285
|
@@ -1,43 +1,46 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module explorer/pieces/work-issues
|
|
3
3
|
*
|
|
4
|
-
* The Issues tab
|
|
4
|
+
* The Issues tab (its rows are drawn with the PRs' in work-prs.js), an issue's actions in the node panel, and an issue older than the Work view's 14 days.
|
|
5
|
+
* Part of the Work piece (pieces/work.js): `install(ctx)` makes this part's functions for one mount, and hands the ones other parts call
|
|
5
6
|
* to `ctx.fn`; nothing is shared between two mounts.
|
|
6
7
|
*/
|
|
7
8
|
|
|
8
|
-
import {
|
|
9
|
+
import { escapeHtml as escHtml } from '../../core/text.js';
|
|
10
|
+
import { issueUrl, listUrl, listKeyOf, specBlock } from '../forge-panel-model.js';
|
|
9
11
|
|
|
10
12
|
export function install(ctx) {
|
|
11
|
-
const { ui, fn
|
|
12
|
-
const {
|
|
13
|
+
const { ui, fn } = ctx;
|
|
14
|
+
const { t } = ctx.h;
|
|
13
15
|
|
|
14
|
-
/** An issue the
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
if (
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
return fn.linkMissing(res.status === 404 ? `There is no issue ${n}.` : fn.failWords(res, `issue ${n}`));
|
|
16
|
+
/** An issue's actions in the node panel: Start a spec (step 1 of the pipeline) and Start an agent, each opening its confirm step; a closed issue has none */
|
|
17
|
+
function issueActionsHtml(item) {
|
|
18
|
+
const n = item.number;
|
|
19
|
+
if (!item.open) return `<p class="hx-faint">${escHtml(specBlock({ state: 'closed' }))}</p>`;
|
|
20
|
+
const spec = specBlock({ state: 'open' }) === null
|
|
21
|
+
? `<button data-corn-kind="secondary" type="button" class="hx-btn hx-forge-act hx-forge-startspec" data-forge-spec="${n}" aria-label="Start a spec for issue ${n}"${ui.busy ? ' disabled' : ''}>Start a spec …</button>`
|
|
22
|
+
: '';
|
|
23
|
+
const agent = `<button data-corn-kind="secondary" type="button" class="hx-btn hx-forge-act hx-forge-startspec" data-forge-agent="issue:${n}" aria-label="${escHtml(t('startAgent'))} on issue ${n}">${escHtml(t('startAgent'))} …</button>`;
|
|
24
|
+
return `<div class="hx-forge-cta">${agent}${spec}</div>`;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
/**
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
27
|
+
/**
|
|
28
|
+
* The issue the Work list names that the graph does not draw: a list already read holds it (the open one is read for this), else the issue's own route does (a closed one, or one past the end of the list).
|
|
29
|
+
* `null` says why in the list and through the live region when there is none.
|
|
30
|
+
*/
|
|
31
|
+
async function oldIssue(n) {
|
|
32
|
+
const key = listKeyOf('issues', 'open');
|
|
33
|
+
if (!ui.lists[key]) {
|
|
34
|
+
const res = await fn.request(listUrl('issues', 'open'), false);
|
|
35
|
+
if (res.ok && !ui.lists[key]) ui.lists[key] = { items: res.body.items || [], at: res.body.at, rate: res.body.rate || '', stale: res.body.stale || '', problem: res.body.problem || '' };
|
|
36
|
+
}
|
|
37
|
+
const hit = Object.entries(ui.lists).filter(([k]) => k.startsWith('issues|')).flatMap(([, list]) => list.items).find((i) => i.number === n); // any list read, whatever its state filter
|
|
38
|
+
if (hit) return hit;
|
|
39
|
+
const res = await fn.request(issueUrl(n));
|
|
40
|
+
if (res.ok && res.body.issue) return res.body.issue;
|
|
41
|
+
fn.linkMissing(res.status === 404 ? `There is no issue ${n}.` : fn.failWords(res, `issue ${n}`));
|
|
42
|
+
return null;
|
|
40
43
|
}
|
|
41
44
|
|
|
42
|
-
Object.assign(fn, {
|
|
45
|
+
Object.assign(fn, { issueActionsHtml, oldIssue });
|
|
43
46
|
}
|
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module explorer/pieces/work-list
|
|
3
|
+
*
|
|
4
|
+
* The Work list (spec 0012 D6): opening and closing it (the List toggle of the Work view), what a click, a change, an input and a key in it do, and how a row selects its node.
|
|
5
|
+
* A row never shows the detail: it names a piece of work (`data-work-ref="pull:27"`), the Work view selects that node on the map, and the node panel shows it and its actions
|
|
6
|
+
* (`showDetail` below reads what it needs; pieces/work-paint.js `paintDetail` draws it). Work the graph does not draw (older than its 14 days, past its caps) is shown by the same path:
|
|
7
|
+
* `showRef` makes its node from what the lists read (work-model.js `oldItem`) and puts it in the node panel without selecting anything on the map.
|
|
8
|
+
* Part of the Work piece (pieces/work.js): `install(ctx)` makes this part's functions for one mount, and hands the ones other parts call
|
|
9
|
+
* to `ctx.fn`; nothing is shared between two mounts.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { workStatus } from '../agents-model.js';
|
|
13
|
+
import { defaultFilters, filterItems, listKeyOf, listUrl, threadUrl, pullUrl } from '../forge-panel-model.js';
|
|
14
|
+
import { specGroups } from '../waiting-model.js';
|
|
15
|
+
import { oldItem, oldNode } from '../work-model.js';
|
|
16
|
+
import { clearSelection } from '../engine/selection.js';
|
|
17
|
+
import { plural, TABS, SEARCH_ANNOUNCE_MS } from './work-common.js';
|
|
18
|
+
|
|
19
|
+
export function install(ctx) {
|
|
20
|
+
const { inst, ui, m, fn, state, $ } = ctx;
|
|
21
|
+
const { announce, isPhone, expandSheet, collapseSheet, showSheet, nodeById, selectNode, clearResult, resultOf, showResultIn, setT, clearT } = ctx.h;
|
|
22
|
+
|
|
23
|
+
const isForgeOpen = () => ui.open;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Opens the list with the focus on its title; the first time, loads what its tab shows (the proposals, to start with).
|
|
27
|
+
* `tab` opens it on that tab ('specs', 'pulls', 'issues', 'threads', 'work' for Runs, 'deploys'), whichever was shown last otherwise. `quiet`: the list is read without
|
|
28
|
+
* saying how many it holds (an address for old work: what the node panel shows is what is said).
|
|
29
|
+
*/
|
|
30
|
+
function openForge({ load = true, tab, quiet = false } = {}) {
|
|
31
|
+
const panel = $('forge-panel');
|
|
32
|
+
if (!panel || panel.hidden) return;
|
|
33
|
+
if (tab && tab !== (ui.kind === 'notes' ? 'pulls' : ui.kind) && TABS.includes(tab)) { // the Release notes are one level down on PRs
|
|
34
|
+
ui.kind = tab;
|
|
35
|
+
ui.filters = defaultFilters(tab);
|
|
36
|
+
ui.actNote = null;
|
|
37
|
+
} else if (!tab && load && !ui.open) {
|
|
38
|
+
// Opened by a toggle: on the tab with the oldest thing waiting on you, else the tab used last (spec 0010 D2)
|
|
39
|
+
const oldest = fn.waitingNow().oldest;
|
|
40
|
+
if (oldest && oldest !== ui.kind) {
|
|
41
|
+
ui.kind = oldest;
|
|
42
|
+
ui.filters = defaultFilters(oldest);
|
|
43
|
+
ui.actNote = null;
|
|
44
|
+
fn.paintFilters();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
ui.open = true;
|
|
48
|
+
panel.inert = false;
|
|
49
|
+
panel.classList.add('forge-open');
|
|
50
|
+
if (isPhone()) { showSheet('forge'); if (tab) expandSheet('forge'); } // a peek (it takes the place of the node panel's sheet: spec 0010 D7); only a link that names a tab opens it expanded
|
|
51
|
+
fn.paintButton();
|
|
52
|
+
const title = $('forge-title');
|
|
53
|
+
title.focus();
|
|
54
|
+
announce('Work list');
|
|
55
|
+
inst.emit('work:list', { open: true });
|
|
56
|
+
if (!load) return; // a deep link loads the list it wants itself
|
|
57
|
+
if (!tab) fn.primeCounts(); // opened by a toggle, not for a tab: the other tabs' counts are read quietly
|
|
58
|
+
if (ui.kind === 'notes') { if (!ui.notes.data && !ui.notes.loading) fn.loadNotes(); else fn.paint(); return; }
|
|
59
|
+
if (ui.kind === 'specs' || !fn.current()) { fn.paintFilters(); fn.loadList(false, quiet); } else fn.paint();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** What a link names is not there: a line in the list, said through the live region */
|
|
63
|
+
function linkMissing(words) {
|
|
64
|
+
ui.actNote = { ok: false, text: words };
|
|
65
|
+
fn.paint();
|
|
66
|
+
announce(words);
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Closes the list. The node panel keeps what it shows. */
|
|
71
|
+
function closeForge({ restoreFocus = true } = {}) {
|
|
72
|
+
const panel = $('forge-panel');
|
|
73
|
+
if (!panel || !ui.open) return;
|
|
74
|
+
const hadFocus = panel.contains(inst.active());
|
|
75
|
+
ui.open = false;
|
|
76
|
+
panel.classList.remove('forge-open');
|
|
77
|
+
panel.inert = true;
|
|
78
|
+
collapseSheet('forge');
|
|
79
|
+
fn.paintButton();
|
|
80
|
+
const back = m.openerEl && m.openerEl.isConnected ? m.openerEl : ctx.root.querySelector('[data-action="toggle-forge"]');
|
|
81
|
+
if (restoreFocus && hadFocus && back) back.focus();
|
|
82
|
+
inst.emit('work:list', { open: false });
|
|
83
|
+
announce('Work list closed');
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const toggleForge = () => (ui.open ? closeForge() : openForge());
|
|
87
|
+
|
|
88
|
+
/** After a filter changes: the list again, and how many it holds */
|
|
89
|
+
function filtersChanged(announceNow = true) {
|
|
90
|
+
fn.paint();
|
|
91
|
+
const list = fn.current();
|
|
92
|
+
if (announceNow && list && ui.kind === 'work') announce(workStatus(fn.groupsShown(), '', m.now()));
|
|
93
|
+
else if (announceNow && list) announce(`${filterItems(list.items, ui.kind, ui.filters).length} of ${plural(list.items.length, fn.kindWords())} shown`);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** A click in the list: the tabs, a spec group's fold, a row (it selects its node), the filters, Release notes, the New idea form */
|
|
97
|
+
function onClick(e) {
|
|
98
|
+
const t = e.target;
|
|
99
|
+
if (!t.closest) return;
|
|
100
|
+
const kind = t.closest('[data-forge-kind]');
|
|
101
|
+
if (kind) {
|
|
102
|
+
if (kind.dataset.forgeKind === ui.kind) return;
|
|
103
|
+
ui.kind = kind.dataset.forgeKind;
|
|
104
|
+
ui.actNote = null;
|
|
105
|
+
ui.filters = defaultFilters(ui.kind);
|
|
106
|
+
fn.paintFilters();
|
|
107
|
+
// The proposals are asked for again each time (worktrees come and go); the other lists keep what they have
|
|
108
|
+
if (ui.kind === 'specs') { fn.paint(); fn.loadList(false, true); announce(fn.current() ? `${plural(fn.current().items.length, 'spec')} shown` : 'Looking for proposals'); } else if (fn.current()) filtersChanged(); else { fn.paint(); fn.loadList(); }
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
const fold = t.closest('[data-spec-group-toggle]');
|
|
112
|
+
if (fold) {
|
|
113
|
+
// Drafts folded behind their header, opened by hand and folded again; the focus stays on the header (findAgain)
|
|
114
|
+
const drafts = specGroups(fn.specsList() ? fn.specsList().items : [], { query: ui.specQuery }).find((g) => g.key === 'drafts');
|
|
115
|
+
const folded = ui.draftsOpen === null ? !!(drafts && drafts.collapsed) : !ui.draftsOpen;
|
|
116
|
+
ui.draftsOpen = folded;
|
|
117
|
+
fn.paint();
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
const row = t.closest('[data-work-ref]');
|
|
121
|
+
if (row) {
|
|
122
|
+
const ref = row.dataset.workRef;
|
|
123
|
+
// A row already shown goes into the node panel, as Enter on the map does: the focus otherwise stays on the row, so the list can be read down
|
|
124
|
+
if (m.rowRef === ref && isShown(ref)) { inst.emit('node:focus'); return; }
|
|
125
|
+
m.rowRef = ref; // the row the node panel's Escape gives the focus back to (`rowBack`)
|
|
126
|
+
const at = ref.indexOf(':');
|
|
127
|
+
fn.showRef(ref.slice(0, at), ref.slice(at + 1)).then((shown) => {
|
|
128
|
+
// On a phone the list gave way to the node's sheet: the focus, left in a list that is gone, goes into the node panel
|
|
129
|
+
const now = inst.active();
|
|
130
|
+
if (shown && !ctx.dead && (!now || now === inst.doc.body || now.closest('[inert]'))) inst.emit('node:focus');
|
|
131
|
+
}).catch(() => {});
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
const action = t.closest('[data-action]');
|
|
135
|
+
if (!action) return;
|
|
136
|
+
if (action.dataset.action === 'close-forge') closeForge();
|
|
137
|
+
else if (action.dataset.action === 'refresh-forge' || action.dataset.action === 'retry-forge') fn.refreshForge();
|
|
138
|
+
else if (action.dataset.action === 'clear-specs-search') {
|
|
139
|
+
ui.specQuery = '';
|
|
140
|
+
const box = $('specs-search');
|
|
141
|
+
if (box) { box.value = ''; }
|
|
142
|
+
fn.paint();
|
|
143
|
+
announce(fn.specsShownWords());
|
|
144
|
+
if (box) box.focus();
|
|
145
|
+
}
|
|
146
|
+
else if (action.dataset.action === 'copy-notes') fn.copyNotes();
|
|
147
|
+
else if (action.dataset.action === 'post-notes') { if (ui.notes.confirm) fn.closeNotesConfirm(); else fn.openNotesConfirm(); }
|
|
148
|
+
else if (action.dataset.action === 'confirm-notes') fn.postDraft();
|
|
149
|
+
else if (action.dataset.action === 'cancel-notes') { fn.closeNotesConfirm(); announce('Cancelled. Nothing was posted.'); }
|
|
150
|
+
else if (action.dataset.action === 'toggle-filters') { ui.filtersOpen = !ui.filtersOpen; fn.paintChip(); }
|
|
151
|
+
else if (action.dataset.action === 'open-notes') fn.openNotes();
|
|
152
|
+
else if (action.dataset.action === 'close-notes') fn.closeNotes();
|
|
153
|
+
else if (action.dataset.action === 'idea-open') fn.toggleIdea(!ui.idea.open);
|
|
154
|
+
else if (action.dataset.action === 'idea-send') {
|
|
155
|
+
// Nothing of it may escape as an unhandled rejection: what went wrong is said, and the form is usable again
|
|
156
|
+
fn.sendIdea().catch((err) => {
|
|
157
|
+
ui.idea.busy = false;
|
|
158
|
+
ui.idea.message = `Something went wrong in the page: ${err instanceof Error ? err.message : err}`;
|
|
159
|
+
ui.idea.bad = true;
|
|
160
|
+
fn.paintIdea();
|
|
161
|
+
announce(ui.idea.message);
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
else if (action.dataset.action === 'idea-cancel') { fn.toggleIdea(false); announce('Cancelled. Nothing was opened.'); }
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** A click in the node panel's actions (spec 0012 D5): Land it, Re-run, Start an agent, a run's answer, Stop, Cancel a landing ... today's confirms and server checks, unchanged */
|
|
168
|
+
function onDetailClick(e) {
|
|
169
|
+
const t = e.target;
|
|
170
|
+
if (!t.closest) return;
|
|
171
|
+
const nodeBtn = t.closest('[data-forge-node]');
|
|
172
|
+
if (nodeBtn) {
|
|
173
|
+
const node = nodeById(nodeBtn.dataset.forgeNode);
|
|
174
|
+
if (!node) return;
|
|
175
|
+
selectNode(node, { frame: true });
|
|
176
|
+
announce(`${node.label}, ${node.type}`);
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
const agent = t.closest('[data-forge-agent]');
|
|
180
|
+
if (agent) { fn.openAgent(agent.dataset.forgeAgent, `[data-forge-agent="${agent.dataset.forgeAgent}"]`); return; }
|
|
181
|
+
const stop = t.closest('[data-forge-stop]');
|
|
182
|
+
if (stop) { fn.stopRun(stop.dataset.forgeStop); return; }
|
|
183
|
+
const retry = t.closest('[data-forge-retry]');
|
|
184
|
+
if (retry) { fn.startAgain(retry.dataset.forgeRetry); return; }
|
|
185
|
+
const goto = t.closest('[data-run-goto]');
|
|
186
|
+
if (goto) { fn.goToRun(goto.dataset.runGoto); return; }
|
|
187
|
+
const answer = t.closest('[data-run-answer]');
|
|
188
|
+
if (answer) { fn.answerRun(answer.dataset.runId, answer.dataset.runAnswer); return; }
|
|
189
|
+
const discard = t.closest('[data-run-discard]');
|
|
190
|
+
if (discard) { fn.discardReply(discard.dataset.runDiscard); return; }
|
|
191
|
+
const timeline = t.closest('[data-run-timeline]');
|
|
192
|
+
if (timeline) { fn.toggleTimeline(timeline.dataset.runTimeline); return; }
|
|
193
|
+
const unland = t.closest('[data-forge-landing-cancel]');
|
|
194
|
+
if (unland) { fn.cancelLanding(Number(unland.dataset.forgeLandingCancel)); return; }
|
|
195
|
+
const merge = t.closest('[data-forge-merge]');
|
|
196
|
+
if (merge) { fn.openConfirm('[data-forge-merge]'); return; }
|
|
197
|
+
const spec = t.closest('[data-forge-spec]');
|
|
198
|
+
if (spec) { fn.askPlan('spec', Number(spec.dataset.forgeSpec), null, `[data-forge-spec="${spec.dataset.forgeSpec}"]`); return; }
|
|
199
|
+
const build = t.closest('[data-forge-build]');
|
|
200
|
+
if (build && ui.selected !== null) { fn.askPlan('build', ui.selected, build.dataset.forgeBuild, `[data-forge-build="${build.dataset.forgeBuild}"]`); return; }
|
|
201
|
+
const rerun = t.closest('[data-forge-rerun]');
|
|
202
|
+
if (rerun) { fn.rerunCheck(rerun.dataset.forgeRerun); return; }
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function onChange(e) {
|
|
206
|
+
const id = e.target.id;
|
|
207
|
+
if (id === 'notes-since') {
|
|
208
|
+
ui.notes.since = e.target.value;
|
|
209
|
+
ui.notes.message = '';
|
|
210
|
+
fn.loadNotes();
|
|
211
|
+
} else if (id === 'forge-state') {
|
|
212
|
+
ui.filters.state = e.target.value;
|
|
213
|
+
fn.paintFilters();
|
|
214
|
+
if (fn.current()) filtersChanged(); else { fn.paint(); fn.loadList(); }
|
|
215
|
+
} else if (id === 'forge-work-agents' || id === 'forge-work-finished') {
|
|
216
|
+
if (id === 'forge-work-agents') ui.workFilters.agentsOnly = e.target.checked;
|
|
217
|
+
else ui.workFilters.finished = e.target.checked;
|
|
218
|
+
fn.paint();
|
|
219
|
+
announce(workStatus(fn.groupsShown(), '', m.now()));
|
|
220
|
+
} else if (id === 'forge-label') {
|
|
221
|
+
ui.filters.label = e.target.value;
|
|
222
|
+
filtersChanged();
|
|
223
|
+
} else if (id === 'forge-author') {
|
|
224
|
+
ui.filters.author = e.target.value;
|
|
225
|
+
filtersChanged();
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function onInput(e) {
|
|
230
|
+
if (e.target.id === 'specs-search') {
|
|
231
|
+
ui.specQuery = e.target.value;
|
|
232
|
+
fn.paint();
|
|
233
|
+
clearT(m.searchTimer);
|
|
234
|
+
m.searchTimer = setT(() => announce(fn.specsShownWords()), SEARCH_ANNOUNCE_MS);
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
if (e.target.id !== 'forge-text') return;
|
|
238
|
+
ui.filters.text = e.target.value;
|
|
239
|
+
filtersChanged(false);
|
|
240
|
+
clearT(m.searchTimer);
|
|
241
|
+
m.searchTimer = setT(() => filtersChanged(), SEARCH_ANNOUNCE_MS);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/** A reply being typed in a run's card is kept, so a repaint (the runs are looked at again) brings it back */
|
|
245
|
+
function onDetailInput(e) {
|
|
246
|
+
if (!(e.target.dataset && e.target.dataset.runReply)) return;
|
|
247
|
+
const id = e.target.dataset.runReply;
|
|
248
|
+
ui.runReplies.set(id, e.target.value);
|
|
249
|
+
// "Write a reply first" goes once something is written: a refusal does not outlive what it was about
|
|
250
|
+
const said = resultOf(id);
|
|
251
|
+
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); }
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/** Enter in a run's reply field sends it (the node panel's own Escape closes the panel; a field keeps its own) */
|
|
255
|
+
function onDetailKey(e) {
|
|
256
|
+
if (e.key === 'Enter' && e.target.dataset && e.target.dataset.runReply && !e.defaultPrevented) { e.preventDefault(); fn.answerRun(e.target.dataset.runReply, 'reply'); }
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/** Escape anywhere in the list closes it, and the toggle has the focus again (a field's own Escape comes first) */
|
|
260
|
+
function onKey(e) {
|
|
261
|
+
if (e.key === 'Enter' && e.target.id === 'notes-tag' && !e.defaultPrevented) { e.preventDefault(); fn.postDraft(); return; }
|
|
262
|
+
if (e.key === 'Escape' && !e.defaultPrevented && ui.notes.confirm && e.target.closest && e.target.closest('#notes-confirm')) {
|
|
263
|
+
e.preventDefault();
|
|
264
|
+
fn.closeNotesConfirm();
|
|
265
|
+
announce('Cancelled. Nothing was posted.');
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
if (e.key !== 'Escape' || e.defaultPrevented) return;
|
|
269
|
+
if (e.target.closest && e.target.closest('select, input, textarea')) return;
|
|
270
|
+
e.preventDefault();
|
|
271
|
+
closeForge();
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// ---------------------------------------------------------------------------
|
|
275
|
+
// A row selects its node; the node panel shows the piece of work
|
|
276
|
+
// ---------------------------------------------------------------------------
|
|
277
|
+
|
|
278
|
+
/** The row a piece of work is: `pull:27`, `proposal:0100-flow`, `run:run-…`, `deploy:9004` */
|
|
279
|
+
const refOf = (item) => `${item.kind}:${item.kind === 'run' ? item.runId : item.kind === 'proposal' ? item.slug : item.kind === 'deploy' ? item.deployId : item.number}`;
|
|
280
|
+
|
|
281
|
+
/** Whether `ref` is the piece of work the node panel shows now: a row's pressed state (a spec's pull request is its proposal here, an idea's issue its thread) */
|
|
282
|
+
function isShown(ref) {
|
|
283
|
+
if (!ui.item) return false;
|
|
284
|
+
if (ui.ref === ref) return true;
|
|
285
|
+
const at = ref.indexOf(':');
|
|
286
|
+
const n = Number(ref.slice(at + 1));
|
|
287
|
+
const kind = ref.slice(0, at);
|
|
288
|
+
return (kind === 'pull' && ui.item.kind === 'proposal' && ui.item.number === n) || (kind === 'issue' && ui.item.kind === 'thread' && ui.item.number === n);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/** What the node panel says of a piece of work as it is read: said for work the graph does not draw; in the Work view the live region has said the node's name, kind, state and place (work-view.js), and this would only cover it */
|
|
292
|
+
const sayDetail = (words) => { if (m.sayDetail) announce(words); };
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Selects the piece of work a row (or a link) names: the Work view selects its node on the map and the node panel shows it; work the graph does not hold is made a node
|
|
296
|
+
* of `oldNode` and shown by the node panel alone. Resolves when the node panel has what it needs, true when there was something to show.
|
|
297
|
+
* @param {'pull' | 'issue' | 'thread' | 'run' | 'deploy' | 'proposal'} kind
|
|
298
|
+
* @param {string} key a number, a run id, a deploy id or a slug
|
|
299
|
+
*/
|
|
300
|
+
async function showRef(kind, key) {
|
|
301
|
+
m.shown = Promise.resolve();
|
|
302
|
+
if (inst.ask('work:pick', { kind, key }) === true) { await m.shown; return true; }
|
|
303
|
+
const item = await oldItemOf(kind, key);
|
|
304
|
+
if (!item || ctx.dead) return false;
|
|
305
|
+
clearSelection(inst, { source: 'api' }); // a selection and the panel are one: the map has none of this
|
|
306
|
+
inst.emit('node:show', { node: oldNode(item), frame: false });
|
|
307
|
+
await m.shown;
|
|
308
|
+
if (isPhone()) collapseSheet('forge');
|
|
309
|
+
return true;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/** What the lists know of a piece of work the graph does not draw: from a list already read, else from its own route; a name that is nowhere is said, never blank */
|
|
313
|
+
async function oldItemOf(kind, key) {
|
|
314
|
+
const n = Number(key);
|
|
315
|
+
if (kind === 'issue') { const src = await fn.oldIssue(n); return src && oldItem('issue', src); }
|
|
316
|
+
if (kind === 'pull') {
|
|
317
|
+
const res = await fn.request(pullUrl(n), false);
|
|
318
|
+
if (!res.ok || !res.body.pull) { fn.linkMissing(fn.failWords(res, `pull request ${n}`)); return null; }
|
|
319
|
+
m.preload = { kind: 'pull', n, res }; // the node panel's own read of it is this one
|
|
320
|
+
return oldItem('pull', res.body.pull);
|
|
321
|
+
}
|
|
322
|
+
if (kind === 'thread') {
|
|
323
|
+
const res = await fn.request(threadUrl(n), false);
|
|
324
|
+
const thread = res.ok && res.body.thread;
|
|
325
|
+
if (!thread) { fn.linkMissing(res.ok ? `Thread ${n} could not be read: the answer had no thread in it. Refresh to ask again.` : fn.failWords(res, `thread ${n}`)); return null; }
|
|
326
|
+
m.preload = { kind: 'thread', n, res };
|
|
327
|
+
return oldItem('thread', thread);
|
|
328
|
+
}
|
|
329
|
+
if (kind === 'run') {
|
|
330
|
+
if (!(ui.runs && ui.runs.data)) await fn.loadRuns(false, { say: false });
|
|
331
|
+
let run = fn.runById(key);
|
|
332
|
+
if (!run && ui.runs && ui.runs.data) { await fn.loadRuns(true, { say: false }); run = fn.runById(key); } // a run asked for a moment ago may not be in what was read before
|
|
333
|
+
if (!run) { fn.linkMissing(ui.runs && ui.runs.data ? `There is no run ${key}.` : (ui.runs && ui.runs.error) || 'The runs could not be read.'); return null; }
|
|
334
|
+
return oldItem('run', run);
|
|
335
|
+
}
|
|
336
|
+
if (kind === 'deploy') {
|
|
337
|
+
if (!ui.lists[listKeyOf('deploys')]) {
|
|
338
|
+
const res = await fn.request(listUrl('deploys', 'all'), false);
|
|
339
|
+
if (res.ok) ui.lists[listKeyOf('deploys')] = { items: res.body.items || [], at: res.body.at, rate: res.body.rate || '', stale: res.body.stale || '', problem: res.body.problem || '' };
|
|
340
|
+
}
|
|
341
|
+
const hit = ui.lists.deploys && ui.lists.deploys.items.find((d) => d.id === key);
|
|
342
|
+
if (!hit) { fn.linkMissing(`There is no deploy ${key} among the last hundred.`); return null; }
|
|
343
|
+
return oldItem('deploy', hit);
|
|
344
|
+
}
|
|
345
|
+
if (kind === 'proposal') {
|
|
346
|
+
if (!fn.specsList()) await fn.loadSpecs(m.listToken, true);
|
|
347
|
+
const items = fn.specsList() ? fn.specsList().items : [];
|
|
348
|
+
const hit = items.find((e) => e.slug === key) || items.find((e) => String(e.slug).startsWith(`${key}-`));
|
|
349
|
+
if (!hit) { fn.linkMissing(`There is no proposal ${key}.`); return null; }
|
|
350
|
+
return oldItem('proposal', hit);
|
|
351
|
+
}
|
|
352
|
+
return null;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/** The node panel shows a piece of work (`node:painted`): what it needs is read, and its actions are drawn into it */
|
|
356
|
+
function showDetail(node) {
|
|
357
|
+
const item = node.item;
|
|
358
|
+
const ref = refOf(item);
|
|
359
|
+
if (ui.node === node.id && ui.ref === ref && ui.item === item) { fn.paint(); return Promise.resolve(); } // the same node, its panel drawn again: the place of its actions is new, what it holds is not
|
|
360
|
+
dropDetail();
|
|
361
|
+
ui.node = node.id;
|
|
362
|
+
ui.ref = ref;
|
|
363
|
+
ui.item = item;
|
|
364
|
+
m.sayDetail = node.old === true;
|
|
365
|
+
switch (item.kind) {
|
|
366
|
+
case 'pull': return fn.selectPull(item.number);
|
|
367
|
+
case 'thread': return fn.selectThread(item.number);
|
|
368
|
+
case 'deploy': return fn.showDeploy(item.deployId);
|
|
369
|
+
case 'run': return fn.showRun(item.runId);
|
|
370
|
+
// A spec pull request is a proposal here: its Review, and what its pull request has (Land it, the checks, Open the build issue, a landing waiting on its approval)
|
|
371
|
+
case 'proposal': if (Number.isInteger(item.number)) { fn.paint(); return fn.selectPull(item.number); } fn.paint(); sayDetail(`Proposal ${item.slug}: ${node.title}.`); return Promise.resolve();
|
|
372
|
+
default: fn.paint(); sayDetail(`Issue ${item.number}: ${node.title}${item.state ? `. It is ${item.state}` : ''}.`); return Promise.resolve(); // the words the side panel said of an issue a link named
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* Where the focus goes when the node panel closes (`node:back`): to the row of the open list that chose what it shows. Asked before the panel lets go, it answers with
|
|
378
|
+
* what gives that row the focus once the list is drawn again (true when it did), or nothing: the map has it.
|
|
379
|
+
*/
|
|
380
|
+
function rowBack() {
|
|
381
|
+
const ref = m.rowRef;
|
|
382
|
+
if (!ui.open || !ref || !isShown(ref)) return undefined;
|
|
383
|
+
return () => {
|
|
384
|
+
const row = ui.open && [...$('forge-panel').querySelectorAll('[data-work-ref]')].find((r) => r.dataset.workRef === ref);
|
|
385
|
+
if (!row || row.closest('[hidden]')) return false;
|
|
386
|
+
row.focus();
|
|
387
|
+
return true;
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/** The node panel shows something else, or closed: what it held is let go of */
|
|
392
|
+
function dropDetail() {
|
|
393
|
+
if (!ui.node && !ui.selected && ui.thread === null && !ui.deployItem && !ui.runShown) return;
|
|
394
|
+
fn.clearPull();
|
|
395
|
+
fn.clearThread();
|
|
396
|
+
fn.clearDeploy();
|
|
397
|
+
ui.runShown = null;
|
|
398
|
+
ui.node = '';
|
|
399
|
+
ui.ref = '';
|
|
400
|
+
ui.item = null;
|
|
401
|
+
ui.note = null;
|
|
402
|
+
fn.paint();
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
Object.assign(fn, { isForgeOpen, openForge, linkMissing, closeForge, toggleForge, filtersChanged, onClick, onDetailClick, onChange, onInput, onDetailInput, onDetailKey, onKey, refOf, isShown, sayDetail, showRef, showDetail, rowBack, dropDetail });
|
|
406
|
+
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module explorer/pieces/work-markup
|
|
3
3
|
*
|
|
4
|
-
* The Work piece's markup (spec 0011 D3
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* The Work piece's markup (spec 0011 D3, spec 0012 D6): the Work list (the panel's lists, opened by the List toggle of the Work view), the layer of marks
|
|
5
|
+
* over the map, and the two dialogs the actions open (the confirm step and Start an agent), which sit at the end of the page, over a scrim. A piece of
|
|
6
|
+
* work's detail and actions are the node panel's (work-model.js `workPanelHtml` puts its place, `forge-detail`, in the panel). Every `data-corn` element also gets its `part` when
|
|
7
|
+
* the piece places it (engine/piece.js).
|
|
7
8
|
*/
|
|
8
9
|
|
|
9
10
|
import { withParts } from '../engine/piece.js';
|
|
@@ -12,19 +13,12 @@ import { withParts } from '../engine/piece.js';
|
|
|
12
13
|
export const markup = () => Object.fromEntries(Object.entries(markupOf()).map(([slot, html]) => [slot, withParts(html)]));
|
|
13
14
|
|
|
14
15
|
const markupOf = () => ({
|
|
15
|
-
/** The Work
|
|
16
|
-
|
|
17
|
-
<span data-corn-string="issuesAndPrs">Work</span>
|
|
18
|
-
<span id="forge-btn-lit" class="hx-forge-lit" data-corn="count" hidden></span>
|
|
19
|
-
<span id="forge-btn-dot" class="hx-runner-dot" aria-hidden="true" title="No runner online" hidden></span>
|
|
20
|
-
<span id="forge-btn-waiting" class="hx-waiting-badge" data-corn="waiting-badge" aria-hidden="true" hidden></span>
|
|
21
|
-
</button>`,
|
|
22
|
-
/** Specs, PRs, Issues, Threads, Runs and Deploys, in the order of the loop: a slide-over from the left on desktop, a bottom sheet on a phone; hidden and inert until the config names a forge. `forge-panel` on the inner box is the old name of the hook, kept for one release (docs/theming.md) */
|
|
23
|
-
panel: `<aside id="forge-panel" class="hx-forge glass" aria-label="Work" inert hidden data-corn="work-panel">
|
|
16
|
+
/** The Work list: 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 Work view opens it. A row selects its node; the detail is the node panel's. `forge-panel` on the inner box is the old name of the hook, kept for one release (docs/theming.md) */
|
|
17
|
+
panel: `<aside id="forge-panel" class="hx-forge glass" aria-label="Work list" inert hidden data-corn="work-panel">
|
|
24
18
|
<div class="hx-forge-body" data-corn="forge-panel">
|
|
25
19
|
<div class="hx-forge-top" data-corn="work-top">
|
|
26
20
|
<div class="hx-forge-head" data-corn="work-head">
|
|
27
|
-
<h2 id="forge-title" class="hx-drawer-title" data-corn="work-title" tabindex="-1">Work</h2>
|
|
21
|
+
<h2 id="forge-title" class="hx-drawer-title" data-corn="work-title" tabindex="-1">Work list</h2>
|
|
28
22
|
<button type="button" class="hx-btn hx-btn--quiet" data-action="refresh-forge" title="Ask the forge again" data-corn-kind="quiet">Refresh</button>
|
|
29
23
|
<button type="button" class="hx-close" data-action="close-forge" aria-label="Close" data-corn-kind="icon">✕</button>
|
|
30
24
|
</div>
|
|
@@ -86,9 +80,8 @@ const markupOf = () => ({
|
|
|
86
80
|
<p id="forge-runs-trigger" class="hx-forge-notice" hidden data-corn="notice"></p>
|
|
87
81
|
<div id="forge-runs-totals" data-corn="run-totals" role="group" aria-label="Tokens and cost the runners reported" hidden></div>
|
|
88
82
|
<ul id="forge-runs-hand" class="hx-forge-meta" aria-label="Requests written by hand that started nothing" hidden></ul>
|
|
89
|
-
<ul id="forge-runs-list" class="hx-forge-
|
|
83
|
+
<ul id="forge-runs-list" class="hx-forge-list" aria-label="Runs"></ul>
|
|
90
84
|
</section>
|
|
91
|
-
<section id="forge-detail" class="hx-forge-detail" aria-label="Selected pull request" hidden></section>
|
|
92
85
|
<ul id="forge-list" class="hx-forge-list" aria-label="Results"></ul>
|
|
93
86
|
<div id="forge-foot" class="hx-forge-foot" data-corn="work-foot">
|
|
94
87
|
<button data-corn-kind="secondary" type="button" id="notes-open" class="hx-btn" data-action="open-notes" hidden>Release notes …</button>
|
|
@@ -153,3 +146,4 @@ const markupOf = () => ({
|
|
|
153
146
|
</div>
|
|
154
147
|
</div>`,
|
|
155
148
|
});
|
|
149
|
+
|
|
@@ -150,7 +150,6 @@ export function install(ctx) {
|
|
|
150
150
|
const notice = $('forge-notice');
|
|
151
151
|
const words = n.error || (n.data && n.data.stale ? `Showing an older answer. ${n.data.stale}` : '');
|
|
152
152
|
fn.setNotice(notice, words, !!words);
|
|
153
|
-
$('forge-detail').hidden = true;
|
|
154
153
|
fn.paintIdea();
|
|
155
154
|
$('forge-rate').textContent = (n.data && n.data.rate) || '';
|
|
156
155
|
paintNotes();
|