@fungi.computer/bonsai 0.4.4 → 0.4.6

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/CHANGELOG.md CHANGED
@@ -1,5 +1,51 @@
1
1
  # @fungi.computer/bonsai
2
2
 
3
+ ## 0.4.6
4
+
5
+ ### Patch Changes
6
+
7
+ - Changes since 0.4.5:
8
+
9
+ - fix(bonsai): your own commits read You and the actor bar has a legend
10
+ - fix(bonsai): merged change header names the merger and folds the merge hash
11
+ into the meta line
12
+ - fix(bonsai): name members You or A member and never put an id in a fork name
13
+ - fix(bonsai): one actor formatter, readable fork names, plural and loader
14
+ polish
15
+ - fix(bonsai): a merged Change keeps its commits and diff
16
+
17
+ - Updated dependencies
18
+ - Updated dependencies
19
+ - Updated dependencies
20
+ - Updated dependencies
21
+ - Updated dependencies
22
+ - @fungi.computer/agar@0.8.0
23
+ - @fungi.computer/caps@0.8.0
24
+ - @fungi.computer/oyster@0.15.0
25
+ - @fungi.computer/stipe@0.1.1
26
+ - @fungi.computer/watchdog@0.1.3
27
+ - @fungi.computer/trellis@0.7.4
28
+ - @fungi.computer/braid@0.4.6
29
+ - @fungi.computer/nacre@0.2.3
30
+ - @fungi.computer/workflows-wire@0.4.6
31
+ - @fungi.computer/maosaico@0.1.1
32
+ - @fungi.computer/sigils@0.3.0
33
+ - @fungi.computer/puffball@0.5.4
34
+
35
+ ## 0.4.5
36
+
37
+ ### Patch Changes
38
+
39
+ - Updated dependencies
40
+ - @fungi.computer/watchdog@0.1.2
41
+ - @fungi.computer/braid@0.4.5
42
+ - @fungi.computer/oyster@0.14.1
43
+ - @fungi.computer/trellis@0.7.3
44
+ - @fungi.computer/agar@0.7.3
45
+ - @fungi.computer/puffball@0.5.3
46
+ - @fungi.computer/workflows-wire@0.4.5
47
+ - @fungi.computer/nacre@0.2.2
48
+
3
49
  ## 0.4.4
4
50
 
5
51
  ### Patch Changes
@@ -13,7 +13,23 @@ import {
13
13
  type ChangeHistory,
14
14
  } from "./history.js";
15
15
  import type { Bonsai } from "./service.js";
16
- import { gitStore } from "./git.js";
16
+ import { gitStore, type GitStore } from "./git.js";
17
+
18
+ /**
19
+ * The target a Change is compared against. Once merged, the target is the new
20
+ * main, which already holds the work, so a comparison against it shows nothing.
21
+ * The merge commit's first parent is main as it stood before the merge, which
22
+ * keeps the commits and diff that were merged.
23
+ */
24
+ async function comparisonTarget(
25
+ store: GitStore,
26
+ row: ChangeRecord,
27
+ ): Promise<string> {
28
+ if (row.state !== "merged" || row.mergedCommit === null) return row.target;
29
+ const merge = await store.commit(row.repo, row.mergedCommit);
30
+ const [before, merged] = merge?.parents ?? [];
31
+ return before !== undefined && merged === row.head ? before : row.target;
32
+ }
17
33
 
18
34
  async function buildChangeCopy(
19
35
  runtime: Bonsai,
@@ -22,13 +38,13 @@ async function buildChangeCopy(
22
38
  ) {
23
39
  const bonsai = { ...runtime, store: projectionStore(runtime) };
24
40
  const compared =
25
- history ??
41
+ (row.state === "merged" ? undefined : history) ??
26
42
  (await compareChange(
27
43
  bonsai.store,
28
44
  row.repo,
29
45
  row.sourceRepo,
30
46
  row.head,
31
- row.target,
47
+ await comparisonTarget(bonsai.store, row),
32
48
  ));
33
49
  if (compared === null)
34
50
  throw new AppMethodRefusal("not_found", "The proposed head is missing");
@@ -999,9 +999,18 @@ const definition = defineAppBackend<BonsaiMethodContext>({
999
999
  requires: [],
1000
1000
  input: z.strictObject({}),
1001
1001
  output: agentPage,
1002
- handler: (_input, context) => ({
1003
- agents: context.bonsai.state.actors(),
1004
- }),
1002
+ handler: (_input, context, caller) => {
1003
+ const me = callerActor(caller);
1004
+ return {
1005
+ agents: context.bonsai.state
1006
+ .actors()
1007
+ .map((agent) =>
1008
+ agent.kind === "human" && agent.name === me.name
1009
+ ? { ...agent, you: true as const }
1010
+ : agent,
1011
+ ),
1012
+ };
1013
+ },
1005
1014
  }),
1006
1015
  },
1007
1016
  });
@@ -40,6 +40,7 @@ import type {
40
40
  TreeListing,
41
41
  } from "@fungi.computer/agar/roles/files";
42
42
  import { activityEnvelope, type HookEvent } from "../shared/hooks.js";
43
+ import { forkOwnerSlug } from "../shared/actors.js";
43
44
  import { drainOutbox } from "./state.js";
44
45
  import { AppMethodRefusal } from "@fungi.computer/agar/backend";
45
46
  import { readCodeInsights } from "./insights.js";
@@ -400,7 +401,15 @@ export async function forkFor(
400
401
  const source = known(bonsai, name);
401
402
  if (source.parent !== null)
402
403
  throw new AppMethodRefusal("invalid", "Fork the canonical repository");
403
- const forkName = `${source.name}--${actor.name}`;
404
+ let forkName = `${source.name}--${forkOwnerSlug(actor.name)}`;
405
+ // Two members can land on the same pond word; the next word is theirs.
406
+ for (
407
+ let attempt = 1;
408
+ bonsai.state.repo(forkName) !== null &&
409
+ bonsai.state.repo(forkName)?.owner !== actor.name;
410
+ attempt += 1
411
+ )
412
+ forkName = `${source.name}--${forkOwnerSlug(actor.name, attempt)}`;
404
413
  bonsai.state.assertRepoAvailable(forkName);
405
414
  const revision = bonsai.state.repositoryRefStatus(forkName).revision;
406
415
  const sourceRevision = bonsai.state.repositoryRefStatus(source.name).revision;
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@fungi.computer/bonsai",
3
- "version": "0.4.4",
3
+ "version": "0.4.6",
4
4
  "author": "Levi <levi@technomancy.dev>",
5
5
  "type": "module",
6
6
  "description": "Bonsai: a git platform for many agents working at once, on Workers and Artifacts",
7
7
  "dependencies": {
8
- "@fungi.computer/agar": "0.7.2",
9
- "@fungi.computer/caps": "0.7.1",
8
+ "@fungi.computer/agar": "0.8.0",
9
+ "@fungi.computer/caps": "0.8.0",
10
10
  "@fungi.computer/issues": "0.2.0",
11
- "@fungi.computer/oyster": "0.14.0",
12
- "@fungi.computer/puffball": "0.5.2",
11
+ "@fungi.computer/oyster": "0.15.0",
12
+ "@fungi.computer/puffball": "0.5.4",
13
13
  "@fungi.computer/sigils": "0.3.0",
14
- "@fungi.computer/stipe": "0.1.0",
14
+ "@fungi.computer/stipe": "0.1.1",
15
15
  "@pierre/diffs": "1.3.6",
16
16
  "@pierre/trees": "1.0.0-beta.6",
17
17
  "@tanstack/react-query": "5.102.8",
@@ -23,16 +23,16 @@
23
23
  "react": "18.3.1",
24
24
  "react-dom": "18.3.1",
25
25
  "zod": "4.4.3",
26
- "@fungi.computer/watchdog": "0.1.1",
26
+ "@fungi.computer/watchdog": "0.1.3",
27
27
  "effect": "4.0.2",
28
28
  "@fungi.computer/cairn": "0.1.0",
29
29
  "@fungi.computer/maosaico": "0.1.1",
30
30
  "@visx/hierarchy": "3.12.0",
31
31
  "@fungi.computer/gills": "0.2.2",
32
- "@fungi.computer/nacre": "0.2.1",
33
- "@fungi.computer/trellis": "0.7.2",
34
- "@fungi.computer/braid": "0.4.4",
35
- "@fungi.computer/workflows-wire": "0.4.4"
32
+ "@fungi.computer/nacre": "0.2.3",
33
+ "@fungi.computer/trellis": "0.7.4",
34
+ "@fungi.computer/braid": "0.4.6",
35
+ "@fungi.computer/workflows-wire": "0.4.6"
36
36
  },
37
37
  "devDependencies": {
38
38
  "playwright": "1.62.1",
@@ -52,7 +52,7 @@
52
52
  "eslint": "10.9.1",
53
53
  "oxlint": "1.78.0",
54
54
  "jsdom": "29.0.1",
55
- "@fungi.computer/computer-contract": "0.0.11"
55
+ "@fungi.computer/computer-contract": "0.0.13"
56
56
  },
57
57
  "botanical": {
58
58
  "role": "app",
@@ -0,0 +1,65 @@
1
+ /** How Bonsai names a person it knows only by the host-issued member id. */
2
+
3
+ /** Whether a name is a host-issued member id rather than something readable. */
4
+ export function isMemberId(name: string): boolean {
5
+ return /(?:^|_)member_[a-z0-9]+$/iu.test(name);
6
+ }
7
+
8
+ const pondWords = [
9
+ "alder",
10
+ "bramble",
11
+ "cattail",
12
+ "clover",
13
+ "dragonfly",
14
+ "fern",
15
+ "heron",
16
+ "iris",
17
+ "juniper",
18
+ "kingfisher",
19
+ "lilypad",
20
+ "marsh",
21
+ "newt",
22
+ "otter",
23
+ "pebble",
24
+ "reed",
25
+ "sedge",
26
+ "tadpole",
27
+ "willow",
28
+ "yarrow",
29
+ "moss",
30
+ "minnow",
31
+ "lotus",
32
+ "ripple",
33
+ "frog",
34
+ "maple",
35
+ "birch",
36
+ "cedar",
37
+ "dew",
38
+ "ember",
39
+ "fable",
40
+ "glade",
41
+ ];
42
+
43
+ function hashOf(text: string): number {
44
+ let value = 2166136261;
45
+ for (const char of text) {
46
+ value ^= char.codePointAt(0) ?? 0;
47
+ value = Math.imul(value, 16777619) >>> 0;
48
+ }
49
+ return value;
50
+ }
51
+
52
+ /**
53
+ * The name a fork carries after `--`. A member id is never part of a repository
54
+ * name: it becomes a short pond word picked from a hash of the id, so the same
55
+ * member always gets the same word. `attempt` picks the next word when two
56
+ * members land on the same one. A readable name is used as it is.
57
+ */
58
+ export function forkOwnerSlug(name: string, attempt = 0): string {
59
+ if (!isMemberId(name)) return name;
60
+ const start = hashOf(name);
61
+ const word = pondWords[(start + attempt) % pondWords.length] ?? "member";
62
+ return attempt >= pondWords.length
63
+ ? `${word}-${String(Math.floor(attempt / pondWords.length) + 1)}`
64
+ : word;
65
+ }
@@ -31,6 +31,8 @@ const agent = z.strictObject({
31
31
  color: z.string(),
32
32
  kind: z.enum(["agent", "human"]),
33
33
  createdAt: z.number(),
34
+ /** Set on the caller's own row, so a view can say "You". */
35
+ you: z.literal(true).optional(),
34
36
  });
35
37
  export type Agent = z.infer<typeof agent>;
36
38
 
@@ -0,0 +1,117 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { createElement } from "react";
3
+ import { renderToStaticMarkup } from "react-dom/server";
4
+ import { activity, type Graph } from "../shared/contract.js";
5
+ import { forkOwnerSlug } from "../shared/actors.js";
6
+ import { actorCounts, contributionWeeks } from "../web/insight-data.js";
7
+ import { NetworkGraph } from "../web/network-graph.js";
8
+ import { agentColors } from "../web/parts.js";
9
+ import { WorkingNow } from "../web/working-now.js";
10
+
11
+ const id = "tenant_member_rf0i0tf5k36kc6erujz8r";
12
+ const person = {
13
+ id,
14
+ name: id,
15
+ color: "c0",
16
+ kind: "human",
17
+ createdAt: 1,
18
+ } as const;
19
+ const agentRow = {
20
+ id: "luna",
21
+ name: "luna",
22
+ color: "c1",
23
+ kind: "agent",
24
+ createdAt: 1,
25
+ } as const;
26
+ const hash = (n: number) => n.toString(16).padStart(40, "0");
27
+
28
+ const graph: Graph = {
29
+ lanes: [
30
+ {
31
+ id: "a",
32
+ repo: "koi-pond",
33
+ ref: "main",
34
+ owner: null,
35
+ head: hash(1),
36
+ canonical: true,
37
+ },
38
+ {
39
+ id: "b",
40
+ repo: "koi-pond--heron",
41
+ ref: "main",
42
+ owner: id,
43
+ head: hash(2),
44
+ canonical: false,
45
+ },
46
+ ],
47
+ nodes: [1, 2].map((n) => ({
48
+ hash: hash(n),
49
+ parents: n === 1 ? [] : [hash(1)],
50
+ message: "Add fish",
51
+ author: "levi",
52
+ agent: id,
53
+ origin: "koi-pond",
54
+ committedAt: Math.floor(Date.now() / 1000),
55
+ lanes: n === 1 ? ["a"] : ["b"],
56
+ })),
57
+ };
58
+
59
+ describe("one actor formatter", () => {
60
+ it("renders no raw member or tenant id in lanes, the live row or the contributor names", () => {
61
+ const colors = agentColors([person, agentRow]);
62
+ const html = [
63
+ renderToStaticMarkup(
64
+ createElement(NetworkGraph, {
65
+ graph,
66
+ colors,
67
+ fresh: new Set<string>(),
68
+ onSelect: () => undefined,
69
+ }),
70
+ ),
71
+ renderToStaticMarkup(
72
+ createElement(WorkingNow, {
73
+ colors,
74
+ events: [
75
+ activity.parse({
76
+ id: 1,
77
+ at: Date.now(),
78
+ type: "push",
79
+ repo: "koi-pond--heron",
80
+ actor: id,
81
+ data: {
82
+ updates: [
83
+ { ref: "refs/heads/main", before: hash(1), after: hash(2) },
84
+ ],
85
+ commits: [],
86
+ paths: ["src/fish.ts"],
87
+ },
88
+ }),
89
+ ],
90
+ }),
91
+ ),
92
+ contributionWeeks(graph, [person, agentRow])
93
+ .contributors.map((contributor) => contributor.name)
94
+ .join(),
95
+ ].join("\n");
96
+ expect(/tenant_|member_/u.exec(html)).toBeNull();
97
+ expect(html).toContain("A member");
98
+ expect(/Member [a-z0-9]{6}/u.exec(html)).toBeNull();
99
+ });
100
+
101
+ it("counts one person once", () => {
102
+ expect(actorCounts(graph, [person])).toEqual({
103
+ agent: 0,
104
+ human: 1,
105
+ unknown: 0,
106
+ });
107
+ });
108
+
109
+ it("names a fork after a readable handle", () => {
110
+ const slug = forkOwnerSlug(id);
111
+ expect(slug).toMatch(/^[a-z]+$/u);
112
+ expect(slug).not.toContain("member");
113
+ expect(forkOwnerSlug(id)).toBe(slug);
114
+ expect(forkOwnerSlug(id, 1)).not.toBe(slug);
115
+ expect(forkOwnerSlug("Luna")).toBe("Luna");
116
+ });
117
+ });
@@ -11,7 +11,7 @@ import { appsOpen } from "@fungi.computer/agar/apps";
11
11
  import { appMethods } from "@fungi.computer/agar/backend";
12
12
  import { connect } from "../../web/transport.js";
13
13
 
14
- import type { Graph, RepoDetail } from "../../shared/contract.js";
14
+ import type { Agent, Graph, RepoDetail } from "../../shared/contract.js";
15
15
  import "@fungi.computer/caps/fonts.css";
16
16
  import { RepoPage, CommitPage } from "../../web/pages.js";
17
17
  import { ChangePage } from "../../web/change-page.js";
@@ -23,13 +23,18 @@ const hash = (n: number) =>
23
23
  (Math.imul(n, 2654435761) >>> 0).toString(16).padStart(8, "0") +
24
24
  n.toString(16).padStart(32, "0");
25
25
  const now = Date.UTC(2026, 9, 12) / 1000;
26
- const agents = ["Levi", "Luna", "Astra", "Sol"].map((name, i) => ({
27
- id: name,
28
- name,
29
- kind: i === 0 ? "human" : "agent",
30
- color: `c${String(i)}`,
31
- createdAt: 0,
32
- }));
26
+ const agents: Agent[] = [];
27
+ for (const [i, name] of ["Levi", "Luna", "Astra", "Sol"].entries()) {
28
+ const row: Agent = {
29
+ id: name,
30
+ name,
31
+ kind: i === 0 ? "human" : "agent",
32
+ color: `c${String(i)}`,
33
+ createdAt: 0,
34
+ };
35
+ if (i === 0) row.you = true;
36
+ agents.push(row);
37
+ }
33
38
  const graph: Graph = {
34
39
  lanes: agents.map((agent, i) => ({
35
40
  id: `${agent.name}:main`,
@@ -456,7 +461,9 @@ capabilities.provide(appMethods, {
456
461
  return Promise.reject(
457
462
  new Error("Bonsai could not finish that request"),
458
463
  );
459
- return Promise.resolve(method === "graph.get" ? graph : { agents });
464
+ return Promise.resolve(
465
+ z.json().parse(method === "graph.get" ? graph : { agents }),
466
+ );
460
467
  }
461
468
  if (method === "activity.list") return Promise.resolve({ events: [] });
462
469
  if (method === "repos.get") return Promise.resolve(detail);
@@ -533,6 +540,9 @@ capabilities.provide(appMethods, {
533
540
  };
534
541
  value.change.state = "merged";
535
542
  value.change.status = "merged";
543
+ value.change.mergedCommit = hash(99);
544
+ value.change.mergedBy = "Levi";
545
+ value.change.behind = 0;
536
546
  value.change.mergeable = { allowed: false, reason: "not-open" };
537
547
  return Promise.resolve({
538
548
  kind: "merged",
@@ -399,6 +399,33 @@ describe("Stored Change lifecycle from accepted host pushes", () => {
399
399
  }
400
400
  });
401
401
 
402
+ it("keeps the merged commits after the target takes the merge", async () => {
403
+ const f = fixture();
404
+ try {
405
+ await f.push("push-one", "pond--morel", base, first);
406
+ const merge = "e".repeat(40);
407
+ f.commits.set(merge, commit(merge, [base, first], "Merge morel"));
408
+ f.branches.get("pond")?.set("main", merge);
409
+ await f.push("target-move", "pond", base, merge);
410
+ const merged = await change(
411
+ f.bonsai,
412
+ { name: "morel", kind: "human" },
413
+ "pond",
414
+ 1,
415
+ );
416
+ expect(merged.change).toMatchObject({
417
+ state: "merged",
418
+ mergedCommit: merge,
419
+ ahead: 1,
420
+ behind: 0,
421
+ base,
422
+ });
423
+ expect(merged.commits.map((item) => item.commit.hash)).toEqual([first]);
424
+ } finally {
425
+ f.database.close();
426
+ }
427
+ });
428
+
402
429
  it("atomically opens every proposal from a push larger than one drain page", async () => {
403
430
  const f = fixture();
404
431
  try {
@@ -5,11 +5,10 @@ import type { Agent } from "../shared/contract.js";
5
5
  import {
6
6
  AgentName,
7
7
  Sparkline,
8
- actorLabel,
9
8
  agentColors,
10
9
  type AgentColors,
11
10
  } from "../web/parts.js";
12
- import { shortActor } from "../web/format.js";
11
+ import { actorLabel } from "../web/format.js";
13
12
 
14
13
  const agent = (overrides: Partial<Agent>): Agent => ({
15
14
  id: "morel",
@@ -22,23 +21,17 @@ const agent = (overrides: Partial<Agent>): Agent => ({
22
21
 
23
22
  describe("actorLabel", () => {
24
23
  it("keeps a resolved agent's recorded name", () => {
25
- const colors: AgentColors = agentColors([agent({})]);
26
- expect(actorLabel("morel", colors)).toBe("morel");
24
+ expect(actorLabel("morel")).toBe("morel");
27
25
  });
28
26
 
29
- it("replaces a resolved human member's raw host id with a short label", () => {
27
+ it("calls the current member You and any other member A member", () => {
30
28
  const id = "tenant_member_5mirwh5a0r0p7v793qxhy";
31
- const colors: AgentColors = agentColors([
32
- agent({ id, name: id, kind: "human" }),
33
- ]);
34
- const label = actorLabel(id, colors);
35
- expect(label).toBe(shortActor(id));
36
- expect(label).not.toContain(id);
37
- expect(label).not.toBe(id);
29
+ expect(actorLabel(id, true)).toBe("You");
30
+ expect(actorLabel(id)).toBe("A member");
38
31
  });
39
32
 
40
- it("leaves an unresolved actor's string untouched rather than guessing", () => {
41
- expect(actorLabel("unresolved-actor", new Map())).toBe("unresolved-actor");
33
+ it("leaves an unresolved readable name untouched rather than guessing", () => {
34
+ expect(actorLabel("unresolved-actor")).toBe("unresolved-actor");
42
35
  });
43
36
  });
44
37
 
@@ -52,7 +45,7 @@ describe("AgentName", () => {
52
45
  createElement(AgentName, { name: id, colors }),
53
46
  );
54
47
  expect(html).not.toContain(id);
55
- expect(html).toContain("Member");
48
+ expect(html).toContain("A member");
56
49
  });
57
50
 
58
51
  it("still renders a bot agent's readable name", () => {
package/web/bonsai.css CHANGED
@@ -129,7 +129,8 @@ body {
129
129
  margin-left: -0.375rem;
130
130
  }
131
131
  .bonsai-spark-area {
132
- fill: var(--color-base-200);
132
+ fill: var(--color-base-content);
133
+ fill-opacity: 0.08;
133
134
  }
134
135
  .bonsai-spark-line {
135
136
  fill: none;
@@ -325,7 +326,7 @@ body {
325
326
  .bonsai-network-axis text {
326
327
  fill: var(--stipe-fg-muted);
327
328
  font-family: var(--font-numeric, var(--font-mono));
328
- font-size: 10.5px;
329
+ font-size: 12px;
329
330
  }
330
331
  .bonsai-edge[data-merge] {
331
332
  stroke-dasharray: none;
@@ -561,7 +562,7 @@ body {
561
562
  }
562
563
  .bonsai-tile-content svg text {
563
564
  font-family: inherit;
564
- font-size: 11px;
565
+ font-size: 12px;
565
566
  fill: var(--color-base-content);
566
567
  }
567
568
  .bonsai-chart-note {
@@ -313,6 +313,7 @@ export function ChangePage({ repo, number }: { repo: string; number: number }) {
313
313
  (lane) =>
314
314
  lane.repo === change.sourceRepo && lane.ref === change.sourceRef,
315
315
  )?.owner ?? change.sourceRepo;
316
+ const merged = change.state === "merged";
316
317
  const mergeReason = change.mergeable.allowed
317
318
  ? undefined
318
319
  : policyMessage(change.mergeable.reason, change.head);
@@ -345,14 +346,29 @@ export function ChangePage({ repo, number }: { repo: string; number: number }) {
345
346
  <div className="space-y-3">
346
347
  <div className="flex flex-wrap items-center justify-between gap-3">
347
348
  <div className="flex min-w-0 items-center gap-3">
348
- <AgentMark name={change.openedBy} colors={colors} size="lg" />
349
+ <AgentMark
350
+ name={
351
+ merged
352
+ ? (change.mergedBy ?? change.openedBy)
353
+ : change.openedBy
354
+ }
355
+ colors={colors}
356
+ size="lg"
357
+ />
349
358
  <div className="min-w-0">
350
359
  <h1 className="caps-card-title">
351
360
  #{change.number} {change.title}
352
361
  </h1>
353
362
  <p className="text-sm">
354
- <AgentName name={change.openedBy} colors={colors} /> wants to
355
- merge{" "}
363
+ <AgentName
364
+ name={
365
+ merged
366
+ ? (change.mergedBy ?? change.openedBy)
367
+ : change.openedBy
368
+ }
369
+ colors={colors}
370
+ />{" "}
371
+ {merged ? "merged" : "wants to merge"}{" "}
356
372
  <InlineCode>
357
373
  {change.sourceRepo}/{change.sourceRef}
358
374
  </InlineCode>{" "}
@@ -382,7 +398,21 @@ export function ChangePage({ repo, number }: { repo: string; number: number }) {
382
398
  {pending === "close" ? "Closing…" : "Close"}
383
399
  </Button>
384
400
  ) : null}
385
- {change.mergeable.allowed ? (
401
+ {merged ? (
402
+ change.mergedCommit !== null ? (
403
+ <Button variant="outline" asChild>
404
+ <Link
405
+ to={href({
406
+ page: "commit",
407
+ repo: change.repo,
408
+ hash: change.mergedCommit,
409
+ })}
410
+ >
411
+ View commit
412
+ </Link>
413
+ </Button>
414
+ ) : null
415
+ ) : change.mergeable.allowed ? (
386
416
  mergeButton
387
417
  ) : (
388
418
  <Tooltip>
@@ -397,10 +427,20 @@ export function ChangePage({ repo, number }: { repo: string; number: number }) {
397
427
  </div>
398
428
  </div>
399
429
  <p className="text-sm text-[var(--stipe-fg-muted)]">
400
- {change.ahead} ahead · {change.behind} behind · {fileCount}{" "}
401
- {fileCount === 1 ? "file" : "files"} · +{diff.additions} / −
402
- {diff.deletions} · updated {relativeTime(change.updatedAt)} · head{" "}
430
+ {merged
431
+ ? `${String(commits.length)} ${commits.length === 1 ? "commit" : "commits"}`
432
+ : `${String(change.ahead)} ahead · ${String(change.behind)} behind`}{" "}
433
+ · {fileCount} {fileCount === 1 ? "file" : "files"} · +
434
+ {diff.additions} / −{diff.deletions} · updated{" "}
435
+ {relativeTime(change.updatedAt)} · head{" "}
403
436
  <InlineCode>{shortHash(change.head)}</InlineCode>
437
+ {merged && change.mergedCommit !== null ? (
438
+ <>
439
+ {" "}
440
+ · merged as{" "}
441
+ <InlineCode>{shortHash(change.mergedCommit)}</InlineCode>
442
+ </>
443
+ ) : null}
404
444
  </p>
405
445
  {change.body ? <Markdown text={change.body} /> : null}
406
446
  {change.conflict ? (
@@ -409,12 +449,14 @@ export function ChangePage({ repo, number }: { repo: string; number: number }) {
409
449
  title="Resolve conflicts before merging"
410
450
  description={`Bonsai recorded conflicts in ${change.conflict.paths.join(", ")}. Update ${sourceOwner}/${change.sourceRef} from ${change.targetRef}, resolve the files and push again.`}
411
451
  />
412
- ) : !change.mergeable.allowed ? (
452
+ ) : !merged && !change.mergeable.allowed ? (
413
453
  <p className="text-sm text-[var(--stipe-fg-muted)]">
414
454
  {mergeReason}
415
455
  </p>
416
456
  ) : null}
417
- {displayedOutcome ? <p role="status">{displayedOutcome}</p> : null}
457
+ {displayedOutcome && !merged ? (
458
+ <p role="status">{displayedOutcome}</p>
459
+ ) : null}
418
460
  {actionError ? (
419
461
  <Alert tone="error" description={actionError} />
420
462
  ) : null}
package/web/format.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  /** Small presentation helpers shared by Bonsai's views. */
2
2
 
3
+ import { isMemberId } from "../shared/actors.js";
4
+
3
5
  const AGENT_COLOR = /^c[0-7]$/u;
4
6
 
5
7
  /** An agent's palette slot as a CSS colour; unknown agents read as neutral ink. */
@@ -14,11 +16,14 @@ export function shortHash(hash: string): string {
14
16
  }
15
17
 
16
18
  /**
17
- * A readable stand-in for a human actor whose host-issued member id is the
18
- * only identity Bonsai has recorded; never show that raw id.
19
+ * The one way Bonsai shows who did something. The host gives Bonsai a member
20
+ * id and no name, so the current member reads "You" and any other member
21
+ * reads "A member". Agents and other readable names are shown as they are.
22
+ * Never render a raw `tenant_` or `member_` id.
19
23
  */
20
- export function shortActor(id: string): string {
21
- return `Member ${id.slice(-6)}`;
24
+ export function actorLabel(name: string, you = false): string {
25
+ if (you) return "You";
26
+ return isMemberId(name) ? "A member" : name;
22
27
  }
23
28
 
24
29
  const units: [Intl.RelativeTimeFormatUnit, number][] = [
package/web/home-page.tsx CHANGED
@@ -103,7 +103,7 @@ function RepoCard({
103
103
  {repo.lastPushAt !== null
104
104
  ? `Pushed ${relativeTime(repo.lastPushAt)} · `
105
105
  : ""}
106
- {repo.forks.length} forks
106
+ {repo.forks.length} {repo.forks.length === 1 ? "fork" : "forks"}
107
107
  {changes.data
108
108
  ? ` · ${String(changes.data.changes.filter((change) => change.state === "open" || change.state === "merging").length)} open changes`
109
109
  : ""}
@@ -1,4 +1,5 @@
1
1
  import type { Agent, Graph } from "../shared/contract.js";
2
+ import { actorLabel } from "./format.js";
2
3
 
3
4
  type ContributorKind = "agent" | "human" | "unknown";
4
5
  function contributorKind(
@@ -8,6 +9,22 @@ function contributorKind(
8
9
  return actors.find((item) => item.id === actor)?.kind ?? "unknown";
9
10
  }
10
11
 
12
+ /** How many distinct actors of each kind contributed, so one person counts once. */
13
+ export function actorCounts(graph: Graph, actors: readonly Agent[]) {
14
+ const seen = {
15
+ agent: new Set<string>(),
16
+ human: new Set<string>(),
17
+ unknown: new Set<string>(),
18
+ };
19
+ for (const node of graph.nodes)
20
+ seen[contributorKind(node.agent, actors)].add(node.agent ?? node.author);
21
+ return {
22
+ agent: seen.agent.size,
23
+ human: seen.human.size,
24
+ unknown: seen.unknown.size,
25
+ };
26
+ }
27
+
11
28
  export function actorSplit(graph: Graph, actors: readonly Agent[]) {
12
29
  const counts = () => ({ agent: 0, human: 0, unknown: 0 });
13
30
  const commits = counts();
@@ -63,7 +80,10 @@ export function contributionWeeks(
63
80
  const actor = actors.find((item) => item.id === node.agent);
64
81
  const contributor = contributors.get(id) ?? {
65
82
  id,
66
- name: actor?.name ?? node.agent ?? node.author,
83
+ name: actorLabel(
84
+ actor?.name ?? node.agent ?? node.author,
85
+ actor?.you === true,
86
+ ),
67
87
  kind: contributorKind(node.agent, actors),
68
88
  color: actor?.color,
69
89
  total: 0,
@@ -15,6 +15,7 @@ import {
15
15
  type CodeInsights,
16
16
  } from "../shared/insights.js";
17
17
  import {
18
+ actorCounts,
18
19
  actorSplit,
19
20
  contributionDays,
20
21
  contributionWeeks,
@@ -78,7 +79,7 @@ function Contributors({ graph, actors }: { graph: Graph; actors: Agent[] }) {
78
79
  return (
79
80
  <>
80
81
  <p className="text-xs text-[var(--stipe-fg-muted)] bonsai-chart-note">
81
- Loaded history (up to 12 weeks) · weekly commits by first pushing actor
82
+ Commits per week, last 12 weeks
82
83
  </p>
83
84
  <svg
84
85
  ref={ref}
@@ -154,6 +155,7 @@ function Contributors({ graph, actors }: { graph: Graph; actors: Agent[] }) {
154
155
 
155
156
  function ActorSplit({ graph, actors }: { graph: Graph; actors: Agent[] }) {
156
157
  const split = actorSplit(graph, actors);
158
+ const counts = actorCounts(graph, actors);
157
159
  const total =
158
160
  split.commits.agent + split.commits.human + split.commits.unknown;
159
161
  const contributors = contributionWeeks(graph, actors).contributors;
@@ -190,26 +192,35 @@ function ActorSplit({ graph, actors }: { graph: Graph; actors: Agent[] }) {
190
192
  );
191
193
  })}
192
194
  </svg>
193
- <ScreenCells>
194
- {kinds.map((kind) => (
195
- <ScreenCell
196
- key={kind}
197
- legend={
198
- kind === "agent"
199
- ? "Agents"
200
- : kind === "human"
201
- ? "People"
202
- : "Unknown"
203
- }
204
- >
205
- {split.commits[kind]}
206
- </ScreenCell>
195
+ <ul className="text-xs bonsai-chart-legend">
196
+ {contributors.map((actor) => (
197
+ <li key={actor.id}>
198
+ <i style={{ background: agentColor(actor.color) }} />
199
+ <span>{actor.name}</span>
200
+ </li>
207
201
  ))}
202
+ </ul>
203
+ <ScreenCells>
204
+ {kinds
205
+ .filter((kind) => kind !== "unknown" || counts.unknown > 0)
206
+ .map((kind) => (
207
+ <ScreenCell
208
+ key={kind}
209
+ legend={
210
+ kind === "agent"
211
+ ? "Agents"
212
+ : kind === "human"
213
+ ? "People"
214
+ : "Unknown"
215
+ }
216
+ >
217
+ {counts[kind]}
218
+ </ScreenCell>
219
+ ))}
208
220
  </ScreenCells>
209
221
  <p className="text-xs text-[var(--stipe-fg-muted)]">
210
- {total} loaded commits ·{" "}
211
- {split.merges.agent + split.merges.human + split.merges.unknown} merges.
212
- Review counts are not included.
222
+ {total} {total === 1 ? "commit" : "commits"} ·{" "}
223
+ {split.merges.agent + split.merges.human + split.merges.unknown} merges
213
224
  </p>
214
225
  </>
215
226
  );
@@ -17,7 +17,7 @@ import {
17
17
  type RefObject,
18
18
  } from "react";
19
19
  import type { Graph, GraphLane, GraphNode } from "../shared/contract.js";
20
- import { agentColor, relativeTime, shortHash } from "./format.js";
20
+ import { actorLabel, agentColor, relativeTime, shortHash } from "./format.js";
21
21
  import type { AgentColors } from "./parts.js";
22
22
 
23
23
  const ROW = 52;
@@ -245,6 +245,15 @@ export function NetworkGraph({
245
245
  const [hover, setHover] = useState<Placed | null>(null);
246
246
  const drag = useRef<{ x: number; left: number; moved: boolean } | null>(null);
247
247
 
248
+ const laneOwner = (lane: { owner: string | null; repo: string }) =>
249
+ lane.owner === null
250
+ ? lane.repo
251
+ : actorLabel(lane.owner, colors.get(lane.owner)?.you);
252
+ const nodeActor = (node: { agent: string | null; author: string }) =>
253
+ actorLabel(
254
+ node.agent ?? node.author,
255
+ colors.get(node.agent ?? node.author)?.you,
256
+ );
248
257
  const narrow = width > 0 && width < NARROW;
249
258
  const labelRoom = narrow ? NARROW_LABEL_ROOM : LABEL_ROOM;
250
259
  const labelChars = narrow ? NARROW_LABEL_CHARS : LABEL_CHARS;
@@ -462,7 +471,7 @@ export function NetworkGraph({
462
471
  >
463
472
  <span className="flex min-w-0 flex-col items-start">
464
473
  <span className="max-w-full truncate">
465
- {lane.owner ?? lane.repo} / {lane.ref}
474
+ {laneOwner(lane)} / {lane.ref}
466
475
  </span>
467
476
  <span className="text-xs text-[var(--stipe-fg-muted)]">
468
477
  {laneDetails?.get(lane.repo)}
@@ -473,8 +482,10 @@ export function NetworkGraph({
473
482
  <>
474
483
  <span className="bonsai-lane-owner min-w-0 truncate">
475
484
  {shortLabels
476
- ? (lane.owner ?? lane.ref)
477
- : (lane.owner ?? lane.repo)}
485
+ ? lane.owner === null
486
+ ? lane.ref
487
+ : laneOwner(lane)
488
+ : laneOwner(lane)}
478
489
  </span>
479
490
  {!shortLabels ? (
480
491
  <span className="bonsai-lane-ref">{lane.ref}</span>
@@ -565,7 +576,7 @@ export function NetworkGraph({
565
576
  className={classes.join(" ")}
566
577
  tabIndex={0}
567
578
  role="button"
568
- aria-label={`${item.node.message} by ${item.node.agent ?? item.node.author}`}
579
+ aria-label={`${item.node.message} by ${nodeActor(item.node)}`}
569
580
  onPointerEnter={() => {
570
581
  setHover(item);
571
582
  }}
@@ -635,8 +646,7 @@ export function NetworkGraph({
635
646
  <strong>{hover.node.message}</strong>
636
647
  <span>
637
648
  <i style={{ background: beadInk(hover) }} aria-hidden="true" />
638
- {hover.node.agent ?? hover.node.author} ·{" "}
639
- {shortHash(hover.node.hash)} ·{" "}
649
+ {nodeActor(hover.node)} · {shortHash(hover.node.hash)} ·{" "}
640
650
  {relativeTime(hover.node.committedAt * 1000)}
641
651
  </span>
642
652
  </div>
package/web/parts.tsx CHANGED
@@ -1,7 +1,7 @@
1
1
  /** Shared pieces composed from Caps: agent marks, the activity feed, sparklines. */
2
2
  import { Button } from "@fungi.computer/caps/components/button";
3
3
  import { Monogram } from "@fungi.computer/caps/components/monogram";
4
- import { Loader } from "@fungi.computer/caps/components/loader";
4
+ import { LoadingState } from "@fungi.computer/caps/blocks/loading-state";
5
5
  import { EmptyState } from "@fungi.computer/caps/blocks/empty-state";
6
6
  import { useListMotion } from "@fungi.computer/caps/lib/reorder-motion";
7
7
  import { curveMonotoneX } from "@visx/curve";
@@ -10,33 +10,23 @@ import { AreaClosed, LinePath } from "@visx/shape";
10
10
  import { useRef, type ReactNode } from "react";
11
11
  import type { Activity, Agent } from "../shared/contract.js";
12
12
  import { ApiError } from "./api.js";
13
- import { agentColor, relativeTime, shortActor, shortHash } from "./format.js";
13
+ import { actorLabel, agentColor, relativeTime, shortHash } from "./format.js";
14
14
  import { href, Link } from "./router.js";
15
15
 
16
16
  export type AgentColors = ReadonlyMap<
17
17
  string,
18
- { color: string; kind: Agent["kind"] }
18
+ { color: string; kind: Agent["kind"]; you?: boolean }
19
19
  >;
20
20
 
21
21
  export function agentColors(agents: readonly Agent[] | undefined): AgentColors {
22
22
  return new Map(
23
23
  (agents ?? []).map((agent) => [
24
24
  agent.name,
25
- { color: agent.color, kind: agent.kind },
25
+ { color: agent.color, kind: agent.kind, you: agent.you === true },
26
26
  ]),
27
27
  );
28
28
  }
29
29
 
30
- /**
31
- * The actor's readable label. Bonsai never records a human member's display
32
- * name (their id is their identity, see `callerActor`), so a known human
33
- * actor reads as a short label instead of the raw host-issued id. Agents,
34
- * and any actor this view hasn't resolved yet, keep their recorded name.
35
- */
36
- export function actorLabel(name: string, colors: AgentColors): string {
37
- return colors.get(name)?.kind === "human" ? shortActor(name) : name;
38
- }
39
-
40
30
  export function AgentMark({
41
31
  name,
42
32
  colors,
@@ -48,7 +38,7 @@ export function AgentMark({
48
38
  }) {
49
39
  return (
50
40
  <Monogram
51
- name={actorLabel(name, colors)}
41
+ name={actorLabel(name, colors.get(name)?.you)}
52
42
  seed={name}
53
43
  size={size}
54
44
  data-agent-slot={colors.get(name)?.color}
@@ -79,7 +69,7 @@ export function AgentName({
79
69
  fill={agentColor(colors.get(name)?.color)}
80
70
  />
81
71
  </svg>
82
- {actorLabel(name, colors)}
72
+ {actorLabel(name, colors.get(name)?.you)}
83
73
  </span>
84
74
  );
85
75
  }
@@ -343,7 +333,7 @@ export function Sparkline({
343
333
  export function Loading({ label }: { label: string }) {
344
334
  return (
345
335
  <div className="bonsai-loading">
346
- <Loader label={label} size="sm" />
336
+ <LoadingState message={label} />
347
337
  </div>
348
338
  );
349
339
  }
@@ -1,6 +1,6 @@
1
1
  import type { Activity } from "../shared/contract.js";
2
2
  import { AgentMark, AgentName, type AgentColors } from "./parts.js";
3
- import { relativeTime } from "./format.js";
3
+ import { actorLabel, relativeTime } from "./format.js";
4
4
 
5
5
  const activityWindowMs = 15 * 60_000;
6
6
 
@@ -69,21 +69,24 @@ export function WorkingNow({
69
69
  return (
70
70
  <li key={item.agent} data-agent-slot={colors.get(item.agent)?.color}>
71
71
  <AgentMark name={item.agent} colors={colors} />
72
- <div>
73
- <p>
72
+ <div className="min-w-0">
73
+ <p className="truncate">
74
74
  <AgentName name={item.agent} colors={colors} />{" "}
75
75
  <span className="text-sm text-[var(--stipe-fg-muted)] bonsai-muted">
76
76
  on
77
77
  </span>{" "}
78
78
  <span className="font-mono text-sm bonsai-ref">
79
- {item.repo.includes("--") ? `${item.agent}/` : ""}
79
+ {item.repo.includes("--")
80
+ ? `${actorLabel(item.agent, colors.get(item.agent)?.you)}/`
81
+ : ""}
80
82
  {item.ref}
81
83
  </span>
82
- </p>
83
- <p className="text-xs bonsai-working-areas">
84
- {areas.map((area) => (
85
- <code key={area}>{area}</code>
86
- ))}
84
+ {areas.length > 0 ? (
85
+ <span className="text-sm text-[var(--stipe-fg-muted)] bonsai-muted">
86
+ {" · "}
87
+ {areas.join(", ")}
88
+ </span>
89
+ ) : null}
87
90
  </p>
88
91
  </div>
89
92
  <time className="text-xs text-[var(--stipe-fg-muted)] bonsai-feed-time">