clavarium 0.2.464-next.1 → 0.2.466-next.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/deploy/updater.mjs +12 -3
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/server/bridge.mjs +10 -3
- package/server/health.mjs +6 -0
- package/server/main.mjs +5 -2
- package/server/revive.mjs +14 -10
- package/web/app.js +16 -5
package/deploy/updater.mjs
CHANGED
|
@@ -85,6 +85,10 @@ const WATCH_EVERY_MS = 3600_000;
|
|
|
85
85
|
const WATCH_RECENT_MS = 24 * 3600_000;
|
|
86
86
|
const HISTORY_MAX = 30;
|
|
87
87
|
const ASK_EVERY_MS = 6 * 3600_000;
|
|
88
|
+
/* A VERSION THAT COULD NOT EVEN BE FETCHED (16-11: npm asked one minute after it came out, before every mirror
|
|
89
|
+
had it): nothing of it ran here, so it is tried again by itself, this long after, this many times at most. */
|
|
90
|
+
export const FETCH_AGAIN_MS = 30 * 60_000;
|
|
91
|
+
export const FETCH_TRIES = 3;
|
|
88
92
|
/* Between "Switching" said in state.json and the server stopped: the pages ask the server every
|
|
89
93
|
10 seconds at most (app.js), and the server says it in each answer (updates.mjs, notice): each
|
|
90
94
|
gives way to the maintenance page before the server goes. */
|
|
@@ -602,7 +606,7 @@ export class Updater {
|
|
|
602
606
|
const unlock = this.#lock();
|
|
603
607
|
try {
|
|
604
608
|
let release;
|
|
605
|
-
try { release = await this.prepare({ version }); } catch (error) { this.#history({ action: 'update', from: from?.version ?? null, to: version, result: 'failed', why: error.message }); throw error; }
|
|
609
|
+
try { release = await this.prepare({ version }); } catch (error) { this.#history({ action: 'update', from: from?.version ?? null, to: version, result: 'failed', why: error.message, ...(/^npm could not install /.test(error.message) ? { fetch: true } : {}) }); throw error; }
|
|
606
610
|
const before = this.#dataFormat();
|
|
607
611
|
let archive;
|
|
608
612
|
try {
|
|
@@ -714,8 +718,13 @@ export class Updater {
|
|
|
714
718
|
const available = await this.check();
|
|
715
719
|
if (!available) return 'up to date';
|
|
716
720
|
if (conf.MODE === 'ask') return `${available} is out: waiting for the owner`;
|
|
717
|
-
/* A version that failed here is not tried again by itself: the owner can, from Settings.
|
|
718
|
-
|
|
721
|
+
/* A version that failed here is not tried again by itself: the owner can, from Settings. One that only
|
|
722
|
+
could not be fetched (nothing of it ran) is, later, a few times. */
|
|
723
|
+
const failed = (state.history ?? []).filter((h) => h.to === available && h.action === 'update' && h.result !== 'done');
|
|
724
|
+
if (failed.some((h) => h.fetch !== true)) return `${available} failed here before: not tried again by itself`;
|
|
725
|
+
if (failed.length >= FETCH_TRIES) return `${available} could not be fetched ${failed.length} times: not tried again by itself`;
|
|
726
|
+
const lastAt = Math.max(...failed.map((h) => new Date(h.at ?? 0).getTime()), -Infinity);
|
|
727
|
+
if (failed.length && now - lastAt < FETCH_AGAIN_MS) return `${available} could not be fetched: tried again later`;
|
|
719
728
|
const why = await this.busy(); if (why) return why;
|
|
720
729
|
await this.apply(available);
|
|
721
730
|
/* What the history says, not what was hoped: a version that did not start was undone. */
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.466-next.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "clavarium",
|
|
9
|
-
"version": "0.2.
|
|
9
|
+
"version": "0.2.466-next.1",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
package/package.json
CHANGED
package/server/bridge.mjs
CHANGED
|
@@ -31,6 +31,9 @@ export const CLOSE_ENDED = 1000;
|
|
|
31
31
|
export const CLOSE_TAKEN = 4001;
|
|
32
32
|
/* A device whose right on this terminal was taken back (or its session ended): put out at once. */
|
|
33
33
|
export const CLOSE_REVOKED = 4003;
|
|
34
|
+
/* A page that came back by itself (a dropped connection, this server restarted) to a machine put to sleep or
|
|
35
|
+
stopped: not woken -- only a person opening it wakes it (16-11: a tab left open woke a sleeper at each update). */
|
|
36
|
+
export const CLOSE_ASLEEP = 4004;
|
|
34
37
|
/* A channel that dropped is reopened after a moment, a few times a minute at most. */
|
|
35
38
|
export const REOPEN_AFTER_MS = 1000;
|
|
36
39
|
export const REDRAW_AFTER_MS = 250;
|
|
@@ -87,7 +90,7 @@ export const sameOrigin = makeOriginCheck();
|
|
|
87
90
|
const BY_ITSELF = /\x1b\[[IO]|\x1b\[\??[>=]?[\d;]*c|\x1b\[\d+;\d+R|\x1b\][\d;]*(?:rgb:[0-9a-fA-F/]+)?(?:\x07|\x1b\\)|\x1bP[^\x1b]*\x1b\\/g;
|
|
88
91
|
export const byHand = (typed) => String(typed ?? '').replace(BY_ITSELF, '').length > 0;
|
|
89
92
|
|
|
90
|
-
export function attachBridge(server, { spawn, onLeft = () => {}, onEnded = () => {}, originOk = sameOrigin, gate = () => 'local', deviceName = () => undefined, onRejoin = () => {}, onTyped = () => {} }) {
|
|
93
|
+
export function attachBridge(server, { spawn, onLeft = () => {}, onEnded = () => {}, originOk = sameOrigin, gate = () => 'local', deviceName = () => undefined, onRejoin = () => {}, onTyped = () => {}, asleep = () => false }) {
|
|
91
94
|
const sockets = new WebSocketServer({ noServer: true });
|
|
92
95
|
const seats = new Seats();
|
|
93
96
|
/* THE DEVICES AT A TERMINAL, each with what lets it stay: asked again when the owner changes
|
|
@@ -123,9 +126,11 @@ export function attachBridge(server, { spawn, onLeft = () => {}, onEnded = () =>
|
|
|
123
126
|
} else return;
|
|
124
127
|
const cols = Number(url.searchParams.get('cols'));
|
|
125
128
|
const rows = Number(url.searchParams.get('rows'));
|
|
129
|
+
/* `resume=1`: the page comes back by itself, nobody asked to open it. */
|
|
130
|
+
const resume = url.searchParams.get('resume') === '1';
|
|
126
131
|
sockets.handleUpgrade(request, socket, head, (viewer) => {
|
|
127
132
|
if (still) { deviceSeats.set(viewer, still); viewer.on('close', () => deviceSeats.delete(viewer)); }
|
|
128
|
-
seat(viewer, name, within(cols, COLS) ? cols : 80, within(rows, ROWS) ? rows : 24);
|
|
133
|
+
seat(viewer, name, within(cols, COLS) ? cols : 80, within(rows, ROWS) ? rows : 24, resume);
|
|
129
134
|
});
|
|
130
135
|
});
|
|
131
136
|
|
|
@@ -211,7 +216,7 @@ export function attachBridge(server, { spawn, onLeft = () => {}, onEnded = () =>
|
|
|
211
216
|
return kept;
|
|
212
217
|
}
|
|
213
218
|
|
|
214
|
-
async function seat(viewer, name, cols, rows) {
|
|
219
|
+
async function seat(viewer, name, cols, rows, resume = false) {
|
|
215
220
|
const previous = seats.take(name, viewer);
|
|
216
221
|
if (previous) {
|
|
217
222
|
previous.send(JSON.stringify({ type: 'taken' }));
|
|
@@ -249,6 +254,8 @@ export function attachBridge(server, { spawn, onLeft = () => {}, onEnded = () =>
|
|
|
249
254
|
resize(taken, cols, Math.max(2, rows - 1));
|
|
250
255
|
setTimeout(() => { if (live.get(name) === taken && taken.sink === viewer) resize(taken, taken.cols, taken.rows); }, REDRAW_AFTER_MS);
|
|
251
256
|
} else {
|
|
257
|
+
/* Asleep or stopped, and nobody asked: left so; the page offers to wake it. */
|
|
258
|
+
if (resume && (() => { try { return asleep(name) === true; } catch { return false; } })()) { viewer.close(CLOSE_ASLEEP, 'asleep'); return; }
|
|
252
259
|
try { kept = await open(name, cols, rows, viewer, say); }
|
|
253
260
|
catch (error) {
|
|
254
261
|
/* Only a message written for the person is passed on. */
|
package/server/health.mjs
CHANGED
|
@@ -33,6 +33,10 @@ import { SESSION } from './conversations.mjs';
|
|
|
33
33
|
export const RESTART_OUTSIDE = '/var/tmp/clavarium-restart-asked';
|
|
34
34
|
/* What a folder that came loose looks like on a terminal (the kernel's words for ENOTCONN). */
|
|
35
35
|
const LOOSE_WORDS = 'transport endpoint is not connected|socket is not connected|ENOTCONN';
|
|
36
|
+
/* A WORK FOLDER THE VM MANAGER CANNOT TAKE BACK (16-11, tried on a test server): its mount program died, multipass
|
|
37
|
+
cannot unmount it ("Failed to terminate SSHFS mount process") and then refuses to mount it again ("already
|
|
38
|
+
mounted"). Only a restart of its machine mounts it again. */
|
|
39
|
+
export const STUCK_MOUNT = /already mounted|terminate SSHFS mount process/i;
|
|
36
40
|
|
|
37
41
|
/* How long installing the shared-folder helper in a machine may take (it comes from the snap store). */
|
|
38
42
|
export const SHARING_MS = 180_000;
|
|
@@ -143,6 +147,7 @@ export function judge(record) {
|
|
|
143
147
|
for (const path of record.remounted ?? []) add('info', 'mount', `remounted:${path}`, `${path} had come loose in the machine: it was mounted again.`);
|
|
144
148
|
for (const { path, why } of record.failed ?? []) add('bad', 'mount', `failed:${path}`, `${path} is not reachable in the machine and could not be mounted again${why ? `: ${why}` : ''}.`);
|
|
145
149
|
for (const path of record.missing ?? []) if (!(record.failed ?? []).some((f) => f.path === path)) add('warn', 'mount', `missing:${path}`, `${path} is not reachable in the machine.`);
|
|
150
|
+
if (record.stuckWork) add('bad', 'mount', 'stuck-work', 'Its work folder cannot be mounted again in its machine: its machine is restarted, its work picks up where it was.');
|
|
146
151
|
if (record.stale) add('bad', 'mount', 'stale-tool', 'Its tool is still in a folder that came loose: it is restarted, its work picks up where it was.');
|
|
147
152
|
/* Its terminal says so while its folders look well: said, nothing done (its tool may only be quoting it). */
|
|
148
153
|
else if (record.screenLoose > 0 && !(record.missing ?? []).length) add('warn', 'mount', 'screen-loose', 'Its terminal says a folder is not connected, though its folders look well.');
|
|
@@ -249,6 +254,7 @@ export class Health {
|
|
|
249
254
|
return this.#keep(name, {
|
|
250
255
|
at, state, answering: true, memory: facts.memory, oomKills: facts.oomKills ?? 0, ...(facts.oomKinds ? { oomKinds: facts.oomKinds } : {}), disks: facts.disks,
|
|
251
256
|
paths, missing: loose(), ...(remounted.length ? { remounted } : {}), ...(failed.length ? { failed } : {}), ...(links ? { links } : {}),
|
|
257
|
+
...(failed.some((f) => f.path === '/work' && STUCK_MOUNT.test(f.why ?? '')) ? { stuckWork: true } : {}),
|
|
252
258
|
...(facts.stale ? { stale: true } : {}), ...(facts.screenLoose ? { screenLoose: facts.screenLoose } : {}), ...(facts.restartAsked ? { restartAsked: true } : {}),
|
|
253
259
|
/* What was put back stays said until a later look finds nothing to put back. */
|
|
254
260
|
});
|
package/server/main.mjs
CHANGED
|
@@ -618,16 +618,17 @@ export async function startHome({ port, host, dataDir, mntDir = dataDir, gitRese
|
|
|
618
618
|
by the server, its tool only; told through its docket first (read as it starts), its chat after. */
|
|
619
619
|
const revive = new Revive({
|
|
620
620
|
restart: (name) => all.restartTool(name),
|
|
621
|
+
restartMachine: async (name) => { const r = await all.machineAction(name, 'restart', { wait: true }); return r?.ok !== false; },
|
|
621
622
|
busy: (name) => talk.pulse(name)?.busy === true,
|
|
622
623
|
taken: (name) => vms.exec(name, ['rm', '-f', RESTART_OUTSIDE], { timeoutMs: 10_000 }),
|
|
623
624
|
tell: (name, why, step) => {
|
|
624
|
-
const loose = why === 'stale';
|
|
625
|
+
const loose = why === 'stale' || why === 'stuck';
|
|
625
626
|
if (step === 'before') {
|
|
626
627
|
if (loose) try { if (dockets.on(name)) dockets.post(name, { kind: 'restarted', text: 'Your work folder came loose in your machine and was put back: your tool was restarted to see it again (what was in the old one could not be reached). Your work picks up where it was; what ran in the background stopped.' }); } catch { /* its docket may be off */ }
|
|
627
628
|
return;
|
|
628
629
|
}
|
|
629
630
|
const text = step === 'done'
|
|
630
|
-
? (loose ? 'Its work folder had come loose: its tool was restarted to see it again. Its work picks up where it was.' : 'Its tool was restarted as it asked: its work picks up where it was.')
|
|
631
|
+
? (why === 'stuck' ? 'Its work folder could not be mounted again: its machine was restarted, the folder is back. Its work picks up where it was.' : loose ? 'Its work folder had come loose: its tool was restarted to see it again. Its work picks up where it was.' : 'Its tool was restarted as it asked: its work picks up where it was.')
|
|
631
632
|
: 'Its tool could not be restarted: open its terminal and type exit, it starts again.';
|
|
632
633
|
try { talk.event(name, { kind: step === 'done' ? 'restarted' : 'machine-problem', text, topic: step === 'done' ? 'Restarted' : 'Machine', ...(step === 'done' ? {} : { tone: 'warn' }) }); } catch { /* its chat is off */ }
|
|
633
634
|
if (step === 'failed') events.add({ kind: 'machine', text: `${name}: ${text}`, conversation: name });
|
|
@@ -917,6 +918,8 @@ export async function startHome({ port, host, dataDir, mntDir = dataDir, gitRese
|
|
|
917
918
|
try { syncTargets(tethers.store(), boxes.all()); } catch (error) { console.error(`voice boxes in Tether: ${error.message}`); }
|
|
918
919
|
bridge = attachBridge(server, {
|
|
919
920
|
onRejoin: (name) => all.rejoin(name),
|
|
921
|
+
/* Put to sleep or stopped: a page that comes back by itself does not wake it (bridge.mjs, CLOSE_ASLEEP). */
|
|
922
|
+
asleep: (name) => { const c = all.get(name); return c?.asleep === true || c?.stopped === true; },
|
|
920
923
|
onTyped: (name, data) => { answerer.typed(name, data); talk.typed(name); all.touch(name); typingWatch.typed(name, data); },
|
|
921
924
|
spawn: async (name, cols, rows, say) => {
|
|
922
925
|
const [program, ...argv] = await all.open(name, say);
|
package/server/revive.mjs
CHANGED
|
@@ -7,7 +7,9 @@
|
|
|
7
7
|
*
|
|
8
8
|
* Told by health.mjs, each look (`judged`):
|
|
9
9
|
* - `stale`: a program of its tool's session is in a folder that cannot be entered;
|
|
10
|
-
* - `restartAsked`: its tool asked from outside /work (health.mjs, RESTART_OUTSIDE)
|
|
10
|
+
* - `restartAsked`: its tool asked from outside /work (health.mjs, RESTART_OUTSIDE);
|
|
11
|
+
* - `stuckWork`: its work folder cannot be mounted again (health.mjs, STUCK_MOUNT): its MACHINE is restarted
|
|
12
|
+
* (`restartMachine`), the one thing that mounts it again; it outranks the others.
|
|
11
13
|
* Then, at the next tick: its tool only is restarted (conversations.mjs restartTool, never its
|
|
12
14
|
* machine), once its turn has ended -- or after WAIT_MS anyway when stale: a tool stuck in a dead
|
|
13
15
|
* folder cannot say its turn ended (its pulse is in /work). Never a loop: not again within AGAIN_MS.
|
|
@@ -17,27 +19,29 @@ export const WAIT_MS = 5 * 60_000;
|
|
|
17
19
|
export const AGAIN_MS = 30 * 60_000;
|
|
18
20
|
|
|
19
21
|
export class Revive {
|
|
20
|
-
#restart; #busy; #tell; #taken; #now; #wanted = new Map(); #lastAt = new Map(); #going = new Set();
|
|
22
|
+
#restart; #restartMachine; #busy; #tell; #taken; #now; #wanted = new Map(); #lastAt = new Map(); #going = new Set();
|
|
21
23
|
|
|
22
24
|
/* `restart(name)`: its tool restarted, resolves with whether it was. `busy(name)`: its turn goes on.
|
|
23
25
|
`tell(name, why, step)`: said where it should be, step 'before' (its docket), then 'done' or 'failed' (main.mjs).
|
|
24
26
|
`taken(name)`: the request outside /work removed (in its machine). */
|
|
25
|
-
constructor({ restart, busy = () => false, tell = () => {}, taken = async () => {}, now = Date.now }) {
|
|
26
|
-
this.#restart = restart; this.#busy = busy; this.#tell = tell; this.#taken = taken; this.#now = now;
|
|
27
|
+
constructor({ restart, restartMachine = async () => false, busy = () => false, tell = () => {}, taken = async () => {}, now = Date.now }) {
|
|
28
|
+
this.#restart = restart; this.#restartMachine = restartMachine; this.#busy = busy; this.#tell = tell; this.#taken = taken; this.#now = now;
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
/* What one look found. A look that finds it well forgets a stale one not yet acted on. */
|
|
30
32
|
judged(name, record) {
|
|
31
33
|
if (!record || record.state !== 'Running' || record.answering !== true) return;
|
|
32
34
|
if (record.restartAsked) { void Promise.resolve().then(() => this.#taken(name)).catch(() => {}); this.#want(name, 'asked'); }
|
|
33
|
-
if (record.
|
|
34
|
-
else if (this.#
|
|
35
|
+
if (record.stuckWork) this.#want(name, 'stuck');
|
|
36
|
+
else if (record.stale) this.#want(name, 'stale');
|
|
37
|
+
else if (['stale', 'stuck'].includes(this.#wanted.get(name)?.why)) this.#wanted.delete(name);
|
|
35
38
|
}
|
|
36
39
|
|
|
37
40
|
#want(name, why) {
|
|
38
41
|
const had = this.#wanted.get(name);
|
|
39
|
-
/*
|
|
40
|
-
|
|
42
|
+
/* stuck over stale over a plain request: the stronger is acted on, even while it looks busy. */
|
|
43
|
+
const rank = { asked: 0, stale: 1, stuck: 2 };
|
|
44
|
+
if (!had || rank[why] > rank[had.why]) this.#wanted.set(name, { why, since: had?.since ?? this.#now() });
|
|
41
45
|
}
|
|
42
46
|
|
|
43
47
|
wanted(name) { return this.#wanted.get(name)?.why ?? null; }
|
|
@@ -49,14 +53,14 @@ export class Revive {
|
|
|
49
53
|
for (const [name, { why, since }] of [...this.#wanted]) {
|
|
50
54
|
if (this.#going.has(name)) continue;
|
|
51
55
|
const busy = (() => { try { return this.#busy(name); } catch { return false; } })();
|
|
52
|
-
if (busy && !(why
|
|
56
|
+
if (busy && !(why !== 'asked' && this.#now() - since >= WAIT_MS)) continue;
|
|
53
57
|
this.#wanted.delete(name);
|
|
54
58
|
if (this.#now() - (this.#lastAt.get(name) ?? -Infinity) < AGAIN_MS) continue;
|
|
55
59
|
this.#lastAt.set(name, this.#now());
|
|
56
60
|
this.#going.add(name);
|
|
57
61
|
try {
|
|
58
62
|
try { this.#tell(name, why, 'before'); } catch { /* told, nothing more */ }
|
|
59
|
-
const ok = await this.#restart(name).catch(() => false);
|
|
63
|
+
const ok = await (why === 'stuck' ? this.#restartMachine(name) : this.#restart(name)).catch(() => false);
|
|
60
64
|
if (ok) done.push(name);
|
|
61
65
|
try { this.#tell(name, why, ok ? 'done' : 'failed'); } catch { /* told, nothing more */ }
|
|
62
66
|
} finally { this.#going.delete(name); }
|
package/web/app.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
(() => {
|
|
5
5
|
const CLOSE_ENDED = 1000;
|
|
6
6
|
const CLOSE_TAKEN = 4001;
|
|
7
|
+
const CLOSE_ASLEEP = 4004;
|
|
7
8
|
const CLOSE_FAILED = 1011;
|
|
8
9
|
const RETRY_MS = 1500;
|
|
9
10
|
const NAME = /^[a-z](?:[a-z0-9-]{0,30}[a-z0-9])?$/;
|
|
@@ -821,11 +822,16 @@
|
|
|
821
822
|
/* When this wait began (kept across the tries made by the page itself), and whether the server repaired it meanwhile. */
|
|
822
823
|
let waitingSince = 0;
|
|
823
824
|
let repairedFor = '';
|
|
825
|
+
let resumeWait = false;
|
|
824
826
|
const disconnect = () => { wanted = false; clearSlow(); socket?.close(); socket = undefined; stopVoice?.(); };
|
|
825
827
|
|
|
826
828
|
/* `again`: a try made by the page itself, within the same wait. */
|
|
829
|
+
/* `resume`: the page comes back by itself (a dropped connection, the server restarted): a machine asleep stays so. */
|
|
827
830
|
function connect(options) {
|
|
828
831
|
const again = options?.again === true;
|
|
832
|
+
/* Tries the page makes by itself within that wait keep it: a server still restarting refuses a few first. */
|
|
833
|
+
const resume = options?.resume === true || (again && resumeWait);
|
|
834
|
+
resumeWait = resume;
|
|
829
835
|
disconnect();
|
|
830
836
|
if (!NAME.test(current)) return;
|
|
831
837
|
const name = current;
|
|
@@ -835,7 +841,7 @@
|
|
|
835
841
|
say('connecting', 'connecting');
|
|
836
842
|
fit.fit();
|
|
837
843
|
const scheme = location.protocol === 'https:' ? 'wss' : 'ws';
|
|
838
|
-
const where = DEVICE ? `/c/terminal?d=${pairing}&c=${encodeURIComponent(name)}&cols=${terminal.cols}&rows=${terminal.rows}` : `/terminal?c=${encodeURIComponent(name)}&cols=${terminal.cols}&rows=${terminal.rows}`;
|
|
844
|
+
const where = DEVICE ? `/c/terminal?d=${pairing}&c=${encodeURIComponent(name)}&cols=${terminal.cols}&rows=${terminal.rows}${resume ? '&resume=1' : ''}` : `/terminal?c=${encodeURIComponent(name)}&cols=${terminal.cols}&rows=${terminal.rows}${resume ? '&resume=1' : ''}`;
|
|
839
845
|
const mine = new WebSocket(`${scheme}://${location.host}${where}`);
|
|
840
846
|
socket = mine;
|
|
841
847
|
mine.binaryType = 'arraybuffer';
|
|
@@ -904,7 +910,11 @@
|
|
|
904
910
|
};
|
|
905
911
|
mine.onclose = (event) => {
|
|
906
912
|
if (socket !== mine || !wanted) return; /* we moved on, or closed it ourselves */
|
|
907
|
-
if (event.code ===
|
|
913
|
+
if (event.code === CLOSE_ASLEEP) {
|
|
914
|
+
say('asleep', 'waiting');
|
|
915
|
+
show(uiSaid('set-asleep-page', 'Asleep. It wakes only when you wake it.'), uiSaid('set-wake-it', 'Wake it'), connect); mascot('asleep');
|
|
916
|
+
if (DEVICE) void refresh();
|
|
917
|
+
} else if (event.code === CLOSE_TAKEN) {
|
|
908
918
|
say('open elsewhere', 'waiting');
|
|
909
919
|
show('This conversation is now open on another screen.', 'Use it here', connect);
|
|
910
920
|
} else if (event.code === CLOSE_ENDED) {
|
|
@@ -939,7 +949,7 @@
|
|
|
939
949
|
} else {
|
|
940
950
|
say('reconnecting', 'connecting');
|
|
941
951
|
if (DEVICE) void refresh(); /* removed meanwhile? then say it, do not retry for ever */
|
|
942
|
-
setTimeout(() => { if (socket === mine && wanted) connect(); }, RETRY_MS);
|
|
952
|
+
setTimeout(() => { if (socket === mine && wanted) connect({ resume: true }); }, RETRY_MS);
|
|
943
953
|
}
|
|
944
954
|
};
|
|
945
955
|
}
|
|
@@ -951,7 +961,7 @@
|
|
|
951
961
|
if (!current || !socket || !wanted) return;
|
|
952
962
|
const dead = socket; socket = undefined;
|
|
953
963
|
try { dead.close(); } catch { /* gone */ }
|
|
954
|
-
connect();
|
|
964
|
+
connect({ resume: true });
|
|
955
965
|
});
|
|
956
966
|
|
|
957
967
|
terminal.onData(send);
|
|
@@ -8177,7 +8187,8 @@
|
|
|
8177
8187
|
apply.dataset.retry = String(failedHere);
|
|
8178
8188
|
apply.className = failedHere ? '' : 'primary';
|
|
8179
8189
|
apply.textContent = failedHere ? `Try ${u.available} again\u2026` : `Update to ${u.available ?? ''}`;
|
|
8180
|
-
|
|
8190
|
+
const onlyFetch = failedHere && u.history.filter((h) => h.action === 'update' && h.to === u.available && h.result !== 'done').every((h) => h.fetch === true);
|
|
8191
|
+
$('updates-retry-note').textContent = !failedHere ? '' : onlyFetch ? 'It could not be downloaded before; it is tried again by itself.' : `It did not start here before. If it fails again, ${u.version} is put back.`;
|
|
8181
8192
|
$('updates-retry-note').hidden = !failedHere;
|
|
8182
8193
|
$('updates-retry-yes').hidden = true; $('updates-retry-no').hidden = true; apply.hidden = false;
|
|
8183
8194
|
/* The last thing that went wrong, said once at the top, in words: a version put
|