clavarium 0.2.448-next.1 → 0.2.449-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/api.mjs +3 -1
- package/server/carry.mjs +2 -0
- package/server/conversations.mjs +120 -22
- package/server/jobs.mjs +2 -0
- package/server/settingswords.mjs +1 -1
- package/web/app.js +11 -4
- package/web/index.html +2 -2
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.449-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.449-next.1",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
package/package.json
CHANGED
package/server/api.mjs
CHANGED
|
@@ -25,7 +25,8 @@
|
|
|
25
25
|
* POST /api/binder/suggest {id}: at most three quick actions for that card -> {actions: [{key, label, why, on, ask?}]}
|
|
26
26
|
* POST /api/mailboxes/<name>/live {smtp, email?}: that mailbox connected live too (send, move...), its password reused
|
|
27
27
|
* POST /api/conversations/<name>/erase {confirm: <its name>}: deleted for good -- its machine and its work files
|
|
28
|
-
* POST /api/conversations/<name>/into-machine {machine, machineMb?}: moved into a shared machine (#221), its tool's state along (202)
|
|
28
|
+
* POST /api/conversations/<name>/into-machine {machine, machineMb?}: moved into a shared machine (#221), its tool's state along (202);
|
|
29
|
+
* {} (no machine): out of its shared machine, into one of its own (15-11)
|
|
29
30
|
* POST /api/conversations/<name>/copy {title?, machine?, machineMb?}: a copy -- its work, its tool's state, its accesses; it untouched (202)
|
|
30
31
|
* POST /api/conversations/<name>/rebuild {reset?, confirm?}: built again; reset (confirm: its name) for a working one too
|
|
31
32
|
* POST /api/conversations/<name>/ask-first {on}: its tool asks before acting (true), or acts without asking in its machine (false, the default), from its next start
|
|
@@ -1031,6 +1032,7 @@ export async function handleApi(request, response, conversations, headers, resou
|
|
|
1031
1032
|
/* Moved into a shared machine (#221): one there already, or a new one of the size given. */
|
|
1032
1033
|
const moving = /^\/api\/conversations\/([^/]+)\/into-machine$/.exec(pathname);
|
|
1033
1034
|
if (moving) {
|
|
1035
|
+
if (body?.machine === undefined) return send(202, await conversations.moveToOwn(decodeURIComponent(moving[1]))), true;
|
|
1034
1036
|
const machineMb = body?.machineMb === undefined ? undefined : Number(body.machineMb);
|
|
1035
1037
|
return send(202, await conversations.moveToShared(decodeURIComponent(moving[1]), { machine: body?.machine, machineMb })), true;
|
|
1036
1038
|
}
|
package/server/carry.mjs
CHANGED
|
@@ -42,6 +42,8 @@ export function wholeStream(homeTar, workDir, done = () => {}) {
|
|
|
42
42
|
const home = createReadStream(homeTar, { start: 0, end: size - END - 1 });
|
|
43
43
|
home.on('error', end);
|
|
44
44
|
home.on('end', () => {
|
|
45
|
+
/* Its home read whole: its part taken away now, before the file ends (15-11, a test saw it still there). */
|
|
46
|
+
done();
|
|
45
47
|
/* Its work: every file, its carried parts left out; named work/... (a link's target left as it is). */
|
|
46
48
|
child = spawn('tar', ['-cf', '-', '-b', '1', '-C', workDir, `--exclude=./${CARRY}`, '--transform', 's,^\\.,work,S', '.'], { stdio: ['ignore', 'pipe', 'pipe'] });
|
|
47
49
|
child.stdout.pipe(gzip);
|
package/server/conversations.mjs
CHANGED
|
@@ -176,6 +176,7 @@ export class Conversations {
|
|
|
176
176
|
/* A move into a shared machine cut short (14-11): back in its own machine, as it was -- never « build it
|
|
177
177
|
again », which would make its own machine anew and lose its tool's memory. */
|
|
178
178
|
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.` });
|
|
179
|
+
else if (c.phase === 'building' && c.movingOutOf) store.patch(c.name, { phase: 'ready', step: undefined, progress: undefined, buildingSince: undefined, ...c.movingOutOf, movingOutOf: undefined, stopped: true, moved: `The server restarted while it was moving out of the shared machine ${c.movingOutOf.sharedMachine}: it stays there. Move it again when you like.` });
|
|
179
180
|
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.' });
|
|
180
181
|
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.' });
|
|
181
182
|
/* An action cut short: said as such, never left running on the page. */
|
|
@@ -1288,6 +1289,34 @@ export class Conversations {
|
|
|
1288
1289
|
return this.#store.get(name);
|
|
1289
1290
|
}
|
|
1290
1291
|
|
|
1292
|
+
/* ITS TOOL'S STATE, TAKEN ALONG for a move (12-11, 15-11): through its work folder, as a copy reads it (14-11),
|
|
1293
|
+
written to `carried`. -> undefined, or why it could not be. */
|
|
1294
|
+
async #takeState(name, c, tool, carried) {
|
|
1295
|
+
this.#store.patch(name, { step: `Taking ${tool.label}'s state along` });
|
|
1296
|
+
/* Through its work folder, as a copy reads it (14-11): the VM manager's output stalls past ~36 KB on
|
|
1297
|
+
the owner's server -- a move then waited for ever. Its size read as it grows, said; quiet too long: ended. */
|
|
1298
|
+
const workDir = c.work === 'kept' && typeof this.workFolder === 'function' ? this.workFolder(name) : '';
|
|
1299
|
+
const carryId = workDir ? `move-${name}-${Date.now()}` : '';
|
|
1300
|
+
const inWork = carryId ? join(workDir, '.clavarium-carry', `${carryId}.tgz`) : '';
|
|
1301
|
+
if (inWork) await Promise.race([Promise.resolve().then(() => this.mounted(name, true)).catch(() => {}), new Promise((r) => { setTimeout(r, MOUNTED_MS).unref?.(); })]);
|
|
1302
|
+
const { stream, child } = await this.exportState(name, inWork ? { toWork: carryId } : {});
|
|
1303
|
+
let read = 0; let lastAt = Date.now(); let stalled = false;
|
|
1304
|
+
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)}` }); };
|
|
1305
|
+
const sizing = setInterval(() => {
|
|
1306
|
+
if (inWork) { try { grew(statSync(inWork).size); } catch { /* not there yet */ } }
|
|
1307
|
+
if (Date.now() - lastAt >= COPY_QUIET_MS) { stalled = true; child.kill('SIGKILL'); }
|
|
1308
|
+
}, 1000);
|
|
1309
|
+
const failed = new Promise((ok) => child.on('error', () => ok(-1)));
|
|
1310
|
+
const file = inWork ? null : createWriteStream(carried, { mode: 0o600 });
|
|
1311
|
+
if (file) { stream.on('data', (d) => grew(read + d.length)); stream.pipe(file); } else stream.resume();
|
|
1312
|
+
const code = await Promise.race([new Promise((ok) => child.on('close', ok)), failed]).finally(() => clearInterval(sizing));
|
|
1313
|
+
if (file) await new Promise((ok) => (file.writableFinished ? ok() : file.on('finish', ok)));
|
|
1314
|
+
if (inWork) { try { if (code === 0 && !stalled) copyFileSync(inWork, carried); } finally { rmSync(inWork, { force: true }); } }
|
|
1315
|
+
if (stalled) return `its tool's state stopped coming (${sizeWords(read)} read, then nothing for ${COPY_QUIET_MS / 60_000} min).`;
|
|
1316
|
+
if (code !== 0) return `its tool's state could not be taken (exit ${code}${firstLine(child.said) ? `: ${firstLine(child.said)}` : ''}).`;
|
|
1317
|
+
return undefined;
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1291
1320
|
async #moving(name, c, tool, machine, size, memory, state) {
|
|
1292
1321
|
const old = vmName(name);
|
|
1293
1322
|
const dir = mkdtempSync(join(tmpdir(), 'clv-move-'));
|
|
@@ -1302,28 +1331,8 @@ export class Conversations {
|
|
|
1302
1331
|
this.drop(name);
|
|
1303
1332
|
if (state === 'Running') await this.#vms.exec(name, ['tmux', '-L', SOCKET, 'kill-server'], { timeoutMs: 10_000 }).catch(() => {});
|
|
1304
1333
|
if (tool.state) {
|
|
1305
|
-
this.#
|
|
1306
|
-
|
|
1307
|
-
the owner's server -- a move then waited for ever. Its size read as it grows, said; quiet too long: ended. */
|
|
1308
|
-
const workDir = c.work === 'kept' && typeof this.workFolder === 'function' ? this.workFolder(name) : '';
|
|
1309
|
-
const carryId = workDir ? `move-${name}-${Date.now()}` : '';
|
|
1310
|
-
const inWork = carryId ? join(workDir, '.clavarium-carry', `${carryId}.tgz`) : '';
|
|
1311
|
-
if (inWork) await Promise.race([Promise.resolve().then(() => this.mounted(name, true)).catch(() => {}), new Promise((r) => { setTimeout(r, MOUNTED_MS).unref?.(); })]);
|
|
1312
|
-
const { stream, child } = await this.exportState(name, inWork ? { toWork: carryId } : {});
|
|
1313
|
-
let read = 0; let lastAt = Date.now(); let stalled = false;
|
|
1314
|
-
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)}` }); };
|
|
1315
|
-
const sizing = setInterval(() => {
|
|
1316
|
-
if (inWork) { try { grew(statSync(inWork).size); } catch { /* not there yet */ } }
|
|
1317
|
-
if (Date.now() - lastAt >= COPY_QUIET_MS) { stalled = true; child.kill('SIGKILL'); }
|
|
1318
|
-
}, 1000);
|
|
1319
|
-
const failed = new Promise((ok) => child.on('error', () => ok(-1)));
|
|
1320
|
-
const file = inWork ? null : createWriteStream(carried, { mode: 0o600 });
|
|
1321
|
-
if (file) { stream.on('data', (d) => grew(read + d.length)); stream.pipe(file); } else stream.resume();
|
|
1322
|
-
const code = await Promise.race([new Promise((ok) => child.on('close', ok)), failed]).finally(() => clearInterval(sizing));
|
|
1323
|
-
if (file) await new Promise((ok) => (file.writableFinished ? ok() : file.on('finish', ok)));
|
|
1324
|
-
if (inWork) { try { if (code === 0 && !stalled) copyFileSync(inWork, carried); } finally { rmSync(inWork, { force: true }); } }
|
|
1325
|
-
if (stalled) return back(`its tool's state stopped coming (${sizeWords(read)} read, then nothing for ${COPY_QUIET_MS / 60_000} min).`);
|
|
1326
|
-
if (code !== 0) return back(`its tool's state could not be taken (exit ${code}${firstLine(child.said) ? `: ${firstLine(child.said)}` : ''}).`);
|
|
1334
|
+
const why = await this.#takeState(name, c, tool, carried);
|
|
1335
|
+
if (why) return back(why);
|
|
1327
1336
|
}
|
|
1328
1337
|
if (state !== undefined) {
|
|
1329
1338
|
this.#store.patch(name, { step: 'Stopping its own machine' });
|
|
@@ -1361,6 +1370,95 @@ export class Conversations {
|
|
|
1361
1370
|
} finally { rmSync(dir, { recursive: true, force: true }); }
|
|
1362
1371
|
}
|
|
1363
1372
|
|
|
1373
|
+
/* OUT OF ITS SHARED MACHINE, INTO ONE OF ITS OWN (#221, 15-11): the move the other way. Its tool's state carried
|
|
1374
|
+
(as into a shared machine), its programs there ended and its work taken out of its place, its own machine built
|
|
1375
|
+
as a new one's, the state put back, then its place in the shared machine removed -- its user and home there, or
|
|
1376
|
+
the whole machine when it was the last in it. Anything wrong before its own machine is ready: back in the shared
|
|
1377
|
+
machine, as it was (its place there kept until the end). -> the record, at once; `this.built`: the end of it. */
|
|
1378
|
+
async moveToOwn(name) {
|
|
1379
|
+
const c = this.#busyCheck(name);
|
|
1380
|
+
if (!c.sharedMachine) throw new Refusal(409, 'It has a machine of its own already.');
|
|
1381
|
+
const tool = this.#tools.find((t) => t.id === c.tool);
|
|
1382
|
+
if (!tool) throw new Refusal(400, 'The tool of this conversation is no longer offered.');
|
|
1383
|
+
const state = await this.#vms.state(name, { fresh: true }).catch(() => undefined);
|
|
1384
|
+
if (tool.state && state !== 'Running') throw new Refusal(409, 'Its shared machine is not running: open the conversation first, so that its tool\'s state can come along.', { retry: false });
|
|
1385
|
+
const memory = Math.max(tool.memoryMb, Number(c.memoryMb) || tool.memoryMb);
|
|
1386
|
+
await this.room({ kind: 'create', memoryMb: memory });
|
|
1387
|
+
const act = this.#take(name, 'move');
|
|
1388
|
+
this.#cancelStop(name);
|
|
1389
|
+
const now = new Date().toISOString();
|
|
1390
|
+
/* `movingOutOf`: what a restart of this server finds, to put it back in its shared machine (constructor). */
|
|
1391
|
+
this.#store.patch(name, { phase: 'building', step: `Moving out of the shared machine ${c.sharedMachine}`, buildingSince: now, progress: buildProgress(now), movingOutOf: { sharedMachine: c.sharedMachine, machineMb: c.machineMb, machineUser: c.machineUser, memoryMb: c.memoryMb } });
|
|
1392
|
+
this.built = this.#movingOut(name, c, tool, memory, state).finally(() => this.#give(name, act));
|
|
1393
|
+
return this.#store.get(name);
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1396
|
+
async #movingOut(name, c, tool, memory, state) {
|
|
1397
|
+
const shared = c.sharedMachine;
|
|
1398
|
+
const was = { sharedMachine: shared, machineMb: c.machineMb, machineUser: c.machineUser, memoryMb: c.memoryMb };
|
|
1399
|
+
const dir = mkdtempSync(join(tmpdir(), 'clv-move-'));
|
|
1400
|
+
const carried = join(dir, 'state.tar.gz');
|
|
1401
|
+
let left = false;
|
|
1402
|
+
const back = async (why) => {
|
|
1403
|
+
/* Back in its shared machine, as it was: its own machine, if begun, removed; its work shown there again. */
|
|
1404
|
+
if (!this.#store.get(name)) return undefined;
|
|
1405
|
+
this.#store.patch(name, { sharedMachine: undefined });
|
|
1406
|
+
if ((await this.#vms.state(name, { fresh: true }).catch(() => undefined)) !== undefined) await this.#vms.removeVm(vmName(name)).catch(() => {});
|
|
1407
|
+
this.#store.patch(name, { ...was, phase: 'ready', step: undefined, progress: undefined, buildingSince: undefined, error: undefined, movingOutOf: undefined });
|
|
1408
|
+
if (left) await this.#vms.workMount(name, this.#uid, this.#gid).catch(() => {});
|
|
1409
|
+
this.#fresh.add(name); this.#mountAgain.add(name);
|
|
1410
|
+
try { this.renewed(name, `Not moved out of the shared machine ${shared}: ${why} It stays there, as it was.`, false); } catch { /* told, nothing more */ }
|
|
1411
|
+
return undefined;
|
|
1412
|
+
};
|
|
1413
|
+
try {
|
|
1414
|
+
this.drop(name);
|
|
1415
|
+
if (state === 'Running') await this.#vms.exec(name, ['tmux', '-L', SOCKET, 'kill-server'], { timeoutMs: 10_000 }).catch(() => {});
|
|
1416
|
+
if (tool.state) {
|
|
1417
|
+
const why = await this.#takeState(name, c, tool, carried);
|
|
1418
|
+
if (why) return back(why);
|
|
1419
|
+
}
|
|
1420
|
+
if (state === 'Running') {
|
|
1421
|
+
/* Its programs there ended, its work taken out of its place: nothing of it runs there any more. */
|
|
1422
|
+
this.#store.patch(name, { step: `Leaving the shared machine ${shared}` });
|
|
1423
|
+
await this.#vms.execMachine(name, ['sudo', '-n', 'pkill', '-KILL', '-u', `c-${name}`], { timeoutMs: 30_000 }).catch(() => {});
|
|
1424
|
+
await this.#vms.workUnmount(name).catch(() => {});
|
|
1425
|
+
left = true;
|
|
1426
|
+
}
|
|
1427
|
+
/* Its own machine, as a new conversation's: built with its name, held before its tool starts. */
|
|
1428
|
+
this.#store.patch(name, { sharedMachine: undefined, machineMb: undefined, machineUser: undefined, memoryMb: memory, step: 'Starting the machine' });
|
|
1429
|
+
/* One left behind by an attempt cut short: not this conversation's any more. */
|
|
1430
|
+
if ((await this.#vms.state(name, { fresh: true }).catch(() => undefined)) !== undefined) await this.#vms.removeVm(vmName(name)).catch(() => {});
|
|
1431
|
+
this.#holding.add(name);
|
|
1432
|
+
try { await this.#build(name, tool, memory); } finally { this.#holding.delete(name); }
|
|
1433
|
+
const now = this.#store.get(name);
|
|
1434
|
+
if (!now) return undefined; /* archived meanwhile */
|
|
1435
|
+
if (now.phase === 'failed') return back(`${String(now.error ?? 'its own machine could not be made.').replace(/\.?$/, '.')}`);
|
|
1436
|
+
let lost = '';
|
|
1437
|
+
if (tool.state) {
|
|
1438
|
+
this.#store.patch(name, { step: `Putting ${tool.label}'s state back` });
|
|
1439
|
+
try { await this.#unpack(name, c.tool, carried); } catch (error) { lost = error.message; }
|
|
1440
|
+
}
|
|
1441
|
+
this.#store.patch(name, { phase: 'ready', step: undefined, progress: undefined, buildingSince: undefined, toolStarted: false, movingOutOf: undefined });
|
|
1442
|
+
this.ready(name);
|
|
1443
|
+
/* There for good: its place in the shared machine goes -- the whole machine with the last one in it. */
|
|
1444
|
+
const others = this.#store.all().filter((x) => x.name !== name && x.sharedMachine === shared);
|
|
1445
|
+
if (others.length) {
|
|
1446
|
+
const there = this.#vms.run;
|
|
1447
|
+
await there(['vm', 'unshare', vmName(shared), name]).catch(() => {});
|
|
1448
|
+
if (left) {
|
|
1449
|
+
await there(['vm', 'exec', vmName(shared), '--', 'sudo', '-n', 'userdel', '--remove', `c-${name}`], { timeoutMs: 60_000 }).catch(() => {});
|
|
1450
|
+
await there(['vm', 'exec', vmName(shared), '--', 'sudo', '-n', 'rm', '-f', `/etc/clavarium/limits/${name}`], { timeoutMs: 30_000 }).catch(() => {});
|
|
1451
|
+
}
|
|
1452
|
+
} else await this.#vms.removeVm(vmName(shared)).catch(() => {});
|
|
1453
|
+
this.renewed(name, lost
|
|
1454
|
+
? `Moved out of the shared machine ${shared} into a machine of its own, but ${tool.label}'s state did not come along (${lost}): it starts afresh.`
|
|
1455
|
+
: `Moved out of the shared machine ${shared} into a machine of its own: its work folder${tool.state ? `, ${tool.label}'s state` : ''} and this chat came along.`, true);
|
|
1456
|
+
return undefined;
|
|
1457
|
+
} catch (error) {
|
|
1458
|
+
return back(`${String(error?.message ?? error).replace(/\.?$/, '.')}`);
|
|
1459
|
+
} finally { rmSync(dir, { recursive: true, force: true }); }
|
|
1460
|
+
}
|
|
1461
|
+
|
|
1364
1462
|
async #fixup(name, tool) {
|
|
1365
1463
|
for (const step of tool.fixups) {
|
|
1366
1464
|
const r = await this.#vms.exec(name, step.argv, { timeoutMs: 120_000 }).catch(() => ({ code: 1 }));
|
package/server/jobs.mjs
CHANGED
|
@@ -33,6 +33,8 @@ const bare = ({ log, ...job }) => job;
|
|
|
33
33
|
export function jobWords(c) {
|
|
34
34
|
if (c.phase === 'moving') return `Moving ${titleOf(c)}${c.sharedMachine ? ` into « ${c.sharedMachine} »` : ''}`;
|
|
35
35
|
if (c.phase === 'restarting') return `Restarting ${titleOf(c)}`;
|
|
36
|
+
if (c.movingTo) return `Moving ${titleOf(c)} into « ${c.movingTo} »`;
|
|
37
|
+
if (c.movingOutOf) return `Moving ${titleOf(c)} out of « ${c.movingOutOf.sharedMachine} »`;
|
|
36
38
|
if (c.copyOf) return `Copy ${titleOf(c)}${c.sharedMachine ? ` in « ${c.sharedMachine} »` : ''}`;
|
|
37
39
|
return `Building ${titleOf(c)}${c.sharedMachine ? ` in « ${c.sharedMachine} »` : ''}`;
|
|
38
40
|
}
|
package/server/settingswords.mjs
CHANGED
|
@@ -181,7 +181,7 @@ export const SETTINGS_WORDS_FR = {
|
|
|
181
181
|
'set-cm-goes-work': 'Son dossier de travail', 'set-cm-goes-memory': 'La mémoire de son IA', 'set-cm-goes-access': 'Ses accès',
|
|
182
182
|
'set-cm-not': 'Ni ses appareils, ni ses rappels', 'set-cm-untouched': 'Celle-ci intacte : lue, puis remise en l\'état',
|
|
183
183
|
'set-cm-stay': 'Vous restez ici · « Ouvrir » une fois prête', 'set-cm-stops': 'Son outil s\'arrête environ une minute',
|
|
184
|
-
'set-cm-deleted': 'Sa propre machine est supprimée', 'set-cm-back': 'Retour', 'set-cm-copy-go': 'La copier', 'set-cm-move-go': 'La déplacer',
|
|
184
|
+
'set-cm-deleted': 'Sa propre machine est supprimée', 'set-cm-stops-out': 'Son outil s\'arrête quelques minutes', 'set-cm-shared-deleted': 'La machine partagée « {m} » est supprimée', 'set-cm-place-deleted': 'Sa place dans « {m} » est supprimée', 'set-cm-back': 'Retour', 'set-cm-copy-go': 'La copier', 'set-cm-move-go': 'La déplacer',
|
|
185
185
|
'set-cm-ready': 'Copie prête', 'set-cm-open': 'Ouvrir', 'set-cm-failed': 'Pas copiée', 'set-cm-see-why': 'Voir pourquoi',
|
|
186
186
|
'set-carry': 'Exporter / Importer', 'set-carry-hint': 'Mémoire de son IA, ou tout : à emporter.',
|
|
187
187
|
'set-carry-export': 'Mémoire de son IA', 'set-carry-all': 'Tout (dossier perso, travail, accès)', 'set-carry-all-off': 'Son travail doit être gardé ici.',
|
package/web/app.js
CHANGED
|
@@ -3267,11 +3267,13 @@
|
|
|
3267
3267
|
/* The places it may go, for a copy or a move of this one; the one chosen kept if it still is one. */
|
|
3268
3268
|
function cmPlaces(here) {
|
|
3269
3269
|
const machines = sharedMachines().filter((m) => !(cm.kind === 'move' && m.name === here.sharedMachine));
|
|
3270
|
-
|
|
3271
|
-
const
|
|
3270
|
+
/* Out of a shared machine (15-11): into one of its own, first; or into another shared one. */
|
|
3271
|
+
const own = cm.kind === 'copy' || Boolean(here.sharedMachine);
|
|
3272
|
+
const open = [...(own ? [''] : []), ...(cm.kind === 'move' && here.sharedMachine ? [] : [...machines.map((m) => m.name), 'new'])];
|
|
3272
3273
|
if (!open.includes(cm.place)) cm.place = open[0];
|
|
3273
3274
|
const cards = [];
|
|
3274
|
-
if (
|
|
3275
|
+
if (own) cards.push(cmCard('', uiSaid('set-where-own', 'Its own machine')));
|
|
3276
|
+
if (cm.kind === 'move' && here.sharedMachine) return { cards, open };
|
|
3275
3277
|
for (const m of machines) {
|
|
3276
3278
|
const small = [m.who.length ? uiSaid('set-cm-with', 'With {who}', { who: m.who.join(', ') }) : '', m.mb ? sizeWords(m.mb) : ''].filter(Boolean).join(' · ');
|
|
3277
3279
|
cards.push(cmCard(m.name, uiSaid('set-cm-shared', 'Shared machine « {m} »', { m: m.name }), small));
|
|
@@ -3316,7 +3318,7 @@
|
|
|
3316
3318
|
const here = conversations.find((x) => x.name === current);
|
|
3317
3319
|
if (DEVICE || !here || here.phase !== 'ready') return;
|
|
3318
3320
|
if (cm.of !== here.name) { $('cm-new-name').value = ''; $('cm-copy-title').value = ''; }
|
|
3319
|
-
Object.assign(cm, { of: here.name, kind, place: kind === 'copy' ? '' : (sharedMachines().find((m) => m.name !== here.sharedMachine)?.name ?? 'new') });
|
|
3321
|
+
Object.assign(cm, { of: here.name, kind, place: kind === 'copy' || here.sharedMachine ? '' : (sharedMachines().find((m) => m.name !== here.sharedMachine)?.name ?? 'new') });
|
|
3320
3322
|
$('machine-names').replaceChildren(...sharedMachines().map((m) => Object.assign(document.createElement('option'), { value: m.name })));
|
|
3321
3323
|
$('cm-copy-title').value = `${here.title ?? here.name} (copy)`;
|
|
3322
3324
|
/* Its sheep: two for a copy (the second slides out of the first), one walking for a move. */
|
|
@@ -3346,6 +3348,11 @@
|
|
|
3346
3348
|
$('cm-new-line')?.remove();
|
|
3347
3349
|
if (goes.machine && !goes.known) $('cm-check').prepend(Object.assign(document.createElement('p'), { id: 'cm-new-line', className: 'cm-not', textContent: uiSaid('set-cm-new-line', 'A new shared machine · {size}', { size: sizeWords(goes.machineMb) }) }));
|
|
3348
3350
|
$('cm-copy-part').hidden = cm.kind !== 'copy'; $('cm-move-part').hidden = cm.kind !== 'move';
|
|
3351
|
+
/* Out of a shared machine (15-11): its own machine is built, its place there removed -- the machine itself with the last one in it. */
|
|
3352
|
+
const out = cm.kind === 'move' && here.sharedMachine;
|
|
3353
|
+
const alone = out && !conversations.some((x) => x.name !== here.name && x.sharedMachine === here.sharedMachine);
|
|
3354
|
+
$('cm-stops').textContent = out ? uiSaid('set-cm-stops-out', 'Its tool stops for a few minutes') : uiSaid('set-cm-stops', 'Its tool stops for about a minute');
|
|
3355
|
+
$('cm-deleted').textContent = !out ? uiSaid('set-cm-deleted', 'Its own machine is deleted') : alone ? uiSaid('set-cm-shared-deleted', 'The shared machine « {m} » is deleted', { m: here.sharedMachine }) : uiSaid('set-cm-place-deleted', 'Its place in « {m} » is deleted', { m: here.sharedMachine });
|
|
3349
3356
|
$('cm-go').textContent = cm.kind === 'copy' ? uiSaid('set-cm-copy-go', 'Copy it') : uiSaid('set-cm-move-go', 'Move it');
|
|
3350
3357
|
$('cm-go').className = 'primary';
|
|
3351
3358
|
$('cm-choose').hidden = true; $('cm-check').hidden = false;
|
package/web/index.html
CHANGED
|
@@ -1520,8 +1520,8 @@
|
|
|
1520
1520
|
<p class="cm-box" data-said="set-cm-stay">You stay here · « Open it » when it is ready</p>
|
|
1521
1521
|
</div>
|
|
1522
1522
|
<div id="cm-move-part">
|
|
1523
|
-
<p class="cm-box" data-said="set-cm-stops">Its tool stops for about a minute</p>
|
|
1524
|
-
<p class="cm-box cm-danger" data-said="set-cm-deleted">Its own machine is deleted</p>
|
|
1523
|
+
<p class="cm-box" id="cm-stops" data-said="set-cm-stops">Its tool stops for about a minute</p>
|
|
1524
|
+
<p class="cm-box cm-danger" id="cm-deleted" data-said="set-cm-deleted">Its own machine is deleted</p>
|
|
1525
1525
|
</div>
|
|
1526
1526
|
<div class="cm-acts"><button type="button" id="cm-back" data-said="set-cm-back">Back</button><button type="button" class="primary" id="cm-go"></button></div>
|
|
1527
1527
|
</div>
|