clavarium 0.2.443-next.1 → 0.2.445-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/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/server/conversations.mjs +29 -8
- package/web/app.js +105 -8
- package/web/index.html +1 -1
- package/web/kit.js +30 -1
- package/web/style.css +23 -0
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.445-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.445-next.1",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
package/package.json
CHANGED
package/server/conversations.mjs
CHANGED
|
@@ -168,7 +168,10 @@ export class Conversations {
|
|
|
168
168
|
/* A move cut short leaves the machine as it was at that moment:
|
|
169
169
|
it is said, with where to look, rather than guessed at. */
|
|
170
170
|
if (c.phase === 'moving') store.patch(c.name, { phase: 'ready', step: undefined, moved: 'The server restarted while the work folder was being moved. The files are safe, in the machine: look at /work, /work.before-move and /work.moving.' });
|
|
171
|
-
|
|
171
|
+
/* A move into a shared machine cut short (14-11): back in its own machine, as it was -- never « build it
|
|
172
|
+
again », which would make its own machine anew and lose its tool's memory. */
|
|
173
|
+
if (c.phase === 'building' && c.movingTo) store.patch(c.name, { phase: 'ready', step: undefined, progress: undefined, buildingSince: undefined, sharedMachine: undefined, machineMb: undefined, machineUser: undefined, ...(c.movingFromMb ? { memoryMb: c.movingFromMb } : {}), movingTo: undefined, movingFromMb: undefined, stopped: true, moved: `The server restarted while it was moving to the shared machine ${c.movingTo}: it stays in its own machine, as it was. Move it again when you like.` });
|
|
174
|
+
else if (c.phase === 'building') store.patch(c.name, { phase: 'failed', error: 'The server restarted while this conversation was being built. Build it again, or archive it.' });
|
|
172
175
|
if (c.phase === 'restarting') store.patch(c.name, { phase: 'ready', step: undefined, restartingSince: undefined, restarted: 'The server restarted while this machine was being restarted: look at its state, and restart it again if needed.' });
|
|
173
176
|
/* An action cut short: said as such, never left running on the page. */
|
|
174
177
|
if (store.get(c.name)?.machine) store.patch(c.name, { machine: undefined, machineReport: { kind: c.machine.kind, ok: false, cut: true, at: new Date().toISOString(), steps: (c.machine.steps ?? []).filter((x) => x.state !== 'todo').map(({ id, state, s }) => ({ id, result: state === 'run' ? 'cut' : state, ...(s !== undefined ? { s } : {}) })), advice: 'look', said: 'The server restarted during this action: look at its state.' } });
|
|
@@ -1202,7 +1205,8 @@ export class Conversations {
|
|
|
1202
1205
|
const act = this.#take(name, 'move');
|
|
1203
1206
|
this.#cancelStop(name);
|
|
1204
1207
|
const now = new Date().toISOString();
|
|
1205
|
-
|
|
1208
|
+
/* `movingTo`: what a restart of this server finds, to put it back in its own machine, as it was (14-11). */
|
|
1209
|
+
this.#store.patch(name, { phase: 'building', step: `Moving to the shared machine ${machine}`, buildingSince: now, progress: buildProgress(now), movingTo: machine, movingFromMb: c.memoryMb });
|
|
1206
1210
|
this.built = this.#moving(name, c, tool, machine, size, memory, state).finally(() => this.#give(name, act));
|
|
1207
1211
|
return this.#store.get(name);
|
|
1208
1212
|
}
|
|
@@ -1213,7 +1217,7 @@ export class Conversations {
|
|
|
1213
1217
|
const carried = join(dir, 'state.tar.gz');
|
|
1214
1218
|
const back = (why) => {
|
|
1215
1219
|
/* Back to its own machine, as it was (stopped: the next opening wakes it). */
|
|
1216
|
-
this.#store.patch(name, { sharedMachine: undefined, machineMb: undefined, machineUser: undefined, memoryMb: c.memoryMb, phase: 'ready', step: undefined, progress: undefined, buildingSince: undefined, error: undefined });
|
|
1220
|
+
this.#store.patch(name, { sharedMachine: undefined, machineMb: undefined, machineUser: undefined, memoryMb: c.memoryMb, phase: 'ready', step: undefined, progress: undefined, buildingSince: undefined, error: undefined, movingTo: undefined, movingFromMb: undefined });
|
|
1217
1221
|
this.#fresh.add(name); this.#mountAgain.add(name);
|
|
1218
1222
|
try { this.renewed(name, `Not moved to the shared machine ${machine}: ${why} It stays in its own machine, as it was.`, false); } catch { /* told, nothing more */ }
|
|
1219
1223
|
};
|
|
@@ -1222,12 +1226,26 @@ export class Conversations {
|
|
|
1222
1226
|
if (state === 'Running') await this.#vms.exec(name, ['tmux', '-L', SOCKET, 'kill-server'], { timeoutMs: 10_000 }).catch(() => {});
|
|
1223
1227
|
if (tool.state) {
|
|
1224
1228
|
this.#store.patch(name, { step: `Taking ${tool.label}'s state along` });
|
|
1225
|
-
|
|
1229
|
+
/* Through its work folder, as a copy reads it (14-11): the VM manager's output stalls past ~36 KB on
|
|
1230
|
+
the owner's server -- a move then waited for ever. Its size read as it grows, said; quiet too long: ended. */
|
|
1231
|
+
const workDir = c.work === 'kept' && typeof this.workFolder === 'function' ? this.workFolder(name) : '';
|
|
1232
|
+
const carryId = workDir ? `move-${name}-${Date.now()}` : '';
|
|
1233
|
+
const inWork = carryId ? join(workDir, '.clavarium-carry', `${carryId}.tgz`) : '';
|
|
1234
|
+
if (inWork) await Promise.race([Promise.resolve().then(() => this.mounted(name, true)).catch(() => {}), new Promise((r) => { setTimeout(r, MOUNTED_MS).unref?.(); })]);
|
|
1235
|
+
const { stream, child } = await this.exportState(name, inWork ? { toWork: carryId } : {});
|
|
1236
|
+
let read = 0; let lastAt = Date.now(); let stalled = false;
|
|
1237
|
+
const grew = (n) => { if (n <= read) return; read = n; lastAt = Date.now(); this.#store.patch(name, { step: `Taking ${tool.label}'s state along: ${sizeWords(read)}` }); };
|
|
1238
|
+
const sizing = setInterval(() => {
|
|
1239
|
+
if (inWork) { try { grew(statSync(inWork).size); } catch { /* not there yet */ } }
|
|
1240
|
+
if (Date.now() - lastAt >= COPY_QUIET_MS) { stalled = true; child.kill('SIGKILL'); }
|
|
1241
|
+
}, 1000);
|
|
1226
1242
|
const failed = new Promise((ok) => child.on('error', () => ok(-1)));
|
|
1227
|
-
const file = createWriteStream(carried, { mode: 0o600 });
|
|
1228
|
-
stream.pipe(file);
|
|
1229
|
-
const code = await Promise.race([new Promise((ok) => child.on('close', ok)), failed]);
|
|
1230
|
-
await new Promise((ok) => (file.writableFinished ? ok() : file.on('finish', ok)));
|
|
1243
|
+
const file = inWork ? null : createWriteStream(carried, { mode: 0o600 });
|
|
1244
|
+
if (file) { stream.on('data', (d) => grew(read + d.length)); stream.pipe(file); } else stream.resume();
|
|
1245
|
+
const code = await Promise.race([new Promise((ok) => child.on('close', ok)), failed]).finally(() => clearInterval(sizing));
|
|
1246
|
+
if (file) await new Promise((ok) => (file.writableFinished ? ok() : file.on('finish', ok)));
|
|
1247
|
+
if (inWork) { try { if (code === 0 && !stalled) copyFileSync(inWork, carried); } finally { rmSync(inWork, { force: true }); } }
|
|
1248
|
+
if (stalled) return back(`its tool's state stopped coming (${sizeWords(read)} read, then nothing for ${COPY_QUIET_MS / 60_000} min).`);
|
|
1231
1249
|
if (code !== 0) return back(`its tool's state could not be taken (exit ${code}${firstLine(child.said) ? `: ${firstLine(child.said)}` : ''}).`);
|
|
1232
1250
|
}
|
|
1233
1251
|
if (state !== undefined) {
|
|
@@ -1251,12 +1269,15 @@ export class Conversations {
|
|
|
1251
1269
|
try { await this.#unpack(name, c.tool, carried); } catch (error) {
|
|
1252
1270
|
this.#store.patch(name, { phase: 'ready', step: undefined });
|
|
1253
1271
|
this.ready(name);
|
|
1272
|
+
this.#store.patch(name, { movingTo: undefined, movingFromMb: undefined });
|
|
1254
1273
|
this.renewed(name, `Moved to the shared machine ${machine}, but ${tool.label}'s state did not come along (${error.message}): it starts afresh. Its old machine is kept, stopped.`, true);
|
|
1255
1274
|
return undefined;
|
|
1256
1275
|
}
|
|
1257
1276
|
this.#store.patch(name, { phase: 'ready', step: undefined });
|
|
1258
1277
|
this.ready(name);
|
|
1259
1278
|
}
|
|
1279
|
+
/* There for good: its own machine can go. */
|
|
1280
|
+
this.#store.patch(name, { movingTo: undefined, movingFromMb: undefined });
|
|
1260
1281
|
await this.#vms.removeVm(old).catch(() => {});
|
|
1261
1282
|
this.renewed(name, `Moved to the shared machine ${machine}: its work folder${tool.state ? `, ${tool.label}'s state` : ''} and this chat came along. Its own machine is deleted.`, true);
|
|
1262
1283
|
return undefined;
|
package/web/app.js
CHANGED
|
@@ -3099,12 +3099,22 @@
|
|
|
3099
3099
|
/* A CONVERSATION'S AT HAND: its machine's three tiles, from its health (memory, disk) and its last hour
|
|
3100
3100
|
(/api/history, read at most every 30 s). */
|
|
3101
3101
|
const convHandAt = { of: '', at: 0, h: null };
|
|
3102
|
+
/* Its tiles while they are read, at once as its settings open: never those of the one shown before. */
|
|
3103
|
+
function convHandLoading(here) {
|
|
3104
|
+
const box = $('panel-tiles');
|
|
3105
|
+
if (DEVICE || !here || here.asleep || here.phase !== 'ready') return;
|
|
3106
|
+
if (box.dataset.of === here.name && box.children.length) return;
|
|
3107
|
+
box.dataset.of = here.name; box.replaceChildren(...handTilesLoading()); box.hidden = false; KIT.loading(box);
|
|
3108
|
+
}
|
|
3102
3109
|
async function paintConvHand(here) {
|
|
3103
3110
|
const box = $('panel-tiles');
|
|
3104
3111
|
if (DEVICE || !here || here.asleep || here.phase !== 'ready') { box.hidden = true; return; }
|
|
3105
|
-
|
|
3112
|
+
convHandLoading(here);
|
|
3113
|
+
/* One reading at a time, awaited by every painting meanwhile: never tiles drawn without it while it comes. */
|
|
3114
|
+
if (convHandAt.of !== here.name || Date.now() - convHandAt.at > 30_000) { convHandAt.of = here.name; convHandAt.at = Date.now(); convHandAt.h = handHistory(here.name); }
|
|
3115
|
+
const h = await convHandAt.h;
|
|
3106
3116
|
if (current !== here.name) return;
|
|
3107
|
-
const
|
|
3117
|
+
const health = here.health;
|
|
3108
3118
|
const tiles = [];
|
|
3109
3119
|
const mem = health?.memory;
|
|
3110
3120
|
const memUsed = mem?.totalMb ? 100 - (mem.availableMb / mem.totalMb) * 100 : lastOf(h?.memory);
|
|
@@ -3116,6 +3126,7 @@
|
|
|
3116
3126
|
if (h) tiles.push(handTile(uiSaid('set-cpu', 'CPU'), cpu, uiSaid(here.cpus === 1 ? 'set-core' : 'set-cores', here.cpus === 1 ? '1 core' : '{n} cores', { n: here.cpus ?? 1 }), h.cpu, levelAt(cpu ?? 0)));
|
|
3117
3127
|
for (const t of tiles) t.addEventListener('click', () => { openChapter('machine')?.scrollIntoView({ block: 'start' }); });
|
|
3118
3128
|
box.replaceChildren(...tiles); box.hidden = tiles.length === 0;
|
|
3129
|
+
KIT.loading(box, false);
|
|
3119
3130
|
}
|
|
3120
3131
|
/* What each folded chapter of a conversation says: its state now. */
|
|
3121
3132
|
function paintConvStates(here) {
|
|
@@ -4338,6 +4349,9 @@
|
|
|
4338
4349
|
if (place !== 'conversations') leavePlace();
|
|
4339
4350
|
if (giving) { openGive(); return; }
|
|
4340
4351
|
goTab('settings');
|
|
4352
|
+
/* Shown at once with what is known (14-11): its rows do not come one by one while it is asked again. */
|
|
4353
|
+
if (!giving && $('panel').dataset.painted !== current) { $('panel').dataset.painted = current; void paintPanel().catch(() => {}); }
|
|
4354
|
+
if (!giving) { convHandLoading(conversations.find((x) => x.name === current)); curvesLoading($('machine-curves'), current); }
|
|
4341
4355
|
/* What it has may have changed from another screen: asked again before it is shown. */
|
|
4342
4356
|
await refresh();
|
|
4343
4357
|
await paintPanel();
|
|
@@ -7556,11 +7570,19 @@
|
|
|
7556
7570
|
for (const [i, v] of known) d += `${d ? 'L' : 'M'}${((i / n) * 100).toFixed(1)},${(22 - (v / 100) * 20).toFixed(1)}`;
|
|
7557
7571
|
const svg = svgEl('svg', { viewBox: '0 0 100 22', preserveAspectRatio: 'none', class: 'tile-spark', 'aria-hidden': 'true' });
|
|
7558
7572
|
svg.append(svgEl('path', { d, 'vector-effect': 'non-scaling-stroke' })); t.append(svg);
|
|
7559
|
-
}
|
|
7573
|
+
} else t.append(el('span', 'tile-spark'));
|
|
7560
7574
|
t.append(el('span', 'tile-sub', sub));
|
|
7561
7575
|
t.setAttribute('aria-label', `${label}: ${percent === null ? '—' : `${Math.round(percent)} %`}, ${sub}`);
|
|
7562
7576
|
return t;
|
|
7563
7577
|
}
|
|
7578
|
+
/* THE THREE TILES WHILE THEY ARE READ (14-11): their names, « … » where the figures go, bones for the bar and
|
|
7579
|
+
the line -- the size they will have, never a figure made up. */
|
|
7580
|
+
const handTilesLoading = () => [uiSaid('set-memory', 'Memory'), uiSaid('set-disk', 'Disk'), uiSaid('set-cpu', 'CPU')].map((label) => {
|
|
7581
|
+
const t = el('div', 'tile'); t.dataset.loading = '';
|
|
7582
|
+
const k = el('span', 'tile-k'); k.append(el('b', '', label), el('span', 'tile-n', '…'));
|
|
7583
|
+
t.append(k, KIT.Bone({ cls: 'tile-bar' }), KIT.Bone({ cls: 'tile-spark' }), el('span', 'tile-sub', '…'));
|
|
7584
|
+
return t;
|
|
7585
|
+
});
|
|
7564
7586
|
const lastOf = (values) => { for (let i = (values?.length ?? 0) - 1; i >= 0; i -= 1) if (values[i] !== null && values[i] !== undefined) return values[i]; return null; };
|
|
7565
7587
|
const handHistory = async (of) => (of ? fetch(`${API}/history?of=${encodeURIComponent(of)}&span=1h`).then((x) => (x.ok ? x.json() : null)).catch(() => null) : null);
|
|
7566
7588
|
/* A chip: a dot of its state and a word -- only when it says something. */
|
|
@@ -7568,6 +7590,16 @@
|
|
|
7568
7590
|
|
|
7569
7591
|
/* The server's: under the top bar of Settings. */
|
|
7570
7592
|
let lastServer = null;
|
|
7593
|
+
/* Shown at once as Settings opens, at its final size: the tiles and a chip still being read. */
|
|
7594
|
+
let handFactsRead = false;
|
|
7595
|
+
function settingsHandLoading() {
|
|
7596
|
+
if (DEVICE) return;
|
|
7597
|
+
$('settings-hand').hidden = false;
|
|
7598
|
+
const tiles = $('settings-tiles');
|
|
7599
|
+
if (!tiles.children.length) { tiles.replaceChildren(...handTilesLoading()); tiles.hidden = false; KIT.loading(tiles); }
|
|
7600
|
+
const facts = $('settings-facts');
|
|
7601
|
+
if (!facts.children.length) { handFactsRead = false; facts.replaceChildren(KIT.Bone({ cls: 'hand-chip' })); facts.hidden = false; KIT.loading(facts); }
|
|
7602
|
+
}
|
|
7571
7603
|
async function paintSettingsHand(r = lastServer) {
|
|
7572
7604
|
if (DEVICE) return;
|
|
7573
7605
|
lastServer = r;
|
|
@@ -7582,6 +7614,7 @@
|
|
|
7582
7614
|
if (h) { const most = Math.max(0, ...(h.cpu ?? []).filter((v) => v !== null)); tiles.push(handTile(uiSaid('set-cpu', 'CPU'), cpu, uiSaid('set-highest', 'highest {n} % in 1 h', { n: Math.round(most) }), h.cpu, levelAt(cpu ?? 0))); }
|
|
7583
7615
|
for (const t of tiles) t.addEventListener('click', go);
|
|
7584
7616
|
$('settings-tiles').replaceChildren(...tiles); $('settings-tiles').hidden = tiles.length === 0;
|
|
7617
|
+
KIT.loading($('settings-tiles'), false);
|
|
7585
7618
|
paintSettingsFacts();
|
|
7586
7619
|
}
|
|
7587
7620
|
/* Its chips: the version, a conversation that is not well, a voice box away. */
|
|
@@ -7592,14 +7625,17 @@
|
|
|
7592
7625
|
if (u?.installed) {
|
|
7593
7626
|
if (u.available) chips.push(handChip('warn', uiSaid('set-update-out', '{v} is out', { v: u.available.version ?? u.available }), () => { openChapter('s-updates')?.scrollIntoView({ block: 'start' }); }));
|
|
7594
7627
|
else if (u.version) chips.push(handChip('ok', uiSaid('set-up-to-date', 'Up to date · {v}', { v: u.version })));
|
|
7595
|
-
}
|
|
7628
|
+
} else if (u?.version) chips.push(handChip('ok', `Clavarium ${u.version}`));
|
|
7596
7629
|
if (handWifi?.using?.ssid) chips.push(handChip('ok', uiSaid('set-wifi-on', 'Wi-Fi · {name}', { name: handWifi.using.ssid })));
|
|
7597
7630
|
for (const c of conversations.filter((x) => (x.health?.problems ?? []).some((p) => p.level === 'warn' || p.level === 'bad'))) {
|
|
7598
7631
|
const bad = c.health.problems.some((p) => p.level === 'bad');
|
|
7599
7632
|
chips.push(handChip(bad ? 'bad' : 'warn', `${c.title || c.name} · ${uiSaid('set-not-well', 'not well')}`, () => select(c.name, { step: true })));
|
|
7600
7633
|
}
|
|
7601
7634
|
for (const b of (handBoxes ?? []).filter((x) => x.online === false)) chips.push(handChip('off', uiSaid('set-box-away', '{name} offline', { name: b.name })));
|
|
7635
|
+
/* Nothing to say yet, while some is still read: its bone stays (the row does not come and go). */
|
|
7636
|
+
if (!chips.length && !handFactsRead) return;
|
|
7602
7637
|
$('settings-facts').replaceChildren(...chips); $('settings-facts').hidden = chips.length === 0;
|
|
7638
|
+
KIT.loading($('settings-facts'), false);
|
|
7603
7639
|
}
|
|
7604
7640
|
let handBoxes = null;
|
|
7605
7641
|
$('hand-check').addEventListener('click', () => { const sheet = $('settings'); sheet.showTab?.('automatic'); openChapter('s-updates'); $('updates-check').click(); $('settings-updates-top').scrollIntoView({ block: 'start' }); });
|
|
@@ -7644,11 +7680,13 @@
|
|
|
7644
7680
|
const last = Array.isArray(events) ? events[0] : null;
|
|
7645
7681
|
if (last) chapterNow('s-events', `${agoSaid(last.at)} · ${String(last.text).slice(0, 60)}`);
|
|
7646
7682
|
handBoxes = await fetch(`${API}/boxes`).then((r) => (r.ok ? r.json() : null)).catch(() => null);
|
|
7683
|
+
handFactsRead = true;
|
|
7647
7684
|
paintSettingsFacts();
|
|
7648
7685
|
}
|
|
7649
7686
|
for (const d of document.querySelectorAll('#settings details.chapter')) d.addEventListener('toggle', () => { if (!d.open) void paintSettingsStates(); });
|
|
7650
7687
|
async function openSettings({ push = true } = {}) {
|
|
7651
7688
|
enterPlace('settings', push);
|
|
7689
|
+
settingsHandLoading(); serverLoading();
|
|
7652
7690
|
void paintSettingsFeatures().catch(() => {});
|
|
7653
7691
|
void paintAlerts().catch(() => {});
|
|
7654
7692
|
void paintWords().catch(() => {});
|
|
@@ -8168,6 +8206,7 @@
|
|
|
8168
8206
|
what can be done -- move the machines to it, mount it, prepare (erase) it -- or why not. */
|
|
8169
8207
|
async function paintMoveMachines() {
|
|
8170
8208
|
const size = (mb) => (mb >= 1024 * 1024 ? `${(mb / 1024 / 1024).toFixed(1)} TB` : GB(mb));
|
|
8209
|
+
listLoading($('move-machines-rows'), 'move-machines', 2);
|
|
8171
8210
|
const [p, m] = await Promise.all([fetch(`${API}/machines/disks`).then((r) => (r.ok ? r.json() : null)).catch(() => null), fetch(`${API}/machines/moving`).then((r) => (r.ok ? r.json() : null)).catch(() => null)]);
|
|
8172
8211
|
const old = await fetch(`${API}/machines/places`).then((r) => (r.ok ? r.json() : null)).catch(() => null);
|
|
8173
8212
|
const rows = $('move-machines-rows'); rows.replaceChildren();
|
|
@@ -8255,7 +8294,7 @@
|
|
|
8255
8294
|
}
|
|
8256
8295
|
if (!p.disks.some((d) => !d.system)) rows.append(el('p', 'hint', 'No other disk: plug one in (or add one to this server), then open this again.'));
|
|
8257
8296
|
}
|
|
8258
|
-
$('move-machines-box').addEventListener('toggle', () => { if ($('move-machines-box').open) void paintMoveMachines(); });
|
|
8297
|
+
$('move-machines-box').addEventListener('toggle', () => { if ($('move-machines-box').open) void paintMoveMachines().finally(() => KIT.loading($('move-machines-rows'), false, 'move-machines')); });
|
|
8259
8298
|
/* NETWORK: this server's Wi-Fi (server/wifi.mjs). The networks it sees, the one it is on, another
|
|
8260
8299
|
joined with its password, one it keeps forgotten. A join only STARTS a switch: the host goes back
|
|
8261
8300
|
to the network before by itself when the new one does not work within a minute -- this page may
|
|
@@ -8461,6 +8500,7 @@
|
|
|
8461
8500
|
let eventsShown = []; let eventsAsk = 0;
|
|
8462
8501
|
async function paintEvents({ more = false } = {}) {
|
|
8463
8502
|
const ask = ++eventsAsk;
|
|
8503
|
+
if (!more) listLoading($('events-list'), 'events', 6);
|
|
8464
8504
|
const before = more && eventsShown.length ? eventsShown.at(-1).at : '';
|
|
8465
8505
|
const q = new URLSearchParams({ kind: $('events-kind').value, q: $('events-q').value.trim(), limit: '100', ...(before ? { before } : {}) });
|
|
8466
8506
|
const got = await fetch(`${API}/events?${q}`).then((r) => (r.ok ? r.json() : null)).catch(() => null);
|
|
@@ -8485,6 +8525,7 @@
|
|
|
8485
8525
|
if (e.who && !e.text.includes(e.who)) li.append(el('span', 'event-who', e.who));
|
|
8486
8526
|
list.append(li);
|
|
8487
8527
|
}
|
|
8528
|
+
KIT.loading(list, false, 'events');
|
|
8488
8529
|
$('events-said').textContent = eventsShown.length ? '' : 'Nothing yet.';
|
|
8489
8530
|
$('events-more').hidden = got.length < 100;
|
|
8490
8531
|
}
|
|
@@ -8503,6 +8544,7 @@
|
|
|
8503
8544
|
async function paintJobsChapter() {
|
|
8504
8545
|
clearTimeout(jobsTimer);
|
|
8505
8546
|
if (!$('settings-jobs-top').open) return;
|
|
8547
|
+
listLoading($('jobs-list'), 'jobs', 2);
|
|
8506
8548
|
const got = await fetch(`${API}/jobs`).then((r) => (r.ok ? r.json() : null)).catch(() => null);
|
|
8507
8549
|
if (!got) { $('jobs-said').textContent = uiSaid('set-jobs-unread', 'Cannot be read just now'); return; }
|
|
8508
8550
|
const line = (j, result) => {
|
|
@@ -8521,7 +8563,7 @@
|
|
|
8521
8563
|
const parts = [];
|
|
8522
8564
|
if (got.running.length) parts.push(el('h3', '', uiSaid('set-jobs-running', 'Under way')), ...got.running.map((j) => line(j, 'running')));
|
|
8523
8565
|
if (got.done.length) parts.push(el('h3', '', uiSaid('set-jobs-today', 'Today')), ...got.done.map((j) => line(j, j.result === 'done' ? 'done' : 'failed')));
|
|
8524
|
-
$('jobs-list').replaceChildren(...parts);
|
|
8566
|
+
$('jobs-list').replaceChildren(...parts); KIT.loading($('jobs-list'), false, 'jobs');
|
|
8525
8567
|
$('jobs-said').textContent = parts.length ? '' : uiSaid('set-jobs-none', 'Nothing today');
|
|
8526
8568
|
if (got.running.length) jobsTimer = setTimeout(() => { void paintJobsChapter(); }, 5000);
|
|
8527
8569
|
}
|
|
@@ -8634,6 +8676,22 @@
|
|
|
8634
8676
|
if (r.marks?.length) box.append(el('small', 'hint curve-legend curve-legend-oom', `● ${r.marks.length === 1 ? 'a program was' : `${r.marks.length} times a program was`} stopped for lack of memory`));
|
|
8635
8677
|
return box;
|
|
8636
8678
|
}
|
|
8679
|
+
/* Its three curves while they are read (14-11): their names, « … », a bone where each line goes -- the size
|
|
8680
|
+
they will have; those of another machine are never left in sight meanwhile. The server's say its reserve. */
|
|
8681
|
+
function curvesLoading(box, of = box.dataset.of) {
|
|
8682
|
+
if (DEVICE || !of || box.dataset.drawn === of) return;
|
|
8683
|
+
box.dataset.drawn = of;
|
|
8684
|
+
box.querySelector('.curves-row').replaceChildren(...CURVES.map(([key, label]) => {
|
|
8685
|
+
const f = el('figure', 'curve'); f.dataset.measure = key; f.dataset.loading = '';
|
|
8686
|
+
const head = el('figcaption', 'curve-head'); head.append(el('b', '', label), el('span', 'curve-now', '…'), el('span', 'curve-max', ''));
|
|
8687
|
+
const plot = el('div', 'curve-plot'); plot.append(KIT.Bone());
|
|
8688
|
+
const foot = el('div', 'curve-foot'); foot.append(el('span', '', '\u00a0'));
|
|
8689
|
+
f.append(head, plot, foot);
|
|
8690
|
+
if (of === 'server' && key !== 'cpu') f.append(el('small', 'hint curve-legend', '\u00a0'));
|
|
8691
|
+
return f;
|
|
8692
|
+
}));
|
|
8693
|
+
box.hidden = false; KIT.loading(box);
|
|
8694
|
+
}
|
|
8637
8695
|
const curvesAt = new WeakMap();
|
|
8638
8696
|
async function paintCurves(box, { force = false } = {}) {
|
|
8639
8697
|
const of = box.dataset.of; if (!of) { box.hidden = true; return; }
|
|
@@ -8641,10 +8699,12 @@
|
|
|
8641
8699
|
const was = curvesAt.get(box);
|
|
8642
8700
|
if (!force && was && was.of === of && was.span === span && Date.now() - was.at < 30_000) return;
|
|
8643
8701
|
curvesAt.set(box, { of, span, at: Date.now() });
|
|
8702
|
+
curvesLoading(box, of);
|
|
8644
8703
|
const r = await fetch(`${API}/history?of=${encodeURIComponent(of)}&span=${span}`).then((x) => (x.ok ? x.json() : null)).catch(() => null);
|
|
8645
8704
|
if (box.dataset.of !== of) return;
|
|
8646
|
-
box.hidden = !r; if (!r) return;
|
|
8705
|
+
box.hidden = !r; if (!r) { delete box.dataset.drawn; curvesAt.delete(box); return; }
|
|
8647
8706
|
box.querySelector('.curves-row').replaceChildren(...CURVES.map(([key, label]) => drawCurve(r, key, label)));
|
|
8707
|
+
KIT.loading(box, false);
|
|
8648
8708
|
}
|
|
8649
8709
|
for (const box of document.querySelectorAll('.curves')) {
|
|
8650
8710
|
box.querySelector('.curves-span').addEventListener('click', (event) => {
|
|
@@ -8896,6 +8956,39 @@
|
|
|
8896
8956
|
addEventListener('resize', () => { clearTimeout(usageResize); usageResize = setTimeout(() => { const w = $('usage-plot').clientWidth; if (w !== usageWidth && $('settings-usage-top').open && $('usage').offsetParent !== null) paintUsageAll(); }, 80); });
|
|
8897
8957
|
/* Kept current while in sight: a new look a minute. */
|
|
8898
8958
|
setInterval(() => { if ($('settings-usage-top').open && $('usage').offsetParent !== null) void paintUsage(); }, 60_000);
|
|
8959
|
+
/* RESOURCES WHILE THEY ARE READ (14-11): a disk and the memory, at the size they had the last time on this
|
|
8960
|
+
device, bones in place of their bar, figures, donut and list -- never a figure made up. */
|
|
8961
|
+
const partsBones = (n) => { const b = el('div', 'server-parts-bones'); for (let i = 0; i < n; i += 1) b.append(KIT.Bone({ w: i % 3 === 0 ? '70%' : '55%' })); return b; };
|
|
8962
|
+
/* A list while it is read: a few bones, at the height it had the last time on this device. */
|
|
8963
|
+
function listLoading(box, key, n = 3) {
|
|
8964
|
+
if (box.children.length || box.getAttribute('aria-busy') === 'true') return;
|
|
8965
|
+
const b = el(box.tagName === 'OL' || box.tagName === 'UL' ? 'li' : 'div', 'list-bones');
|
|
8966
|
+
for (let i = 0; i < n; i += 1) b.append(KIT.Bone({ h: '1.4em', w: i % 2 ? '60%' : '80%' }));
|
|
8967
|
+
box.replaceChildren(b); KIT.loading(box, true, key);
|
|
8968
|
+
}
|
|
8969
|
+
function serverLoading() {
|
|
8970
|
+
if (DEVICE) return;
|
|
8971
|
+
curvesLoading($('server-curves'));
|
|
8972
|
+
const disks = $('server-disks');
|
|
8973
|
+
if (!disks.children.length) {
|
|
8974
|
+
const block = el('div', 'server-block'); block.dataset.loading = '';
|
|
8975
|
+
const head = el('div', 'server-head'); head.append(el('b', '', uiSaid('set-disk', 'Disk')), el('span', 'server-figures', '…'));
|
|
8976
|
+
const row = el('div', 'share-row'); row.append(KIT.Bone({ cls: 'share-donut' }), partsBones(5));
|
|
8977
|
+
block.append(head, KIT.Bone({ cls: 'server-meter' }), el('p', 'server-note', '…'), row);
|
|
8978
|
+
disks.replaceChildren(block); KIT.loading(disks, true, 'server-disks');
|
|
8979
|
+
}
|
|
8980
|
+
const mem = $('server-memory');
|
|
8981
|
+
if (mem.hidden && !$('server-memory-figures').textContent) {
|
|
8982
|
+
mem.hidden = false; mem.dataset.loading = '';
|
|
8983
|
+
$('server-memory-figures').textContent = '…'; $('server-memory-note').textContent = '…';
|
|
8984
|
+
$('server-memory-meter').classList.add('kit-bone');
|
|
8985
|
+
$('server-memory-share').replaceChildren(KIT.Bone({ cls: 'share-donut' }));
|
|
8986
|
+
$('server-memory-parts').replaceChildren(partsBones(4));
|
|
8987
|
+
KIT.loading(mem, true, 'server-memory');
|
|
8988
|
+
}
|
|
8989
|
+
/* The reserve's lines, said once read: their room kept meanwhile. */
|
|
8990
|
+
for (const id of ['reserve-now', 'promised-disk', 'promised-memory']) if (!$(id).textContent) { $(id).textContent = '…'; $(id).hidden = false; }
|
|
8991
|
+
}
|
|
8899
8992
|
async function paintServer() {
|
|
8900
8993
|
clearTimeout(serverTimer);
|
|
8901
8994
|
const r = await fetch(`${API}/server`).then((x) => (x.ok ? x.json() : null)).catch(() => null);
|
|
@@ -8922,7 +9015,7 @@
|
|
|
8922
9015
|
promised($('promised-memory'), r.promised?.memory, (mb, total) => `Memory given to running machines: ${mb} of ${total}.`);
|
|
8923
9016
|
$('server-unknown').hidden = r.known;
|
|
8924
9017
|
$('server-disks').hidden = !r.disk; $('server-memory').hidden = !r.memory;
|
|
8925
|
-
if (r.disk) paintDisks(r);
|
|
9018
|
+
if (r.disk) { paintDisks(r); KIT.loading($('server-disks'), false, 'server-disks'); }
|
|
8926
9019
|
if (r.memory) {
|
|
8927
9020
|
const mem = r.memory;
|
|
8928
9021
|
$('server-memory-figures').textContent = `${GB(mem.freeMb)} free of ${GB(mem.totalMb)}`;
|
|
@@ -8939,6 +9032,8 @@
|
|
|
8939
9032
|
...named.map(({ key, label, x }) => [label, x.sizeMb ? `uses ${GB(x.rssMb)} · given ${GB(x.sizeMb)}` : `uses ${GB(x.rssMb)}`, true, share.slot.get(key)]),
|
|
8940
9033
|
['The system and other programs', rest, false, 'rest'],
|
|
8941
9034
|
]);
|
|
9035
|
+
delete $('server-memory').dataset.loading; $('server-memory-meter').classList.remove('kit-bone');
|
|
9036
|
+
KIT.loading($('server-memory'), false, 'server-memory');
|
|
8942
9037
|
}
|
|
8943
9038
|
/* Still measuring: looked at again in a moment, while Settings is open. */
|
|
8944
9039
|
if ((r.measuring || !r.usage) && !$('settings').hidden) serverTimer = setTimeout(() => { void paintServer(); }, 4000);
|
|
@@ -8969,6 +9064,7 @@
|
|
|
8969
9064
|
async function paintMachines() {
|
|
8970
9065
|
clearTimeout(machinesTimer);
|
|
8971
9066
|
if (DEVICE) { $('settings-ch-machines').hidden = true; return; }
|
|
9067
|
+
listLoading($('machines-rows'), 'machines', 2);
|
|
8972
9068
|
const r = await fetch(`${API}/server/machines`).then((x) => (x.ok ? x.json() : null)).catch(() => null);
|
|
8973
9069
|
$('settings-ch-machines').hidden = !r;
|
|
8974
9070
|
if (!r) return;
|
|
@@ -8992,6 +9088,7 @@
|
|
|
8992
9088
|
row.append(what, acts);
|
|
8993
9089
|
rows.append(row);
|
|
8994
9090
|
}
|
|
9091
|
+
KIT.loading(rows, false, 'machines');
|
|
8995
9092
|
/* The machine manager: does it answer, since when not, waiting for its owner, the last restart. */
|
|
8996
9093
|
const g = r.manager;
|
|
8997
9094
|
const ml = $('manager-line');
|
package/web/index.html
CHANGED
|
@@ -1277,7 +1277,7 @@
|
|
|
1277
1277
|
<summary><span class="chapter-title" data-said="set-ch-s-updates">Updates</span><span class="chapter-about">Version and updates.</span></summary>
|
|
1278
1278
|
<div class="chapter-body">
|
|
1279
1279
|
<div id="updates" tabindex="-1">
|
|
1280
|
-
<div class="set-row updates-head"><div class="status-line" id="updates-line"><b id="updates-version"
|
|
1280
|
+
<div class="set-row updates-head"><div class="status-line" id="updates-line"><b id="updates-version">…</b><span id="updates-state" class="hint" role="status"></span></div><div class="set-control"><button type="button" id="updates-check">Check now</button></div></div>
|
|
1281
1281
|
<p id="updates-news" class="updates-news callout" hidden></p>
|
|
1282
1282
|
<div id="updates-relay" class="hint" hidden></div>
|
|
1283
1283
|
<div class="action-row" id="updates-offer" hidden><span class="hint" id="updates-retry-note" hidden></span><button type="button" id="updates-retry-no" hidden>Cancel</button><button type="button" id="updates-retry-yes" class="primary" hidden>Try again</button><button type="button" id="updates-apply" class="primary"></button></div>
|
package/web/kit.js
CHANGED
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
* a device are two of its kinds too (step 4).
|
|
20
20
|
* TopBar THE BAR atop every page of the right-hand pane, two variants: `main` (a conversation, a room:
|
|
21
21
|
* its views on the right) and `sub` (a page of its own or inside one: a way back on the right)
|
|
22
|
+
* Bone, loading WHILE IT LOADS (14-11): bars in place of what is read, the area at its final size; then it fades in
|
|
22
23
|
* ShareDonut who takes a whole (memory, a disk): a small donut, its slices from shareSlices, the main
|
|
23
24
|
* figure in its middle; ShareKey, a slice's swatch beside its row in the list
|
|
24
25
|
* AssetIcon an asset's sign and colour, by its kind (one table, ASSET_ICONS)
|
|
@@ -429,6 +430,34 @@
|
|
|
429
430
|
return root;
|
|
430
431
|
}
|
|
431
432
|
|
|
433
|
+
/* ---------- WHILE IT LOADS (14-11): no area grows when what it shows arrives ----------
|
|
434
|
+
Bone: a quiet bar where a figure, a line or a chart will be, sized by the page's style (`cls`) or `w`/`h`;
|
|
435
|
+
it shimmers slowly (still under reduced motion). Never a figure made up meanwhile (no « 0 % »).
|
|
436
|
+
loading(box, true, key): the box says it is busy, and keeps the height it had the last time it was read on
|
|
437
|
+
this device (`key`: a size only, never a figure). loading(box, false, key): it lets go of that height,
|
|
438
|
+
remembers the new one, and what it shows fades in -- only when it was waiting (a refresh does not blink). */
|
|
439
|
+
function Bone({ cls = '', w = '', h = '' } = {}) {
|
|
440
|
+
const b = node('span', `kit-bone${cls ? ` ${cls}` : ''}`); b.setAttribute('aria-hidden', 'true');
|
|
441
|
+
if (w) b.style.width = w; if (h) b.style.height = h;
|
|
442
|
+
return b;
|
|
443
|
+
}
|
|
444
|
+
const SIZES = 'clavarium.sizes';
|
|
445
|
+
const sizesKept = () => { try { return JSON.parse(localStorage.getItem(SIZES) ?? '{}') ?? {}; } catch { return {}; } };
|
|
446
|
+
function loading(box, on = true, key = '') {
|
|
447
|
+
if (!box) return;
|
|
448
|
+
if (on) {
|
|
449
|
+
box.setAttribute('aria-busy', 'true');
|
|
450
|
+
const h = key ? Number(sizesKept()[key]) : 0;
|
|
451
|
+
if (h > 0) box.style.minHeight = `${h}px`;
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
454
|
+
if (box.getAttribute('aria-busy') !== 'true') return;
|
|
455
|
+
box.removeAttribute('aria-busy'); box.style.minHeight = '';
|
|
456
|
+
if (key && box.offsetHeight > 0) { const all = sizesKept(); all[key] = box.offsetHeight; try { localStorage.setItem(SIZES, JSON.stringify(all)); } catch { /* a private window */ } }
|
|
457
|
+
box.classList.remove('kit-settle'); void box.offsetWidth; box.classList.add('kit-settle');
|
|
458
|
+
box.addEventListener('animationend', () => box.classList.remove('kit-settle'), { once: true });
|
|
459
|
+
}
|
|
460
|
+
|
|
432
461
|
/* ---------- ASSETS (06-11, the unified assets, step 1: the pieces; the screens move to them in step 2) ---------- */
|
|
433
462
|
|
|
434
463
|
/* AN ASSET'S SIGN, by its kind: the icon set's name (Lucide, icons.js), or '' for one drawn here (a binder).
|
|
@@ -1102,7 +1131,7 @@
|
|
|
1102
1131
|
AssetIcon, AssetCard, Holders, MemberStack, memberStackModel, roomPatch, RightsBadge, RightsPicker, AssetList, assetListModel, deviceItems, AccessList, accessModel, AssetPanel, AssetDelete, AssetPicker, assetPickModel, RIGHT_SAME,
|
|
1103
1132
|
memberLevel, groupLevels, groupLevel, groupFanOut, skippedSaid, GroupChip,
|
|
1104
1133
|
ASSET_ICONS, ASSET_KINDS, RIGHTS, RIGHT_LEVELS, MCP_WORDS, rightsKey, rightsFor, rightOf, storedOf, lightest, rightWord,
|
|
1105
|
-
shareSlices, ShareDonut, ShareKey,
|
|
1134
|
+
shareSlices, ShareDonut, ShareKey, Bone, loading,
|
|
1106
1135
|
STATES, STATE_WORDS, stateOf, hueOf, initialOf, IDLE_MS, idleFor, idleWords, tidyList,
|
|
1107
1136
|
setWords(fn) { if (typeof fn === 'function') words = fn; },
|
|
1108
1137
|
StatusDot, Avatar, Chips, Switch, Segmented, InlineConfirm, ConvCard, StepFlow, SecretPicker, NewAsset, TopBar,
|
package/web/style.css
CHANGED
|
@@ -3151,3 +3151,26 @@ a.button[aria-disabled] { opacity: .5; pointer-events: none; }
|
|
|
3151
3151
|
.cm-toast[data-tone="ok"] > span { color: var(--ok); }
|
|
3152
3152
|
.cm-toast[data-tone="bad"] > span { color: var(--danger); }
|
|
3153
3153
|
.cm-toast button { flex: none; }
|
|
3154
|
+
/* WHILE IT LOADS (14-11, kit.js Bone, loading): quiet bars in place of what is read, the area at its final size;
|
|
3155
|
+
a slow shimmer, none under reduced motion; what arrives fades in. */
|
|
3156
|
+
/* Its own size only where the page's style gives none (:where weighs nothing): a bone in a tile's bar is that bar. */
|
|
3157
|
+
:where(.kit-bone) { display: block; height: .8em; border-radius: 4px; }
|
|
3158
|
+
.kit-bone.kit-bone { background-color: color-mix(in srgb, var(--ink2) 16%, transparent); }
|
|
3159
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
3160
|
+
.kit-bone.kit-bone { background-image: linear-gradient(90deg, transparent 0, color-mix(in srgb, var(--ink2) 14%, transparent) 50%, transparent 100%); background-size: 200% 100%; background-repeat: no-repeat; animation: kit-shimmer 1.6s ease-in-out infinite; }
|
|
3161
|
+
.kit-settle { animation: kit-settle .15s ease-out; }
|
|
3162
|
+
}
|
|
3163
|
+
@keyframes kit-shimmer { from { background-position: 150% 0; } to { background-position: -50% 0; } }
|
|
3164
|
+
@keyframes kit-settle { from { opacity: 0; } }
|
|
3165
|
+
[aria-busy="true"] .tile, .tile[data-loading] { cursor: default; }
|
|
3166
|
+
.tile[data-loading] .tile-n, .tile[data-loading] .tile-sub, .curve[data-loading] .curve-now, .server-block[data-loading] .server-figures { color: var(--ink2); }
|
|
3167
|
+
/* A tile keeps the room of its small line even with none to draw, and of two lines of words on a phone. */
|
|
3168
|
+
span.tile-spark { display: block; height: 22px; }
|
|
3169
|
+
@media (max-width: 520px) { .hand-tiles .tile-sub { line-height: 1.3; min-height: 2.6em; } }
|
|
3170
|
+
.curve-plot > .kit-bone { height: 72px; margin-top: 4px; }
|
|
3171
|
+
.hand-chip.kit-bone { width: 9rem; height: 24px; border: 0; padding: 0; border-radius: 999px; }
|
|
3172
|
+
.hand-chip.kit-bone::before { content: none; }
|
|
3173
|
+
.server-meter.kit-bone { height: 10px; border: 0; }
|
|
3174
|
+
.share-donut.kit-bone { border-radius: 50%; }
|
|
3175
|
+
.server-parts-bones { display: grid; gap: 8px; flex: 1 1 auto; min-width: 0; padding-top: 4px; }
|
|
3176
|
+
.list-bones { display: grid; gap: 10px; padding: 8px 0; }
|