@fungi.computer/tourtois 0.31.0 → 0.31.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,4 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { toast } from "@fungi.computer/caps/components/toaster";
3
+ import { WORKBENCH_NOTICES } from "./app-toast.js";
4
+ import { failureMessage } from "@fungi.computer/agar/errors";
2
5
  import { Button } from "@fungi.computer/caps/components/button";
3
6
  import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogTitle, } from "@fungi.computer/caps/components/dialog";
4
7
  import { WindowFrame } from "@fungi.computer/caps/components/window";
@@ -60,17 +63,15 @@ function plainRights(request) {
60
63
  /** One-click host consent: one sheet listing every right in plain words. */
61
64
  export function AppAccessConsent({ request, }) {
62
65
  const [saving, setSaving] = useState(false);
63
- const [failed, setFailed] = useState(false);
64
66
  const approve = useRef(null);
65
67
  const settle = (outcome) => {
66
68
  setSaving(false);
67
- setFailed(false);
68
69
  request?.settle(outcome);
69
70
  };
70
71
  return (_jsx(Dialog, { open: request !== null, onOpenChange: (next) => {
71
72
  if (!next && !saving)
72
73
  settle("declined");
73
- }, children: _jsx(DialogContent, { render: _jsx(WindowFrame, { floating: true }), keepMounted: false, className: "tourtois-app-consent", initialFocus: approve, children: _jsxs("div", { className: "tourtois-app-consent-body", children: [_jsx(DialogTitle, { children: request ? `Approve ${request.appName}'s permissions?` : "" }), _jsx(DialogDescription, { children: request ? `${request.appName} would like to:` : "" }), request !== null ? (_jsx("ul", { className: "tourtois-app-consent-rights text-sm", children: plainRights(request).map((right) => (_jsx("li", { children: right }, right))) })) : null, _jsx("p", { className: "text-sm", children: "You can change this later in System Settings." }), request?.refusal !== undefined ? (_jsx("p", { role: "alert", "data-refusal-code": request.refusal.code, children: request.refusal.message })) : null, failed ? (_jsx("p", { role: "alert", children: "Access could not be saved. Try again." })) : null, _jsxs(DialogFooter, { className: "tourtois-app-consent-footer", children: [_jsx(Button, { variant: "ghost", size: "sm", disabled: saving, onClick: () => {
74
+ }, children: _jsx(DialogContent, { render: _jsx(WindowFrame, { floating: true }), keepMounted: false, className: "tourtois-app-consent", initialFocus: approve, children: _jsxs("div", { className: "tourtois-app-consent-body", children: [_jsx(DialogTitle, { children: request ? `Approve ${request.appName}'s permissions?` : "" }), _jsx(DialogDescription, { children: request ? `${request.appName} would like to:` : "" }), request !== null ? (_jsx("ul", { className: "tourtois-app-consent-rights text-sm", children: plainRights(request).map((right) => (_jsx("li", { children: right }, right))) })) : null, _jsx("p", { className: "text-sm", children: "You can change this later in System Settings." }), request?.refusal !== undefined ? (_jsx("p", { role: "alert", "data-refusal-code": request.refusal.code, children: request.refusal.message })) : null, _jsxs(DialogFooter, { className: "tourtois-app-consent-footer", children: [_jsx(Button, { variant: "ghost", size: "sm", disabled: saving, onClick: () => {
74
75
  settle("customize");
75
76
  }, children: "Customize\u2026" }), _jsxs("div", { className: "tourtois-app-consent-decision", children: [_jsx(Button, { variant: "ghost", disabled: saving, onClick: () => {
76
77
  settle("declined");
@@ -78,12 +79,11 @@ export function AppAccessConsent({ request, }) {
78
79
  if (request === null || request.refusal !== undefined)
79
80
  return;
80
81
  setSaving(true);
81
- setFailed(false);
82
82
  void request.allow().then((saved) => {
83
83
  settle(saved ? "granted" : "declined");
84
- }, () => {
84
+ }, (cause) => {
85
85
  setSaving(false);
86
- setFailed(true);
86
+ toast.error(failureMessage("Access could not be saved", cause), { toasterId: WORKBENCH_NOTICES });
87
87
  });
88
88
  }, children: saving ? "Approving…" : "Approve" })] })] })] }) }) }));
89
89
  }
@@ -5,7 +5,8 @@ import { Button } from "@fungi.computer/caps/components/button";
5
5
  import { DataList, DataRow } from "@fungi.computer/caps/components/data-list";
6
6
  import { toast } from "@fungi.computer/caps/components/toaster";
7
7
  import { Select } from "@fungi.computer/caps/components/select";
8
- import { WORKBENCH_NOTICES, failureNotice } from "./app-toast.js";
8
+ import { WORKBENCH_NOTICES } from "./app-toast.js";
9
+ import { failureMessage } from "@fungi.computer/agar/errors";
9
10
  const sizeLabels = { S: "Small", M: "Medium", L: "Large" };
10
11
  function GillOption({ app, gill, desktop, consentReadyAt, }) {
11
12
  const sizes = gill.desktop?.sizes ?? [];
@@ -42,7 +43,7 @@ function GillOption({ app, gill, desktop, consentReadyAt, }) {
42
43
  });
43
44
  if (!retired) {
44
45
  setUnavailable(true);
45
- toast.error(failureNotice("Your desktop could not be read", cause), {
46
+ toast.error(failureMessage("Your desktop could not be read", cause), {
46
47
  toasterId: WORKBENCH_NOTICES,
47
48
  });
48
49
  }
@@ -74,7 +75,7 @@ function GillOption({ app, gill, desktop, consentReadyAt, }) {
74
75
  cause,
75
76
  });
76
77
  setUnavailable(true);
77
- toast.error(failureNotice("The widget could not be changed", cause), {
78
+ toast.error(failureMessage("The widget could not be changed", cause), {
78
79
  toasterId: WORKBENCH_NOTICES,
79
80
  });
80
81
  // A refusal may mean another tab changed the saved layout. Never keep an optimistic membership flag.
@@ -6,6 +6,7 @@ import { ResizeHandle } from "@fungi.computer/caps/components/resize-handle";
6
6
  import { LoadingState } from "@fungi.computer/caps/blocks/loading-state";
7
7
  import { toast, Toaster } from "@fungi.computer/caps/components/toaster";
8
8
  import { WORKBENCH_NOTICES } from "./app-toast.js";
9
+ import { failureMessage } from "@fungi.computer/agar/errors";
9
10
  import { WindowSnapPreview } from "@fungi.computer/caps/components/window";
10
11
  import { MaosaicoRegion, useLayer, useMaosaicoLayout, } from "@fungi.computer/maosaico";
11
12
  import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore, } from "react";
@@ -57,7 +58,7 @@ function arrangeDesktop(hide, arrange, onFailure) {
57
58
  }
58
59
  void hiding.then(arrange).catch((cause) => {
59
60
  console.error("Arrange desktop could not show the desktop", cause);
60
- onFailure("The desktop could not be shown. Try again.");
61
+ onFailure(failureMessage("The desktop could not be shown", cause));
61
62
  });
62
63
  }
63
64
  /** Phone Home uses the same public shell command as the keyboard. */
@@ -70,12 +71,12 @@ function phoneShowDesktop(phone, covered, host, onFailure) {
70
71
  .then((outcome) => {
71
72
  if (outcome.status !== "handled") {
72
73
  console.error("Phone Show desktop refused", outcome);
73
- onFailure("The desktop could not be shown. Try again.");
74
+ onFailure(`The desktop could not be shown: the host answered ${outcome.status}.`);
74
75
  }
75
76
  })
76
77
  .catch((cause) => {
77
78
  console.error("Phone Show desktop failed", cause);
78
- onFailure("The desktop could not be shown. Try again.");
79
+ onFailure(failureMessage("The desktop could not be shown", cause));
79
80
  });
80
81
  };
81
82
  }
@@ -325,15 +326,16 @@ export function AppWorkbench({ paneLayerRef, phone, teamId, teamName, initialCom
325
326
  const apps = refreshed.data?.apps ?? [];
326
327
  reconciledDirectoryRef.current = apps;
327
328
  const failure = { action: null };
328
- const replaced = await reconcileAppWindowFromDirectory(appWindows, launch, apps, launchFor, { kind: "selection-changed" }, (action) => {
329
+ const replaced = await reconcileAppWindowFromDirectory(appWindows, launch, apps, launchFor, { kind: "selection-changed" }, (action, cause) => {
329
330
  failure.action = action;
331
+ failure.cause = cause;
330
332
  });
331
333
  if (!replaced && failure.action === null)
332
334
  setAppStatus("The App selection changed. This window stayed open; close it after saving or discarding work, then reopen the App.");
333
335
  else if (!replaced)
334
- setAppStatus(failure.action === "close"
335
- ? "App could not be closed."
336
- : "App could not be replaced.");
336
+ setAppStatus(failureMessage(failure.action === "close"
337
+ ? "App could not be closed"
338
+ : "App could not be replaced", failure.cause));
337
339
  return replaced;
338
340
  };
339
341
  const openNavigation = async (input) => {
@@ -458,10 +460,10 @@ export function AppWorkbench({ paneLayerRef, phone, teamId, teamName, initialCom
458
460
  reconciledDirectoryRef.current = null;
459
461
  return;
460
462
  }
461
- void reconcileAppDirectory(appWindows, listedApps, launchFor, (action) => {
462
- setAppStatus(action === "close"
463
- ? "App could not be closed."
464
- : "App could not be replaced.");
463
+ void reconcileAppDirectory(appWindows, listedApps, launchFor, (action, cause) => {
464
+ setAppStatus(failureMessage(action === "close"
465
+ ? "App could not be closed"
466
+ : "App could not be replaced", cause));
465
467
  });
466
468
  }, [appWindows, listedApps, initialComputerId, computers]);
467
469
  const directory = useMemo(() => listedApps ?? [], [listedApps]);
@@ -12,7 +12,8 @@ import { useState } from "react";
12
12
  import * as z from "zod";
13
13
  import { SettingsItem } from "./settings-item.js";
14
14
  import { toast } from "@fungi.computer/caps/components/toaster";
15
- import { WORKBENCH_NOTICES, failureNotice } from "./app-toast.js";
15
+ import { WORKBENCH_NOTICES } from "./app-toast.js";
16
+ import { failureMessage } from "@fungi.computer/agar/errors";
16
17
  /** What an Agent may do with one connection: everything, only reads, or named tools. */
17
18
  const connectionAccessSchema = z.union([
18
19
  z.literal("all"),
@@ -77,7 +78,7 @@ export function Connections({ port, target, onNavigate, }) {
77
78
  mutationFn: (connectionId) => port.remove(connectionId),
78
79
  onSuccess: refresh,
79
80
  onError: (cause) => {
80
- toast.error(failureNotice("The connection could not be removed", cause), {
81
+ toast.error(failureMessage("The connection could not be removed", cause), {
81
82
  toasterId: WORKBENCH_NOTICES,
82
83
  });
83
84
  },
@@ -122,7 +123,7 @@ function AgentAccess({ connection, agents, port, onChanged, }) {
122
123
  },
123
124
  onSuccess: onChanged,
124
125
  onError: (cause) => {
125
- toast.error(failureNotice("The access could not be changed", cause), {
126
+ toast.error(failureMessage("The access could not be changed", cause), {
126
127
  toasterId: WORKBENCH_NOTICES,
127
128
  });
128
129
  },
@@ -18,7 +18,8 @@ import * as Schema from "effect/Schema";
18
18
  import * as z from "zod";
19
19
  import { websiteConversationSchema, websiteTranscriptSchema, } from "@fungi.computer/nacre/website-channels";
20
20
  import { ChannelConversations } from "./ChannelConversations.js";
21
- import { WORKBENCH_NOTICES, failureNotice } from "./app-toast.js";
21
+ import { WORKBENCH_NOTICES } from "./app-toast.js";
22
+ import { failureMessage } from "@fungi.computer/agar/errors";
22
23
  import { tourtoisQueryKeys } from "./queries.js";
23
24
  import { requestIds } from "./team-directory.js";
24
25
  const snowflake = z.string().regex(/^\d{17,20}$/u);
@@ -347,7 +348,7 @@ function DiscordRow({ port, binding, interactionsOrigin, agentName, open, justCr
347
348
  return port.update(binding.bindingId, current.authorityVersion, change);
348
349
  },
349
350
  onError: (cause) => {
350
- toast.error(failureNotice("Couldn't update Discord", cause), {
351
+ toast.error(failureMessage("Couldn't update Discord", cause), {
351
352
  toasterId: WORKBENCH_NOTICES,
352
353
  closeButton: true,
353
354
  });
@@ -357,7 +358,7 @@ function DiscordRow({ port, binding, interactionsOrigin, agentName, open, justCr
357
358
  const register = useMutation({
358
359
  mutationFn: () => port.registerCommands(binding.bindingId),
359
360
  onError: (cause) => {
360
- toast.error(failureNotice("Couldn't register the Discord commands", cause), {
361
+ toast.error(failureMessage("Couldn't register the Discord commands", cause), {
361
362
  toasterId: WORKBENCH_NOTICES,
362
363
  closeButton: true,
363
364
  });
package/dist/Keys.js CHANGED
@@ -14,7 +14,8 @@ import * as z from "zod";
14
14
  import { Sigil } from "@fungi.computer/sigils";
15
15
  import { SettingsItem } from "./settings-item.js";
16
16
  import { toast } from "@fungi.computer/caps/components/toaster";
17
- import { WORKBENCH_NOTICES, failureNotice } from "./app-toast.js";
17
+ import { WORKBENCH_NOTICES } from "./app-toast.js";
18
+ import { failureMessage } from "@fungi.computer/agar/errors";
18
19
  const mutationIds = defineIdFamily({
19
20
  family: "tourtois-keys-mutation",
20
21
  version: 1,
@@ -63,7 +64,7 @@ function KeysContent({ port, apps, }) {
63
64
  }
64
65
  catch (cause) {
65
66
  console.error("Key change failed", pending.kind, cause);
66
- toast.error(failureNotice("The key change failed", cause), {
67
+ toast.error(failureMessage("The key change failed", cause), {
67
68
  toasterId: WORKBENCH_NOTICES,
68
69
  });
69
70
  }
@@ -18,7 +18,8 @@ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
18
18
  import { useId, useMemo, useState } from "react";
19
19
  import * as z from "zod";
20
20
  import { ChannelConversations } from "./ChannelConversations.js";
21
- import { WORKBENCH_NOTICES, failureNotice } from "./app-toast.js";
21
+ import { WORKBENCH_NOTICES } from "./app-toast.js";
22
+ import { failureMessage } from "@fungi.computer/agar/errors";
22
23
  import { tourtoisQueryKeys } from "./queries.js";
23
24
  import { requestIds } from "./team-directory.js";
24
25
  /** The Toaster id a host mounts so channel failures reach the person. */
@@ -321,7 +322,7 @@ function WebsiteRow({ port, copy, site, notice, embedOrigin, agentName, open, ju
321
322
  return port.update(site.bindingId, current.authorityVersion, change);
322
323
  },
323
324
  onError: (cause) => {
324
- toast.error(failureNotice("Couldn't save the website", cause), {
325
+ toast.error(failureMessage("Couldn't save the website", cause), {
325
326
  toasterId: WORKBENCH_NOTICES,
326
327
  closeButton: true,
327
328
  });
@@ -7,8 +7,8 @@ export type AppWindowReconciliationTrigger = Readonly<{
7
7
  /** Replace open windows when the owner-issued App directory changes authority. */
8
8
  export declare function reconcileAppDirectory<A extends {
9
9
  surfaceId: string;
10
- }>(appWindows: AppWindowManager, apps: readonly A[], launchFor: (app: A, currentLaunch?: AppLaunchDescriptor) => AppLaunchDescriptor | null, onFailure: (action: "close" | "replace") => void): Promise<void>;
10
+ }>(appWindows: AppWindowManager, apps: readonly A[], launchFor: (app: A, currentLaunch?: AppLaunchDescriptor) => AppLaunchDescriptor | null, onFailure: (action: "close" | "replace", cause: unknown) => void): Promise<void>;
11
11
  /** Refresh one stale mount and report whether its old generation was retired. */
12
12
  export declare function reconcileAppWindowFromDirectory<A extends {
13
13
  surfaceId: string;
14
- }>(appWindows: AppWindowManager, staleLaunch: AppLaunchDescriptor, apps: readonly A[], launchFor: (app: A, currentLaunch?: AppLaunchDescriptor) => AppLaunchDescriptor | null, trigger: AppWindowReconciliationTrigger, onFailure: (action: "close" | "replace") => void): Promise<boolean>;
14
+ }>(appWindows: AppWindowManager, staleLaunch: AppLaunchDescriptor, apps: readonly A[], launchFor: (app: A, currentLaunch?: AppLaunchDescriptor) => AppLaunchDescriptor | null, trigger: AppWindowReconciliationTrigger, onFailure: (action: "close" | "replace", cause: unknown) => void): Promise<boolean>;
@@ -45,7 +45,7 @@ export async function reconcileAppWindowFromDirectory(appWindows, staleLaunch, a
45
45
  }
46
46
  catch (cause) {
47
47
  console.error("App directory reconciliation failed", cause);
48
- onFailure(next ? "replace" : "close");
48
+ onFailure(next ? "replace" : "close", cause);
49
49
  return false;
50
50
  }
51
51
  const after = appWindows
@@ -1,10 +1,4 @@
1
1
  import type { ToastInput } from "@fungi.computer/agar";
2
2
  /** The one Toaster mount an App's notice reaches in the Tourtois shell. */
3
3
  export declare const WORKBENCH_NOTICES = "workbench-notices";
4
- /**
5
- * A failed change as one sentence: what failed, then the host's own reason.
6
- * Host ports throw an Error whose message is that reason; Hub's client names
7
- * the HTTP cause when a refusal's body names none.
8
- */
9
- export declare function failureNotice(summary: string, cause: unknown): string;
10
4
  export declare function showAppToast(notice: ToastInput): void;
package/dist/app-toast.js CHANGED
@@ -1,16 +1,6 @@
1
1
  import { showNotice } from "@fungi.computer/caps/components/toaster";
2
2
  /** The one Toaster mount an App's notice reaches in the Tourtois shell. */
3
3
  export const WORKBENCH_NOTICES = "workbench-notices";
4
- /**
5
- * A failed change as one sentence: what failed, then the host's own reason.
6
- * Host ports throw an Error whose message is that reason; Hub's client names
7
- * the HTTP cause when a refusal's body names none.
8
- */
9
- export function failureNotice(summary, cause) {
10
- return cause instanceof Error && cause.message !== ""
11
- ? `${summary}: ${cause.message}`
12
- : `${summary}.`;
13
- }
14
4
  export function showAppToast(notice) {
15
5
  showNotice(notice, WORKBENCH_NOTICES);
16
6
  }
@@ -1,4 +1,5 @@
1
1
  import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
+ import { failureMessage } from "@fungi.computer/agar/errors";
2
3
  import { useEffect, useRef, useState } from "react";
3
4
  import {} from "@fungi.computer/gills";
4
5
  import { Button } from "@fungi.computer/caps/components/button";
@@ -28,11 +29,11 @@ export function GillParamPicker({ gill, initialParams = {}, computers, transport
28
29
  if (accepted)
29
30
  onClose();
30
31
  else
31
- setError("Your widget could not be saved. Try again.");
32
+ setError("The host did not accept your widget, and gave no reason.");
32
33
  })
33
34
  .catch((cause) => {
34
35
  console.error("Gill placement could not be confirmed", cause);
35
- setError("Your widget placement could not be confirmed.");
36
+ setError(failureMessage("Your widget placement could not be confirmed", cause));
36
37
  })
37
38
  .finally(() => {
38
39
  setSaving(false);
@@ -2,7 +2,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { SectionHeading } from "@fungi.computer/caps/blocks/section-heading";
3
3
  import { memberAvatarSchema, defaultMemberAvatar, } from "@fungi.computer/sprite-zdog/avatar";
4
4
  import { toast } from "@fungi.computer/caps/components/toaster";
5
- import { WORKBENCH_NOTICES, failureNotice } from "./app-toast.js";
5
+ import { WORKBENCH_NOTICES } from "./app-toast.js";
6
+ import { failureMessage } from "@fungi.computer/agar/errors";
6
7
  import { AvatarPreview } from "./AvatarPreview.js";
7
8
  import { AvatarPicker } from "./AvatarPicker.js";
8
9
  import { skipToken, useMutation, useQuery, useQueryClient, } from "@tanstack/react-query";
@@ -62,7 +63,7 @@ function useSaveMemberAvatar(save) {
62
63
  },
63
64
  mutationFn: save,
64
65
  onError: (cause, _next, snapshot) => {
65
- toast.error(failureNotice("Your avatar could not be saved", cause), {
66
+ toast.error(failureMessage("Your avatar could not be saved", cause), {
66
67
  toasterId: WORKBENCH_NOTICES,
67
68
  });
68
69
  if (snapshot &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fungi.computer/tourtois",
3
- "version": "0.31.0",
3
+ "version": "0.31.1",
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.27.0",
80
+ "@fungi.computer/agar": "0.27.1",
81
81
  "@fungi.computer/cairn": "0.1.0",
82
82
  "@fungi.computer/caps": "0.12.8",
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.17.0",
86
+ "@fungi.computer/parakeet": "0.17.1",
87
87
  "@fungi.computer/puffball": "0.15.0",
88
- "@fungi.computer/shiitake": "0.22.2",
88
+ "@fungi.computer/shiitake": "0.22.3",
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.9.1"
103
+ "@fungi.computer/nacre": "0.9.2"
104
104
  },
105
105
  "peerDependencies": {
106
106
  "react": "^18.3.1 || ^19.2.0"
107
107
  },
108
108
  "devDependencies": {
109
- "@fungi.computer/oyster": "0.56.0",
109
+ "@fungi.computer/oyster": "0.56.2",
110
110
  "@cloudflare/workers-types": "5.20260828.1",
111
111
  "@fungi.computer/forage": "0.5.1",
112
112
  "@fungi.computer/mycelium": "0.4.11",