clavarium 0.2.23 → 0.2.24-next.2
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/api.mjs +7 -2
- package/server/events.mjs +2 -0
- package/server/gitchecks.mjs +3 -1
- package/server/gitkeeper.mjs +7 -2
- package/server/guide.mjs +1 -1
- package/server/health.mjs +13 -1
- package/server/main.mjs +15 -2
- package/server/secrets.mjs +86 -16
- package/server/talk.mjs +2 -2
- package/web/app.js +217 -46
- package/web/index.html +2 -1
- package/web/links.js +164 -114
- package/web/style.css +74 -52
package/web/app.js
CHANGED
|
@@ -330,14 +330,25 @@
|
|
|
330
330
|
$('fold').setAttribute('aria-pressed', String(folded));
|
|
331
331
|
$('fold').setAttribute('aria-label', folded ? 'Show the list of conversations' : 'Hide the list of conversations');
|
|
332
332
|
};
|
|
333
|
-
let listFolded = false;
|
|
333
|
+
let listFolded = false;
|
|
334
334
|
try { listFolded = localStorage.getItem('clavarium-list') === 'folded'; } catch { /* a private window */ }
|
|
335
|
-
|
|
335
|
+
/* THE LIST SLIDES, THE PAGE IS LAID OUT ONCE. Animating the grid's columns laid the whole page out (and
|
|
336
|
+
redrew the terminal) at every frame: it stuttered. The list and the menu slide instead -- a transform,
|
|
337
|
+
which costs nothing -- and the columns change once: after it slid out, or before it slides in. */
|
|
338
|
+
const sliders = () => ['list', 'nav'].map((id) => $(id)).filter(Boolean);
|
|
339
|
+
const slide = (out) => Promise.all(sliders().map((e) => e.animate(
|
|
340
|
+
[{ transform: 'none', opacity: 1 }, { transform: 'translateX(-100%)', opacity: 0 }],
|
|
341
|
+
{ duration: 200, easing: 'ease', direction: out ? 'normal' : 'reverse' }).finished.catch(() => {})));
|
|
342
|
+
const still = () => window.matchMedia?.('(prefers-reduced-motion: reduce)').matches || window.innerWidth <= 700;
|
|
343
|
+
$('fold').addEventListener('click', async () => {
|
|
336
344
|
listFolded = !listFolded;
|
|
337
345
|
try { localStorage.setItem('clavarium-list', listFolded ? 'folded' : 'open'); } catch { /* as above */ }
|
|
338
|
-
|
|
339
|
-
|
|
346
|
+
const folded = listFolded;
|
|
347
|
+
if (!still() && folded) await slide(true);
|
|
348
|
+
if (listFolded !== folded) return;
|
|
349
|
+
applyFold(folded);
|
|
340
350
|
fit.fit(); focusTerminal();
|
|
351
|
+
if (!still() && !folded) await slide(false);
|
|
341
352
|
});
|
|
342
353
|
|
|
343
354
|
/* ---------- light or dark ---------- */
|
|
@@ -357,16 +368,20 @@
|
|
|
357
368
|
for (const view of document.querySelectorAll('.md-view')) view.dataset.theme = light ? 'light' : 'dark';
|
|
358
369
|
terminal.options.theme = light ? LIGHT : DARK;
|
|
359
370
|
document.querySelector('meta[name=theme-color]')?.setAttribute('content', light ? LIGHT.background : DARK.background);
|
|
360
|
-
|
|
371
|
+
/* What is chosen, said by the choice pressed: never a button that names the other one. */
|
|
372
|
+
for (const b of $('theme').children) b.setAttribute('aria-pressed', String(b.dataset.theme === themeChoice));
|
|
361
373
|
};
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
374
|
+
/* light, dark, or system (as the device says, and as it changes). */
|
|
375
|
+
const systemLight = window.matchMedia?.('(prefers-color-scheme: light)');
|
|
376
|
+
let themeChoice = 'dark';
|
|
377
|
+
try { const kept = localStorage.getItem('clavarium-theme'); if (['light', 'dark', 'system'].includes(kept)) themeChoice = kept; } catch { /* a private window: the choice lasts as long as the page */ }
|
|
378
|
+
const themeNow = () => (themeChoice === 'system' ? Boolean(systemLight?.matches) : themeChoice === 'light');
|
|
379
|
+
applyTheme(themeNow());
|
|
380
|
+
systemLight?.addEventListener?.('change', () => { if (themeChoice === 'system') applyTheme(themeNow()); });
|
|
381
|
+
for (const b of $('theme').children) b.addEventListener('click', () => {
|
|
382
|
+
themeChoice = b.dataset.theme;
|
|
383
|
+
try { localStorage.setItem('clavarium-theme', themeChoice); } catch { /* as above */ }
|
|
384
|
+
applyTheme(themeNow());
|
|
370
385
|
});
|
|
371
386
|
const fit = new FitAddon.FitAddon();
|
|
372
387
|
terminal.loadAddon(fit);
|
|
@@ -752,8 +767,9 @@
|
|
|
752
767
|
stepText(way);
|
|
753
768
|
}, true);
|
|
754
769
|
let wheelAt = 0;
|
|
755
|
-
/* A picture large in the chat's viewer zooms itself, with a pinch or the wheel: the text is not grown under it.
|
|
756
|
-
|
|
770
|
+
/* A picture large in the chat's viewer zooms itself, with a pinch or the wheel: the text is not grown under it.
|
|
771
|
+
So does the map of Access (links.js). */
|
|
772
|
+
const inViewer = (event) => event.target instanceof Element && Boolean(event.target.closest('.parley-zoom, .lk-scroller'));
|
|
757
773
|
addEventListener('wheel', (event) => {
|
|
758
774
|
if (!event.ctrlKey || inViewer(event)) return;
|
|
759
775
|
event.preventDefault(); event.stopPropagation();
|
|
@@ -1597,12 +1613,24 @@
|
|
|
1597
1613
|
/* THE BAR (G): Chat | Terminal | Assets N, then its settings. What was
|
|
1598
1614
|
given to it is counted on "Assets", and shown there. */
|
|
1599
1615
|
let assetsShown = false; let roomPick = '';
|
|
1616
|
+
/* A secret near or past its expiry (secrets.mjs, WARN_DAYS): a dot on Assets, and on the
|
|
1617
|
+
Assets of a conversation that has it. Read with the list, at most once a minute. */
|
|
1618
|
+
let secretsKnown = []; let secretsReadAt = 0;
|
|
1619
|
+
const secretDue = (s) => s.expired === true || (typeof s.days === 'number' && s.days <= 7);
|
|
1620
|
+
function markSecrets(list) {
|
|
1621
|
+
secretsKnown = Array.isArray(list) ? list : []; secretsReadAt = Date.now();
|
|
1622
|
+
$('nav-assets').toggleAttribute('data-attention', secretsKnown.some(secretDue));
|
|
1623
|
+
$('view-assets').toggleAttribute('data-attention', secretsKnown.some((s) => secretDue(s) && s.conversations.includes(current)));
|
|
1624
|
+
}
|
|
1625
|
+
async function readSecretsNow() { if (!DEVICE) markSecrets(await (await fetch(`${API}/secrets`)).json().catch(() => [])); }
|
|
1600
1626
|
function paintChips() {
|
|
1601
1627
|
if (DEVICE) return;
|
|
1602
1628
|
const c = conversations.find((x) => x.name === current);
|
|
1603
1629
|
$('views').hidden = !c;
|
|
1604
1630
|
const n = (c?.resources?.length ?? 0) + (c?.secrets?.length ?? 0) + (c?.work === 'kept' ? 1 : 0);
|
|
1605
1631
|
$('assets-count').textContent = n ? String(n) : '';
|
|
1632
|
+
$('view-assets').toggleAttribute('data-attention', secretsKnown.some((s) => secretDue(s) && s.conversations.includes(current)));
|
|
1633
|
+
if (Date.now() - secretsReadAt > 60_000) { secretsReadAt = Date.now(); void readSecretsNow().catch(() => {}); }
|
|
1606
1634
|
/* Its title names each of them, with what it may do. */
|
|
1607
1635
|
$('view-assets').title = c ? [...(c.offline === true ? ['offline'] : []), ...(c.resources ?? []).map((r) => `${r.name} - ${r.access}`), ...(c.secrets ?? [])].join(', ') || 'Nothing given yet' : '';
|
|
1608
1636
|
paintViews();
|
|
@@ -1869,19 +1897,33 @@
|
|
|
1869
1897
|
for (const b of $('network').children) b.setAttribute('aria-pressed', String((b.dataset.online === 'true') !== offline));
|
|
1870
1898
|
await paintSignIn();
|
|
1871
1899
|
}
|
|
1872
|
-
/* ---------- chapters (a conversation's settings, and Settings): folded or not
|
|
1873
|
-
/* All folded
|
|
1900
|
+
/* ---------- chapters (a conversation's settings, and Settings): folded or not ---------- */
|
|
1901
|
+
/* All folded when the app is opened: what the person opens stays open while this tab lives (a reload
|
|
1902
|
+
included), never from one day to the next -- a page that opens half-unfolded says nothing. What asks
|
|
1903
|
+
for them is said on the folded chapter instead (markAttention). */
|
|
1874
1904
|
const OPEN_AT_FIRST = {};
|
|
1875
1905
|
let chapters = {};
|
|
1876
|
-
try { chapters = JSON.parse(
|
|
1906
|
+
try { chapters = JSON.parse(sessionStorage.getItem('clavarium-chapters') ?? '{}') ?? {}; } catch { /* a private window */ }
|
|
1907
|
+
try { localStorage.removeItem('clavarium-chapters'); } catch { /* as above */ }
|
|
1877
1908
|
for (const chapter of document.querySelectorAll('details.chapter')) {
|
|
1878
1909
|
const key = chapter.dataset.chapter;
|
|
1879
1910
|
chapter.open = chapters[key] ?? OPEN_AT_FIRST[key] ?? false;
|
|
1880
1911
|
chapter.addEventListener('toggle', () => {
|
|
1881
1912
|
chapters[key] = chapter.open;
|
|
1882
|
-
try {
|
|
1913
|
+
try { sessionStorage.setItem('clavarium-chapters', JSON.stringify(chapters)); } catch { /* as above */ }
|
|
1883
1914
|
});
|
|
1884
1915
|
}
|
|
1916
|
+
/* A chapter that holds something asking for the person -- a callout, or a state said as a warning or a
|
|
1917
|
+
fault -- wears a dot on its title, folded or not: one look at Settings says where to go. */
|
|
1918
|
+
const asksForYou = (el2) => [...el2.querySelectorAll('.callout, .status-line[data-tone="warn"], .status-line[data-tone="bad"]')]
|
|
1919
|
+
.some((x) => !x.closest('[hidden]') && x.textContent.trim());
|
|
1920
|
+
let marking;
|
|
1921
|
+
const markAttention = () => { clearTimeout(marking); marking = setTimeout(() => {
|
|
1922
|
+
for (const chapter of document.querySelectorAll('details.chapter')) chapter.toggleAttribute('data-attention', asksForYou(chapter));
|
|
1923
|
+
/* And on its category, in the side list of Settings. */
|
|
1924
|
+
for (const b of document.querySelectorAll('#settings-nav button[data-group]')) b.toggleAttribute('data-attention', Boolean(document.querySelector(`#settings-group-${b.dataset.group} details.chapter[data-attention]`)));
|
|
1925
|
+
}, 150); };
|
|
1926
|
+
new MutationObserver(markAttention).observe(document.body, { subtree: true, childList: true, attributes: true, attributeFilter: ['hidden', 'data-tone', 'class'] });
|
|
1885
1927
|
/* Reached by a link (or a button that leads to it): opened, and said for a moment. */
|
|
1886
1928
|
let reachedTimer;
|
|
1887
1929
|
const openChapter = (key, { show = true } = {}) => {
|
|
@@ -2376,7 +2418,15 @@
|
|
|
2376
2418
|
onView: (v) => { chatView = v; try { localStorage.setItem('clavarium-chat-view', v); } catch { /* as above */ } },
|
|
2377
2419
|
load: () => fetch(talkPath(name)).then((r) => r.json()).then(machineLines).then((data) => withMachine(data, name)),
|
|
2378
2420
|
/* `via: 'voice'`: part of it was dictated, said to the tool. */
|
|
2379
|
-
send: (text, answers, files, extra) => post(talkPath(name), { text, answers, ...(files ? { files: files.map((f) => (f.note ? { path: f.path, note: f.note } : f.path)) } : {}), ...(extra?.via === 'voice' ? { via: 'voice' } : {})
|
|
2421
|
+
send: (text, answers, files, extra) => post(talkPath(name), { text, answers, ...(files ? { files: files.map((f) => (f.note ? { path: f.path, note: f.note } : f.path)) } : {}), ...(extra?.via === 'voice' ? { via: 'voice' } : {}),
|
|
2422
|
+
/* The choices ticked, the answers of a group, the zone of a picture the answer is about. */
|
|
2423
|
+
...(extra?.picked ? { picked: extra.picked } : {}), ...(extra?.replies ? { replies: extra.replies } : {}), ...(extra?.about ? { about: extra.about } : {}) }),
|
|
2424
|
+
/* Formulas: Parley's own KaTeX, served here. Zones and people may point to a file of a shared folder (file:/work/...). */
|
|
2425
|
+
math: { url: new URL('vendor/katex/katex.mjs', new URL(DEVICE ? '/c/' : '/', location.href)).href },
|
|
2426
|
+
refs: {
|
|
2427
|
+
label: (ref) => (/^file:\/(work|resources)\//.test(ref) ? 'Open' : null),
|
|
2428
|
+
open: (ref) => { const m = /^file:\/(work|resources\/[^/]+)\/(.+)$/.exec(ref); if (!m) return; const tab = m[1] === 'work' ? 'work' : m[1].slice('resources/'.length); void preview(tab, m[2], m[2].split('/').pop(), 0); },
|
|
2429
|
+
},
|
|
2380
2430
|
/* A reaction to one of its messages: wherever the chat may be written in. */
|
|
2381
2431
|
...(!DEVICE || deviceParts.chat === 'write' ? { react: (to, reaction) => post(talkPath(name, '/react'), { to, reaction }) } : {}),
|
|
2382
2432
|
/* The buttons of a line of the machine: what this screen may do. */
|
|
@@ -2391,6 +2441,8 @@
|
|
|
2391
2441
|
...(noTerminal() ? {} : { terminal: () => seeTerminal() }),
|
|
2392
2442
|
/* What the tool writes is rendered (Parley builds it element by element), and named by its tool. */
|
|
2393
2443
|
/* Named as its owner chose, else by the neutral word of the dictionary; its tool, small, in the detailed view. */
|
|
2444
|
+
/* What is being written is kept per conversation: another one looked at, it is there again. */
|
|
2445
|
+
draft: name,
|
|
2394
2446
|
markdown: true, agentName: conversations.find((x) => x.name === name)?.chatName ?? '', agentTool: conversations.find((x) => x.name === name)?.toolLabel ?? '',
|
|
2395
2447
|
/* Its pictures, from the shared folders only, by the same route as the thumbnails of Files (type proved by the bytes, never SVG). */
|
|
2396
2448
|
picture: (file) => { if (!file.open) return null; const at = file.open.indexOf(':'); return `${API}/files/thumb?${new URLSearchParams({ c: name, r: file.open.slice(0, at), p: file.open.slice(at + 1) })}`; },
|
|
@@ -2613,7 +2665,7 @@
|
|
|
2613
2665
|
wordsSettings = await fetch(`${API}/talk/settings`).then((r) => (r.ok ? r.json() : null)).catch(() => null);
|
|
2614
2666
|
if (!wordsSettings) return;
|
|
2615
2667
|
const select = $('words-lang');
|
|
2616
|
-
select.replaceChildren(...[['device', `
|
|
2668
|
+
select.replaceChildren(...[['device', `Each device's (${languageName(deviceLang())})`], ...wordsSettings.languages.map((l) => [l, languageName(l)])].map(([value, label]) => { const o = document.createElement('option'); o.value = value; o.textContent = label; return o; }));
|
|
2617
2669
|
select.value = wordsSettings.lang;
|
|
2618
2670
|
if (document.activeElement !== $('words-own')) $('words-own').value = Object.keys(wordsSettings.own).length ? JSON.stringify(wordsSettings.own, null, 2) : '';
|
|
2619
2671
|
}
|
|
@@ -2933,6 +2985,7 @@
|
|
|
2933
2985
|
const name = el('b', '', item.name);
|
|
2934
2986
|
if (item.badge) { const badge = el('span', `as-badge${item.badgeTone ? ` ${item.badgeTone}` : ''}`, item.badge); if (item.badgeTitle) badge.title = item.badgeTitle; name.append(badge); }
|
|
2935
2987
|
const sub = el('small', item.tone ? `as-sub ${item.tone}` : 'as-sub', item.sub ?? '');
|
|
2988
|
+
if (item.dot) { sub.classList.add('status-line'); sub.dataset.tone = item.dot; }
|
|
2936
2989
|
const words = el('span', 'as-words'); words.append(name, sub);
|
|
2937
2990
|
row.append(kindIcon(kind), words);
|
|
2938
2991
|
row.addEventListener('click', () => choose(item.key));
|
|
@@ -2954,6 +3007,21 @@
|
|
|
2954
3007
|
const chapter = (title, ...extra) => { const head = el('div', 'as-chapter'); head.append(el('h3', '', title), ...extra); return head; };
|
|
2955
3008
|
const boxSub = (box) => (!box ? 'mailbox' : box.failure ? box.failure : `${box.messages} message${box.messages === 1 ? '' : 's'}`);
|
|
2956
3009
|
const gitSub = (r) => (r.from ? `from ${hostOf(r.from)}` : 'repository');
|
|
3010
|
+
/* A secret's expiry, as said: `due` when it asks for the person (near, or past). */
|
|
3011
|
+
const secretState = (s) => {
|
|
3012
|
+
if (s.expired) return { text: 'Expired', tone: 'bad', due: true };
|
|
3013
|
+
if (s.days === null || s.days === undefined) return { text: 'No expiry', tone: '', due: false };
|
|
3014
|
+
if (secretDue(s)) return { text: s.days === 1 ? 'Expires tomorrow' : `Expires in ${s.days} days`, tone: 'warn', due: true };
|
|
3015
|
+
return { text: `Expires ${s.expires}`, tone: 'ok', due: false };
|
|
3016
|
+
};
|
|
3017
|
+
const secretItem = (s, sub) => { const st = secretState(s); return st.due ? { sub: st.text, dot: st.tone, tone: st.tone === 'bad' ? 'bad' : '' } : { sub }; };
|
|
3018
|
+
/* Its line on a sheet: the state and the day. */
|
|
3019
|
+
const secretLine = (s, expiredWords) => {
|
|
3020
|
+
const st = secretState(s);
|
|
3021
|
+
const line = el('p', 'status-line secret-expiry-state', st.tone === 'bad' ? `Expired · ${expiredWords}` : st.due ? `${st.text} · ${s.expires}` : st.text);
|
|
3022
|
+
if (st.tone) line.dataset.tone = st.tone;
|
|
3023
|
+
return line;
|
|
3024
|
+
};
|
|
2957
3025
|
|
|
2958
3026
|
/* A repository, on the right: its branch, what would go, the diagram. */
|
|
2959
3027
|
async function gitDetail(holder, name, { place = false, others = false } = {}) {
|
|
@@ -3031,9 +3099,8 @@
|
|
|
3031
3099
|
the same target, the same guards). One refused does not hold the
|
|
3032
3100
|
others back: each says what became of it. */
|
|
3033
3101
|
const STATE_SAID = { 'up-to-date': 'up to date', diverged: 'behind: its agent must pull first', 'no-remote': 'no remote', unreachable: 'remote not answering', empty: 'empty' };
|
|
3034
|
-
/* How many other branches of a repository are looked at
|
|
3102
|
+
/* How many other branches of a repository are looked at. */
|
|
3035
3103
|
const BRANCHES_MORE = 7;
|
|
3036
|
-
const MOVED_LATELY_MS = 24 * 3600_000;
|
|
3037
3104
|
/* What a row is, for the filter: a branch the remote has and that is ahead of it, a branch it does not have, nothing to send. */
|
|
3038
3105
|
const kindOfRow = (out) => (out?.state !== 'ahead' ? 'none' : out.targetExists === false ? 'new' : 'update');
|
|
3039
3106
|
const TS_FILTERS = [['update', 'To update'], ['new', 'New branches'], ['all', 'All']];
|
|
@@ -3051,7 +3118,7 @@
|
|
|
3051
3118
|
bar.append(why, together, go);
|
|
3052
3119
|
const said = el('p', 'ts-said'); said.hidden = true; said.setAttribute('role', 'status');
|
|
3053
3120
|
const review = el('div', 'ts-review'); review.hidden = true;
|
|
3054
|
-
holder.append(progress, meter, filters, list, bar,
|
|
3121
|
+
holder.append(progress, meter, said, filters, list, bar, review);
|
|
3055
3122
|
const rows = [];
|
|
3056
3123
|
let filter = 'update';
|
|
3057
3124
|
let sending = false; let checking = false;
|
|
@@ -3066,21 +3133,33 @@
|
|
|
3066
3133
|
if (r.target) query.set('target', r.target);
|
|
3067
3134
|
const [out, keep] = await Promise.all([fetch(`${API}/git/${r.name}/outgoing${query.size ? `?${query}` : ''}`).then(async (x) => { const j = await x.json().catch(() => ({})); return x.ok ? j : { state: 'error', message: j.error || 'It could not be read.' }; }).catch(() => ({ state: 'error', message: 'It could not be read.' })), r.keep ? r.keep : getJson(`/git/${r.name}/keep`, null)]);
|
|
3068
3135
|
r.out = out; r.keep = keep; r.branch = out.branch ?? r.branch; r.target = out.target ?? r.target; r.check = null;
|
|
3136
|
+
/* What the server knows of this very commit and target: a check still running is followed again; the last
|
|
3137
|
+
one that ran is shown with its age (left and come back, even the next day: nothing run again for nothing). */
|
|
3138
|
+
if (out.state === 'ahead' && out.head) {
|
|
3139
|
+
const going = (keep?.running ?? []).find((x) => x.head === out.head && x.target === out.target);
|
|
3140
|
+
const ran = (keep?.last ?? []).find((x) => x.head === out.head && x.target === out.target && x.status !== 'unavailable');
|
|
3141
|
+
if (going) setTimeout(() => { void checkRow(r, { since: Date.parse(going.since) || Date.now(), resume: true }); }, 0);
|
|
3142
|
+
else if (ran) r.check = { ...ran, earlier: true };
|
|
3143
|
+
}
|
|
3069
3144
|
if (out.state !== 'ahead') r.picked = false;
|
|
3070
3145
|
}
|
|
3071
3146
|
/* The server keeps the run: a request hears "running" after a while, and asks again until it ends. */
|
|
3072
|
-
async function checkRow(r) {
|
|
3147
|
+
async function checkRow(r, { since = Date.now(), resume = false } = {}) {
|
|
3073
3148
|
const { head, target } = r.out;
|
|
3074
|
-
r.check = { status: 'running' }; r.open = false; paint();
|
|
3149
|
+
r.check = { status: 'running', since }; r.open = false; paint();
|
|
3150
|
+
/* While it runs, its line moves every second: how long so far, and about how long the last one took. */
|
|
3151
|
+
const ticking = setInterval(() => { if (r.check?.status === 'running') paint(); }, 1000);
|
|
3075
3152
|
let result;
|
|
3076
3153
|
for (let first = true; ; first = false) {
|
|
3077
|
-
try { result = await post(`${API}/git/${r.name}/check`, { head, target, ...(first ? {} : { join: true }) }); }
|
|
3154
|
+
try { result = await post(`${API}/git/${r.name}/check`, { head, target, ...(first && !resume ? {} : { join: true }) }); }
|
|
3078
3155
|
catch (error) { result = { status: 'unavailable', output: `The page could not reach the server: ${error.message}` }; }
|
|
3079
3156
|
if (result?.status !== 'running' || r.out?.head !== head || r.out?.target !== target) break;
|
|
3080
3157
|
}
|
|
3158
|
+
clearInterval(ticking);
|
|
3081
3159
|
if (r.out?.head !== head || r.out?.target !== target) return;
|
|
3082
3160
|
r.check = result; paint();
|
|
3083
3161
|
}
|
|
3162
|
+
const checkedAgo = (at) => { const m = Math.max(0, Math.round((Date.now() - Date.parse(at)) / 60000)); return m < 1 ? 'just now' : m < 60 ? `${m} min ago` : m < 1440 ? `${Math.round(m / 60)} h ago` : `${Math.round(m / 1440)} d ago`; };
|
|
3084
3163
|
/* What its agent is told when checks did not pass: where, and the end of what they said. */
|
|
3085
3164
|
const forAgent = (r) => `The checks of ${r.name} (${r.out.branch} → ${r.out.target}) did not pass before sending. Please fix it, commit, and tell me.\n\n\`\`\`\n${String(r.check?.output ?? '').slice(-3000)}\n\`\`\``;
|
|
3086
3165
|
const stopped = (r) => Boolean(r.keep?.settings?.requireForSend) && r.check?.status !== 'passed';
|
|
@@ -3111,7 +3190,9 @@
|
|
|
3111
3190
|
together.textContent = p.length > 1 ? `Review the ${p.length} together` : 'Review';
|
|
3112
3191
|
go.disabled = sending || checking || p.length === 0 || running.length > 0 || (!unchecked.length && held.length > 0);
|
|
3113
3192
|
why.textContent = p.length === 0 ? 'Nothing ticked.' : running.length ? 'Checking...' : unchecked.length ? '' : held.length ? `Passing checks are required: ${held.map(label).join(', ')}.` : failed.length ? `Checks did not pass: ${failed.map(label).join(', ')}.` : '';
|
|
3114
|
-
|
|
3193
|
+
/* Once something went and nothing is left ticked, no button that would seem to say nothing went. */
|
|
3194
|
+
go.hidden = !sending && p.length === 0 && rows.some((r) => r.sent?.ok);
|
|
3195
|
+
if (sending) { go.textContent = 'Sending…'; return; }
|
|
3115
3196
|
/* First the checks of what is ticked; then Send. */
|
|
3116
3197
|
if (unchecked.length || running.length) { go.dataset.step = 'check'; go.textContent = `Check ${word}`; return; }
|
|
3117
3198
|
go.dataset.step = 'send';
|
|
@@ -3132,7 +3213,7 @@
|
|
|
3132
3213
|
const who = el('div', 'ts-who'); who.append(el('b', '', r.name), el('small', 'hint', out?.remote ? hostOf(out.remote) : out ? 'no remote' : ''));
|
|
3133
3214
|
const way = el('div', 'ts-way');
|
|
3134
3215
|
if (out?.branch) {
|
|
3135
|
-
|
|
3216
|
+
const code = el('code', 'ts-branch', out.branch); code.title = out.branch; way.append(code);
|
|
3136
3217
|
if (['ahead', 'up-to-date', 'diverged'].includes(out.state) && out.target) {
|
|
3137
3218
|
way.append(el('span', 'ts-arrow', '→'));
|
|
3138
3219
|
const to = el('select'); to.setAttribute('aria-label', `Where ${label(r)} goes`); to.disabled = sending || checking;
|
|
@@ -3152,14 +3233,28 @@
|
|
|
3152
3233
|
size.append(el('span', '', what), el('br'), el('span', 'plus', `+${files.reduce((n, f) => n + f.added, 0)}`), ' ', el('span', 'minus', `−${files.reduce((n, f) => n + f.removed, 0)}`));
|
|
3153
3234
|
} else size.append(el('span', 'hint', out.state === 'up-to-date' ? 'nothing' : '-'));
|
|
3154
3235
|
const state = el('div', 'ts-state');
|
|
3155
|
-
if (r.
|
|
3236
|
+
if (r.sending) { const s2 = el('span', 'ts-running'); s2.append(el('span', 'warn', 'Sending…')); state.append(s2); }
|
|
3237
|
+
else if (r.sent) state.append(el('b', r.sent.ok ? 'ok' : 'bad', r.sent.ok ? r.sent.text : '✗ Not sent'));
|
|
3156
3238
|
else if (!out) state.append('');
|
|
3157
3239
|
else if (!ahead) state.append(el('span', out.state === 'diverged' || out.state === 'unreachable' || out.state === 'error' ? 'bad' : 'hint', STATE_SAID[out.state] ?? out.message ?? out.state));
|
|
3158
3240
|
else if (!r.check) state.append(el('span', 'hint', r.picked ? 'to check' : ''));
|
|
3159
|
-
else if (r.check.status === 'running')
|
|
3241
|
+
else if (r.check.status === 'running') {
|
|
3242
|
+
const took = (r.keep?.last ?? []).find((x) => x.target === r.out.target && Number.isFinite(x.ms))?.ms ?? (r.keep?.last ?? []).find((x) => Number.isFinite(x.ms))?.ms;
|
|
3243
|
+
const so = Date.now() - (r.check.since ?? Date.now());
|
|
3244
|
+
const clock = (ms) => { const s = Math.round(ms / 1000); return `${Math.floor(s / 60)}:${String(s % 60).padStart(2, '0')}`; };
|
|
3245
|
+
const box = el('span', 'ts-running');
|
|
3246
|
+
box.append(el('span', 'warn', `Checking ${clock(so)}`), el('small', 'hint', took ? `last time ${clock(took)}` : 'may take minutes'));
|
|
3247
|
+
const bar = el('span', 'ts-meter ts-meter-row'); const fill = el('i'); bar.append(fill);
|
|
3248
|
+
/* Measured against the last run: never full until it ends; without one, a slow sweep. */
|
|
3249
|
+
fill.style.width = took ? `${Math.min(95, Math.round((so / took) * 100))}%` : '';
|
|
3250
|
+
if (!took) bar.classList.add('ts-sweep');
|
|
3251
|
+
box.append(bar);
|
|
3252
|
+
state.append(box);
|
|
3253
|
+
}
|
|
3160
3254
|
else {
|
|
3161
3255
|
const [word, tone] = CHECK_WORDS[r.check.status] ?? [String(r.check.status), ''];
|
|
3162
|
-
const
|
|
3256
|
+
const age = r.check.earlier && r.check.at ? ` · ${checkedAgo(r.check.at)}` : '';
|
|
3257
|
+
const text = `${r.check.status === 'passed' ? '✓ Checks passed' : r.check.status === 'failed' ? '✗ Checks failed' : word}${age}`;
|
|
3163
3258
|
/* What did not pass says why, one tap away: the reason, what they printed, and what to do. */
|
|
3164
3259
|
if (r.check.status === 'failed' || r.check.status === 'unavailable') {
|
|
3165
3260
|
const open = el('button', `ts-why-open ${tone}`, `${text} ${r.open ? '▴' : '▾'}`); open.type = 'button'; open.setAttribute('aria-expanded', String(Boolean(r.open)));
|
|
@@ -3222,7 +3317,14 @@
|
|
|
3222
3317
|
if (tab === 'changes') {
|
|
3223
3318
|
const tree = el('div', 'rv-tree ts-tree'); const diffs = el('div', 'rv-diff ts-diffs');
|
|
3224
3319
|
for (const { r, files } of all) {
|
|
3225
|
-
|
|
3320
|
+
/* Each repository its own group: a header that says which, where to, how much; its files under it, folding with it. */
|
|
3321
|
+
const group = el('section', 'ts-tree-group');
|
|
3322
|
+
const head = el('button', 'ts-tree-repo'); head.type = 'button'; head.setAttribute('aria-expanded', 'true');
|
|
3323
|
+
head.append(el('b', '', label(r)), el('code', '', `${r.out.branch} → ${r.out.target}`),
|
|
3324
|
+
el('small', 'hint', `${files.length} file${files.length === 1 ? '' : 's'}`), el('small', 'plus', `+${files.reduce((n, f) => n + f.added, 0)}`), el('small', 'minus', `−${files.reduce((n, f) => n + f.removed, 0)}`));
|
|
3325
|
+
const list2 = el('div', 'ts-tree-files');
|
|
3326
|
+
head.addEventListener('click', () => { const open = list2.hidden; list2.hidden = !open; head.setAttribute('aria-expanded', String(open)); });
|
|
3327
|
+
group.append(head, list2); tree.append(group);
|
|
3226
3328
|
const box = el('div', 'ts-diff'); box.dataset.repo = r.name;
|
|
3227
3329
|
box.append(el('h4', '', `${r.name}: ${r.out.branch} → ${r.out.target}`));
|
|
3228
3330
|
const inner = el('div'); box.append(inner);
|
|
@@ -3230,7 +3332,7 @@
|
|
|
3230
3332
|
const b = el('button'); b.type = 'button'; b.dataset.how = f.how;
|
|
3231
3333
|
b.append(el('span', 'rv-path', f.path), el('small', 'plus', `+${f.added}`), el('small', 'minus', `−${f.removed}`));
|
|
3232
3334
|
b.addEventListener('click', () => { inner.querySelectorAll('.d2h-file-wrapper')[i]?.scrollIntoView({ block: 'start' }); });
|
|
3233
|
-
|
|
3335
|
+
list2.append(b);
|
|
3234
3336
|
});
|
|
3235
3337
|
const Ui = window.Diff2HtmlUI;
|
|
3236
3338
|
if (!r.out.diff) inner.append(el('p', 'hint', 'No change to show.'));
|
|
@@ -3284,11 +3386,12 @@
|
|
|
3284
3386
|
for (const r of rows) r.sent = null;
|
|
3285
3387
|
paint();
|
|
3286
3388
|
for (const r of p) {
|
|
3389
|
+
r.sending = true; paint();
|
|
3287
3390
|
try {
|
|
3288
3391
|
const sent = await post(`${API}/git/${r.name}/push`, { head: r.out.head, target: r.out.target, ...(r.out.guards?.confirm ? { sure: true } : {}) });
|
|
3289
3392
|
r.sent = { ok: true, text: sent.already ? `✓ Already in ${sent.branch}` : sent.commits > 0 ? `✓ Sent to ${sent.branch}` : `✓ Made ${sent.branch}` };
|
|
3290
3393
|
} catch (error) { r.sent = { ok: false, text: /^Not sent/.test(error.message) ? error.message : `Not sent: ${error.message}` }; }
|
|
3291
|
-
paint();
|
|
3394
|
+
r.sending = false; paint();
|
|
3292
3395
|
}
|
|
3293
3396
|
sending = false; paint();
|
|
3294
3397
|
const ok = p.filter((r) => r.sent?.ok).length;
|
|
@@ -3298,12 +3401,13 @@
|
|
|
3298
3401
|
/* What is left to send, read again; what became of each stays said. */
|
|
3299
3402
|
const kept = new Map(rows.map((r) => [r, r.sent]));
|
|
3300
3403
|
await Promise.all(rows.map((r) => look(r)));
|
|
3301
|
-
|
|
3404
|
+
/* What went is unticked: nothing is offered again for what is done. */
|
|
3405
|
+
for (const r of rows) { r.sent = kept.get(r); if (r.sent?.ok) r.picked = false; }
|
|
3302
3406
|
paint();
|
|
3407
|
+
said.scrollIntoView({ block: 'nearest' });
|
|
3303
3408
|
});
|
|
3304
3409
|
paint();
|
|
3305
3410
|
/* Each repository's branch that moved last, then up to BRANCHES_MORE others of its agent: each row shown as soon as it is read. */
|
|
3306
|
-
const lately = (r) => r.movedAt && Date.now() - Date.parse(r.movedAt) < MOVED_LATELY_MS;
|
|
3307
3411
|
await Promise.all(names.map(async (name) => {
|
|
3308
3412
|
const first = { name, out: null, keep: null, branch: '', target: '', picked: false, check: null, sent: null };
|
|
3309
3413
|
rows.push(first);
|
|
@@ -3315,7 +3419,8 @@
|
|
|
3315
3419
|
await Promise.all(others.map(async (b) => {
|
|
3316
3420
|
const r = { name, out: null, keep: first.keep, branch: b.name, target: '', picked: false, check: null, sent: null, movedAt: b.movedAt };
|
|
3317
3421
|
await look(r);
|
|
3318
|
-
|
|
3422
|
+
/* Ticked by one rule for every row: a branch of the remote to update is ticked; a new one is not. */
|
|
3423
|
+
if (r.out?.state === 'ahead') { r.picked = kindOfRow(r.out) === 'update'; rows.splice(rows.findLastIndex((x) => x.name === name) + 1, 0, r); }
|
|
3319
3424
|
paint();
|
|
3320
3425
|
}));
|
|
3321
3426
|
reposDone++; paint();
|
|
@@ -3358,7 +3463,8 @@
|
|
|
3358
3463
|
items.push({ key: `${kind}:${r.name}`, kind, name: r.name, resource: r, box, badge: access, badgeTone: access, badgeLong: access === 'write' ? 'read and write' : 'read only',
|
|
3359
3464
|
sub: kind === 'git' ? gitSub(r) : kind === 'mailbox' ? boxSub(box) : 'folder', tone: box?.failure ? 'bad' : '' });
|
|
3360
3465
|
}
|
|
3361
|
-
|
|
3466
|
+
markSecrets(secrets);
|
|
3467
|
+
for (const s2 of secrets.filter((x) => x.conversations.includes(current))) items.push({ key: `secret:${s2.name}`, kind: 'secret', name: s2.name, secret: s2, ...secretItem(s2, 'name only · used by its agent') });
|
|
3362
3468
|
/* TO SEND, above them all, once it has a repository: every one of them on one screen. */
|
|
3363
3469
|
const gits = items.filter((i) => i.kind === 'git').map((i) => i.name);
|
|
3364
3470
|
const outbox = gits.length ? { key: 'send:all', kind: 'send', name: 'To send', sub: 'every repository, reviewed and sent at once' } : null;
|
|
@@ -3391,6 +3497,7 @@
|
|
|
3391
3497
|
} else if (chosen.kind === 'send') await sendDetail(detail, gits);
|
|
3392
3498
|
else if (chosen.kind === 'git') await gitDetail(detail, chosen.name, { others: gits.length > 1 });
|
|
3393
3499
|
else {
|
|
3500
|
+
if (chosen.secret.expires) detail.append(secretLine(chosen.secret, 'not given to its tool'));
|
|
3394
3501
|
detail.append(el('p', 'hint', 'Handed to its tool as a variable and a file, the next time it starts. Its value is never shown.'), chapter('Used by'));
|
|
3395
3502
|
const list = el('div', 'as-chips');
|
|
3396
3503
|
for (const who of chosen.secret.conversations) list.append(el('span', 'as-chip', shownName(conversations.find((x) => x.name === who)) || who));
|
|
@@ -3426,12 +3533,63 @@
|
|
|
3426
3533
|
if ($('cassets').contains($('gitview'))) shutGit();
|
|
3427
3534
|
}
|
|
3428
3535
|
|
|
3536
|
+
/* REPLACE THE VALUE, without seeing it: a new one typed (never shown, the old one
|
|
3537
|
+
never sent here) and/or its expiry; its name and who has it stay. */
|
|
3538
|
+
let secretReplacing = ''; let secretSaid = null;
|
|
3539
|
+
function secretReplace(chosen) {
|
|
3540
|
+
const said = el(secretReplacing === chosen.name ? 'span' : 'p', 'hint secret-replace-said', secretSaid?.name === chosen.name ? secretSaid.text : ''); said.setAttribute('role', 'status');
|
|
3541
|
+
if (secretReplacing !== chosen.name) {
|
|
3542
|
+
const open = el('button', '', 'Replace the value...'); open.type = 'button'; open.id = 'secret-replace-open';
|
|
3543
|
+
open.addEventListener('click', () => { secretReplacing = chosen.name; secretSaid = null; void paintAssets(); });
|
|
3544
|
+
const what = el('div', 'set-what'); what.append(el('span', '', 'Value'), el('small', '', 'Never shown'));
|
|
3545
|
+
const control = el('div', 'set-control'); control.append(open);
|
|
3546
|
+
const row = el('div', 'set-row'); row.append(what, control);
|
|
3547
|
+
return { rows: said.textContent ? [row, said] : [row], card: [] };
|
|
3548
|
+
}
|
|
3549
|
+
const form = el('form', 'set-rows as-block secret-replace'); form.id = 'secret-replace'; form.autocomplete = 'off';
|
|
3550
|
+
const value = el('input'); value.id = 'secret-replace-value'; value.type = 'password'; value.autocomplete = 'new-password'; value.setAttribute('aria-label', 'New value');
|
|
3551
|
+
const lines = el('textarea', 'secret-lines'); lines.id = 'secret-replace-lines'; lines.rows = 5; lines.spellcheck = false; lines.hidden = true; lines.setAttribute('aria-label', 'New value, several lines');
|
|
3552
|
+
/* A key pasted: its lines kept, in a box of several lines, masked too. */
|
|
3553
|
+
value.addEventListener('paste', (event) => {
|
|
3554
|
+
const text = event.clipboardData?.getData('text') ?? '';
|
|
3555
|
+
if (!/[\r\n]/.test(text.replace(/[\r\n]+$/, ''))) return;
|
|
3556
|
+
event.preventDefault();
|
|
3557
|
+
lines.value = text.replace(/\r\n?/g, '\n'); lines.hidden = false; value.hidden = true; value.value = ''; lines.focus();
|
|
3558
|
+
});
|
|
3559
|
+
const day = el('input'); day.id = 'secret-replace-expires'; day.type = 'date'; day.value = chosen.secret.expires ?? ''; day.setAttribute('aria-label', 'Expires');
|
|
3560
|
+
const field = (label, small, ...control) => {
|
|
3561
|
+
const what = el('div', 'set-what'); what.append(el('span', '', label), el('small', '', small));
|
|
3562
|
+
const c = el('div', 'set-control'); c.append(...control);
|
|
3563
|
+
const row = el('div', 'set-row'); row.append(what, c); return row;
|
|
3564
|
+
};
|
|
3565
|
+
const cancel = el('button', '', 'Cancel'); cancel.type = 'button';
|
|
3566
|
+
cancel.addEventListener('click', () => { secretReplacing = ''; void paintAssets(); });
|
|
3567
|
+
const go = el('button', 'primary', 'Replace'); go.type = 'submit';
|
|
3568
|
+
const actions = el('div', 'action-row'); actions.append(said, cancel, go);
|
|
3569
|
+
form.append(field('New value', 'Never shown · empty keeps it', value, lines), field('Expires', 'Optional', day), actions);
|
|
3570
|
+
form.addEventListener('submit', async (event) => {
|
|
3571
|
+
event.preventDefault();
|
|
3572
|
+
$('assets-error').hidden = true;
|
|
3573
|
+
const typed = lines.hidden ? value.value : lines.value.replace(/\r\n?/g, '\n');
|
|
3574
|
+
const body = { expires: day.value };
|
|
3575
|
+
if (typed) body.value = typed;
|
|
3576
|
+
/* Not kept in the page a moment longer. */
|
|
3577
|
+
value.value = ''; lines.value = '';
|
|
3578
|
+
try { await post(`${API}/secrets/${chosen.name}/replace`, body); secretReplacing = ''; secretSaid = { name: chosen.name, text: 'Machines get it at their next start' }; }
|
|
3579
|
+
catch (error) { $('assets-error').textContent = error.message; $('assets-error').hidden = false; }
|
|
3580
|
+
await paintAssets();
|
|
3581
|
+
});
|
|
3582
|
+
setTimeout(() => value.focus(), 0);
|
|
3583
|
+
return { rows: [], card: [form] };
|
|
3584
|
+
}
|
|
3585
|
+
|
|
3429
3586
|
/* ---- the server's ---- */
|
|
3430
3587
|
let assetOpen = ''; let assetsAdding = ''; let assetsQuery = ''; let remoteShown = ''; let remoteEditing = false;
|
|
3431
3588
|
async function paintAssets() {
|
|
3432
3589
|
if (place !== 'assets' || DEVICE) return;
|
|
3433
3590
|
const [all, boxes, secrets, keys] = await Promise.all([getJson('/resources', []), getJson('/mailboxes', []), getJson('/secrets', []), getJson('/git-keys', []), readDevices()]);
|
|
3434
3591
|
paintKeys(keys);
|
|
3592
|
+
markSecrets(secrets);
|
|
3435
3593
|
const items = [];
|
|
3436
3594
|
for (const r of all) {
|
|
3437
3595
|
const kind = kindOf(r); const users = Object.keys(r.attachments ?? {}).length;
|
|
@@ -3439,7 +3597,7 @@
|
|
|
3439
3597
|
items.push({ key: `${kind}:${r.name}`, kind, name: r.name, resource: r, box, badge: String(users), badgeTitle: `Used by ${users} conversation${users === 1 ? '' : 's'}`, badgeTone: 'count',
|
|
3440
3598
|
sub: kind === 'git' ? `${gitSub(r)}${viaText(r.via)}` : kind === 'mailbox' ? boxSub(box) : 'folder', tone: box?.failure ? 'bad' : '' });
|
|
3441
3599
|
}
|
|
3442
|
-
for (const s2 of secrets) items.push({ key: `secret:${s2.name}`, kind: 'secret', name: s2.name, secret: s2, badge: String(s2.conversations.length), badgeTitle: `Used by ${s2.conversations.length} conversation${s2.conversations.length === 1 ? '' : 's'}`, badgeTone: 'count',
|
|
3600
|
+
for (const s2 of secrets) items.push({ key: `secret:${s2.name}`, kind: 'secret', name: s2.name, secret: s2, badge: String(s2.conversations.length), badgeTitle: `Used by ${s2.conversations.length} conversation${s2.conversations.length === 1 ? '' : 's'}`, badgeTone: 'count', ...secretItem(s2, 'name only') });
|
|
3443
3601
|
const shown = assetsQuery ? items.filter((i) => i.name.includes(assetsQuery.toLowerCase()) || i.name.toLowerCase().includes(assetsQuery.toLowerCase())) : items;
|
|
3444
3602
|
const chosen = assetsAdding ? null : items.find((i) => i.key === assetOpen) ?? null;
|
|
3445
3603
|
$('assets-as').dataset.open = chosen || assetsAdding ? 'detail' : 'list';
|
|
@@ -3489,7 +3647,7 @@
|
|
|
3489
3647
|
const form = el('form', 'set-row secret-rename'); form.autocomplete = 'off';
|
|
3490
3648
|
const name = el('input'); name.id = 'secret-rename-name'; name.value = chosen.name; name.maxLength = 40; name.pattern = '[A-Z][A-Z0-9_]*'; name.spellcheck = false; name.autocapitalize = 'characters'; name.setAttribute('aria-label', 'New name');
|
|
3491
3649
|
const go = el('button', '', 'Rename'); go.type = 'submit';
|
|
3492
|
-
const what = el('div', 'set-what'); what.append(el('span', '', 'Name'), el('small', '', '
|
|
3650
|
+
const what = el('div', 'set-what'); what.append(el('span', '', 'Name'), el('small', '', 'Applies at next start'));
|
|
3493
3651
|
const control = el('div', 'set-control'); control.append(name, go);
|
|
3494
3652
|
form.append(what, control);
|
|
3495
3653
|
form.addEventListener('submit', async (event) => {
|
|
@@ -3499,8 +3657,10 @@
|
|
|
3499
3657
|
catch (error) { $('assets-error').textContent = error.message; $('assets-error').hidden = false; }
|
|
3500
3658
|
await paintAssets();
|
|
3501
3659
|
});
|
|
3502
|
-
|
|
3503
|
-
|
|
3660
|
+
detail.append(secretLine(chosen.secret, 'not given to machines'));
|
|
3661
|
+
const replace = secretReplace(chosen);
|
|
3662
|
+
const box = el('div', 'set-rows as-block'); box.append(form, ...replace.rows);
|
|
3663
|
+
detail.append(box, ...replace.card);
|
|
3504
3664
|
}
|
|
3505
3665
|
/* Used by: each conversation that has it, what it may do; "+" offers the others. */
|
|
3506
3666
|
const options = chosen.kind === 'secret' ? [['off', 'Off'], ['use', 'Use']] : chosen.kind === 'mailbox' ? [['none', 'Off'], ['read', 'Read']] : [['none', 'Off'], ['read', 'Read'], ['write', 'Write']];
|
|
@@ -3728,7 +3888,8 @@
|
|
|
3728
3888
|
const lines = !$('secret-lines').hidden;
|
|
3729
3889
|
/* A key's last line ends with a line break: kept as it was pasted. */
|
|
3730
3890
|
const value = lines ? $('secret-lines').value.replace(/\r\n?/g, '\n') : $('secret-value').value;
|
|
3731
|
-
|
|
3891
|
+
const expires = $('secret-expires').value;
|
|
3892
|
+
try { await post(`${API}/secrets`, { name: $('secret-name').value.trim(), value, ...(expires ? { expires } : {}) }); assetOpen = `secret:${$('secret-name').value.trim()}`; assetsAdding = ''; $('secret-name').value = ''; $('secret-expires').value = ''; secretLines(false, ''); }
|
|
3732
3893
|
catch (error) { $('assets-error').textContent = error.message; $('assets-error').hidden = false; }
|
|
3733
3894
|
await paintAssets();
|
|
3734
3895
|
});
|
|
@@ -4602,7 +4763,17 @@
|
|
|
4602
4763
|
for (const e of got) {
|
|
4603
4764
|
const li = el('li', 'event'); li.dataset.kind = e.kind;
|
|
4604
4765
|
const when = el('time', 'event-when', new Date(e.at).toLocaleString([], { day: 'numeric', month: 'short', hour: '2-digit', minute: '2-digit' })); when.dateTime = e.at;
|
|
4605
|
-
|
|
4766
|
+
/* Which conversation, in a column of its own (and out of the text, where older lines put it first): one click opens it. */
|
|
4767
|
+
const conv = el('span', 'event-conv');
|
|
4768
|
+
let text = e.text;
|
|
4769
|
+
if (e.conversation) {
|
|
4770
|
+
if (text.startsWith(`${e.conversation}: `)) text = text.slice(e.conversation.length + 2);
|
|
4771
|
+
const open = el('button', 'as-link', e.conversation); open.type = 'button'; open.title = `Open ${e.conversation}`;
|
|
4772
|
+
open.disabled = !conversations.some((c) => c.name === e.conversation);
|
|
4773
|
+
open.addEventListener('click', () => { leavePlace(); select(e.conversation); });
|
|
4774
|
+
conv.append(open);
|
|
4775
|
+
}
|
|
4776
|
+
li.append(when, el('span', 'event-kind', EVENT_WORDS[e.kind] ?? e.kind), conv, el('span', 'event-text', text));
|
|
4606
4777
|
if (e.who && !e.text.includes(e.who)) li.append(el('span', 'event-who', e.who));
|
|
4607
4778
|
list.append(li);
|
|
4608
4779
|
}
|
|
@@ -4615,7 +4786,7 @@
|
|
|
4615
4786
|
$('events-q').addEventListener('input', () => { clearTimeout(eventsTyping); eventsTyping = setTimeout(() => { void paintEvents(); }, 250); });
|
|
4616
4787
|
$('events-more').addEventListener('click', () => { void paintEvents({ more: true }); });
|
|
4617
4788
|
$('events-copy').addEventListener('click', async () => {
|
|
4618
|
-
const text = eventsShown.map((e) => `${e.at}\t${e.kind}\t${e.text}${e.who ? `\t${e.who}` : ''}`).join('\n');
|
|
4789
|
+
const text = eventsShown.map((e) => `${e.at}\t${e.kind}\t${e.conversation ?? ''}\t${e.text}${e.who ? `\t${e.who}` : ''}`).join('\n');
|
|
4619
4790
|
try { await navigator.clipboard.writeText(text); $('events-said').textContent = `Copied: ${eventsShown.length} lines.`; } catch { $('events-said').textContent = 'The clipboard is not available here.'; }
|
|
4620
4791
|
});
|
|
4621
4792
|
/* WHAT THE SERVER'S PROGRAMS SAID: one source over a span, to read, copy whole or keep as a file. */
|
package/web/index.html
CHANGED
|
@@ -519,6 +519,7 @@
|
|
|
519
519
|
<div class="row"><input id="secret-name" maxlength="40" pattern="[A-Z][A-Z0-9_]*" title="Capitals, digits and underscores, starting with a letter. Example: MODEL_KEY" placeholder="MODEL_KEY" spellcheck="false" autocapitalize="characters" required>
|
|
520
520
|
<input id="secret-value" type="password" placeholder="value (never shown again)" autocomplete="new-password" required>
|
|
521
521
|
<button type="submit" class="primary">Save</button></div>
|
|
522
|
+
<div class="row secret-expiry"><label for="secret-expires">Expires</label><input id="secret-expires" type="date"><small class="hint">Optional</small></div>
|
|
522
523
|
<!-- A key or a certificate is several lines: pasted into the line above, they come here by themselves. -->
|
|
523
524
|
<textarea id="secret-lines" class="secret-lines" rows="7" spellcheck="false" autocomplete="off" autocapitalize="off" placeholder="-----BEGIN ...----- ... -----END ...-----" aria-label="Value, several lines (never shown again)" hidden></textarea>
|
|
524
525
|
<button type="button" id="secret-lines-switch" class="as-link">Several lines (a key, a certificate)</button>
|
|
@@ -552,7 +553,7 @@
|
|
|
552
553
|
<details class="chapter" id="settings-ch-screen" data-chapter="s-screen">
|
|
553
554
|
<summary><span class="chapter-title">Screen</span><span class="chapter-about">Theme, text size, the app.</span></summary>
|
|
554
555
|
<div class="chapter-body">
|
|
555
|
-
<div class="set-row"><div class="set-what"><span>Theme</span><small>This device only</small></div><div class="set-control"><
|
|
556
|
+
<div class="set-row"><div class="set-what"><span>Theme</span><small>This device only</small></div><div class="set-control"><div class="levels" id="theme" role="group" aria-label="Theme"><button type="button" data-theme="light">Light</button><button type="button" data-theme="dark">Dark</button><button type="button" data-theme="system">System</button></div></div></div>
|
|
556
557
|
<div class="set-row"><div class="set-what"><span>Text size</span><small>Also: a pinch, or Ctrl + and Ctrl -</small></div><div class="set-control"><span class="text-size" id="settings-text" role="group" aria-label="Text size"><button type="button" data-text="smaller" aria-label="Smaller text">A−</button><button type="button" data-text="normal" aria-label="Normal text size" class="text-now">100%</button><button type="button" data-text="larger" aria-label="Larger text">A+</button></span></div></div>
|
|
557
558
|
<div class="set-row" id="install-row" hidden><div class="set-what"><span>App</span><small>Installed on this device's home screen</small></div><div class="set-control"><button type="button" id="install" class="primary" hidden>Install the app</button></div></div>
|
|
558
559
|
<form id="install-name-form" class="set-row" autocomplete="off" hidden><div class="set-what"><label for="install-name">Name on this device</label></div><div class="set-control"><input id="install-name" maxlength="30" spellcheck="false"><button type="submit" class="primary">Install</button><button type="button" id="install-name-cancel">Cancel</button></div></form>
|