clavarium 0.2.442-next.1 → 0.2.444-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 +6 -6
- package/package.json +2 -2
- package/server/api.mjs +4 -1
- package/server/conversations.mjs +29 -8
- package/server/settingswords.mjs +3 -0
- package/server/talk.mjs +26 -2
- package/web/app.js +27 -0
- package/web/index.html +2 -0
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.444-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.444-next.1",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
|
13
13
|
"@xterm/xterm": "^6.0.0",
|
|
14
14
|
"clavarium-binder": "0.1.62-next.1",
|
|
15
15
|
"clavarium-docket": "0.1.2-next.2",
|
|
16
|
-
"clavarium-parley": "0.17.
|
|
16
|
+
"clavarium-parley": "0.17.93-next.1",
|
|
17
17
|
"clavarium-tether": "0.1.0-next.67",
|
|
18
18
|
"mammoth": "1.13.0",
|
|
19
19
|
"mermaid": "11.17.2",
|
|
@@ -787,9 +787,9 @@
|
|
|
787
787
|
}
|
|
788
788
|
},
|
|
789
789
|
"node_modules/clavarium-parley": {
|
|
790
|
-
"version": "0.17.
|
|
791
|
-
"resolved": "https://registry.npmjs.org/clavarium-parley/-/clavarium-parley-0.17.
|
|
792
|
-
"integrity": "sha512-
|
|
790
|
+
"version": "0.17.93-next.1",
|
|
791
|
+
"resolved": "https://registry.npmjs.org/clavarium-parley/-/clavarium-parley-0.17.93-next.1.tgz",
|
|
792
|
+
"integrity": "sha512-D+h9CwtW2j8mgS+hUlSyc1h5aSvMfqSUQ821cijtR4dvHNlgPe/0/GYZqsf1Kms8dV+eGUxQBT2aTd8CcxvpXA==",
|
|
793
793
|
"license": "MIT",
|
|
794
794
|
"bin": {
|
|
795
795
|
"parley": "bin/parley.mjs",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.444-next.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "A conversation is a VM with a terminal in it. Everything else is a folder.",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"@xterm/xterm": "^6.0.0",
|
|
48
48
|
"clavarium-binder": "0.1.62-next.1",
|
|
49
49
|
"clavarium-docket": "0.1.2-next.2",
|
|
50
|
-
"clavarium-parley": "0.17.
|
|
50
|
+
"clavarium-parley": "0.17.93-next.1",
|
|
51
51
|
"clavarium-tether": "0.1.0-next.67",
|
|
52
52
|
"mammoth": "1.13.0",
|
|
53
53
|
"mermaid": "11.17.2",
|
package/server/api.mjs
CHANGED
|
@@ -34,6 +34,8 @@
|
|
|
34
34
|
* POST /api/conversations/<name>/talk {text, answers?, files?, via?}: written in its chat; files from .../talk/file; via 'voice': dictated
|
|
35
35
|
* POST /api/conversations/<name>/talk/react {to, reaction}: the owner's reaction to a message of the tool (null: taken back)
|
|
36
36
|
* POST /api/conversations/<name>/talk/pin {to, on}: the owner pins a message of the chat (on: false unpins); 5 at most
|
|
37
|
+
* POST /api/conversations/<name>/talk/split {messages: 500..100000} | {days: 0.5..365} | {off: true}: when its thread is
|
|
38
|
+
* archived into volumes (nothing deleted) -> {split}; read back as `split` in GET .../talk
|
|
37
39
|
* POST /api/conversations/<name>/chat-name {name}: the name the chat gives its tool ('' : the neutral word of the dictionary)
|
|
38
40
|
* POST /api/conversations/<name>/tasks-binder {binder}: the binder shown beside its chat ('' automatic, '-' none, else an id)
|
|
39
41
|
* POST /api/conversations/<name>/voice-mark {on}: what is dictated into its terminal starts with a microphone sign (AI tools only)
|
|
@@ -835,13 +837,14 @@ export async function handleApi(request, response, conversations, headers, resou
|
|
|
835
837
|
}
|
|
836
838
|
return send(200, { asset, rights, given }), true;
|
|
837
839
|
}
|
|
838
|
-
const talking = /^\/api\/conversations\/([^/]+)\/talk(\/invite|\/remind|\/react|\/pin)?$/.exec(pathname);
|
|
840
|
+
const talking = /^\/api\/conversations\/([^/]+)\/talk(\/invite|\/remind|\/react|\/pin|\/split)?$/.exec(pathname);
|
|
839
841
|
if (talking && talk) {
|
|
840
842
|
const conversation = decodeURIComponent(talking[1]);
|
|
841
843
|
if (talking[2] === '/invite') return send(200, await talk.invite(conversation, typeof body.lang === 'string' ? body.lang : 'en')), true;
|
|
842
844
|
if (talking[2] === '/remind') return send(200, await talk.remind(conversation, { urgent: body?.urgent === true })), true;
|
|
843
845
|
if (talking[2] === '/react') return send(200, await talk.react(conversation, body.to, body.reaction ?? null)), true;
|
|
844
846
|
if (talking[2] === '/pin') return send(200, await talk.pin(conversation, body.to, body.on !== false)), true;
|
|
847
|
+
if (talking[2] === '/split') return send(200, talk.setSplit(conversation, { messages: body.messages, days: body.days, off: body.off })), true;
|
|
845
848
|
if (typeof body.on === 'boolean') { const now = await talk.set(conversation, body.on); retell(conversation); return send(200, now), true; }
|
|
846
849
|
/* What the chat may add to an answer: the choices ticked, the answers of a group, the zone of a picture it is about (Parley checks each). */
|
|
847
850
|
return send(201, await talk.say(conversation, body.text, body.answers, body.files, body.via, { picked: body.picked, replies: body.replies, about: body.about, quick: body.quick === true })), true;
|
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/server/settingswords.mjs
CHANGED
|
@@ -11,6 +11,9 @@ export const SETTINGS_WORDS_FR = {
|
|
|
11
11
|
'set-ch-s-words': 'Écran du chat', 'set-ch-s-dictation': 'Dictée', 'set-ch-s-shortcuts': 'Raccourcis', 'set-ch-s-thread': 'Événements du chat',
|
|
12
12
|
'set-ch-s-updates': 'Mises à jour', 'set-ch-s-binders': 'Classeurs', 'set-ch-s-events': 'Activité', 'set-ch-s-jobs': 'Tâches', 'set-ch-s-logs': 'Journaux',
|
|
13
13
|
'set-ch-s-usage': 'Usage', 'set-ch-s-backup': 'Sauvegarde', 'set-ch-s-advanced': 'Avancé',
|
|
14
|
+
/* Chat › when its thread is archived (talk.mjs setSplit). */
|
|
15
|
+
'set-chat-split': 'Archiver son fil', 'set-split-2000': 'Tous les 2 000 messages', 'set-split-5000': 'Tous les 5 000',
|
|
16
|
+
'set-split-week': 'Chaque semaine', 'set-split-day': 'Chaque jour', 'set-split-never': 'Jamais',
|
|
14
17
|
'set-check-updates': 'Chercher une mise à jour', 'set-activity': 'Activité', 'set-restart-dots': 'Redémarrer…', 'set-terminal': 'Terminal',
|
|
15
18
|
'set-search': 'Chercher', 'set-why': 'Pourquoi',
|
|
16
19
|
/* Diagnostics › Tâches (jobs.mjs): celles du jour, chacune avec son journal. */
|
package/server/talk.mjs
CHANGED
|
@@ -71,6 +71,9 @@ import { SOCKET } from './tmux.mjs';
|
|
|
71
71
|
import { isConversationName } from './names.mjs';
|
|
72
72
|
|
|
73
73
|
export const FOLDER = '.parley';
|
|
74
|
+
/* What the owner may choose for archiving a thread (setSplit): messages from 500 to 100,000, days from half a day to a year. */
|
|
75
|
+
export const SPLIT_MESSAGES = Object.freeze([500, 100_000]);
|
|
76
|
+
export const SPLIT_DAYS = Object.freeze([0.5, 365]);
|
|
74
77
|
const IN_MACHINE = `/work/${FOLDER}`;
|
|
75
78
|
/* Texts this server gives the tool to read (keepText): kept this many days, this many at most of one name. */
|
|
76
79
|
export const KEPT_TEXT_DAYS = 7;
|
|
@@ -352,11 +355,12 @@ export class Talk {
|
|
|
352
355
|
/* The machine's lines go among the messages, where they happened. */
|
|
353
356
|
const lines = (record.system ?? []).map((l) => ({ from: 'system', kind: 'system', choices: [], ...l }));
|
|
354
357
|
const asked = partOf(part);
|
|
355
|
-
|
|
358
|
+
/* When its thread is archived (split), with the rest of its chat's state: a small file read. */
|
|
359
|
+
if (asked?.state) return { on: true, possible, tools, wake, split: this.split(name) };
|
|
356
360
|
if (!asked) {
|
|
357
361
|
const read = this.#parley(name).read();
|
|
358
362
|
const messages = [...read.messages, ...lines].sort((a, b) => String(a.at).localeCompare(String(b.at))).slice(-SHOWN_MAX);
|
|
359
|
-
return { on: true, possible, tools, ...read, messages, wake };
|
|
363
|
+
return { on: true, possible, tools, ...read, messages, wake, split: this.split(name) };
|
|
360
364
|
}
|
|
361
365
|
/* Its own lines change apart from the thread (and their buttons with what was marked seen): their stamp is part of the cursor. */
|
|
362
366
|
const stamp = createHash('sha256').update(JSON.stringify([record.system ?? [], this.#health?.of?.(name)?.seenAt ?? null])).digest('hex').slice(0, 10);
|
|
@@ -376,6 +380,26 @@ export class Talk {
|
|
|
376
380
|
return this.#parley(name).search(String(text ?? '').slice(0, 200));
|
|
377
381
|
}
|
|
378
382
|
|
|
383
|
+
/* WHEN ITS THREAD IS ARCHIVED (Parley's split, "The archive" in its protocol): its older messages go into
|
|
384
|
+
volumes, nothing deleted, every part still read as one thread. The owner's choice per conversation, kept in
|
|
385
|
+
its bridge folder (.parley/settings.json): { messages: N } once the thread holds N lines, { days: D } for
|
|
386
|
+
volumes of D days at most, or false (never). Parley's own default is { messages: 5000 }. */
|
|
387
|
+
split(name) { this.#known(name); return this.#parley(name).split(); }
|
|
388
|
+
setSplit(name, { messages, days, off } = {}) {
|
|
389
|
+
if (this.#known(name).work !== 'kept') throw new Refusal(409, 'Its work folder is not kept here: its chat has no thread to archive.');
|
|
390
|
+
let value;
|
|
391
|
+
if (off === true) value = false;
|
|
392
|
+
else if (messages !== undefined) {
|
|
393
|
+
if (!Number.isInteger(messages) || messages < SPLIT_MESSAGES[0] || messages > SPLIT_MESSAGES[1]) throw new Refusal(400, `"messages" is a whole number from ${SPLIT_MESSAGES[0]} to ${SPLIT_MESSAGES[1]}.`);
|
|
394
|
+
value = { messages };
|
|
395
|
+
} else if (days !== undefined) {
|
|
396
|
+
if (typeof days !== 'number' || !Number.isFinite(days) || days < SPLIT_DAYS[0] || days > SPLIT_DAYS[1]) throw new Refusal(400, `"days" is a number from ${SPLIT_DAYS[0]} to ${SPLIT_DAYS[1]}.`);
|
|
397
|
+
value = { days };
|
|
398
|
+
} else throw new Refusal(400, 'Say {messages}, {days} or {off: true}.');
|
|
399
|
+
this.#parley(name).setSplit(value);
|
|
400
|
+
return { split: this.split(name) };
|
|
401
|
+
}
|
|
402
|
+
|
|
379
403
|
/* What the tool reads of its chat after a restart (REREAD), the owner's choice of WINDOWS. */
|
|
380
404
|
window() {
|
|
381
405
|
const ai = this.#words?.get('window')?.ai;
|
package/web/app.js
CHANGED
|
@@ -3864,6 +3864,7 @@
|
|
|
3864
3864
|
const here = conversations.find((x) => x.name === current);
|
|
3865
3865
|
if (document.activeElement !== $('chat-name')) $('chat-name').value = here?.chatName ?? '';
|
|
3866
3866
|
void paintTasksBinder(here);
|
|
3867
|
+
void paintChatSplit();
|
|
3867
3868
|
if (document.activeElement !== $('title-name')) $('title-name').value = shownName(here);
|
|
3868
3869
|
$('title-box').hidden = $('hide-box').hidden = $('group-box').hidden = DEVICE || !here;
|
|
3869
3870
|
if (document.activeElement !== $('group-name')) $('group-name').value = here?.group ?? '';
|
|
@@ -3941,6 +3942,32 @@
|
|
|
3941
3942
|
try { await post(`${API}/conversations/${encodeURIComponent(current)}/tasks-binder`, { binder: $('tasks-binder').value }); await refresh(); void paintTasks(current); }
|
|
3942
3943
|
catch (error) { $('panel-error').textContent = error.message; $('panel-error').hidden = false; }
|
|
3943
3944
|
});
|
|
3945
|
+
/* WHEN ITS THREAD IS ARCHIVED (server/talk.mjs setSplit): a choice of a few; another value set elsewhere is shown as it is. */
|
|
3946
|
+
const CHAT_SPLITS = [
|
|
3947
|
+
['messages:2000', () => uiSaid('set-split-2000', 'Every 2,000 messages')],
|
|
3948
|
+
['messages:5000', () => uiSaid('set-split-5000', 'Every 5,000')],
|
|
3949
|
+
['days:7', () => uiSaid('set-split-week', 'Every week')],
|
|
3950
|
+
['days:1', () => uiSaid('set-split-day', 'Every day')],
|
|
3951
|
+
['off', () => uiSaid('set-split-never', 'Never')],
|
|
3952
|
+
];
|
|
3953
|
+
const splitKey = (v) => (v === false ? 'off' : v?.days ? `days:${v.days}` : `messages:${v?.messages ?? 5000}`);
|
|
3954
|
+
async function paintChatSplit() {
|
|
3955
|
+
const name = current;
|
|
3956
|
+
const t = talkOf === name ? talk : await readTalk();
|
|
3957
|
+
if (name !== current) return;
|
|
3958
|
+
$('chat-split-row').hidden = !t?.on || t.split === undefined;
|
|
3959
|
+
if ($('chat-split-row').hidden || document.activeElement === $('chat-split')) return;
|
|
3960
|
+
const now = splitKey(t.split);
|
|
3961
|
+
const choices = CHAT_SPLITS.some(([v]) => v === now) ? CHAT_SPLITS : [...CHAT_SPLITS, [now, () => now.replace(':', ' ')]];
|
|
3962
|
+
$('chat-split').replaceChildren(...choices.map(([v, text]) => { const o = document.createElement('option'); o.value = v; o.textContent = text(); o.selected = v === now; return o; }));
|
|
3963
|
+
}
|
|
3964
|
+
$('chat-split').addEventListener('change', async () => {
|
|
3965
|
+
const [kind, n] = $('chat-split').value.split(':');
|
|
3966
|
+
$('panel-error').hidden = true;
|
|
3967
|
+
try { await post(`${API}/conversations/${encodeURIComponent(current)}/talk/split`, kind === 'off' ? { off: true } : { [kind]: Number(n) }); await readTalk(); }
|
|
3968
|
+
catch (error) { $('panel-error').textContent = error.message; $('panel-error').hidden = false; }
|
|
3969
|
+
$('chat-split').blur(); await paintChatSplit();
|
|
3970
|
+
});
|
|
3944
3971
|
$('chat-name-form').addEventListener('submit', async (event) => {
|
|
3945
3972
|
event.preventDefault();
|
|
3946
3973
|
$('panel-error').hidden = true;
|
package/web/index.html
CHANGED
|
@@ -297,6 +297,8 @@
|
|
|
297
297
|
<div class="chapter-body">
|
|
298
298
|
<div id="talk-box">
|
|
299
299
|
<form id="chat-name-form" class="set-row" autocomplete="off"><div class="set-what"><label for="chat-name">Its name in the chat</label><small id="chat-name-hint">Empty: "Assistant"</small></div><div class="set-control"><input id="chat-name" maxlength="40" placeholder="Assistant" spellcheck="false"><button type="submit">Save</button></div></form>
|
|
300
|
+
<!-- WHEN ITS THREAD IS ARCHIVED (Parley's split): older messages go into volumes, none deleted, still read and searched. -->
|
|
301
|
+
<div class="set-row" id="chat-split-row" hidden><div class="set-what"><label for="chat-split" data-said="set-chat-split">Archive its thread</label></div><div class="set-control"><select id="chat-split"></select></div></div>
|
|
300
302
|
<div class="set-row" id="tasks-binder-row" hidden><div class="set-what"><label for="tasks-binder">Binder beside the chat</label><small class="tip" hidden>Automatic: its first binder of batches</small></div><div class="set-control"><select id="tasks-binder"></select></div></div>
|
|
301
303
|
</div>
|
|
302
304
|
<!-- DICTATION INTO ITS TERMINAL: marked once per message, so that the tool knows it may hold recognition mistakes. -->
|