@fungi.computer/tourtois 0.29.1 → 0.29.2

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.
@@ -27,7 +27,7 @@ export type OysterComputersPort = Readonly<{
27
27
  */
28
28
  stop?(computerId: string): Promise<void>;
29
29
  /** Hosts that can stop a Computer also read whether it is running. */
30
- state?(computerId: string): Promise<ComputerRunState>;
30
+ state?(computerId: string): Promise<ComputerRunReading>;
31
31
  internetAccess(computerId: string): Promise<boolean>;
32
32
  setInternetAccess(computerId: string, enabled: boolean): Promise<boolean>;
33
33
  keepAwake(computerId: string): Promise<boolean>;
@@ -44,6 +44,11 @@ export type OysterComputersPort = Readonly<{
44
44
  }>;
45
45
  /** Whether a Computer's runtime is up, as the host reads it without waking it. */
46
46
  export type ComputerRunState = "running" | "sleeping" | "starting" | "queued" | "start_failed";
47
+ /** A failed start says why when its host knows; older hosts send no reason. */
48
+ export type ComputerRunReading = Readonly<{
49
+ state: ComputerRunState;
50
+ reason?: string | undefined;
51
+ }>;
47
52
  /** The durable per-Computer switches an owner manages. */
48
53
  export type ComputerSwitchSetting = "internet-access" | "keep-awake";
49
54
  /**
@@ -17,7 +17,7 @@ import { SettingsItem } from "./settings-item.js";
17
17
  import { teamComputerDirectorySchema, teamComputerSchema, } from "@fungi.computer/nacre/workbench";
18
18
  import { workbenchDirectorySchema } from "@fungi.computer/nacre/workbench-directory";
19
19
  import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
20
- import { useMemo, useRef, useState, } from "react";
20
+ import { useEffect, useMemo, useRef, useState, } from "react";
21
21
  import * as z from "zod";
22
22
  import { requestIds } from "./team-directory.js";
23
23
  import { tourtoisQueryKeys } from "./queries.js";
@@ -33,6 +33,7 @@ const sizeDetail = (size, prices) => [computerSizes[size].resources, prices?.[si
33
33
  .join(", ");
34
34
  const computerRunStateSchema = z.looseObject({
35
35
  state: z.enum(["running", "sleeping", "starting", "queued", "start_failed"]),
36
+ reason: z.string().min(1).max(1_024).optional(),
36
37
  });
37
38
  const missingRuntime = z.strictObject({ error: z.literal("no_runtime") });
38
39
  const switchUnavailable = z.strictObject({ error: z.literal("unavailable") });
@@ -111,7 +112,8 @@ export function createOysterComputersPort(origin) {
111
112
  },
112
113
  state: async (computerId) => {
113
114
  const response = await read(`/api/computers/${encodeURIComponent(computerId)}/state`);
114
- return computerRunStateSchema.parse(await response.json()).state;
115
+ const { state, reason } = computerRunStateSchema.parse(await response.json());
116
+ return { state, reason };
115
117
  },
116
118
  selection: {
117
119
  selected: async () => {
@@ -220,18 +222,31 @@ function useComputerRunState(teamId, computer, port) {
220
222
  queryFn: () => read === undefined
221
223
  ? Promise.reject(new Error("This host cannot read Computer state"))
222
224
  : read(computer.computerId),
223
- refetchInterval: (query) => query.state.data === "starting" || query.state.data === "queued"
225
+ refetchInterval: (query) => query.state.data?.state === "starting" ||
226
+ query.state.data?.state === "queued"
224
227
  ? 2000
225
228
  : false,
226
229
  });
227
230
  }
228
231
  /** The state beside a Computer's name: a dot and one word. */
229
232
  function ComputerRunStatus({ teamId, computer, port, }) {
230
- const run = useComputerRunState(teamId, computer, port);
231
- if (run.data === undefined)
233
+ const run = useComputerRunState(teamId, computer, port).data;
234
+ const failure = run?.state === "start_failed" ? (run.reason ?? "") : null;
235
+ useEffect(() => {
236
+ if (failure === null)
237
+ return;
238
+ // One toast per failure: its id holds while the state is re-read.
239
+ toast.error(failure === ""
240
+ ? `${computer.name} didn't start. Start it again.`
241
+ : `${computer.name} didn't start: ${failure}. Start it again.`, {
242
+ toasterId: WORKBENCH_NOTICES,
243
+ id: `start-failed:${computer.computerId}:${failure}`,
244
+ });
245
+ }, [failure, computer.name, computer.computerId]);
246
+ if (run === undefined)
232
247
  return null;
233
- const { label, tone } = stateDisplay[run.data];
234
- return (_jsx(Status, { size: "compact", tone: tone, label: label, motion: run.data === "starting" || run.data === "queued" ? "pulse" : "none" }));
248
+ const { label, tone } = stateDisplay[run.state];
249
+ return (_jsx(Status, { size: "compact", tone: tone, label: label, motion: run.state === "starting" || run.state === "queued" ? "pulse" : "none" }));
235
250
  }
236
251
  /**
237
252
  * Start when the Computer sleeps, Stop when it runs; neither while it is
@@ -241,7 +256,7 @@ function ComputerLifecycleKeys({ teamId, computer, port, disabled, busy, onStart
241
256
  const run = useComputerRunState(teamId, computer, port);
242
257
  const [confirming, setConfirming] = useState(false);
243
258
  const canStop = port.stop !== undefined && port.state !== undefined;
244
- if (canStop && run.data === "running")
259
+ if (canStop && run.data?.state === "running")
245
260
  return (_jsxs(_Fragment, { children: [_jsx(KeycapButton, { density: "compact", label: "Stop", icon: _jsx(Sigil, { name: "stop" }), "aria-label": `Stop ${computer.name}`, disabled: disabled || busy, onClick: () => {
246
261
  setConfirming(true);
247
262
  } }), _jsx(Dialog, { open: confirming, onOpenChange: (next, details) => {
@@ -257,7 +272,10 @@ function ComputerLifecycleKeys({ teamId, computer, port, disabled, busy, onStart
257
272
  // The mutation's onError already shows the toast.
258
273
  () => undefined);
259
274
  }, children: "Stop" })] })] }) })] }));
260
- return (_jsx(KeycapButton, { density: "compact", label: "Start", icon: _jsx(Sigil, { name: "run" }), "aria-label": `Start ${computer.name}`, disabled: disabled || busy || run.data === "starting" || run.data === "queued", onClick: onStart }));
275
+ return (_jsx(KeycapButton, { density: "compact", label: "Start", icon: _jsx(Sigil, { name: "run" }), "aria-label": `Start ${computer.name}`, disabled: disabled ||
276
+ busy ||
277
+ run.data?.state === "starting" ||
278
+ run.data?.state === "queued", onClick: onStart }));
261
279
  }
262
280
  /** Owner Settings over the host's existing inventory and optional default. */
263
281
  export function OysterComputers({ teamId, port, onChanged, }) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fungi.computer/tourtois",
3
- "version": "0.29.1",
3
+ "version": "0.29.2",
4
4
  "author": "Levi <levi@technomancy.dev>",
5
5
  "description": "Tourtois: the trusted desktop shell for Oyster and Fungi, with host-supplied Settings sections",
6
6
  "type": "module",
@@ -77,15 +77,15 @@
77
77
  "LICENSE"
78
78
  ],
79
79
  "dependencies": {
80
- "@fungi.computer/agar": "0.23.1",
80
+ "@fungi.computer/agar": "0.23.2",
81
81
  "@fungi.computer/cairn": "0.1.0",
82
82
  "@fungi.computer/caps": "0.12.2",
83
83
  "@fungi.computer/ear-tag": "0.1.0",
84
84
  "@fungi.computer/gills": "0.4.0",
85
85
  "@fungi.computer/maosaico": "0.1.2",
86
- "@fungi.computer/parakeet": "0.16.0",
86
+ "@fungi.computer/parakeet": "0.16.1",
87
87
  "@fungi.computer/puffball": "0.12.0",
88
- "@fungi.computer/shiitake": "0.21.9",
88
+ "@fungi.computer/shiitake": "0.21.10",
89
89
  "@fungi.computer/sigils": "0.3.2",
90
90
  "@fungi.computer/sprite": "0.2.2",
91
91
  "@fungi.computer/sprite-zdog": "0.3.2",
@@ -100,13 +100,13 @@
100
100
  "lucide-react": "0.460.0",
101
101
  "react-dom": "18.3.1",
102
102
  "zod": "4.4.3",
103
- "@fungi.computer/nacre": "0.8.4"
103
+ "@fungi.computer/nacre": "0.8.5"
104
104
  },
105
105
  "peerDependencies": {
106
106
  "react": "^18.3.1 || ^19.2.0"
107
107
  },
108
108
  "devDependencies": {
109
- "@fungi.computer/oyster": "0.47.3",
109
+ "@fungi.computer/oyster": "0.47.4",
110
110
  "@cloudflare/workers-types": "5.20260828.1",
111
111
  "@fungi.computer/forage": "0.3.13",
112
112
  "@fungi.computer/mycelium": "0.4.7",