clavarium 0.2.8-next.1 → 0.2.9-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/server/events.mjs +1 -1
- package/server/talk.mjs +7 -1
- package/web/app.js +26 -9
- package/web/style.css +9 -1
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.9-next.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "clavarium",
|
|
9
|
-
"version": "0.2.
|
|
9
|
+
"version": "0.2.9-next.1",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
package/package.json
CHANGED
package/server/events.mjs
CHANGED
|
@@ -53,7 +53,7 @@ const SAID = [
|
|
|
53
53
|
[/^\/api\/machines\/prepare$/, 'server', (m, b) => `Disk ${clip(b.path, 40)} erased and prepared for the machines`],
|
|
54
54
|
[/^\/api\/machines\/mount$/, 'server', (m, b) => `Disk ${clip(b.path, 40)} mounted`],
|
|
55
55
|
[/^\/api\/machines\/forget-old$/, 'server', () => 'The old copy of the machines removed'],
|
|
56
|
-
[/^\/api\/instance$/, 'server', (m, b) => `This Clavarium named "${clip(b.name, 40)}"`],
|
|
56
|
+
[/^\/api\/instance$/, 'server', (m, b) => (String(b.name ?? '').trim() ? `This Clavarium named "${clip(b.name, 40)}"` : 'This Clavarium given back the name drawn from its address')],
|
|
57
57
|
[/^\/api\/operators$/, 'sign-in', (m, b) => `Administrator ${clip(b.email, 80)} added`],
|
|
58
58
|
[/^\/api\/operators\/([^/]+)\/(password|disable|enable|remove)$/, 'sign-in', (m) => `Administrator ${clip(decodeURIComponent(m[1]), 80)}: ${{ password: 'new password', disable: 'disabled', enable: 'enabled', remove: 'removed' }[m[2]]}`],
|
|
59
59
|
[/^\/api\/setup\/import$/, 'conversation', () => 'A setup imported from a file'],
|
package/server/talk.mjs
CHANGED
|
@@ -269,7 +269,13 @@ export class Talk {
|
|
|
269
269
|
const now = this.#parley(name).read();
|
|
270
270
|
/* Its last message, either way: the list says when it last spoke, and what (app.js, Recent). */
|
|
271
271
|
const last = (now.messages ?? []).filter((m) => m.kind !== 'doing').at(-1);
|
|
272
|
-
|
|
272
|
+
/* IT NEEDS ITS OWNER only if it asked, or said it waits, AFTER the owner last wrote: answered (with
|
|
273
|
+
the buttons or in a message of one's own), the turn is the tool's again. */
|
|
274
|
+
const messages = now.messages ?? [];
|
|
275
|
+
const personAt = messages.filter((m) => m.from === 'person').map((m) => m.at).sort().at(-1) ?? '';
|
|
276
|
+
const askedAt = messages.filter((m) => m.from !== 'person' && m.kind === 'ask' && !m.closed).map((m) => m.at).sort().at(-1) ?? '';
|
|
277
|
+
const needs = (now.waiting > 0 && askedAt > personAt) || (now.status?.state === 'waiting' && String(now.status.at ?? '') > personAt);
|
|
278
|
+
return { waiting: now.waiting, state: now.status?.state ?? null, needs, ...(last ? { lastAt: last.at, lastFrom: last.from === 'person' ? 'person' : 'agent', lastText: String(last.short || last.text || '').replace(/\s+/g, ' ').trim().slice(0, 90) } : {}) };
|
|
273
279
|
} catch { return { waiting: 0, state: null }; }
|
|
274
280
|
}
|
|
275
281
|
|
package/web/app.js
CHANGED
|
@@ -853,7 +853,9 @@
|
|
|
853
853
|
/* The name a person reads; a conversation made before free names is read by its identifier. */
|
|
854
854
|
const shownName = (c) => (c && typeof c.title === 'string' && c.title ? c.title : c?.name ?? '');
|
|
855
855
|
/* It needs its owner: it asks or waits, its answerer asks, it failed, its machine is unwell. Said even when it is hidden. */
|
|
856
|
-
|
|
856
|
+
/* Its tool asks or waits for its owner, and the owner has not written since (talk.mjs, brief). */
|
|
857
|
+
const talkNeeds = (c) => Boolean(c.talk && (c.talk.needs ?? (c.talk.waiting > 0 || c.talk.state === 'waiting')));
|
|
858
|
+
const needsYou = (c) => Boolean(talkNeeds(c) || c.answerer?.needs || c.phase === 'failed'
|
|
857
859
|
|| (c.phase === 'ready' && !c.asleep && ['warn', 'bad'].includes(c.health?.level)));
|
|
858
860
|
/* Hidden conversations are shown on a click on "N hidden", for this page only. */
|
|
859
861
|
let showHidden = false;
|
|
@@ -921,7 +923,7 @@
|
|
|
921
923
|
const waking = (c.wakeups?.items ?? []).filter((w) => w.on).length;
|
|
922
924
|
if (waking > 0) { const mark = document.createElement('small'); mark.className = 'shared-mark'; mark.textContent = `${waking} wake-up${waking > 1 ? 's' : ''}`; b.append(mark); }
|
|
923
925
|
/* It talks through the app, and asks or waits for its owner there. */
|
|
924
|
-
if (
|
|
926
|
+
if (talkNeeds(c)) { const mark = document.createElement('small'); mark.className = 'needs-mark'; mark.textContent = c.talk.waiting > 0 ? 'asks you' : 'waits for you'; b.append(mark); }
|
|
925
927
|
if (c.answerer?.on) { const mark = document.createElement('small'); mark.className = c.answerer.needs ? 'needs-mark' : 'shared-mark'; mark.textContent = c.answerer.needs ? 'asks for you' : 'answered in your place'; b.append(mark); }
|
|
926
928
|
/* Seen at a glance: this conversation is in other hands too. */
|
|
927
929
|
const holders = sharedDevices.filter((d) => d.grants.some((g) => g.asset === `conversation:${c.name}`)).length;
|
|
@@ -931,6 +933,8 @@
|
|
|
931
933
|
}
|
|
932
934
|
/* `label`: the name shown; the conversations in no group are one of their own ("Not filed", key NONE). */
|
|
933
935
|
const NONE = '\u0000none';
|
|
936
|
+
/* The two sections above the groups, folded or not like a group (never a group's name: those are plain words). */
|
|
937
|
+
const NEEDS = '\u0001needs'; const RECENT = '\u0001recent';
|
|
934
938
|
function groupBox(g, inside, all, open, label = g) {
|
|
935
939
|
const box = document.createElement('div'); box.className = 'group'; box.dataset.group = g === NONE ? '' : g;
|
|
936
940
|
const head = document.createElement('button'); head.type = 'button'; head.className = 'group-head'; head.dataset.group = g === NONE ? '' : g;
|
|
@@ -968,18 +972,31 @@
|
|
|
968
972
|
/* A search: everything found, in its place. */
|
|
969
973
|
items.append(...shown.filter((c) => !c.group).map((c) => itemButton(c)));
|
|
970
974
|
} else {
|
|
975
|
+
/* A section that folds: open at first, folded or not on this device as its owner leaves it. */
|
|
976
|
+
const section = (key, label, count) => {
|
|
977
|
+
const open = !folded.has(key);
|
|
978
|
+
const b = document.createElement('button'); b.type = 'button'; b.className = 'list-head list-fold'; b.dataset.section = key === NEEDS ? 'needs' : 'recent';
|
|
979
|
+
b.setAttribute('aria-expanded', String(open));
|
|
980
|
+
const chevron = document.createElement('span'); chevron.className = 'list-chevron'; chevron.setAttribute('aria-hidden', 'true'); chevron.textContent = open ? '\u25BE' : '\u25B8';
|
|
981
|
+
/* How many, only when folded: open, its rows (and "Show more") say it. */
|
|
982
|
+
b.append(chevron, document.createTextNode(label));
|
|
983
|
+
if (!open) { const n = document.createElement('span'); n.className = 'list-count'; n.textContent = String(count); b.append(n); }
|
|
984
|
+
b.addEventListener('click', () => { if (folded.has(key)) folded.delete(key); else folded.add(key); keepFolded(); paint(); });
|
|
985
|
+
top.append(b);
|
|
986
|
+
return open;
|
|
987
|
+
};
|
|
971
988
|
/* NEEDS YOU: whatever its date, until its owner acts; hidden ones too (they said so). */
|
|
972
989
|
const needs = conversations.filter(needsYou).sort((a, b) => activityOf(b) - activityOf(a));
|
|
973
|
-
if (needs.length
|
|
974
|
-
/* RECENT: by when it was last used;
|
|
975
|
-
groups: before, the one list below says the same, in the order chosen by hand. */
|
|
990
|
+
if (needs.length && section(NEEDS, 'Needs you', needs.length)) top.append(...needs.map((c) => itemButton(c, true)));
|
|
991
|
+
/* RECENT: by when it was last used; the last four, then all. Never a hidden one. Only once there
|
|
992
|
+
are groups: before, the one list below says the same, in the order chosen by hand. */
|
|
976
993
|
const recent = conversations.filter((c) => c.hidden !== true || c.name === current).sort((a, b) => activityOf(b) - activityOf(a));
|
|
977
|
-
const few =
|
|
978
|
-
if (recent.length && groups.length) {
|
|
979
|
-
top.append(
|
|
994
|
+
const few = 4;
|
|
995
|
+
if (recent.length && groups.length && section(RECENT, 'Recent', recent.length)) {
|
|
996
|
+
top.append(...recent.slice(0, showAllRecent ? recent.length : few).map((c) => itemButton(c, true)));
|
|
980
997
|
if (recent.length > few) {
|
|
981
998
|
const more = document.createElement('button'); more.type = 'button'; more.className = 'inline more-recent';
|
|
982
|
-
more.textContent = showAllRecent ? 'Show fewer' : `Show
|
|
999
|
+
more.textContent = showAllRecent ? 'Show fewer' : `Show more (${recent.length - few})`;
|
|
983
1000
|
more.addEventListener('click', () => { showAllRecent = !showAllRecent; paint(); });
|
|
984
1001
|
top.append(more);
|
|
985
1002
|
}
|
package/web/style.css
CHANGED
|
@@ -294,7 +294,10 @@ footer button.careful { border-style: dashed; color: var(--ink2); }
|
|
|
294
294
|
.given > .parts-off { color: var(--warn); margin: 6px 0 2px; font-size: .8125rem; }
|
|
295
295
|
|
|
296
296
|
/* The left column: conversations, then the platform's three entries, always in sight. */
|
|
297
|
-
|
|
297
|
+
/* One scroll for the whole list (#list): never a box scrolled on its own inside it. */
|
|
298
|
+
#list #items { flex: 0 0 auto; display: flex; flex-direction: column; gap: 8px; }
|
|
299
|
+
/* The gauge, when shown: at the bottom of the list, and kept in sight while it scrolls. */
|
|
300
|
+
#list #server-gauge { margin-top: auto; position: sticky; bottom: 0; z-index: 1; }
|
|
298
301
|
/* Assets: one row per thing; opened, it says who may do what with it. */
|
|
299
302
|
#assets section { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
|
|
300
303
|
#assets section .panel-top small { margin-left: 8px; }
|
|
@@ -1337,3 +1340,8 @@ select.pill { appearance: auto; }
|
|
|
1337
1340
|
@media (max-width: 600px) { .event { grid-template-columns: 1fr auto; } .event-text, .event-who { grid-column: 1 / -1; } }
|
|
1338
1341
|
/* The choices of Logs and What happened: as wide as their words, in the colours of the page. */
|
|
1339
1342
|
.events-pick select, .logs-pick select { width: auto; max-width: 100%; background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; }
|
|
1343
|
+
/* Needs you and Recent: a heading that folds its rows, with how many it holds. */
|
|
1344
|
+
.list-fold { display: flex; align-items: center; gap: 6px; width: 100%; background: none; border: 0; padding: 2px; cursor: pointer; text-align: left; font: inherit; font-size: .78rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink2); }
|
|
1345
|
+
.list-fold:hover { color: var(--ink); }
|
|
1346
|
+
.list-chevron { width: 1em; text-align: center; }
|
|
1347
|
+
.list-count { margin-left: auto; font-weight: 400; letter-spacing: 0; font-variant-numeric: tabular-nums; }
|