@popcorn245/cornfield 0.50.0 → 0.50.1
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/explorer/focus-room.js +1 -7
- package/explorer/focusables.js +1 -1
- package/explorer/forge-panel.js +36 -2630
- package/explorer/index.html +15 -147
- package/explorer/instance-state.js +0 -7
- package/explorer/instance.js +16 -1
- package/explorer/page-pieces.js +21 -2
- package/explorer/page.js +3 -3
- package/explorer/panels.js +1 -5
- package/explorer/pieces/layers.js +1 -0
- package/explorer/pieces/node-panel.js +15 -5
- package/explorer/pieces/proposal.js +9 -0
- package/explorer/pieces/work-agent.js +211 -0
- package/explorer/pieces/work-common.js +88 -0
- package/explorer/pieces/work-confirm.js +169 -0
- package/explorer/pieces/work-data.js +178 -0
- package/explorer/pieces/work-deploys.js +104 -0
- package/explorer/pieces/work-events.js +285 -0
- package/explorer/pieces/work-issues.js +43 -0
- package/explorer/pieces/work-markup.js +155 -0
- package/explorer/pieces/work-notes.js +177 -0
- package/explorer/pieces/work-paint.js +312 -0
- package/explorer/pieces/work-prs.js +253 -0
- package/explorer/pieces/work-runs.js +387 -0
- package/explorer/pieces/work-specs.js +71 -0
- package/explorer/pieces/work-threads.js +309 -0
- package/explorer/pieces/work.js +285 -0
- package/explorer/proposal.js +1 -2
- package/explorer/runs-map.js +108 -103
- package/explorer/runs-view.js +8 -6
- package/explorer/strings.js +1 -1
- package/explorer/waiting-model.js +12 -12
- package/explorer/waiting-view.js +6 -6
- package/package.json +1 -1
- package/explorer/feedback.js +0 -15
- package/explorer/waiting-line.js +0 -14
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module explorer/pieces/work-agent
|
|
3
|
+
*
|
|
4
|
+
* The Start an agent dialog (a modal dialog over a scrim). 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
|
+
* to `ctx.fn`; nothing is shared between two mounts.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { RUNS_URL, canRetry, retryRefs, retryWords, limitsFromFields, defaultLimits, LIMIT_KEYS, briefUrl, KINDS, aboutWords, startBody, startWords, confirmStartWords } from '../runs-model.js';
|
|
9
|
+
import { trapTab } from '../focusables.js';
|
|
10
|
+
import { option } from './work-common.js';
|
|
11
|
+
|
|
12
|
+
export function install(ctx) {
|
|
13
|
+
const { inst, ui, m, fn, root, $ } = ctx;
|
|
14
|
+
const { announce, t, trapFocus } = ctx.h;
|
|
15
|
+
|
|
16
|
+
const agentEl = () => $('agent-start');
|
|
17
|
+
|
|
18
|
+
/** While the dialog is open the focus cannot leave it */
|
|
19
|
+
function keepFocusInAgent(e) {
|
|
20
|
+
const el = agentEl();
|
|
21
|
+
if (ui.agent && el && !el.contains(inst.active())) $('agent-kind').focus(); // (the focus in the root's own tree: outside it, none)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Opens the Start an agent dialog for `issue:<n>` or `proposal:<slug>`; the focus goes to the first field. The limit fields hold what the request
|
|
26
|
+
* starts from (the config's, for the profile). With `again` (a run that failed or was stopped) it is **Start again**: the same kind, refs,
|
|
27
|
+
* profile, brief and limits filled in, all editable, and the request will carry `retryOf`. `brief` is that run's whole brief when the list's was cut
|
|
28
|
+
*/
|
|
29
|
+
async function openAgent(ref, opener, again = null, brief = null) {
|
|
30
|
+
if (!agentEl() || ui.agent || ui.confirm) return; // one dialog at a time
|
|
31
|
+
const at = ref.indexOf(':');
|
|
32
|
+
const type = ref.slice(0, at);
|
|
33
|
+
const value = ref.slice(at + 1);
|
|
34
|
+
const refs = again ? retryRefs(again) : type === 'proposal' ? { proposal: value } : { issue: Number(value) };
|
|
35
|
+
ui.agent = { opener, refs, posting: false, retryOf: again ? again.runId : null };
|
|
36
|
+
// The profiles the config lists come with the runs: asked for if the Agents tab has not been opened yet
|
|
37
|
+
if (!ui.runs) { await fn.loadRuns(false); if (ui.kind === 'work') fn.paint(); }
|
|
38
|
+
if (!ui.agent) return;
|
|
39
|
+
const profiles = (ui.runs && ui.runs.data && ui.runs.data.profiles) || [];
|
|
40
|
+
$('agent-start-about').textContent = `About ${aboutWords(refs)}`;
|
|
41
|
+
fn.paintRunner('agent-start-runner', ui.runs && ui.runs.data);
|
|
42
|
+
const kind = again ? again.kind : 'code';
|
|
43
|
+
// The old run's profile stays on offer even if the config no longer lists it: the server then says so, in its words
|
|
44
|
+
const shown = again && again.profile && !profiles.includes(again.profile) ? [...profiles, again.profile] : profiles;
|
|
45
|
+
$('agent-kind').innerHTML = KINDS.map(([v, l]) => option(v, l, v === kind)).join('');
|
|
46
|
+
$('agent-profile').innerHTML = option('', 'No profile', !(again && again.profile)) + shown.map((p) => option(p, p, !!again && p === again.profile)).join('');
|
|
47
|
+
$('agent-profile-field').hidden = !shown.length;
|
|
48
|
+
$('agent-profile').value = again && again.profile ? again.profile : ''; // as well as `selected`, which not every DOM honours
|
|
49
|
+
$('agent-start-title').textContent = again ? t('startAgain') : t('startAgent');
|
|
50
|
+
const note = $('agent-retry-note');
|
|
51
|
+
note.hidden = !again;
|
|
52
|
+
note.textContent = again ? retryWords(again) : '';
|
|
53
|
+
fillLimits(again ? again.limits || {} : limitDefaultsNow());
|
|
54
|
+
$('agent-brief').value = brief ?? (again && typeof again.brief === 'string' ? again.brief : '');
|
|
55
|
+
$('agent-force').checked = false;
|
|
56
|
+
$('agent-force-field').hidden = true;
|
|
57
|
+
$('agent-start-msg').hidden = true;
|
|
58
|
+
$('agent-start-msg').textContent = '';
|
|
59
|
+
$('agent-start-words').textContent = confirmStartWords(refs, fn.forgeName());
|
|
60
|
+
const go = $('agent-start-go');
|
|
61
|
+
go.disabled = false;
|
|
62
|
+
go.removeAttribute('aria-busy');
|
|
63
|
+
go.textContent = fn.askRunnerWords();
|
|
64
|
+
m.agentTrap = trapFocus(keepFocusInAgent);
|
|
65
|
+
agentEl().hidden = false;
|
|
66
|
+
$('agent-kind').focus();
|
|
67
|
+
announce(`${again ? t('startAgain') : t('startAgent')} on ${aboutWords(refs)}. ${confirmStartWords(refs, fn.forgeName())}`);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** "Start again" on a run that failed or was stopped. A brief the list shows cut is read whole first: the dialog never starts from part of one */
|
|
71
|
+
async function startAgain(runId) {
|
|
72
|
+
const run = ui.runs && ui.runs.data ? ui.runs.data.runs.find((r) => r.runId === runId) : null;
|
|
73
|
+
if (!run || !canRetry(run) || ui.agent || ui.retrying) return;
|
|
74
|
+
let brief = null;
|
|
75
|
+
if (run.briefCut) {
|
|
76
|
+
ui.retrying = true;
|
|
77
|
+
const res = await fn.request(briefUrl(runId), false);
|
|
78
|
+
ui.retrying = false;
|
|
79
|
+
if (!res.ok || typeof res.body.brief !== 'string') {
|
|
80
|
+
ui.runNote = { text: `The brief of ${runId} could not be read, so Start again did not open: ${fn.failWords(res)}`, ok: false };
|
|
81
|
+
fn.paint();
|
|
82
|
+
announce(ui.runNote.text);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
brief = res.body.brief;
|
|
86
|
+
}
|
|
87
|
+
const about = run.refs.proposal != null ? `proposal:${run.refs.proposal}` : `issue:${run.refs.issue ?? run.refs.thread}`;
|
|
88
|
+
openAgent(about, `[data-forge-retry="${runId}"]`, run, brief);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** The limits the config gives a request under the chosen profile */
|
|
92
|
+
const limitDefaultsNow = () => defaultLimits(ui.runs && ui.runs.data && ui.runs.data.limits, $('agent-profile-field').hidden ? '' : $('agent-profile').value);
|
|
93
|
+
|
|
94
|
+
/** What the four limit fields hold, as text */
|
|
95
|
+
const limitFields = () => Object.fromEntries(LIMIT_KEYS.map((k) => [k, $(`agent-limit-${k}`).value]));
|
|
96
|
+
|
|
97
|
+
/** Fills the four limit fields (blank where `limits` has none) and remembers what was filled */
|
|
98
|
+
function fillLimits(limits) {
|
|
99
|
+
for (const k of LIMIT_KEYS) {
|
|
100
|
+
const field = $(`agent-limit-${k}`);
|
|
101
|
+
field.value = limits && limits[k] != null ? String(limits[k]) : '';
|
|
102
|
+
field.removeAttribute('aria-invalid');
|
|
103
|
+
field.removeAttribute('aria-describedby');
|
|
104
|
+
}
|
|
105
|
+
if (ui.agent) ui.agent.filled = JSON.stringify(limitFields());
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** Another profile: its limits fill the fields, unless the person has typed in them */
|
|
109
|
+
function onAgentProfile() {
|
|
110
|
+
if (ui.agent && ui.agent.filled === JSON.stringify(limitFields())) fillLimits(limitDefaultsNow());
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** Closes the dialog; the focus goes back to the button that opened it unless told not to */
|
|
114
|
+
function closeAgent({ restoreFocus = true } = {}) {
|
|
115
|
+
const el = agentEl();
|
|
116
|
+
if (!el || !ui.agent) return;
|
|
117
|
+
const { opener } = ui.agent;
|
|
118
|
+
ui.agent = null;
|
|
119
|
+
el.hidden = true;
|
|
120
|
+
if (m.agentTrap) { m.agentTrap(); m.agentTrap = null; }
|
|
121
|
+
if (!restoreFocus) return;
|
|
122
|
+
const back = root.querySelector(opener) || $('forge-title'); // the node panel's Start a run is an opener too
|
|
123
|
+
if (back && !back.disabled) back.focus();
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** The one write: posts the choices once; a refusal stays in the dialog, in the server's words */
|
|
127
|
+
async function submitAgent(e) {
|
|
128
|
+
e.preventDefault();
|
|
129
|
+
if (!ui.agent || ui.agent.posting) return;
|
|
130
|
+
ui.agent.posting = true;
|
|
131
|
+
const go = $('agent-start-go');
|
|
132
|
+
go.disabled = true;
|
|
133
|
+
go.setAttribute('aria-busy', 'true');
|
|
134
|
+
go.textContent = 'Asking …';
|
|
135
|
+
$('agent-start-msg').hidden = true;
|
|
136
|
+
const again = ui.agent.retryOf;
|
|
137
|
+
const fields = limitFields();
|
|
138
|
+
const limits = limitsFromFields(fields);
|
|
139
|
+
// Each field that is not a number above zero is marked, and the first has the focus; the message says why
|
|
140
|
+
const wrong = LIMIT_KEYS.filter((k) => limitsFromFields({ [k]: fields[k] }) === null);
|
|
141
|
+
for (const k of LIMIT_KEYS) {
|
|
142
|
+
const field = $(`agent-limit-${k}`);
|
|
143
|
+
if (wrong.includes(k)) { field.setAttribute('aria-invalid', 'true'); field.setAttribute('aria-describedby', 'agent-start-msg'); } else { field.removeAttribute('aria-invalid'); field.removeAttribute('aria-describedby'); }
|
|
144
|
+
}
|
|
145
|
+
if (limits === null) {
|
|
146
|
+
ui.agent.posting = false;
|
|
147
|
+
go.disabled = false;
|
|
148
|
+
go.removeAttribute('aria-busy');
|
|
149
|
+
go.textContent = fn.askRunnerWords();
|
|
150
|
+
const bad = $('agent-start-msg');
|
|
151
|
+
bad.textContent = `A limit is a number above zero, or blank for the config's (${wrong.join(', ')}).`;
|
|
152
|
+
bad.hidden = false;
|
|
153
|
+
$(`agent-limit-${wrong[0]}`).focus();
|
|
154
|
+
announce(bad.textContent);
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
const res = await fn.post(RUNS_URL, startBody({
|
|
158
|
+
kind: $('agent-kind').value, profile: $('agent-profile-field').hidden ? '' : $('agent-profile').value, brief: $('agent-brief').value, refs: ui.agent.refs, force: $('agent-force').checked,
|
|
159
|
+
limits, ...(again ? { retryOf: again } : {}),
|
|
160
|
+
}));
|
|
161
|
+
if (!ui.agent) return;
|
|
162
|
+
ui.agent.posting = false;
|
|
163
|
+
const text = startWords(res.status, res.body);
|
|
164
|
+
if (res.ok) {
|
|
165
|
+
closeAgent();
|
|
166
|
+
ui.runNote = { text, ok: true };
|
|
167
|
+
announce(text);
|
|
168
|
+
await fn.loadRuns(false);
|
|
169
|
+
fn.paint();
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
go.disabled = false;
|
|
173
|
+
go.removeAttribute('aria-busy');
|
|
174
|
+
go.textContent = fn.askRunnerWords();
|
|
175
|
+
const msg = $('agent-start-msg');
|
|
176
|
+
msg.textContent = text;
|
|
177
|
+
msg.hidden = false;
|
|
178
|
+
// The one-per-issue rule can be set aside on purpose; the cap cannot
|
|
179
|
+
if (res.body && res.body.code === 'run-open') $('agent-force-field').hidden = false;
|
|
180
|
+
announce(text);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/** Keys inside the dialog: Escape cancels, Tab stays inside, nothing reaches the map behind it */
|
|
184
|
+
function onAgentKey(e) {
|
|
185
|
+
e.stopPropagation();
|
|
186
|
+
if (e.key === 'Escape') {
|
|
187
|
+
e.preventDefault();
|
|
188
|
+
if (!ui.agent || !ui.agent.posting) closeAgent();
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
trapTab(e, agentEl());
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function onAgentClick(e) {
|
|
195
|
+
const t = e.target;
|
|
196
|
+
if (t === agentEl()) { if (ui.agent && !ui.agent.posting) closeAgent(); return; } // the scrim
|
|
197
|
+
if (t.closest && t.closest('[data-action="agent-start-cancel"]') && ui.agent && !ui.agent.posting) closeAgent();
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/** `?proposal=<slug>&start=1`: the Start dialog on that proposal (the proposal itself is opened by proposal.js) */
|
|
201
|
+
async function openProposalStart(slug, opener = '#forge-title') {
|
|
202
|
+
if (!ui.config || !agentEl()) return false;
|
|
203
|
+
await openAgent(`proposal:${slug}`, opener);
|
|
204
|
+
return !!ui.agent;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/** 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) */
|
|
208
|
+
const canStartAgent = () => !!(ui.config && ui.config.agents && agentEl());
|
|
209
|
+
|
|
210
|
+
Object.assign(fn, { agentEl, keepFocusInAgent, openAgent, startAgain, limitDefaultsNow, limitFields, fillLimits, onAgentProfile, closeAgent, submitAgent, onAgentKey, onAgentClick, openProposalStart, canStartAgent });
|
|
211
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module explorer/pieces/work-common
|
|
3
|
+
*
|
|
4
|
+
* What the parts of the Work piece (pieces/work.js and work-*.js) share and that holds nothing of one mount: words, small pure helpers, and the
|
|
5
|
+
* shape of the two forms' state. No instance, no page.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { escapeHtml as escHtml } from '../../core/text.js';
|
|
9
|
+
import { defaultFilters } from '../forge-panel-model.js';
|
|
10
|
+
import { withParts } from '../engine/piece.js';
|
|
11
|
+
|
|
12
|
+
export const FORGE_NAMES = { github: 'GitHub', forgejo: 'Forgejo' };
|
|
13
|
+
export const SEARCH_ANNOUNCE_MS = 500;
|
|
14
|
+
/** How often the runs are read again while one is open */
|
|
15
|
+
export const RUNS_POLL_MS = 60_000;
|
|
16
|
+
/** 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) */
|
|
17
|
+
export const SPECS_POLL_MS = 5 * 60_000;
|
|
18
|
+
/** The tabs, in the order of the loop */
|
|
19
|
+
export const TABS = ['specs', 'pulls', 'issues', 'threads', 'work', 'deploys'];
|
|
20
|
+
/** A node id that reads back as one mention: no brackets or line breaks, as core/mentions.js parses them */
|
|
21
|
+
export const MENTIONABLE = /^[^[\]\r\n]{1,200}$/;
|
|
22
|
+
|
|
23
|
+
export const plural = (n, word, more = `${word}s`) => `${n} ${n === 1 ? word : more}`;
|
|
24
|
+
/** A link only if it is the forge's web address: a forge's JSON is data, not trusted markup */
|
|
25
|
+
export const safeUrl = (u) => (typeof u === 'string' && /^https?:\/\//i.test(u) ? u : null);
|
|
26
|
+
export const option = (value, label, on) => `<option value="${escHtml(value)}"${on ? ' selected' : ''}>${escHtml(label)}</option>`;
|
|
27
|
+
/** The back control of a detail: an arrow and the name of the list it returns to ("All pull requests") */
|
|
28
|
+
export const backHtml = (action, words) => withParts(`<button data-corn="back" type="button" class="hx-forge-back" data-action="${action}"><svg width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6" aria-hidden="true"><path d="M10 3L5 8l5 5"/></svg><span class="hx-forge-back-text">${escHtml(words)}</span></button>`);
|
|
29
|
+
/** The thread a successful answer holds, or null (a failure, or an answer without one) */
|
|
30
|
+
export const threadOf = (res) => (res && res.ok && res.body && res.body.thread && typeof res.body.thread === 'object' && Array.isArray(res.body.thread.messages) ? res.body.thread : null);
|
|
31
|
+
|
|
32
|
+
/** The Release notes view: the draft loaded for a tag, and where the confirm step is */
|
|
33
|
+
export function freshNotes() {
|
|
34
|
+
return { since: '', data: null, loading: false, error: '', confirm: false, posting: false, message: '', bad: false, link: null };
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** The New idea form: whether it is open, one send in flight, and what the last send came to */
|
|
38
|
+
export function freshIdea() {
|
|
39
|
+
// `opener` is the id of the node whose panel button that opened the form ('' when the bar's own button did), `node` the node it was about
|
|
40
|
+
return { open: false, busy: false, message: '', bad: false, link: null, opener: '', node: null };
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** What is shown: the lists loaded, the filters, the selected pull request with its files and checks */
|
|
44
|
+
export function freshUi() {
|
|
45
|
+
return {
|
|
46
|
+
config: null,
|
|
47
|
+
open: false,
|
|
48
|
+
kind: 'specs', // the tab: specs | pulls | issues | threads | work (Runs) | deploys; 'notes' is the Release notes view, reached from the PRs list
|
|
49
|
+
filtersOpen: false, // the Filter chip's box
|
|
50
|
+
filters: defaultFilters(),
|
|
51
|
+
lists: {}, // `${kind}|${server state}` -> { items, at, rate, stale }
|
|
52
|
+
work: null, // { grouped, problem, at, rate, stale } of the Agents tab
|
|
53
|
+
specQuery: '', // the Specs tab's search (spec 0010 D5)
|
|
54
|
+
draftsOpen: null, // the Drafts group opened (true) or folded (false) by hand; null: as the model has it (folded past 10 rows)
|
|
55
|
+
workFilters: { agentsOnly: false, finished: false },
|
|
56
|
+
loading: false,
|
|
57
|
+
error: '',
|
|
58
|
+
selected: null, // the pull request's number
|
|
59
|
+
selectedOn: '', // the tab it was selected on ('pulls' or 'work')
|
|
60
|
+
detail: null, // { pull, files, checks, at, rate, stale } of the selected one
|
|
61
|
+
landing: null, // what waits to land on its approval for the selected pull request ({ slug, by, since }), or null
|
|
62
|
+
detailError: '',
|
|
63
|
+
lit: null, // litFor(detail, nodes)
|
|
64
|
+
thread: null, // the selected thread's number (Threads tab)
|
|
65
|
+
threadDetail: null, // { thread, at, rate, stale } of the selected one: its messages, as written
|
|
66
|
+
threadError: '',
|
|
67
|
+
litThread: null, // litForThread(thread, nodes)
|
|
68
|
+
idea: freshIdea(), // the New idea form
|
|
69
|
+
deploy: null, // the selected deploy's id; the deploy itself is `deployItem`
|
|
70
|
+
deployItem: null,
|
|
71
|
+
litDeploy: null, // litForDeploy(deployItem, nodes)
|
|
72
|
+
nodesSeen: null, // the `state.nodes` the lights were worked out for
|
|
73
|
+
busy: '', // the action in flight ('merge', or 'rerun:<check id>'), so a second click does nothing
|
|
74
|
+
note: null, // { text, ok }: what the last action came to, for the selected pull request
|
|
75
|
+
confirm: null, // { opener: selector, kind: 'merge' | 'spec' | 'build', plan?, n?, slug? } while the confirm dialog is open
|
|
76
|
+
actNote: null, // { text, ok, url }: what the last pipeline step came to
|
|
77
|
+
notes: freshNotes(), // the Release notes view
|
|
78
|
+
runs: null, // { data, error } of the Agents tab's runs: what /api/agent-runs answered
|
|
79
|
+
runNote: null, // { text, ok }: what the last Stop came to
|
|
80
|
+
runSel: null, // the run lit on the map (Light on the map), by id
|
|
81
|
+
runnerSaid: null, // the runner state last shown ('online', 'offline', 'none'; null off the pull transport), so a change is said once
|
|
82
|
+
runTimelines: new Set(), // the runs whose timeline is open
|
|
83
|
+
runReplies: new Map(), // the reply typed so far for each waiting run, so a repaint (the runs are looked at again) keeps it
|
|
84
|
+
agent: null, // { opener, refs, posting, retryOf, filled } while the Start an agent dialog is open
|
|
85
|
+
threadsOn: true, // `threads: false` in the config turns the Threads tab off
|
|
86
|
+
retrying: false, // a Start again reading its run's whole brief, so a second click does nothing
|
|
87
|
+
};
|
|
88
|
+
}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module explorer/pieces/work-confirm
|
|
3
|
+
*
|
|
4
|
+
* The confirm step: landing a pull request, starting a spec, opening a build issue (a modal dialog over a scrim). 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
|
+
* to `ctx.fn`; nothing is shared between two mounts.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { withParts } from '../engine/piece.js';
|
|
9
|
+
import { mergeBlock, confirmMerge, mergeBody, actionUrl, actionWords, planUrl, confirmSpec, confirmBuild, specBody, buildBody, existingWords } from '../forge-panel-model.js';
|
|
10
|
+
import { trapTab } from '../focusables.js';
|
|
11
|
+
import { escapeHtml as escHtml } from '../../core/text.js';
|
|
12
|
+
|
|
13
|
+
export function install(ctx) {
|
|
14
|
+
const { inst, ui, m, fn, $ } = ctx;
|
|
15
|
+
const { announce, t, trapFocus } = ctx.h;
|
|
16
|
+
|
|
17
|
+
const confirmEl = () => $('forge-confirm');
|
|
18
|
+
|
|
19
|
+
/** While the confirm step is open the focus cannot leave it: a focus that lands elsewhere is brought back */
|
|
20
|
+
function keepFocusIn(e) {
|
|
21
|
+
const el = confirmEl();
|
|
22
|
+
if (ui.confirm && el && !el.contains(inst.active())) el.querySelector('[data-action="forge-confirm-cancel"]').focus(); // (the focus in the root's own tree: outside it, none)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Fills and opens the confirm step; the focus goes to Cancel. `what` is the model's: title, lines, checks, previews, note */
|
|
26
|
+
function showConfirm(what, goLabel, state) {
|
|
27
|
+
const el = confirmEl();
|
|
28
|
+
const asCode = ['Commit', 'At commit', 'Branch', 'File', 'Proposal'];
|
|
29
|
+
$('forge-confirm-title').textContent = what.title;
|
|
30
|
+
$('forge-confirm-body').innerHTML = withParts(`<dl class="hx-confirm-facts">${what.lines.map(([k, v]) => `<dt>${escHtml(k)}</dt><dd>${asCode.includes(k) ? `<code class="hx-code">${escHtml(v)}</code>` : escHtml(v)}</dd>`).join('')}</dl>
|
|
31
|
+
${(what.checks || []).length ? `<ul class="hx-confirm-checks">${what.checks.map((c) => `<li><span class="hx-forge-state hx-forge-state--success" data-corn="state-pill" data-corn-state="success">${escHtml(c.words)}</span> ${escHtml(c.name)}</li>`).join('')}</ul>` : ''}
|
|
32
|
+
${(what.previews || []).map((pv) => `<p class="hx-confirm-label">${escHtml(pv.label)}</p><pre class="hx-confirm-pre" data-corn="confirm-preview" tabindex="0" role="region" aria-label="${escHtml(pv.label)}">${escHtml(pv.text)}</pre>`).join('')}
|
|
33
|
+
<p class="hx-confirm-note">${escHtml(what.note)}</p>`);
|
|
34
|
+
const go = el.querySelector('[data-action="forge-confirm-go"]');
|
|
35
|
+
go.disabled = false;
|
|
36
|
+
go.textContent = goLabel;
|
|
37
|
+
go.removeAttribute('aria-busy');
|
|
38
|
+
// The scrim covers the page for the pointer, aria-modal tells a reader the rest is out of play, and the focus stays in
|
|
39
|
+
ui.confirm = state;
|
|
40
|
+
m.confirmTrap = trapFocus(keepFocusIn);
|
|
41
|
+
el.hidden = false;
|
|
42
|
+
el.querySelector('[data-action="forge-confirm-cancel"]').focus();
|
|
43
|
+
announce(`${what.title} ${what.lines.map(([k, v]) => `${k}: ${v}`).join('. ')}. ${what.note} Cancel or ${goLabel}.`);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Opens the confirm step for landing the selected pull request: what will land, exactly */
|
|
47
|
+
function openConfirm(opener) {
|
|
48
|
+
if (!confirmEl() || ui.confirm || ui.agent || ui.busy || !ui.detail || mergeBlock(ui.detail)) return; // one dialog at a time
|
|
49
|
+
showConfirm(confirmMerge(ui.detail, fn.forgeName(), ui.config && ui.config.forge && ui.config.forge.mergeMethod), t('landIt'), { opener, kind: 'merge' });
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** What a pipeline step came to, on the panel (with a link to what it made) and through the live region */
|
|
53
|
+
function stepNote(text, ok, url = null) {
|
|
54
|
+
ui.actNote = { text, ok, url };
|
|
55
|
+
announce(text);
|
|
56
|
+
fn.paint();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Forgets the lists of the other kind (a step made something there), so they are asked again when shown */
|
|
60
|
+
function forgetOtherLists() {
|
|
61
|
+
for (const key of Object.keys(ui.lists)) if (!key.startsWith(`${ui.kind}|`)) delete ui.lists[key];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* A pipeline step, first half: reads the plan from the server (what would be made, from the forge now). A step that
|
|
66
|
+
* was done before says so and stops; otherwise the confirm step shows the plan and nothing is made until it is confirmed.
|
|
67
|
+
*/
|
|
68
|
+
async function askPlan(action, n, slug, opener) {
|
|
69
|
+
if (ui.busy || ui.confirm || ui.agent || !confirmEl()) return;
|
|
70
|
+
ui.busy = `plan:${action}`;
|
|
71
|
+
ui.actNote = null;
|
|
72
|
+
announce(action === 'spec' ? `Looking at what a spec for issue ${n} would make` : `Looking at the build issue for ${slug}`);
|
|
73
|
+
fn.paint();
|
|
74
|
+
const res = await fn.request(planUrl(action, n, slug), true);
|
|
75
|
+
ui.busy = '';
|
|
76
|
+
// The button was off while it asked; it has the focus again whatever the answer is
|
|
77
|
+
const refocus = () => { const back = $('forge-panel').querySelector(opener); if (back && !back.disabled && !ui.confirm) back.focus(); };
|
|
78
|
+
if (!res.ok || !res.body || !res.body.plan) {
|
|
79
|
+
stepNote(actionWords(action, res.status, res.body, n), false);
|
|
80
|
+
refocus();
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const { plan } = res.body;
|
|
84
|
+
if (plan.existing) {
|
|
85
|
+
stepNote(existingWords(action, plan), true, plan.existing.url);
|
|
86
|
+
refocus();
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
fn.paint();
|
|
90
|
+
if (ui.agent) return; // Start an agent was opened while the plan was read: one dialog at a time, and that one has the focus
|
|
91
|
+
const what = action === 'spec' ? confirmSpec(plan, fn.forgeName()) : confirmBuild(plan, fn.forgeName());
|
|
92
|
+
showConfirm(what, what.go, { opener, kind: action, plan, n, slug });
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** A pipeline step, second half: the plan that was shown is confirmed; the server plans again and must find the same */
|
|
96
|
+
async function confirmedStep() {
|
|
97
|
+
if (ui.busy || !ui.confirm || !ui.confirm.plan) return;
|
|
98
|
+
const { kind, plan, n } = ui.confirm;
|
|
99
|
+
ui.busy = kind;
|
|
100
|
+
ui.actNote = null;
|
|
101
|
+
const go = confirmEl().querySelector('[data-action="forge-confirm-go"]');
|
|
102
|
+
go.disabled = true;
|
|
103
|
+
go.setAttribute('aria-busy', 'true');
|
|
104
|
+
go.textContent = 'Working …';
|
|
105
|
+
announce(kind === 'spec' ? `Starting the spec for issue ${n}` : `Opening the build issue for ${plan.slug}`);
|
|
106
|
+
const res = await fn.post(actionUrl(n, kind), kind === 'spec' ? specBody(plan) : buildBody(plan));
|
|
107
|
+
closeConfirm();
|
|
108
|
+
ui.busy = '';
|
|
109
|
+
const made = res.body && (kind === 'spec' ? res.body.pull : res.body.issue);
|
|
110
|
+
stepNote(actionWords(kind, res.status, res.body, n), res.ok, res.ok && made ? made.url : null);
|
|
111
|
+
// Whatever it came to, it is read again: a refusal says the issue or the pull request is not what was shown
|
|
112
|
+
if (res.status !== null) {
|
|
113
|
+
forgetOtherLists();
|
|
114
|
+
if (kind === 'build' && ui.selected === n) await fn.refreshForge({ quiet: true });
|
|
115
|
+
else await fn.loadList(true, true);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** Closes the confirm step; the focus goes back to the button that opened it (or the panel's title if that is gone) */
|
|
120
|
+
function closeConfirm({ restoreFocus = true } = {}) {
|
|
121
|
+
const el = confirmEl();
|
|
122
|
+
if (!el || !ui.confirm) return;
|
|
123
|
+
const { opener } = ui.confirm;
|
|
124
|
+
ui.confirm = null;
|
|
125
|
+
el.hidden = true;
|
|
126
|
+
if (m.confirmTrap) { m.confirmTrap(); m.confirmTrap = null; }
|
|
127
|
+
if (!restoreFocus) return;
|
|
128
|
+
const back = $('forge-panel').querySelector(opener) || $('forge-title');
|
|
129
|
+
if (back && !back.disabled) back.focus();
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** Land it, confirmed: posts the head that was shown */
|
|
133
|
+
async function confirmedMerge() {
|
|
134
|
+
if (ui.busy || !ui.detail || !ui.confirm || ui.confirm.kind !== 'merge') return;
|
|
135
|
+
const { pull } = ui.detail;
|
|
136
|
+
const body = mergeBody(ui.detail);
|
|
137
|
+
ui.busy = 'merge';
|
|
138
|
+
ui.note = null;
|
|
139
|
+
const go = confirmEl().querySelector('[data-action="forge-confirm-go"]');
|
|
140
|
+
go.disabled = true;
|
|
141
|
+
go.setAttribute('aria-busy', 'true');
|
|
142
|
+
go.textContent = 'Landing …';
|
|
143
|
+
announce(`Landing pull request ${pull.number}`);
|
|
144
|
+
const res = await fn.post(actionUrl(pull.number, 'merge'), body);
|
|
145
|
+
closeConfirm();
|
|
146
|
+
await fn.finishAction('merge', res, pull.number);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** Keys inside the confirm step: Escape cancels, Tab stays between its two buttons, nothing reaches the map behind it */
|
|
150
|
+
function onConfirmKey(e) {
|
|
151
|
+
e.stopPropagation();
|
|
152
|
+
if (e.key === 'Escape') {
|
|
153
|
+
e.preventDefault();
|
|
154
|
+
if (!ui.busy) closeConfirm();
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
trapTab(e, confirmEl());
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function onConfirmClick(e) {
|
|
161
|
+
const t = e.target;
|
|
162
|
+
if (t === confirmEl()) { if (!ui.busy) closeConfirm(); return; } // the scrim
|
|
163
|
+
const action = t.closest && t.closest('[data-action]');
|
|
164
|
+
if (!action) return;
|
|
165
|
+
if (action.dataset.action === 'forge-confirm-cancel') { if (!ui.busy) closeConfirm(); } else if (action.dataset.action === 'forge-confirm-go') { if (ui.confirm && ui.confirm.kind === 'merge') confirmedMerge(); else confirmedStep(); }
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
Object.assign(fn, { confirmEl, keepFocusIn, showConfirm, openConfirm, stepNote, forgetOtherLists, askPlan, confirmedStep, closeConfirm, confirmedMerge, onConfirmKey, onConfirmClick });
|
|
169
|
+
}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module explorer/pieces/work-data
|
|
3
|
+
*
|
|
4
|
+
* The Work panel's asking: every request, the list a tab shows, what a selection lights on the map, the counts read quietly. 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
|
+
* to `ctx.fn`; nothing is shared between two mounts.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { litOfRun } from '../runs-model.js';
|
|
9
|
+
import { listUrl, pullUrl, filterItems, litFor, errorWords, listKeyOf, litForDeploy, threadUrl, litForThread } from '../forge-panel-model.js';
|
|
10
|
+
import { plural, threadOf, FORGE_NAMES } from './work-common.js';
|
|
11
|
+
import { credentialed } from '../engine/connection.js';
|
|
12
|
+
|
|
13
|
+
export function install(ctx) {
|
|
14
|
+
const { inst, ui, m, fn, state, $ } = ctx;
|
|
15
|
+
const { announce, render, touchScene, repaintThreads, isOffline } = ctx.h;
|
|
16
|
+
|
|
17
|
+
/** Every request carries the maintainer's session to the base's own origin only (engine/connection.js) */
|
|
18
|
+
const ask = credentialed(inst);
|
|
19
|
+
/** An answer that comes after the piece ended is not wanted: whatever was waiting for it waits for ever, and so does nothing */
|
|
20
|
+
const never = () => new Promise(() => {});
|
|
21
|
+
|
|
22
|
+
const forgeName = () => FORGE_NAMES[ui.config && ui.config.forge && ui.config.forge.type] || 'the forge';
|
|
23
|
+
|
|
24
|
+
const listKey = () => listKeyOf(ui.kind, ui.filters.state);
|
|
25
|
+
|
|
26
|
+
const current = () => (ui.kind === 'work' ? ui.work : ui.kind === 'specs' ? fn.specsList() : ui.lists[listKey()]) || null;
|
|
27
|
+
|
|
28
|
+
const kindWords = () => ({ specs: 'spec', pulls: 'pull request', issues: 'issue', threads: 'thread', deploys: 'deploy' })[ui.kind] || 'piece of work';
|
|
29
|
+
|
|
30
|
+
/** A failed answer in words (the model's), said as offline when the browser is, and naming what could not be loaded */
|
|
31
|
+
const failWords = (res, what = '') => errorWords(res.status, res.body, { offline: isOffline(), what });
|
|
32
|
+
|
|
33
|
+
/** One GET (or the one POST, with its JSON); `{ ok, status, body }`, with a status of null when the server did not answer */
|
|
34
|
+
async function request(url, refresh, post) {
|
|
35
|
+
if (ctx.dead) return never(); // nothing is asked once the piece has ended
|
|
36
|
+
try {
|
|
37
|
+
// Refresh sends `Cache-Control: no-cache`, which the server takes as "ask the forge again"
|
|
38
|
+
const init = post ? { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(post) } : refresh ? { cache: 'reload' } : {};
|
|
39
|
+
const res = await ask(url, init);
|
|
40
|
+
if (ctx.dead) return never();
|
|
41
|
+
let body = null;
|
|
42
|
+
try { body = await res.json(); } catch { /* no body */ }
|
|
43
|
+
if (ctx.dead) return never();
|
|
44
|
+
return { ok: !!res.ok && !!body && body.ok !== false, status: res.status, body };
|
|
45
|
+
} catch {
|
|
46
|
+
if (ctx.dead) return never();
|
|
47
|
+
return { ok: false, status: null, body: null };
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** One POST of JSON; `{ ok, status, body }`, with a status of null when the server did not answer */
|
|
52
|
+
async function post(url, payload) {
|
|
53
|
+
if (ctx.dead) return never();
|
|
54
|
+
try {
|
|
55
|
+
const res = await ask(url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(payload) });
|
|
56
|
+
if (ctx.dead) return never();
|
|
57
|
+
let body = null;
|
|
58
|
+
try { body = await res.json(); } catch { /* no body */ }
|
|
59
|
+
if (ctx.dead) return never();
|
|
60
|
+
return { ok: !!res.ok && !!body && body.ok === true, status: res.status, body };
|
|
61
|
+
} catch {
|
|
62
|
+
if (ctx.dead) return never();
|
|
63
|
+
return { ok: false, status: null, body: null };
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Loads the list the kind and state name (again, past the server's cache, on a refresh) */
|
|
68
|
+
async function loadList(refresh = false, quiet = false) {
|
|
69
|
+
const token = ++m.listToken;
|
|
70
|
+
if (ui.kind === 'work') return fn.loadWork(refresh, token);
|
|
71
|
+
if (ui.kind === 'specs') return fn.loadSpecs(token, quiet);
|
|
72
|
+
const key = listKey();
|
|
73
|
+
ui.loading = true;
|
|
74
|
+
ui.error = '';
|
|
75
|
+
fn.paint();
|
|
76
|
+
const res = await request(listUrl(ui.kind, ui.filters.state), refresh);
|
|
77
|
+
if (token !== m.listToken) return;
|
|
78
|
+
ui.loading = false;
|
|
79
|
+
if (res.ok) {
|
|
80
|
+
ui.lists[key] = { items: res.body.items || [], at: res.body.at, rate: res.body.rate || '', stale: res.body.stale || '', problem: res.body.problem || '' };
|
|
81
|
+
if (ui.kind === 'threads') {
|
|
82
|
+
repaintThreads();
|
|
83
|
+
// A thread's row names the state of the run that is about it (issue #104): the runs are read, once, when the tab is the first thing opened
|
|
84
|
+
if (!ui.runs) fn.loadRuns(false, { say: false }).then(() => { if (ui.open && ui.kind === 'threads') fn.paint(); }, () => {});
|
|
85
|
+
}
|
|
86
|
+
if (!quiet) announce(`${plural(filterItems(ui.lists[key].items, ui.kind, ui.filters).length, kindWords())} shown${ui.lists[key].stale ? '. This is an older answer' : ''}`);
|
|
87
|
+
} else {
|
|
88
|
+
ui.error = failWords(res, `the ${kindWords()}s`);
|
|
89
|
+
if (!quiet) announce(ui.error);
|
|
90
|
+
}
|
|
91
|
+
fn.paintFilters();
|
|
92
|
+
fn.paint();
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** 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) */
|
|
96
|
+
function primeCounts() {
|
|
97
|
+
for (const kind of ['pulls', 'issues']) {
|
|
98
|
+
const key = listKeyOf(kind, 'open');
|
|
99
|
+
if (ui.lists[key] || m.primed.has(kind) || kind === ui.kind) continue;
|
|
100
|
+
m.primed.add(kind);
|
|
101
|
+
request(listUrl(kind, 'open'), false).then((res) => {
|
|
102
|
+
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 || '' };
|
|
103
|
+
if (ui.open) fn.paint();
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
if (!m.primed.has('threads')) { m.primed.add('threads'); fn.ensureThreadsList(); }
|
|
107
|
+
if (ui.kind !== 'specs') fn.readSpecsQuiet(); // the specs part of the number is read when Work opens (spec 0010 D2)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** What the selected pull request lights, worked out again: for the nodes now on the map */
|
|
111
|
+
function relight() {
|
|
112
|
+
ui.nodesSeen = state.nodes;
|
|
113
|
+
if (ui.runSel) {
|
|
114
|
+
const run = fn.runById(ui.runSel);
|
|
115
|
+
state.forgeLit = run ? litOfRun(run) : null;
|
|
116
|
+
} else if (ui.threadDetail && ui.threadDetail.thread) {
|
|
117
|
+
ui.litThread = litForThread(ui.threadDetail.thread, state.nodes);
|
|
118
|
+
state.forgeLit = { changed: ui.litThread.changed, failing: ui.litThread.failing };
|
|
119
|
+
} else if (ui.deployItem) {
|
|
120
|
+
ui.litDeploy = litForDeploy(ui.deployItem, state.nodes);
|
|
121
|
+
state.forgeLit = { changed: ui.litDeploy.changed, failing: ui.litDeploy.failing };
|
|
122
|
+
} else if (ui.detail) {
|
|
123
|
+
ui.lit = litFor(ui.detail, state.nodes);
|
|
124
|
+
state.forgeLit = { changed: ui.lit.changed, failing: ui.lit.failing };
|
|
125
|
+
} else {
|
|
126
|
+
ui.lit = null;
|
|
127
|
+
state.forgeLit = null;
|
|
128
|
+
}
|
|
129
|
+
touchScene();
|
|
130
|
+
render();
|
|
131
|
+
fn.paint();
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** A proposal opening, or the live layer, changes the nodes: the lights follow them */
|
|
135
|
+
function onNodesChange() {
|
|
136
|
+
if ((ui.detail || ui.deployItem || ui.threadDetail) && state.nodes !== ui.nodesSeen) relight();
|
|
137
|
+
repaintThreads();
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** Asks the forge again, past the server's cache: the list, and the selected pull request */
|
|
141
|
+
async function refreshForge({ quiet = false } = {}) {
|
|
142
|
+
if (!quiet) announce('Asking the forge again');
|
|
143
|
+
if (ui.kind === 'notes') { await fn.loadNotes(true); return; }
|
|
144
|
+
const n = ui.selected;
|
|
145
|
+
await loadList(true, quiet);
|
|
146
|
+
if (ui.deployItem) {
|
|
147
|
+
// The list is read again: the deploy as the forge now has it (still running, now finished), else the last copy
|
|
148
|
+
const again = ui.lists.deploys && ui.lists.deploys.items.find((d) => d.id === ui.deploy);
|
|
149
|
+
if (again) { ui.deployItem = again; relight(); }
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
if (ui.thread !== null) {
|
|
153
|
+
const at = ui.thread;
|
|
154
|
+
const token = ++m.threadToken;
|
|
155
|
+
const res = await request(threadUrl(at), true);
|
|
156
|
+
const thread = threadOf(res);
|
|
157
|
+
if (token !== m.threadToken || !thread) return;
|
|
158
|
+
ui.threadDetail = { thread, at: res.body.at, rate: res.body.rate || '', stale: res.body.stale || '' };
|
|
159
|
+
relight();
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
if (n !== null && ui.selected === n) {
|
|
163
|
+
const token = ++m.pullToken;
|
|
164
|
+
const res = await request(pullUrl(n), true);
|
|
165
|
+
if (token !== m.pullToken || !res.ok) return;
|
|
166
|
+
ui.detail = { pull: res.body.pull, files: res.body.files || [], checks: res.body.checks || [], specs: res.body.specs || [], at: res.body.at, rate: res.body.rate || '', stale: res.body.stale || '' };
|
|
167
|
+
relight();
|
|
168
|
+
await fn.loadLanding(n, token);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/** Back online: a tab that could not be read is read again, so its error does not outlive the cause (the same function each time, added once) */
|
|
173
|
+
function readOnline() {
|
|
174
|
+
if (ui.open && (ui.error || (ui.runs && ui.runs.error) || ui.detailError || (ui.kind === 'notes' && ui.notes.error))) refreshForge({ quiet: true });
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
Object.assign(fn, { forgeName, listKey, current, kindWords, failWords, request, post, loadList, primeCounts, relight, onNodesChange, refreshForge, readOnline });
|
|
178
|
+
}
|