clavarium 0.2.303-next.1 → 0.2.306-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 +1 -1
- package/server/boxes.mjs +4 -3
- package/server/rooms.mjs +5 -3
- package/server/speech.mjs +28 -2
- package/web/app.js +64 -13
- package/web/index.html +2 -0
- package/web/style.css +10 -1
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.306-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.306-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.59-next.1",
|
|
15
15
|
"clavarium-docket": "0.1.2-next.2",
|
|
16
|
-
"clavarium-parley": "0.17.
|
|
16
|
+
"clavarium-parley": "0.17.57-next.1",
|
|
17
17
|
"clavarium-tether": "0.1.0-next.49",
|
|
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.57-next.1",
|
|
791
|
+
"resolved": "https://registry.npmjs.org/clavarium-parley/-/clavarium-parley-0.17.57-next.1.tgz",
|
|
792
|
+
"integrity": "sha512-jG+AXX7QOkQWaFAxT/oZpE58HgdRvnR5ChsCiI7YURom1AeWBuGjXOoCVSABXv4QYmFfCIqCe+nUH0/N9XgqOA==",
|
|
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.306-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.",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"@xterm/xterm": "^6.0.0",
|
|
47
47
|
"clavarium-binder": "0.1.59-next.1",
|
|
48
48
|
"clavarium-docket": "0.1.2-next.2",
|
|
49
|
-
"clavarium-parley": "0.17.
|
|
49
|
+
"clavarium-parley": "0.17.57-next.1",
|
|
50
50
|
"clavarium-tether": "0.1.0-next.49",
|
|
51
51
|
"mammoth": "1.13.0",
|
|
52
52
|
"mermaid": "11.17.2",
|
package/server/api.mjs
CHANGED
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
* POST /api/asset-groups/place {asset, group}: put an asset in a group (group null to take it out)
|
|
90
90
|
* POST /api/asset-groups/<id>/rename {label}
|
|
91
91
|
* POST /api/asset-groups/<id>/remove
|
|
92
|
-
* GET /api/rooms the rooms (#268): [{id, name, host, members: [{id, kind, name, ref, host?}]}]
|
|
92
|
+
* GET /api/rooms the rooms (#268): [{id, name, host, members: [{id, kind, name, ref, host?}], unread, last, thinking: [names]}]
|
|
93
93
|
* POST /api/rooms {name, conversations: [names], boxes: [ids], host?}: a new room
|
|
94
94
|
* POST /api/rooms/<id> {name?, host?, add?: {conversations, boxes}, remove?: [member ids]}
|
|
95
95
|
* POST /api/rooms/<id>/remove the room and its thread
|
package/server/boxes.mjs
CHANGED
|
@@ -29,7 +29,7 @@ export const FIRMWARE_PATH = '/c/api/box/firmware/';
|
|
|
29
29
|
export const FIRMWARE_MINUTES = 10;
|
|
30
30
|
/* THE WAKE WORD HEARD AGAIN (03-11): « Mésange » and what a dictation makes of it (mes anges, mais sange...). */
|
|
31
31
|
export const CLIP_MAX_BYTES = 16_000 * 2 * 3;
|
|
32
|
-
export const WAKE_HEARD = /\bm[ae]i?s+\s?an?ge?s?\b|\bmes anges?\b|\bmesange|\bmaisange|\bmessage?s?\b/;
|
|
32
|
+
export const WAKE_HEARD = /\bm[ae]i?s+\s?an?ge?s?\b|\bmes anges?\b|\bmesange|\bmaisange|\bmessage?s?\b|\bmessenge?s?\b/; /* « Messenges »: Whisper's reading of the server's own voice saying it */
|
|
33
33
|
export const WAKE_DROP = process.env.CLAVARIUM_WAKE_DROP === '1';
|
|
34
34
|
const plainWords = (t) => String(t).toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g, '').replace(/[^a-z\s]/g, ' ').replace(/\s+/g, ' ').trim();
|
|
35
35
|
export const SENTENCE_MAX = 300 * 32_000 + 32_000; /* 5 min of 16 kHz 16-bit mono, and some slack */
|
|
@@ -668,7 +668,7 @@ export class Boxes {
|
|
|
668
668
|
this.#log(`voice box ${box.name}: a sentence while recording here, the recording closed`);
|
|
669
669
|
r.out.end(() => { void this.#recorded(link, r); });
|
|
670
670
|
}
|
|
671
|
-
if (m.t === 'listen.start') { link.why = whyOf(m);
|
|
671
|
+
if (m.t === 'listen.start') { link.why = whyOf(m); link.wakeCheck = null; } /* its clip, if any, comes after listen.start: an older check never carries over */
|
|
672
672
|
if (m.t === 'listen.start') { if (this.stop(box.id)) this.#log(`voice box ${box.name}: stopped playing, someone speaks`); sentence = []; size = 0; return; }
|
|
673
673
|
if (m.t === 'listen.end' && sentence && m.reason === 'nobody') {
|
|
674
674
|
/* Listened again, nobody spoke: a conversation ends there, in silence. */
|
|
@@ -792,7 +792,8 @@ export class Boxes {
|
|
|
792
792
|
turned on (WAKE_DROP), after its results were looked at -- a real call must never be lost to it. */
|
|
793
793
|
const check = link.wakeCheck ? await link.wakeCheck.catch(() => null) : null; link.wakeCheck = null;
|
|
794
794
|
if (check) {
|
|
795
|
-
|
|
795
|
+
/* First in the line: Parley keeps 120 characters of `why`, and the end stats after it can pass that. */
|
|
796
|
+
link.why = `mot ${check.ok ? '\u2713' : '\u2717'} « ${check.heard.slice(0, 30)} »${link.why ? ` · ${link.why}` : ''}`;
|
|
796
797
|
this.#log(`voice box ${box.name}: wake word heard again: ${check.ok ? 'yes' : 'NO'} (« ${check.heard.slice(0, 40)} »)`);
|
|
797
798
|
if (!check.ok && WAKE_DROP) { link.send({ t: 'cue', name: 'done' }); return; }
|
|
798
799
|
}
|
package/server/rooms.mjs
CHANGED
|
@@ -57,7 +57,10 @@ export class Rooms {
|
|
|
57
57
|
#unread(r) { try { const seen = Date.parse(r.seen ?? '') || 0; return this.#thread(r.id).read({ last: 200 }).messages.filter((m) => (m.from === 'agent' || m.by) && (Date.parse(m.at) || 0) > seen).length; } catch { return 0; } }
|
|
58
58
|
/* Its last message, for the list: when, and its first words. */
|
|
59
59
|
#last(r) { try { const m = this.#thread(r.id).read({ last: 1 }).messages.at(-1); return m ? { at: m.at, text: String(m.text ?? '').replace(/\s+/g, ' ').slice(0, 120), ...(m.by?.name ? { by: m.by.name } : {}) } : null; } catch { return null; } }
|
|
60
|
-
|
|
60
|
+
/* Who has a message of the room and has not answered yet (#282), by their names of the moment: « Hugo parle… »
|
|
61
|
+
in its row of the list and on its bar, « Hugo réfléchit… » in its thread. */
|
|
62
|
+
#thinkingOf(id, members) { return [...(this.#thinking.get(id) ?? new Map()).entries()].filter(([, at]) => Date.now() - at < THINKING_MS).map(([mid]) => members.find((m) => m.id === mid)?.name).filter(Boolean); }
|
|
63
|
+
list() { return this.#all().map((r) => { const members = this.#shown(r); return { id: r.id, name: r.name, host: r.host, members, at: r.at, unread: this.#unread(r), last: this.#last(r), thinking: this.#thinkingOf(r.id, members) }; }); }
|
|
61
64
|
get(id) { const r = this.#find(id); return { id: r.id, name: r.name, host: r.host, members: this.#shown(r), at: r.at }; }
|
|
62
65
|
|
|
63
66
|
/* A new room: its name, its AIs (conversation names), its boxes (ids), and which AI is the host (the first by default). */
|
|
@@ -121,8 +124,7 @@ export class Rooms {
|
|
|
121
124
|
/* A member named in a text (@{id}): its name of the moment, on the screen. */
|
|
122
125
|
const named = (text) => String(text ?? '').replace(/@\{([0-9a-f-]{36})\}/g, (whole, mid) => { const m = members.find((x) => x.id === mid); return m ? `@${m.name}` : whole; });
|
|
123
126
|
if (options?.seen !== false) { const list = this.#all(); const r = list.find((x) => x.id === id); if (r) { r.seen = this.#now().toISOString(); this.#file.set(list); } }
|
|
124
|
-
|
|
125
|
-
const thinking = [...(this.#thinking.get(id) ?? new Map()).entries()].filter(([, at]) => Date.now() - at < THINKING_MS).map(([mid]) => members.find((m) => m.id === mid)?.name).filter(Boolean);
|
|
127
|
+
const thinking = this.#thinkingOf(id, members);
|
|
126
128
|
return { room: this.get(id), thinking, ...read, messages: (read.messages ?? []).map((m) => (typeof m.text === 'string' && m.text.includes('@{') ? { ...m, text: named(m.text) } : m)) };
|
|
127
129
|
}
|
|
128
130
|
|
package/server/speech.mjs
CHANGED
|
@@ -43,10 +43,24 @@ export const ELEVEN_VOICE = 'onwK4e9ZLuTAKqWW03F9'; /* "Daniel" */
|
|
|
43
43
|
export const ELEVEN_MODEL = 'eleven_multilingual_v2';
|
|
44
44
|
export const SPEED = 1.1; /* a little quicker than the voices' own pace: found slow on the real box (31-10) */
|
|
45
45
|
|
|
46
|
+
/* WHY ELEVENLABS SAID NO, from its answer's body ({detail: {status|code, message}}): credits used up and a key
|
|
47
|
+
refused are not fixed the same way (04-11: a 401 every sentence, the quota spent). */
|
|
48
|
+
export function elevenRefusal(status, body) {
|
|
49
|
+
const d = body?.detail ?? {};
|
|
50
|
+
const what = `${d.status ?? ''} ${d.code ?? ''} ${d.message ?? ''}`.toLowerCase();
|
|
51
|
+
if (/quota|credit|character_limit/.test(what)) return 'credits used up';
|
|
52
|
+
if (/missing_permission/.test(what)) return 'key lacks the text-to-speech permission';
|
|
53
|
+
if (status === 401 || /invalid_api_key|unauthori/.test(what)) return 'key refused';
|
|
54
|
+
if (status === 429) return 'too many requests';
|
|
55
|
+
return `answered ${status}`;
|
|
56
|
+
}
|
|
57
|
+
/* After a refusal, ElevenLabs is left alone this long (the same key), then asked again: said once, not each sentence. */
|
|
58
|
+
export const ELEVEN_REST_MS = 60 * 60_000;
|
|
59
|
+
|
|
46
60
|
/* A moment before the main voice is asked again (a sentence it missed). */
|
|
47
61
|
export const AGAIN_MS = 700;
|
|
48
62
|
export class Speech {
|
|
49
|
-
#dir; #lang; #engine = null; #loading = null; #fetch; #log; #secret; #pocket; #pocketDown = 0;
|
|
63
|
+
#dir; #lang; #engine = null; #loading = null; #fetch; #log; #secret; #pocket; #pocketDown = 0; #elevenOff = null;
|
|
50
64
|
|
|
51
65
|
/* `pocket`: the default voice (pocket.mjs), else null. Then ElevenLabs when its key is set, then Piper. */
|
|
52
66
|
constructor({ dir, lang = 'fr', fetcher = fetch, log = () => {}, secret = () => undefined, pocket = null }) {
|
|
@@ -56,12 +70,24 @@ export class Speech {
|
|
|
56
70
|
async #eleven(text) {
|
|
57
71
|
const key = this.#secret(ELEVEN_SECRET);
|
|
58
72
|
if (!key) return null;
|
|
73
|
+
/* Refused for this very key not long ago: not asked, not said again. A new key is tried at once. */
|
|
74
|
+
if (this.#elevenOff?.key === key && Date.now() < this.#elevenOff.until) return null;
|
|
59
75
|
try {
|
|
60
76
|
const r = await this.#fetch(`https://api.elevenlabs.io/v1/text-to-speech/${ELEVEN_VOICE}?output_format=pcm_16000`, {
|
|
61
77
|
method: 'POST', headers: { 'xi-api-key': key, 'content-type': 'application/json' },
|
|
62
78
|
body: JSON.stringify({ text, model_id: ELEVEN_MODEL, voice_settings: { stability: 0.5, similarity_boost: 0.75, speed: SPEED } }), signal: AbortSignal.timeout(20_000),
|
|
63
79
|
});
|
|
64
|
-
if (!r.ok) {
|
|
80
|
+
if (!r.ok) {
|
|
81
|
+
const why = elevenRefusal(r.status, await r.json().catch(() => undefined));
|
|
82
|
+
if (r.status === 401 || r.status === 402 || r.status === 429) {
|
|
83
|
+
const again = this.#elevenOff?.key === key && this.#elevenOff.why === why;
|
|
84
|
+
this.#elevenOff = { key, why, until: Date.now() + ELEVEN_REST_MS };
|
|
85
|
+
if (again) return null;
|
|
86
|
+
}
|
|
87
|
+
this.#log(`speech: ElevenLabs: ${why}, this server's voice instead`);
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
this.#elevenOff = null;
|
|
65
91
|
return Buffer.from(await r.arrayBuffer());
|
|
66
92
|
} catch (error) { this.#log(`speech: ElevenLabs unreachable (${error.message}), this server's voice instead`); return null; }
|
|
67
93
|
}
|
package/web/app.js
CHANGED
|
@@ -424,6 +424,8 @@
|
|
|
424
424
|
return bar;
|
|
425
425
|
}
|
|
426
426
|
for (const top of [...document.querySelectorAll('#places .sheet > .panel-top')]) topBar(top, top.parentElement.id === 'salon' ? { state: 'salon-state' } : {});
|
|
427
|
+
/* A room's title: its name, and under it who speaks now (salonLive). */
|
|
428
|
+
{ const t = $('salon-title'); const name = document.createElement('span'); name.id = 'salon-name'; name.textContent = t.textContent; const live = document.createElement('small'); live.id = 'salon-live'; live.className = 'salon-live'; live.hidden = true; t.replaceChildren(name, live); }
|
|
427
429
|
/* A room's settings: on its bar's right, in the same group of views a conversation's settings sit in. */
|
|
428
430
|
{ const views = document.createElement('div'); views.className = 'views'; views.setAttribute('role', 'group'); views.setAttribute('aria-label', 'Room'); views.append($('salon-settings')); $('salon').querySelector('.topbar .bar-right').prepend(views); }
|
|
429
431
|
const applyFold = (folded) => {
|
|
@@ -1257,6 +1259,17 @@
|
|
|
1257
1259
|
/* The rooms known, even before their part of this page has run (a list painted early). */
|
|
1258
1260
|
const roomsNow = () => { try { return Array.isArray(rooms) ? rooms : []; } catch { return []; } };
|
|
1259
1261
|
const roomOpenNow = () => { try { return place === 'salon' ? salonId : ''; } catch { return ''; } };
|
|
1262
|
+
/* Words of the screen's language (Parley's texts, /api/talk/words) once read; English till then. */
|
|
1263
|
+
const uiSaid = (key, fallback, vars = {}) => {
|
|
1264
|
+
let words = null; try { words = chatWords; } catch { /* not read yet */ }
|
|
1265
|
+
return (typeof words?.[key] === 'string' ? words[key] : fallback).replace(/\{(\w+)\}/g, (all, k) => (k in vars ? String(vars[k]) : all));
|
|
1266
|
+
};
|
|
1267
|
+
/* Who of a room speaks now (#282, an AI given a message and not done): « Cuisine parle… ». */
|
|
1268
|
+
const speaking = (who) => (who.length > 1 ? uiSaid('room-speaking-many', '{names} are speaking\u2026', { names: who.join(', ') }) : uiSaid('room-speaking', '{name} is speaking\u2026', { name: who[0] }));
|
|
1269
|
+
const thinkingOf = (r) => (Array.isArray(r?.thinking) ? r.thinking.filter((x) => typeof x === 'string' && x) : []);
|
|
1270
|
+
/* ROOMS ONLY (a filter of the list): kept on this device. */
|
|
1271
|
+
let roomsOnly = false;
|
|
1272
|
+
try { roomsOnly = localStorage.getItem('clavarium-list-show') === 'rooms'; } catch { /* a private window */ }
|
|
1260
1273
|
function roomItem(r) {
|
|
1261
1274
|
/* The same row as a conversation's (03-11: « de même nature ») -- its name, when, its last words on one line,
|
|
1262
1275
|
its state's dot -- told apart by a small room sign before its name. */
|
|
@@ -1265,12 +1278,15 @@
|
|
|
1265
1278
|
const sign = document.createElement('span'); sign.className = 'room-sign'; sign.setAttribute('aria-hidden', 'true');
|
|
1266
1279
|
title.append(sign, r.name);
|
|
1267
1280
|
b.append(title);
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1281
|
+
/* One of its AIs speaking now: said instead of its last message (a conversation at work: its dot, gold). */
|
|
1282
|
+
const who = thinkingOf(r);
|
|
1283
|
+
if (who.length) b.dataset.live = 'true';
|
|
1284
|
+
if (r.last || who.length) {
|
|
1285
|
+
const last = document.createElement('small'); last.className = 'last'; last.textContent = who.length ? speaking(who) : `${r.last.by ? `${r.last.by}: ` : ''}${r.last.text}`; b.append(last);
|
|
1286
|
+
if (r.last) { const when = document.createElement('small'); when.className = 'when'; when.textContent = whenWords(Date.parse(r.last.at)); b.append(when); b.dataset.when = 'true'; }
|
|
1271
1287
|
} else { const sub = document.createElement('small'); sub.textContent = `Room \u00b7 ${r.members.filter((m) => m.kind === 'ai').length} AIs`; b.append(sub); }
|
|
1272
|
-
/* Its dot: new words in it waiting (the colour of what waits for you), else ready. */
|
|
1273
|
-
const point = statePoint(r.unread > 0 ? 'wait' : 'ready'); point.title = r.unread > 0 ? `${r.unread} new` : 'Room'; b.append(point);
|
|
1288
|
+
/* Its dot: new words in it waiting (the colour of what waits for you), else at work while one speaks, else ready. */
|
|
1289
|
+
const point = statePoint(r.unread > 0 ? 'wait' : who.length ? 'work' : 'ready'); point.title = r.unread > 0 ? `${r.unread} new` : who.length ? speaking(who) : 'Room'; b.append(point);
|
|
1274
1290
|
if (r.id === roomOpenNow()) b.setAttribute('aria-current', 'true');
|
|
1275
1291
|
b.addEventListener('click', () => { void openSalon(r.id); });
|
|
1276
1292
|
return b;
|
|
@@ -1307,6 +1323,26 @@
|
|
|
1307
1323
|
if (open) { const body = document.createElement('div'); body.className = 'group-body'; body.append(...inside.map((c) => itemButton(c))); unfolding(g, [body]); box.append(body); }
|
|
1308
1324
|
return box;
|
|
1309
1325
|
}
|
|
1326
|
+
/* THE LIST'S FILTER (All | Rooms only): the same pressed buttons as the other views' (Files: List | Icons). */
|
|
1327
|
+
let wordsAsked = false;
|
|
1328
|
+
function paintListShow() {
|
|
1329
|
+
const box = $('list-show'); if (!box) return;
|
|
1330
|
+
box.hidden = DEVICE || roomsNow().length === 0;
|
|
1331
|
+
/* Its words (and a room's « … parle… ») in the screen's language: read once, then painted again. */
|
|
1332
|
+
if (!box.hidden && !wordsAsked) { wordsAsked = true; void readWords().then(() => paint(), () => { wordsAsked = false; }); }
|
|
1333
|
+
for (const b of box.querySelectorAll('button')) {
|
|
1334
|
+
b.textContent = b.dataset.show === 'rooms' ? uiSaid('list-rooms-only', 'Rooms only') : uiSaid('list-all', 'All');
|
|
1335
|
+
b.setAttribute('aria-pressed', String((b.dataset.show === 'rooms') === roomsOnly));
|
|
1336
|
+
}
|
|
1337
|
+
box.setAttribute('aria-label', uiSaid('list-show', 'Show'));
|
|
1338
|
+
}
|
|
1339
|
+
for (const b of $('list-show')?.querySelectorAll('button') ?? []) {
|
|
1340
|
+
b.addEventListener('click', () => {
|
|
1341
|
+
roomsOnly = b.dataset.show === 'rooms';
|
|
1342
|
+
try { localStorage.setItem('clavarium-list-show', roomsOnly ? 'rooms' : 'all'); } catch { /* a private window */ }
|
|
1343
|
+
paint();
|
|
1344
|
+
});
|
|
1345
|
+
}
|
|
1310
1346
|
function paint() {
|
|
1311
1347
|
if (listHeld) { paintLater = true; return; }
|
|
1312
1348
|
/* The groups, folded as a whole or not (a search shows them all). */
|
|
@@ -1319,7 +1355,11 @@
|
|
|
1319
1355
|
const shown = conversations.filter((c) => (query ? matches(c) : c.hidden !== true || showHidden || c.name === current)).sort(byRank);
|
|
1320
1356
|
const heading = (text) => { const h = document.createElement('h3'); h.className = 'list-head'; h.textContent = text; return h; };
|
|
1321
1357
|
const groups = groupsInOrder();
|
|
1322
|
-
|
|
1358
|
+
/* ROOMS ONLY: the rooms alone (a search among them); offered once there is one. */
|
|
1359
|
+
const onlyRooms = roomsOnly && !DEVICE && roomsNow().length > 0;
|
|
1360
|
+
paintListShow();
|
|
1361
|
+
if (onlyRooms) groupsOpen = false;
|
|
1362
|
+
else if (query || DEVICE) {
|
|
1323
1363
|
/* A search: everything found, in its place. */
|
|
1324
1364
|
items.append(...shown.filter((c) => !c.group).map((c) => itemButton(c)));
|
|
1325
1365
|
} else {
|
|
@@ -1391,15 +1431,15 @@
|
|
|
1391
1431
|
if (inside.length === 0) continue;
|
|
1392
1432
|
items.append(groupBox(g, inside, conversations.filter((c) => c.group === g).sort(byRank), Boolean(query) || !folded.has(g)));
|
|
1393
1433
|
}
|
|
1394
|
-
if (groupsOpen) unfolding(GROUPS, [...items.children]);
|
|
1434
|
+
if (groupsOpen && !onlyRooms) unfolding(GROUPS, [...items.children]);
|
|
1395
1435
|
/* ROOMS (03-11): their own list, after the groups of conversations; a search finds them by name. */
|
|
1396
1436
|
const roomsShown = roomsNow().filter((r) => !query || r.name.toLowerCase().includes(String(query).toLowerCase()));
|
|
1397
1437
|
if (!DEVICE && roomsShown.length) {
|
|
1398
1438
|
const b = document.createElement('button'); b.type = 'button'; b.className = 'list-head list-fold'; b.dataset.section = 'rooms';
|
|
1399
|
-
const open = !folded.has(ROOMS); b.setAttribute('aria-expanded', String(open));
|
|
1439
|
+
const open = onlyRooms || !folded.has(ROOMS); b.setAttribute('aria-expanded', String(open));
|
|
1400
1440
|
const chevron = document.createElement('span'); chevron.className = 'list-chevron'; chevron.setAttribute('aria-hidden', 'true'); chevron.textContent = open ? '\u25BE' : '\u25B8';
|
|
1401
1441
|
b.append(chevron, document.createTextNode('Rooms'));
|
|
1402
|
-
b.addEventListener('click', () => { if (folded.has(ROOMS)) folded.delete(ROOMS); else folded.add(ROOMS); keepFolded(); paint(); });
|
|
1442
|
+
b.addEventListener('click', () => { if (onlyRooms) return; if (folded.has(ROOMS)) folded.delete(ROOMS); else folded.add(ROOMS); keepFolded(); paint(); });
|
|
1403
1443
|
items.append(b);
|
|
1404
1444
|
if (open) items.append(...roomsShown.map((r) => roomItem(r)));
|
|
1405
1445
|
}
|
|
@@ -1410,7 +1450,7 @@
|
|
|
1410
1450
|
if (query) hits.forEach((h, i) => { h.toggleAttribute('data-chosen', i === chosenHit); if (i === chosenHit) h.scrollIntoView?.({ block: 'nearest' }); });
|
|
1411
1451
|
$('search-none').hidden = !query || hits.length > 0;
|
|
1412
1452
|
const toggle = $('hidden-toggle');
|
|
1413
|
-
toggle.hidden = DEVICE || hidden.length === 0 || Boolean(query);
|
|
1453
|
+
toggle.hidden = DEVICE || hidden.length === 0 || Boolean(query) || onlyRooms;
|
|
1414
1454
|
toggle.textContent = showHidden ? `Hide ${hidden.length} hidden` : `${hidden.length} hidden`;
|
|
1415
1455
|
toggle.setAttribute('aria-expanded', String(showHidden));
|
|
1416
1456
|
const calling = hidden.some(needsYou);
|
|
@@ -5160,6 +5200,12 @@
|
|
|
5160
5200
|
return card;
|
|
5161
5201
|
}
|
|
5162
5202
|
let salonThread = null; let salonId = ''; let salonTimer = null;
|
|
5203
|
+
/* A room's bar while one of its AIs speaks: its dot at work (gold, breathing), the words under its name. */
|
|
5204
|
+
function salonLive(who) {
|
|
5205
|
+
const dot = $('salon-state'); const line = $('salon-live');
|
|
5206
|
+
if (dot) { dot.dataset.state = who.length ? 'work' : 'ok'; dot.title = who.length ? speaking(who) : ''; }
|
|
5207
|
+
if (line) { line.hidden = who.length === 0; line.textContent = who.length ? speaking(who) : ''; }
|
|
5208
|
+
}
|
|
5163
5209
|
function salonLeft() { clearInterval(salonTimer); salonTimer = null; salonThread?.destroy(); salonThread = null; salonId = ''; }
|
|
5164
5210
|
async function openSalon(id, push = true) {
|
|
5165
5211
|
if (DEVICE) return;
|
|
@@ -5167,7 +5213,8 @@
|
|
|
5167
5213
|
const r = rooms.find((x) => x.id === id); if (!r) return;
|
|
5168
5214
|
enterPlace('salon', push);
|
|
5169
5215
|
salonLeft(); salonId = id;
|
|
5170
|
-
$('salon-
|
|
5216
|
+
$('salon-name').textContent = r.name;
|
|
5217
|
+
salonLive(thinkingOf(r));
|
|
5171
5218
|
$('salon-who').replaceChildren(memberChips(r.members), el('span', 'hint', `${countOf(r.members)} \u25BE`));
|
|
5172
5219
|
$('salon-who').setAttribute('aria-expanded', 'false'); $('salon-members').hidden = true;
|
|
5173
5220
|
const rows = ['person', 'ai', 'box'].map((k) => { const of = r.members.filter((m) => m.kind === k); if (!of.length) return null; const row = el('div', 'salon-members-row'); row.append(el('span', 'hint', k === 'person' ? 'People' : k === 'ai' ? 'AIs' : 'Boxes'), ...of.map((m) => { const x = el('span', 'salon-member'); x.append(memberChips([m], 1), document.createTextNode(m.name)); if (m.host) x.append(el('span', 'salon-host', 'host')); return x; })); return row; }).filter(Boolean);
|
|
@@ -5179,10 +5226,14 @@
|
|
|
5179
5226
|
words, markdown: true, agentName: '',
|
|
5180
5227
|
load: (asked = {}) => fetch(`${API}/rooms/${id}/talk${asked.last ? `?last=${asked.last}` : ''}`).then((x) => x.json()).then((d) => {
|
|
5181
5228
|
/* Who was given a message and has not answered yet (#282): « Hugo réfléchit… ». */
|
|
5182
|
-
const who =
|
|
5229
|
+
const who = thinkingOf(d);
|
|
5183
5230
|
$('salon-thinking').hidden = who.length === 0;
|
|
5184
|
-
$('salon-thinking').replaceChildren(el('span', 'state-dot'), document.createTextNode(
|
|
5231
|
+
$('salon-thinking').replaceChildren(el('span', 'state-dot'), document.createTextNode(who.length > 1 ? uiSaid('room-thinking-many', '{names} are thinking\u2026', { names: who.join(', ') }) : uiSaid('room-thinking', '{name} is thinking\u2026', { name: who[0] ?? '' })));
|
|
5185
5232
|
$('salon-thinking').firstChild.dataset.state = 'work';
|
|
5233
|
+
/* Its bar says it too, as its row in the list: its dot at work, « Cuisine parle… » under its name. */
|
|
5234
|
+
salonLive(who);
|
|
5235
|
+
const known = rooms.find((x) => x.id === id);
|
|
5236
|
+
if (known && JSON.stringify(thinkingOf(known)) !== JSON.stringify(who)) { known.thinking = who; paint(); }
|
|
5186
5237
|
return d;
|
|
5187
5238
|
}),
|
|
5188
5239
|
send: (text) => post(`${API}/rooms/${id}/talk`, { text }),
|
package/web/index.html
CHANGED
|
@@ -18,6 +18,8 @@
|
|
|
18
18
|
<!-- SEARCH, discreet: opened by the magnifier, "/" or Ctrl+K; filters as it is typed. -->
|
|
19
19
|
<div id="search" role="search" hidden><input id="search-field" type="search" placeholder="Search" aria-label="Search conversations: name, folder, identifier, tool" autocomplete="off" spellcheck="false" maxlength="60" aria-controls="items"></div>
|
|
20
20
|
<!-- Needs you and Recent: copies of rows of the list below, by when they were last used (app.js, paint). -->
|
|
21
|
+
<!-- A FILTER of the list (once there is a room): everything, or the rooms only; kept on this device. -->
|
|
22
|
+
<div id="list-show" class="levels list-show" role="group" aria-label="Show" hidden><button type="button" data-show="all" aria-pressed="true">All</button><button type="button" data-show="rooms" aria-pressed="false">Rooms only</button></div>
|
|
21
23
|
<div id="recent"></div>
|
|
22
24
|
<div id="items"></div>
|
|
23
25
|
<p id="search-none" class="hint" hidden>Nothing found.</p>
|
package/web/style.css
CHANGED
|
@@ -57,7 +57,7 @@ button:focus-visible, input:focus-visible { outline: 2px solid var(--brass); out
|
|
|
57
57
|
.unfolding { animation: unfold .18s ease-out; }
|
|
58
58
|
@keyframes unfold { from { opacity: 0; transform: translateY(-6px); } }
|
|
59
59
|
@keyframes breathe { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .5; transform: scale(.85); } }
|
|
60
|
-
@media (prefers-reduced-motion: reduce) { .item > .state-dot, .unfolding { animation: none !important; } }
|
|
60
|
+
@media (prefers-reduced-motion: reduce) { .item > .state-dot, header.topbar .bar-state, .unfolding { animation: none !important; } }
|
|
61
61
|
.choices { display: flex; flex-wrap: wrap; gap: 6px; }
|
|
62
62
|
.choices button[aria-checked="true"] { border-color: var(--brass); background: rgba(210, 169, 78, .16); }
|
|
63
63
|
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
|
|
@@ -1384,6 +1384,9 @@ select.pill { appearance: auto; }
|
|
|
1384
1384
|
#list-pin[aria-pressed="true"] .ic { transform: none; fill: currentColor; fill-opacity: .25; }
|
|
1385
1385
|
@media (max-width: 700px) { #list-pin { display: none; } }
|
|
1386
1386
|
#search[hidden] { display: none; }
|
|
1387
|
+
/* The list's filter (All | Rooms only): the pressed buttons of the other views, small, the list's width. */
|
|
1388
|
+
.list-show[hidden] { display: none; }
|
|
1389
|
+
.list-show button { flex: 1 1 0; padding: 4px 8px; font-size: .78rem; }
|
|
1387
1390
|
#search-field { width: 100%; box-sizing: border-box; padding: 6px 10px; font-size: .9rem; border-radius: 8px; }
|
|
1388
1391
|
#search-none { margin: 0 .25rem; }
|
|
1389
1392
|
.item[data-chosen] { border-color: var(--brass); }
|
|
@@ -2285,6 +2288,12 @@ header.topbar > .fold-here { font-size: 1rem; line-height: 1; padding: 4px 9px;
|
|
|
2285
2288
|
header.topbar > b { flex: 1 1 auto; font-size: 1rem; }
|
|
2286
2289
|
header.topbar > .bar-right { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-left: auto; }
|
|
2287
2290
|
header.topbar .bar-state { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; }
|
|
2291
|
+
/* A room one of whose AIs speaks now: its dot as a conversation's at work, the words under its name. */
|
|
2292
|
+
header.topbar .bar-state[data-state="work"] { background: var(--brass); animation: breathe 1.7s ease-in-out infinite; }
|
|
2293
|
+
#salon-title { display: flex; flex-direction: column; min-width: 0; }
|
|
2294
|
+
#salon-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
2295
|
+
.salon-live { font-size: .75rem; font-weight: 400; color: var(--ink2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
2296
|
+
.salon-live[hidden] { display: none; }
|
|
2288
2297
|
header.topbar .views .icon-btn { width: auto; height: auto; }
|
|
2289
2298
|
/* Pages with margins of their own: their bar goes edge to edge, as a conversation's. */
|
|
2290
2299
|
#places .sheet:not(.as-place) > header.topbar { margin: -14px -14px 4px; }
|