@floless/app 0.152.0 → 0.152.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/dist/floless-server.cjs +9 -9
- package/dist/web/app.css +5 -0
- package/dist/web/commands-shell.js +1 -0
- package/dist/web/tool-updates.js +138 -38
- package/package.json +1 -1
package/dist/floless-server.cjs
CHANGED
|
@@ -2632,13 +2632,13 @@ function appVersion() {
|
|
|
2632
2632
|
return resolveVersion({
|
|
2633
2633
|
isSea: isSea2(),
|
|
2634
2634
|
sqVersionXml: readSqVersionXml(),
|
|
2635
|
-
define: true ? "0.152.
|
|
2635
|
+
define: true ? "0.152.1" : void 0,
|
|
2636
2636
|
pkgVersion: readPkgVersion()
|
|
2637
2637
|
});
|
|
2638
2638
|
}
|
|
2639
2639
|
function buildVersion(sources) {
|
|
2640
2640
|
if (sources) return resolveBuildVersion(sources.define, sources.pkgVersion);
|
|
2641
|
-
return resolveBuildVersion(true ? "0.152.
|
|
2641
|
+
return resolveBuildVersion(true ? "0.152.1" : void 0, readPkgVersion());
|
|
2642
2642
|
}
|
|
2643
2643
|
function resolveBuildVersion(define, pkgVersion) {
|
|
2644
2644
|
if (typeof define === "string" && define) return define;
|
|
@@ -2656,7 +2656,7 @@ function resolveChannel(s) {
|
|
|
2656
2656
|
function appChannel() {
|
|
2657
2657
|
return resolveChannel({
|
|
2658
2658
|
isSea: isSea2(),
|
|
2659
|
-
define: true ? "0.152.
|
|
2659
|
+
define: true ? "0.152.1" : void 0,
|
|
2660
2660
|
// argv[1] is the entry the runtime actually loaded (…/dist/floless-server.cjs), which is what
|
|
2661
2661
|
// carries the npx cache prefix. Absent under the SEA exe, which never reaches the npx branch.
|
|
2662
2662
|
modulePath: process.argv[1]
|
|
@@ -130485,9 +130485,9 @@ function budgetRefusalFrom(raw2, limits, boundPages) {
|
|
|
130485
130485
|
function removeScriptDir(scriptDir) {
|
|
130486
130486
|
return (0, import_promises19.rm)(scriptDir, { recursive: true, force: true, maxRetries: 5, retryDelay: 50 });
|
|
130487
130487
|
}
|
|
130488
|
-
function dropQuarantinedScriptDir(scriptDir) {
|
|
130488
|
+
function dropQuarantinedScriptDir(scriptDir, remove = removeScriptDir) {
|
|
130489
130489
|
if (!scriptDir) return;
|
|
130490
|
-
void
|
|
130490
|
+
void remove(scriptDir).catch(() => {
|
|
130491
130491
|
});
|
|
130492
130492
|
}
|
|
130493
130493
|
function readCleanupMarker(path) {
|
|
@@ -130626,11 +130626,11 @@ async function executePython(script, input2, options2) {
|
|
|
130626
130626
|
if (tracked.durableClaim) {
|
|
130627
130627
|
const stillClaimed = durableMarkers.some((marker) => marker.pid === pid && marker.procStartedAt === tracked.procStartedAt);
|
|
130628
130628
|
if (!stillClaimed && await killTreeAndVerify(pid, tracked.procStartedAt)) {
|
|
130629
|
-
dropQuarantinedScriptDir(tracked.scriptDir);
|
|
130629
|
+
dropQuarantinedScriptDir(tracked.scriptDir, tracked.remove);
|
|
130630
130630
|
unclosedPythonTrees.delete(pid);
|
|
130631
130631
|
}
|
|
130632
130632
|
} else if (await killTreeAndVerify(pid, tracked.procStartedAt)) {
|
|
130633
|
-
dropQuarantinedScriptDir(tracked.scriptDir);
|
|
130633
|
+
dropQuarantinedScriptDir(tracked.scriptDir, tracked.remove);
|
|
130634
130634
|
unclosedPythonTrees.delete(pid);
|
|
130635
130635
|
}
|
|
130636
130636
|
}
|
|
@@ -130723,7 +130723,7 @@ async function executePython(script, input2, options2) {
|
|
|
130723
130723
|
expectedUntil: Date.now() + timeoutMs + (options2.cleanupTimeoutMs ?? 1e4)
|
|
130724
130724
|
});
|
|
130725
130725
|
} catch {
|
|
130726
|
-
if (child.pid) unclosedPythonTrees.set(child.pid, { procStartedAt, durableClaim: false, scriptDir });
|
|
130726
|
+
if (child.pid) unclosedPythonTrees.set(child.pid, { procStartedAt, durableClaim: false, scriptDir, remove });
|
|
130727
130727
|
let admissionSettled = false;
|
|
130728
130728
|
let admissionTimer;
|
|
130729
130729
|
const settleAdmission = () => {
|
|
@@ -130779,7 +130779,7 @@ async function executePython(script, input2, options2) {
|
|
|
130779
130779
|
if (settled2) return;
|
|
130780
130780
|
if (outcome === "timeout") timerWon = true;
|
|
130781
130781
|
else clearTimeout(timer);
|
|
130782
|
-
if (child.pid) unclosedPythonTrees.set(child.pid, { procStartedAt, durableClaim: true, scriptDir });
|
|
130782
|
+
if (child.pid) unclosedPythonTrees.set(child.pid, { procStartedAt, durableClaim: true, scriptDir, remove });
|
|
130783
130783
|
if (child.pid) try {
|
|
130784
130784
|
(options2.markCleanup ?? markCleanupState)(child.pid, procStartedAt);
|
|
130785
130785
|
} catch {
|
package/dist/web/app.css
CHANGED
|
@@ -3283,6 +3283,10 @@
|
|
|
3283
3283
|
.tool-updates-pill[data-state="nudge"]:hover,
|
|
3284
3284
|
.tool-updates-pill[data-state="needs"]:hover { border-color: var(--warn); color: var(--warn); }
|
|
3285
3285
|
.tool-updates-pill[data-state="urgent"]:hover { border-color: var(--err); color: var(--err); }
|
|
3286
|
+
/* A check this page started and is still waiting on (#2143): the default accent pill plus the panel's pulsing dot. Only when there is
|
|
3287
|
+
nothing else to say; when something needs the person the pill keeps its colour and only gains " · checking…". */
|
|
3288
|
+
.tool-updates-pill[data-state="checking"]::before { content: ""; flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: aware-update-pulse 1.2s ease-in-out infinite; }
|
|
3289
|
+
@media (prefers-reduced-motion: reduce) { .tool-updates-pill[data-state="checking"]::before { animation: none; } }
|
|
3286
3290
|
#tool-updates-modal .tool-updates-dialog { width: 560px; max-width: 92vw; max-height: 86vh; display: flex; flex-direction: column; }
|
|
3287
3291
|
#tool-updates-modal .modal-title:focus { outline: none; }
|
|
3288
3292
|
#tool-updates-modal .modal-title:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
|
|
@@ -3352,6 +3356,7 @@
|
|
|
3352
3356
|
.tool-updates-progress { flex: none; margin-top: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2); }
|
|
3353
3357
|
.tool-updates-progress-head { margin-bottom: 8px; color: var(--text); font-size: 12px; font-weight: 600; line-height: 1.45; }
|
|
3354
3358
|
.tool-updates-progress-lost { margin: -4px 0 8px; color: var(--warn); font-size: 11px; line-height: 1.4; }
|
|
3359
|
+
.tool-updates-progress-hint { margin-top: 8px; color: var(--text-muted); font-size: 11px; line-height: 1.4; }
|
|
3355
3360
|
.tool-updates-steps { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
|
|
3356
3361
|
.tool-updates-step { display: grid; grid-template-columns: 14px minmax(0, 1fr) auto; column-gap: 8px; row-gap: 1px; align-items: baseline; font-size: 12px; line-height: 17px; }
|
|
3357
3362
|
.tool-updates-step-mark { grid-column: 1; grid-row: 1; align-self: start; height: 17px; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; line-height: 1; }
|
|
@@ -2869,6 +2869,7 @@
|
|
|
2869
2869
|
interaction: 'instant',
|
|
2870
2870
|
risk: ['costs-time'],
|
|
2871
2871
|
guidance: 'on-demand',
|
|
2872
|
+
why: 'A check can take several minutes, one tool at a time. You can close the dialog while it runs. The check keeps going, and the button at the bottom of the screen says it is still running.',
|
|
2872
2873
|
});
|
|
2873
2874
|
|
|
2874
2875
|
def('shell.tool-updates-forget-folder', {
|
package/dist/web/tool-updates.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
view and sends ONE thing back: the person's click, naming the batch it
|
|
8
8
|
showed. Every string shown is the server's, set with textContent.
|
|
9
9
|
|
|
10
|
-
States: a pill only when something is offered
|
|
10
|
+
States: a pill only when something is offered, needs the person, or a check started from this page is still running; the
|
|
11
11
|
dialog lists "Ready to approve" cards, "Needs you" rows, the downloads
|
|
12
12
|
line and the consequence footnote; after the click, the results replace
|
|
13
13
|
the cards in a live region.
|
|
@@ -18,6 +18,10 @@
|
|
|
18
18
|
been on it. It asks for that at most once a second (a slow answer skips a
|
|
19
19
|
tick) and only while the dialog is open and a check is running; those
|
|
20
20
|
answers are shown, never applied as the view.
|
|
21
|
+
|
|
22
|
+
A running check never holds the person in the dialog (#2143): Esc and the cancel button (it reads "Close" while a check
|
|
23
|
+
runs, "Not now" otherwise) leave it, the check goes on in the server, and the footer pill says so until the Check
|
|
24
|
+
request this page sent is answered. Only an approval locks the dialog.
|
|
21
25
|
────────────────────────────────────────────────────────────────────────── */
|
|
22
26
|
(function () {
|
|
23
27
|
'use strict';
|
|
@@ -65,9 +69,14 @@
|
|
|
65
69
|
view = Object.assign({}, view, { cleanup: next });
|
|
66
70
|
return true;
|
|
67
71
|
}
|
|
68
|
-
var
|
|
69
|
-
var checking = false; // the Check for updates request is in flight
|
|
72
|
+
var approving = false; // an approval is running: the one thing that holds the dialog, because its results are shown only here
|
|
73
|
+
var checking = false; // the Check for updates request is in flight; the person may close the dialog meanwhile
|
|
74
|
+
var checkController = null; // cancels that request when its answer never comes back
|
|
75
|
+
var answerLost = false; // that request was given up on
|
|
76
|
+
var quietAsks = 0; // progress answers in a row saying nothing runs while the Check request is still unanswered
|
|
70
77
|
var returnFocus = null;
|
|
78
|
+
var PILL_TIP = $pill.getAttribute('data-tip');
|
|
79
|
+
var LOST_ANSWER_AFTER_QUIET_ASKS = 3; // three idle progress answers in a row (about 1 s apart): the answer to the Check request is taken as lost
|
|
71
80
|
|
|
72
81
|
// ── A running check, as the server describes it ───────────────────────────────────────────────────────────
|
|
73
82
|
// The clock is deliberately here although the headless-run styling avoids one (web/app.css, "Headless runs (#571
|
|
@@ -90,7 +99,8 @@
|
|
|
90
99
|
var POLL_PATIENCE_MS = 6000;
|
|
91
100
|
|
|
92
101
|
function checkInFlight() { return checking || !!(view && view.checking); }
|
|
93
|
-
function
|
|
102
|
+
function isOpen() { return $modal.classList.contains('show'); }
|
|
103
|
+
function checkRunning() { return isOpen() && checkInFlight(); }
|
|
94
104
|
|
|
95
105
|
function elapsedText(seconds) {
|
|
96
106
|
var nb = '\u00a0'; // never wraps between the number and its unit
|
|
@@ -162,6 +172,8 @@
|
|
|
162
172
|
});
|
|
163
173
|
$progress.appendChild(list);
|
|
164
174
|
}
|
|
175
|
+
// Not while contact is lost: the page cannot say then that the check keeps going.
|
|
176
|
+
if (!lostContact) $progress.appendChild(el('div', 'tool-updates-progress-hint', 'You can close this dialog. The check keeps going, and what it finds shows at the bottom of the screen.'));
|
|
165
177
|
paintedSteps = signature;
|
|
166
178
|
}
|
|
167
179
|
announce(steps);
|
|
@@ -192,8 +204,11 @@
|
|
|
192
204
|
// is queued behind another has no steps yet: the old ones go with it rather than freeze with a running clock.
|
|
193
205
|
if (body.checking) {
|
|
194
206
|
progress = body.progress || null;
|
|
207
|
+
quietAsks = 0;
|
|
195
208
|
} else {
|
|
196
209
|
progress = null; // nothing is running: no steps, and no clock counting on one
|
|
210
|
+
// The server has said "idle" three times running yet the Check request is unanswered: its answer is taken as lost, not late.
|
|
211
|
+
if (checking && ++quietAsks >= LOST_ANSWER_AFTER_QUIET_ASKS && checkController) { answerLost = true; checkController.abort(); }
|
|
197
212
|
// A check that ended without this page asking (a background one): the page reads the view and repaints, one read at a time.
|
|
198
213
|
if (!checking && !rereading) {
|
|
199
214
|
rereading = true;
|
|
@@ -256,7 +271,10 @@
|
|
|
256
271
|
|
|
257
272
|
async function call(path, method, payload, signal) {
|
|
258
273
|
var res = await fetch(path, { method: method || 'GET', headers: { 'content-type': 'application/json' }, body: payload, signal: signal });
|
|
259
|
-
var body = await res.json().catch(function () {
|
|
274
|
+
var body = await res.json().catch(function (error) {
|
|
275
|
+
if (error && error.name === 'AbortError') throw error; // the page gave this request up: not "an unreadable answer"
|
|
276
|
+
return { ok: false, error: 'FloLess received an unreadable answer (HTTP ' + res.status + ').' };
|
|
277
|
+
});
|
|
260
278
|
if (!res.ok && body.ok !== true && !body.results) {
|
|
261
279
|
var error = new Error(body.error || ('HTTP ' + res.status));
|
|
262
280
|
error.body = body;
|
|
@@ -277,10 +295,13 @@
|
|
|
277
295
|
var needs = view && view.supported ? view.needsYou || [] : [];
|
|
278
296
|
var cleanup = cleanupNeeds();
|
|
279
297
|
var urgent = offers.filter(function (o) { return !!o.advisory; }).length;
|
|
280
|
-
|
|
298
|
+
// Only a check this page started: a background pass is not something the person is waiting for.
|
|
299
|
+
if (!offers.length && !needs.length && !cleanup.length && !checking) {
|
|
300
|
+
// A pill that disappears under the keyboard's focus must not drop focus to the page behind.
|
|
301
|
+
if (document.activeElement === $pill) { var menu = document.getElementById('menu-btn'); if (menu) menu.focus(); }
|
|
281
302
|
$pill.hidden = true;
|
|
282
303
|
$pill.removeAttribute('data-state');
|
|
283
|
-
if (
|
|
304
|
+
if (isOpen() && !results) paint();
|
|
284
305
|
return;
|
|
285
306
|
}
|
|
286
307
|
var text;
|
|
@@ -296,18 +317,25 @@
|
|
|
296
317
|
var days = Math.max.apply(null, offers.map(function (o) { return o.waitingDays || 0; }));
|
|
297
318
|
text += ' · waiting ' + plural(days, 'day', 'days');
|
|
298
319
|
}
|
|
299
|
-
} else {
|
|
320
|
+
} else if (needs.length || cleanup.length) {
|
|
300
321
|
state = 'needs';
|
|
301
322
|
var folders = cleanup.filter(function (c) { return c.kind !== 'unreadable'; }).length;
|
|
302
323
|
if (needs.length && cleanup.length) text = (needs.length + cleanup.length) + ' things need you';
|
|
303
324
|
else if (needs.length) text = plural(needs.length, 'workflow needs you', 'workflows need you');
|
|
304
325
|
else if (folders === cleanup.length) text = plural(folders, 'folder needs you', 'folders need you');
|
|
305
326
|
else text = plural(cleanup.length, 'item needs you', 'items need you');
|
|
327
|
+
} else {
|
|
328
|
+
state = 'checking';
|
|
329
|
+
text = 'Checking for tool updates…';
|
|
306
330
|
}
|
|
331
|
+
// Something to act on keeps its wording and colour; a running check is added to it, not put in its place.
|
|
332
|
+
if (checking && state !== 'checking') text += ' · checking…';
|
|
307
333
|
$pill.textContent = text;
|
|
308
334
|
$pill.setAttribute('data-state', state);
|
|
335
|
+
$pill.setAttribute('data-tip', !checking ? PILL_TIP : state === 'checking'
|
|
336
|
+
? 'Still checking for tool updates. Open to watch it.' : PILL_TIP + '. A check is also running.');
|
|
309
337
|
$pill.hidden = false;
|
|
310
|
-
if (
|
|
338
|
+
if (isOpen() && !approving && !results) paint();
|
|
311
339
|
}
|
|
312
340
|
|
|
313
341
|
// ── The dialog ─────────────────────────────────────────────────────────────
|
|
@@ -387,7 +415,7 @@
|
|
|
387
415
|
var busyHere = forgetting === item.path;
|
|
388
416
|
var button = el('button', 'tool-updates-open', busyHere ? 'Removing…' : 'Remove from list');
|
|
389
417
|
button.type = 'button';
|
|
390
|
-
button
|
|
418
|
+
lock(button, forgetReason());
|
|
391
419
|
button.setAttribute('data-command-id', 'shell.tool-updates-forget-folder');
|
|
392
420
|
button.setAttribute('data-tip', 'Stop keeping old tool versions for the workflows in this folder');
|
|
393
421
|
button.setAttribute('aria-label', 'Remove ' + (item.name || item.path) + ' from the list');
|
|
@@ -398,7 +426,7 @@
|
|
|
398
426
|
}
|
|
399
427
|
|
|
400
428
|
async function forgetFolder(item) {
|
|
401
|
-
if (
|
|
429
|
+
if (approving || checking || forgetting) return;
|
|
402
430
|
var path = item.path;
|
|
403
431
|
var ok = false;
|
|
404
432
|
forgetting = path;
|
|
@@ -586,27 +614,42 @@
|
|
|
586
614
|
$approve.hidden = !canApprove;
|
|
587
615
|
if (canApprove) $approve.textContent = 'Approve ' + plural(offers.length, 'workflow', 'workflows');
|
|
588
616
|
$check.hidden = !!results || !(view && view.supported);
|
|
589
|
-
|
|
617
|
+
// "Not now" would read as cancelling the check, which closing the dialog does not do.
|
|
618
|
+
$cancel.textContent = results ? 'Done' : checkInFlight() ? 'Close' : 'Not now';
|
|
590
619
|
}
|
|
591
620
|
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
621
|
+
/** A control that cannot be used right now says why (Instructor reads data-blocked-reason only while it is disabled). */
|
|
622
|
+
function lock(button, reason) {
|
|
623
|
+
button.disabled = !!reason;
|
|
624
|
+
if (reason) button.setAttribute('data-blocked-reason', reason); else button.removeAttribute('data-blocked-reason');
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
/** Why a button that needs the dialog to itself is held, or '' when nothing holds it. */
|
|
628
|
+
function heldReason(whileChecking) { return approving ? 'Approving now.' : checking ? whileChecking : ''; }
|
|
629
|
+
|
|
630
|
+
/** Why a Remove from list button is held (any row: one folder is removed at a time). */
|
|
631
|
+
function forgetReason() { return heldReason('Wait for the check to finish.') || (forgetting ? 'Removing a folder now.' : ''); }
|
|
632
|
+
|
|
633
|
+
function syncControls() {
|
|
634
|
+
// Only an approval is busy for the screen reader: a busy dialog can make it hold back the step announcements inside.
|
|
635
|
+
$modal.setAttribute('aria-busy', approving ? 'true' : 'false');
|
|
636
|
+
lock($check, heldReason('A check is already running.'));
|
|
637
|
+
lock($approve, heldReason('Wait for the check to finish, then approve.'));
|
|
638
|
+
lock($cancel, approving ? 'Approving now.' : '');
|
|
639
|
+
Array.prototype.forEach.call($body.querySelectorAll('[data-command-id="shell.tool-updates-forget-folder"]'), function (b) { lock(b, forgetReason()); });
|
|
599
640
|
}
|
|
600
641
|
|
|
601
642
|
async function refresh() {
|
|
602
643
|
var ticket = nextTicket();
|
|
603
644
|
try {
|
|
604
645
|
var body = await call('/api/tool-updates');
|
|
646
|
+
// Only the server's own answer can be the view: a body that is not one keeps the last view on screen.
|
|
647
|
+
if (!body || body.ok !== true) throw new Error('not the server\'s answer');
|
|
605
648
|
applyView(ticket, body);
|
|
606
649
|
} catch (error) {
|
|
607
650
|
// Keep the last answer on screen (and its pill): a dropped request is not "nothing to update".
|
|
608
651
|
console.warn('tool updates unavailable', error);
|
|
609
|
-
if (
|
|
652
|
+
if (isOpen() && !approving && !checking) $live.textContent = 'FloLess could not check for tool updates just now. What is shown is from the last check.';
|
|
610
653
|
}
|
|
611
654
|
paintPill();
|
|
612
655
|
syncProgress();
|
|
@@ -621,15 +664,17 @@
|
|
|
621
664
|
syncProgress();
|
|
622
665
|
// Focus the title, not the primary: approving is consequential and Enter on open must not do it.
|
|
623
666
|
setTimeout(function () { $title.focus(); }, 0);
|
|
624
|
-
void refresh().then(function () { if (
|
|
667
|
+
void refresh().then(function () { if (isOpen() && !approving && !results) paint(); });
|
|
625
668
|
}
|
|
626
669
|
|
|
627
670
|
function close() {
|
|
628
|
-
if (
|
|
671
|
+
if (approving) return;
|
|
629
672
|
$modal.classList.remove('show');
|
|
630
673
|
syncProgress();
|
|
631
674
|
if (results) { results = null; }
|
|
632
|
-
|
|
675
|
+
// The pill may have gone while the dialog was open (a check that found nothing): then the menu button, never the page behind.
|
|
676
|
+
var back = returnFocus && !returnFocus.hidden && document.contains(returnFocus) ? returnFocus : document.getElementById('menu-btn');
|
|
677
|
+
if (back) back.focus();
|
|
633
678
|
returnFocus = null;
|
|
634
679
|
}
|
|
635
680
|
|
|
@@ -650,36 +695,90 @@
|
|
|
650
695
|
else if (!e.shiftKey && document.activeElement === last) { e.preventDefault(); first.focus(); }
|
|
651
696
|
});
|
|
652
697
|
|
|
698
|
+
/** A line in the corner, for the end of a check the person left running. It takes no focus. A warning stays until it is closed: the person went away for a long check. */
|
|
699
|
+
function toast(text, kind) {
|
|
700
|
+
try { showToast(text, kind, kind === 'warn' ? { persistent: true } : undefined); } catch (error) { console.warn('tool update toast failed', error); }
|
|
701
|
+
}
|
|
702
|
+
|
|
653
703
|
$check.addEventListener('click', async function () {
|
|
704
|
+
if (checking || approving) return;
|
|
705
|
+
var controller = new AbortController();
|
|
706
|
+
checkController = controller;
|
|
654
707
|
checking = true;
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
708
|
+
var said = ''; // what the end of the check says: in the live line when the dialog is open, in a corner message when it was closed
|
|
709
|
+
var failed = false;
|
|
710
|
+
var downloadProblem = false;
|
|
658
711
|
try {
|
|
712
|
+
answerLost = false;
|
|
713
|
+
quietAsks = 0;
|
|
714
|
+
syncControls();
|
|
715
|
+
// A button just disabled had the keyboard (Check, Approve or Remove from list), or focus was already outside the dialog
|
|
716
|
+
// (a browser that does not focus a button on a click): left alone, focus is on the page behind the dialog, where Esc is
|
|
717
|
+
// not heard and Tab leaves the dialog. Parked on the title (as open() does), Esc closes it and Tab stays inside.
|
|
718
|
+
var held = document.activeElement;
|
|
719
|
+
if (!held || !$dialog.contains(held) || held.disabled) $title.focus();
|
|
720
|
+
$live.textContent = ''; // the panel below says what is being checked; the live line is for what came of it
|
|
721
|
+
paintPill(); // the pill carries the running check once the dialog is closed; with the dialog open it also paints the panel
|
|
659
722
|
var ticket = nextTicket();
|
|
660
|
-
var answer = await call('/api/tool-updates/check', 'POST');
|
|
661
|
-
|
|
723
|
+
var answer = await call('/api/tool-updates/check', 'POST', undefined, controller.signal);
|
|
724
|
+
// Only the server's own answer can be the view: a body that is not one must not replace what is on screen.
|
|
725
|
+
if (answer && answer.ok === true) applyView(ticket, answer);
|
|
726
|
+
// Said from the check's own answer, not from the view on screen: a dialog reopened mid-check re-reads the server, and that
|
|
727
|
+
// re-read (the previous pass's result) takes a later ticket than this answer and so wins the view.
|
|
662
728
|
var n = (answer.offers || []).length;
|
|
663
|
-
|
|
729
|
+
said = n ? plural(n, 'workflow is', 'workflows are') + ' ready to approve.' : 'No workflows to approve.';
|
|
730
|
+
downloadProblem = !!(answer.downloads && answer.downloads.error);
|
|
731
|
+
// Not a finished check: a 200 whose body is not the server's answer (ok is not true), or one carrying the server's own
|
|
732
|
+
// sentence (AWARE not asked, or too old). Both are read from THIS request's answer, never from a newer re-read.
|
|
733
|
+
if (answer.ok !== true || answer.sentence) {
|
|
734
|
+
console.warn('tool update check did not run', answer.sentence || answer.error || '');
|
|
735
|
+
failed = true;
|
|
736
|
+
said = 'The tool update check did not go through. Try again in a moment.';
|
|
737
|
+
}
|
|
664
738
|
// The cleanup pass Check now started keeps running after this answer, and may already have finished and been
|
|
665
739
|
// re-read: read the server again so this (older) answer never stands over a newer cleanup result.
|
|
666
740
|
void refresh();
|
|
667
741
|
} catch (error) {
|
|
668
|
-
|
|
742
|
+
if (answerLost) {
|
|
743
|
+
// The server said three times running that nothing was running: it finished and its answer never got here, or the
|
|
744
|
+
// request never reached it. The page cannot tell which, so it says only what it knows and reads the view again.
|
|
745
|
+
said = 'FloLess got no answer to the check and cannot say whether it ran. Nothing is running now, and the list is what FloLess last read. You can check again.';
|
|
746
|
+
void refresh();
|
|
747
|
+
} else {
|
|
748
|
+
console.warn('tool update check failed', error);
|
|
749
|
+
failed = true;
|
|
750
|
+
said = 'The tool update check did not go through. Try again in a moment.';
|
|
751
|
+
}
|
|
669
752
|
} finally {
|
|
753
|
+
var left = !isOpen(); // closed while it ran: nothing below repaints it, moves focus into it, or writes its live line (only the button states are reset)
|
|
670
754
|
checking = false;
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
755
|
+
checkController = null;
|
|
756
|
+
answerLost = false;
|
|
757
|
+
// What came of it is said before anything is repainted, so a repaint that throws cannot swallow it.
|
|
758
|
+
if (left) {
|
|
759
|
+
if (failed) toast('The tool update check did not go through. Open Tool updates to try again.', 'warn');
|
|
760
|
+
else if (downloadProblem) toast('Tool update check finished, but downloading new tool versions ran into a problem. Open Tool updates for details.', 'warn');
|
|
761
|
+
else toast('Tool update check finished. ' + said, 'ok');
|
|
762
|
+
} else {
|
|
763
|
+
$live.textContent = said;
|
|
764
|
+
}
|
|
765
|
+
syncControls();
|
|
766
|
+
paintPill(); // also repaints an open dialog; the panel goes unless the view still says a check is running
|
|
767
|
+
if (!left) {
|
|
768
|
+
// Put focus back on Check if it is still parked on the title (above) or fell out of the dialog; anywhere else the
|
|
769
|
+
// person put it themselves.
|
|
770
|
+
var kept = document.activeElement;
|
|
771
|
+
if (!kept || kept === $title || !$dialog.contains(kept)) { if (!$check.hidden) $check.focus(); else $title.focus(); }
|
|
772
|
+
}
|
|
676
773
|
}
|
|
677
774
|
});
|
|
678
775
|
|
|
679
776
|
$approve.addEventListener('click', async function () {
|
|
680
|
-
if (!view || !view.batchId) return;
|
|
777
|
+
if (!view || !view.batchId || checking || approving) return;
|
|
681
778
|
var apps = (view.offers || []).map(function (o) { return o.app; });
|
|
682
|
-
|
|
779
|
+
approving = true;
|
|
780
|
+
syncControls();
|
|
781
|
+
$approve.textContent = 'Approving…';
|
|
683
782
|
$live.textContent = 'Approving ' + plural(apps.length, 'workflow', 'workflows') + '…';
|
|
684
783
|
try {
|
|
685
784
|
var ticket = nextTicket();
|
|
@@ -703,7 +802,8 @@
|
|
|
703
802
|
await refresh();
|
|
704
803
|
$live.textContent = 'FloLess did not hear back after your approval, so it cannot say yet which workflows moved. The list below is what is still waiting.';
|
|
705
804
|
} finally {
|
|
706
|
-
|
|
805
|
+
approving = false;
|
|
806
|
+
syncControls();
|
|
707
807
|
paint();
|
|
708
808
|
paintPill();
|
|
709
809
|
var head = document.getElementById('tool-updates-results-head');
|