clavarium 0.2.333-next.1 → 0.2.336-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.
@@ -1,20 +1,20 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.333-next.1",
3
+ "version": "0.2.336-next.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "clavarium",
9
- "version": "0.2.333-next.1",
9
+ "version": "0.2.336-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
- "clavarium-binder": "0.1.60-next.1",
14
+ "clavarium-binder": "0.1.61-next.1",
15
15
  "clavarium-docket": "0.1.2-next.2",
16
16
  "clavarium-parley": "0.17.71-next.1",
17
- "clavarium-tether": "0.1.0-next.53",
17
+ "clavarium-tether": "0.1.0-next.54",
18
18
  "mammoth": "1.13.0",
19
19
  "mermaid": "11.17.2",
20
20
  "node-pty": "^1.1.0",
@@ -761,9 +761,9 @@
761
761
  }
762
762
  },
763
763
  "node_modules/clavarium-binder": {
764
- "version": "0.1.60-next.1",
765
- "resolved": "https://registry.npmjs.org/clavarium-binder/-/clavarium-binder-0.1.60-next.1.tgz",
766
- "integrity": "sha512-Tyat1gQu+V4XCvQknRTBc3TChsE3RTWdRuQATsQoTDD7/FmaXWijFhmhH8IaUdMhtA5p5IikxEfDha7AR0PBlw==",
764
+ "version": "0.1.61-next.1",
765
+ "resolved": "https://registry.npmjs.org/clavarium-binder/-/clavarium-binder-0.1.61-next.1.tgz",
766
+ "integrity": "sha512-yxaKU3pBfoGYkGXADEALeEhEBivP6L2GD8S/ke2/oESIMRd/D9uLf8fYg+geHfonxLNxj3cWen/H6d1YoCGtww==",
767
767
  "license": "MIT",
768
768
  "bin": {
769
769
  "binder": "bin/binder.mjs",
@@ -800,9 +800,9 @@
800
800
  }
801
801
  },
802
802
  "node_modules/clavarium-tether": {
803
- "version": "0.1.0-next.53",
804
- "resolved": "https://registry.npmjs.org/clavarium-tether/-/clavarium-tether-0.1.0-next.53.tgz",
805
- "integrity": "sha512-kFSGOQs0bNaURU4SG+IFO7C7zRmLavefZZ/BXvjceuTHM2WP5A58q8H8xkWb1HrHDrj74DqQXYl4TF3kKSNkiA==",
803
+ "version": "0.1.0-next.54",
804
+ "resolved": "https://registry.npmjs.org/clavarium-tether/-/clavarium-tether-0.1.0-next.54.tgz",
805
+ "integrity": "sha512-sB6g/J9jWwEGB+bohHKnp1AI2R93RvCUGWdB5AZxMUgQAsrdj2xifZeldW1nqVUtDcRajYyTC3B6YTrKW2/egA==",
806
806
  "license": "MIT",
807
807
  "bin": {
808
808
  "tether": "bin/cli.mjs",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.333-next.1",
3
+ "version": "0.2.336-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.",
@@ -44,10 +44,10 @@
44
44
  "dependencies": {
45
45
  "@xterm/addon-fit": "^0.11.0",
46
46
  "@xterm/xterm": "^6.0.0",
47
- "clavarium-binder": "0.1.60-next.1",
47
+ "clavarium-binder": "0.1.61-next.1",
48
48
  "clavarium-docket": "0.1.2-next.2",
49
49
  "clavarium-parley": "0.17.71-next.1",
50
- "clavarium-tether": "0.1.0-next.53",
50
+ "clavarium-tether": "0.1.0-next.54",
51
51
  "mammoth": "1.13.0",
52
52
  "mermaid": "11.17.2",
53
53
  "node-pty": "^1.1.0",
package/server/api.mjs CHANGED
@@ -140,6 +140,7 @@
140
140
  * POST /api/setup/pair {label}: what a device to pair will get (the code is made by /api/shares)
141
141
  * POST /api/setup/drop {id}: something an import waits for, not wanted after all
142
142
  * GET /api/files/download?c=...&r=...&p=<path> one file
143
+ * GET /api/mail/open?ref=mail:...&c= GET /api/mail/page?ref=... a mail cited by its reference, read now (mailref.mjs)
143
144
  * POST /api/files/import?c=...&r=...&p=<folder>&name=<file name>[&dir=<subfolders>&exists=keep|replace|skip&batch=<id>] the body IS the file
144
145
  * GET /api/files/thumb|text POST /api/files/save|make|rename|move|remove|taken ?c=...&r=...&p=... (see files.mjs)
145
146
  *
@@ -153,6 +154,7 @@ import { sameOrigin } from './bridge.mjs';
153
154
  import { Refusal, DISK_GB } from './conversations.mjs';
154
155
  import { VmUnknown } from './vm.mjs';
155
156
  import { list, download, importFile, page, PAGE_HEADERS, changeRoute, IMAGE_HEADERS, mailFile, mailPage } from './files.mjs';
157
+ import { mailRoute } from './mailref.mjs';
156
158
  import { WORK_TAB } from './resources.mjs';
157
159
  import { transcribe, AUDIO_MAX } from './voice.mjs';
158
160
  import { FILE_MAX } from './setup.mjs';
@@ -251,6 +253,11 @@ export async function handleApi(request, response, conversations, headers, resou
251
253
  response.end(shown.body);
252
254
  return true;
253
255
  }
256
+ if (request.method === 'GET' && (pathname === '/api/mail/open' || pathname === '/api/mail/page')) {
257
+ /* A mail cited by its reference (mailref.mjs), read now through Tether: the owner may read every mailbox. */
258
+ const c = query.get('c') ?? '';
259
+ return await mailRoute(pathname.slice('/api'.length), query, response, { tethers, headers, who: { id: `person:${identity || 'owner'}`, name: identity || 'Owner' }, may: () => true, offline: conversations.list().find((x) => x.name === c)?.offline === true, of: c });
260
+ }
254
261
  if (request.method === 'GET' && pathname === '/api/files/download') {
255
262
  const file = await download(attached(), query.get('p') ?? '');
256
263
  response.writeHead(200, { ...headers, 'content-type': 'application/octet-stream', 'content-length': file.size,
package/server/door.mjs CHANGED
@@ -18,6 +18,7 @@
18
18
  * GET /c/api/<pairing>/voice POST .../voice
19
19
  * GET /c/api/<pairing>/files GET .../files/download GET .../files/machine POST .../files/import
20
20
  * GET .../files/thumb|text POST .../files/save|make|rename|move|remove|taken (see files.mjs)
21
+ * GET .../mail/open?ref= GET .../mail/page?ref= a mail cited by its reference: only a mailbox it may read (mailref.mjs)
21
22
  * POST /c/api/<pairing>/leave the device removes this pairing itself
22
23
  * GET /c/api/<pairing>/talk/words?lang=
23
24
  * GET /c/api/<pairing>/conversations/<any>/talk POST the same {text, answers}; ?last= ?days= ?before= ?from= ?since=: a part of it
@@ -50,6 +51,7 @@ import { readCookie, sessionCookie, cookieNameOf, isPairingId } from './devices.
50
51
  import { WORK_TAB } from './resources.mjs';
51
52
  import { list, download, importFile, page, PAGE_HEADERS, changeRoute, CHANGE_ROUTES, IMAGE_HEADERS, mailFile, mailPage } from './files.mjs';
52
53
  import { transcribe, AUDIO_MAX } from './voice.mjs';
54
+ import { mailRoute, deviceMayRead } from './mailref.mjs';
53
55
 
54
56
  const BODY_MAX = 16 * 1024;
55
57
 
@@ -84,7 +86,7 @@ export function devicePairing(devices, headers, pairing) {
84
86
  }
85
87
 
86
88
  /* Returns true when the request was under /c/api/ (answered here). */
87
- export async function handleDoor(request, response, { devices, conversations, resources, shortcuts, voice, originOk, headers, secure, talk, repair }) {
89
+ export async function handleDoor(request, response, { devices, conversations, resources, shortcuts, voice, originOk, headers, secure, talk, repair, tethers, mailboxes }) {
88
90
  const url = new URL(request.url ?? '/', 'http://local');
89
91
  if (!url.pathname.startsWith('/c/api/')) return false;
90
92
  /* "/<pairing>/me" -> the pairing and "/me"; "/pair" has no pairing yet. */
@@ -155,7 +157,7 @@ export async function handleDoor(request, response, { devices, conversations, re
155
157
  return send(200, { ...about, conversations: names.filter((n) => conversations.list().some((c) => c.name === n)), shared: own });
156
158
  }
157
159
  /* The files a device was given for itself need no conversation; everything else does. */
158
- const forFiles = route === '/files' || route === '/files/download' || route === '/files/page' || route === '/files/mail' || route === '/files/import' || CHANGE_ROUTES.includes(route) || route === '/leave';
160
+ const forFiles = route === '/files' || route === '/files/download' || route === '/files/page' || route === '/files/mail' || route === '/files/import' || CHANGE_ROUTES.includes(route) || route === '/leave' || route === '/mail/open' || route === '/mail/page';
159
161
  if (!mine && !forFiles) return send(404, { error: 'This device was given no conversation.' });
160
162
  /* Shortcuts are typed into the terminal, or are the ready answers of the chat: one of the two must be its to write in. */
161
163
  if (request.method === 'GET' && route === '/shortcuts') { need(part.terminal || part.chat === 'write', 'the terminal or the chat'); return send(200, shortcuts.list()); }
@@ -215,6 +217,10 @@ export async function handleDoor(request, response, { devices, conversations, re
215
217
  response.end(shown.body);
216
218
  return true;
217
219
  }
220
+ /* A mail cited by its reference (mailref.mjs): only a mailbox this device was given to read. */
221
+ if (request.method === 'GET' && (route === '/mail/open' || route === '/mail/page')) {
222
+ return await mailRoute(route, url.searchParams, response, { tethers, headers, who: { id: `pairing:${pairing}`, name: 'A device' }, may: (t) => deviceMayRead(t, own, mailboxes), offline: mine?.offline === true });
223
+ }
218
224
  if (request.method === 'GET' && route === '/files/download') {
219
225
  const file = await download(attached('read', 'open'), url.searchParams.get('p') ?? '');
220
226
  response.writeHead(200, { ...headers, 'content-type': 'application/octet-stream', 'content-length': file.size,
package/server/files.mjs CHANGED
@@ -130,6 +130,13 @@ export function mailPage(bytes) {
130
130
  const body = reader.pageOf(reader.parse(bytes), { remote: true }).html;
131
131
  return { body, headers: { ...MAIL_HEADERS, 'content-length': Buffer.byteLength(body) } };
132
132
  }
133
+ /* A mail's name as a file: its subject, made a plain file name (a mail opened by its reference, downloaded). */
134
+ export function mailName(bytes) {
135
+ let subject = '';
136
+ try { subject = mailReader().parse(bytes).subject; } catch { /* no subject read */ }
137
+ const plain = String(subject ?? '').replace(/[\\/:*?"<>|\u0000-\u001f\u007f]+/g, ' ').replace(/\s+/g, ' ').trim().slice(0, 80);
138
+ return `${plain || 'mail'}.eml`;
139
+ }
133
140
  /* The bytes of a mail file of a folder, for mailPage. */
134
141
  export async function mailFile(root, relative) {
135
142
  const file = await download(root, relative);
@@ -0,0 +1,90 @@
1
+ /* A MAIL CITED BY ITS REFERENCE (06-11), opened in the page's mail viewer -- the one .eml files open in
2
+ * (web/mail-view.js, showMail in app.js): one reader, never a second one.
3
+ *
4
+ * mail:TARGET/MESSAGE-ID[?in=FOLDER&uid=N] Tether's reference (clavarium-tether/verbs): the
5
+ * mailbox target, the mail's own Message-ID, hints
6
+ *
7
+ * GET .../mail/open?ref= the mail's bytes (message/rfc822), read through Tether (mail.open) at the
8
+ * moment it is opened: never before, never kept here, on disk or elsewhere
9
+ * GET .../mail/page?ref= the same mail as a page with its remote pictures (files.mjs mailPage, the
10
+ * .eml's own code and headers), only when the reader asks for them
11
+ *
12
+ * WHO MAY OPEN IT: whoever may read that mailbox -- the owner always; a device only with the Read right
13
+ * on a mailbox asset of the same address (grants.mjs, "mailbox r"). Anyone else is told it is not theirs
14
+ * to open, and nothing is read. The read is that person's in Tether's journal, never an agent's, and is
15
+ * never asked of anyone.
16
+ *
17
+ * An OLD REFERENCE (a bare uid a card kept before references existed) opens only where it can be read
18
+ * without guessing: the one mailbox its conversation was given, its inbox. Else it says so. */
19
+ import { readMailRef } from 'clavarium-tether/verbs';
20
+ import { Refusal } from './conversations.mjs';
21
+ import { mailPage, mailName, MAIL_MAX } from './files.mjs';
22
+
23
+ const refused = (status, kind, message) => Object.assign(new Refusal(status, message), { kind });
24
+ const OLD_REF = /^[A-Za-z0-9_=+/-]{1,1024}$/;
25
+ export const isMailRef = (text) => readMailRef(text) !== null;
26
+
27
+ /* A device may read the mailbox of a target when it was given a mailbox asset of the same address, to read. */
28
+ export function deviceMayRead(target, own, mailboxes) {
29
+ const user = String(target?.config?.user ?? '').trim().toLowerCase();
30
+ if (!user) return false;
31
+ const boxes = mailboxes?.list?.() ?? [];
32
+ return (own ?? []).some((g) => g.type === 'mailbox' && boxes.some((m) => m.name === g.name && String(m.user ?? '').trim().toLowerCase() === user));
33
+ }
34
+
35
+ /* The mail of a reference, read now: { bytes, box, folder, ref, cut }. `may(target)`: this person reads that
36
+ mailbox. `who`: { id, name }, said in Tether's journal. `of`: the conversation an old reference was kept by. */
37
+ export async function openMail(tethers, given, { who, may, of = '' }) {
38
+ if (!tethers) throw refused(503, 'unreachable', 'Mailboxes are not reached from this server.');
39
+ const text = String(given ?? '').trim();
40
+ const ref = readMailRef(text);
41
+ if (!ref) return oldRef(tethers, text, { who, may, of });
42
+ const target = tethers.store().target(ref.target);
43
+ if (!target || target.kind !== 'mail') throw refused(404, 'gone', 'This mailbox is no longer here.');
44
+ if (!may(target)) throw refused(403, 'not-yours', 'This mailbox is not yours to open.');
45
+ const got = await tethers.read('mail.open', { ref: text }, who);
46
+ if (!got.ok) {
47
+ if (got.code === 'gone') throw refused(410, 'gone', 'This mail is no longer in the mailbox.');
48
+ throw refused(502, 'unreachable', `${target.title} cannot be reached: ${got.text}`);
49
+ }
50
+ return { bytes: got.data.raw, box: target.title, folder: got.data.folder ?? '', ref: got.data.ref || text, cut: got.data.cut === true };
51
+ }
52
+ async function oldRef(tethers, text, { who, may, of }) {
53
+ const old = () => refused(409, 'old-ref', 'An old reference: ask the AI to attach this mail again.');
54
+ if (!OLD_REF.test(text) || !of) throw old();
55
+ const boxes = tethers.store().targets().filter((t) => t.kind === 'mail' && t.grants?.[`conversation:${of}`]);
56
+ if (boxes.length !== 1) throw old();
57
+ const [target] = boxes;
58
+ if (!may(target)) throw refused(403, 'not-yours', 'This mailbox is not yours to open.');
59
+ const got = await tethers.read('mail.source', { target: target.id, uid: text }, who);
60
+ if (!got.ok) throw old();
61
+ const raw = String(got.text).replace(/\n\n\(Large message — [^)]*\)$/, '');
62
+ return { bytes: Buffer.from(raw, 'utf8'), box: target.title, folder: '', ref: text, cut: raw.length !== String(got.text).length };
63
+ }
64
+
65
+ /* The two routes, one implementation for the owner's page (api.mjs) and a device's (door.mjs). `route`:
66
+ '/mail/open' or '/mail/page'. `offline`: the conversation shown is cut off (no remote pictures, as for an
67
+ .eml). Returns true when answered. */
68
+ export async function mailRoute(route, query, response, { tethers, headers, who, may, offline = false, of = '' }) {
69
+ if (route !== '/mail/open' && route !== '/mail/page') return false;
70
+ if (route === '/mail/page' && offline) throw new Refusal(403, 'This conversation is offline: remote pictures stay blocked.');
71
+ const opened = await openMail(tethers, query.get('ref'), { who, may, of });
72
+ if (opened.bytes.length > MAIL_MAX) throw refused(413, 'too-large', 'This mail is too large to be shown here.');
73
+ const bytes = new Uint8Array(opened.bytes.buffer, opened.bytes.byteOffset, opened.bytes.byteLength);
74
+ if (route === '/mail/page') {
75
+ const shown = mailPage(bytes);
76
+ response.writeHead(200, shown.headers);
77
+ response.end(shown.body);
78
+ return true;
79
+ }
80
+ /* Its bytes, as a file to download too; where it was found, said beside them. */
81
+ response.writeHead(200, {
82
+ ...headers, 'content-type': 'message/rfc822', 'content-length': opened.bytes.length,
83
+ 'content-disposition': `attachment; filename*=UTF-8''${encodeURIComponent(mailName(bytes))}`,
84
+ 'cache-control': 'no-store', 'x-content-type-options': 'nosniff',
85
+ 'x-mail-box': encodeURIComponent(opened.box), 'x-mail-folder': encodeURIComponent(opened.folder),
86
+ 'x-mail-ref': encodeURIComponent(opened.ref), ...(opened.cut ? { 'x-mail-cut': '1' } : {}),
87
+ });
88
+ response.end(opened.bytes);
89
+ return true;
90
+ }
package/server/main.mjs CHANGED
@@ -280,7 +280,7 @@ const PARLEY_WAIT_MS = 20_000;
280
280
  /* The product: conversations are VMs. `host` is how the host program is
281
281
  reached on this installation, as an argument vector: it is the ONLY thing
282
282
  this server runs with more rights than its own. */
283
- export async function startHome({ port, host, dataDir, mntDir = dataDir, gitReserveBytes, env = process.env, conversations, resources, operators = [], publicOrigin, vaultKey, tools = loadTools(), stopDelayMs, mailReader, gitLocalRemotes = false, gitSsh, answerFetcher, answerEveryMs, wakeEveryMs, alertSend, talkEveryMs, gitEveryMs, shelfEveryMs, shelfFirstMs, healthEveryMs, healthSettleMs, setupPollMs, rereadAfterMs, serverRoomMs, updateState, updateConf, appName, startWaitMs = 20_000, vmWatchEveryMs, historyEveryMs = HISTORY_STEP_MS }) {
283
+ export async function startHome({ port, host, dataDir, mntDir = dataDir, gitReserveBytes, env = process.env, conversations, resources, operators = [], publicOrigin, vaultKey, tools = loadTools(), stopDelayMs, mailReader, gitLocalRemotes = false, gitSsh, answerFetcher, answerEveryMs, wakeEveryMs, alertSend, talkEveryMs, gitEveryMs, shelfEveryMs, shelfFirstMs, healthEveryMs, healthSettleMs, setupPollMs, rereadAfterMs, serverRoomMs, updateState, updateConf, appName, startWaitMs = 20_000, vmWatchEveryMs, historyEveryMs = HISTORY_STEP_MS, tetherConnectors }) {
284
284
  /* The data, in the format this code reads, before anything reads it (dataformat.mjs). */
285
285
  const migrated = migrateData(dataDir);
286
286
  if (migrated.ran.length) console.log(`data: format ${migrated.from} -> ${migrated.to}`);
@@ -459,7 +459,7 @@ export async function startHome({ port, host, dataDir, mntDir = dataDir, gitRese
459
459
  mailbox, a calendar, an address book -- held here with their secrets read from
460
460
  the vault by name, never in a machine: see tethers.mjs. */
461
461
  /* Voice boxes are Tether targets too (boxes.mjs): their connector reaches them through `boxes`, made below. */
462
- const tethers = new Tethers({ dataDir, resources: folders, conversations: () => all.list().map((c) => c.name), secrets, dockets, connectors: { voicebox: { run: (...a) => voiceboxConnector(boxes).run(...a) } } });
462
+ const tethers = new Tethers({ dataDir, resources: folders, conversations: () => all.list().map((c) => c.name), secrets, dockets, connectors: { voicebox: { run: (...a) => voiceboxConnector(boxes).run(...a) }, ...(tetherConnectors ?? {}) } });
463
463
  const stopTethers = tethers.start();
464
464
  /* Connecting a mailbox, calendar or address book by token: the consent happens
465
465
  in the owner's browser, the refresh token is kept host-only (never in a
@@ -534,6 +534,8 @@ export async function startHome({ port, host, dataDir, mntDir = dataDir, gitRese
534
534
  tethers.announce = (name, event) => { try { return talk.event(name, event); } catch { return null; } };
535
535
  /* A device given a conversation that talks through the app talks there too. */
536
536
  door.talk = talk;
537
+ /* A mail cited by its reference, opened on a device that may read its mailbox (mailref.mjs). */
538
+ door.tethers = tethers; door.mailboxes = mailboxes;
537
539
  /* AFTER AN UPDATE, the machines that run get the new tools at once (parley, docket: they serve from
538
540
  their next command); a tool started with older launchers is told, in its chat, that a restart
539
541
  gives it the rest (its hooks, its MCP servers: read only when it starts). Nothing is restarted. */
@@ -21,6 +21,8 @@ export const SETTINGS_WORDS_FR = {
21
21
  'set-just-now': 'à l\'instant', 'set-min-ago': 'il y a {n} min', 'set-h-ago': 'il y a {n} h', 'set-days-ago': 'il y a {n} jours',
22
22
  'set-on': 'Activé', 'set-off': 'Désactivé', 'set-none': 'Aucun', 'set-changed': '{n} modifiés', 'set-as-given': 'Comme livrés',
23
23
  'set-lang-device': 'La langue de chaque appareil', 'set-res-now': 'Mémoire {m} % · disque {d} %',
24
+ 'set-share-memory': 'Mémoire par machine', 'set-share-disk': 'Disque par machine', 'set-share-others': 'Autres',
25
+ 'set-share-rest': 'Système et autres', 'set-share-else': 'Tout le reste', 'set-share-free': 'Libre', 'set-share-used': 'Utilisé', 'set-share-of': 'sur {total}',
24
26
  'set-binders-max': 'Les agents en font {n} au plus', 'set-admin-1': '1 administrateur', 'set-admins': '{n} administrateurs',
25
27
  'set-backup-now': 'Exporter · importer', 'set-git-key': '1 clé git', 'set-git-keys': '{n} clés git', 'set-restart': 'redémarrer',
26
28
  'set-logs-now': 'Clavarium, machines, système',
@@ -48,5 +50,9 @@ export const SETTINGS_WORDS_FR = {
48
50
  'set-mail-details': 'Afficher les détails', 'set-mail-hide-details': 'Masquer les détails', 'set-mail-no-subject': '(sans objet)',
49
51
  'set-mail-remote': 'Images distantes bloquées', 'set-mail-show-remote': 'Les afficher', 'set-mail-empty': 'Ce mail n\'a pas de texte.',
50
52
  'set-mail-file': '1 pièce jointe', 'set-mail-files': '{n} pièces jointes', 'set-mail-download': 'Télécharger', 'set-mail-of': 'Pièce jointe de {name}',
53
+ 'set-mail-mail': 'Mail', 'set-mail-reply': 'Répondre…', 'set-mail-reply-ask': 'Réponds à ce mail :', 'set-mail-retry': 'Réessayer',
54
+ 'set-mail-gone': 'Ce mail n\'est plus dans la boîte.', 'set-mail-not-yours': 'Vous n\'avez pas accès à cette boîte.',
55
+ 'set-mail-old-ref': 'Réf. ancienne : demandez à l\'IA de la rattacher.', 'set-mail-unreachable': 'Boîte injoignable pour le moment.',
56
+ 'set-mail-cut': 'Mail tronqué : pièces jointes incomplètes.',
51
57
  };
52
58
  export const settingsWords = (lang) => (String(lang ?? '').toLowerCase().split('-')[0] === 'fr' ? { ...SETTINGS_WORDS_FR } : {});
@@ -262,6 +262,13 @@ export class Tethers {
262
262
  return this.#keeper.act(String(op ?? ''), args && typeof args === 'object' ? args : {}, who);
263
263
  }
264
264
 
265
+ /* A person's read, from the page (a mail opened by its reference, mailref.mjs): never asked, journaled as
266
+ that person's. `who`: { id, name }, the person the caller has already checked may read it. */
267
+ read(verb, args, who) {
268
+ const by = { id: String(who?.id ?? 'person:owner'), name: String(who?.name ?? 'Owner') };
269
+ return this.#keeper.read(String(verb ?? ''), args && typeof args === 'object' ? args : {}, by);
270
+ }
271
+
265
272
  /* The store behind it, for the Assets page to create/give/remove targets. */
266
273
  store() { return this.#keeper.store; }
267
274
 
package/web/app.js CHANGED
@@ -5843,6 +5843,7 @@
5843
5843
  if (a.kind === 'asset') void openAssetsPlace(a.ref);
5844
5844
  else if (a.kind === 'message') void openCardMessage(whose(), a.ref);
5845
5845
  else if (a.kind === 'file') void openCardFile(whose(), a.ref);
5846
+ else if (a.kind === 'mail') openCardMail(whose(), a);
5846
5847
  else if (a.kind === 'commit' || a.kind === 'branch') void openCardGit(whose(), a.ref, a.kind);
5847
5848
  else if (a.kind === 'link' && /^https?:\/\//i.test(a.ref)) window.open(a.ref, '_blank', 'noopener');
5848
5849
  },
@@ -5913,6 +5914,39 @@
5913
5914
  const tab = m[1] === 'work' ? 'work' : m[1].slice('resources/'.length);
5914
5915
  void preview(tab, m[2], m[2].split('/').pop(), 0);
5915
5916
  }
5917
+ /* A mail of a card (06-11): its reference (mail:...) opens the mail viewer; a mail file (.eml), as a file;
5918
+ an old bare id, where the server can still read it (else it says so, in the viewer). */
5919
+ function openCardMail(name, a) {
5920
+ const ref = String(a.ref ?? '').trim();
5921
+ if (!ref.startsWith('mail:') && /\.eml$/i.test(ref)) { openCardFile(name, ref); return; }
5922
+ void openMailRef(ref, { label: a.title, of: name });
5923
+ }
5924
+ /* A MAIL CITED BY ITS REFERENCE (mail:TARGET/MESSAGE-ID, 06-11): the viewer of the .eml files, over the
5925
+ page, its bytes read by the server through Tether when it is opened -- never before, kept nowhere --
5926
+ and only by whoever may read that mailbox. `of`: the conversation it was cited in, whose chat Reply
5927
+ writes in. */
5928
+ function openMailRef(ref, { label = '', of = current } = {}) {
5929
+ const q = new URLSearchParams({ ref, ...(of ? { c: of } : {}) });
5930
+ const name = `${String(label || '').trim() || uiSaid('set-mail-mail', 'Mail')}.eml`;
5931
+ return preview('', '', name, 0, `${API}/mail/open?${q}`, { mailRef: { ref, of, label } });
5932
+ }
5933
+ /* Reply, from the viewer: nothing is sent -- the chat of its conversation is given the start of a request
5934
+ to its AI (« Reply to this mail: » and the reference), for the person to finish and send. */
5935
+ async function replyToMail({ ref, of }) {
5936
+ closePreview();
5937
+ if (!DEVICE && of && of !== current && !toConversation(of)) return;
5938
+ goTab('chat');
5939
+ for (let i = 0; i < 40; i++) {
5940
+ const box = document.querySelector('#chat textarea.parley-box, #simple-thread textarea.parley-box, textarea.parley-box');
5941
+ if (box && box.offsetParent !== null) {
5942
+ box.value = `${uiSaid('set-mail-reply-ask', 'Reply to this mail:')} ${ref}\n`;
5943
+ box.dispatchEvent(new Event('input', { bubbles: true })); box.focus();
5944
+ box.setSelectionRange?.(box.value.length, box.value.length);
5945
+ return;
5946
+ }
5947
+ await new Promise((r) => setTimeout(r, 100));
5948
+ }
5949
+ }
5916
5950
  /* A commit or a branch of a repository of its conversation (ref "repository:sha" / "repository:branch"): the git review, at it. */
5917
5951
  function openCardGit(name, ref, kind) {
5918
5952
  const raw = String(ref ?? '').trim(); const at = raw.indexOf(':');
@@ -6743,13 +6777,27 @@
6743
6777
  const aboveWords = (aboveMb, reserveMb) => (aboveMb >= 0 ? `${GB(aboveMb)} above the ${GB(reserveMb)} reserve` : `${GB(-aboveMb)} into the ${GB(reserveMb)} reserve: new machines are refused`);
6744
6778
  function parts(dl, rows) {
6745
6779
  dl.replaceChildren();
6746
- for (const [label, value, sub] of rows) {
6780
+ for (const [label, value, sub, slot] of rows) {
6747
6781
  if (value === null || value === undefined) continue;
6748
6782
  const dt = document.createElement('dt'); dt.textContent = label; if (sub) dt.className = 'sub';
6783
+ if (slot !== undefined) dt.prepend(KIT.ShareKey(slot));
6749
6784
  const dd = document.createElement('dd'); dd.textContent = typeof value === 'number' ? GB(value) : value; dd.className = [sub ? 'sub' : '', typeof value === 'number' ? '' : 'words'].filter(Boolean).join(' ');
6750
6785
  dl.append(dt, dd);
6751
6786
  }
6752
6787
  }
6788
+ /* WHO TAKES IT, AT A GLANCE (06-11): a small donut by machine beside each list, the list its legend.
6789
+ A machine keeps its colour on both bars while the page lives. */
6790
+ const shareSlots = new Map();
6791
+ const shareWords = () => ({ others: uiSaid('set-share-others', 'Others'), rest: uiSaid('set-share-rest', 'System and others'), free: uiSaid('set-share-free', 'Free') });
6792
+ const machineTitle = (name) => conversations.find((x) => x.name === name)?.title || name;
6793
+ /* The slices, and each machine's slot for its row (a machine folded into "Others" takes its colour). */
6794
+ function shareOf(machines, restMb, freeMb, rest) {
6795
+ const slices = KIT.shareSlices(machines, { restMb, freeMb, slots: shareSlots, words: { ...shareWords(), ...(rest ? { rest } : {}) } });
6796
+ const slot = new Map(slices.flatMap((x) => (x.keys ? x.keys.map((k) => [k, 0]) : [[x.key, x.slot]])));
6797
+ return { slices, slot };
6798
+ }
6799
+ /* The donut, its middle the main figure: what is used, of how much. */
6800
+ const shareDonut = (slices, label, usedMb, totalMb) => KIT.ShareDonut({ slices, label, fmt: GB, center: { top: uiSaid('set-share-used', 'Used'), main: GB(usedMb), sub: uiSaid('set-share-of', 'of {total}', { total: GB(totalMb) }) } });
6753
6801
  const TITLES = { machines: "Disk of the machines", data: "Disk of this server's data", folders: 'Disk of the shared folders' };
6754
6802
  /* One block per disk of the server, with what it holds. */
6755
6803
  function paintDisks(r) {
@@ -6774,6 +6822,7 @@
6774
6822
  note.textContent = machines ? aboveWords(d.freeMb - r.reserve.diskMb, r.reserve.diskMb) : 'No reserve here: the machines are not on this disk.';
6775
6823
  const dl = document.createElement('dl'); dl.className = 'server-parts';
6776
6824
  const rows = [];
6825
+ let share = null;
6777
6826
  if (u) {
6778
6827
  if (d.holds.includes('data')) rows.push(["This server's data", c.dataMb]);
6779
6828
  if (d.holds.includes('folders')) {
@@ -6781,7 +6830,9 @@
6781
6830
  rows.push(['Shared folders', sum(shared)], ...shared);
6782
6831
  }
6783
6832
  if (machines) {
6784
- const each = [...m.each.slice(0, 8).map((x) => [x.name, x.mb, true]), ...(m.each.length > 8 ? [[`${m.each.length - 8} more`, m.each.slice(8).reduce((a, x) => a + x.mb, 0), true]] : []), ...(m.shelfMb ? [['ready-made machine', m.shelfMb, true]] : []), ['images', m.imagesMb, true]];
6833
+ const rest = Math.max(0, d.sizeMb - d.freeMb - m.each.reduce((a, x) => a + x.mb, 0));
6834
+ share = shareOf(m.each.map((x) => ({ key: x.name, label: machineTitle(x.name), mb: x.mb })), rest, d.freeMb, uiSaid('set-share-else', 'Everything else'));
6835
+ const each = [...m.each.slice(0, 8).map((x) => [machineTitle(x.name), x.mb, true, share.slot.get(x.name)]), ...(m.each.length > 8 ? [[`${m.each.length - 8} more`, m.each.slice(8).reduce((a, x) => a + x.mb, 0), true]] : []), ...(m.shelfMb ? [['ready-made machine', m.shelfMb, true]] : []), ['images', m.imagesMb, true]];
6785
6836
  rows.push(['Machines', sum(each)], ...each);
6786
6837
  if (m.othersMb) rows.push(['Other machines', m.othersMb]);
6787
6838
  }
@@ -6793,7 +6844,10 @@
6793
6844
  if (rest > 50) rows.push(['The system and other programs', rest]);
6794
6845
  } else rows.push(['What takes it', r.measuring ? 'measuring...' : 'not measured yet']);
6795
6846
  parts(dl, rows);
6796
- block.append(head, bar, note, dl);
6847
+ const row = document.createElement('div'); row.className = 'share-row';
6848
+ if (share?.slices.some((x) => x.key !== 'free')) row.append(shareDonut(share.slices, uiSaid('set-share-disk', 'Disk by machine'), d.sizeMb - d.freeMb, d.sizeMb));
6849
+ row.append(dl);
6850
+ block.append(head, bar, note, row);
6797
6851
  box.append(block);
6798
6852
  }
6799
6853
  }
@@ -7526,10 +7580,14 @@
7526
7580
  $('server-memory-state').textContent = 'Short'; $('server-memory-state').hidden = !r.high.memory;
7527
7581
  $('server-memory-note').textContent = aboveWords(mem.freeMb - r.reserve.memoryMb, r.reserve.memoryMb);
7528
7582
  const held = r.machines.reduce((a, x) => a + x.rssMb, 0);
7583
+ const rest = Math.max(0, mem.totalMb - mem.freeMb - held);
7584
+ const named = r.machines.map((x, i) => ({ key: x.name ?? `vm-${i}`, label: x.shelf ? 'ready-made machine (being made)' : (x.name ? machineTitle(x.name) : 'another machine'), mb: x.rssMb, x }));
7585
+ const share = shareOf(named, rest, mem.freeMb);
7586
+ $('server-memory-share').replaceChildren(...(r.machines.length ? [shareDonut(share.slices, uiSaid('set-share-memory', 'Memory by machine'), mem.totalMb - mem.freeMb, mem.totalMb)] : []));
7529
7587
  parts($('server-memory-parts'), [
7530
7588
  [`Running machines (${r.machines.length})`, held],
7531
- ...r.machines.map((x) => [x.shelf ? 'ready-made machine (being made)' : (x.name ?? 'another machine'), x.sizeMb ? `uses ${GB(x.rssMb)} · given ${GB(x.sizeMb)}` : `uses ${GB(x.rssMb)}`, true]),
7532
- ['The system and other programs', Math.max(0, mem.totalMb - mem.freeMb - held)],
7589
+ ...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)]),
7590
+ ['The system and other programs', rest, false, 'rest'],
7533
7591
  ]);
7534
7592
  }
7535
7593
  /* Still measuring: looked at again in a moment, while Settings is open. */
@@ -9014,7 +9072,8 @@
9014
9072
  editing = null;
9015
9073
  delete $('viewer').dataset.editing;
9016
9074
  $('preview-body').replaceChildren();
9017
- $('preview-edit').hidden = true;
9075
+ $('preview-edit').hidden = true; $('preview-download').hidden = false;
9076
+ $('viewer').classList.remove('viewer-sheet');
9018
9077
  offerCopy(null);
9019
9078
  const was = !$('viewer').hidden;
9020
9079
  $('viewer').hidden = true;
@@ -9240,18 +9299,20 @@
9240
9299
  if (!$('viewer').hidden) closePreview();
9241
9300
  return undefined;
9242
9301
  });
9302
+ /* A mail cited by its reference: a sheet over the thread (a panel at the right on a wide screen), the thread seen behind. */
9303
+ $('viewer').classList.toggle('viewer-sheet', Boolean(opts.mailRef));
9243
9304
  $('viewer').hidden = false;
9244
9305
  /* Text in a folder this conversation may write in: editable here. */
9245
9306
  $('preview-edit').hidden = Boolean(from) || !editable(name, size) || !canWrite(tab);
9246
9307
  $('preview-edit').onclick = () => { void editFile(tab, inner, name); };
9247
9308
  /* A file of the shared folders: attached to a card from here (#180). */
9248
- $('preview-attach').hidden = Boolean(from) || DEVICE;
9309
+ $('preview-attach').hidden = (Boolean(from) && !opts.mailRef) || DEVICE;
9249
9310
  /* Full screen: the file takes the whole screen (the real API where granted, else a cover); kept while it is open. */
9250
9311
  const full = (on) => { $('viewer').classList.toggle('viewer-full', on); $('preview-full').setAttribute('aria-pressed', String(on)); const w2 = on ? 'Leave full screen' : 'Full screen'; $('preview-full').title = w2; $('preview-full').setAttribute('aria-label', w2); try { if (on) $('viewer').requestFullscreen?.().catch(() => {}); else if (document.fullscreenElement === $('viewer')) document.exitFullscreen?.(); } catch { /* the cover stands in */ } };
9251
9312
  $('preview-full').onclick = () => full(!$('viewer').classList.contains('viewer-full'));
9252
- $('preview-attach').onclick = () => void attachToCard({ kind: 'file', ref: tab === 'work' ? `/work/${inner}` : `/resources/${tab}/${inner}`, title: name });
9313
+ $('preview-attach').onclick = () => void attachToCard(opts.mailRef ? { kind: 'mail', ref: opts.mailRef.got?.ref || opts.mailRef.ref, title: opts.mailRef.title || opts.mailRef.label || name } : { kind: 'file', ref: tab === 'work' ? `/work/${inner}` : `/resources/${tab}/${inner}`, title: name });
9253
9314
  /* A file read from the machine's disk says so, whatever else is said. */
9254
- const origin = opts.within ? uiSaid('set-mail-of', 'An attachment of {name}', { name: opts.within }) : from ? 'Read from the disk of the machine: this file is not kept here, and goes with the machine.' : '';
9315
+ const origin = opts.within ? uiSaid('set-mail-of', 'An attachment of {name}', { name: opts.within }) : opts.mailRef ? '' : from ? 'Read from the disk of the machine: this file is not kept here, and goes with the machine.' : '';
9255
9316
  const note = (text) => { const all = [text, text === 'Loading...' ? '' : origin].filter(Boolean).join(' '); $('preview-note').textContent = all; $('preview-note').hidden = !all; };
9256
9317
  /* NOTHING TO SHOW (02-11): not an empty frame, but a file, why, and a Download button that is seen. */
9257
9318
  const cannot = (why) => {
@@ -9268,9 +9329,28 @@
9268
9329
  const readIt = async () => {
9269
9330
  if (opts.bytes) return opts.bytes.buffer.slice(opts.bytes.byteOffset, opts.bytes.byteOffset + opts.bytes.byteLength);
9270
9331
  const r = await fetch(address);
9271
- if (!r.ok) throw new Error((await r.json().catch(() => ({}))).error || 'The file could not be read.');
9332
+ if (!r.ok) { const said = await r.json().catch(() => ({})); throw Object.assign(new Error(said.error || 'The file could not be read.'), { kind: said.kind }); }
9333
+ /* A mail read by its reference: where it was found, and its reference as it is now. */
9334
+ if (opts.mailRef) { const h = (k) => { try { return decodeURIComponent(r.headers.get(k) ?? ''); } catch { return ''; } }; opts.mailRef.got = { box: h('x-mail-box'), folder: h('x-mail-folder'), ref: h('x-mail-ref') || opts.mailRef.ref, cut: r.headers.get('x-mail-cut') === '1' }; }
9272
9335
  return r.arrayBuffer();
9273
9336
  };
9337
+ /* A mail that cannot be opened by its reference: one clear line (gone, not theirs, unreachable), never a download. */
9338
+ const mailState = (error) => {
9339
+ const LINES = { gone: ['set-mail-gone', 'This mail is no longer in the mailbox.'], 'not-yours': ['set-mail-not-yours', 'This mailbox is not yours to open.'], 'old-ref': ['set-mail-old-ref', 'Old reference: ask the AI to attach it again.'], unreachable: ['set-mail-unreachable', 'The mailbox cannot be reached just now.'] };
9340
+ const line = LINES[error.kind];
9341
+ const box = el('div', 'preview-cannot mail-state'); box.dataset.kind = error.kind || 'error'; box.setAttribute('role', 'status');
9342
+ const icon = el('div', 'preview-cannot-icon'); icon.setAttribute('aria-hidden', 'true');
9343
+ icon.innerHTML = '<svg class="ic" viewBox="0 0 24 24"><rect x="3" y="5" width="18" height="14" rx="2"/><path d="m3 7 9 6 9-6"/></svg>';
9344
+ box.append(icon, el('b', 'mail-state-line', line ? uiSaid(line[0], line[1]) : error.message));
9345
+ if (error.kind === 'unreachable' || !line) {
9346
+ const again = el('button', 'quiet mail-state-retry', uiSaid('set-mail-retry', 'Try again')); again.type = 'button';
9347
+ again.addEventListener('click', () => { void openMailRef(opts.mailRef.ref, { label: opts.mailRef.label, of: opts.mailRef.of }); });
9348
+ box.append(again);
9349
+ }
9350
+ $('preview-name').textContent = opts.mailRef.label || uiSaid('set-mail-mail', 'Mail');
9351
+ $('preview-body').replaceChildren(box); note('');
9352
+ $('preview-attach').hidden = true; $('preview-download').hidden = true;
9353
+ };
9274
9354
  const kind = name.includes('.') ? name.split('.').pop().toLowerCase() : '';
9275
9355
  if (MEDIA[kind]) {
9276
9356
  const video = MEDIA[kind].startsWith('video/');
@@ -9292,7 +9372,7 @@
9292
9372
  if (size > (TEXTS.includes(kind) && kind !== 'eml' ? TEXT_MAX : PREVIEW_MAX)) { cannot(`${sizeOf(size)} · Too large to be shown here.`); return; }
9293
9373
  note('Loading...');
9294
9374
  let bytes;
9295
- try { bytes = await readIt(); } catch (error) { cannot(error.message); return; }
9375
+ try { bytes = await readIt(); } catch (error) { if (opts.mailRef) { if (!$('viewer').hidden && $('preview-name').textContent === name) mailState(error); return; } cannot(error.message); return; }
9296
9376
  if ($('viewer').hidden || $('preview-name').textContent !== name) return; /* closed meanwhile */
9297
9377
  const body = $('preview-body');
9298
9378
  if (PICTURES[kind]) {
@@ -9359,7 +9439,7 @@
9359
9439
  note(doc.numPages > pages ? `The first ${pages} pages of ${doc.numPages}. Download the file to read the rest.` : `${doc.numPages} page${doc.numPages > 1 ? 's' : ''}.`);
9360
9440
  } catch { cannot('This PDF could not be shown here.'); }
9361
9441
  } else if (kind === 'eml') {
9362
- showMail({ bytes, name, tab, inner, from, note });
9442
+ showMail({ bytes, name, tab, inner, from, note, ref: opts.mailRef });
9363
9443
  } else {
9364
9444
  const text = new TextDecoder('utf-8', { fatal: false }).decode(bytes);
9365
9445
  const source = () => { const pre = document.createElement('pre'); pre.className = 'source'; pre.textContent = text; return pre; };
@@ -9427,7 +9507,7 @@
9427
9507
  runs nothing (sandbox: no scripts, no same-origin; its own rules: nothing fetched), made harmless
9428
9508
  first; remote pictures blocked till asked for -- then the server's page of it (files.mjs mailPage),
9429
9509
  still no script. Nothing is fetched on opening. */
9430
- function showMail({ bytes, name, tab, inner, from, note }) {
9510
+ function showMail({ bytes, name, tab, inner, from, note, ref = null }) {
9431
9511
  const body = $('preview-body');
9432
9512
  const M = window.clavariumMail;
9433
9513
  /* Its source: the first megabyte of a large one (Download for all of it). */
@@ -9438,6 +9518,17 @@
9438
9518
  try { mail = M.parse(new Uint8Array(bytes)); } catch { mail = null; }
9439
9519
  if (!mail || (!mail.headers.length && mail.html === null && mail.text === null)) { body.append(source); note(''); return; }
9440
9520
  const view = el('div', 'mail-view');
9521
+ /* Opened by its reference: its subject heads the window, where it is now is said, and its bytes are
9522
+ what Download gives (read once, never fetched again for it). */
9523
+ if (ref) {
9524
+ $('preview-name').textContent = mail.subject || ref.label || name;
9525
+ ref.title = [mail.subject || ref.label, mail.from[0]?.name || mail.from[0]?.address, mail.date ? mail.date.toLocaleDateString(undefined, { day: 'numeric', month: 'short' }) : ''].filter(Boolean).join(' · ');
9526
+ const file = URL.createObjectURL(new Blob([bytes], { type: 'message/rfc822' })); mdUrls.add(file);
9527
+ $('preview-download').href = file; $('preview-download').setAttribute('download', `${(mail.subject || 'mail').replace(/[\\/:*?"<>|]+/g, ' ').slice(0, 80)}.eml`);
9528
+ const where = [ref.got?.box, ref.got?.folder].filter(Boolean).join(' · ');
9529
+ if (where) view.append(el('div', 'mail-where hint', where));
9530
+ if (ref.got?.cut) view.append(el('div', 'mail-cut hint', uiSaid('set-mail-cut', 'Mail cut: attachments may be incomplete.')));
9531
+ }
9441
9532
  /* Who, to whom, when. */
9442
9533
  const head = el('div', 'mail-head');
9443
9534
  head.append(el('h2', 'mail-subject', mail.subject || uiSaid('set-mail-no-subject', '(no subject)')));
@@ -9452,8 +9543,15 @@
9452
9543
  details.addEventListener('click', () => { all.hidden = !all.hidden; details.setAttribute('aria-expanded', String(!all.hidden)); details.textContent = all.hidden ? uiSaid('set-mail-details', 'Show details') : uiSaid('set-mail-hide-details', 'Hide details'); });
9453
9544
  head.append(details, all);
9454
9545
  view.append(head);
9546
+ /* Reply: never sent from here -- the AI is asked in the chat, and its answer comes back as a request to approve. */
9547
+ if (ref && (ref.of || DEVICE) && (!DEVICE || deviceParts.chat === 'write')) {
9548
+ const acts = el('div', 'mail-acts');
9549
+ const reply = el('button', 'mail-reply', uiSaid('set-mail-reply', 'Reply…')); reply.type = 'button';
9550
+ reply.addEventListener('click', () => { void replyToMail({ ref: ref.got?.ref || ref.ref, of: ref.of }); });
9551
+ acts.append(reply); view.append(acts);
9552
+ }
9455
9553
  /* Its words: the HTML in a frame that runs nothing, or the plain words with their links. */
9456
- const offline = conversations.find((x) => x.name === current)?.offline === true;
9554
+ const offline = conversations.find((x) => x.name === (ref ? ref.of : current))?.offline === true;
9457
9555
  const frameOf = () => { const f = document.createElement('iframe'); f.className = 'mail-frame'; f.setAttribute('sandbox', 'allow-popups allow-popups-to-escape-sandbox'); f.setAttribute('referrerpolicy', 'no-referrer'); f.title = mail.subject || name; return f; };
9458
9556
  if (mail.html !== null) {
9459
9557
  const page = M.pageOf(mail);
@@ -9462,9 +9560,11 @@
9462
9560
  const bar = el('div', 'mail-remote'); bar.setAttribute('role', 'status');
9463
9561
  bar.append(el('span', '', uiSaid('set-mail-remote', 'Remote pictures blocked')));
9464
9562
  /* Shown by the server's page of the same file: one of a folder kept here, a conversation not cut off. */
9465
- if (!from && !offline) {
9563
+ /* A mail opened by its reference: the server's page of the same mail, read again then (asked for). */
9564
+ if ((ref || !from) && !offline) {
9466
9565
  const go = el('button', 'quiet mail-remote-show', uiSaid('set-mail-show-remote', 'Show them')); go.type = 'button';
9467
- go.addEventListener('click', () => { const f = frameOf(); f.src = `${API}/files/mail?${new URLSearchParams({ c: current, r: tab, p: inner })}`; frame.replaceWith(f); frame = f; bar.remove(); });
9566
+ const shown = ref ? `${API}/mail/page?${new URLSearchParams({ ref: ref.got?.ref || ref.ref, ...(ref.of ? { c: ref.of } : {}) })}` : `${API}/files/mail?${new URLSearchParams({ c: current, r: tab, p: inner })}`;
9567
+ go.addEventListener('click', () => { const f = frameOf(); f.src = shown; frame.replaceWith(f); frame = f; bar.remove(); });
9468
9568
  bar.append(' · ', go);
9469
9569
  }
9470
9570
  view.append(bar);
@@ -10630,11 +10730,12 @@
10630
10730
  page ask (Chrome, Edge, Android), the button asks. On an iPhone or an
10631
10731
  iPad no page can ask: the button explains the two taps it takes.
10632
10732
  Already running as an app: there is nothing to offer. */
10633
- const asApp = matchMedia('(display-mode: standalone)').matches || navigator.standalone === true;
10733
+ const asApp = matchMedia('(display-mode: standalone)').matches || matchMedia('(display-mode: fullscreen)').matches || navigator.standalone === true;
10634
10734
  const apple = /iPad|iPhone|iPod/.test(navigator.userAgent) || (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1);
10635
10735
  let installEvent = null;
10636
10736
  let installOffered = false;
10637
- const offerInstall = () => { installOffered = true; $('install').hidden = false; $('install-row').hidden = false; };
10737
+ /* 06-11: offered where it is seen -- a button at the top of the list too, not only in Settings › This device. */
10738
+ const offerInstall = () => { installOffered = true; $('install').hidden = false; $('install-row').hidden = false; if (!DEVICE) $('install-top').hidden = false; };
10638
10739
  /* Chrome reads the manifest again when its address changes, and may then
10639
10740
  offer the install anew: that offer, if it comes soon, is the one used. */
10640
10741
  let freshOffer = null;
@@ -10642,7 +10743,9 @@
10642
10743
  event.preventDefault(); installEvent = event; offerInstall();
10643
10744
  if (freshOffer) { const take = freshOffer; freshOffer = null; take(event); }
10644
10745
  });
10645
- addEventListener('appinstalled', () => { installEvent = null; installOffered = false; $('install').hidden = true; $('install-row').hidden = true; $('install-name-form').hidden = true; });
10746
+ addEventListener('appinstalled', () => { installEvent = null; installOffered = false; $('install').hidden = true; $('install-row').hidden = true; $('install-name-form').hidden = true; $('install-top').hidden = true; });
10747
+ /* The top button is the same gesture: Settings at This device, its Install pressed. */
10748
+ $('install-top').addEventListener('click', () => { $('nav-settings').click(); openChapter('s-screen'); $('install-row').scrollIntoView({ block: 'center' }); $('install').click(); });
10646
10749
  if (apple && !asApp) offerInstall();
10647
10750
  /* FIRST A NAME FOR THIS DEVICE, then the browser's own question. */
10648
10751
  $('install').addEventListener('click', async () => {
@@ -10757,6 +10860,8 @@
10757
10860
  enter();
10758
10861
  /* Where it talks through the app, the chat is what this device opens on. */
10759
10862
  void chatFirst();
10863
+ /* A link to a mail (?mail=mail:...): opened over it, if this device may read that mailbox (else it says so). */
10864
+ if (/^mail:/.test(new URLSearchParams(location.search).get('mail') ?? '')) void openMailRef(new URLSearchParams(location.search).get('mail'), { of: current });
10760
10865
  return;
10761
10866
  } else {
10762
10867
  view(current ? 'room' : 'list');
@@ -10779,6 +10884,8 @@
10779
10884
  await chatFirst();
10780
10885
  goTab('lists', { pick: { list: arrived.get('binder'), ...(/^\d{1,9}$/.test(card) ? { card } : {}) } });
10781
10886
  }
10887
+ /* A link to a mail (?mail=mail:TARGET/MESSAGE-ID): the mail viewer opened on it, over the page. */
10888
+ if (/^mail:/.test(arrived.get('mail') ?? '')) void openMailRef(arrived.get('mail'), { of: current });
10782
10889
  /* Arriving on the address of a place (a reload, a link): it is opened. */
10783
10890
  if (home && new URLSearchParams(location.search).has('open')) await followAddress();
10784
10891
  /* THE FIRST START (Features, features.js): nothing made yet, the welcome not passed -- the home
package/web/index.html CHANGED
@@ -14,7 +14,7 @@
14
14
  <link rel="stylesheet" href="/vendor/diff2html.css">
15
15
  <div id="app" data-place="conversations">
16
16
  <aside id="list" hidden>
17
- <div class="top"><b id="list-title" title="Conversations">Clavarium</b><span class="top-acts"><button type="button" id="list-pin" class="icon-btn" aria-pressed="false" aria-label="Keep the list open" title="Keep the list open: it no longer folds when a conversation is opened"><svg class="ic" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 17v5"/><path d="M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z"/></svg></button><button type="button" id="search-open" class="icon-btn" aria-label="Search conversations" title="Search (/ or Ctrl+K)" aria-expanded="false" aria-controls="search"><svg class="ic" viewBox="0 0 24 24" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg></button><button type="button" id="new" class="icon-btn new-btn" aria-label="New conversation" title="New conversation"><svg class="ic" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 5v14"/><path d="M5 12h14"/></svg></button></span></div>
17
+ <div class="top"><b id="list-title" title="Conversations">Clavarium</b><span class="top-acts"><button type="button" id="list-pin" class="icon-btn" aria-pressed="false" aria-label="Keep the list open" title="Keep the list open: it no longer folds when a conversation is opened"><svg class="ic" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 17v5"/><path d="M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z"/></svg></button><button type="button" id="install-top" class="icon-btn" hidden aria-label="Install as an app" title="Install as an app: its own icon, full screen, no browser bar"><svg class="ic" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 3v12"/><path d="m7 10 5 5 5-5"/><path d="M5 21h14"/></svg></button><button type="button" id="search-open" class="icon-btn" aria-label="Search conversations" title="Search (/ or Ctrl+K)" aria-expanded="false" aria-controls="search"><svg class="ic" viewBox="0 0 24 24" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.5-3.5"/></svg></button><button type="button" id="new" class="icon-btn new-btn" aria-label="New conversation" title="New conversation"><svg class="ic" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 5v14"/><path d="M5 12h14"/></svg></button></span></div>
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). -->
@@ -984,7 +984,7 @@
984
984
  <div class="server-head"><b>Memory</b><span id="server-memory-state" class="server-state"></span><span id="server-memory-figures" class="server-figures"></span></div>
985
985
  <div class="server-meter" id="server-memory-meter" role="meter" aria-label="Memory taken" aria-valuemin="0" aria-valuemax="100"><span class="fill"></span><span class="zone"></span><span class="mark"></span></div>
986
986
  <p id="server-memory-note" class="server-note"></p>
987
- <dl id="server-memory-parts" class="server-parts"></dl>
987
+ <div class="share-row"><div id="server-memory-share"></div><dl id="server-memory-parts" class="server-parts"></dl></div>
988
988
  </div>
989
989
  <div class="server-block">
990
990
  <div class="server-head"><b>Reserve</b><span class="server-figures">always kept free</span></div>
package/web/kit.js CHANGED
@@ -15,6 +15,8 @@
15
15
  * NewAsset ONE BOX to make an asset (05-11, step 3): kinds, the kind's form, one ending;
16
16
  * opened with a context (a conversation it will be attached to). A voice box and
17
17
  * a device are two of its kinds too (step 4).
18
+ * ShareDonut who takes a whole (memory, a disk): a small donut, its slices from shareSlices, the main
19
+ * figure in its middle; ShareKey, a slice's swatch beside its row in the list
18
20
  *
19
21
  * No framework: each piece is a function that returns an element. Words: English here; the page
20
22
  * hands its own (`setWords`, app.js `uiSaid`) for the few the kit says by itself.
@@ -264,7 +266,70 @@
264
266
  return root;
265
267
  }
266
268
 
269
+ /* WHO TAKES IT (06-11): one whole -- a server's memory or a disk -- split by who takes it: each machine
270
+ (the largest first, at most `max`, the rest folded into "Others"), the rest of the system, and what is
271
+ free. `parts` [{ key, label, mb }]. A machine keeps its colour while the page lives (`slots`, shared by
272
+ the memory and the disks: a colour follows the machine, never its rank). Slots 1..6 are Parley's chart
273
+ colours (--parley-s1..s6); 0 is "Others"; 'rest' and 'free' are neutral. */
274
+ function shareSlices(parts, { restMb = 0, freeMb = 0, max = 6, slots = new Map(), words: w = {} } = {}) {
275
+ const most = Math.max(1, Math.min(6, max));
276
+ const sorted = (parts ?? []).filter((x) => Number.isFinite(x?.mb) && x.mb > 0).sort((a, b) => b.mb - a.mb);
277
+ const shown = sorted.length > most ? sorted.slice(0, most) : sorted;
278
+ const folded = sorted.slice(shown.length);
279
+ const used = new Set();
280
+ const held = new Set(slots.values());
281
+ const out = shown.map((x) => {
282
+ let s = slots.get(x.key);
283
+ if (!s || used.has(s)) s = [1, 2, 3, 4, 5, 6].find((n) => !used.has(n) && !held.has(n)) ?? [1, 2, 3, 4, 5, 6].find((n) => !used.has(n));
284
+ slots.set(x.key, s); held.add(s); used.add(s);
285
+ return { key: x.key, label: x.label, mb: x.mb, slot: s };
286
+ });
287
+ if (folded.length) out.push({ key: 'others', label: w.others ?? 'Others', mb: folded.reduce((a, x) => a + x.mb, 0), slot: 0, keys: folded.map((x) => x.key) });
288
+ if (restMb > 0) out.push({ key: 'rest', label: w.rest ?? 'System and others', mb: restMb, slot: 'rest' });
289
+ if (freeMb > 0) out.push({ key: 'free', label: w.free ?? 'Free', mb: freeMb, slot: 'free' });
290
+ const total = out.reduce((a, x) => a + x.mb, 0);
291
+ for (const x of out) x.share = total > 0 ? x.mb / total : 0;
292
+ return out;
293
+ }
294
+ const sharePct = (x) => `${x.share > 0 && x.share < 0.01 ? '<1' : Math.round(x.share * 100)} %`;
295
+ /* The swatch of a slice, beside its row in the list (the list is the legend). */
296
+ function ShareKey(slot) { const k = node('span', 'share-key'); k.dataset.s = String(slot); k.setAttribute('aria-hidden', 'true'); return k; }
297
+ const SVG = 'http://www.w3.org/2000/svg';
298
+ const svgNode = (tag, cls) => { const e = document.createElementNS(SVG, tag); if (cls) e.setAttribute('class', cls); return e; };
299
+ /* A SMALL DONUT of those slices (a "camembert"), its size set by the page's style; in its middle the main
300
+ figure (`center`: { top, main, sub }), or the slice under the pointer or the finger: its name, its size,
301
+ its share. Said whole to a screen reader. */
302
+ function ShareDonut({ slices = [], label = '', fmt = (mb) => `${mb} MB`, center = {} } = {}) {
303
+ const root = node('div', 'share-donut');
304
+ const svg = svgNode('svg'); svg.setAttribute('viewBox', '0 0 100 100'); svg.setAttribute('role', 'img');
305
+ svg.setAttribute('aria-label', `${label}: ${slices.map((x) => `${x.label} ${fmt(x.mb)} ${sharePct(x)}`).join('; ')}`);
306
+ const R = 40; const C = 2 * Math.PI * R; const gap = slices.length > 1 ? 1.2 : 0;
307
+ const mid = node('div', 'share-mid'); mid.setAttribute('aria-hidden', 'true');
308
+ const top = node('span', 'share-mid-top'); const main = node('b', 'share-mid-main'); const sub = node('span', 'share-mid-sub');
309
+ mid.append(top, main, sub);
310
+ const say = (t, m, b) => { top.textContent = t ?? ''; main.textContent = m ?? ''; sub.textContent = b ?? ''; };
311
+ const rest = () => { say(center.top, center.main, center.sub); for (const a of arcs) a.removeAttribute('data-on'); svg.removeAttribute('data-on'); };
312
+ let at = 0; let on = null;
313
+ const arcs = slices.map((x) => {
314
+ const len = x.share * C;
315
+ const a = svgNode('circle', 'share-arc'); a.dataset.s = String(x.slot);
316
+ for (const [k, v] of [['cx', 50], ['cy', 50], ['r', R], ['stroke-dasharray', `${Math.max(0.6, len - gap).toFixed(2)} ${C.toFixed(2)}`], ['stroke-dashoffset', (-at).toFixed(2)], ['transform', 'rotate(-90 50 50)']]) a.setAttribute(k, String(v));
317
+ at += len;
318
+ const show = () => { on = x.key; for (const o of arcs) o.setAttribute('data-on', String(o === a)); svg.setAttribute('data-on', 'true'); say(x.label, fmt(x.mb), sharePct(x)); };
319
+ a.addEventListener('pointerenter', (event) => { if (event?.pointerType !== 'touch') show(); });
320
+ /* A tap shows it; a second tap on the same slice puts the main figure back (a mouse's click only shows). */
321
+ a.addEventListener('click', (event) => { if (event?.pointerType !== 'mouse' && on === x.key && svg.getAttribute('data-on')) { on = null; rest(); } else show(); });
322
+ return a;
323
+ });
324
+ svg.addEventListener('pointerleave', (event) => { if (event?.pointerType !== 'touch') { on = null; rest(); } });
325
+ svg.append(...arcs);
326
+ rest();
327
+ root.append(svg, mid);
328
+ return root;
329
+ }
330
+
267
331
  window.clavariumKit = {
332
+ shareSlices, ShareDonut, ShareKey,
268
333
  STATES, STATE_WORDS, stateOf, hueOf, initialOf,
269
334
  setWords(fn) { if (typeof fn === 'function') words = fn; },
270
335
  StatusDot, Avatar, Chips, Switch, Segmented, InlineConfirm, ConvCard, StepFlow, SecretPicker, NewAsset,
@@ -5,6 +5,10 @@
5
5
  "start_url": "./",
6
6
  "scope": "./",
7
7
  "display": "standalone",
8
+ "display_override": [
9
+ "fullscreen",
10
+ "standalone"
11
+ ],
8
12
  "background_color": "#0f141a",
9
13
  "theme_color": "#0f141a",
10
14
  "icons": [
package/web/style.css CHANGED
@@ -253,6 +253,10 @@ footer button.careful { border-style: dashed; color: var(--ink2); }
253
253
  #viewer .row { align-items: center; gap: 8px; flex-wrap: wrap; }
254
254
  #viewer .sp { flex: 1; }
255
255
  #viewer #preview-name { overflow-wrap: anywhere; }
256
+ /* 06-11: the viewer's top row stays one line on a phone (the close button was pushed under): the name is cut with "…". */
257
+ #viewer-card > .row:first-child { flex-wrap: nowrap; min-width: 0; }
258
+ #viewer-card > .row:first-child > #preview-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
259
+ #viewer-card > .row:first-child > button { flex: none; }
256
260
  #viewer a.button { display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border-radius: 8px; background: transparent; border: 1px solid var(--brass); color: var(--brass-ink); font-weight: 600; text-decoration: none; }
257
261
  #viewer button { min-height: 40px; }
258
262
  #viewer p { margin: 0; }
@@ -1044,6 +1048,35 @@ button.inline:hover { color: var(--brass-ink); }
1044
1048
  .server-meter .mark { position: absolute; top: -1px; bottom: -1px; width: 2px; margin-left: -1px; background: var(--ink); opacity: .7; }
1045
1049
  .server-note { margin: 0; font-size: .75rem; color: var(--ink2); }
1046
1050
  /* The labels never squeezed by a long value: a value in words wraps in a column of its own width. */
1051
+ /* WHO TAKES IT (06-11, kit.js ShareDonut): a small donut by machine beside its list (above it, centred, on a
1052
+ phone); the list's swatches are its legend. Parley's chart colours, by name (--parley-s1..s6; s0 "Others"),
1053
+ the same steps per theme; the rest of the system a neutral ink; what is free pale. */
1054
+ :root { --parley-s1: #3987e5; --parley-s2: #d95926; --parley-s3: #199e70; --parley-s4: #c98500; --parley-s5: #d55181; --parley-s6: #008300; --parley-s0: #5b6878; }
1055
+ :root[data-theme="light"] { --parley-s1: #2a78d6; --parley-s2: #eb6834; --parley-s3: #1baf7a; --parley-s4: #eda100; --parley-s5: #e87ba4; --parley-s6: #008300; --parley-s0: #a4adb8; }
1056
+ .share-row { display: flex; align-items: flex-start; gap: 20px; min-width: 0; }
1057
+ .share-row > .server-parts { flex: 1 1 auto; min-width: 0; }
1058
+ .share-row > div:empty { display: none; }
1059
+ .share-donut { position: relative; flex: none; width: 96px; height: 96px; margin-top: 2px; }
1060
+ .share-donut svg { display: block; width: 100%; height: 100%; overflow: visible; }
1061
+ .share-arc { fill: none; stroke-width: 14; cursor: default; transition: opacity .12s, stroke-width .12s; }
1062
+ .share-donut svg[data-on] .share-arc:not([data-on="true"]) { opacity: .4; }
1063
+ .share-arc[data-on="true"] { stroke-width: 17; }
1064
+ .share-mid { position: absolute; inset: 19%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; line-height: 1.15; pointer-events: none; font-variant-numeric: tabular-nums; }
1065
+ .share-mid > * { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
1066
+ .share-mid-top, .share-mid-sub { font-size: .625rem; color: var(--ink2); }
1067
+ .share-mid-main { font-size: .8125rem; color: var(--ink); }
1068
+ .share-key { display: inline-block; width: 9px; height: 9px; margin-right: 6px; border-radius: 2px; vertical-align: 0; }
1069
+ .share-arc[data-s="1"] { stroke: var(--parley-s1); } .share-arc[data-s="2"] { stroke: var(--parley-s2); } .share-arc[data-s="3"] { stroke: var(--parley-s3); }
1070
+ .share-arc[data-s="4"] { stroke: var(--parley-s4); } .share-arc[data-s="5"] { stroke: var(--parley-s5); } .share-arc[data-s="6"] { stroke: var(--parley-s6); }
1071
+ .share-arc[data-s="0"] { stroke: var(--parley-s0); } .share-arc[data-s="rest"] { stroke: var(--ink2); }
1072
+ .share-arc[data-s="free"] { stroke: color-mix(in srgb, var(--ink2) 16%, transparent); }
1073
+ .share-key[data-s="1"] { background: var(--parley-s1); } .share-key[data-s="2"] { background: var(--parley-s2); } .share-key[data-s="3"] { background: var(--parley-s3); }
1074
+ .share-key[data-s="4"] { background: var(--parley-s4); } .share-key[data-s="5"] { background: var(--parley-s5); } .share-key[data-s="6"] { background: var(--parley-s6); }
1075
+ .share-key[data-s="0"] { background: var(--parley-s0); } .share-key[data-s="rest"] { background: var(--ink2); }
1076
+ @media (max-width: 560px) {
1077
+ .share-row { flex-direction: column; align-items: stretch; gap: 8px; }
1078
+ .share-donut { width: 88px; height: 88px; align-self: center; }
1079
+ }
1047
1080
  .server-parts { display: grid; grid-template-columns: minmax(9rem, 1fr) minmax(4.5rem, max-content); gap: 2px 16px; margin: 2px 0 0; font-size: .8125rem; max-width: 30rem; }
1048
1081
  .server-parts dt { margin: 0; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
1049
1082
  .server-parts dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
@@ -2715,3 +2748,18 @@ button.kit-switch[aria-checked="true"]::after { left: 18px; background: var(--ok
2715
2748
  .kit-conv-sub > small { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink2); }
2716
2749
  .kit-conv-row .kit-conv-main > .kit-chips, .kit-conv-sub > .kit-chips { flex: none; margin: 0; gap: 6px; flex-wrap: nowrap; }
2717
2750
  .kit-conv-row .kit-conv-main .kit-chip:not([data-tone="count"]) { border: 0; padding: 0; background: none; line-height: inherit; font-size: .75rem; }
2751
+
2752
+ /* A MAIL CITED BY ITS REFERENCE (06-11, app.js openMailRef): the same viewer, as a sheet over the thread --
2753
+ from the bottom on a phone, a panel at the right on a wide screen; where it is now, one line; Reply. */
2754
+ #viewer.viewer-sheet { padding: 0; align-items: flex-end; background: rgba(8, 11, 15, 0.45); }
2755
+ #viewer.viewer-sheet #viewer-card { width: 100%; height: calc(100% - 36px); border-radius: 14px 14px 0 0; border-bottom: 0; }
2756
+ @media (min-width: 900px) {
2757
+ #viewer.viewer-sheet { justify-content: flex-end; align-items: stretch; }
2758
+ #viewer.viewer-sheet #viewer-card { width: min(620px, 100%); height: 100%; border-radius: 0; border: 0; border-left: 1px solid var(--line); }
2759
+ }
2760
+ #viewer.viewer-sheet.viewer-full #viewer-card { width: 100%; height: 100%; border-radius: 0; }
2761
+ .mail-where { font-size: .8125rem; color: var(--ink2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
2762
+ .mail-cut { font-size: .8125rem; color: var(--warn); }
2763
+ .mail-acts { display: flex; flex-wrap: wrap; gap: 8px; }
2764
+ #viewer .mail-reply { min-height: 40px; padding: 0 16px; border: 1px solid var(--brass); border-radius: 8px; background: transparent; color: var(--brass-ink); font-weight: 600; }
2765
+ .mail-state .mail-state-line { font-weight: 600; color: var(--ink); text-align: center; }