clavarium 0.2.36-beta.2 → 0.2.37-beta.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.
@@ -274,7 +274,7 @@ export class Updater {
274
274
  this.restart = restart ?? (() => this.#restart());
275
275
  /* What was seen when the server did not come up: its journal, its unit, who holds its port. */
276
276
  this.diagnose = diagnose ?? (() => this.#diagnose());
277
- this.health = health ?? ((release) => this.#health(release));
277
+ this.health = health ?? ((release, opts) => this.#health(release, opts));
278
278
  this.backup = backup ?? ((app) => this.#backup(app));
279
279
  this.restoreData = restoreData ?? ((app, archive) => this.#restoreData(app, archive));
280
280
  this.installPrivileged = installPrivileged ?? ((app) => this.#installPrivileged(app));
@@ -606,13 +606,16 @@ export class Updater {
606
606
  await this.installPrivileged(release.app);
607
607
  } catch (error) { return `it could not be put in place: ${error.message}`; }
608
608
  this.#step(action, version, 'Restarting');
609
- return this.#restartAndCheck(release);
609
+ /* Once the new server answers, the maintenance page is gone but a minute or two of
610
+ watching that it stays up is left: said as "Confirming", not "Restarting", so a page
611
+ back up does not look stuck restarting (deploy/updater.mjs, #health onUp). */
612
+ return this.#restartAndCheck(release, () => this.#step(action, version, 'Confirming'));
610
613
  }
611
614
  /* '' when it came up, or why not. */
612
- async #restartAndCheck(release) {
615
+ async #restartAndCheck(release, onUp) {
613
616
  const r = await this.restart().catch((e) => ({ code: 1, stderr: e.message }));
614
617
  if (r?.code) return `the server did not restart: ${lastLine(r)}`;
615
- const h = await this.health(release).catch((e) => e.message || 'no answer');
618
+ const h = await this.health(release, { onUp }).catch((e) => e.message || 'no answer');
616
619
  return h || '';
617
620
  }
618
621
 
@@ -802,7 +805,7 @@ export class Updater {
802
805
 
803
806
  /* Comes up (answers, from this release) within healthMs, then STAYS up: watched until watchMs after
804
807
  the restart; one restart by systemd is forgiven if it answers at the end, not two. */
805
- async #health(release) {
808
+ async #health(release, { onUp } = {}) {
806
809
  const { clock, sleep } = this.#o;
807
810
  const start = clock();
808
811
  const target = realpathSync(release.dir);
@@ -820,7 +823,8 @@ export class Updater {
820
823
  if (clock() - start > this.#o.healthMs) return said;
821
824
  await sleep(1000);
822
825
  }
823
- /* And it stays up. */
826
+ /* It answers, from this release: the maintenance page gives way. Now it must stay up. */
827
+ onUp?.();
824
828
  const until = Math.max(start + this.#o.watchMs, clock() + this.#o.settleMs);
825
829
  let restarts = 0;
826
830
  while (clock() < until) {
@@ -1,19 +1,19 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.36-beta.2",
3
+ "version": "0.2.37-beta.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "clavarium",
9
- "version": "0.2.36-beta.2",
9
+ "version": "0.2.37-beta.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-binder": "0.1.5-next.2",
14
+ "clavarium-binder": "0.1.6-next.1",
15
15
  "clavarium-docket": "0.1.1",
16
- "clavarium-parley": "0.17.3-next.1",
16
+ "clavarium-parley": "0.17.4-next.1",
17
17
  "mermaid": "11.17.2",
18
18
  "node-pty": "^1.1.0",
19
19
  "pdfjs-dist": "6.4.299",
@@ -688,9 +688,9 @@
688
688
  }
689
689
  },
690
690
  "node_modules/clavarium-binder": {
691
- "version": "0.1.5-next.2",
692
- "resolved": "https://registry.npmjs.org/clavarium-binder/-/clavarium-binder-0.1.5-next.2.tgz",
693
- "integrity": "sha512-KfVcxnkVufYL29KqxljhrBC616wDMYUwh3xKcM9inaoOATYAje3Uo+1vTrDhtFqjtmlPFlvzwlwyu6ZO7vtuEA==",
691
+ "version": "0.1.6-next.1",
692
+ "resolved": "https://registry.npmjs.org/clavarium-binder/-/clavarium-binder-0.1.6-next.1.tgz",
693
+ "integrity": "sha512-urE1ZZCYq9svQmQR1ailNX6r5OeBcT0wNDea498PMDRbmcUCOciqoF/1C3IGLT7z133eb4dOUEhVcbRE42/h3A==",
694
694
  "license": "MIT",
695
695
  "bin": {
696
696
  "binder": "bin/binder.mjs",
@@ -714,9 +714,9 @@
714
714
  }
715
715
  },
716
716
  "node_modules/clavarium-parley": {
717
- "version": "0.17.3-next.1",
718
- "resolved": "https://registry.npmjs.org/clavarium-parley/-/clavarium-parley-0.17.3-next.1.tgz",
719
- "integrity": "sha512-wnaCSkDrcaZE/Tf1y7LI0NiYLnz9qAEjZwYeT+DSquvoMIDU43dugBuW7QdNyP1NB8knupaWqXH29oNSZ9n8jw==",
717
+ "version": "0.17.4-next.1",
718
+ "resolved": "https://registry.npmjs.org/clavarium-parley/-/clavarium-parley-0.17.4-next.1.tgz",
719
+ "integrity": "sha512-/rQy9WLP9/XndInawH6mIhS9RivA1IQmMpB5IhYMUflnLSWBvP096Z0TF3xB3u2X1e8uni4tar5Tua5hq/wjWg==",
720
720
  "license": "MIT",
721
721
  "bin": {
722
722
  "parley": "bin/parley.mjs",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.36-beta.2",
3
+ "version": "0.2.37-beta.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,9 +44,9 @@
44
44
  "dependencies": {
45
45
  "@xterm/addon-fit": "^0.11.0",
46
46
  "@xterm/xterm": "^6.0.0",
47
- "clavarium-binder": "0.1.5-next.2",
47
+ "clavarium-binder": "0.1.6-next.1",
48
48
  "clavarium-docket": "0.1.1",
49
- "clavarium-parley": "0.17.3-next.1",
49
+ "clavarium-parley": "0.17.4-next.1",
50
50
  "mermaid": "11.17.2",
51
51
  "node-pty": "^1.1.0",
52
52
  "pdfjs-dist": "6.4.299",
@@ -429,7 +429,9 @@ export class GitReview {
429
429
  /* THE BRANCH DIAGRAM: the agent's branches, the remote's, and their
430
430
  last commits, newest first in topological order: { branches: [{name,
431
431
  id, side: 'agent'|'remote'}], commits: [{id, parents, subject, date,
432
- refs: [{name, side}]}] }. What the agent wrote is escaped as everywhere. */
432
+ author, refs: [{name, side}]}] }. `author` is who committed it, so a
433
+ person can see whose work a commit is. What the agent wrote is escaped
434
+ as everywhere. */
433
435
  async graph(name) {
434
436
  const r = this.#repository(name);
435
437
  try {
@@ -438,13 +440,13 @@ export class GitReview {
438
440
  for (const [b, id] of [...remoteTips].sort(([a], [c]) => a.localeCompare(c)).slice(0, GRAPH_BRANCHES)) branches.push({ name: escaped(b), id, side: 'remote' });
439
441
  const tips = [...new Set(branches.map((b) => b.id))];
440
442
  if (tips.length === 0) return { branches, commits: [] };
441
- const log = await this.#runner.in(got.path, ['log', '--topo-order', `--max-count=${GRAPH_COMMITS}`, '-z', '--format=%H%x00%P%x00%aI%x00%s', '--stdin', '--end-of-options'], { input: `${tips.join('\n')}\n`, deadlineMs: 60_000, maxBytes: 4 * 1024 * 1024 });
443
+ const log = await this.#runner.in(got.path, ['log', '--topo-order', `--max-count=${GRAPH_COMMITS}`, '-z', '--format=%H%x00%P%x00%an%x00%aI%x00%s', '--stdin', '--end-of-options'], { input: `${tips.join('\n')}\n`, deadlineMs: 60_000, maxBytes: 4 * 1024 * 1024 });
442
444
  const fields = log.stdout.toString('utf8').split('\0');
443
445
  const commits = [];
444
- for (let i = 0; i + 3 < fields.length; i += 4) {
446
+ for (let i = 0; i + 4 < fields.length; i += 5) {
445
447
  const id = fields[i].replace(/^\n/, '');
446
448
  if (!isId(id)) break;
447
- commits.push({ id, parents: fields[i + 1].split(' ').filter(isId), date: fields[i + 2], subject: escaped(fields[i + 3]).slice(0, 300),
449
+ commits.push({ id, parents: fields[i + 1].split(' ').filter(isId), author: escaped(fields[i + 2]).slice(0, 200), date: fields[i + 3], subject: escaped(fields[i + 4]).slice(0, 300),
448
450
  refs: branches.filter((b) => b.id === id).map((b) => ({ name: b.name, side: b.side })) });
449
451
  }
450
452
  return { branches, commits };
package/web/app.js CHANGED
@@ -4681,7 +4681,7 @@
4681
4681
  $('updates-state').textContent = running ? `${running.action === 'back' ? 'Going back to' : 'Updating to'} ${running.version}: ${running.step.toLowerCase()}...`
4682
4682
  : u.checkError ? 'Could not check just now.'
4683
4683
  : u.available ? `${u.available} is out.`
4684
- : u.checkedAt ? `Up to date · checked ${sinceWords(u.checkedAt)}` : 'Up to date';
4684
+ : u.checkedAt ? `Nothing newer to install · checked ${sinceWords(u.checkedAt)}` : 'Nothing newer to install';
4685
4685
  $('updates-check').disabled = Boolean(running);
4686
4686
  $('updates-offer').hidden = !u.available || Boolean(running);
4687
4687
  /* A version that already failed here is not offered as usual: tried again only on purpose, warned. */
package/web/gitgraph.js CHANGED
@@ -52,12 +52,42 @@
52
52
  return d.toLocaleDateString([], { day: 'numeric', month: 'short' });
53
53
  }
54
54
 
55
+ /* How far the agent's branch is ahead of or behind the remote's, for a
56
+ branch that both carry at different commits: counted among the commits
57
+ drawn (a parent older than the diagram stops the walk). -> { name:
58
+ { ahead, behind } }. */
59
+ function syncCounts(commits) {
60
+ const parents = new Map((commits ?? []).map((c) => [c.id, c.parents ?? []]));
61
+ const reach = (start) => { const seen = new Set(); const stack = [start]; while (stack.length) { const x = stack.pop(); if (seen.has(x) || !parents.has(x)) continue; seen.add(x); for (const p of parents.get(x)) stack.push(p); } return seen; };
62
+ const tips = {};
63
+ for (const c of commits ?? []) for (const ref of c.refs ?? []) (tips[ref.name] ??= {})[ref.side] = c.id;
64
+ const out = {};
65
+ for (const [name, t] of Object.entries(tips)) {
66
+ if (!t.agent || !t.remote || t.agent === t.remote) continue;
67
+ const a = reach(t.agent); const r = reach(t.remote);
68
+ let ahead = 0; let behind = 0;
69
+ for (const x of a) if (!r.has(x)) ahead++;
70
+ for (const x of r) if (!a.has(x)) behind++;
71
+ out[name] = { ahead, behind };
72
+ }
73
+ return out;
74
+ }
75
+
55
76
  const NS = 'http://www.w3.org/2000/svg';
56
77
  /* graph: what /api/git/<name>/graph answers. pick(commit): a row was chosen. */
57
78
  function draw(graph, { pick, now } = {}) {
58
79
  const commits = graph?.commits ?? [];
59
80
  const box = document.createElement('div'); box.className = 'gg';
60
81
  if (commits.length === 0) { const p = document.createElement('p'); p.className = 'hint'; p.textContent = 'Nothing committed yet.'; box.append(p); return box; }
82
+ const counts = syncCounts(commits);
83
+ /* By default a row shows its message, who committed it, and its branches.
84
+ One click brings in the id, the time and the ahead/behind count; the
85
+ choice is not kept -- it is only how this diagram is being looked at. */
86
+ const wrap = document.createElement('div'); wrap.className = 'gg-wrap';
87
+ const bar = document.createElement('div'); bar.className = 'gg-bar';
88
+ const toggle = document.createElement('button'); toggle.type = 'button'; toggle.className = 'gg-toggle'; toggle.textContent = 'Détails'; toggle.setAttribute('aria-pressed', 'false');
89
+ toggle.addEventListener('click', () => toggle.setAttribute('aria-pressed', box.classList.toggle('gg-detailed') ? 'true' : 'false'));
90
+ bar.append(toggle);
61
91
  const { rows, edges, cols } = layout(commits);
62
92
  const width = PAD * 2 + (cols - 1) * LANE; const height = rows.length * ROW;
63
93
  const svg = document.createElementNS(NS, 'svg');
@@ -94,9 +124,17 @@
94
124
  const c = commits[i];
95
125
  const b = document.createElement('button'); b.type = 'button'; b.className = 'gg-row'; b.dataset.id = c.id;
96
126
  b.title = `Open the review of ${c.id.slice(0, 7)}`;
97
- const subject = document.createElement('span'); subject.className = 'gg-subject'; subject.textContent = c.subject || '(no message)';
98
- const meta = document.createElement('small'); meta.textContent = ` · ${c.id.slice(0, 7)} · ${when(c.date, now)}`;
99
- b.append(subject, meta);
127
+ /* Fixed columns, so the author, the time and the branches line up
128
+ down the rows and read at a glance. All set as text, never markup. */
129
+ const cell = (cls, tag, text) => { const e = document.createElement(tag); e.className = cls; e.textContent = text; return e; };
130
+ /* The message takes all the room it can and is cut only when it must;
131
+ the other columns are a fixed block on the right. */
132
+ const subject = cell('gg-subject', 'span', c.subject || '(no message)'); subject.title = c.subject || '';
133
+ const meta = document.createElement('div'); meta.className = 'gg-meta';
134
+ const author = cell('gg-author', 'span', c.author || '');
135
+ const time = cell('gg-time', 'small', when(c.date, now));
136
+ const sha = cell('gg-id', 'small', c.id.slice(0, 7));
137
+ const refs = document.createElement('div'); refs.className = 'gg-refs';
100
138
  /* Its branches: the agent's (filled), the remote's (outlined); the same name on both is one label. */
101
139
  const names = new Map();
102
140
  for (const ref of c.refs ?? []) names.set(ref.name, names.has(ref.name) && names.get(ref.name) !== ref.side ? 'both' : ref.side);
@@ -104,13 +142,25 @@
104
142
  const pill = document.createElement('span'); pill.className = `gg-ref gg-${side}`; pill.textContent = name;
105
143
  pill.style.setProperty('--c', colour(r.col));
106
144
  pill.title = side === 'agent' ? `The agent's ${name}` : side === 'remote' ? `The remote's ${name}` : `${name}, the same here and on the remote`;
107
- b.append(pill);
145
+ refs.append(pill);
146
+ /* On the agent's tip of a branch that is not level with the remote:
147
+ how far it is ahead and behind (shown only in the detailed view). */
148
+ const n = side !== 'remote' && counts[name];
149
+ if (n && (n.ahead || n.behind)) {
150
+ const badge = document.createElement('small'); badge.className = 'gg-count';
151
+ badge.textContent = `${n.ahead ? `↑${n.ahead}` : ''}${n.behind ? ` ↓${n.behind}` : ''}`.trim();
152
+ badge.title = `${n.ahead} ahead of, ${n.behind} behind the remote`;
153
+ refs.append(badge);
154
+ }
108
155
  }
156
+ meta.append(author, time, sha, refs);
157
+ b.append(subject, meta);
109
158
  if (pick) b.addEventListener('click', () => pick(c));
110
159
  list.append(b);
111
160
  });
112
161
  box.append(svg, list);
113
- return box;
162
+ wrap.append(bar, box);
163
+ return wrap;
114
164
  }
115
- globalThis.clavariumGraph = { layout, draw, when };
165
+ globalThis.clavariumGraph = { layout, draw, when, syncCounts };
116
166
  })();
package/web/index.html CHANGED
@@ -714,7 +714,7 @@
714
714
  <div id="updates-settings" class="set-rows">
715
715
  <div class="set-row"><div class="set-what"><label for="updates-mode">Mode</label><small>When updates are installed</small></div><div class="set-control"><select id="updates-mode"><option value="auto">Automatic, in a window</option><option value="asap">As soon as out</option><option value="ask">Ask me</option><option value="off">Off</option></select></div></div>
716
716
  <div class="set-row" id="updates-window-row"><div class="set-what"><label for="updates-from" id="updates-window-label">Window</label><small>Hours when it may restart</small></div><div class="set-control"><span id="updates-window" class="updates-window"><input type="time" id="updates-from" aria-label="From"><span aria-hidden="true">to</span><input type="time" id="updates-to" aria-label="To"></span></div></div>
717
- <div class="set-row"><div class="set-what"><label for="updates-channel">Channel</label><small>Stable, or earlier builds</small></div><div class="set-control"><select id="updates-channel"><option value="next">Next (earliest tests)</option><option value="beta">Beta (nearly ready)</option><option value="latest">Stable</option></select></div></div>
717
+ <div class="set-row"><div class="set-what"><label for="updates-channel">Channel</label><small>Which builds to follow; you update only to a version newer than this one</small></div><div class="set-control"><select id="updates-channel"><option value="next">Next (earliest tests)</option><option value="beta">Beta (nearly ready)</option><option value="latest">Stable</option></select></div></div>
718
718
  <!-- What the front serves to a browser (server/certificate.mjs). -->
719
719
  <div class="set-row" id="updates-certificate-row" hidden><div class="set-what"><span>Certificate</span><small id="updates-certificate" role="status"></small></div></div>
720
720
  </div>
package/web/style.css CHANGED
@@ -1168,12 +1168,28 @@ header .ic, #folders .ic { width: 18px; height: 18px; fill: none; stroke: curren
1168
1168
  :root { --gg-0: #6d8fe0; --gg-1: #d39a4a; --gg-2: #a77de0; --gg-3: #5fc39d; --gg-4: #e07a8a; --gg-5: #5bc0d6; }
1169
1169
  :root[data-theme="light"] { --gg-0: #2f5bd0; --gg-1: #a86410; --gg-2: #7a46c8; --gg-3: #1f7a5a; --gg-4: #b8324a; --gg-5: #0e7490; }
1170
1170
  .as-graph { border: 1px solid var(--line); border-radius: 12px; background: var(--panel); padding: 12px 14px; overflow-x: auto; }
1171
- .gg { position: relative; min-width: max-content; }
1171
+ .gg-wrap { display: flex; flex-direction: column; gap: 6px; }
1172
+ .gg-bar { display: flex; justify-content: flex-end; }
1173
+ .gg-toggle { font-size: .72rem; padding: 2px 10px; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--ink2); }
1174
+ .gg-toggle[aria-pressed="true"] { color: var(--ink); border-color: var(--gg-0); }
1175
+ .gg { position: relative; width: 100%; }
1172
1176
  .gg-lines { position: absolute; left: 0; top: 0; }
1173
1177
  .gg-rows { display: flex; flex-direction: column; }
1174
- .gg-row { display: flex; align-items: center; gap: 6px; height: 30px; padding: 0 6px; border: 0; border-radius: 6px; background: transparent; text-align: left; font-weight: 400; white-space: nowrap; }
1175
- .gg-row:hover, .gg-row:focus-visible { background: var(--button, #222c38); }
1176
- .gg-subject { font-weight: 600; overflow: hidden; text-overflow: ellipsis; max-width: 32ch; }
1178
+ .gg-row { display: flex; align-items: center; gap: 14px; height: 30px; padding: 0 8px; border: 0; border-radius: 6px; background: transparent; text-align: left; font-weight: 400; white-space: nowrap; width: 100%; }
1179
+ /* A faint highlight on the row the mouse is over, to follow it across a wide screen. */
1180
+ .gg-row:hover, .gg-row:focus-visible { background: color-mix(in srgb, var(--ink) 7%, transparent); }
1181
+ /* The message takes all the room it can; the other columns are a fixed block on the right. */
1182
+ .gg-subject { flex: 1 1 auto; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
1183
+ .gg-meta { flex: none; display: flex; align-items: center; gap: 10px; }
1184
+ .gg-author { width: 11ch; color: var(--ink2); overflow: hidden; text-overflow: ellipsis; }
1185
+ .gg-time { width: 8ch; color: var(--ink2); }
1186
+ .gg-id { width: 7ch; color: var(--ink2); font-family: ui-monospace, Menlo, Consolas, monospace; opacity: .8; }
1187
+ .gg-refs { width: 14ch; flex: none; display: flex; align-items: center; gap: 6px; overflow: hidden; }
1188
+ .gg-count { color: var(--ink2); font-weight: 700; font-size: .72rem; }
1189
+ /* The id, the time and the ahead/behind count come in only when asked. */
1190
+ .gg-id, .gg-time, .gg-count { display: none; }
1191
+ .gg-detailed .gg-id, .gg-detailed .gg-time { display: inline-block; }
1192
+ .gg-detailed .gg-count { display: inline; }
1177
1193
  .gg-row small { color: var(--ink2); }
1178
1194
  .gg-ref { font-size: .6875rem; font-weight: 700; padding: 1px 8px; border-radius: 999px; color: var(--c); border: 1px solid var(--c); }
1179
1195
  .gg-agent, .gg-both { background: color-mix(in srgb, var(--c) 16%, transparent); }