clavarium 0.2.37-next.1 → 0.2.39-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.37-next.1",
3
+ "version": "0.2.39-next.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "clavarium",
9
- "version": "0.2.37-next.1",
9
+ "version": "0.2.39-next.1",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@xterm/addon-fit": "^0.11.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.37-next.1",
3
+ "version": "0.2.39-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.",
@@ -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/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,14 @@
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
+ const subject = cell('gg-subject', 'span', c.subject || '(no message)'); subject.title = c.subject || '';
131
+ const author = cell('gg-author', 'span', c.author || '');
132
+ const time = cell('gg-time', 'small', when(c.date, now));
133
+ const sha = cell('gg-id', 'small', c.id.slice(0, 7));
134
+ b.append(subject, author, time, sha);
100
135
  /* Its branches: the agent's (filled), the remote's (outlined); the same name on both is one label. */
101
136
  const names = new Map();
102
137
  for (const ref of c.refs ?? []) names.set(ref.name, names.has(ref.name) && names.get(ref.name) !== ref.side ? 'both' : ref.side);
@@ -105,12 +140,22 @@
105
140
  pill.style.setProperty('--c', colour(r.col));
106
141
  pill.title = side === 'agent' ? `The agent's ${name}` : side === 'remote' ? `The remote's ${name}` : `${name}, the same here and on the remote`;
107
142
  b.append(pill);
143
+ /* On the agent's tip of a branch that is not level with the remote:
144
+ how far it is ahead and behind (shown only in the detailed view). */
145
+ const n = side !== 'remote' && counts[name];
146
+ if (n && (n.ahead || n.behind)) {
147
+ const badge = document.createElement('small'); badge.className = 'gg-count';
148
+ badge.textContent = `${n.ahead ? `↑${n.ahead}` : ''}${n.behind ? ` ↓${n.behind}` : ''}`.trim();
149
+ badge.title = `${n.ahead} ahead of, ${n.behind} behind the remote`;
150
+ b.append(badge);
151
+ }
108
152
  }
109
153
  if (pick) b.addEventListener('click', () => pick(c));
110
154
  list.append(b);
111
155
  });
112
156
  box.append(svg, list);
113
- return box;
157
+ wrap.append(bar, box);
158
+ return wrap;
114
159
  }
115
- globalThis.clavariumGraph = { layout, draw, when };
160
+ globalThis.clavariumGraph = { layout, draw, when, syncCounts };
116
161
  })();
package/web/style.css CHANGED
@@ -1168,12 +1168,24 @@ 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-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); }
1171
1175
  .gg { position: relative; min-width: max-content; }
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; }
1178
+ .gg-row { display: flex; align-items: center; gap: 12px; height: 30px; padding: 0 6px; border: 0; border-radius: 6px; background: transparent; text-align: left; font-weight: 400; white-space: nowrap; }
1175
1179
  .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; }
1180
+ /* Fixed columns, so the author and the branches line up down the rows. */
1181
+ .gg-subject { flex: none; width: 30ch; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
1182
+ .gg-author { flex: none; width: 12ch; color: var(--ink2); overflow: hidden; text-overflow: ellipsis; }
1183
+ .gg-time { flex: none; width: 9ch; color: var(--ink2); }
1184
+ .gg-id { flex: none; width: 7ch; color: var(--ink2); font-family: ui-monospace, Menlo, Consolas, monospace; opacity: .8; }
1185
+ .gg-count { flex: none; color: var(--ink2); font-weight: 700; font-size: .72rem; }
1186
+ /* The id, the time and the ahead/behind count come in only when asked. */
1187
+ .gg-id, .gg-time, .gg-count { display: none; }
1188
+ .gg-detailed .gg-id, .gg-detailed .gg-time, .gg-detailed .gg-count { display: inline-block; }
1177
1189
  .gg-row small { color: var(--ink2); }
1178
1190
  .gg-ref { font-size: .6875rem; font-weight: 700; padding: 1px 8px; border-radius: 999px; color: var(--c); border: 1px solid var(--c); }
1179
1191
  .gg-agent, .gg-both { background: color-mix(in srgb, var(--c) 16%, transparent); }