clavarium 0.2.290-next.1 → 0.2.292-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.290-next.1",
3
+ "version": "0.2.292-next.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "clavarium",
9
- "version": "0.2.290-next.1",
9
+ "version": "0.2.292-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.290-next.1",
3
+ "version": "0.2.292-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/web/app.js CHANGED
@@ -5157,22 +5157,46 @@
5157
5157
  }
5158
5158
  $('salon-close').addEventListener('click', () => leavePlace());
5159
5159
  $('salon-who').addEventListener('click', () => { const open = $('salon-members').hidden; $('salon-members').hidden = !open; $('salon-who').setAttribute('aria-expanded', String(open)); });
5160
- /* A NEW ROOM (03-11, in the look of a new conversation): its name, its AIs as tiles to pick (the first one
5161
- picked welcomes the room), its boxes the same. */
5162
- let salonPicked = [];
5163
- const salonTile = (value, name, about, box) => {
5164
- const b = el('button'); b.type = 'button'; b.setAttribute('role', 'checkbox'); b.setAttribute('aria-checked', 'false'); b.dataset.value = value;
5165
- b.append(el('b', '', name), el('small', '', about));
5166
- b.addEventListener('click', () => {
5167
- const on = b.getAttribute('aria-checked') !== 'true'; b.setAttribute('aria-checked', String(on));
5168
- if (!box) { salonPicked = on ? [...salonPicked, value] : salonPicked.filter((x) => x !== value); paintWelcome(); }
5169
- });
5170
- return b;
5171
- };
5172
- const paintWelcome = () => { for (const b of $('salon-new-ais').children) { const small = b.querySelector('small'); const host = salonPicked[0] === b.dataset.value; small.replaceChildren(host ? el('span', 'salon-welcome', 'Welcomes the room') : document.createTextNode(small.dataset.about ?? '')); } };
5173
- /* The same page sets a room up again (03-11, as a conversation's settings): its name, its AIs and the one that
5174
- welcomes, its boxes; and removes it. `editing`: the room, or null for a new one. */
5175
- let salonEditing = null;
5160
+ /* A NEW ROOM, or a room set up again (03-11): the one that welcomes in a box of its own at the top; below, every
5161
+ conversation on one row -- its name, the name its assistant has in its chat, its tool -- with a switch (in the
5162
+ room or not) and « Welcomes »; a search; a row dragged into the box above welcomes too. Boxes: the same rows,
5163
+ with a switch only. `editing`: the room, or null for a new one. */
5164
+ let salonIn = new Set(); let salonHost = ''; let salonBoxes = new Set(); let salonEditing = null; let salonBoxList = [];
5165
+ const salonAv = (name) => { const i = el('span', 'salon-av', (name.trim()[0] ?? '?').toUpperCase()); i.style.setProperty('--h', String(huePick(name))); return i; };
5166
+ const salonWho = (c) => [c.chatName, c.toolLabel ?? c.tool].filter(Boolean).join(' \u00b7 ') || 'AI';
5167
+ function paintSalonMembers() {
5168
+ const hostC = conversations.find((c) => c.name === salonHost);
5169
+ const box = $('salon-new-host'); box.replaceChildren();
5170
+ if (hostC) { const what = el('span', 'salon-host-what'); what.append(el('b', '', shownName(hostC)), el('small', '', `${salonWho(hostC)} \u00b7 answers, or hands the message on`)); box.append(salonAv(shownName(hostC)), what); }
5171
+ else box.append(el('small', 'hint', 'Pick one below: « Welcomes »'));
5172
+ const q = $('salon-new-search').value.trim().toLowerCase();
5173
+ const rows = conversations.filter((c) => !q || `${shownName(c)} ${c.chatName ?? ''}`.toLowerCase().includes(q)).sort((a, b) => Number(salonIn.has(b.name)) - Number(salonIn.has(a.name)));
5174
+ $('salon-new-ais').replaceChildren(...rows.map((c) => {
5175
+ const row = el('div', 'salon-member-row'); row.setAttribute('role', 'listitem'); row.draggable = true; row.dataset.name = c.name;
5176
+ const what = el('span', 'salon-member-what'); what.append(el('b', '', shownName(c)), el('small', '', salonWho(c)));
5177
+ const welcome = el('button', 'salon-welcome-btn', 'Welcomes'); welcome.type = 'button'; welcome.setAttribute('aria-pressed', String(c.name === salonHost)); welcome.setAttribute('aria-label', `${shownName(c)} welcomes the room`);
5178
+ welcome.addEventListener('click', () => { salonIn.add(c.name); salonHost = c.name; paintSalonMembers(); });
5179
+ const sw = el('button', 'salon-switch'); sw.type = 'button'; sw.setAttribute('role', 'switch'); sw.setAttribute('aria-checked', String(salonIn.has(c.name))); sw.setAttribute('aria-label', `${shownName(c)} in the room`);
5180
+ sw.addEventListener('click', () => { if (salonIn.has(c.name)) { salonIn.delete(c.name); if (salonHost === c.name) salonHost = [...salonIn][0] ?? ''; } else { salonIn.add(c.name); if (!salonHost) salonHost = c.name; } paintSalonMembers(); });
5181
+ row.append(salonAv(shownName(c)), what, welcome, sw);
5182
+ return row;
5183
+ }));
5184
+ $('salon-new-count').textContent = `\u00b7 ${salonIn.size} in the room`;
5185
+ $('salon-new-boxes').replaceChildren(...salonBoxList.map((b) => {
5186
+ const row = el('div', 'salon-member-row'); row.setAttribute('role', 'listitem');
5187
+ const what = el('span', 'salon-member-what'); what.append(el('b', '', b.name), el('small', '', b.place || 'Voice box'));
5188
+ const sw = el('button', 'salon-switch'); sw.type = 'button'; sw.setAttribute('role', 'switch'); sw.setAttribute('aria-checked', String(salonBoxes.has(b.id))); sw.setAttribute('aria-label', `${b.name} in the room`);
5189
+ sw.addEventListener('click', () => { if (salonBoxes.has(b.id)) salonBoxes.delete(b.id); else salonBoxes.add(b.id); paintSalonMembers(); });
5190
+ row.append(what, sw);
5191
+ return row;
5192
+ }));
5193
+ }
5194
+ $('salon-new-search').addEventListener('input', paintSalonMembers);
5195
+ let salonDragged = '';
5196
+ $('salon-new-ais').addEventListener('dragstart', (e) => { salonDragged = e.target.closest?.('.salon-member-row')?.dataset.name ?? ''; });
5197
+ $('salon-new-host').addEventListener('dragover', (e) => { e.preventDefault(); $('salon-new-host').classList.add('over'); });
5198
+ $('salon-new-host').addEventListener('dragleave', () => $('salon-new-host').classList.remove('over'));
5199
+ $('salon-new-host').addEventListener('drop', (e) => { e.preventDefault(); $('salon-new-host').classList.remove('over'); if (salonDragged) { salonIn.add(salonDragged); salonHost = salonDragged; paintSalonMembers(); } });
5176
5200
  async function openSalonNew(push = true, editing = null) {
5177
5201
  if (DEVICE) return;
5178
5202
  salonEditing = editing;
@@ -5181,19 +5205,13 @@
5181
5205
  $('salon-new-create').textContent = editing ? 'Save' : 'Create';
5182
5206
  $('salon-new-remove-card').hidden = !editing;
5183
5207
  $('salon-new-remove').hidden = false; $('salon-new-remove-card').querySelector('.confirm')?.remove();
5184
- $('salon-new-error').hidden = true; $('salon-new-name').value = editing?.name ?? '';
5185
- const host = editing?.members.find((m) => m.host)?.ref;
5186
- salonPicked = editing ? [host, ...editing.members.filter((m) => m.kind === 'ai' && m.ref !== host).map((m) => m.ref)].filter(Boolean) : [];
5187
- $('salon-new-ais').replaceChildren(...conversations.map((c) => { const t = salonTile(c.name, shownName(c), [c.chatName, c.toolLabel ?? c.tool].filter(Boolean).join(' \u00b7 ') || 'AI'); t.querySelector('small').dataset.about = t.querySelector('small').textContent; return t; }));
5188
- let boxes = []; try { const x = await fetch(`${API}/boxes`); boxes = x.ok ? await x.json() : []; } catch { boxes = []; }
5189
- $('salon-new-boxes-card').hidden = boxes.length === 0;
5190
- $('salon-new-boxes').replaceChildren(...boxes.map((b) => salonTile(b.id, b.name, b.place || 'Voice box', true)));
5191
- if (editing) {
5192
- for (const t of $('salon-new-ais').children) if (salonPicked.includes(t.dataset.value)) t.setAttribute('aria-checked', 'true');
5193
- const mine = editing.members.filter((m) => m.kind === 'box').map((m) => m.ref);
5194
- for (const t of $('salon-new-boxes').children) if (mine.includes(t.dataset.value)) t.setAttribute('aria-checked', 'true');
5195
- paintWelcome();
5196
- }
5208
+ $('salon-new-error').hidden = true; $('salon-new-name').value = editing?.name ?? ''; $('salon-new-search').value = '';
5209
+ salonIn = new Set(editing ? editing.members.filter((m) => m.kind === 'ai').map((m) => m.ref) : []);
5210
+ salonHost = editing?.members.find((m) => m.host)?.ref ?? '';
5211
+ salonBoxes = new Set(editing ? editing.members.filter((m) => m.kind === 'box').map((m) => m.ref) : []);
5212
+ try { const x = await fetch(`${API}/boxes`); salonBoxList = x.ok ? await x.json() : []; } catch { salonBoxList = []; }
5213
+ $('salon-new-boxes-card').hidden = salonBoxList.length === 0;
5214
+ paintSalonMembers();
5197
5215
  $('salon-new-name').focus();
5198
5216
  }
5199
5217
  $('salon-settings').addEventListener('click', async () => { await loadRooms(); const r = rooms.find((x) => x.id === salonId); if (r) await openSalonNew(true, r); });
@@ -5211,20 +5229,21 @@
5211
5229
  $('salon-new-close').addEventListener('click', salonNewBack);
5212
5230
  $('salon-new-cancel').addEventListener('click', salonNewBack);
5213
5231
  $('salon-new-create').addEventListener('click', async () => {
5214
- const boxes = [...$('salon-new-boxes').querySelectorAll('[aria-checked="true"]')].map((b) => b.dataset.value);
5232
+ const picked = [salonHost, ...[...salonIn].filter((c) => c !== salonHost)].filter(Boolean);
5233
+ const boxes = [...salonBoxes];
5215
5234
  try {
5216
- /* Set up again: what is ticked now -- members added, those unticked taken out, the first one picked welcomes. */
5235
+ /* Set up again: what is switched on now -- members added, those switched off taken out, the one that welcomes. */
5217
5236
  if (salonEditing) {
5218
5237
  const r = salonEditing;
5219
5238
  const ais = r.members.filter((m) => m.kind === 'ai'); const had = r.members.filter((m) => m.kind === 'box');
5220
- const add = { conversations: salonPicked.filter((c) => !ais.some((m) => m.ref === c)), boxes: boxes.filter((b) => !had.some((m) => m.ref === b)) };
5221
- const remove = [...ais.filter((m) => !salonPicked.includes(m.ref)), ...had.filter((m) => !boxes.includes(m.ref))].map((m) => m.id);
5239
+ const add = { conversations: picked.filter((c) => !ais.some((m) => m.ref === c)), boxes: boxes.filter((b) => !had.some((m) => m.ref === b)) };
5240
+ const remove = [...ais.filter((m) => !salonIn.has(m.ref)), ...had.filter((m) => !salonBoxes.has(m.ref))].map((m) => m.id);
5222
5241
  let now = await post(`${API}/rooms/${r.id}`, { name: $('salon-new-name').value, add, remove });
5223
- const host = now.members.find((m) => m.kind === 'ai' && m.ref === salonPicked[0]);
5242
+ const host = now.members.find((m) => m.kind === 'ai' && m.ref === salonHost);
5224
5243
  if (host && !host.host) now = await post(`${API}/rooms/${r.id}`, { host: host.id });
5225
5244
  salonEditing = null; await openSalon(r.id, false); return;
5226
5245
  }
5227
- const made = await post(`${API}/rooms`, { name: $('salon-new-name').value, conversations: salonPicked, boxes, host: salonPicked[0] });
5246
+ const made = await post(`${API}/rooms`, { name: $('salon-new-name').value, conversations: picked, boxes, host: salonHost });
5228
5247
  await openSalon(made.id, false);
5229
5248
  } catch (error) { $('salon-new-error').textContent = error.message; $('salon-new-error').hidden = false; }
5230
5249
  });
package/web/index.html CHANGED
@@ -665,13 +665,18 @@
665
665
  <div class="set-row"><div class="set-what"><label for="salon-new-name">Name</label><small>Shown on its card. Can be changed</small></div><div class="set-control"><input id="salon-new-name" maxlength="60" placeholder="Home" spellcheck="false" autocomplete="off"></div></div>
666
666
  </div>
667
667
  <div class="nc-card">
668
- <span class="sub-head">AIs</span>
669
- <div id="salon-new-ais" class="pick" role="group" aria-label="AIs"></div>
670
- <small class="hint">The first one picked welcomes the room: it answers, or hands the message on.</small>
668
+ <span class="sub-head">Welcomes the room</span>
669
+ <div id="salon-new-host" class="salon-host-box" aria-live="polite"></div>
670
+ </div>
671
+ <div class="nc-card">
672
+ <span class="sub-head">Its AIs <span id="salon-new-count" class="hint"></span></span>
673
+ <div class="salon-members-tools"><input id="salon-new-search" type="search" placeholder="Find a conversation" aria-label="Find a conversation" autocomplete="off"></div>
674
+ <div id="salon-new-ais" class="salon-member-list" role="list" aria-label="AIs"></div>
675
+ <small class="hint">The switch puts it in the room or takes it out; « Welcomes » makes it the one that answers, or hands the message on. On a computer, a row can also be dragged into the box above.</small>
671
676
  </div>
672
677
  <div class="nc-card" id="salon-new-boxes-card">
673
678
  <span class="sub-head">Voice boxes</span>
674
- <div id="salon-new-boxes" class="pick" role="group" aria-label="Voice boxes"></div>
679
+ <div id="salon-new-boxes" class="salon-member-list" role="list" aria-label="Voice boxes"></div>
675
680
  </div>
676
681
  <div class="nc-card" id="salon-new-remove-card" hidden>
677
682
  <div class="set-row"><div class="set-what"><label>Remove the room</label><small>Its thread goes. Its AIs and boxes stay, each with its own chat</small></div><div class="set-control"><button type="button" id="salon-new-remove" class="danger">Remove…</button></div></div>
package/web/style.css CHANGED
@@ -2253,3 +2253,27 @@ body.as-dragging #assets-rows .as-row { touch-action: none; }
2253
2253
  .salon-bar { display: flex; align-items: center; gap: 8px; padding: 0 8px 0 0; }
2254
2254
  .salon-bar .salon-who { flex: 1; }
2255
2255
  #salon-new-remove-card .confirm { display: inline-flex; gap: 6px; flex-wrap: wrap; }
2256
+
2257
+ /* A ROOM'S MEMBERS (03-11): the one that welcomes in a box of its own; every conversation on a row, its switch. */
2258
+ .salon-host-box { display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 8px 12px; border: 1px solid var(--brass); border-radius: 10px; background: color-mix(in srgb, var(--brass) 10%, var(--panel)); transition: background .15s; }
2259
+ .salon-host-box.over { background: color-mix(in srgb, var(--brass) 22%, var(--panel)); }
2260
+ .salon-host-what, .salon-member-what { flex: 1; min-width: 0; display: flex; flex-direction: column; }
2261
+ .salon-host-what b, .salon-member-what b { font-weight: 600; font-size: .8125rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
2262
+ .salon-host-what small, .salon-member-what small { color: var(--ink2); font-size: .75rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
2263
+ .salon-av { width: 28px; height: 28px; border-radius: 7px; display: grid; place-items: center; flex: none; color: #fff; font: 600 .8125rem/1 var(--sans); background: hsl(var(--h, 210) 40% 38%); }
2264
+ .salon-members-tools input { width: 100%; }
2265
+ .salon-member-list { display: flex; flex-direction: column; max-height: 22rem; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); padding: 0 !important; }
2266
+ .salon-member-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; min-height: 48px; border-top: 1px solid var(--line); }
2267
+ .salon-member-row:first-child { border-top: 0; }
2268
+ .salon-member-row[draggable="true"] { cursor: grab; }
2269
+ button.salon-welcome-btn { border-radius: 999px; padding: 4px 10px; font-size: .75rem; min-height: 32px; background: transparent; color: var(--ink2); }
2270
+ button.salon-welcome-btn[aria-pressed="true"] { color: var(--brass-ink); border-color: var(--brass); background: color-mix(in srgb, var(--brass) 14%, transparent); }
2271
+ button.salon-switch { position: relative; width: 40px; height: 24px; min-height: 0; flex: none; padding: 0; border-radius: 999px; background: var(--bg); }
2272
+ button.salon-switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--ink2); transition: left .15s, background .15s; }
2273
+ button.salon-switch[aria-checked="true"] { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 25%, var(--bg)); }
2274
+ button.salon-switch[aria-checked="true"]::after { left: 18px; background: var(--ok); }
2275
+ @media (max-width: 700px) { button.salon-switch { min-height: 0; } }
2276
+ .nc-card > .salon-host-box, .nc-card > .salon-member-list { margin: 4px 16px 12px; }
2277
+ .nc-card > .salon-host-box { padding: 8px 12px; }
2278
+ .nc-card > .salon-members-tools { padding-bottom: 4px; }
2279
+ .nc-card > .salon-host-box + *, .nc-card > .salon-member-list + * { border-top: 0; }