@fungi.computer/bonsai 0.6.41 → 0.6.42

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,27 @@
1
1
  # @fungi.computer/bonsai
2
2
 
3
+ ## 0.6.42
4
+
5
+ ### Patch Changes
6
+
7
+ - Changes since 0.6.41:
8
+
9
+ - fix(caps): put the panel on the card face and cap Bonsai Changes width
10
+ - fix(caps): make the empty-state panel a solid card, not a dashed drop zone
11
+ - fix(bonsai): solid cards, guarded one-click starters, phone tab gap
12
+ - fix(bonsai): empty Changes card, one-click starter repos, quieter Arrange
13
+ tiles
14
+ - fix(bonsai): tidy first-run Code, Changes, consent, tabs and diff
15
+
16
+ - Updated dependencies
17
+ - Updated dependencies
18
+ - Updated dependencies
19
+ - Updated dependencies
20
+ - @fungi.computer/caps@0.10.6
21
+ - @fungi.computer/nacre@0.4.6
22
+ - @fungi.computer/oyster@0.20.4
23
+ - @fungi.computer/trellis@0.10.10
24
+
3
25
  ## 0.6.41
4
26
 
5
27
  ### Patch Changes
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@fungi.computer/bonsai",
3
- "version": "0.6.41",
3
+ "version": "0.6.42",
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
8
  "@fungi.computer/agar": "0.9.1",
9
- "@fungi.computer/caps": "0.10.5",
9
+ "@fungi.computer/caps": "0.10.6",
10
10
  "@fungi.computer/issues": "0.2.0",
11
- "@fungi.computer/oyster": "0.20.3",
11
+ "@fungi.computer/oyster": "0.20.4",
12
12
  "@fungi.computer/puffball": "0.5.5",
13
13
  "@fungi.computer/sigils": "0.3.1",
14
14
  "@fungi.computer/stipe": "0.1.1",
@@ -29,8 +29,8 @@
29
29
  "@fungi.computer/maosaico": "0.1.2",
30
30
  "@visx/hierarchy": "3.12.0",
31
31
  "@fungi.computer/gills": "0.3.0",
32
- "@fungi.computer/nacre": "0.4.5",
33
- "@fungi.computer/trellis": "0.10.9",
32
+ "@fungi.computer/nacre": "0.4.6",
33
+ "@fungi.computer/trellis": "0.10.10",
34
34
  "@fungi.computer/braid": "0.4.8",
35
35
  "@fungi.computer/workflows-wire": "0.4.8"
36
36
  },
@@ -475,7 +475,14 @@ if (fresh) {
475
475
  lastPushAt: Date.now() - 20_000,
476
476
  });
477
477
  detail.refs = [{ name: "refs/heads/main", hash: first }];
478
- const firstCommit = { ...fixtureCommit, hash: first, parents: [] };
478
+ const firstCommit = {
479
+ ...fixtureCommit,
480
+ hash: first,
481
+ parents: [],
482
+ message: "Add README",
483
+ committedAt: Math.floor(Date.now() / 1000),
484
+ author: { name: "Levi", email: "fixture@example.test" },
485
+ };
479
486
  client.setQueryData(["graph", "koi-pond"], graph);
480
487
  client.setQueryData(["agents"], { agents: agents.slice(0, 1) });
481
488
  client.setQueryData(["repo", "koi-pond"], detail);
@@ -505,6 +512,33 @@ if (fresh) {
505
512
  text: "# koi-pond\n",
506
513
  size: 11,
507
514
  });
515
+ client.setQueryData(["commit", "koi-pond", first], {
516
+ commit: {
517
+ ...firstCommit,
518
+ message: "Add README",
519
+ author: { name: "Levi", email: "fixture@example.test" },
520
+ committedAt: Math.floor(Date.now() / 1000),
521
+ },
522
+ agent: "Levi",
523
+ diff: {
524
+ files: [
525
+ {
526
+ path: "README.md",
527
+ oldPath: null,
528
+ status: "added",
529
+ additions: 1,
530
+ deletions: 0,
531
+ binary: false,
532
+ truncated: false,
533
+ oldText: "",
534
+ newText: "# koi-pond\n",
535
+ },
536
+ ],
537
+ additions: 1,
538
+ deletions: 0,
539
+ omittedFiles: 0,
540
+ },
541
+ });
508
542
  const freshEvents = {
509
543
  events: [
510
544
  {
@@ -125,6 +125,7 @@ async function fixture(
125
125
  RouterProvider,
126
126
  null,
127
127
  createElement(CodeTab, {
128
+ colors: new Map(),
128
129
  route: {
129
130
  page: "repo",
130
131
  repo: "pond",
@@ -11,7 +11,7 @@ import { createCapabilityRegistry } from "@fungi.computer/agar";
11
11
  import { appMethods } from "@fungi.computer/agar/backend";
12
12
  import { HomePage } from "../web/home-page.js";
13
13
  import { HostGitAccess } from "../web/host-access.js";
14
- import { RouterProvider } from "../web/router.js";
14
+ import { RouterProvider, useRouter } from "../web/router.js";
15
15
  import { connect } from "../web/transport.js";
16
16
  import type { JsonValue } from "../shared/contract.js";
17
17
 
@@ -77,6 +77,15 @@ const render = async (child: ReturnType<typeof createElement>) => {
77
77
  });
78
78
  };
79
79
 
80
+ function RoutePanel() {
81
+ const { route } = useRouter();
82
+ return createElement(
83
+ "output",
84
+ { "data-route": true },
85
+ route.page === "repo" ? `repo:${route.repo}:${route.tab}` : route.page,
86
+ );
87
+ }
88
+
80
89
  describe("Bonsai home page", () => {
81
90
  it("shows the live board and no README section", async () => {
82
91
  callMethod.mockImplementation((method) => {
@@ -183,6 +192,94 @@ describe("Bonsai home page", () => {
183
192
  expect(container.textContent).not.toContain("Loading repositories");
184
193
  });
185
194
 
195
+ describe("starter repository chips", () => {
196
+ const mount = async (create: (input: string) => Promise<JsonValue>) => {
197
+ callMethod.mockImplementation((method, input) => {
198
+ switch (method) {
199
+ case "repos.list":
200
+ return Promise.resolve({ repos: [] });
201
+ case "actors.list":
202
+ return Promise.resolve({ agents: [] });
203
+ case "activity.list":
204
+ return Promise.resolve({ events: [] });
205
+ case "repos.create":
206
+ return create(input);
207
+ default:
208
+ return Promise.reject(new Error(`unexpected method ${method}`));
209
+ }
210
+ });
211
+ await render(
212
+ createElement(
213
+ RouterProvider,
214
+ null,
215
+ createElement(HomePage, {
216
+ live: { connected: true, error: null, fresh: new Set<number>() },
217
+ }),
218
+ createElement(RoutePanel),
219
+ ),
220
+ );
221
+ };
222
+ const chip = (label: string) =>
223
+ [
224
+ ...container.querySelectorAll<HTMLButtonElement>(
225
+ "ul[aria-label] button",
226
+ ),
227
+ ].find((button) => button.textContent.startsWith(label));
228
+ const created = (name: string) => ({
229
+ name,
230
+ description: null,
231
+ parent: null,
232
+ owner: null,
233
+ createdAt: 1,
234
+ lastPushAt: null,
235
+ forks: [],
236
+ openChanges: 0,
237
+ activity: [],
238
+ });
239
+
240
+ it("creates with a README once and opens Overview, even on a double click", async () => {
241
+ let finish: (value: JsonValue) => void = () => undefined;
242
+ await mount(
243
+ () =>
244
+ new Promise<JsonValue>((resolve) => {
245
+ finish = resolve;
246
+ }),
247
+ );
248
+ await act(async () => {
249
+ chip("notes")?.click();
250
+ chip("notes")?.click();
251
+ await Promise.resolve();
252
+ });
253
+ expect(
254
+ callMethod.mock.calls.filter(([method]) => method === "repos.create"),
255
+ ).toEqual([
256
+ ["repos.create", JSON.stringify({ name: "notes", readme: true })],
257
+ ]);
258
+ expect(chip("website")?.disabled).toBe(true);
259
+ await act(async () => {
260
+ finish(created("notes"));
261
+ await Promise.resolve();
262
+ await Promise.resolve();
263
+ await Promise.resolve();
264
+ });
265
+ expect(container.querySelector("output[data-route]")?.textContent).toBe(
266
+ "repo:notes:overview",
267
+ );
268
+ });
269
+
270
+ it("opens the form with the name and the error when creating fails", async () => {
271
+ await mount(() => Promise.reject(new Error("notes already exists")));
272
+ await act(async () => {
273
+ chip("notes")?.click();
274
+ await Promise.resolve();
275
+ await Promise.resolve();
276
+ await Promise.resolve();
277
+ });
278
+ const input = document.querySelector("input");
279
+ expect(input instanceof HTMLInputElement && input.value).toBe("notes");
280
+ expect(document.body.textContent).toContain("notes already exists");
281
+ });
282
+ });
186
283
  it("leads with Approve Git access while Bonsai lacks it, then offers New repository", async () => {
187
284
  const capabilities = createCapabilityRegistry();
188
285
  capabilities.provide(appMethods, { call: callMethod });
@@ -643,6 +643,7 @@ it("opening Code makes zero code-insight calls", async () => {
643
643
  RouterProvider,
644
644
  null,
645
645
  createElement(CodeTab, {
646
+ colors: new Map(),
646
647
  route: {
647
648
  page: "repo",
648
649
  repo: "pond",
package/web/bonsai.css CHANGED
@@ -696,3 +696,20 @@ body {
696
696
  .bonsai-next-steps li p + p {
697
697
  color: var(--stipe-fg-muted);
698
698
  }
699
+
700
+ /* Phone: six repository tabs fit the row instead of clipping at either end. */
701
+ @media (max-width: 480px) {
702
+ .bonsai-repo
703
+ [aria-label="Repository sections"]
704
+ .caps-navigation-rail-content {
705
+ gap: var(--spacing-2xs);
706
+ justify-content: space-between;
707
+ }
708
+ .bonsai-repo
709
+ [aria-label="Repository sections"]
710
+ .caps-navigation-rail-content
711
+ > a {
712
+ padding-inline: var(--spacing-xs);
713
+ font-size: var(--text-sm);
714
+ }
715
+ }
@@ -527,7 +527,10 @@ export function ChangePage({ repo, number }: { repo: string; number: number }) {
527
527
  {agent ? (
528
528
  <AgentName name={agent} colors={colors} />
529
529
  ) : (
530
- actorLabel(commit.author.name)
530
+ actorLabel(
531
+ commit.author.name,
532
+ colors.get(commit.author.name)?.you,
533
+ )
531
534
  )}{" "}
532
535
  · {shortHash(commit.hash)} ·{" "}
533
536
  {relativeTime(commit.committedAt * 1000)}
package/web/code-tab.tsx CHANGED
@@ -14,7 +14,7 @@ import {
14
14
  relativeTime,
15
15
  shortHash,
16
16
  } from "./format.js";
17
- import { Loading, Failure } from "./parts.js";
17
+ import { Loading, Failure, type AgentColors } from "./parts.js";
18
18
  import { QuickSetup } from "./quick-setup.js";
19
19
  import { href, Link, useRouter, type Route } from "./router.js";
20
20
  import { FileView, Markdown, RepoTree } from "./views.js";
@@ -22,9 +22,11 @@ import { FileView, Markdown, RepoTree } from "./views.js";
22
22
  export function CodeTab({
23
23
  route,
24
24
  detail,
25
+ colors,
25
26
  }: {
26
27
  route: Extract<Route, { page: "repo" }>;
27
28
  detail: RepoDetail;
29
+ colors: AgentColors;
28
30
  }) {
29
31
  const { go } = useRouter();
30
32
  const [wide, setWide] = useState(false);
@@ -222,7 +224,11 @@ export function CodeTab({
222
224
  ) : null}
223
225
  {files.data ? (
224
226
  <p className="text-sm text-[var(--stipe-fg-muted)]">
225
- Latest commit · {actorLabel(files.data.commit.author.name)}{" "}
227
+ Latest commit ·{" "}
228
+ {actorLabel(
229
+ files.data.commit.author.name,
230
+ colors.get(files.data.commit.author.name)?.you,
231
+ )}{" "}
226
232
  ·{" "}
227
233
  <Link
228
234
  to={href({
package/web/home-page.tsx CHANGED
@@ -1,10 +1,10 @@
1
- import { useEffect, useMemo, useState } from "react";
1
+ import { useEffect, useMemo, useRef, useState } from "react";
2
2
  import { DataListHeading } from "@fungi.computer/caps/components/data-list";
3
3
  import { Status } from "@fungi.computer/caps/components/status";
4
4
  import { EmptyState } from "@fungi.computer/caps/blocks/empty-state";
5
5
  import { GitBranch } from "lucide-react";
6
+ import { useQueryClient } from "@tanstack/react-query";
6
7
  import { Button } from "@fungi.computer/caps/components/button";
7
- import { SetupNotice } from "@fungi.computer/caps/blocks/setup-notice";
8
8
  import { NewRepositoryDialog } from "./new-repository.js";
9
9
  import { useHostGitAccess } from "./host-access.js";
10
10
  import { requestGitAccess } from "./transport.js";
@@ -14,6 +14,7 @@ import {
14
14
  useGraph,
15
15
  useChanges,
16
16
  useEvents,
17
+ createRepository,
17
18
  type LiveState,
18
19
  } from "./api.js";
19
20
  import { BonsaiBoard, type BoardTile } from "./board.js";
@@ -186,7 +187,47 @@ export function HomePage({ live }: { live: LiveState }) {
186
187
  name: "",
187
188
  count: 0,
188
189
  });
189
- const startWith = (name: string) => {
190
+ const client = useQueryClient();
191
+ const { go } = useRouter();
192
+ // A suggested name creates the repository with a README right away; if that
193
+ // fails the form opens, prefilled, with the error shown.
194
+ // The ref closes the gap before the busy state renders (a fast double click).
195
+ const starting = useRef(false);
196
+ const [startingName, setStartingName] = useState<string | null>(null);
197
+ const [startError, setStartError] = useState<string | null>(null);
198
+ const createNamed = async (name: string): Promise<void> => {
199
+ if (starting.current) return;
200
+ starting.current = true;
201
+ setStartingName(name);
202
+ const result = await createRepository({ name, readme: true }).then(
203
+ (created) => ({ created }),
204
+ (error: unknown) => ({ error }),
205
+ );
206
+ starting.current = false;
207
+ setStartingName(null);
208
+ if ("created" in result) {
209
+ await client.invalidateQueries({ queryKey: ["repos"] });
210
+ go(
211
+ href({
212
+ page: "repo",
213
+ repo: result.created.name,
214
+ tab: "overview",
215
+ ref: null,
216
+ file: null,
217
+ path: "",
218
+ }),
219
+ );
220
+ return;
221
+ }
222
+ startWith(
223
+ name,
224
+ result.error instanceof Error
225
+ ? result.error.message
226
+ : "Couldn't create it.",
227
+ );
228
+ };
229
+ const startWith = (name: string, error: string | null = null) => {
230
+ setStartError(error);
190
231
  setPreset((current) => ({ name, count: current.count + 1 }));
191
232
  setCreating(true);
192
233
  };
@@ -343,19 +384,19 @@ export function HomePage({ live }: { live: LiveState }) {
343
384
  />
344
385
  ) : repos.data.repos.length === 0 ? (
345
386
  missing ? (
346
- <SetupNotice
347
- className="bonsai-onboarding"
348
- variant="panel"
349
- need="Bonsai needs Git access to save your repositories"
350
- cause="Keep files and their history, with a separate working copy for each AI helper."
351
- visual={<GitBranch aria-hidden="true" />}
352
- fix={{
353
- label: "Approve Git access",
354
- onSelect: () => void approveAccess(),
355
- pending: asking,
356
- }}
357
- waitingFor="your answer"
358
- />
387
+ <div className="bonsai-onboarding">
388
+ <EmptyState
389
+ variant="panel"
390
+ visual={<GitBranch aria-hidden="true" />}
391
+ title="Bonsai needs Git access to save your repositories"
392
+ description="Keep files and their history, with a separate working copy for each AI helper."
393
+ primaryAction={{
394
+ label: "Approve Git access",
395
+ onSelect: () => void approveAccess(),
396
+ pending: asking,
397
+ }}
398
+ />
399
+ </div>
359
400
  ) : (
360
401
  <div className="bonsai-onboarding">
361
402
  <EmptyState
@@ -371,8 +412,10 @@ export function HomePage({ live }: { live: LiveState }) {
371
412
  }}
372
413
  suggestions={["notes", "website", "experiments"].map((label) => ({
373
414
  label,
415
+ pending: startingName === label,
416
+ disabled: startingName !== null,
374
417
  onSelect: () => {
375
- startWith(label);
418
+ void createNamed(label);
376
419
  },
377
420
  }))}
378
421
  />
@@ -400,6 +443,7 @@ export function HomePage({ live }: { live: LiveState }) {
400
443
  open={creating}
401
444
  onOpenChange={setCreating}
402
445
  initialName={preset.name}
446
+ initialError={startError}
403
447
  />
404
448
  <BonsaiBoard
405
449
  rowHeight={0}
package/web/insights.tsx CHANGED
@@ -149,7 +149,7 @@ function Grid({
149
149
  ) : (
150
150
  <Button
151
151
  size="sm"
152
- variant="outline"
152
+ variant="ghost"
153
153
  onClick={() => {
154
154
  setEditing(true);
155
155
  }}
@@ -24,11 +24,14 @@ export function NewRepositoryDialog({
24
24
  open,
25
25
  onOpenChange,
26
26
  initialName = "",
27
+ initialError = null,
27
28
  }: {
28
29
  open: boolean;
29
30
  onOpenChange: (open: boolean) => void;
30
31
  /** A suggested name to start from, chosen from the empty state. */
31
32
  initialName?: string;
33
+ /** Why a one-click start failed, shown when the form opens instead. */
34
+ initialError?: string | null;
32
35
  }) {
33
36
  const client = useQueryClient();
34
37
  const { go } = useRouter();
@@ -38,7 +41,7 @@ export function NewRepositoryDialog({
38
41
  const [creating, setCreating] = useState(false);
39
42
  const [needsAccess, setNeedsAccess] = useState(false);
40
43
  const [waiting, setWaiting] = useState(false);
41
- const [failure, setFailure] = useState<string | null>(null);
44
+ const [failure, setFailure] = useState<string | null>(initialError);
42
45
  const problem = repoNameProblem(name);
43
46
  const shownProblem = touched ? problem : null;
44
47
 
package/web/pages.tsx CHANGED
@@ -15,7 +15,7 @@ import { ChangeGroups, needsAttention } from "./change-rows.js";
15
15
  import { RepoNavigation } from "./repo-navigation.js";
16
16
  import { RepoSettings } from "./repo-settings.js";
17
17
  /** Bonsai's pages: the repository list, a repository, and a commit. */
18
- import { ChevronRight } from "lucide-react";
18
+ import { ChevronRight, GitPullRequest } from "lucide-react";
19
19
  import { useEffect, useMemo, useState } from "react";
20
20
  import type { RepoDetail } from "../shared/contract.js";
21
21
  import {
@@ -49,7 +49,6 @@ function useColors(): AgentColors {
49
49
  export type RepoRoute = Extract<Route, { page: "repo" }>;
50
50
 
51
51
  function ChangesTab({ repo, colors }: { repo: string; colors: AgentColors }) {
52
- const { go } = useRouter();
53
52
  const changes = useChanges(repo);
54
53
  if (changes.isPending) return <Loading label="Loading changes" />;
55
54
  if (changes.isError)
@@ -64,24 +63,11 @@ function ChangesTab({ repo, colors }: { repo: string; colors: AgentColors }) {
64
63
  if (changes.data.changes.length === 0)
65
64
  return (
66
65
  <EmptyState
67
- variant="plain"
68
- title="Review changes here"
69
- description="Changes from separate working copies appear here, ready for you to review and combine."
70
- primaryAction={{
71
- label: "Open Code",
72
- onSelect: () => {
73
- go(
74
- href({
75
- page: "repo",
76
- repo,
77
- tab: "code",
78
- ref: null,
79
- path: "",
80
- file: null,
81
- }),
82
- );
83
- },
84
- }}
66
+ variant="panel"
67
+ className="mx-auto w-full max-w-[26rem]"
68
+ visual={<GitPullRequest aria-hidden="true" />}
69
+ title="No changes yet"
70
+ description="A change appears when an AI helper finishes work in its own working copy. You review it here, then combine it into main."
85
71
  />
86
72
  );
87
73
  return (
@@ -354,7 +340,7 @@ function RepoContent({ route, live }: { route: RepoRoute; live: LiveState }) {
354
340
  <section className="bonsai-main">
355
341
  {tab === "code" ? (
356
342
  <>
357
- <CodeTab route={route} detail={detail.data} />
343
+ <CodeTab route={route} detail={detail.data} colors={colors} />
358
344
  </>
359
345
  ) : null}
360
346
  {tab === "commits" ? (
@@ -460,7 +446,10 @@ export function CommitPage({ repo, hash }: { repo: string; hash: string }) {
460
446
  {agent ? (
461
447
  <AgentName name={agent} colors={colors} />
462
448
  ) : (
463
- actorLabel(commit.author.name)
449
+ actorLabel(
450
+ commit.author.name,
451
+ colors.get(commit.author.name)?.you,
452
+ )
464
453
  )}
465
454
  <span className="text-sm text-[var(--stipe-fg-muted)] bonsai-muted">
466
455
  {" "}
@@ -193,14 +193,15 @@ export function RepoNavigation({
193
193
  ))}
194
194
  </Select>
195
195
  </div>
196
- <div className="hidden max-w-sm md:block" ref={desktopClone}>
196
+ <div className="hidden max-w-lg md:block" ref={desktopClone}>
197
197
  <CopyField
198
198
  value={clone}
199
199
  fieldLabel="Clone repository"
200
200
  displayValue={detail.cloneUrl}
201
201
  />
202
202
  <p className="mt-1 text-sm text-[var(--stipe-fg-muted)]">
203
- Run from my-oyster.
203
+ Paste this into a terminal to copy the repository to your
204
+ computer.
204
205
  </p>
205
206
  </div>
206
207
  <div className="md:hidden">
@@ -231,7 +232,8 @@ export function RepoNavigation({
231
232
  displayValue={detail.cloneUrl}
232
233
  />
233
234
  <p className="mt-1 text-sm text-[var(--stipe-fg-muted)]">
234
- Run from my-oyster.
235
+ Paste this into a terminal to copy the repository to your
236
+ computer.
235
237
  </p>
236
238
  </div>
237
239
  </Popover>
package/web/views.tsx CHANGED
@@ -70,6 +70,14 @@ export function FileView({ path, text }: { path: string; text: string }) {
70
70
  );
71
71
  }
72
72
 
73
+ /**
74
+ * Syntax colors include red (headings, keywords), which reads as a removal on
75
+ * the green added-line row. Added lines show their text in the normal
76
+ * foreground so an addition reads as an addition.
77
+ */
78
+ const addedTextCSS =
79
+ '[data-line-type="change-addition"] [data-content] span, [data-line-type="change-addition"] span { color: inherit !important; }';
80
+
73
81
  export function DiffView({ file }: { file: FileDiff }) {
74
82
  const themeType = useThemeType();
75
83
  const oldFile = useMemo(
@@ -108,6 +116,7 @@ export function DiffView({ file }: { file: FileDiff }) {
108
116
  overflow: "scroll",
109
117
  themeType,
110
118
  theme: pierreTheme,
119
+ unsafeCSS: addedTextCSS,
111
120
  }}
112
121
  />
113
122
  </section>