clavarium 0.2.11 → 0.2.12-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/npm-shrinkwrap.json +6 -6
- package/package.json +2 -2
- package/server/bridge.mjs +7 -1
- package/server/health.mjs +3 -3
- package/server/talk.mjs +6 -2
- package/web/app.js +67 -33
- package/web/style.css +18 -7
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.12-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.12-next.1",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
|
13
13
|
"@xterm/xterm": "^6.0.0",
|
|
14
|
-
"clavarium-parley": "0.10.
|
|
14
|
+
"clavarium-parley": "0.10.2-next.2",
|
|
15
15
|
"mermaid": "11.17.2",
|
|
16
16
|
"node-pty": "^1.1.0",
|
|
17
17
|
"pdfjs-dist": "6.4.299",
|
|
@@ -686,9 +686,9 @@
|
|
|
686
686
|
}
|
|
687
687
|
},
|
|
688
688
|
"node_modules/clavarium-parley": {
|
|
689
|
-
"version": "0.10.
|
|
690
|
-
"resolved": "https://registry.npmjs.org/clavarium-parley/-/clavarium-parley-0.10.
|
|
691
|
-
"integrity": "sha512-
|
|
689
|
+
"version": "0.10.2-next.2",
|
|
690
|
+
"resolved": "https://registry.npmjs.org/clavarium-parley/-/clavarium-parley-0.10.2-next.2.tgz",
|
|
691
|
+
"integrity": "sha512-ieFUUASNSZCYg3eo9jRzbndV3raLQS5O06BZg2fY6OWxpfa3yAyvvkjEm+ZvuFberjLQgKzCNO4fpmqRD/8iqQ==",
|
|
692
692
|
"license": "MIT",
|
|
693
693
|
"bin": {
|
|
694
694
|
"parley": "bin/parley.mjs",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.12-next.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "A conversation is a VM with a terminal in it. Everything else is a folder.",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@xterm/addon-fit": "^0.11.0",
|
|
46
46
|
"@xterm/xterm": "^6.0.0",
|
|
47
|
-
"clavarium-parley": "0.10.
|
|
47
|
+
"clavarium-parley": "0.10.2-next.2",
|
|
48
48
|
"mermaid": "11.17.2",
|
|
49
49
|
"node-pty": "^1.1.0",
|
|
50
50
|
"pdfjs-dist": "6.4.299",
|
package/server/bridge.mjs
CHANGED
|
@@ -81,6 +81,12 @@ export const sameOrigin = makeOriginCheck();
|
|
|
81
81
|
still running, in which case only the channel dropped; `onRejoin(name)`
|
|
82
82
|
when a screen takes a terminal that was already open. `originOk` and
|
|
83
83
|
`gate` decide who may attach at all: see gate.mjs. */
|
|
84
|
+
/* WHAT A TERMINAL SAYS BY ITSELF, shown on a screen: the focus coming and going, its answers to the
|
|
85
|
+
program asking what it is, where its cursor is, which colours it has. Sent like keys, they are no
|
|
86
|
+
one typing: never "used just now" (a conversation nobody touched rose in Recent with them). */
|
|
87
|
+
const BY_ITSELF = /\x1b\[[IO]|\x1b\[\??[>=]?[\d;]*c|\x1b\[\d+;\d+R|\x1b\][\d;]*(?:rgb:[0-9a-fA-F/]+)?(?:\x07|\x1b\\)|\x1bP[^\x1b]*\x1b\\/g;
|
|
88
|
+
export const byHand = (typed) => String(typed ?? '').replace(BY_ITSELF, '').length > 0;
|
|
89
|
+
|
|
84
90
|
export function attachBridge(server, { spawn, onLeft = () => {}, onEnded = () => {}, originOk = sameOrigin, gate = () => 'local', deviceName = () => undefined, onRejoin = () => {}, onTyped = () => {} }) {
|
|
85
91
|
const sockets = new WebSocketServer({ noServer: true });
|
|
86
92
|
const seats = new Seats();
|
|
@@ -265,7 +271,7 @@ export function attachBridge(server, { spawn, onLeft = () => {}, onEnded = () =>
|
|
|
265
271
|
a tmux command, not by the tool. A line of this server is
|
|
266
272
|
then not typed through this channel for a while (`type`). */
|
|
267
273
|
if (typed.includes(PREFIX)) mine.prefixAt = Date.now();
|
|
268
|
-
mine.terminal.write(typed); onTyped(name, typed); return;
|
|
274
|
+
mine.terminal.write(typed); if (byHand(typed)) onTyped(name, typed); return;
|
|
269
275
|
}
|
|
270
276
|
let message;
|
|
271
277
|
try { message = JSON.parse(data.toString()); } catch { return; }
|
package/server/health.mjs
CHANGED
|
@@ -135,13 +135,13 @@ export class Health {
|
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
/* The last thing known, or null. Cheap: nothing is asked. */
|
|
138
|
-
of(name) { const r = this.#records.get(name); return r ? { ...r, seen:
|
|
138
|
+
of(name) { const r = this.#records.get(name); const seen = this.#seen?.get(name); return r ? { ...r, seen: seen?.keys ?? [], ...(seen?.at ? { seenAt: seen.at } : {}) } : null; }
|
|
139
139
|
/* "Seen": what it says now no longer calls its owner (Needs you); a problem of another kind, or one
|
|
140
140
|
that comes back after it went away, does. */
|
|
141
141
|
markSeen(name) {
|
|
142
142
|
const r = this.#records.get(name);
|
|
143
143
|
const keys = (r?.problems ?? []).filter((p) => p.level === 'warn' || p.level === 'bad').map((p) => p.key);
|
|
144
|
-
this.#seen?.put({ name, keys });
|
|
144
|
+
this.#seen?.put({ name, keys, at: new Date().toISOString() });
|
|
145
145
|
return this.of(name);
|
|
146
146
|
}
|
|
147
147
|
forget(name) { this.#records.delete(name); this.#quiet.delete(name); this.#seen?.remove?.(name); }
|
|
@@ -217,7 +217,7 @@ export class Health {
|
|
|
217
217
|
const kept = { ...record, ...judge(record) };
|
|
218
218
|
/* What was marked seen and is gone is forgotten: back later, it calls its owner again. */
|
|
219
219
|
const seen = this.#seen?.get(name);
|
|
220
|
-
if (seen && record.state === 'Running' && record.answering === true) { const still = seen.keys.filter((k) => kept.problems.some((p) => p.key === k)); if (still.length !== seen.keys.length) this.#seen.put({
|
|
220
|
+
if (seen && record.state === 'Running' && record.answering === true) { const still = seen.keys.filter((k) => kept.problems.some((p) => p.key === k)); if (still.length !== seen.keys.length) this.#seen.put(still.length ? { ...seen, keys: still } : { name, keys: [] }); }
|
|
221
221
|
this.#records.set(name, kept);
|
|
222
222
|
try { this.judged(name, kept); } catch { /* told, nothing more */ }
|
|
223
223
|
return kept;
|
package/server/talk.mjs
CHANGED
|
@@ -268,14 +268,18 @@ export class Talk {
|
|
|
268
268
|
try {
|
|
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
|
+
/* What the person or the tool said -- never a line of this server (a restart, a machine put to sleep):
|
|
272
|
+
those are no one using it, and would lift it in Recent. */
|
|
273
|
+
const last = (now.messages ?? []).filter((m) => m.kind !== 'doing' && (m.from === 'person' || m.from === 'agent')).at(-1);
|
|
272
274
|
/* IT NEEDS ITS OWNER only if it asked, or said it waits, AFTER the owner last wrote: answered (with
|
|
273
275
|
the buttons or in a message of one's own), the turn is the tool's again. */
|
|
274
276
|
const messages = now.messages ?? [];
|
|
275
277
|
const personAt = messages.filter((m) => m.from === 'person').map((m) => m.at).sort().at(-1) ?? '';
|
|
276
278
|
const askedAt = messages.filter((m) => m.from !== 'person' && m.kind === 'ask' && !m.closed).map((m) => m.at).sort().at(-1) ?? '';
|
|
277
279
|
const needs = (now.waiting > 0 && askedAt > personAt) || (now.status?.state === 'waiting' && String(now.status.at ?? '') > personAt);
|
|
278
|
-
|
|
280
|
+
/* What it said it does (status, doing): it is at work, even without a message. */
|
|
281
|
+
const stepAt = (now.steps ?? []).map((m) => m.at).sort().at(-1) ?? null;
|
|
282
|
+
return { waiting: now.waiting, state: now.status?.state ?? null, needs, ...(stepAt ? { stepAt } : {}), ...(last ? { lastAt: last.at, lastFrom: last.from === 'person' ? 'person' : 'agent', lastText: String(last.short || last.text || '').replace(/\s+/g, ' ').trim().slice(0, 90) } : {}) };
|
|
279
283
|
} catch { return { waiting: 0, state: null }; }
|
|
280
284
|
}
|
|
281
285
|
|
package/web/app.js
CHANGED
|
@@ -890,6 +890,30 @@
|
|
|
890
890
|
full -- not marked "Seen"; a program stopped for lack of memory (its files safe) is only said. */
|
|
891
891
|
const healthNeeds = (c) => c.phase === 'ready' && !c.asleep && (c.health?.problems ?? []).some((p) => (p.level === 'bad' || (p.level === 'warn' && ['memory', 'disk'].includes(p.kind) && !String(p.key).startsWith('oom:'))) && !(c.health.seen ?? []).includes(p.key));
|
|
892
892
|
const needsYou = (c) => Boolean(talkNeeds(c) || c.answerer?.needs || c.phase === 'failed' || healthNeeds(c));
|
|
893
|
+
/* ONE STATE PER CONVERSATION, one point for it: it needs you (red), something to watch (yellow: being built,
|
|
894
|
+
restarted, moved), fine (green), asleep (a hollow ring). */
|
|
895
|
+
const STATE_WORDS = { need: 'needs you', watch: 'to watch', ok: 'fine', sleep: 'asleep' };
|
|
896
|
+
const stateOf = (c) => (needsYou(c) ? 'need' : c.asleep ? 'sleep' : holds(c) || ['building', 'restarting', 'moving'].includes(c.phase) ? 'watch' : 'ok');
|
|
897
|
+
const statePoint = (state) => { const d = document.createElement('span'); d.className = 'state-dot'; d.dataset.state = state; return d; };
|
|
898
|
+
/* Folded, a heading says how its conversations are: at most four points, shared out like them -- every state
|
|
899
|
+
there keeps at least one, the worst first -- and the same in words for a screen reader and the pointer. */
|
|
900
|
+
const STATE_ORDER = ['need', 'watch', 'ok', 'sleep'];
|
|
901
|
+
function stateSummary(list) {
|
|
902
|
+
const count = Object.fromEntries(STATE_ORDER.map((k) => [k, 0]));
|
|
903
|
+
for (const c of list) count[stateOf(c)] += 1;
|
|
904
|
+
const slots = Math.min(4, list.length);
|
|
905
|
+
const present = STATE_ORDER.filter((k) => count[k] > 0);
|
|
906
|
+
const got = Object.fromEntries(STATE_ORDER.map((k) => [k, 0]));
|
|
907
|
+
for (const k of present.slice(0, slots)) got[k] = 1;
|
|
908
|
+
for (let left = slots - Math.min(slots, present.length); left > 0; left -= 1) {
|
|
909
|
+
const k = [...present].sort((a, b) => (count[b] / (got[b] + 1)) - (count[a] / (got[a] + 1)))[0]; got[k] += 1;
|
|
910
|
+
}
|
|
911
|
+
const box = document.createElement('span'); box.className = 'state-sum'; box.setAttribute('role', 'img');
|
|
912
|
+
for (const k of STATE_ORDER) for (let i = 0; i < got[k]; i += 1) box.append(statePoint(k));
|
|
913
|
+
const words = present.map((k) => `${count[k]} ${STATE_WORDS[k]}`).join(', ') || 'none';
|
|
914
|
+
box.setAttribute('aria-label', words); box.title = words;
|
|
915
|
+
return box;
|
|
916
|
+
}
|
|
893
917
|
/* Hidden conversations are shown on a click on "N hidden", for this page only. */
|
|
894
918
|
let showHidden = false;
|
|
895
919
|
/* Recent: a few, or all of them (for this page only). */
|
|
@@ -912,8 +936,9 @@
|
|
|
912
936
|
const matches = (c) => [shownName(c), c.name, c.group, c.toolLabel].some((x) => plain(x).includes(plain(query)));
|
|
913
937
|
const byRank = (a, b) => (a.rank ?? 0) - (b.rank ?? 0);
|
|
914
938
|
const groupsInOrder = () => [...new Set(conversations.filter((c) => c.group).sort((a, b) => (a.groupRank ?? 0) - (b.groupRank ?? 0)).map((c) => c.group))];
|
|
915
|
-
/* WHEN IT WAS LAST USED:
|
|
916
|
-
|
|
939
|
+
/* WHEN IT WAS LAST USED: what was said in its chat, and what its agent said it does (Parley) -- never what
|
|
940
|
+
its terminal shows. A tool with no chat (a plain terminal): the keys typed in it by hand. */
|
|
941
|
+
const activityOf = (c) => Math.max(...[c.talk?.lastAt, c.talk?.stepAt, c.talk ? null : c.lastActiveAt, c.createdAt].map((x) => (x ? new Date(x).getTime() : 0)));
|
|
917
942
|
const whenWords = (t) => {
|
|
918
943
|
if (!t) return '';
|
|
919
944
|
const d = new Date(t); const now = new Date();
|
|
@@ -932,24 +957,29 @@
|
|
|
932
957
|
if (holds(c)) b.dataset.busy = 'true';
|
|
933
958
|
if (c.name === current) b.setAttribute('aria-current', 'true');
|
|
934
959
|
const title = document.createElement('b');
|
|
935
|
-
|
|
936
|
-
title.append(dot, shownName(c));
|
|
960
|
+
title.append(shownName(c));
|
|
937
961
|
if (c.title) b.title = c.name;
|
|
938
962
|
if (c.hidden === true) b.dataset.hidden = 'true';
|
|
939
963
|
const sub = document.createElement('small');
|
|
940
964
|
/* Under way: the step the panel shows, in its words (the tool named once). */
|
|
941
965
|
const under = c.progress && ['building', 'restarting', 'ready'].includes(c.phase) ? stepNow(c.progress, c.toolLabel) : '';
|
|
942
|
-
|
|
966
|
+
/* What it is doing, when it says something: its tool is not named on every row. */
|
|
967
|
+
sub.textContent = under || (holds(c) && c.phase !== 'building' ? (c.progress.kind === 'build' ? 'starting' : 'restarting') : c.phase === 'ready' ? (c.asleep ? 'asleep, wakes when opened' : '') : c.phase === 'building' ? (c.step ?? 'building') : c.phase === 'moving' ? 'moving its work' : c.phase === 'restarting' ? 'restarting' : 'failed');
|
|
943
968
|
if (c.asleep) b.dataset.asleep = 'true';
|
|
969
|
+
/* The line of its tool only when it says something: under way, asleep, failed -- not "Claude Code" again and again. */
|
|
970
|
+
const plain = c.phase === 'ready' && !c.asleep && !under && !holds(c);
|
|
944
971
|
if (told) {
|
|
945
972
|
/* In words, not a symbol: what a tap on it will do. */
|
|
946
|
-
if (c.asleep) sub.textContent = `${c.toolLabel} - asleep, wakes when opened`;
|
|
947
973
|
/* Beside its name, never in it: the name reads (and is read) as it is. */
|
|
948
974
|
const when = document.createElement('small'); when.className = 'when'; when.textContent = whenWords(activityOf(c));
|
|
949
|
-
|
|
950
|
-
|
|
975
|
+
b.append(title);
|
|
976
|
+
/* Its last message, and who said it: so it reads as the last message, not as a subject. */
|
|
977
|
+
if (c.talk?.lastText) { const last = document.createElement('small'); last.className = 'last'; const who = c.talk.lastFrom === 'person' ? 'You' : (c.chatName || (c.ai ? 'Agent' : c.toolLabel)); last.textContent = `${who}: ${c.talk.lastText}`; b.append(last); }
|
|
978
|
+
if (!plain) b.append(sub);
|
|
951
979
|
b.append(when); b.dataset.when = 'true';
|
|
952
|
-
} else b.append(title, sub);
|
|
980
|
+
} else b.append(title, ...(plain ? [] : [sub]));
|
|
981
|
+
/* Its state: one point, on the right. */
|
|
982
|
+
const point = statePoint(stateOf(c)); point.title = STATE_WORDS[point.dataset.state]; b.append(point); b.dataset.state = point.dataset.state;
|
|
953
983
|
/* Found by a search while hidden: said. */
|
|
954
984
|
if (c.hidden === true && query) { const mark = document.createElement('small'); mark.className = 'shared-mark'; mark.textContent = 'hidden'; b.append(mark); }
|
|
955
985
|
/* Several models answer its simple questions; or they stopped, and it waits for its owner. */
|
|
@@ -958,9 +988,7 @@
|
|
|
958
988
|
/* It talks through the app, and asks or waits for its owner there. */
|
|
959
989
|
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); }
|
|
960
990
|
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); }
|
|
961
|
-
/*
|
|
962
|
-
const holders = sharedDevices.filter((d) => d.grants.some((g) => g.asset === `conversation:${c.name}`)).length;
|
|
963
|
-
if (holders > 0) { const mark = document.createElement('small'); mark.className = 'shared-mark'; mark.textContent = `shared with ${holders} device${holders > 1 ? 's' : ''}`; b.append(mark); }
|
|
991
|
+
/* Who else holds it is said in its Access, not in the list (where it said the same on every row). */
|
|
964
992
|
b.addEventListener('click', () => select(c.name, { step: true }));
|
|
965
993
|
return b;
|
|
966
994
|
}
|
|
@@ -968,6 +996,9 @@
|
|
|
968
996
|
const NONE = '\u0000none';
|
|
969
997
|
/* The two sections above the groups, folded or not like a group (never a group's name: those are plain words). */
|
|
970
998
|
const NEEDS = '\u0001needs'; const RECENT = '\u0001recent'; const GROUPS = '\u0001groups';
|
|
999
|
+
/* What was just unfolded comes in gently, once (the next paints show it as it is). */
|
|
1000
|
+
let justOpened = null;
|
|
1001
|
+
const unfolding = (key, els) => { if (justOpened === key) { for (const e of els) e.classList.add('unfolding'); justOpened = null; } return els; };
|
|
971
1002
|
function groupBox(g, inside, all, open, label = g) {
|
|
972
1003
|
const box = document.createElement('div'); box.className = 'group'; box.dataset.group = g === NONE ? '' : g;
|
|
973
1004
|
const head = document.createElement('button'); head.type = 'button'; head.className = 'group-head'; head.dataset.group = g === NONE ? '' : g;
|
|
@@ -975,21 +1006,17 @@
|
|
|
975
1006
|
head.setAttribute('aria-expanded', String(open));
|
|
976
1007
|
const caret = document.createElement('span'); caret.className = 'caret'; caret.setAttribute('aria-hidden', 'true'); caret.textContent = '›';
|
|
977
1008
|
const name = document.createElement('span'); name.className = 'group-name'; name.textContent = label;
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
const dots = document.createElement('span'); dots.className = 'group-dots'; dots.setAttribute('aria-hidden', 'true');
|
|
983
|
-
for (const c of all.slice(0, 6)) { const d = document.createElement('span'); d.className = 'mini'; d.dataset.phase = holds(c) ? 'building' : c.phase; if (c.asleep) d.dataset.asleep = 'true'; dots.append(d); }
|
|
984
|
-
head.append(caret, name, count, dots);
|
|
985
|
-
if (all.some(needsYou)) { const n = document.createElement('span'); n.className = 'needs-dot'; n.setAttribute('aria-label', 'one needs you'); head.append(n); head.dataset.needs = 'true'; }
|
|
1009
|
+
head.append(caret, name);
|
|
1010
|
+
/* Folded: how its conversations are, in points; open, each row says its own. */
|
|
1011
|
+
if (!open) head.append(stateSummary(all));
|
|
1012
|
+
if (all.some(needsYou)) head.dataset.needs = 'true';
|
|
986
1013
|
head.addEventListener('click', () => {
|
|
987
1014
|
if (query) return;
|
|
988
|
-
if (folded.has(g)) folded.delete(g); else folded.add(g);
|
|
1015
|
+
if (folded.has(g)) { folded.delete(g); justOpened = g; } else folded.add(g);
|
|
989
1016
|
keepFolded(); paint();
|
|
990
1017
|
});
|
|
991
1018
|
box.append(head);
|
|
992
|
-
if (open) { const body = document.createElement('div'); body.className = 'group-body'; body.append(...inside.map((c) => itemButton(c))); box.append(body); }
|
|
1019
|
+
if (open) { const body = document.createElement('div'); body.className = 'group-body'; body.append(...inside.map((c) => itemButton(c))); unfolding(g, [body]); box.append(body); }
|
|
993
1020
|
return box;
|
|
994
1021
|
}
|
|
995
1022
|
function paint() {
|
|
@@ -1016,21 +1043,23 @@
|
|
|
1016
1043
|
const chevron = document.createElement('span'); chevron.className = 'list-chevron'; chevron.setAttribute('aria-hidden', 'true'); chevron.textContent = open ? '\u25BE' : '\u25B8';
|
|
1017
1044
|
/* How many, only when folded: open, its rows (and "Show more") say it. */
|
|
1018
1045
|
b.append(chevron, document.createTextNode(label));
|
|
1019
|
-
if (!open)
|
|
1020
|
-
b.addEventListener('click', () => { if (folded.has(key)) folded.delete(key); else folded.add(key); keepFolded(); paint(); });
|
|
1046
|
+
if (!open) b.append(stateSummary(count));
|
|
1047
|
+
b.addEventListener('click', () => { if (folded.has(key)) { folded.delete(key); justOpened = key; } else folded.add(key); keepFolded(); paint(); });
|
|
1021
1048
|
top.append(b);
|
|
1022
1049
|
return open;
|
|
1023
1050
|
};
|
|
1024
1051
|
/* NEEDS YOU: whatever its date, until its owner acts; hidden ones too (they said so). */
|
|
1025
1052
|
const needs = conversations.filter(needsYou).sort((a, b) => activityOf(b) - activityOf(a));
|
|
1026
|
-
if (needs.length && section(NEEDS, 'Needs you', needs
|
|
1053
|
+
if (needs.length && section(NEEDS, 'Needs you', needs)) top.append(...unfolding(NEEDS, needs.map((c) => itemButton(c, true))));
|
|
1027
1054
|
/* RECENT: by when it was last used; the last four, then all. Never a hidden one. Only once there
|
|
1028
1055
|
are groups: before, the one list below says the same, in the order chosen by hand. */
|
|
1029
1056
|
/* One in Needs you just above is not said twice. */
|
|
1030
|
-
|
|
1057
|
+
/* The last day only: what is older is found in its group. */
|
|
1058
|
+
const dayAgo = Date.now() - 24 * 3600_000;
|
|
1059
|
+
const recent = conversations.filter((c) => (c.hidden !== true || c.name === current) && !needsYou(c) && activityOf(c) >= dayAgo).sort((a, b) => activityOf(b) - activityOf(a));
|
|
1031
1060
|
const few = 4;
|
|
1032
|
-
if (recent.length && groups.length && section(RECENT, 'Recent', recent
|
|
1033
|
-
top.append(...recent.slice(0, showAllRecent ? recent.length : few).map((c) => itemButton(c, true)));
|
|
1061
|
+
if (recent.length && groups.length && section(RECENT, 'Recent', recent)) {
|
|
1062
|
+
top.append(...unfolding(RECENT, recent.slice(0, showAllRecent ? recent.length : few).map((c) => itemButton(c, true))));
|
|
1034
1063
|
if (recent.length > few) {
|
|
1035
1064
|
const more = document.createElement('button'); more.type = 'button'; more.className = 'inline more-recent';
|
|
1036
1065
|
/* A chevron, centred: the words for the pointer and for a screen reader. */
|
|
@@ -1044,7 +1073,7 @@
|
|
|
1044
1073
|
/* GROUPS: the order chosen by hand, and those in no group as one of their own. */
|
|
1045
1074
|
if (groups.length) {
|
|
1046
1075
|
const loose = shown.filter((c) => !c.group);
|
|
1047
|
-
groupsOpen = section(GROUPS, 'Groups',
|
|
1076
|
+
groupsOpen = section(GROUPS, 'Groups', conversations.filter((c) => c.hidden !== true));
|
|
1048
1077
|
if (loose.length && groupsOpen) items.append(groupBox(NONE, loose, conversations.filter((c) => !c.group).sort(byRank), !folded.has(NONE), 'Not filed'));
|
|
1049
1078
|
} else {
|
|
1050
1079
|
/* No group yet: one list, each with what was said last and when -- without those in Needs you
|
|
@@ -1064,6 +1093,7 @@
|
|
|
1064
1093
|
if (inside.length === 0) continue;
|
|
1065
1094
|
items.append(groupBox(g, inside, conversations.filter((c) => c.group === g).sort(byRank), Boolean(query) || !folded.has(g)));
|
|
1066
1095
|
}
|
|
1096
|
+
if (groupsOpen) unfolding(GROUPS, [...items.children]);
|
|
1067
1097
|
/* The folders there are, offered where one is chosen. */
|
|
1068
1098
|
$('group-names').replaceChildren(...groupsInOrder().map((g) => { const o = document.createElement('option'); o.value = g; return o; }));
|
|
1069
1099
|
const hits = [...items.querySelectorAll('.item')];
|
|
@@ -1827,7 +1857,7 @@
|
|
|
1827
1857
|
/* "Seen": what its machine says now no longer puts it in Needs you (health.mjs). */
|
|
1828
1858
|
async function markSeen() {
|
|
1829
1859
|
if (!current || DEVICE) return;
|
|
1830
|
-
try { const record = await post(`${API}/conversations/${encodeURIComponent(current)}/health/seen`, {}); const c = conversations.find((x) => x.name === current); if (c) c.health = record; paint(); paintHealth(); }
|
|
1860
|
+
try { const record = await post(`${API}/conversations/${encodeURIComponent(current)}/health/seen`, {}); const c = conversations.find((x) => x.name === current); if (c) c.health = record; paint(); paintHealth(); if (thread && threadOf === current) void thread.refresh(); }
|
|
1831
1861
|
catch (error) { show(error.message, 'Back', () => { notice.hidden = true; }); }
|
|
1832
1862
|
}
|
|
1833
1863
|
function seeTerminal() { if (DEVICE) { simple = false; paintSimple(); focusTerminal(); } else goTab('terminal'); paintHealth(); }
|
|
@@ -2206,7 +2236,7 @@
|
|
|
2206
2236
|
/* A reaction to one of its messages: wherever the chat may be written in. */
|
|
2207
2237
|
...(!DEVICE || deviceParts.chat === 'write' ? { react: (to, reaction) => post(talkPath(name, '/react'), { to, reaction }) } : {}),
|
|
2208
2238
|
/* The buttons of a line of the machine: what this screen may do. */
|
|
2209
|
-
act: (id) => { if (id === 'seen') void markSeen(); else if (id === 'memory') void openMemory(); else if (id === 'disk') void openDisk(); else if (id === 'room') seeTerminal(); else if (id === 'restart') void restartMachine(false); else if (id === 'terminal') seeTerminal(); else if (id.startsWith('review:')) void openGit(id.slice('review:'.length)); else openCommits(id); },
|
|
2239
|
+
act: (id) => { if (id === 'seen-done') return; if (id === 'seen') void markSeen(); else if (id === 'memory') void openMemory(); else if (id === 'disk') void openDisk(); else if (id === 'room') seeTerminal(); else if (id === 'restart') void restartMachine(false); else if (id === 'terminal') seeTerminal(); else if (id.startsWith('review:')) void openGit(id.slice('review:'.length)); else openCommits(id); },
|
|
2210
2240
|
/* What it opens over the thread (a picture, its media, a search...) is a step of this page's: one Back closes it. */
|
|
2211
2241
|
back: { open: (name, close) => nav.over(`chat-${name}`, () => close(), { stack: true }), closed: (step) => { if (step) nav.drop(step); } },
|
|
2212
2242
|
/* Files attached to a message: wherever the chat may be written in. */
|
|
@@ -2286,14 +2316,18 @@
|
|
|
2286
2316
|
function machineLines(data) {
|
|
2287
2317
|
if (!Array.isArray(data?.messages)) return data;
|
|
2288
2318
|
const kindOf = (id) => String(id).split(':')[0];
|
|
2289
|
-
const may = (id) => (id === 'terminal' || id === 'room' ? !noTerminal() : id === 'disk' ? !DEVICE && !narrow() : (id === 'memory' || id === 'restart' || id === 'seen' || /^review:[a-z0-9][a-z0-9._-]*$/.test(id) || COMMITS.test(id)) && !DEVICE);
|
|
2319
|
+
const may = (id) => (id === 'terminal' || id === 'room' ? !noTerminal() : id === 'disk' ? !DEVICE && !narrow() : (id === 'memory' || id === 'restart' || id === 'seen' || id === 'seen-done' || /^review:[a-z0-9][a-z0-9._-]*$/.test(id) || COMMITS.test(id)) && !DEVICE);
|
|
2290
2320
|
const label = (id) => { const n = Number(COMMITS.exec(id)?.[4] ?? 0); return n ? (n === 1 ? 'See the commit' : `See the ${n} commits`) : ACTIONS[kindOf(id)]; };
|
|
2291
2321
|
const linksOf = (m) => {
|
|
2292
2322
|
const repo = DEVICE ? null : (m.actions ?? []).map((id) => /^review:([a-z0-9][a-z0-9-]*)$/.exec(id)?.[1]).find(Boolean);
|
|
2293
2323
|
if (!repo) return [];
|
|
2294
2324
|
return [...new Set(String(m.text ?? '').match(/\b[0-9a-f]{7,40}\b/g) ?? [])].filter((x) => /\d/.test(x)).slice(0, 8).map((x) => ({ text: x, id: `commit:${repo}.${x}` }));
|
|
2295
2325
|
};
|
|
2296
|
-
|
|
2326
|
+
/* ONE "Seen" for its machine: marked on the strip or here, every line it covers says so, and offers it no more. */
|
|
2327
|
+
const seenAt = conversations.find((x) => x.name === current)?.health?.seenAt ?? '';
|
|
2328
|
+
const seenWords = seenAt ? `\u2713 Seen ${new Date(seenAt).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}` : '';
|
|
2329
|
+
const actionsOf = (m) => (m.actions ?? []).filter(may).map((id) => (id === 'seen' && seenAt && String(m.at ?? '') <= seenAt ? { id: 'seen-done', label: seenWords } : { id, label: label(id) }));
|
|
2330
|
+
return { ...data, messages: data.messages.map((m) => (m.from === 'system' ? { ...m, actions: actionsOf(m), links: linksOf(m) } : m)) };
|
|
2297
2331
|
}
|
|
2298
2332
|
/* ITS MACHINE, on the side of the detailed chat: as this page last knew it. */
|
|
2299
2333
|
function withMachine(data, name) {
|
package/web/style.css
CHANGED
|
@@ -32,12 +32,21 @@ button:focus-visible, input:focus-visible { outline: 2px solid var(--brass); out
|
|
|
32
32
|
.item[aria-current="true"] { border-color: var(--brass); box-shadow: 0 0 0 1px var(--brass); }
|
|
33
33
|
.item b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
34
34
|
.item small { color: var(--ink2); }
|
|
35
|
-
|
|
36
|
-
.item
|
|
37
|
-
.
|
|
38
|
-
.
|
|
35
|
+
/* ITS STATE, one point on the right of its row: needs you, to watch, fine, asleep (a hollow ring). */
|
|
36
|
+
.item { position: relative; padding-right: 26px; }
|
|
37
|
+
.state-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; box-sizing: border-box; background: var(--ok); }
|
|
38
|
+
.state-dot[data-state="need"] { background: var(--danger); }
|
|
39
|
+
.state-dot[data-state="watch"] { background: var(--warn); }
|
|
40
|
+
.state-dot[data-state="sleep"] { background: transparent; border: 1.5px solid var(--ink2); }
|
|
41
|
+
.item > .state-dot { position: absolute; right: 10px; top: 13px; }
|
|
42
|
+
.item[data-state="watch"] > .state-dot { animation: pulse 1.6s ease-in-out infinite; }
|
|
43
|
+
/* Folded: up to four points, how its conversations are. */
|
|
44
|
+
.state-sum { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; flex-shrink: 0; }
|
|
45
|
+
/* Unfolded: it comes in gently, once. */
|
|
46
|
+
.unfolding { animation: unfold .18s ease-out; }
|
|
47
|
+
@keyframes unfold { from { opacity: 0; transform: translateY(-6px); } }
|
|
39
48
|
@keyframes pulse { 50% { opacity: .25; } }
|
|
40
|
-
@media (prefers-reduced-motion: reduce) { .item .dot { animation: none !important; } }
|
|
49
|
+
@media (prefers-reduced-motion: reduce) { .item > .state-dot, .unfolding { animation: none !important; } }
|
|
41
50
|
#create { display: flex; flex-direction: column; gap: 6px; padding: 10px; background: var(--bar); border: 1px solid var(--line); border-radius: 8px; }
|
|
42
51
|
#create label, #create .legend { font-size: .75rem; color: var(--ink2); }
|
|
43
52
|
#create input { font: .875rem var(--sans); color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 7px; padding: 7px 9px; min-width: 0; }
|
|
@@ -1283,8 +1292,8 @@ select.pill { appearance: auto; }
|
|
|
1283
1292
|
.list-head { margin: 10px 2px 2px; font-size: .78rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink2); }
|
|
1284
1293
|
.list-head:first-child { margin-top: 2px; }
|
|
1285
1294
|
.item[data-when] { position: relative; }
|
|
1286
|
-
.item[data-when] > b { padding-right:
|
|
1287
|
-
.item .when { position: absolute; top: 9px; right:
|
|
1295
|
+
.item[data-when] > b { padding-right: 5em; }
|
|
1296
|
+
.item .when { position: absolute; top: 9px; right: 26px; max-width: 5em; overflow: hidden; white-space: nowrap; font-weight: 400; color: var(--ink2); }
|
|
1288
1297
|
.item .last { display: block; color: var(--ink); opacity: .85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
1289
1298
|
.more-recent { align-self: center; display: inline-flex; align-items: center; gap: 4px; padding: 2px 14px; border-radius: 999px; text-decoration: none; color: var(--ink2); }
|
|
1290
1299
|
.more-recent:hover { color: var(--ink); background: var(--bar); }
|
|
@@ -1358,3 +1367,5 @@ select.pill { appearance: auto; }
|
|
|
1358
1367
|
.parley-act[data-act="seen"], #health-dismiss { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 60%, transparent); }
|
|
1359
1368
|
.parley-act[data-act="seen"]:hover, #health-dismiss:hover { background: color-mix(in srgb, var(--ok) 14%, transparent); }
|
|
1360
1369
|
button.inline.more-recent { text-decoration: none; }
|
|
1370
|
+
/* Marked seen: said, not offered again. */
|
|
1371
|
+
.parley-act[data-act="seen-done"] { color: var(--ok); border-color: transparent; background: transparent; cursor: default; opacity: .85; }
|