@fungi.computer/tourtois 0.11.0 → 0.12.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.
package/dist/AppPane.d.ts CHANGED
@@ -8,7 +8,7 @@ export declare function FocusedWindowControls({ app, onOpenSettings, onOpenPermi
8
8
  onOpenPermissions: () => void;
9
9
  projection: AppWindowProjection;
10
10
  }): import("react/jsx-runtime").JSX.Element | null;
11
- export declare function AppPane({ projection, nextLaunch, icon, manager, onError, index, focusWindow, afterHide, onBack, onSelectComputer, }: {
11
+ export declare function AppPane({ projection, nextLaunch, icon, manager, onError, index, focusWindow, afterHide, onBack, onSelectComputer, onChooseComputer, }: {
12
12
  projection: AppWindowProjection;
13
13
  nextLaunch?: AppLaunchDescriptor | null;
14
14
  icon: string | null | undefined;
@@ -20,6 +20,8 @@ export declare function AppPane({ projection, nextLaunch, icon, manager, onError
20
20
  onBack: (id: string) => void;
21
21
  /** The person chose another of this window's offered Computers. */
22
22
  onSelectComputer: (windowId: string, computerId: string) => void;
23
+ /** No Computer is granted: open the App's permissions to grant one. */
24
+ onChooseComputer: (surfaceId: string) => void;
23
25
  }): import("react/jsx-runtime").JSX.Element;
24
26
  /**
25
27
  * One window's status bar, owned by the shell like its title bar: the
@@ -31,7 +33,7 @@ export declare function AppPane({ projection, nextLaunch, icon, manager, onError
31
33
  * a shorter notice takes precedence over Inkcap's low-value file count, never
32
34
  * over the App's save state. Desktop presentation stays unchanged.
33
35
  */
34
- export declare function WindowStatusBar({ projection, onSelectComputer, onAction, surface, computerPickerOpen, onComputerPickerOpenChange, onReload, }: {
36
+ export declare function WindowStatusBar({ projection, onSelectComputer, onAction, surface, computerPickerOpen, onComputerPickerOpenChange, onReload, onChooseComputer, }: {
35
37
  projection: AppWindowProjection;
36
38
  onSelectComputer: (computerId: string) => void;
37
39
  onAction: (action: AppStatusAction) => void;
@@ -41,4 +43,6 @@ export declare function WindowStatusBar({ projection, onSelectComputer, onAction
41
43
  onComputerPickerOpenChange?: (open: boolean) => void;
42
44
  /** Uses the window manager's ordinary, veto-respecting replacement. */
43
45
  onReload?: (() => void) | undefined;
46
+ /** With no Computer granted, the chip that opens the App's permissions. */
47
+ onChooseComputer?: (() => void) | undefined;
44
48
  }): import("react/jsx-runtime").JSX.Element | null;
package/dist/AppPane.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { Alert } from "@fungi.computer/caps/components/alert";
2
+ import { LoadingState } from "@fungi.computer/caps/blocks/loading-state";
3
+ import { ResultState } from "@fungi.computer/caps/blocks/result-state";
3
4
  import { Button } from "@fungi.computer/caps/components/button";
4
5
  import { IconButton } from "@fungi.computer/caps/components/icon-button";
5
6
  import { AppStatusBar, AppStatusItem, StatusBarChip, StatusBarPicker, } from "@fungi.computer/caps/blocks/app-status-bar";
@@ -44,22 +45,23 @@ function headerContent(navigation, popover, activate) {
44
45
  content = { ...content, status: navigation.status };
45
46
  return content;
46
47
  }
47
- const windowStatusLabel = (projection) => {
48
- if (projection.status === "error")
49
- return describeAppError(projection.error).message;
50
- if (projection.status === "loading")
51
- return `${projection.launch.title} opening…`;
52
- if (projection.status === "getting-ready")
53
- return "Getting ready…";
54
- return projection.launch.title;
55
- };
56
48
  /** The focused window's App-level settings; its Computer lives in its status bar. */
57
49
  export function FocusedWindowControls({ app, onOpenSettings, onOpenPermissions, projection, }) {
58
50
  if (!app)
59
51
  return null;
60
52
  return (_jsxs("div", { className: "tourtois-focused-controls", role: "group", "aria-label": `${projection.launch.title} settings`, children: [_jsx(IconButton, { size: "responsive", "aria-label": `Permissions for ${projection.launch.title}`, title: "App permissions", icon: _jsx(ShieldCheck, {}), onClick: onOpenPermissions }), _jsx(IconButton, { size: "responsive", "aria-label": `Settings for ${projection.launch.title}`, title: "App settings", icon: _jsx(Settings, {}), onClick: onOpenSettings })] }));
61
53
  }
62
- export function AppPane({ projection, nextLaunch, icon, manager, onError, index, focusWindow, afterHide, onBack, onSelectComputer, }) {
54
+ /** The window's failure card: what happened, what to try, one primary way out. */
55
+ function WindowFailure({ projection, onReopen, }) {
56
+ const { title: appTitle } = projection.launch;
57
+ const lost = projection.error instanceof AppError &&
58
+ projection.error.code === "DISCONNECTED";
59
+ const described = describeAppError(projection.error);
60
+ return (_jsx(ResultState, { className: "tourtois-window-failure", tone: "failed", headingLevel: 3, title: lost ? "This App lost its connection" : described.title, description: _jsxs(_Fragment, { children: [lost ? `${appTitle} stopped answering.` : described.message, _jsx("span", { className: "tourtois-window-failure-note", children: "A request may have finished even if its reply did not arrive, so check before repeating it." })] }), actions: _jsxs(_Fragment, { children: [_jsxs(Button, { type: "button", variant: "primary", onClick: onReopen, children: ["Reopen ", appTitle] }), _jsx(Button, { type: "button", variant: "outline", onClick: () => {
61
+ window.location.reload();
62
+ }, children: "Reload workspace" })] }) }));
63
+ }
64
+ export function AppPane({ projection, nextLaunch, icon, manager, onError, index, focusWindow, afterHide, onBack, onSelectComputer, onChooseComputer, }) {
63
65
  const containerRef = useRef(null);
64
66
  const popover = useLayer("popover");
65
67
  const [computerPickerOpen, setComputerPickerOpen] = useState(false);
@@ -178,14 +180,16 @@ export function AppPane({ projection, nextLaunch, icon, manager, onError, index,
178
180
  onError("App could not be minimized.");
179
181
  });
180
182
  }, onClose: close }) }) }), projection.status === "loading" ||
181
- projection.status === "getting-ready" ? (_jsxs("div", { className: "tourtois-app-loading", role: "status", children: [_jsx(AppIcon, { roles: projection.launch.roles, icon: icon }), _jsxs("div", { children: [_jsx("strong", { children: projection.status === "getting-ready"
182
- ? "Getting ready…"
183
- : `Opening ${projection.launch.title}…` }), _jsx("span", { children: "Preparing this App for your workspace." })] })] })) : null, projection.status === "error" ? (_jsx("div", { className: "tourtois-window-status", children: _jsx(Alert, { tone: "warning", title: projection.error instanceof AppError &&
184
- projection.error.code === "DISCONNECTED"
185
- ? "This App lost its connection."
186
- : windowStatusLabel(projection), description: "Check your connection and the host before reloading. A request may have completed even if its reply did not arrive; check its result before repeating it.", children: _jsx("div", { style: { marginTop: "var(--spacing-md)" }, children: _jsx(Button, { type: "button", variant: "outline", onClick: () => {
187
- window.location.reload();
188
- }, children: "Reload workspace" }) }) }) })) : null, _jsx(WindowBody, { ref: containerRef, className: "tourtois-pane-body", hidden: projection.status === "error" }), _jsx(WindowStatusBar, { projection: projection, onReload: nextLaunch && nextLaunch.releaseId !== projection.launch.releaseId
183
+ projection.status === "getting-ready" ? (_jsx(LoadingState, { className: "tourtois-app-loading", framed: false, icon: _jsx(AppIcon, { roles: projection.launch.roles, icon: icon }), variant: projection.status === "getting-ready" ? "square" : "line", message: projection.status === "getting-ready"
184
+ ? `Getting ${projection.launch.title} ready…`
185
+ : `Opening ${projection.launch.title}…`, detail: "Preparing this App for your workspace." })) : null, projection.status === "error" ? (_jsx("div", { className: "tourtois-window-status", children: _jsx(WindowFailure, { projection: projection, onReopen: () => {
186
+ void manager
187
+ .replace(projection.windowId, projection.launch)
188
+ .catch((cause) => {
189
+ console.error("App reopen failed", cause);
190
+ onError("App could not be reopened.");
191
+ });
192
+ } }) })) : null, _jsx(WindowBody, { ref: containerRef, className: "tourtois-pane-body", hidden: projection.status === "error" }), _jsx(WindowStatusBar, { projection: projection, onReload: nextLaunch && nextLaunch.releaseId !== projection.launch.releaseId
189
193
  ? () => {
190
194
  void manager
191
195
  .replace(projection.windowId, nextLaunch)
@@ -194,7 +198,9 @@ export function AppPane({ projection, nextLaunch, icon, manager, onError, index,
194
198
  onError("App could not be reloaded.");
195
199
  });
196
200
  }
197
- : undefined, computerPickerOpen: computerPickerOpen, onComputerPickerOpenChange: (open) => {
201
+ : undefined, onChooseComputer: () => {
202
+ onChooseComputer(projection.launch.surfaceId);
203
+ }, computerPickerOpen: computerPickerOpen, onComputerPickerOpenChange: (open) => {
198
204
  if (open)
199
205
  dismissOthers();
200
206
  setComputerPickerOpen(open);
@@ -219,7 +225,7 @@ export function AppPane({ projection, nextLaunch, icon, manager, onError, index,
219
225
  * a shorter notice takes precedence over Inkcap's low-value file count, never
220
226
  * over the App's save state. Desktop presentation stays unchanged.
221
227
  */
222
- export function WindowStatusBar({ projection, onSelectComputer, onAction, surface, computerPickerOpen, onComputerPickerOpenChange, onReload, }) {
228
+ export function WindowStatusBar({ projection, onSelectComputer, onAction, surface, computerPickerOpen, onComputerPickerOpenChange, onReload, onChooseComputer, }) {
223
229
  const popover = useLayer("popover");
224
230
  const [phone, setPhone] = useState(false);
225
231
  useEffect(() => {
@@ -237,7 +243,10 @@ export function WindowStatusBar({ projection, onSelectComputer, onAction, surfac
237
243
  const { computers, title } = projection.launch;
238
244
  const items = projection.statusItems;
239
245
  if (computers === undefined && items.length === 0 && !onReload)
240
- return null;
246
+ // While the App opens, an empty bar holds the footer's height so the
247
+ // window does not jump when the readouts arrive.
248
+ return projection.status === "loading" ||
249
+ projection.status === "getting-ready" ? (_jsx(AppStatusBar, { "aria-hidden": "true", className: "tourtois-window-status-bar" })) : null;
241
250
  const anchorFor = (key) => {
242
251
  const origin = surface?.()?.getBoundingClientRect();
243
252
  if (!origin)
@@ -251,14 +260,17 @@ export function WindowStatusBar({ projection, onSelectComputer, onAction, surfac
251
260
  const render = (item) => (_jsx(WindowStatusItem, { item: item, container: popover, onAction: onAction, anchorFor: anchorFor }, item.id));
252
261
  const end = items.filter((item) => item.end === true);
253
262
  const start = items.filter((item) => item.end !== true &&
254
- !(phone &&
255
- projection.launch.appId === "inkcap" &&
256
- item.kind === "text" &&
257
- item.id === "documents"));
263
+ !(phone && item.kind === "text" && item.priority === "low"));
258
264
  const appReadouts = end.length === 0 ? undefined : end.map(render);
259
- return (_jsx(AppStatusBar, { className: "tourtois-window-status-bar", "aria-label": `${title} status`, attachment:
260
- // One Computer is not a choice: the picker appears from two.
261
- computers === undefined || computers.length === 1 ? undefined : (_jsx(StatusBarPicker, { ...(computerPickerOpen === undefined
265
+ // Zero Computers: a chip to grant one. One is not a choice, so the picker
266
+ // appears from two.
267
+ let attachment;
268
+ if (computers === undefined || computers.length === 1)
269
+ attachment = undefined;
270
+ else if (computers.length === 0)
271
+ attachment = (_jsx(StatusBarChip, { label: "Choose Computer", onClick: onChooseComputer }));
272
+ else
273
+ attachment = (_jsx(StatusBarPicker, { ...(computerPickerOpen === undefined
262
274
  ? {}
263
275
  : { open: computerPickerOpen }), ...(onComputerPickerOpenChange === undefined
264
276
  ? {}
@@ -266,7 +278,8 @@ export function WindowStatusBar({ projection, onSelectComputer, onAction, surfac
266
278
  id: computer.computerId,
267
279
  label: computer.name,
268
280
  })), value: launchComputerId(projection.launch.href), emptyMessage: "No Computers are granted to this App", disabled: projection.status === "loading" ||
269
- projection.status === "getting-ready", onSelect: onSelectComputer })), end: onReload ? (_jsxs("span", { className: phone
281
+ projection.status === "getting-ready", onSelect: onSelectComputer }));
282
+ return (_jsx(AppStatusBar, { className: "tourtois-window-status-bar", "aria-label": `${title} status`, attachment: attachment, end: onReload ? (_jsxs("span", { className: phone
270
283
  ? "flex min-w-0 items-center gap-xs"
271
284
  : "flex min-w-0 flex-wrap items-center gap-xs", children: [appReadouts, _jsxs(AppStatusItem, { children: [_jsx("span", { role: "status", children: phone ? "Update ready" : "New version available" }), _jsx(StatusBarChip, { label: "Reload", "aria-label": `Reload ${title}`, onClick: onReload })] })] })) : (appReadouts), children: start.length === 0 ? undefined : start.map(render) }));
272
285
  }
@@ -5,6 +5,7 @@ import {} from "@fungi.computer/caps/blocks/app-bar";
5
5
  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
+ import { WORKBENCH_NOTICES } from "./app-toast.js";
8
9
  import { WindowSnapPreview } from "@fungi.computer/caps/components/window";
9
10
  import { MaosaicoRegion, useLayer, useMaosaicoLayout, } from "@fungi.computer/maosaico";
10
11
  import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore, } from "react";
@@ -42,9 +43,11 @@ function announceFloating(tiled, projection) {
42
43
  if (!tiled && !hasVisibleAppWindows(projection))
43
44
  toast("New windows will float", {
44
45
  id: "workbench-layout",
45
- toasterId: "workbench-notices",
46
+ toasterId: WORKBENCH_NOTICES,
46
47
  });
47
48
  }
49
+ /** The trial's starter Apps that are still being set up, if the host says so. */
50
+ const installingApps = (directory) => directory?.installing;
48
51
  /** Windows cover the desktop, so Show desktop runs before arranging it. */
49
52
  function arrangeDesktop(hide, arrange, onFailure) {
50
53
  const hiding = hide();
@@ -121,7 +124,7 @@ export function AppWorkbench({ paneLayerRef, phone, teamId, teamName, initialCom
121
124
  message = "This App lost its connection.";
122
125
  const notice = {
123
126
  id: "workbench-status",
124
- toasterId: "workbench-notices",
127
+ toasterId: WORKBENCH_NOTICES,
125
128
  closeButton: true,
126
129
  dismissible: true,
127
130
  };
@@ -584,10 +587,10 @@ export function AppWorkbench({ paneLayerRef, phone, teamId, teamName, initialCom
584
587
  }, onOpenPermissions: () => {
585
588
  openAppPermissions(activeWindow.launch.surfaceId);
586
589
  } }, activeWindow.windowId)) : null, systemMenuItems: systemMenuItems }), noticeContainer
587
- ? createPortal(_jsx(Toaster, { id: "workbench-notices", position: "bottom-right", offset: 24, mobileOffset: 24, style: { fontFamily: "var(--font-sans)" }, closeButton: true }), noticeContainer)
590
+ ? createPortal(_jsx(Toaster, { id: WORKBENCH_NOTICES, position: "bottom-right", offset: 24, mobileOffset: 24, style: { fontFamily: "var(--font-sans)" }, closeButton: true }), noticeContainer)
588
591
  : null, _jsxs("div", { className: "relative min-h-0 flex-1", children: [_jsx(MaosaicoRegion, { layer: "desktop", style: { position: "absolute", inset: 0 }, "data-desktop-visibility": visibility, ref: desktopRef, "aria-hidden": covered ? true : undefined, children: _jsx(Desktop, { phone: phone, editing: desktopEditing, onEditingChange: setDesktopEditing, onOwner: receiveDesktopOwner, launcherItems: launchableItems, onAllApps: () => {
589
592
  setAppDialOpen(true);
590
- }, paused: covered, apps: windowApps, needsUpdate: needsUpdate, onAppSettings: (app) => {
593
+ }, installing: installingApps(appsQuery.data), onRetryInstall: platform.retryInstall, paused: covered, apps: windowApps, needsUpdate: needsUpdate, onAppSettings: (app) => {
591
594
  setSettingsLocation({
592
595
  category: "apps",
593
596
  appKey: addressKey(app.address),
@@ -607,7 +610,7 @@ export function AppWorkbench({ paneLayerRef, phone, teamId, teamName, initialCom
607
610
  const app = directory.find((item) => item.surfaceId === projection.launch.surfaceId);
608
611
  return (_jsx(AppPane, { index: index, focusWindow: focusWindow, afterHide: afterHide, onBack: goBack, manager: appWindows, projection: projection, nextLaunch: app ? launchFor(app, projection.launch) : null, icon: app?.icon, onError: setAppStatus, onSelectComputer: (windowId, computerId) => {
609
612
  void selectWindowComputer(windowId, computerId);
610
- } }, projection.windowId));
613
+ }, onChooseComputer: openAppPermissions }, projection.windowId));
611
614
  }), extraPanes?.({ activeId, order, focus }), layout.snapPreview && (_jsx(WindowSnapPreview, { "data-snap-side": layout.snapPreview.side, style: {
612
615
  left: layout.snapPreview.frame.x,
613
616
  top: layout.snapPreview.frame.y,
@@ -105,6 +105,15 @@ export declare function useAppDirectory(teamId: string, directoryReader: () => P
105
105
  appId: string | null;
106
106
  displayName: string;
107
107
  }[] | undefined;
108
+ installing?: {
109
+ installationId: string;
110
+ displayName: string;
111
+ state: "failed" | "installing" | "needs-runtime";
112
+ reason?: {
113
+ code: "unknown" | "build_failed" | "network" | "unsupported";
114
+ message: string;
115
+ } | undefined;
116
+ }[] | undefined;
108
117
  }, Error>;
109
118
  apps: {
110
119
  address: {
@@ -15,7 +15,10 @@ export function useAppDirectory(teamId, directoryReader) {
15
15
  // is refused. Every directory read costs the host a Registry read, and
16
16
  // explicit mutations already invalidate this query, so the poll is a slow
17
17
  // backstop. React Query pauses it while the page is hidden.
18
- refetchInterval: 60_000,
18
+ // While a trial installs its starter Apps the list changes, so poll quickly.
19
+ refetchInterval: (current) => current.state.data?.installing?.some((entry) => entry.state === "installing")
20
+ ? 3_000
21
+ : 60_000,
19
22
  });
20
23
  return {
21
24
  query,
@@ -1,6 +1,6 @@
1
1
  import { type ReactNode } from "react";
2
2
  import type { WhistleCommand, WhistleCommandKey, WhistleExecutionInput, WhistleExecutionOutcome, WhistleMenuProjection, WhistleSnapshot } from "@fungi.computer/whistle";
3
- import type { AgentSessionSelection, AppNavigationState, AppStatusItem, FileNavigationInput } from "@fungi.computer/agar";
3
+ import type { AgentSessionSelection, AppNavigationState, AppStatusItem, FileNavigationInput, ToastInput } from "@fungi.computer/agar";
4
4
  import type { AppOpenInput, AppRoleChoice } from "@fungi.computer/agar/apps";
5
5
  import type { AppDeclaredCommand } from "@fungi.computer/puffball/app";
6
6
  import type { AppWindowMount } from "./app-windows.js";
@@ -20,6 +20,8 @@ export type TourtoisAppMountEvents = Pick<WindowEvents, "onDeliveryPending"> & R
20
20
  onNavigationState?: (state: AppNavigationState | null) => void;
21
21
  /** The App's parsed status readouts for its window's status bar. */
22
22
  onStatusItems?: (items: readonly AppStatusItem[]) => void;
23
+ /** A transient notice the App asks the shell to show. */
24
+ onToast?: (toast: ToastInput) => void;
23
25
  /**
24
26
  * The App's own document took focus, as when the person clicks into it.
25
27
  * Its sandboxed frame keeps that pointer from this document, so the App's
@@ -0,0 +1,4 @@
1
+ import type { ToastInput } from "@fungi.computer/agar";
2
+ /** The one Toaster mount an App's notice reaches in the Tourtois shell. */
3
+ export declare const WORKBENCH_NOTICES = "workbench-notices";
4
+ export declare function showAppToast(notice: ToastInput): void;
@@ -0,0 +1,6 @@
1
+ import { showNotice } from "@fungi.computer/caps/components/toaster";
2
+ /** The one Toaster mount an App's notice reaches in the Tourtois shell. */
3
+ export const WORKBENCH_NOTICES = "workbench-notices";
4
+ export function showAppToast(notice) {
5
+ showNotice(notice, WORKBENCH_NOTICES);
6
+ }
@@ -4,6 +4,7 @@ import type { AppStorage } from "@fungi.computer/agar/storage";
4
4
  import type { AppBarItem } from "@fungi.computer/caps/blocks/app-bar";
5
5
  import type { WorkbenchDirectory } from "@fungi.computer/nacre/workbench-directory";
6
6
  import { type DesktopLayoutClient } from "../desktop-client.js";
7
+ import type { InstallingApp } from "@fungi.computer/nacre/workbench-directory";
7
8
  import { type DesktopGillTransport } from "./row-gill.js";
8
9
  export type DesktopProps = {
9
10
  phone: boolean;
@@ -19,6 +20,9 @@ export type DesktopProps = {
19
20
  unavailable: boolean;
20
21
  onRetryApps: () => void;
21
22
  onAllApps: () => void;
23
+ /** Starter Apps a trial is still setting up, or could not set up. */
24
+ installing?: readonly InstallingApp[] | undefined;
25
+ onRetryInstall?: ((installationId: string) => Promise<void>) | undefined;
22
26
  onOpen: (target: AppOpenInput) => void;
23
27
  computersForGill?: ((surfaceId: string) => readonly {
24
28
  computerId: string;
@@ -8,6 +8,7 @@ import { LoadingState } from "@fungi.computer/caps/blocks/loading-state";
8
8
  import { Button } from "@fungi.computer/caps/components/button";
9
9
  import { IconButton } from "@fungi.computer/caps/components/icon-button";
10
10
  import { GripVertical, Trash2 } from "lucide-react";
11
+ import { WORKBENCH_NOTICES } from "../app-toast.js";
11
12
  import { toast } from "@fungi.computer/caps/components/toaster";
12
13
  import { Badge } from "@fungi.computer/caps/components/badge";
13
14
  import { Sigil } from "@fungi.computer/sigils";
@@ -248,7 +249,7 @@ function ArrangedDesktop({ owner, ...props }) {
248
249
  if (saved)
249
250
  toast("Desktop saved", {
250
251
  id: "desktop-saved",
251
- toasterId: "workbench-notices",
252
+ toasterId: WORKBENCH_NOTICES,
252
253
  });
253
254
  setSaved(false);
254
255
  onEditingChange(false);
@@ -334,7 +335,7 @@ function ArrangedDesktop({ owner, ...props }) {
334
335
  }, children: [_jsx("div", { className: "tourtois-desktop-tile-body", ref: (node) => {
335
336
  if (node)
336
337
  node.inert = editing;
337
- }, children: gill.kind === "launcher" ? (_jsx(LauncherGill, { items: props.launcherItems, size: item.size, onAllApps: props.onAllApps, loading: props.loading, unavailable: props.unavailable, onRetry: props.onRetryApps, warnings: warnings, preferences: snapshot.layout.launcher, onPreference: (id, state) => {
338
+ }, children: gill.kind === "launcher" ? (_jsx(LauncherGill, { items: props.launcherItems, size: item.size, onAllApps: props.onAllApps, installing: props.installing ?? [], onRetryInstall: props.onRetryInstall, loading: props.loading, unavailable: props.unavailable, onRetry: props.onRetryApps, warnings: warnings, preferences: snapshot.layout.launcher, onPreference: (id, state) => {
338
339
  void save("layout.launcher", { appId: id, state });
339
340
  }, editHandle: editing ? _jsx("span", { "aria-hidden": "true" }) : undefined, onContentHeight: onContentHeight })) : declaration && app ? (_jsx(RowGill, { surfaceId: item.surfaceId, appHeader: {
340
341
  name: app.displayName ?? "App",
@@ -1,8 +1,9 @@
1
1
  import type { AppGridItem } from "@fungi.computer/caps/blocks/launcher-grid";
2
2
  import type { AppBarItem } from "@fungi.computer/caps/blocks/app-bar";
3
3
  import type { AppGillDesktopSize } from "@fungi.computer/gills";
4
+ import type { InstallingApp } from "@fungi.computer/nacre/workbench-directory";
4
5
  /** Trusted shell Gill. Defaults to the same complete launchable set/order as the AppBar. */
5
- export declare function LauncherGill({ items, size, onAllApps, loading, unavailable, onRetry, warnings, preferences, onPreference, editHandle, onContentHeight, }: {
6
+ export declare function LauncherGill({ items, size, onAllApps, loading, unavailable, onRetry, warnings, preferences, onPreference, editHandle, onContentHeight, installing, onRetryInstall, }: {
6
7
  items: readonly AppBarItem[];
7
8
  size?: AppGillDesktopSize;
8
9
  onAllApps: () => void;
@@ -17,4 +18,8 @@ export declare function LauncherGill({ items, size, onAllApps, loading, unavaila
17
18
  onPreference: (id: string, state: "Pinned" | "Shown" | "Hidden") => void;
18
19
  onContentHeight?: ((height: number) => void) | undefined;
19
20
  editHandle?: React.ReactNode;
21
+ /** Starter Apps a trial is still setting up, or could not set up. */
22
+ installing?: readonly InstallingApp[];
23
+ /** Ask the trial to try one failed App again. */
24
+ onRetryInstall?: ((installationId: string) => Promise<void>) | undefined;
20
25
  }): import("react/jsx-runtime").JSX.Element;
@@ -7,12 +7,16 @@ import { Select } from "@fungi.computer/caps/components/select";
7
7
  import { EmptyState } from "@fungi.computer/caps/blocks/empty-state";
8
8
  import { Sigil } from "@fungi.computer/sigils";
9
9
  import { ExternalLink } from "lucide-react";
10
+ import { SetupNotice } from "@fungi.computer/caps/blocks/setup-notice";
11
+ import { FailureLine } from "@fungi.computer/caps/components/failure-line";
12
+ import { Badge } from "@fungi.computer/caps/components/badge";
13
+ import { Loader } from "@fungi.computer/caps/components/loader";
10
14
  import { GillFrame } from "./gill-frame.js";
11
15
  import { FirstRunWelcome, useWelcome } from "./welcome.js";
12
16
  import { LoadingState } from "@fungi.computer/caps/blocks/loading-state";
13
17
  const installDocs = "https://docs.fungi.computer/oyster-quickstart/";
14
18
  /** Trusted shell Gill. Defaults to the same complete launchable set/order as the AppBar. */
15
- export function LauncherGill({ items, size = "M", onAllApps, loading = false, unavailable = false, onRetry, warnings = [], preferences, onPreference, editHandle, onContentHeight, }) {
19
+ export function LauncherGill({ items, size = "M", onAllApps, loading = false, unavailable = false, onRetry, warnings = [], preferences, onPreference, editHandle, onContentHeight, installing = [], onRetryInstall, }) {
16
20
  const [editing, setEditing] = useState(false);
17
21
  const welcome = useWelcome();
18
22
  const stateFor = (id) => preferences.hidden.includes(id)
@@ -25,17 +29,41 @@ export function LauncherGill({ items, size = "M", onAllApps, loading = false, un
25
29
  ...shown.filter((item) => stateFor(item.id) === "Pinned"),
26
30
  ...shown.filter((item) => stateFor(item.id) !== "Pinned"),
27
31
  ];
28
- const tiles = ordered.map((item) => ({
29
- id: item.id,
30
- label: item.label,
31
- icon: item.icon,
32
- onSelect: item.onSelect,
32
+ const needsRuntime = new Set(installing
33
+ .filter((entry) => entry.state === "needs-runtime")
34
+ .map((entry) => `app:${entry.installationId}`));
35
+ const tiles = ordered.map((item) => {
36
+ const tile = {
37
+ id: item.id,
38
+ label: item.label,
39
+ icon: item.icon,
40
+ onSelect: item.onSelect,
41
+ };
42
+ return needsRuntime.has(item.id)
43
+ ? {
44
+ ...tile,
45
+ muted: true,
46
+ status: (_jsx(Badge, { tone: "warning", variant: "quiet", size: "sm", className: "whitespace-nowrap", title: `${item.label} needs a Computer runtime this trial doesn't have`, children: "Needs Computer" })),
47
+ }
48
+ : tile;
49
+ });
50
+ const pendingTiles = installing
51
+ .filter((entry) => entry.state === "installing")
52
+ .map((entry) => ({
53
+ id: `installing:${entry.installationId}`,
54
+ label: entry.displayName,
55
+ icon: _jsx(Loader, { decorative: true, variant: "square", size: "md" }),
56
+ muted: true,
57
+ disabled: true,
58
+ status: (_jsx(Badge, { tone: "neutral", variant: "quiet", size: "sm", className: "whitespace-nowrap", title: `Getting ${entry.displayName} ready…`, children: "Getting ready" })),
59
+ onSelect: () => undefined,
33
60
  }));
34
61
  const ready = !loading && !unavailable;
35
62
  return (_jsxs(GillFrame, { title: "Launcher", size: size, onContentHeight: onContentHeight, editHandle: editHandle ?? (_jsx(Button, { size: "xs", variant: "outline", "aria-expanded": editing, onClick: () => {
36
63
  setEditing(!editing);
37
64
  }, children: editing ? "Done" : "Edit launcher" })), children: [loading ? _jsx(LoadingState, { message: "Loading Apps\u2026" }) : null, unavailable ? (_jsxs("p", { role: "alert", children: ["App directory unavailable.", " ", onRetry ? (_jsx(Button, { size: "sm", variant: "ghost", onClick: onRetry, children: "Retry" })) : null] })) : null, ready ? (_jsxs(_Fragment, { children: [welcome.visible ? (_jsx(FirstRunWelcome, { items: items, onDismiss: welcome.dismiss })) : null, items.length === 0 ? (_jsx(EmptyState, { variant: "hint", title: "No Apps available", description: "Installed launchable Apps appear here." })) : null, items.length > 0 && shown.length === 0 ? (_jsx("p", { children: "No Apps shown. Edit the launcher to show them again." })) : null, _jsx(AppGrid, { "aria-label": "Apps", items: [
38
65
  ...tiles,
66
+ ...pendingTiles,
39
67
  ...warnings,
40
68
  {
41
69
  id: "all-apps",
@@ -43,7 +71,7 @@ export function LauncherGill({ items, size = "M", onAllApps, loading = false, un
43
71
  icon: _jsx(Sigil, { name: "allApps" }),
44
72
  onSelect: onAllApps,
45
73
  },
46
- ], size: "lg" }), _jsx("div", { className: "tourtois-launcher-more", children: _jsxs(Button, { size: "sm", variant: "ghost", onClick: () => {
74
+ ], size: "lg" }), _jsx("div", { className: "tourtois-install-notes", children: installing.map((entry) => entry.state === "installing" ? null : (_jsx(InstallNote, { entry: entry, onRetry: onRetryInstall, onOpen: items.find((item) => item.id === `app:${entry.installationId}`)?.onSelect }, entry.installationId))) }), _jsx("div", { className: "tourtois-launcher-more", children: _jsxs(Button, { size: "sm", variant: "ghost", onClick: () => {
47
75
  window.open(installDocs, "_blank", "noopener,noreferrer");
48
76
  }, children: ["More Apps", _jsx(ExternalLink, { "aria-hidden": "true", size: 14 })] }) }), editing ? (_jsx(DataList, { "aria-label": "Launcher preferences", children: items.map((item) => (_jsx(DataRow, { children: _jsxs("div", { className: "tourtois-launcher-preference", children: [_jsx("span", { "aria-hidden": "true", className: "grid size-6 place-items-center [&_svg]:size-full", children: item.icon ?? _jsx(Sigil, { name: "installApps" }) }), _jsx("div", { className: "tourtois-launcher-preference-identity", children: _jsx("span", { children: item.label }) }), _jsxs(Select, { "aria-label": `Launcher state for ${item.label}`, value: stateFor(item.id), onChange: (event) => {
49
77
  const value = event.currentTarget.value;
@@ -54,3 +82,21 @@ export function LauncherGill({ items, size = "M", onAllApps, loading = false, un
54
82
  onPreference(item.id, value);
55
83
  }, children: [_jsx("option", { value: "Shown", children: "Shown" }), _jsx("option", { value: "Pinned", children: "Pinned" }), _jsx("option", { value: "Hidden", children: "Hidden" })] })] }) }, item.id))) })) : null] })) : null] }));
56
84
  }
85
+ /** A starter App the trial could not set up, or that needs what the trial lacks. */
86
+ function InstallNote({ entry, onRetry, onOpen, }) {
87
+ const [asked, setAsked] = useState(false);
88
+ if (entry.state === "needs-runtime")
89
+ return onOpen ? (_jsx(SetupNotice, { variant: "inline", need: `${entry.displayName} needs a Computer`, cause: entry.reason?.message ??
90
+ `${entry.displayName} is installed, but it needs a Computer runtime this trial doesn't have.`, fix: { label: `Open ${entry.displayName}`, onSelect: onOpen } })) : null;
91
+ return (_jsx(FailureLine, { message: `${entry.displayName} couldn't be installed${entry.reason ? `: ${entry.reason.message}` : "."}`, retryLabel: asked ? "Retrying…" : "Retry", ...(onRetry && !asked
92
+ ? {
93
+ onRetry: () => {
94
+ setAsked(true);
95
+ void onRetry(entry.installationId).catch((cause) => {
96
+ console.error("Retry was not accepted", cause);
97
+ setAsked(false);
98
+ });
99
+ },
100
+ }
101
+ : {}) }));
102
+ }
@@ -68,3 +68,20 @@
68
68
  margin-inline-end: calc(-1 * (var(--spacing-md) + 1px));
69
69
  margin-block-start: var(--spacing-sm);
70
70
  }
71
+
72
+ /* Trial starter Apps that failed or need a runtime stack under the grid. */
73
+ .tourtois-install-notes {
74
+ display: grid;
75
+ gap: var(--spacing-sm);
76
+ margin-block-start: var(--spacing-md);
77
+ }
78
+ .tourtois-install-notes:empty {
79
+ display: none;
80
+ }
81
+ /* One-line failures centre the Retry button on the text. */
82
+ .tourtois-install-notes .caps-failure-line {
83
+ align-items: center;
84
+ }
85
+ .tourtois-install-notes .caps-failure-line > .caps-status {
86
+ margin-block-start: 0;
87
+ }
@@ -318,6 +318,14 @@ export const mountPlatformControls = (root, input) => {
318
318
  ...controls,
319
319
  setup,
320
320
  parseSettings: (value) => S.decodeUnknownSync(S.Json)(settingsLocationSchema.parse(value)),
321
+ retryInstall: async (installationId) => {
322
+ const response = await fetch(`/api/trial/starters/${encodeURIComponent(installationId)}/retry`, { method: "POST", credentials: "same-origin" });
323
+ if (!response.ok)
324
+ throw new AppError("The retry was not accepted", {
325
+ code: "HOST_FAILURE",
326
+ retryable: true,
327
+ });
328
+ },
321
329
  openSettings: (value, options) => {
322
330
  controls.openSettings(settingsLocationSchema.parse(value), options);
323
331
  },
@@ -20,6 +20,8 @@ export type PlatformControls = Readonly<{
20
20
  openSettings: (location: SettingsLocation) => void;
21
21
  /** Settings the host backs with real data; undefined means all of them. */
22
22
  sections?: readonly SettingsLocation["category"][] | undefined;
23
+ /** Ask a trial Oyster to retry one starter App that failed to install. */
24
+ retryInstall?: ((installationId: string) => Promise<void>) | undefined;
23
25
  registerDesktopSettings: (handler: WorkbenchDesktopSettings) => Promise<WorkbenchDesktopRegistration>;
24
26
  /** Observe Team App changes these controls made, to refresh a directory. */
25
27
  subscribeChanges: (listener: () => void) => () => void;
@@ -141,7 +141,7 @@ export function createTourtoisShell(workbench) {
141
141
  // One Whistle graph for Tourtois's own shell commands and every mounted
142
142
  // child's Release-validated commands, so the menu bar and Cmd-K follow focus.
143
143
  const commands = createAppSurfaceCommandHost();
144
- const mount = async (container, launch, signal, { onAgentSessionSelection, onDeliveryPending, onComputerChoice, onNavigation, onAppOpen, onAppRole, onSelectionChanged, onNavigationState, onStatusItems, onFocus, }) => {
144
+ const mount = async (container, launch, signal, { onAgentSessionSelection, onDeliveryPending, onComputerChoice, onNavigation, onAppOpen, onAppRole, onSelectionChanged, onNavigationState, onStatusItems, onToast, onFocus, }) => {
145
145
  const commandMount = commands.mount(launch.surfaceId, launch.commands);
146
146
  let resolveHandle = () => undefined;
147
147
  const handleReady = new Promise((resolve) => {
@@ -191,6 +191,12 @@ export function createTourtoisShell(workbench) {
191
191
  onNavigationState(parseNavigationRelay(relayed));
192
192
  }),
193
193
  }),
194
+ ...(onToast && {
195
+ onToast: (toast) => {
196
+ onToast(toast);
197
+ return Promise.resolve();
198
+ },
199
+ }),
194
200
  ...(onStatusItems && {
195
201
  onStatusItems: (items) =>
196
202
  // The host parsed these at the App's edge; parse again at ours.
package/dist/shell.css CHANGED
@@ -588,35 +588,35 @@
588
588
  min-width: 0;
589
589
  width: 100%;
590
590
  }
591
+ /* The failure fills the body so the footer stays at the window's bottom. */
591
592
  .tourtois-window-status {
592
- padding: var(--spacing-xs) var(--spacing-md);
593
- font-size: 12px;
593
+ display: grid;
594
+ flex: 1 1 auto;
595
+ min-height: 0;
596
+ padding: var(--spacing-lg);
597
+ place-items: center;
598
+ }
599
+ .tourtois-window-failure {
600
+ inline-size: min(100%, 36rem);
601
+ }
602
+ .tourtois-window-failure-note {
594
603
  color: var(--stipe-fg-muted);
604
+ display: block;
605
+ font-size: var(--text-xs);
606
+ margin-block-start: var(--spacing-xs);
595
607
  }
608
+ /* The loader covers the App's body but sits beneath the window's header and
609
+ footer, which stay in place so the window can be closed or minimised. */
596
610
  .tourtois-app-loading {
597
- align-items: center;
598
611
  background: var(--color-base-100);
599
- color: var(--color-base-content);
600
- display: flex;
601
- gap: var(--spacing-md);
602
612
  inset: 0;
603
- justify-content: center;
604
- padding: var(--spacing-lg);
605
613
  position: absolute;
606
614
  z-index: 1;
607
615
  }
608
- .tourtois-app-loading > :is(svg, .caps-monogram) {
609
- flex: none;
610
- height: 2rem;
611
- width: 2rem;
612
- }
613
- .tourtois-app-loading > div {
614
- display: grid;
615
- gap: var(--spacing-xs);
616
- }
617
- .tourtois-app-loading span {
618
- color: var(--stipe-fg-muted);
619
- font-size: var(--text-sm);
616
+ .tourtois-pane .caps-window-header,
617
+ .tourtois-pane .tourtois-window-status-bar {
618
+ position: relative;
619
+ z-index: 2;
620
620
  }
621
621
 
622
622
  .tourtois-team-git {
@@ -1,4 +1,5 @@
1
1
  import { useEffect, useMemo, useRef } from "react";
2
+ import { showAppToast } from "./app-toast.js";
2
3
  import { createAppWindowManager, } from "./app-windows.js";
3
4
  /** One mounted host connection owns its windows, including StrictMode teardown. */
4
5
  export function useAppWindowManager(host, teamId, events) {
@@ -27,6 +28,7 @@ export function useAppWindowManager(host, teamId, events) {
27
28
  },
28
29
  onNavigationState: projectionEvents.onNavigationState,
29
30
  onStatusItems: projectionEvents.onStatusItems,
31
+ onToast: showAppToast,
30
32
  onComputerChoice: projectionEvents.onComputerChoice,
31
33
  });
32
34
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fungi.computer/tourtois",
3
- "version": "0.11.0",
3
+ "version": "0.12.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",
@@ -79,11 +79,11 @@
79
79
  "dependencies": {
80
80
  "@fungi.computer/agar": "0.9.0",
81
81
  "@fungi.computer/cairn": "0.1.0",
82
- "@fungi.computer/caps": "0.9.0",
82
+ "@fungi.computer/caps": "0.10.1",
83
83
  "@fungi.computer/ear-tag": "0.1.0",
84
84
  "@fungi.computer/gills": "0.3.0",
85
85
  "@fungi.computer/maosaico": "0.1.1",
86
- "@fungi.computer/parakeet": "0.10.0",
86
+ "@fungi.computer/parakeet": "0.11.1",
87
87
  "@fungi.computer/puffball": "0.5.5",
88
88
  "@fungi.computer/shiitake": "0.12.3",
89
89
  "@fungi.computer/sigils": "0.3.0",
@@ -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.3.0"
103
+ "@fungi.computer/nacre": "0.4.1"
104
104
  },
105
105
  "peerDependencies": {
106
106
  "react": "^18.3.1 || ^19.2.0"
107
107
  },
108
108
  "devDependencies": {
109
- "@fungi.computer/oyster": "0.16.0",
109
+ "@fungi.computer/oyster": "0.18.1",
110
110
  "@cloudflare/workers-types": "5.20260828.1",
111
111
  "@fungi.computer/forage": "0.3.5",
112
112
  "@fungi.computer/mycelium": "0.3.8",
@@ -118,7 +118,7 @@
118
118
  "typescript": "5.9.3",
119
119
  "vite": "8.2.2",
120
120
  "vitest": "4.1.11",
121
- "wrangler": "4.135.0",
121
+ "wrangler": "4.156.2",
122
122
  "eslint": "10.9.1",
123
123
  "oxlint": "1.78.0",
124
124
  "tsx": "4.23.12",