@fungi.computer/tourtois 0.9.2 → 0.10.0

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.
@@ -3,6 +3,7 @@ import { desktopSettingsHandler } from "./desktop/consent.js";
3
3
  import { AppError } from "@fungi.computer/agar";
4
4
  import {} from "@fungi.computer/caps/blocks/app-bar";
5
5
  import { ResizeHandle } from "@fungi.computer/caps/components/resize-handle";
6
+ import { LoadingState } from "@fungi.computer/caps/blocks/loading-state";
6
7
  import { toast, Toaster } from "@fungi.computer/caps/components/toaster";
7
8
  import { WindowSnapPreview } from "@fungi.computer/caps/components/window";
8
9
  import { MaosaicoRegion, useLayer, useMaosaicoLayout, } from "@fungi.computer/maosaico";
@@ -27,11 +28,35 @@ import { useAppWindowManager } from "./useAppWindowManager.js";
27
28
  import { useDirectoryCommands } from "./useDirectoryCommands.js";
28
29
  const emptyAppBarLabel = (loading, failed) => {
29
30
  if (loading)
30
- return "Loading Apps…";
31
+ return _jsx(LoadingState, { message: "Loading Apps\u2026" });
31
32
  if (failed)
32
33
  return "Apps unavailable";
33
34
  return "Apps will appear here when available.";
34
35
  };
36
+ /** "Edit avatar…" exists only where the host backs avatar Settings. */
37
+ const avatarMenuAction = (platform, open) => platform.sections === undefined || platform.sections.includes("avatar")
38
+ ? open
39
+ : undefined;
40
+ /** Choosing Floating with nothing open would otherwise show no change. */
41
+ function announceFloating(tiled, projection) {
42
+ if (!tiled && !hasVisibleAppWindows(projection))
43
+ toast("New windows will float", {
44
+ id: "workbench-layout",
45
+ toasterId: "workbench-notices",
46
+ });
47
+ }
48
+ /** Windows cover the desktop, so Show desktop runs before arranging it. */
49
+ function arrangeDesktop(hide, arrange, onFailure) {
50
+ const hiding = hide();
51
+ if (!hiding) {
52
+ arrange();
53
+ return;
54
+ }
55
+ void hiding.then(arrange).catch((cause) => {
56
+ console.error("Arrange desktop could not show the desktop", cause);
57
+ onFailure("The desktop could not be shown. Try again.");
58
+ });
59
+ }
35
60
  /** Phone Home uses the same public shell command as the keyboard. */
36
61
  function phoneShowDesktop(phone, covered, host, onFailure) {
37
62
  if (!phone || !covered || !host)
@@ -116,6 +141,29 @@ export function AppWorkbench({ paneLayerRef, phone, teamId, teamName, initialCom
116
141
  else
117
142
  toast(message, notice);
118
143
  }, [appStatus]);
144
+ const editAvatar = avatarMenuAction(platform, () => {
145
+ menuAction(() => {
146
+ setSettingsLocation({ category: "avatar" });
147
+ });
148
+ });
149
+ const hideVisibleWindows = () => {
150
+ if (!hasVisibleAppWindows(appWindows.read()))
151
+ return null;
152
+ layout.zoom(null);
153
+ const hiding = appWindows.hideAll();
154
+ afterHide("");
155
+ return hiding;
156
+ };
157
+ /** A menu command's failure is a notice, never only a console line. */
158
+ const menuAction = (run) => {
159
+ try {
160
+ run();
161
+ }
162
+ catch (cause) {
163
+ console.error("Menu action failed", cause);
164
+ setAppStatus(cause instanceof Error ? cause : "That could not be completed.");
165
+ }
166
+ };
119
167
  const reconciledDirectoryRef = useRef(null);
120
168
  const focusWindow = useCallback((id) => {
121
169
  focus(id);
@@ -509,20 +557,23 @@ export function AppWorkbench({ paneLayerRef, phone, teamId, teamName, initialCom
509
557
  label: "Open Apps",
510
558
  icon: (_jsx(OwnSprite, { "aria-hidden": "true", style: { width: "100%", height: "100%" } })),
511
559
  } }), onOpenSettings: () => {
512
- setSettingsLocation({ category: "home" });
513
- }, onEditAvatar: () => {
514
- setSettingsLocation({ category: "avatar" });
515
- }, focusedId: activeWindow?.windowId ?? null, title: activeWindow?.launch.title ?? "Apps", tiled: mode === "tiled", onLayoutChange: onLayoutChange
560
+ menuAction(() => {
561
+ setSettingsLocation({ category: "home" });
562
+ });
563
+ }, onEditAvatar: editAvatar, focusedId: activeWindow?.windowId ?? null, title: activeWindow?.launch.title ?? "Apps", tiled: mode === "tiled", onLayoutChange: onLayoutChange
516
564
  ? (tiled) => {
517
565
  layout.zoom(null);
518
566
  onLayoutChange(tiled);
567
+ announceFloating(tiled, appProjection);
519
568
  }
520
569
  : undefined, onRestoreLayout: layout.zoomedId
521
570
  ? () => {
522
571
  layout.zoom(null);
523
572
  }
524
573
  : undefined, onArrangeDesktop: () => {
525
- setDesktopEditing(true);
574
+ arrangeDesktop(hideVisibleWindows, () => {
575
+ setDesktopEditing(true);
576
+ }, setAppStatus);
526
577
  }, focusedControls: activeWindow ? (_jsx(FocusedWindowControls, { projection: activeWindow, app: directory.find((app) => app.surfaceId === activeWindow.launch.surfaceId), onOpenSettings: () => {
527
578
  const app = directory.find((item) => item.surfaceId === activeWindow.launch.surfaceId);
528
579
  setSettingsLocation({
@@ -12,7 +12,8 @@ export declare function DesktopMenuBar({ teamName, focusedId, title, appBar, til
12
12
  onArrangeDesktop?: (() => void) | undefined;
13
13
  focusedControls?: ReactNode;
14
14
  onOpenSettings: () => void;
15
- onEditAvatar: () => void;
15
+ /** Absent when the host offers no avatar Settings. */
16
+ onEditAvatar?: (() => void) | undefined;
16
17
  systemMenuItems?: ReactNode;
17
18
  onShowDesktop?: (() => void) | undefined;
18
19
  }): import("react/jsx-runtime").JSX.Element;
@@ -15,9 +15,11 @@ export function DesktopMenuBar({ teamName, focusedId, title, appBar, tiled, onLa
15
15
  const [layoutOpen, setLayoutOpen] = useState(false);
16
16
  return (_jsxs(ShellMenuBar, { children: [_jsxs(DropdownMenu, { modal: false, open: systemOpen, onOpenChange: setSystemOpen, children: [_jsxs(DropdownMenuTrigger, { className: "tourtois-system-menu-trigger", render: _jsx(Button, { size: "menubar", variant: "ghost" }), "aria-label": "Team and account menu", "aria-description": "Current Team: " + teamName, title: teamName, children: [_jsx(MushroomMark, {}), _jsx("span", { className: "tourtois-team-name truncate", children: teamName })] }), _jsxs(DropdownMenuContent, { align: "start", container: popover,
17
17
  // A sibling App click keeps focus there; Escape still returns here.
18
- finalFocus: (interaction) => interaction === "keyboard" && document.hasFocus(), children: [_jsx(DropdownMenuItem, { onSelect: onOpenSettings, children: "System Settings\u2026" }), _jsx(DropdownMenuItem, { onSelect: onEditAvatar, children: "Edit avatar\u2026" }), systemMenuItems] })] }), appBar, onShowDesktop ? (_jsx(IconButton, { size: "responsive", icon: _jsx(Home, {}), "aria-label": "Show desktop", title: "Show desktop", onClick: onShowDesktop })) : null, _jsx("strong", { className: "tourtois-focused-app", children: title }), _jsx(FocusedAppMenus, {}, `menus:${focusedId ?? "shell"}`), onLayoutChange || onRestoreLayout || onArrangeDesktop ? (_jsxs(DropdownMenu, { modal: false, open: layoutOpen, onOpenChange: setLayoutOpen, children: [_jsx(DropdownMenuTrigger, { render: _jsx(Button, { size: "menubar", variant: "ghost" }), children: "Layout" }), _jsxs(DropdownMenuContent, { align: "start", container: popover, finalFocus: (interaction) => interaction === "keyboard" && document.hasFocus(), children: [onLayoutChange ? (_jsxs(_Fragment, { children: [_jsx(DropdownMenuCheckboxItem, { checked: tiled, onCheckedChange: () => {
18
+ finalFocus: (interaction) => interaction === "keyboard" && document.hasFocus(), children: [_jsx(DropdownMenuItem, { onSelect: onOpenSettings, children: "System Settings\u2026" }), onEditAvatar ? (_jsx(DropdownMenuItem, { onSelect: onEditAvatar, children: "Edit avatar\u2026" })) : null, systemMenuItems] })] }), appBar, onShowDesktop ? (_jsx(IconButton, { size: "responsive", icon: _jsx(Home, {}), "aria-label": "Show desktop", title: "Show desktop", onClick: onShowDesktop })) : null, _jsx("strong", { className: "tourtois-focused-app", children: title }), _jsx(FocusedAppMenus, {}, `menus:${focusedId ?? "shell"}`), onLayoutChange || onRestoreLayout || onArrangeDesktop ? (_jsxs(DropdownMenu, { modal: false, open: layoutOpen, onOpenChange: setLayoutOpen, children: [_jsx(DropdownMenuTrigger, { render: _jsx(Button, { size: "menubar", variant: "ghost" }), children: "Layout" }), _jsxs(DropdownMenuContent, { align: "start", container: popover, finalFocus: (interaction) => interaction === "keyboard" && document.hasFocus(), children: [onLayoutChange ? (_jsxs(_Fragment, { children: [_jsx(DropdownMenuCheckboxItem, { checked: tiled, onCheckedChange: () => {
19
19
  onLayoutChange(true);
20
+ setLayoutOpen(false);
20
21
  }, children: "Tiled" }), _jsx(DropdownMenuCheckboxItem, { checked: !tiled, onCheckedChange: () => {
21
22
  onLayoutChange(false);
23
+ setLayoutOpen(false);
22
24
  }, children: "Floating" })] })) : null, onRestoreLayout ? (_jsx(DropdownMenuItem, { onSelect: onRestoreLayout, children: "Restore layout" })) : null, onArrangeDesktop ? (_jsx(DropdownMenuItem, { onSelect: onArrangeDesktop, children: "Arrange desktop" })) : null] })] }, `window:${focusedId ?? "shell"}`)) : null, focusedControls] }));
23
25
  }
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { AppBar } from "@fungi.computer/caps/blocks/app-bar";
3
- import { IconButton } from "@fungi.computer/caps/components/icon-button";
3
+ import { Button } from "@fungi.computer/caps/components/button";
4
4
  import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, } from "@fungi.computer/caps/components/dropdown-menu";
5
5
  import { useLayer } from "@fungi.computer/maosaico";
6
6
  import { Check, PanelsTopLeft } from "lucide-react";
@@ -8,5 +8,5 @@ import { Check, PanelsTopLeft } from "lucide-react";
8
8
  export function WorkbenchAppBar({ phone, ...props }) {
9
9
  const popover = useLayer("popover");
10
10
  const collapsed = phone && props.windows.length > 0;
11
- return (_jsxs(_Fragment, { children: [collapsed ? (_jsxs(DropdownMenu, { modal: false, children: [_jsx(DropdownMenuTrigger, { render: _jsx(IconButton, { size: "responsive", icon: props.windows.find((item) => item.active)?.icon ?? (_jsx(PanelsTopLeft, {})), "aria-label": "Switch open Apps" }), "aria-label": "Switch open Apps", title: "Switch open Apps" }), _jsxs(DropdownMenuContent, { container: popover, align: "start", children: [props.windows.map((item) => (_jsxs(DropdownMenuItem, { role: "menuitemradio", "aria-checked": item.active ?? false, "aria-current": item.active ? "page" : undefined, onSelect: item.onSelect, children: [_jsx("span", { "aria-hidden": "true", className: "grid size-7 shrink-0 place-items-center [&_svg]:size-5", children: item.icon }), _jsx("span", { className: "flex-1", children: item.label }), item.active ? _jsx(Check, { "aria-hidden": "true", size: 16 }) : null] }, item.id))), _jsx(DropdownMenuSeparator, {}), props.windows.map((item) => item.onClose ? (_jsxs(DropdownMenuItem, { onSelect: item.onClose, children: ["Close ", item.label] }, item.id)) : null)] })] })) : null, _jsx(AppBar, { ...props, windows: collapsed ? [] : props.windows })] }));
11
+ return (_jsxs(_Fragment, { children: [collapsed ? (_jsxs(DropdownMenu, { modal: false, children: [_jsxs(DropdownMenuTrigger, { render: _jsx(Button, { size: "menubar", variant: "ghost" }), "aria-label": "Switch open Apps", title: "Switch open Apps", children: [_jsx("span", { "aria-hidden": "true", className: "grid size-5 place-items-center [&_svg]:size-full", children: props.windows.find((item) => item.active)?.icon ?? (_jsx(PanelsTopLeft, {})) }), _jsx("span", { children: "Windows" })] }), _jsxs(DropdownMenuContent, { container: popover, align: "start", children: [props.windows.map((item) => (_jsxs(DropdownMenuItem, { role: "menuitemradio", "aria-checked": item.active ?? false, "aria-current": item.active ? "page" : undefined, onSelect: item.onSelect, children: [_jsx("span", { "aria-hidden": "true", className: "grid size-7 shrink-0 place-items-center [&_svg]:size-5", children: item.icon }), _jsx("span", { className: "flex-1", children: item.label }), item.active ? _jsx(Check, { "aria-hidden": "true", size: 16 }) : null] }, item.id))), _jsx(DropdownMenuSeparator, {}), props.windows.map((item) => item.onClose ? (_jsxs(DropdownMenuItem, { onSelect: item.onClose, children: ["Close ", item.label] }, item.id)) : null)] })] })) : null, _jsx(AppBar, { ...props, windows: collapsed ? [] : props.windows })] }));
12
12
  }
@@ -1,7 +1,10 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { GillParamPicker } from "./gill-param-picker.js";
3
- import { useEffect, useRef, useState, useSyncExternalStore } from "react";
4
- import { arrangeBento, useMaosaicoBento } from "@fungi.computer/maosaico";
3
+ import { useEffect, useRef, useState, useSyncExternalStore, } from "react";
4
+ import { createPortal } from "react-dom";
5
+ import { arrangeBento, useLayer, useMaosaicoBento, } from "@fungi.computer/maosaico";
6
+ import { EmptyState } from "@fungi.computer/caps/blocks/empty-state";
7
+ import { LoadingState } from "@fungi.computer/caps/blocks/loading-state";
5
8
  import { Button } from "@fungi.computer/caps/components/button";
6
9
  import { IconButton } from "@fungi.computer/caps/components/icon-button";
7
10
  import { GripVertical, Trash2 } from "lucide-react";
@@ -62,7 +65,46 @@ export function Desktop(props) {
62
65
  }, [owner, catalog]);
63
66
  return (_jsxs("div", { className: "tourtois-desktop", "data-desktop-bento": true, children: [error ? (_jsxs("p", { role: "alert", children: [error, " ", _jsx(Button, { variant: "ghost", size: "sm", onClick: () => {
64
67
  setRetry((value) => value + 1);
65
- }, children: "Retry" })] })) : null, !owner && !error ? _jsx("p", { role: "status", children: "Loading desktop\u2026" }) : null, owner ? _jsx(ArrangedDesktop, { ...props, owner: owner }) : null] }));
68
+ }, children: "Retry" })] })) : null, !owner && !error ? (_jsx(LoadingState, { message: "Loading your desktop\u2026" })) : null, owner ? _jsx(ArrangedDesktop, { ...props, owner: owner }) : null] }));
69
+ }
70
+ /** One plain line per refusal; the raw code goes to the console only. */
71
+ function refusalMessage(code) {
72
+ switch (code) {
73
+ case "conflict":
74
+ return "The desktop changed elsewhere. Try your change again.";
75
+ case "too_large":
76
+ return "This desktop arrangement is too large to save. Remove some widgets or Launcher preferences and try again.";
77
+ case "last_launcher":
78
+ return "Your desktop needs one Launcher.";
79
+ case "quota_exceeded":
80
+ return "The App's storage quota is full. Free some storage before saving again.";
81
+ default:
82
+ return "Couldn't save that change. Try again.";
83
+ }
84
+ }
85
+ /**
86
+ * The arrange controls live in the chrome layer so no window can cover them;
87
+ * the in-flow spacer keeps the widgets clear of the bar.
88
+ */
89
+ function ArrangeToolbar({ children }) {
90
+ const chrome = useLayer("chrome");
91
+ const [bar, setBar] = useState(null);
92
+ const [height, setHeight] = useState(0);
93
+ useEffect(() => {
94
+ if (!bar)
95
+ return;
96
+ const observer = new ResizeObserver(() => {
97
+ setHeight(bar.offsetHeight);
98
+ });
99
+ observer.observe(bar);
100
+ setHeight(bar.offsetHeight);
101
+ return () => {
102
+ observer.disconnect();
103
+ };
104
+ }, [bar]);
105
+ return (_jsxs(_Fragment, { children: [_jsx("div", { "aria-hidden": "true", style: { height, marginBottom: 16 } }), chrome
106
+ ? createPortal(_jsx("div", { ref: setBar, className: "tourtois-desktop-controls", role: "toolbar", "aria-label": "Arrange desktop", children: children }), chrome)
107
+ : null] }));
66
108
  }
67
109
  function ArrangedDesktop({ owner, ...props }) {
68
110
  const snapshot = useSyncExternalStore(owner.subscribe, owner.get, owner.get);
@@ -88,6 +130,11 @@ function ArrangedDesktop({ owner, ...props }) {
88
130
  };
89
131
  }, []);
90
132
  const columns = props.phone ? 1 : 4;
133
+ const isLauncher = (item) => catalog.some((gill) => gill.kind === "launcher" &&
134
+ gill.surfaceId === item.surfaceId &&
135
+ gill.gillId === item.gillId);
136
+ const onlyLauncher = visibleItems.filter(isLauncher).length <= 1;
137
+ const launcherGill = catalog.find((gill) => gill.kind === "launcher");
91
138
  useEffect(() => {
92
139
  setContentHeights((previous) => {
93
140
  const current = new Map([...previous].filter(([id]) => snapshot.layout.items.some((item) => item.id === id)));
@@ -114,15 +161,9 @@ function ArrangedDesktop({ owner, ...props }) {
114
161
  basedOn: scope === "team" ? snapshot.teamRevision : snapshot.memberRevision,
115
162
  ...input,
116
163
  });
117
- setError(result.kind === "accepted"
118
- ? null
119
- : result.code === "conflict"
120
- ? "The desktop changed elsewhere. Try your change again."
121
- : result.code === "too_large"
122
- ? "This desktop arrangement is too large to save. Remove some widgets or Launcher preferences and try again."
123
- : result.code === "quota_exceeded"
124
- ? "The App's storage quota is full. Free some storage before saving again."
125
- : `Desktop change refused: ${result.code}.`);
164
+ if (result.kind !== "accepted")
165
+ console.error("Desktop change refused", result.code);
166
+ setError(result.kind === "accepted" ? null : refusalMessage(result.code));
126
167
  return result.kind === "accepted";
127
168
  }
128
169
  catch (cause) {
@@ -201,7 +242,7 @@ function ArrangedDesktop({ owner, ...props }) {
201
242
  onSelect: () => undefined,
202
243
  })),
203
244
  ];
204
- return (_jsxs(_Fragment, { children: [snapshot.refreshFailure ? (_jsx("p", { role: "alert", children: snapshot.refreshFailure.message })) : null, editing ? (_jsxs("div", { className: "tourtois-desktop-controls", children: [_jsx(Button, { size: "sm", variant: "outline", onClick: () => {
245
+ return (_jsxs(_Fragment, { children: [snapshot.refreshFailure ? (_jsx("p", { role: "alert", children: snapshot.refreshFailure.message })) : null, editing ? (_jsxs(ArrangeToolbar, { children: [_jsx(Button, { size: "sm", variant: "outline", onClick: () => {
205
246
  onEditingChange(false);
206
247
  }, children: "Done arranging" }), _jsx("div", { className: "tourtois-desktop-add-gill", children: _jsxs(Select, { "aria-label": "Add widget", className: "select-sm", value: "", disabled: saving, onChange: (event) => {
207
248
  const gill = catalog[Number(event.currentTarget.value)];
@@ -216,7 +257,7 @@ function ArrangedDesktop({ owner, ...props }) {
216
257
  });
217
258
  }, children: [_jsx("option", { value: "", children: "Add widget\u2026" }), catalog.map((gill, index) => (_jsx("option", { value: index, children: gill.title }, `${gill.surfaceId}:${gill.gillId}`)))] }) }), _jsx(Button, { size: "sm", variant: "outline", disabled: saving, onClick: () => {
218
259
  void save("layout.reset", {});
219
- }, children: "Reset to Team default" }), snapshot.canWriteTeam ? (_jsx(Button, { size: "sm", variant: "outline", disabled: saving, onClick: () => {
260
+ }, children: "Reset layout" }), snapshot.canWriteTeam ? (_jsx(Button, { size: "sm", variant: "outline", disabled: saving, onClick: () => {
220
261
  void save("layout.set", { layout: snapshot.layout }, "team");
221
262
  }, children: "Save as Team default" })) : null] })) : null, configuration ? (_jsx(GillParamPicker, { gill: configuration.gill, initialParams: snapshot.layout.items.find((item) => item.id === configuration.itemId)?.params, computers: props.computersForGill?.(configuration.gill.surfaceId) ?? [], transport: props.transport, editing: configuration.itemId !== undefined, onClose: () => {
222
263
  setConfiguration(null);
@@ -240,16 +281,30 @@ function ArrangedDesktop({ owner, ...props }) {
240
281
  })
241
282
  : Promise.resolve(false);
242
283
  } }, configuration.itemId ??
243
- `${configuration.gill.surfaceId}:${configuration.gill.gillId}`)) : null, snapshot.notice ? _jsx("p", { role: "alert", children: snapshot.notice }) : null, error ? _jsx("p", { role: "alert", children: error }) : null, _jsx("div", { ref: stage, className: "tourtois-desktop-stage", style: { height }, "data-desktop-columns": columns, "data-preview": binding.preview, children: visibleItems.map((item) => {
284
+ `${configuration.gill.surfaceId}:${configuration.gill.gillId}`)) : null, snapshot.notice ? _jsx("p", { role: "alert", children: snapshot.notice }) : null, visibleItems.length === 0 ? (_jsx("div", { className: "tourtois-desktop-empty", children: _jsx(EmptyState, { variant: "panel", title: "Your desktop is empty", description: "Restore the Launcher to get back to your Apps.", actions: _jsx(Button, { disabled: saving, onClick: () => {
285
+ const size = launcherGill?.sizes.includes("M")
286
+ ? "M"
287
+ : launcherGill?.sizes[0];
288
+ if (launcherGill && size)
289
+ void save("layout.place", {
290
+ surfaceId: launcherGill.surfaceId,
291
+ gillId: launcherGill.gillId,
292
+ size,
293
+ });
294
+ else
295
+ void save("layout.reset", {});
296
+ }, children: "Restore Launcher" }) }) })) : null, error ? _jsx("p", { role: "alert", children: error }) : null, _jsx("div", { ref: stage, className: "tourtois-desktop-stage", style: { height }, "data-desktop-columns": columns, "data-preview": binding.preview, children: visibleItems.map((item) => {
244
297
  const frame = binding.frames.get(item.id);
245
298
  const gill = catalog.find((gill) => gill.surfaceId === item.surfaceId && gill.gillId === item.gillId);
246
299
  if (!frame || !gill)
247
300
  return null;
248
- const controls = editing ? (_jsxs("div", { className: "tourtois-gill-controls", children: [_jsx(IconButton, { size: "responsive", "aria-label": `Move ${gill.title}`, title: `Move ${gill.title}`, icon: _jsx(GripVertical, {}), ...binding.bind(item.id, "move") }), _jsx("div", { className: "join tourtois-gill-sizes", role: "group", "aria-label": `Size of ${gill.title}`, children: gill.sizes.map((size) => (_jsx(IconButton, { className: "join-item", size: "xs", icon: size, "aria-label": `Size ${size === "S" ? "small" : size === "M" ? "medium" : "large"}`, title: `${gill.title}: ${size}`, variant: size === item.size ? "secondary" : "ghost", "aria-pressed": size === item.size, disabled: saving, onClick: () => {
301
+ const controls = editing ? (_jsxs("div", { className: "tourtois-gill-controls", children: [_jsx(IconButton, { size: "responsive", "aria-label": `Move ${gill.title}`, title: `Move ${gill.title}`, icon: _jsx(GripVertical, {}), ...binding.bind(item.id, "move") }), _jsx("div", { className: "join tourtois-gill-sizes", role: "group", "aria-label": `Size of ${gill.title}`, children: gill.sizes.map((size) => (_jsx(IconButton, { className: "join-item", size: "sm", icon: size, "aria-label": `Size ${size === "S" ? "small" : size === "M" ? "medium" : "large"}`, title: `${gill.title}: ${size}`, variant: size === item.size ? "secondary" : "ghost", "aria-pressed": size === item.size, disabled: saving, onClick: () => {
249
302
  void save("layout.resize", { id: item.id, size });
250
- } }, size))) }), _jsx(IconButton, { size: "responsive", "aria-label": `Remove ${gill.title}`, title: `Remove ${gill.title}`, icon: _jsx(Trash2, {}), disabled: saving, onClick: () => {
251
- void save("layout.remove", { id: item.id });
252
- } })] })) : undefined;
303
+ } }, size))) }), _jsx("span", { title: onlyLauncher && isLauncher(item)
304
+ ? "Your desktop needs one Launcher"
305
+ : undefined, children: _jsx(IconButton, { size: "responsive", "aria-label": `Remove ${gill.title}`, title: `Remove ${gill.title}`, icon: _jsx(Trash2, {}), disabled: saving || (onlyLauncher && isLauncher(item)), onClick: () => {
306
+ void save("layout.remove", { id: item.id });
307
+ } }) })] })) : undefined;
253
308
  const onContentHeight = (height) => {
254
309
  setContentHeights((previous) => previous.get(item.id) === height
255
310
  ? previous
@@ -92,6 +92,7 @@ export declare const desktopArrangeResultSchema: z.ZodDiscriminatedUnion<[z.ZodO
92
92
  unknown_app: "unknown_app";
93
93
  size_not_allowed: "size_not_allowed";
94
94
  unknown_item: "unknown_item";
95
+ last_launcher: "last_launcher";
95
96
  too_many: "too_many";
96
97
  conflict: "conflict";
97
98
  too_large: "too_large";
@@ -78,6 +78,7 @@ export const desktopArrangeResultSchema = z.discriminatedUnion("kind", [
78
78
  "unknown_app",
79
79
  "size_not_allowed",
80
80
  "unknown_item",
81
+ "last_launcher",
81
82
  "too_many",
82
83
  "conflict",
83
84
  "too_large",
@@ -212,6 +213,13 @@ export function applyDesktopOps(current, ops, catalog, launchableAppIds, createI
212
213
  if (!item)
213
214
  return { kind: "rejected", code: "unknown_item" };
214
215
  if (op.kind === "remove") {
216
+ // The Launcher is the desktop's one route to every App.
217
+ const isLauncher = (entry) => catalog.some((gill) => gill.kind === "launcher" &&
218
+ gill.surfaceId === entry.surfaceId &&
219
+ gill.gillId === entry.gillId);
220
+ if (isLauncher(item) &&
221
+ !layout.items.some((entry) => entry.id !== item.id && isLauncher(entry)))
222
+ return { kind: "rejected", code: "last_launcher" };
215
223
  layout = compactDesktopLayout({
216
224
  ...layout,
217
225
  items: layout.items.filter((entry) => entry.id !== op.id),
@@ -18,6 +18,8 @@ export { type KeyAppOption, type KeyGrantOption, type KeyGrantPreviewProps, type
18
18
  */
19
19
  export type PlatformControls = Readonly<{
20
20
  openSettings: (location: SettingsLocation) => void;
21
+ /** Settings the host backs with real data; undefined means all of them. */
22
+ sections?: readonly SettingsLocation["category"][] | undefined;
21
23
  registerDesktopSettings: (handler: WorkbenchDesktopSettings) => Promise<WorkbenchDesktopRegistration>;
22
24
  /** Observe Team App changes these controls made, to refresh a directory. */
23
25
  subscribeChanges: (listener: () => void) => () => void;
package/dist/shell.css CHANGED
@@ -734,14 +734,35 @@
734
734
  overflow: auto;
735
735
  padding: 16px;
736
736
  }
737
+ /* The arrange toolbar sits in the chrome layer, directly under the menu bar,
738
+ so no window covers it. */
737
739
  .tourtois-desktop-controls {
740
+ position: absolute;
741
+ inset-inline: 0;
742
+ top: var(--spacing-3xl);
743
+ box-sizing: border-box;
738
744
  display: flex;
739
745
  flex-wrap: wrap;
740
746
  align-items: center;
741
747
  gap: 8px;
748
+ padding: 8px 16px;
749
+ background: var(--color-base-200);
750
+ box-shadow: inset 0 -1px 0 var(--color-base-300);
751
+ pointer-events: auto;
742
752
  }
743
- .tourtois-desktop-controls {
744
- margin-bottom: 16px;
753
+ @media (min-width: 541px) {
754
+ .tourtois-desktop-controls {
755
+ top: var(--spacing-2xl);
756
+ }
757
+ }
758
+ /* The recovery card sits mid-desktop, bounded like any panel EmptyState. */
759
+ .tourtois-desktop-empty {
760
+ display: grid;
761
+ place-items: center;
762
+ min-height: 60%;
763
+ }
764
+ .tourtois-desktop-empty > .empty-state {
765
+ width: min(100%, 32rem);
745
766
  }
746
767
  .tourtois-desktop-add-gill {
747
768
  width: 11rem;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fungi.computer/tourtois",
3
- "version": "0.9.2",
3
+ "version": "0.10.0",
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,18 +77,18 @@
77
77
  "LICENSE"
78
78
  ],
79
79
  "dependencies": {
80
- "@fungi.computer/agar": "0.7.2",
80
+ "@fungi.computer/agar": "0.8.0",
81
81
  "@fungi.computer/cairn": "0.1.0",
82
- "@fungi.computer/caps": "0.7.1",
82
+ "@fungi.computer/caps": "0.8.0",
83
83
  "@fungi.computer/ear-tag": "0.1.0",
84
84
  "@fungi.computer/gills": "0.2.2",
85
85
  "@fungi.computer/maosaico": "0.1.1",
86
- "@fungi.computer/parakeet": "0.9.0",
87
- "@fungi.computer/puffball": "0.5.2",
88
- "@fungi.computer/shiitake": "0.12.0",
86
+ "@fungi.computer/parakeet": "0.9.2",
87
+ "@fungi.computer/puffball": "0.5.4",
88
+ "@fungi.computer/shiitake": "0.12.2",
89
89
  "@fungi.computer/sigils": "0.3.0",
90
- "@fungi.computer/sprite": "0.2.0",
91
- "@fungi.computer/sprite-zdog": "0.3.0",
90
+ "@fungi.computer/sprite": "0.2.1",
91
+ "@fungi.computer/sprite-zdog": "0.3.1",
92
92
  "@fungi.computer/whistle": "0.3.0",
93
93
  "@tanstack/history": "1.162.1",
94
94
  "@tanstack/react-form": "1.33.2",
@@ -100,16 +100,16 @@
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.2.1"
103
+ "@fungi.computer/nacre": "0.2.3"
104
104
  },
105
105
  "peerDependencies": {
106
106
  "react": "^18.3.1 || ^19.2.0"
107
107
  },
108
108
  "devDependencies": {
109
- "@fungi.computer/oyster": "0.14.0",
109
+ "@fungi.computer/oyster": "0.15.0",
110
110
  "@cloudflare/workers-types": "5.20260828.1",
111
- "@fungi.computer/forage": "0.3.2",
112
- "@fungi.computer/mycelium": "0.3.5",
111
+ "@fungi.computer/forage": "0.3.4",
112
+ "@fungi.computer/mycelium": "0.3.7",
113
113
  "@ladle/react": "5.1.1",
114
114
  "@types/react": "18.3.3",
115
115
  "@vitejs/plugin-react": "6.1.1",