clavarium 0.2.38-next.1 → 0.2.40-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.38-next.1",
3
+ "version": "0.2.40-next.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "clavarium",
9
- "version": "0.2.38-next.1",
9
+ "version": "0.2.40-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.38-next.1",
3
+ "version": "0.2.40-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.",
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,11 +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
- /* Who committed it, then its short id and when: set as text, never markup. */
99
- const author = c.author ? `${c.author} · ` : '';
100
- const meta = document.createElement('small'); meta.textContent = ` · ${author}${c.id.slice(0, 7)} · ${when(c.date, now)}`;
101
- 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';
102
138
  /* Its branches: the agent's (filled), the remote's (outlined); the same name on both is one label. */
103
139
  const names = new Map();
104
140
  for (const ref of c.refs ?? []) names.set(ref.name, names.has(ref.name) && names.get(ref.name) !== ref.side ? 'both' : ref.side);
@@ -106,13 +142,25 @@
106
142
  const pill = document.createElement('span'); pill.className = `gg-ref gg-${side}`; pill.textContent = name;
107
143
  pill.style.setProperty('--c', colour(r.col));
108
144
  pill.title = side === 'agent' ? `The agent's ${name}` : side === 'remote' ? `The remote's ${name}` : `${name}, the same here and on the remote`;
109
- 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
+ }
110
155
  }
156
+ meta.append(author, time, sha, refs);
157
+ b.append(subject, meta);
111
158
  if (pick) b.addEventListener('click', () => pick(c));
112
159
  list.append(b);
113
160
  });
114
161
  box.append(svg, list);
115
- return box;
162
+ wrap.append(bar, box);
163
+ return wrap;
116
164
  }
117
- globalThis.clavariumGraph = { layout, draw, when };
165
+ globalThis.clavariumGraph = { layout, draw, when, syncCounts };
118
166
  })();
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); }