clavarium 0.2.474-next.1 → 0.2.476-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,12 +1,12 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.474-next.1",
3
+ "version": "0.2.476-next.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "clavarium",
9
- "version": "0.2.474-next.1",
9
+ "version": "0.2.476-next.1",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@xterm/addon-fit": "^0.11.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.474-next.1",
3
+ "version": "0.2.476-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.",
package/server/agenda.mjs CHANGED
@@ -78,6 +78,11 @@ export const NOTES_MAX = 2000;
78
78
  const notesOf = (v) => String(v ?? '').replace(/[\u0000-\u0008\u000b-\u001f\u007f]/g, '').replace(/\n{3,}/g, '\n\n').trim().slice(0, NOTES_MAX);
79
79
  const SHOW = { busy: 'busy', free: 'free', tentative: 'tentative', oof: 'away', away: 'away', workingelsewhere: 'elsewhere', elsewhere: 'elsewhere' };
80
80
 
81
+ /* WHAT TETHER HANDED AS DATA, where its keeper puts it: a person's read answers { ok, text, data: { size, ...the
82
+ connector's own fields } }, so a connector's `data` arrives one level down (data.data). Both are read (16-11: the
83
+ panels read only the top level, and fell back to the text lines: no invitation text, no link, no organizer). */
84
+ export const handed = (got) => (got?.data?.data && typeof got.data.data === 'object' && !Array.isArray(got.data.data) ? { ...got, data: got.data.data } : got);
85
+
81
86
  /* One event Tether handed as data, kept to the fields the page shows. */
82
87
  export function eventOf(e) {
83
88
  const start = timeOf(e?.start);
@@ -122,6 +127,7 @@ export async function readAgenda(tethers, { target, from, to } = {}, { who, zone
122
127
  finally { clearTimeout(timer); }
123
128
  if (got === null) throw refused(504, 'late', `${t.title} did not answer in time. Try again.`);
124
129
  if (!got?.ok) throw refused(502, 'unreachable', `${t.title} could not be read: ${line(got?.text, 300) || 'no answer'}.`);
130
+ got = handed(got);
125
131
  const given = Array.isArray(got.data?.events);
126
132
  const all = (given ? got.data.events.map(eventOf).filter(Boolean) : eventsOfText(got.text))
127
133
  .sort((a, b) => a.start.localeCompare(b.start));
@@ -13,6 +13,7 @@
13
13
  * A Tether that hands its contacts as data (`data.contacts`, `data.contact`: the fields below) gives them all; one that
14
14
  * gives only its text lines (0.1.0-next.69) gives name, emails and phones in one line, no company: `partial`. */
15
15
  import { Refusal } from './conversations.mjs';
16
+ import { handed } from './agenda.mjs';
16
17
  import { READ_MS } from './mailview.mjs';
17
18
 
18
19
  export const CONTACTS_MAX = 200;
@@ -37,7 +38,7 @@ async function asked(tethers, t, verb, args, who, wait) {
37
38
  finally { clearTimeout(timer); }
38
39
  if (got === null) throw refused(504, 'late', `${t.title} did not answer in time. Try again.`);
39
40
  if (!got?.ok) throw refused(/no such contact/.test(String(got?.text)) ? 404 : 502, 'unreachable', `${t.title} could not be read: ${line(got?.text, 300) || 'no answer'}.`);
40
- return got;
41
+ return handed(got);
41
42
  }
42
43
 
43
44
  /* One contact Tether handed as data, kept to what the list shows. */
@@ -0,0 +1,102 @@
1
+ /* THE DESK ("Bureau", 16-11): the home page as a grid of icons, ONE per person, the same on every screen.
2
+ *
3
+ * What is kept is only where each thing sits: no name, no state -- those are read live from the
4
+ * conversations, the rooms and the assets. The grid takes as many columns as the screen allows; a
5
+ * place that does not fit a narrow screen is moved at display time only (web/desk.js), so the place
6
+ * kept here is never rewritten by a small screen.
7
+ *
8
+ * items [{ id, size, c?, r?, t? }] id: 'c:<conversation>' | 'r:<room>' | 'a:<asset key>'
9
+ * [{ id: 'f:<x>', folder, size, c?, r?, t?, items: [id] }] a folder of the desk (one level;
10
+ * not the list's groups: the list never changes)
11
+ * size: 's' (an icon) | 'm' (wide) | 'l' (large); c, r: its column and row, from 1 (none: the
12
+ * first free cell); t: when it was put there (the last put wins a cell)
13
+ * gone [id] conversations and rooms taken off the desk: a new one comes by itself, these do not
14
+ *
15
+ * Kept per person: the name the gate gives (an operator's address, or 'local' on one machine). */
16
+ import { Refusal } from './conversations.mjs';
17
+ import { JsonFile } from './store.mjs';
18
+
19
+ export const DESK_LIMITS = { bytes: 64 * 1024, items: 300, inFolder: 200, ids: 1000, gone: 1000, cols: 48, rows: 400, id: 200, folderName: 60 };
20
+ const SIZES = new Set(['s', 'm', 'l']);
21
+ /* No control character, no line: an id is a key, never shown as markup. */
22
+ const CONTROL = /[\u0000-\u001f\u007f]/;
23
+ const THING = /^[cra]:\S/;
24
+ const FOLDER = /^f:[A-Za-z0-9_-]{1,40}$/;
25
+
26
+ const intIn = (v, lo, hi) => Number.isInteger(v) && v >= lo && v <= hi;
27
+ function idOk(id) { return typeof id === 'string' && id.length <= DESK_LIMITS.id && THING.test(id) && !CONTROL.test(id); }
28
+
29
+ /* The desk as sent, made safe or refused (Refusal 400): only the known fields are kept. Pure. */
30
+ export function cleanDesk(body) {
31
+ if (!body || typeof body !== 'object' || !Array.isArray(body.items)) throw new Refusal(400, 'Send { items: [...] }.');
32
+ const { items } = body;
33
+ if (items.length > DESK_LIMITS.items) throw new Refusal(400, `At most ${DESK_LIMITS.items} things on the desk.`);
34
+ const seen = new Set();
35
+ const once = (id) => { if (seen.has(id)) throw new Refusal(400, `Twice on the desk: ${id}`); seen.add(id); if (seen.size > DESK_LIMITS.ids) throw new Refusal(400, `At most ${DESK_LIMITS.ids} things in all.`); };
36
+ const out = [];
37
+ for (const x of items) {
38
+ if (!x || typeof x !== 'object') throw new Refusal(400, 'Each thing is an object.');
39
+ const size = x.size ?? 's';
40
+ if (!SIZES.has(size)) throw new Refusal(400, 'A size is s, m or l.');
41
+ const one = { id: x.id, size };
42
+ if (x.folder !== undefined) {
43
+ if (typeof x.id !== 'string' || !FOLDER.test(x.id)) throw new Refusal(400, 'A folder\'s id is f: and up to 40 letters.');
44
+ const name = typeof x.folder === 'string' ? x.folder.trim() : '';
45
+ if (!name || name.length > DESK_LIMITS.folderName || CONTROL.test(name)) throw new Refusal(400, `A folder's name: one line, 1 to ${DESK_LIMITS.folderName} characters.`);
46
+ if (!Array.isArray(x.items) || x.items.length > DESK_LIMITS.inFolder) throw new Refusal(400, `A folder holds at most ${DESK_LIMITS.inFolder} things.`);
47
+ once(x.id);
48
+ for (const k of x.items) { if (!idOk(k)) throw new Refusal(400, 'Not a thing of the desk.'); once(k); }
49
+ one.folder = name; one.items = [...x.items];
50
+ } else {
51
+ if (!idOk(x.id)) throw new Refusal(400, 'Not a thing of the desk.');
52
+ once(x.id);
53
+ }
54
+ if (x.c !== undefined || x.r !== undefined) {
55
+ if (!intIn(x.c, 1, DESK_LIMITS.cols) || !intIn(x.r, 1, DESK_LIMITS.rows)) throw new Refusal(400, `A place is a column 1-${DESK_LIMITS.cols} and a row 1-${DESK_LIMITS.rows}.`);
56
+ one.c = x.c; one.r = x.r;
57
+ if (x.t !== undefined) { if (!Number.isFinite(x.t) || x.t < 0) throw new Refusal(400, 'Not a time.'); one.t = x.t; }
58
+ }
59
+ out.push(one);
60
+ }
61
+ const gone = body.gone ?? [];
62
+ if (!Array.isArray(gone) || gone.length > DESK_LIMITS.gone || gone.some((g) => !idOk(g) || !/^[cr]:/.test(g))) throw new Refusal(400, 'gone: conversations and rooms only.');
63
+ return { items: out, gone: [...new Set(gone)].filter((g) => !seen.has(g)) };
64
+ }
65
+
66
+ export class Desks {
67
+ #file; #now;
68
+ constructor({ file = new JsonFile(undefined, {}), now = () => Date.now() } = {}) { this.#file = file; this.#now = now; }
69
+ #all() { const v = this.#file.get(); return v && typeof v === 'object' && !Array.isArray(v) ? v : {}; }
70
+ /* `who`: the gate's name for the person. None kept yet: saved false (the page fills it from the home cards). */
71
+ get(who) {
72
+ const d = Object.hasOwn(this.#all(), String(who)) ? this.#all()[String(who)] : null;
73
+ return d ? { saved: true, items: d.items ?? [], gone: d.gone ?? [], at: d.at ?? null } : { saved: false, items: [], gone: [], at: null };
74
+ }
75
+ put(who, body) {
76
+ if (typeof who !== 'string' || !who) throw new Refusal(403, 'Nobody to keep it for.');
77
+ const desk = cleanDesk(body);
78
+ const at = new Date(this.#now()).toISOString();
79
+ this.#file.set({ ...this.#all(), [who]: { ...desk, at } });
80
+ return { saved: true, ...desk, at };
81
+ }
82
+ }
83
+
84
+ /* GET /api/desktop, PUT /api/desktop { items, gone }: `who` is the gate's answer for this request. */
85
+ export async function handleDesktop(request, response, desks, who, originOk, headers = {}) {
86
+ const { pathname } = new URL(request.url ?? '/', 'http://local');
87
+ if (pathname !== '/api/desktop') return false;
88
+ const send = (status, body) => { response.writeHead(status, { ...headers, 'content-type': 'application/json; charset=utf-8', 'cache-control': 'no-store' }).end(JSON.stringify(body)); return true; };
89
+ try {
90
+ if (request.method === 'GET') return send(200, desks.get(who));
91
+ if (request.method !== 'PUT') return send(405, { error: 'GET or PUT.' });
92
+ if (!originOk(request.headers) || !String(request.headers['content-type'] ?? '').startsWith('application/json')) return send(403, { error: 'This request does not come from this site.' });
93
+ let text = '';
94
+ for await (const piece of request) { text += piece; if (text.length > DESK_LIMITS.bytes) return send(413, { error: 'Too long.' }); }
95
+ let body;
96
+ try { body = JSON.parse(text); } catch { return send(400, { error: 'The request is not JSON.' }); }
97
+ return send(200, desks.put(who, body));
98
+ } catch (error) {
99
+ if (error instanceof Refusal) return send(error.status, { error: error.message });
100
+ return send(500, { error: 'Something failed on the server.' });
101
+ }
102
+ }
@@ -21,6 +21,7 @@
21
21
  * that gives only its text lines (0.1.0-next.69) gives who, subject, date, and no unread or attachment mark: the
22
22
  * answer says `partial`. */
23
23
  import { Refusal } from './conversations.mjs';
24
+ import { handed } from './agenda.mjs';
24
25
 
25
26
  export const MESSAGES_MAX = 25;
26
27
  export const READ_MS = 30_000;
@@ -129,7 +130,7 @@ async function asked(tethers, t, verb, args, who, wait) {
129
130
  finally { clearTimeout(timer); }
130
131
  if (got === null) throw refused(504, 'late', `${t.title} did not answer in time. Try again.`);
131
132
  if (!got?.ok) throw refused(got?.code === 'gone' ? 404 : 502, got?.code === 'gone' ? 'gone' : 'unreachable', `${t.title} could not be read: ${line(got?.text, 300) || 'no answer'}.`);
132
- return got;
133
+ return handed(got);
133
134
  }
134
135
 
135
136
  /* THE LATEST MESSAGES OF A MAILBOX TARGET, or those matching `text`, read now. `who`: { id, name }, said in Tether's
package/server/main.mjs CHANGED
@@ -92,6 +92,7 @@ import { Boxes, handleBoxes, voiceboxConnector, syncTargets, PAIR_PATH as BOX_PA
92
92
  import { Pocket } from './pocket.mjs';
93
93
  import { Speech } from './speech.mjs';
94
94
  import { Features, handleFeatures, cached } from './features.mjs';
95
+ import { Desks, handleDesktop } from './desktop.mjs';
95
96
  import { ApiKeys, handleExternal, handleApiKeys, statusOf } from './apikeys.mjs';
96
97
  import { RelayJoin, handleRelayJoin, RELAY_JOIN_PATH } from './relayjoin.mjs';
97
98
  import { WebSocketServer } from 'ws';
@@ -116,6 +117,8 @@ export const FILES = {
116
117
  '/links.js': ['web/links.js', 'text/javascript; charset=utf-8'],
117
118
  '/features.js': ['web/features.js', 'text/javascript; charset=utf-8'],
118
119
  '/kit.js': ['web/kit.js', 'text/javascript; charset=utf-8'],
120
+ /* The desk, the home page (desktop.mjs keeps its places). */
121
+ '/desk.js': ['web/desk.js', 'text/javascript; charset=utf-8'],
119
122
  /* A mail file (.eml) read as a mail program shows it (the file viewer, app.js showMail). */
120
123
  '/mail-view.js': ['web/mail-view.js', 'text/javascript; charset=utf-8'],
121
124
  '/gitgraph.js': ['web/gitgraph.js', 'text/javascript; charset=utf-8'],
@@ -194,7 +197,7 @@ const withoutTmux = (env) => Object.fromEntries(Object.entries(env).filter(([key
194
197
 
195
198
  const REFUSED = 'This Clavarium belongs to someone else: your account is not one of its operators.\n';
196
199
 
197
- function serve(port, conversations, resources, { gate = () => 'local', originOk, shortcuts, voice, sharing, door, secrets, network, signin, mailboxes, gitReview, platform, answerer, wakeups, alerts, talk, gitAccess, gitKeeper, shelf, health, setup, guide, repair, capacity, updates, instance = new Instance(), certificate, team, reacting, machinesMove, serverLogs, history, events, bundles, wifi, binders, meshcentral, tethers, accounts, groups, boxes, catalogue, rooms, machineList, features, apikeys, relayJoin } = {}) {
200
+ function serve(port, conversations, resources, { gate = () => 'local', originOk, shortcuts, voice, sharing, door, secrets, network, signin, mailboxes, gitReview, platform, answerer, wakeups, alerts, talk, gitAccess, gitKeeper, shelf, health, setup, guide, repair, capacity, updates, instance = new Instance(), certificate, team, reacting, machinesMove, serverLogs, history, events, bundles, wifi, binders, meshcentral, tethers, accounts, groups, boxes, catalogue, rooms, machineList, features, apikeys, relayJoin, desks } = {}) {
198
201
  /* Its manifest carries the name of this Clavarium, or the one a device chose (instance.mjs). */
199
202
  const sendManifest = (response, url) => response.writeHead(200, { ...HEADERS, 'content-type': 'application/manifest+json' }).end(instance.manifest(new URL(url ?? '/', 'http://local').searchParams.get('name') ?? undefined));
200
203
  const sendFile = async (response, file) => {
@@ -259,10 +262,13 @@ function serve(port, conversations, resources, { gate = () => 'local', originOk,
259
262
  return;
260
263
  }
261
264
  /* Before anything else, static files included: see gate.mjs. */
262
- if (gate(request.headers) === undefined) {
265
+ const who = gate(request.headers);
266
+ if (who === undefined) {
263
267
  response.writeHead(403, { ...HEADERS, 'content-type': 'text/plain; charset=utf-8' }).end(REFUSED);
264
268
  return;
265
269
  }
270
+ /* The desk (desktop.mjs): one per person, the gate's name for them. */
271
+ if (desks && pathname === '/api/desktop' && await handleDesktop(request, response, desks, who, originOk, HEADERS)) return;
266
272
  /* What this Clavarium can do and its next step (features.mjs); an export of the setup is its backup's day. */
267
273
  if (features && pathname.startsWith('/api/features') && await handleFeatures(request, response, features, originOk, HEADERS)) return;
268
274
  if (features && ((request.method === 'POST' && pathname === '/api/setup/export') || (request.method === 'GET' && pathname === '/api/setup/bundle' && !request.url.includes('stats=1')))) response.once('finish', () => { if (response.statusCode === 200) features.exported(); });
@@ -910,7 +916,7 @@ export async function startHome({ port, host, dataDir, mntDir = dataDir, gitRese
910
916
  answerer: answererConfig(env)?.models.length ?? 0, updates: updates.about(), team: team ? team.list().length : null,
911
917
  screen: await quick(screenNow(), 1500, null), catalogue: await quick(catalogue.providers().catch(() => []), 1500, []),
912
918
  }) });
913
- const { server, listening } = serve(port, all, folders, { gate, originOk, shortcuts, voice, sharing, door, secrets, network, signin, mailboxes, gitReview, platform, answerer, wakeups, alerts, talk, gitAccess, gitKeeper, shelf, health, setup, guide, capacity, updates, instance, certificate, team, reacting, machinesMove, serverLogs, history, events, wifi, binders, meshcentral, tethers, accounts, groups, boxes, catalogue, rooms, machineList, features, apikeys, relayJoin: host.length ? new RelayJoin({ host: asHost }) : null, bundles: new Bundles({ dir: `${dataDir}/imports`, folder: (name) => folders.folder(name) }), repair: (name) => repairTerminal(name) });
919
+ const { server, listening } = serve(port, all, folders, { gate, originOk, shortcuts, voice, sharing, door, secrets, network, signin, mailboxes, gitReview, platform, answerer, wakeups, alerts, talk, gitAccess, gitKeeper, shelf, health, setup, guide, capacity, updates, instance, certificate, team, reacting, machinesMove, serverLogs, history, events, wifi, binders, meshcentral, tethers, accounts, groups, boxes, catalogue, rooms, machineList, features, desks: new Desks({ file: new JsonFile(`${dataDir}/desktops.json`, {}) }), apikeys, relayJoin: host.length ? new RelayJoin({ host: asHost }) : null, bundles: new Bundles({ dir: `${dataDir}/imports`, folder: (name) => folders.folder(name) }), repair: (name) => repairTerminal(name) });
914
920
  server.on('close', () => { closing = true; stopBinders(); stopTethers(); clearInterval(historyTimer); clearInterval(secretsTimer); history.save(); stopVmWatch(); stopShelf(); stopHealth(); stopNetworkWatch(); stopUpdates(); stopWatch(); clearInterval(mailTimer); clearInterval(restartTimer); clearInterval(expiryTimer); clearInterval(answerTimer); clearInterval(wakeTimer); clearInterval(docketTimer); clearInterval(stopSigninHelp); dockets.stop(); clearInterval(gitTimer); talk.stop(); });
915
921
  let closing = false;
916
922
  boxes.attach(server, WebSocketServer);
@@ -325,6 +325,17 @@ export const SETTINGS_WORDS_FR = {
325
325
  'set-ct-failed-one': 'Contact illisible pour le moment.', 'set-ct-none': 'Aucun contact', 'set-ct-more': 'Certains contacts masqués : cherchez',
326
326
  'set-ct-partial': 'Sans société dans la liste, pour l\'instant', 'set-ct-email': 'Courriel', 'set-ct-phone': 'Téléphone', 'set-ct-company': 'Société',
327
327
  'set-ct-f-title': 'Fonction', 'set-ct-f-birthday': 'Anniversaire', 'set-ct-f-address': 'Adresse', 'set-ct-notes': 'Notes',
328
+ /* The desk, the home page (desk.js, 16-11). */
329
+ 'desk-add': '+ Ajouter', 'desk-edit': 'Modifier', 'desk-done': 'Terminé', 'desk-tidy': 'Tasser', 'desk-tidy-what': 'Tout ranger en haut à gauche',
330
+ 'desk-empty': 'Bureau vide : + Ajouter', 'desk-not-saved': 'Bureau non enregistré', 'desk-options': 'Options', 'desk-size': 'Taille',
331
+ 'desk-size-s': 'Icône', 'desk-size-m': 'Large', 'desk-size-l': 'Grande',
332
+ 'desk-mv-left': 'Déplacer à gauche', 'desk-mv-right': 'Déplacer à droite', 'desk-mv-up': 'Déplacer en haut', 'desk-mv-down': 'Déplacer en bas',
333
+ 'desk-remove': 'Retirer du bureau', 'desk-folder-open': 'Ouvrir', 'desk-folder-undo': 'Défaire le dossier', 'desk-folder-out': 'Sortir du dossier',
334
+ 'desk-folder-new': 'Nouveau dossier', 'desk-folder-name': 'Nom du dossier', 'desk-folder-of': 'Dossier {name}', 'desk-folder-n': '{n} éléments',
335
+ 'desk-folder-empty': 'Dossier vide', 'desk-close': 'Fermer', 'desk-add-title': 'Ajouter au bureau', 'desk-add-convs': 'Conversations',
336
+ 'desk-add-rooms': 'Salons', 'desk-add-assets': 'Assets', 'desk-add-more': 'Dossiers', 'desk-add-all': 'Tout est déjà sur le bureau',
337
+ 'desk-added': 'Ajouté au bureau', 'desk-editing': 'Mode modification', 'desk-drop-folder': 'Lâcher : faire un dossier',
338
+ 'desk-drop-into': 'Lâcher : mettre dans le dossier', 'desk-create': 'Créer', 'desk-new-conv': 'Nouvelle conversation', 'desk-new-room': 'Nouveau salon',
328
339
  'set-ml-short': 'Manque de mémoire', 'set-ml-short-what': 'La plus grosse machine', 'set-ml-force': 'Forcer l’arrêt', 'set-ml-sleep': 'Mettre en veille', 'set-ml-alert': 'Alerter seulement',
329
340
  };
330
341
  export const settingsWords = (lang) => (String(lang ?? '').toLowerCase().split('-')[0] === 'fr' ? { ...SETTINGS_WORDS_FR } : {});
package/web/app.js CHANGED
@@ -2002,6 +2002,8 @@
2002
2002
  paint();
2003
2003
  paintChips();
2004
2004
  paintHealth();
2005
+ /* The desk shown: its cards say the states of now (its places are not read again). */
2006
+ if (!DEVICE && place === 'deck') { try { paintDeskStates(); } catch { /* not set up yet */ } }
2005
2007
  if (!DEVICE) void paintGauge();
2006
2008
  /* The chats of the others, kept for a switch at once (15-11): what moved, fetched in the background. */
2007
2009
  if (!DEVICE) void keepChats();
@@ -7124,20 +7126,87 @@
7124
7126
  $('features-title').textContent = uiSaid('features-title', 'Features');
7125
7127
  $('features-about').textContent = data ? uiSaid('features-lit-of', '{n} of {t} rooms lit', { n: data.counts.ready, t: data.counts.total }) : '';
7126
7128
  }
7129
+ /* THE DESK (desk.js, 16-11): the home page, a grid of icons kept per person by the server, the same on
7130
+ every screen. Each thing is drawn as everywhere else (kit ConvCard, AssetCard); its folders are its own
7131
+ (the list's groups never change). The first time, it holds the home cards as they were. */
7132
+ let desk = null;
7133
+ let deskAssets = new Map();
7134
+ /* The assets a desk may hold (its "+ Add"): folders, repositories, mailboxes, connected accounts, binders. */
7135
+ async function readDeskAssets() {
7136
+ const [all, lists, tether] = await Promise.all([getJson('/resources', []), binderCall('lists', {}), getJson('/tether', {})]);
7137
+ const got = new Map();
7138
+ for (const r of Array.isArray(all) ? all : []) { const kind = kindOf(r); got.set(`a:${kind}:${r.name}`, { key: `${kind}:${r.name}`, kind, name: r.name }); }
7139
+ for (const t of Array.isArray(tether?.targets) ? tether.targets : []) got.set(`a:connexion:${t.id}`, { key: `connexion:${t.id}`, kind: tetherCat(t.kind), name: t.title ?? t.id });
7140
+ for (const l of lists?.ok && Array.isArray(lists.data) ? lists.data.filter((x) => !x.archived) : []) got.set(`a:list:${l.id}`, { key: `list:${l.id}`, kind: 'list', name: l.title, sub: cardsSub(l.count) });
7141
+ deskAssets = got;
7142
+ }
7143
+ const deskConv = (id) => (id.startsWith('c:') ? conversations.find((c) => c.name === id.slice(2)) : undefined);
7144
+ const deskRoom = (id) => (id.startsWith('r:') ? roomsNow().find((r) => r.id === id.slice(2)) : undefined);
7145
+ const roomSign = () => { const sign = document.createElement('span'); sign.className = 'room-sign'; return sign; };
7146
+ function deskThing(id) {
7147
+ const c = deskConv(id); if (c) return { name: shownName(c) };
7148
+ const r = deskRoom(id); if (r) return { name: r.name };
7149
+ const a = deskAssets.get(id); return a ? { name: a.name } : null;
7150
+ }
7151
+ function deskMini(id) {
7152
+ const c = deskConv(id); if (c) return KIT.Avatar({ name: shownName(c) });
7153
+ const r = deskRoom(id); if (r) return KIT.Avatar({ name: r.name, glyph: roomSign() });
7154
+ return KIT.AssetIcon({ kind: deskAssets.get(id)?.kind ?? 'folder' });
7155
+ }
7156
+ function deskTile(id) {
7157
+ const c = deskConv(id); if (c) { const card = KIT.ConvCard(convModel(c, true), { size: 'card', tag: 'div', cls: 'desk-card' }); card.dataset.name = c.name; return card; }
7158
+ const r = deskRoom(id); if (r) { const card = KIT.ConvCard(roomModel(r), { size: 'card', tag: 'div', cls: 'desk-card desk-card-room' }); card.dataset.room = r.id; return card; }
7159
+ const a = deskAssets.get(id);
7160
+ return KIT.AssetCard({ key: a?.key, kind: a?.kind, name: a?.name ?? '', sub: a?.sub || uiSaid(`set-acc-kind-${a?.kind}`, ASSET_WORD[a?.kind] ?? '') }, { size: 'row', tag: 'div', cls: 'desk-card' });
7161
+ }
7162
+ function deskOpen(id) {
7163
+ const c = deskConv(id); if (c) { leavePlace(); select(c.name, { step: true }); return; }
7164
+ const r = deskRoom(id); if (r) { void openSalon(r.id, true, { step: true }); return; }
7165
+ const a = deskAssets.get(id); if (a) void openAssetsPlace(a.key);
7166
+ }
7167
+ function mountDesk() {
7168
+ if (desk || !window.clavariumDesk) return desk;
7169
+ desk = window.clavariumDesk.Desk($('deck-cards'), {
7170
+ load: async () => { const r = await fetch(`${API}/desktop`); if (!r.ok) throw new Error(`desk: ${r.status}`); return r.json(); },
7171
+ save: async (body) => { const r = await fetch(`${API}/desktop`, { method: 'PUT', headers: { 'content-type': 'application/json' }, body: JSON.stringify(body) }); if (!r.ok) throw new Error(`desk: ${r.status}`); },
7172
+ has: (id) => deskThing(id) !== null,
7173
+ name: (id) => deskThing(id)?.name ?? '',
7174
+ tile: (id) => deskTile(id),
7175
+ mini: (id) => deskMini(id),
7176
+ waits: (id) => { const c = deskConv(id); if (c) return needsYou(c); const r = deskRoom(id); return Boolean(r && r.unread > 0); },
7177
+ open: (id) => deskOpen(id),
7178
+ /* Today's home cards, in their order: the rooms, then the conversations. */
7179
+ wanted: () => [...roomsNow().map((r) => ({ id: `r:${r.id}`, size: 'm' })), ...conversations.map((c) => ({ id: `c:${c.name}`, size: 'm' }))],
7180
+ addable: () => [
7181
+ { title: uiSaid('desk-add-convs', 'Conversations'), items: conversations.map((c) => ({ id: `c:${c.name}`, name: shownName(c), sign: deskMini(`c:${c.name}`) })) },
7182
+ { title: uiSaid('desk-add-rooms', 'Rooms'), items: roomsNow().map((r) => ({ id: `r:${r.id}`, name: r.name, sign: deskMini(`r:${r.id}`) })) },
7183
+ { title: uiSaid('desk-add-assets', 'Assets'), items: [...deskAssets].map(([id, a]) => ({ id, name: a.name, what: uiSaid(`set-acc-kind-${a.kind}`, ASSET_WORD[a.kind] ?? a.kind), sign: deskMini(id) })) },
7184
+ ],
7185
+ create: [{ label: uiSaid('desk-new-conv', 'New conversation'), run: () => { void openNew(); } }, { label: uiSaid('desk-new-room', 'New room'), run: () => { void openSalonNew(); } }],
7186
+ word: (key, en, vars) => uiSaid(key, en, vars),
7187
+ });
7188
+ return desk;
7189
+ }
7190
+ /* Drawn again only when what its cards say changed, and never while it is being arranged. */
7191
+ let deskSaid = '';
7192
+ function paintDeskStates() {
7193
+ if (!desk || desk.editing) return;
7194
+ const said = JSON.stringify([conversations.map((c) => convModel(c, true)), roomsNow().map((r) => roomModel(r))]);
7195
+ if (said !== deskSaid) { deskSaid = said; desk.render(); }
7196
+ }
7127
7197
  async function paintDeck() {
7128
7198
  $('deck-title').textContent = appName;
7129
- const list = [...conversations];
7130
- const add = el('button', 'conv-card conv-card-new'); add.type = 'button';
7131
- add.append(el('span', 'conv-card-plus', '+'), el('small', '', 'New conversation'));
7132
- add.addEventListener('click', () => { void openNew(); });
7133
- const addRoom = el('button', 'conv-card conv-card-new conv-card-new-room'); addRoom.type = 'button';
7134
- addRoom.append(el('span', 'conv-card-plus', '+'), el('small', '', 'New room'));
7135
- addRoom.addEventListener('click', () => { void openSalonNew(); });
7136
- const paint = () => $('deck-cards').replaceChildren(...rooms.map((r) => roomCard(r)), ...list.map((c) => convCard(c, (x) => { leavePlace(); select(x.name); })), add, ...(list.length ? [addRoom] : []));
7137
- paint();
7138
- $('deck-cards').hidden = list.length === 0; $('deck-empty').hidden = list.length > 0;
7139
- void paintDeckFeatures(list.length);
7140
- await Promise.all([loadRooms(), loadBoxes()]); paint();
7199
+ const count = conversations.length;
7200
+ $('deck-cards').hidden = count === 0; $('deck-empty').hidden = count > 0;
7201
+ void paintDeckFeatures(count);
7202
+ if (!count) return;
7203
+ const d = mountDesk(); if (!d) return;
7204
+ /* Drawn at once with what is known; the rooms, the boxes and the assets read behind, then again. */
7205
+ await Promise.all([loadRooms(), loadBoxes()]);
7206
+ if (place !== 'deck') return;
7207
+ try { await d.refresh(); } catch { /* not read: drawn at the next opening */ }
7208
+ await readDeskAssets().catch(() => {});
7209
+ if (place === 'deck') d.render();
7141
7210
  }
7142
7211
  /* FEATURES (features.js): the welcome in place of "No conversation yet" until it is passed; then the
7143
7212
  next step over the cards. */
@@ -7337,6 +7406,8 @@
7337
7406
  $('settings').hidden = which !== 'settings';
7338
7407
  $('assets').hidden = which !== 'assets';
7339
7408
  $('deck').hidden = which !== 'deck';
7409
+ /* The desk left: its menu, an open folder, its edit mode go with it. */
7410
+ if (which !== 'deck') { try { desk?.leave(); } catch { /* not set up yet */ } }
7340
7411
  $('salon').hidden = which !== 'salon'; $('salon-new').hidden = which !== 'salon-new';
7341
7412
  /* The places of the whole have a part of the page of their own, over the conversation (03-11). */
7342
7413
  $('places').hidden = !['access', 'settings', 'assets', 'deck', 'new', 'salon', 'salon-new'].includes(which);
@@ -7351,7 +7422,8 @@
7351
7422
  function placeAddress() {
7352
7423
  const q = new URLSearchParams();
7353
7424
  if (current) q.set('c', current);
7354
- if (place !== 'conversations') q.set('open', place);
7425
+ /* The desk with no conversation open is the bare address: the page of arrival. */
7426
+ if (place !== 'conversations' && !(place === 'deck' && !current)) q.set('open', place);
7355
7427
  if (place === 'salon' && roomOpenNow()) q.set('room', roomOpenNow());
7356
7428
  if (place === 'assets' && assetOpen) q.set('a', assetOpen);
7357
7429
  if (place === 'assets' && assetOpen && assetOpen === listOpen && assetsView?.place.page === 'card') q.set('card', assetsView.place.card);
@@ -13196,6 +13268,10 @@
13196
13268
  const d = await features?.refresh().catch(() => null);
13197
13269
  if (d?.welcome && place === 'conversations' && !conversations.length) openDeck(false);
13198
13270
  }
13271
+ /* THE DESK, the page of arrival (16-11): the bare address opens on it where the list sits beside it; on a
13272
+ phone the list stays the first screen, the desk one tap away (its title). An address that names a
13273
+ conversation or a place opens on that instead. */
13274
+ else if (home && !DEVICE && !current && !location.search && place === 'conversations' && !narrow()) openDeck(false);
13199
13275
  }
13200
13276
  void start();
13201
13277
  })();
package/web/desk.js ADDED
@@ -0,0 +1,497 @@
1
+ /* THE DESK ("Bureau", 16-11, mockup bureau-2): the home page as a grid of icons that snap to cells.
2
+ *
3
+ * One desk per person, kept by the server (GET/PUT /api/desktop, server/desktop.mjs), the same on every
4
+ * screen. The grid takes as many columns as the screen allows; a thing whose cell does not fit is shown
5
+ * in the first free cell, at display time only: its place is kept, and it is back when the screen widens.
6
+ *
7
+ * - free placement in any cell; « Tidy » packs them to the top left, in their reading order
8
+ * - edit mode: a long press, or « Edit »; free cells dotted; dropped on a taken cell, the one there
9
+ * goes to the first free cell; dropped on the middle of another, a folder (or into that folder)
10
+ * - « ⋯ » on each: its size (icon, wide, large), moves by one cell, out of its folder, off the desk;
11
+ * the same from the keyboard (arrows move, Enter opens the menu): never only by dragging
12
+ * - folders of the desk are the desk's own: the list's groups never change
13
+ *
14
+ * It draws no card of its own: each thing is drawn by app.js with the kit (ConvCard, AssetCard), as
15
+ * everywhere else. What it shows of a person's data is text nodes only.
16
+ * Words: English here, others through the page's words (app.js uiSaid, server/settingswords.mjs). */
17
+ (() => {
18
+ const W = (it, n) => Math.min(it.size === 'm' || it.size === 'l' ? 2 : 1, Math.max(1, n));
19
+ const H = (it) => (it.size === 'l' ? 2 : 1);
20
+ const overlap = (a, b) => a.c < b.c + b.w && b.c < a.c + a.w && a.r < b.r + b.h && b.r < a.r + a.h;
21
+
22
+ /* WHERE EACH ONE GOES on `n` columns: its own cell when it was put there and still fits (the last put
23
+ wins a cell); else the first free one, in the desk's order. Pure: the items are not changed. */
24
+ function layout(items, n) {
25
+ const cols = Math.max(1, n | 0);
26
+ const occ = new Set(); const k = (c, r) => `${c},${r}`;
27
+ const fits = (c, r, w, h) => { if (c < 1 || r < 1 || c + w - 1 > cols) return false; for (let i = 0; i < w; i++) for (let j = 0; j < h; j++) if (occ.has(k(c + i, r + j))) return false; return true; };
28
+ const placed = items.filter((it) => it.c && it.r).sort((a, b) => (b.t || 0) - (a.t || 0) || a.r - b.r || a.c - b.c);
29
+ const pos = new Map(); let rows = 0;
30
+ for (const it of [...placed, ...items.filter((x) => !(x.c && x.r))]) {
31
+ const w = W(it, cols); const h = H(it);
32
+ let c = it.c ? Math.min(it.c, cols - w + 1) : 1; let r = it.r || 1;
33
+ if (!(it.c && it.r && c === it.c && fits(c, r, w, h))) {
34
+ search: for (r = 1; ; r++) for (c = 1; c <= cols - w + 1; c++) if (fits(c, r, w, h)) break search;
35
+ }
36
+ for (let i = 0; i < w; i++) for (let j = 0; j < h; j++) occ.add(k(c + i, r + j));
37
+ pos.set(it.id, { c, r, w, h }); rows = Math.max(rows, r + h - 1);
38
+ }
39
+ return { pos, rows, occ, cols };
40
+ }
41
+
42
+ /* PUT ONE ON A CELL: those it covers go to the first free cells; the others not placed yet keep the cell
43
+ they are seen in (nothing else moves). `pos`: layout(items, n).pos as seen now. Changes `items`. */
44
+ function moveTo(items, id, c, r, n, pos, now = Date.now()) {
45
+ const it = items.find((x) => x.id === id); if (!it) return false;
46
+ const w = W(it, n); const h = H(it);
47
+ const at = { c: Math.max(1, Math.min(c, n - w + 1)), r: Math.max(1, r), w, h };
48
+ for (const o of items) {
49
+ if (o === it) continue;
50
+ const p = pos.get(o.id); if (!p) continue;
51
+ if (overlap(p, at)) { delete o.c; delete o.r; delete o.t; } else if (!(o.c && o.r)) { o.c = p.c; o.r = p.r; }
52
+ }
53
+ it.c = at.c; it.r = at.r; it.t = now;
54
+ return true;
55
+ }
56
+ /* By one cell: ← → ↑ ↓ (dc, dr). */
57
+ function moveBy(items, id, dc, dr, n, pos, now) {
58
+ const p = pos.get(id); if (!p) return false;
59
+ return moveTo(items, id, p.c + dc, Math.max(1, p.r + dr), n, pos, now);
60
+ }
61
+ /* TIDY: all packed to the top left, in the order they are read now. Returns the new order. */
62
+ function tidy(items, pos) {
63
+ const seen = (x) => pos.get(x.id) ?? { r: Infinity, c: Infinity };
64
+ return [...items].sort((a, b) => seen(a).r - seen(b).r || seen(a).c - seen(b).c).map((x) => { const y = { ...x }; delete y.c; delete y.r; delete y.t; return y; });
65
+ }
66
+ /* Every id on the desk, those in folders too. */
67
+ const idsOf = (items) => items.flatMap((x) => (x.folder !== undefined ? [x.id, ...x.items] : [x.id]));
68
+ /* ONE DROPPED ON ANOTHER: into it if it is a folder; else both in a new folder at the other's place.
69
+ A folder is never put in a folder. Returns the folder, or null. */
70
+ function merge(items, dragId, ontoId, { id, name }) {
71
+ const drag = items.find((x) => x.id === dragId); const onto = items.find((x) => x.id === ontoId);
72
+ if (!drag || !onto || drag === onto || drag.folder !== undefined) return null;
73
+ items.splice(items.indexOf(drag), 1);
74
+ if (onto.folder !== undefined) { onto.items.push(drag.id); return onto; }
75
+ const f = { id, folder: name, size: onto.size === 'l' ? 'm' : onto.size, items: [onto.id, drag.id] };
76
+ if (onto.c && onto.r) { f.c = onto.c; f.r = onto.r; if (onto.t) f.t = onto.t; }
77
+ items.splice(items.indexOf(onto), 1, f);
78
+ return f;
79
+ }
80
+ /* A folder undone: its things back on the desk, as icons, in the first free cells. */
81
+ function unfold(items, folderId) {
82
+ const i = items.findIndex((x) => x.id === folderId);
83
+ if (i < 0 || items[i].folder === undefined) return false;
84
+ items.splice(i, 1, ...items[i].items.map((k) => ({ id: k, size: 's' })));
85
+ return true;
86
+ }
87
+ /* Out of its folder, onto the desk; an emptied folder goes. */
88
+ function takeOut(items, folderId, id) {
89
+ const f = items.find((x) => x.id === folderId); if (!f || f.folder === undefined) return false;
90
+ f.items = f.items.filter((k) => k !== id);
91
+ items.push({ id, size: 's' });
92
+ return true;
93
+ }
94
+ /* Off the desk (`folderId`: from that folder). Conversations and rooms taken off are said `gone`: a
95
+ new one comes by itself, those do not. Returns the ids now gone. */
96
+ function remove(items, id, folderId = '') {
97
+ if (folderId) {
98
+ const f = items.find((x) => x.id === folderId); if (!f) return [];
99
+ f.items = f.items.filter((k) => k !== id);
100
+ return /^[cr]:/.test(id) ? [id] : [];
101
+ }
102
+ const i = items.findIndex((x) => x.id === id); if (i < 0) return [];
103
+ const [x] = items.splice(i, 1);
104
+ return (x.folder !== undefined ? x.items : [x.id]).filter((k) => /^[cr]:/.test(k));
105
+ }
106
+ /* What the home cards show and the desk does not have yet (and was never taken off): added, in order.
107
+ `wanted`: [{ id, size }]. Returns how many were added. */
108
+ function addNew(items, gone, wanted) {
109
+ const have = new Set(idsOf(items)); const off = new Set(gone);
110
+ let added = 0;
111
+ for (const w of wanted) if (!have.has(w.id) && !off.has(w.id)) { items.push({ id: w.id, size: w.size ?? 's' }); have.add(w.id); added++; }
112
+ return added;
113
+ }
114
+ /* Emptied folders go (a last thing taken out, or removed from it). */
115
+ const dropEmpty = (items) => items.filter((x) => x.folder === undefined || x.items.length > 0);
116
+
117
+ /* ---------------- the page ---------------- */
118
+ const el = (tag, cls = '', text) => { const e = document.createElement(tag); if (cls) e.className = cls; if (text !== undefined) e.textContent = text; return e; };
119
+ const button = (cls, text, label) => { const b = el('button', cls, text); b.type = 'button'; if (label) { b.setAttribute('aria-label', label); b.title = label; } return b; };
120
+
121
+ /* `host`: where it is drawn. `o`:
122
+ load() -> { saved, items, gone } save({ items, gone }) -> Promise (throws: not kept)
123
+ has(id) the thing exists (else not shown; its place is kept)
124
+ name(id) its name tile(id, size) -> its card (kit), not a button
125
+ mini(id) its small sign (an avatar) waits(id) -> it waits for the person
126
+ open(id) opened wanted() -> [{ id, size }] the home cards, in order
127
+ addable() -> [{ title, items: [{ id, name, sign }] }] create: [{ label, run }]
128
+ word(key, en, vars) the page's words
129
+ toast(text) said a moment */
130
+ function Desk(host, o) {
131
+ const toast = o.toast ?? ((text) => { const t = el('div', 'desk-toast', text); t.setAttribute('role', 'status'); document.body.append(t); setTimeout(() => t.remove(), 1800); });
132
+ const w = (key, en, vars) => (o.word ? o.word(key, en, vars) : en.replace(/\{(\w+)\}/g, (a, k) => (vars && k in vars ? String(vars[k]) : a)));
133
+ let items = []; let gone = []; let editing = false; let ready = false; let shownFolder = '';
134
+ let cols = 0; let pos = new Map();
135
+ const bar = el('div', 'desk-bar');
136
+ const add = button('desk-add', w('desk-add', '+ Add'));
137
+ const tidyB = button('desk-tidy', w('desk-tidy', 'Tidy'), w('desk-tidy-what', 'Pack to the top left')); tidyB.hidden = true;
138
+ const edit = button('desk-edit', w('desk-edit', 'Edit')); edit.setAttribute('aria-pressed', 'false');
139
+ bar.append(add, tidyB, edit);
140
+ const grid = el('div', 'desk-grid'); grid.id = 'desk'; grid.setAttribute('role', 'list');
141
+ const empty = el('p', 'desk-empty hint', w('desk-empty', 'Nothing on the desk yet: + Add')); empty.hidden = true;
142
+ host.replaceChildren(bar, grid, empty);
143
+
144
+ /* KEPT: a moment after the last change, the whole desk. */
145
+ let saving = null;
146
+ const save = () => {
147
+ clearTimeout(saving);
148
+ saving = setTimeout(async () => { try { await o.save({ items, gone }); } catch { toast(w('desk-not-saved', 'Desk not saved')); } }, 250);
149
+ };
150
+ const changed = () => { render(); save(); };
151
+
152
+ /* HOW MANY COLUMNS fit: from the cell's size in the style sheet (--desk-cell), not from a grid drawn. */
153
+ function measure() {
154
+ const cs = getComputedStyle(grid);
155
+ const gap = parseFloat(cs.columnGap) || 12;
156
+ const cell = parseFloat(cs.getPropertyValue('--desk-cell')) || 104;
157
+ const inner = grid.clientWidth - (parseFloat(cs.paddingLeft) || 0) - (parseFloat(cs.paddingRight) || 0);
158
+ return inner > 0 ? Math.max(1, Math.min(48, Math.floor((inner + gap) / (cell + gap)))) : 0;
159
+ }
160
+ function cellAt(x, y) {
161
+ const cs = getComputedStyle(grid); const b = grid.getBoundingClientRect();
162
+ const gap = parseFloat(cs.columnGap) || 12; const rowGap = parseFloat(cs.rowGap) || gap;
163
+ const x0 = b.left + (parseFloat(cs.paddingLeft) || 0); const y0 = b.top + (parseFloat(cs.paddingTop) || 0);
164
+ const inner = grid.clientWidth - (parseFloat(cs.paddingLeft) || 0) - (parseFloat(cs.paddingRight) || 0);
165
+ const cw = (inner - gap * (cols - 1)) / cols; const rh = parseFloat(cs.gridAutoRows) || cw;
166
+ return { c: Math.max(1, Math.min(cols, Math.floor((x - x0) / (cw + gap)) + 1)), r: Math.max(1, Math.floor((y - y0) / (rh + rowGap)) + 1) };
167
+ }
168
+ const shown = () => items.filter((x) => (x.folder !== undefined ? true : o.has(x.id)));
169
+ const find = (id) => items.find((x) => x.id === id);
170
+ const kidsOf = (f) => f.items.filter((k) => o.has(k));
171
+
172
+ function folderFace(f, size) {
173
+ const kids = kidsOf(f);
174
+ const box = el('div', 'desk-folder');
175
+ const sign = el('span', 'desk-folder-ic'); sign.setAttribute('aria-hidden', 'true');
176
+ for (const k of kids.slice(0, 4)) sign.append(o.mini(k));
177
+ const head = el('span', 'desk-folder-head');
178
+ const words = el('span', 'desk-folder-words');
179
+ words.append(el('b', 'desk-folder-name', f.folder));
180
+ if (size !== 's') words.append(el('small', 'when', w('desk-folder-n', '{n} items', { n: kids.length })));
181
+ head.append(sign, words); box.append(head);
182
+ if (size !== 's') {
183
+ const mini = el('span', 'desk-folder-mini');
184
+ for (const k of kids.slice(0, size === 'l' ? 9 : 6)) { const s = el('span', 'desk-folder-kid'); s.append(o.mini(k), el('em', '', o.name(k))); mini.append(s); }
185
+ box.append(mini);
186
+ }
187
+ const waits = kids.filter((k) => o.waits?.(k)).length;
188
+ if (waits) box.append(el('span', 'desk-badge', String(waits)));
189
+ return box;
190
+ }
191
+ function tileOf(it, { inFolder = '' } = {}) {
192
+ const size = inFolder ? 's' : it.size;
193
+ const t = el('div', `desk-tile desk-${size}${it.folder !== undefined ? ' desk-is-folder' : ''}`);
194
+ t.dataset.id = it.id; t.tabIndex = 0; t.setAttribute('role', 'listitem');
195
+ const name = it.folder !== undefined ? it.folder : o.name(it.id);
196
+ t.setAttribute('aria-label', it.folder !== undefined ? w('desk-folder-of', 'Folder {name}', { name }) : name);
197
+ if (inFolder) t.dataset.folder = inFolder;
198
+ const more = button('desk-more', '⋯', w('desk-options', 'Options'));
199
+ t.append(more, it.folder !== undefined ? folderFace(it, size) : o.tile(it.id, size));
200
+ return t;
201
+ }
202
+
203
+ function render() {
204
+ if (!ready || drag) return;
205
+ const n = measure(); if (!n) return;
206
+ cols = n;
207
+ grid.style.gridTemplateColumns = `repeat(${n}, minmax(0, 1fr))`;
208
+ grid.classList.toggle('desk-editing', editing);
209
+ const list = shown();
210
+ const lay = layout(list, n); pos = lay.pos;
211
+ const nodes = [];
212
+ if (editing) {
213
+ for (let r = 1; r <= lay.rows + 2; r++) for (let c = 1; c <= n; c++) if (!lay.occ.has(`${c},${r}`)) {
214
+ const m = el('div', 'desk-cell'); m.style.gridColumn = String(c); m.style.gridRow = String(r); m.dataset.c = String(c); m.dataset.r = String(r); nodes.push(m);
215
+ }
216
+ }
217
+ for (const it of list) {
218
+ const p = pos.get(it.id); const t = tileOf(it);
219
+ t.style.gridColumn = `${p.c} / span ${p.w}`; t.style.gridRow = `${p.r} / span ${p.h}`;
220
+ t.dataset.c = String(p.c); t.dataset.r = String(p.r);
221
+ nodes.push(t);
222
+ }
223
+ const had = document.activeElement?.closest?.('.desk-tile')?.dataset.id;
224
+ grid.replaceChildren(...nodes);
225
+ if (had) grid.querySelector(`.desk-tile[data-id="${CSS.escape(had)}"]`)?.focus({ preventScroll: true });
226
+ empty.hidden = list.length > 0 || editing;
227
+ tidyB.hidden = !editing;
228
+ edit.textContent = editing ? w('desk-done', 'Done') : w('desk-edit', 'Edit');
229
+ edit.setAttribute('aria-pressed', String(editing)); edit.classList.toggle('primary', editing);
230
+ if (shownFolder) paintFolder();
231
+ }
232
+ const setEditing = (on) => { editing = on; closeMenu(); render(); };
233
+
234
+ /* ---- the menu of one: its size, moves, out of its folder, off the desk ---- */
235
+ let menu = null;
236
+ function closeMenu() { menu?.remove(); menu = null; document.removeEventListener('pointerdown', outside, true); }
237
+ function outside(e) { if (menu && !menu.contains(e.target) && !e.target.closest?.('.desk-more')) closeMenu(); }
238
+ function menuFor(id, anchor, inFolder = '') {
239
+ closeMenu();
240
+ const it = inFolder ? null : find(id);
241
+ const m = el('div', 'desk-menu'); m.setAttribute('role', 'menu');
242
+ const item = (text, act, label) => { const b = button('', text, label); b.setAttribute('role', 'menuitem'); b.dataset.act = act; return b; };
243
+ if (it) {
244
+ const sizes = el('div', 'desk-sizes'); sizes.setAttribute('role', 'group'); sizes.setAttribute('aria-label', w('desk-size', 'Size'));
245
+ for (const [s, en] of [['s', 'Icon'], ['m', 'Wide'], ['l', 'Large']]) { const b = item(w(`desk-size-${s}`, en), `size-${s}`); b.setAttribute('aria-pressed', String(it.size === s)); sizes.append(b); }
246
+ m.append(sizes);
247
+ const arrows = el('div', 'desk-arrows');
248
+ for (const [glyph, act, en] of [['←', 'left', 'Move left'], ['↑', 'up', 'Move up'], ['↓', 'down', 'Move down'], ['→', 'right', 'Move right']]) arrows.append(item(glyph, `mv-${act}`, w(`desk-mv-${act}`, en)));
249
+ m.append(arrows);
250
+ }
251
+ if (it?.folder !== undefined) m.append(item(w('desk-folder-open', 'Open'), 'open'), item(w('desk-folder-undo', 'Undo the folder'), 'unfold'));
252
+ if (inFolder) m.append(item(w('desk-folder-out', 'Take out of the folder'), 'out'));
253
+ m.append(item(w('desk-remove', 'Remove from the desk'), 'remove'));
254
+ document.body.append(m); menu = m;
255
+ const a = anchor.getBoundingClientRect(); const r = m.getBoundingClientRect();
256
+ m.style.left = `${Math.max(8, Math.min(a.left, innerWidth - r.width - 8))}px`;
257
+ m.style.top = `${Math.max(8, Math.min(a.bottom + 4, innerHeight - r.height - 8))}px`;
258
+ m.querySelector('button')?.focus();
259
+ setTimeout(() => document.addEventListener('pointerdown', outside, true));
260
+ m.addEventListener('keydown', (e) => {
261
+ if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); closeMenu(); anchor.closest('.desk-tile')?.focus(); }
262
+ if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
263
+ const all = [...m.querySelectorAll('button')]; const i = all.indexOf(document.activeElement);
264
+ e.preventDefault(); all[(i + (e.key === 'ArrowDown' ? 1 : all.length - 1)) % all.length]?.focus();
265
+ }
266
+ });
267
+ m.addEventListener('click', (e) => {
268
+ const b = e.target.closest('button[data-act]'); if (!b) return;
269
+ const act = b.dataset.act;
270
+ if (act.startsWith('size-')) { it.size = act.slice(5); changed(); menuFor(id, gridTile(id) ?? anchor); return; }
271
+ if (act.startsWith('mv-')) {
272
+ const [dc, dr] = { left: [-1, 0], right: [1, 0], up: [0, -1], down: [0, 1] }[act.slice(3)];
273
+ moveBy(items, id, dc, dr, cols, pos); changed(); menuFor(id, gridTile(id) ?? anchor); return;
274
+ }
275
+ closeMenu();
276
+ if (act === 'open') { shownFolder = id; paintFolder(); return; }
277
+ if (act === 'unfold') unfold(items, id);
278
+ else if (act === 'out') { takeOut(items, inFolder, id); items = dropEmpty(items); }
279
+ else if (act === 'remove') { const off = remove(items, id, inFolder); gone = [...new Set([...gone, ...off])]; if (inFolder) items = dropEmpty(items); }
280
+ changed();
281
+ });
282
+ }
283
+ const gridTile = (id) => grid.querySelector(`.desk-tile[data-id="${CSS.escape(id)}"]`);
284
+
285
+ /* ---- a folder, opened over the desk ---- */
286
+ let sheet = null;
287
+ function closeFolder() { shownFolder = ''; sheet?.remove(); sheet = null; }
288
+ function paintFolder() {
289
+ const f = find(shownFolder);
290
+ if (!f || f.folder === undefined) { closeFolder(); return; }
291
+ const fresh = !sheet;
292
+ if (fresh) {
293
+ sheet = el('div', 'desk-sheet-bg');
294
+ const box = el('div', 'desk-sheet'); box.setAttribute('role', 'dialog'); box.setAttribute('aria-modal', 'true');
295
+ const head = el('div', 'desk-sheet-head');
296
+ const name = el('input', 'desk-folder-input'); name.maxLength = 60; name.setAttribute('aria-label', w('desk-folder-name', 'Folder name'));
297
+ name.addEventListener('input', () => { const g = find(shownFolder); if (!g) return; g.folder = name.value.trim().replace(/[\u0000-\u001f\u007f]/g, '') || w('desk-folder-new', 'New folder'); box.setAttribute('aria-label', g.folder); render(); save(); });
298
+ const close = button('desk-close', w('desk-close', 'Close'));
299
+ close.addEventListener('click', () => { closeFolder(); gridTile(f.id)?.focus(); });
300
+ head.append(name, close);
301
+ const kids = el('div', 'desk-grid desk-in-folder'); kids.setAttribute('role', 'list');
302
+ box.append(head, kids); sheet.append(box);
303
+ sheet.addEventListener('click', (e) => { if (e.target === sheet) closeFolder(); });
304
+ sheet.addEventListener('keydown', (e) => { if (e.key === 'Escape' && !menu) { e.stopPropagation(); closeFolder(); gridTile(f.id)?.focus(); } });
305
+ kidsHandlers(kids);
306
+ document.body.append(sheet);
307
+ name.value = f.folder;
308
+ }
309
+ const box = sheet.querySelector('.desk-sheet'); box.setAttribute('aria-label', f.folder);
310
+ const kids = sheet.querySelector('.desk-in-folder');
311
+ kids.classList.toggle('desk-editing', editing);
312
+ kids.replaceChildren(...kidsOf(f).map((k) => tileOf({ id: k, size: 's' }, { inFolder: f.id })));
313
+ if (fresh) (kids.querySelector('.desk-tile') ?? sheet.querySelector('input'))?.focus();
314
+ }
315
+ function kidsHandlers(kids) {
316
+ kids.addEventListener('click', (e) => {
317
+ const t = e.target.closest('.desk-tile'); if (!t) return;
318
+ if (e.target.closest('.desk-more')) { menuFor(t.dataset.id, e.target.closest('.desk-more'), t.dataset.folder); return; }
319
+ if (!editing) { closeFolder(); o.open(t.dataset.id); }
320
+ });
321
+ kids.addEventListener('keydown', (e) => {
322
+ const t = e.target.closest('.desk-tile'); if (!t || e.target !== t) return;
323
+ if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); if (editing) menuFor(t.dataset.id, t, t.dataset.folder); else { closeFolder(); o.open(t.dataset.id); } }
324
+ });
325
+ }
326
+
327
+ /* ---- adding: what is not on the desk yet ---- */
328
+ function openAdd() {
329
+ const bg = el('div', 'desk-sheet-bg');
330
+ const box = el('div', 'desk-sheet'); box.setAttribute('role', 'dialog'); box.setAttribute('aria-modal', 'true'); box.setAttribute('aria-label', w('desk-add-title', 'Add to the desk'));
331
+ const head = el('div', 'desk-sheet-head'); head.append(el('h2', '', w('desk-add-title', 'Add to the desk')));
332
+ const close = button('desk-close', w('desk-close', 'Close')); head.append(close);
333
+ const pick = el('div', 'desk-pick');
334
+ const on = new Set(idsOf(items));
335
+ const row = (x, run) => { const b = button('desk-pick-row'); b.dataset.id = x.id ?? ''; b.append(x.sign, el('span', '', x.name)); if (x.what) b.append(el('small', '', x.what)); b.addEventListener('click', () => run(b)); return b; };
336
+ let any = false;
337
+ for (const group of o.addable()) {
338
+ const free = group.items.filter((x) => !on.has(x.id));
339
+ if (!free.length) continue;
340
+ any = true;
341
+ pick.append(el('h3', '', group.title));
342
+ for (const x of free) pick.append(row(x, (b) => {
343
+ if (!idsOf(items).includes(x.id)) items.push({ id: x.id, size: 's' });
344
+ gone = gone.filter((g) => g !== x.id);
345
+ changed(); toast(w('desk-added', 'Added to the desk')); b.remove();
346
+ }));
347
+ }
348
+ if (!any) pick.append(el('p', 'hint', w('desk-add-all', 'Everything is on the desk')));
349
+ pick.append(el('h3', '', w('desk-add-more', 'Folders')));
350
+ const folderSign = el('span', 'desk-folder-ic'); folderSign.setAttribute('aria-hidden', 'true');
351
+ pick.append(row({ name: w('desk-folder-empty', 'Empty folder'), sign: folderSign }, () => {
352
+ const f = { id: `f:${Date.now().toString(36)}${Math.random().toString(36).slice(2, 6)}`, folder: w('desk-folder-new', 'New folder'), size: 's', items: [] };
353
+ /* Empty, it waits on the desk for things dropped on it (one emptied by taking things out goes). */
354
+ items.push(f); bg.remove(); changed(); shownFolder = f.id; paintFolder(); sheet?.querySelector('input')?.select();
355
+ }));
356
+ if (o.create?.length) {
357
+ pick.append(el('h3', '', w('desk-create', 'Create')));
358
+ for (const c of o.create) { const b = button('desk-pick-row'); b.append(el('span', 'desk-plus', '+'), el('span', '', c.label)); b.addEventListener('click', () => { bg.remove(); c.run(); }); pick.append(b); }
359
+ }
360
+ box.append(head, pick); bg.append(box);
361
+ const shut = () => { bg.remove(); add.focus(); };
362
+ close.addEventListener('click', shut);
363
+ bg.addEventListener('click', (e) => { if (e.target === bg) shut(); });
364
+ bg.addEventListener('keydown', (e) => { if (e.key === 'Escape') { e.stopPropagation(); shut(); } });
365
+ document.body.append(bg);
366
+ (pick.querySelector('button') ?? close).focus();
367
+ }
368
+
369
+ /* ---- the pointer: a press opens; a long press, or a drag in edit mode, moves ---- */
370
+ let press = null; let drag = null;
371
+ const LONG_MS = 550;
372
+ function down(e) {
373
+ if (e.button !== 0 && e.pointerType === 'mouse') return;
374
+ const t = e.target.closest('.desk-tile'); if (!t || t.closest('.desk-sheet') || e.target.closest('.desk-more')) return;
375
+ press = { id: t.dataset.id, x: e.clientX, y: e.clientY, tile: t, timer: setTimeout(() => { if (!editing && press) { press = null; setEditing(true); toast(w('desk-editing', 'Edit mode')); } }, LONG_MS) };
376
+ addEventListener('pointermove', move); addEventListener('pointerup', up); addEventListener('pointercancel', cancel);
377
+ }
378
+ function stop() { removeEventListener('pointermove', move); removeEventListener('pointerup', up); removeEventListener('pointercancel', cancel); }
379
+ function cancel() { if (press) clearTimeout(press.timer); press = null; if (drag) endDrag(true); stop(); }
380
+ function move(e) {
381
+ if (drag) { moveDrag(e); return; }
382
+ if (!press) return;
383
+ if (Math.hypot(e.clientX - press.x, e.clientY - press.y) > 8) {
384
+ clearTimeout(press.timer);
385
+ if (editing) startDrag(e); else { press = null; stop(); }
386
+ }
387
+ }
388
+ function up() {
389
+ if (drag) { endDrag(false); stop(); return; }
390
+ stop();
391
+ if (!press) return;
392
+ clearTimeout(press.timer);
393
+ const p = press; press = null;
394
+ if (editing) return;
395
+ const it = find(p.id);
396
+ if (it?.folder !== undefined) { shownFolder = it.id; paintFolder(); } else o.open(p.id);
397
+ }
398
+ function startDrag(e) {
399
+ const t = press.tile; const r = t.getBoundingClientRect();
400
+ const ghost = t.cloneNode(true); ghost.classList.add('desk-drag'); ghost.removeAttribute('tabindex'); ghost.setAttribute('aria-hidden', 'true');
401
+ Object.assign(ghost.style, { left: `${r.left}px`, top: `${r.top}px`, width: `${r.width}px`, height: `${r.height}px`, gridColumn: '', gridRow: '' });
402
+ document.body.append(ghost);
403
+ drag = { id: press.id, ghost, dx: e.clientX - r.left, dy: e.clientY - r.top, over: '', since: 0, merge: '', cell: null };
404
+ press = null;
405
+ t.classList.add('desk-ghosted');
406
+ }
407
+ let hint = null; let mark = null;
408
+ function clearMarks() { hint?.remove(); hint = null; mark?.remove(); mark = null; grid.querySelectorAll('.desk-target').forEach((x) => x.classList.remove('desk-target')); }
409
+ function moveDrag(e) {
410
+ const d = drag;
411
+ d.ghost.style.left = `${e.clientX - d.dx}px`; d.ghost.style.top = `${e.clientY - d.dy}px`;
412
+ const under = document.elementsFromPoint(e.clientX, e.clientY).find((x) => x.classList?.contains('desk-tile') && x.parentNode === grid && x.dataset.id !== d.id);
413
+ const dragged = find(d.id);
414
+ if (under && dragged?.folder === undefined) {
415
+ const r = under.getBoundingClientRect();
416
+ const cx = (e.clientX - r.left) / r.width; const cy = (e.clientY - r.top) / r.height;
417
+ if (cx > 0.25 && cx < 0.75 && cy > 0.2 && cy < 0.8) {
418
+ if (d.over !== under.dataset.id) { d.over = under.dataset.id; d.since = performance.now(); d.merge = ''; }
419
+ if (!d.merge && performance.now() - d.since > 350) {
420
+ clearMarks(); d.merge = under.dataset.id; d.cell = null;
421
+ under.classList.add('desk-target');
422
+ hint = el('div', 'desk-hint', find(d.merge)?.folder !== undefined ? w('desk-drop-into', 'Drop: put in the folder') : w('desk-drop-folder', 'Drop: make a folder'));
423
+ document.body.append(hint);
424
+ }
425
+ if (d.merge) return;
426
+ mark?.remove(); mark = null; d.cell = null;
427
+ return;
428
+ }
429
+ }
430
+ d.over = ''; d.merge = ''; clearMarks();
431
+ const it = find(d.id); const g = d.ghost.getBoundingClientRect();
432
+ const cell = cellAt(g.left + Math.min(20, g.width / 4), g.top + Math.min(20, g.height / 4));
433
+ const span = W(it, cols); cell.c = Math.min(cell.c, cols - span + 1); d.cell = cell;
434
+ mark = el('div', 'desk-dropmark'); mark.style.gridColumn = `${cell.c} / span ${span}`; mark.style.gridRow = `${cell.r} / span ${H(it)}`;
435
+ grid.append(mark);
436
+ }
437
+ function endDrag(cancelled) {
438
+ const d = drag; drag = null; d.ghost.remove(); clearMarks();
439
+ if (!cancelled && d.merge) {
440
+ const f = merge(items, d.id, d.merge, { id: `f:${Date.now().toString(36)}${Math.random().toString(36).slice(2, 6)}`, name: w('desk-folder-new', 'New folder') });
441
+ changed();
442
+ if (f && f.items.length === 2) { shownFolder = f.id; paintFolder(); sheet?.querySelector('input')?.select(); }
443
+ return;
444
+ }
445
+ if (!cancelled && d.cell) { moveTo(items, d.id, d.cell.c, d.cell.r, cols, pos); changed(); return; }
446
+ render();
447
+ }
448
+
449
+ grid.addEventListener('pointerdown', down);
450
+ grid.addEventListener('contextmenu', (e) => { if (e.target.closest('.desk-tile')) e.preventDefault(); });
451
+ grid.addEventListener('click', (e) => {
452
+ const more = e.target.closest('.desk-more');
453
+ if (more) { e.stopPropagation(); const t = more.closest('.desk-tile'); if (menu && menu.dataset.for === t.dataset.id) { closeMenu(); return; } menuFor(t.dataset.id, more); if (menu) menu.dataset.for = t.dataset.id; }
454
+ });
455
+ grid.addEventListener('keydown', (e) => {
456
+ const t = e.target.closest('.desk-tile'); if (!t || e.target !== t) return;
457
+ const id = t.dataset.id;
458
+ if (e.key === 'Enter' || e.key === ' ') {
459
+ e.preventDefault();
460
+ if (editing) { menuFor(id, t); return; }
461
+ const it = find(id);
462
+ if (it?.folder !== undefined) { shownFolder = id; paintFolder(); } else o.open(id);
463
+ return;
464
+ }
465
+ const arrow = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }[e.key];
466
+ if (arrow && editing) { e.preventDefault(); moveBy(items, id, arrow[0], arrow[1], cols, pos); changed(); gridTile(id)?.focus(); }
467
+ if (e.key === 'Escape' && editing) { e.preventDefault(); setEditing(false); }
468
+ });
469
+ edit.addEventListener('click', () => setEditing(!editing));
470
+ tidyB.addEventListener('click', () => { items = tidy(items, pos); changed(); });
471
+ add.addEventListener('click', openAdd);
472
+ /* The screen narrower or wider: as many columns as it holds now (the places kept are not touched). */
473
+ const watch = typeof ResizeObserver === 'function' ? new ResizeObserver(() => { if (ready && measure() !== cols) render(); }) : null;
474
+ watch?.observe(grid);
475
+
476
+ /* READ: the desk kept; none yet, the home cards as they are today (nothing disappears); the
477
+ conversations and rooms made since, added. */
478
+ async function refresh() {
479
+ const got = await o.load();
480
+ if (drag || press) return;
481
+ items = Array.isArray(got?.items) ? got.items.map((x) => (x.folder !== undefined ? { ...x, items: [...x.items] } : { ...x })) : [];
482
+ gone = Array.isArray(got?.gone) ? [...got.gone] : [];
483
+ const added = addNew(items, gone, o.wanted());
484
+ ready = true;
485
+ render();
486
+ if (!got?.saved || added) save();
487
+ }
488
+ return {
489
+ refresh, render,
490
+ get editing() { return editing; },
491
+ state: () => ({ items: structuredClone(items), gone: [...gone], cols }),
492
+ leave() { closeMenu(); closeFolder(); if (editing) setEditing(false); },
493
+ };
494
+ }
495
+
496
+ window.clavariumDesk = { layout, moveTo, moveBy, tidy, merge, unfold, takeOut, remove, addNew, idsOf, dropEmpty, Desk };
497
+ })();
package/web/index.html CHANGED
@@ -734,7 +734,8 @@
734
734
  <!-- FEATURES (features.js): the next step over the cards; the welcome in place of "No conversation yet". -->
735
735
  <div id="deck-features" hidden></div>
736
736
  <div id="deck-welcome" hidden></div>
737
- <div id="deck-cards" class="deck"></div>
737
+ <!-- THE DESK (desk.js): the home page, a grid of icons kept per person, the same on every screen. -->
738
+ <div id="deck-cards" class="desk-host"></div>
738
739
  <div id="deck-empty" class="deck-empty" hidden><p>No conversation yet.</p><div class="deck-empty-acts"><button type="button" id="deck-empty-new" class="primary">+ Create a conversation</button><button type="button" id="deck-empty-import">Import a configuration</button></div></div>
739
740
  </div>
740
741
  <!-- A room (#268): one thread for several AIs, the person and voice boxes. -->
@@ -1538,6 +1539,7 @@
1538
1539
  <div id="cm-toast" class="cm-toast" role="status" hidden><span id="cm-toast-text"></span><button type="button" id="cm-toast-go" class="primary"></button><button type="button" id="cm-toast-close" class="quiet" aria-label="Close">×</button></div>
1539
1540
  <script src="/features.js"></script>
1540
1541
  <script src="/kit.js"></script>
1542
+ <script src="/desk.js"></script>
1541
1543
  <script src="/mail-view.js"></script>
1542
1544
  <script src="/app.js"></script>
1543
1545
  <script type="module" src="/voice.js"></script>
package/web/style.css CHANGED
@@ -3249,3 +3249,92 @@ span.tile-spark { display: block; height: 22px; }
3249
3249
  .list-bones { display: grid; gap: 10px; padding: 8px 0; }
3250
3250
  .ap-edit { flex: 1 1 100%; }
3251
3251
  .ap-edit textarea { width: 100%; box-sizing: border-box; }
3252
+
3253
+ /* THE DESK (desk.js, 16-11, mockup bureau-2): the home page, icons that snap to cells. The cards inside are the
3254
+ kit's (ConvCard, AssetCard); only their sizes are set here: an icon (s), wide (m: two cells), large (l: 2 x 2). */
3255
+ .desk-host { --desk-cell: 104px; --desk-row: 104px; --desk-gap: 12px; display: flex; flex-direction: column; min-height: 0; }
3256
+ .desk-bar { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; padding: 10px 16px 0; }
3257
+ .desk-bar .desk-edit.primary { background: var(--brass); color: var(--on-brass); border-color: var(--brass); }
3258
+ .desk-grid { display: grid; grid-auto-rows: var(--desk-row); gap: var(--desk-gap); padding: 12px 16px 96px; min-width: 0; }
3259
+ .desk-empty { text-align: center; color: var(--ink2); padding: 24px 16px; }
3260
+ @media (max-width: 520px) { .desk-host { --desk-cell: 72px; --desk-row: 96px; --desk-gap: 10px; } }
3261
+ .desk-tile { position: relative; min-width: 0; min-height: 0; border-radius: 16px; border: 1px solid var(--line); background: linear-gradient(160deg, var(--bar), var(--panel)); overflow: hidden; cursor: pointer; user-select: none; -webkit-user-select: none; touch-action: manipulation; -webkit-touch-callout: none; outline-offset: 2px; }
3262
+ .desk-tile:focus-visible { outline: 2px solid var(--brass); }
3263
+ .desk-tile:hover { border-color: var(--brass); }
3264
+ .desk-tile > .desk-card, .desk-tile > .desk-folder { height: 100%; padding: 10px; min-height: 0; }
3265
+ .desk-card.kit-conv-card { min-height: 0; overflow: hidden; }
3266
+ .desk-l .desk-card.kit-conv-card .kit-conv-main > .last { -webkit-line-clamp: 6; }
3267
+ .desk-card.kit-asset { flex-direction: row; align-items: center; align-content: flex-start; }
3268
+ .desk-m .desk-card.kit-asset, .desk-l .desk-card.kit-asset { align-items: flex-start; }
3269
+ .desk-l .desk-card .kit-asset-ic { --ka-ic: 40px; }
3270
+ /* An icon: its sign, its name under it, nothing else (its point still says how it is). */
3271
+ .desk-s { background: transparent; border-color: transparent; }
3272
+ .desk-s:hover { border-color: transparent; background: color-mix(in srgb, var(--ink) 5%, transparent); }
3273
+ .desk-s > .desk-card, .desk-s > .desk-folder { padding: 6px 4px; }
3274
+ .desk-s .desk-card.kit-conv-card { --kc-av: 50px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; }
3275
+ .desk-s .desk-card.kit-conv-card > .state-dot { position: absolute; top: 50%; left: 50%; margin: 6px 0 0 16px; width: 12px; height: 12px; }
3276
+ .desk-s .desk-card .kit-conv-head { align-items: center; }
3277
+ .desk-s .desk-card .kit-conv-head > b, .desk-s .desk-card .kit-asset-name, .desk-s .desk-folder-name { font-size: .75rem; font-weight: 500; -webkit-line-clamp: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; display: block; text-align: center; }
3278
+ .desk-s .desk-card :is(.when, .last, .kit-conv-now, .kit-chips, .kit-asset-sub, .kit-asset-side) { display: none !important; }
3279
+ .desk-s .desk-card.kit-conv-card .kit-conv-main { display: block; max-width: 100%; }
3280
+ .desk-s .desk-card.kit-asset { flex-direction: column; justify-content: center; gap: 6px; }
3281
+ .desk-s .desk-card.kit-asset .kit-asset-main { flex: none; max-width: 100%; align-items: center; }
3282
+ .desk-s .desk-card .kit-asset-ic { --ka-ic: 50px; border-radius: 14px; }
3283
+ @media (max-width: 520px) { .desk-s .desk-card.kit-conv-card { --kc-av: 44px; } .desk-s .desk-card .kit-asset-ic { --ka-ic: 44px; } }
3284
+ /* A folder of the desk: up to four signs in its square; wide or large, its first ones by name. */
3285
+ .desk-folder { position: relative; display: flex; flex-direction: column; gap: 8px; color: var(--ink); }
3286
+ .desk-folder-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
3287
+ .desk-folder-words { display: flex; flex-direction: column; min-width: 0; }
3288
+ .desk-folder-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
3289
+ .desk-folder-words .when { color: var(--ink2); font-size: .75rem; }
3290
+ .desk-folder-ic { flex: none; width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--button); display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 3px; padding: 5px; }
3291
+ .desk-folder-ic > * { --kc-av: 100%; --ka-ic: 100%; width: 100%; height: 100%; border-radius: 4px; font-size: 0; min-width: 0; min-height: 0; }
3292
+ .desk-folder-ic > * svg { display: none; }
3293
+ .desk-s .desk-folder { align-items: center; justify-content: center; text-align: center; gap: 6px; }
3294
+ .desk-s .desk-folder-head { flex-direction: column; gap: 6px; max-width: 100%; }
3295
+ .desk-s .desk-folder-words { max-width: 100%; }
3296
+ .desk-s .desk-folder-ic { width: 50px; height: 50px; border-radius: 14px; }
3297
+ @media (max-width: 520px) { .desk-s .desk-folder-ic { width: 44px; height: 44px; } }
3298
+ .desk-folder-mini { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
3299
+ .desk-m .desk-folder-mini { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; }
3300
+ .desk-m .desk-folder-mini em { display: none; }
3301
+ .desk-folder-kid { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; font-size: .6875rem; color: var(--ink2); }
3302
+ .desk-folder-kid > :first-child { --kc-av: 30px; --ka-ic: 30px; }
3303
+ .desk-folder-kid em { font-style: normal; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
3304
+ .desk-badge { position: absolute; top: 4px; right: 4px; min-width: 20px; padding: 1px 6px; border-radius: 10px; background: var(--wait); color: #fff; font: 700 .6875rem/1.4 var(--sans); text-align: center; }
3305
+ /* Edit mode: free cells dotted, each thing a « ⋯ », a slight wobble (none when motion is reduced). */
3306
+ .desk-cell { border: 1px dashed var(--line); border-radius: 16px; opacity: .7; }
3307
+ .desk-dropmark { border: 2px solid var(--brass); border-radius: 16px; background: color-mix(in srgb, var(--brass) 15%, transparent); pointer-events: none; }
3308
+ .desk-more { display: none; position: absolute; top: 4px; right: 4px; z-index: 2; width: 28px; height: 28px; padding: 0; border-radius: 50%; border: 1px solid var(--line); background: var(--bar); color: var(--ink); line-height: 1; font-size: 1rem; }
3309
+ .desk-editing .desk-more { display: block; }
3310
+ .desk-editing .desk-tile { touch-action: none; animation: desk-wobble .28s ease-in-out infinite alternate; }
3311
+ .desk-editing .desk-tile:nth-child(2n) { animation-delay: .14s; }
3312
+ .desk-editing .desk-s { border: 1px dashed var(--line); }
3313
+ @keyframes desk-wobble { from { transform: rotate(-.7deg); } to { transform: rotate(.7deg); } }
3314
+ @media (prefers-reduced-motion: reduce) { .desk-editing .desk-tile { animation: none; } }
3315
+ .desk-ghosted { opacity: .25; }
3316
+ .desk-target { outline: 2px solid var(--brass); outline-offset: 2px; }
3317
+ .desk-drag { position: fixed; z-index: 80; margin: 0; pointer-events: none; transform: scale(1.05); box-shadow: 0 12px 30px rgba(0, 0, 0, .35); animation: none !important; }
3318
+ .desk-hint { position: fixed; left: 50%; bottom: 72px; transform: translateX(-50%); z-index: 85; padding: 6px 12px; border-radius: 10px; background: var(--brass); color: var(--on-brass); font-size: .8125rem; pointer-events: none; }
3319
+ .desk-toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 90; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--bar); color: var(--ink); box-shadow: 0 8px 20px rgba(0, 0, 0, .3); }
3320
+ .desk-menu { position: fixed; z-index: 90; min-width: 200px; padding: 6px; border-radius: 12px; border: 1px solid var(--line); background: var(--bar); box-shadow: 0 10px 30px rgba(0, 0, 0, .35); display: flex; flex-direction: column; gap: 2px; }
3321
+ .desk-menu > button { text-align: left; border: 0; background: none; color: var(--ink); padding: 8px 10px; border-radius: 8px; }
3322
+ .desk-menu button:hover, .desk-menu button:focus-visible { background: var(--button); }
3323
+ .desk-sizes, .desk-arrows { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 2px 2px 4px; }
3324
+ .desk-arrows { grid-template-columns: repeat(4, 1fr); }
3325
+ .desk-sizes button, .desk-arrows button { text-align: center; background: transparent; color: var(--ink); padding: 6px 4px; }
3326
+ .desk-sizes button[aria-pressed="true"] { background: var(--brass); color: var(--on-brass); border-color: var(--brass); }
3327
+ .desk-sheet-bg { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, .5); }
3328
+ .desk-sheet { width: min(560px, 100%); max-height: 85vh; overflow: auto; padding: 14px; border-radius: 18px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); }
3329
+ .desk-sheet-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
3330
+ .desk-sheet-head h2 { flex: 1; margin: 0; font-size: 1rem; }
3331
+ .desk-folder-input { flex: 1; min-width: 0; font: inherit; font-weight: 600; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); }
3332
+ .desk-in-folder { grid-template-columns: repeat(auto-fill, minmax(var(--desk-cell, 96px), 1fr)); padding: 4px 0; --desk-cell: 96px; --desk-row: 104px; }
3333
+ .desk-pick { display: flex; flex-direction: column; gap: 6px; }
3334
+ .desk-pick h3 { margin: 10px 0 2px; font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; color: var(--ink2); }
3335
+ .desk-pick-row { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); text-align: left; font-weight: 500; }
3336
+ .desk-pick-row > :first-child { --kc-av: 30px; --ka-ic: 30px; }
3337
+ .desk-pick-row > .desk-folder-ic { width: 30px; height: 30px; border-radius: 9px; }
3338
+ .desk-pick-row > span:nth-child(2) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
3339
+ .desk-pick-row small { margin-left: auto; color: var(--ink2); }
3340
+ .desk-plus { width: 30px; text-align: center; color: var(--brass-ink); font-size: 1.25rem; }