@fungi.computer/tourtois 0.9.3 → 0.11.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.
@@ -2,15 +2,19 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
2
2
  import { GillParamPicker } from "./gill-param-picker.js";
3
3
  import { useEffect, useRef, useState, useSyncExternalStore } from "react";
4
4
  import { arrangeBento, useMaosaicoBento } from "@fungi.computer/maosaico";
5
+ import { Alert } from "@fungi.computer/caps/components/alert";
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";
8
- import { Select } from "@fungi.computer/caps/components/select";
11
+ import { toast } from "@fungi.computer/caps/components/toaster";
9
12
  import { Badge } from "@fungi.computer/caps/components/badge";
10
13
  import { Sigil } from "@fungi.computer/sigils";
11
14
  import { DeclaredAppIcon } from "../app-icon.js";
12
15
  import { createDesktopLayoutClient, } from "../desktop-client.js";
13
16
  import { availableDesktopLayout, desktopPlacements, desktopBentoIntent, } from "../desktop-layout.js";
17
+ import { ArrangeToolbar } from "./arrange-toolbar.js";
14
18
  import { LauncherGill } from "./launcher-gill.js";
15
19
  import { RowGill } from "./row-gill.js";
16
20
  const gap = 16;
@@ -60,9 +64,24 @@ export function Desktop(props) {
60
64
  owner.invalidate();
61
65
  readCatalog.current = catalog;
62
66
  }, [owner, catalog]);
63
- 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
- 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] }));
67
+ return (_jsxs("div", { className: "tourtois-desktop", "data-desktop-bento": true, children: [error ? (_jsx(Alert, { tone: "error", description: error, action: _jsx(Button, { variant: "ghost", size: "sm", onClick: () => {
68
+ setRetry((value) => value + 1);
69
+ }, children: "Retry" }) })) : null, !owner && !error ? (_jsx(LoadingState, { message: "Loading your desktop\u2026" })) : null, owner ? _jsx(ArrangedDesktop, { ...props, owner: owner }) : null] }));
70
+ }
71
+ /** One plain line per refusal; the raw code goes to the console only. */
72
+ function refusalMessage(code) {
73
+ switch (code) {
74
+ case "conflict":
75
+ return "The desktop changed elsewhere. Try your change again.";
76
+ case "too_large":
77
+ return "This desktop arrangement is too large to save. Remove some widgets or Launcher preferences and try again.";
78
+ case "last_launcher":
79
+ return "Your desktop needs one Launcher.";
80
+ case "quota_exceeded":
81
+ return "The App's storage quota is full. Free some storage before saving again.";
82
+ default:
83
+ return "Couldn't save that change. Try again.";
84
+ }
66
85
  }
67
86
  function ArrangedDesktop({ owner, ...props }) {
68
87
  const snapshot = useSyncExternalStore(owner.subscribe, owner.get, owner.get);
@@ -72,6 +91,7 @@ function ArrangedDesktop({ owner, ...props }) {
72
91
  const [configuration, setConfiguration] = useState(null);
73
92
  const [error, setError] = useState(null);
74
93
  const [saving, setSaving] = useState(false);
94
+ const [saved, setSaved] = useState(false);
75
95
  const stage = useRef(null);
76
96
  const [width, setWidth] = useState(0);
77
97
  const [contentHeights, setContentHeights] = useState(new Map());
@@ -88,6 +108,11 @@ function ArrangedDesktop({ owner, ...props }) {
88
108
  };
89
109
  }, []);
90
110
  const columns = props.phone ? 1 : 4;
111
+ const isLauncher = (item) => catalog.some((gill) => gill.kind === "launcher" &&
112
+ gill.surfaceId === item.surfaceId &&
113
+ gill.gillId === item.gillId);
114
+ const onlyLauncher = visibleItems.filter(isLauncher).length <= 1;
115
+ const launcherGill = catalog.find((gill) => gill.kind === "launcher");
91
116
  useEffect(() => {
92
117
  setContentHeights((previous) => {
93
118
  const current = new Map([...previous].filter(([id]) => snapshot.layout.items.some((item) => item.id === id)));
@@ -114,15 +139,11 @@ function ArrangedDesktop({ owner, ...props }) {
114
139
  basedOn: scope === "team" ? snapshot.teamRevision : snapshot.memberRevision,
115
140
  ...input,
116
141
  });
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}.`);
142
+ if (result.kind !== "accepted")
143
+ console.error("Desktop change refused", result.code);
144
+ setError(result.kind === "accepted" ? null : refusalMessage(result.code));
145
+ if (result.kind === "accepted")
146
+ setSaved(true);
126
147
  return result.kind === "accepted";
127
148
  }
128
149
  catch (cause) {
@@ -201,24 +222,44 @@ function ArrangedDesktop({ owner, ...props }) {
201
222
  onSelect: () => undefined,
202
223
  })),
203
224
  ];
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: () => {
205
- onEditingChange(false);
206
- }, 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
- const gill = catalog[Number(event.currentTarget.value)];
208
- const size = gill?.sizes[0];
209
- if (gill && size && (gill.params?.length ?? 0) > 0)
210
- setConfiguration({ gill });
211
- else if (gill && size)
212
- void save("layout.place", {
213
- surfaceId: gill.surfaceId,
214
- gillId: gill.gillId,
215
- size,
216
- });
217
- }, 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
- void save("layout.reset", {});
219
- }, children: "Reset to Team default" }), snapshot.canWriteTeam ? (_jsx(Button, { size: "sm", variant: "outline", disabled: saving, onClick: () => {
220
- void save("layout.set", { layout: snapshot.layout }, "team");
221
- }, 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: () => {
225
+ const choices = catalog.map((gill) => {
226
+ const app = props.apps.find((entry) => entry.surfaceId === gill.surfaceId);
227
+ return {
228
+ gill,
229
+ placed: visibleItems.some((item) => item.surfaceId === gill.surfaceId && item.gillId === gill.gillId),
230
+ appName: app?.displayName ?? "Desktop",
231
+ icon: app ? (_jsx(DeclaredAppIcon, { icon: app.icon })) : (_jsx(Sigil, { name: "allApps" })),
232
+ };
233
+ });
234
+ const addWidget = (gill) => {
235
+ const size = gill.sizes[0];
236
+ if (!size)
237
+ return;
238
+ if ((gill.params?.length ?? 0) > 0)
239
+ setConfiguration({ gill });
240
+ else
241
+ void save("layout.place", {
242
+ surfaceId: gill.surfaceId,
243
+ gillId: gill.gillId,
244
+ size,
245
+ });
246
+ };
247
+ const finishArranging = () => {
248
+ if (saved)
249
+ toast("Desktop saved", {
250
+ id: "desktop-saved",
251
+ toasterId: "workbench-notices",
252
+ });
253
+ setSaved(false);
254
+ onEditingChange(false);
255
+ };
256
+ const longPress = useRef(undefined);
257
+ return (_jsxs(_Fragment, { children: [snapshot.refreshFailure ? (_jsx(Alert, { tone: "warning", description: snapshot.refreshFailure.message })) : null, editing ? (_jsx(ArrangeToolbar, { phone: props.phone, status: saving ? "saving" : saved ? "saved" : "idle", error: error, canWriteTeam: snapshot.canWriteTeam, choices: choices, saving: saving, onChoose: addWidget, onReset: async () => {
258
+ if (!(await save("layout.reset", {})))
259
+ throw new Error("The layout was not reset");
260
+ }, onSaveTeam: () => {
261
+ void save("layout.set", { layout: snapshot.layout }, "team");
262
+ }, onDone: finishArranging })) : 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);
223
264
  }, onSave: (params) => {
224
265
  if (configuration.itemId !== undefined)
@@ -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(Alert, { tone: "info", description: 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 && !editing ? _jsx(Alert, { tone: "error", description: error }) : null, _jsx("div", { ref: stage, className: "tourtois-desktop-stage", style: { height }, "data-desktop-columns": columns, "data-preview": binding.preview, "data-arranging": editing ? "" : undefined, 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-arrange-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
@@ -257,23 +312,40 @@ function ArrangedDesktop({ owner, ...props }) {
257
312
  };
258
313
  const app = props.apps.find((app) => app.surfaceId === item.surfaceId);
259
314
  const declaration = app?.gills.find((declaration) => declaration.id === item.gillId);
260
- return (_jsx("div", { "data-desktop-gill": item.id, className: "tourtois-desktop-tile", style: {
315
+ return (_jsxs("div", { "data-desktop-gill": item.id, className: "tourtois-desktop-tile", style: {
261
316
  left: frame.x,
262
317
  top: frame.y,
263
318
  width: frame.width,
264
319
  height: frame.height,
265
- }, 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) => {
266
- void save("layout.launcher", { appId: id, state });
267
- }, editHandle: controls, onContentHeight: onContentHeight })) : declaration && app ? (_jsx(RowGill, { surfaceId: item.surfaceId, appHeader: {
268
- name: app.displayName ?? "App",
269
- icon: _jsx(DeclaredAppIcon, { icon: app.icon }),
270
- }, declaration: declaration, params: item.params, size: item.size, paused: props.paused, transport: props.transport, onOpen: (target) => {
271
- props.onOpen({
272
- appId: app.appId,
273
- intent: { kind: "navigate", params: target.params },
274
- });
275
- }, onConfigure: () => {
276
- setConfiguration({ gill, itemId: item.id });
277
- }, launch: props.launcherItems.find((app) => app.id === `app:${item.surfaceId}`), editHandle: controls, onContentHeight: onContentHeight }, JSON.stringify(item.params ?? {}))) : null }, item.id));
320
+ }, onPointerDown: (event) => {
321
+ // Touch has no menu to reach Arrange from: a long press enters it.
322
+ if (editing || event.pointerType !== "touch")
323
+ return;
324
+ window.clearTimeout(longPress.current);
325
+ longPress.current = window.setTimeout(() => {
326
+ onEditingChange(true);
327
+ }, 600);
328
+ }, onPointerUp: () => {
329
+ window.clearTimeout(longPress.current);
330
+ }, onPointerMove: () => {
331
+ window.clearTimeout(longPress.current);
332
+ }, onPointerCancel: () => {
333
+ window.clearTimeout(longPress.current);
334
+ }, children: [_jsx("div", { className: "tourtois-desktop-tile-body", ref: (node) => {
335
+ if (node)
336
+ 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
+ void save("layout.launcher", { appId: id, state });
339
+ }, editHandle: editing ? _jsx("span", { "aria-hidden": "true" }) : undefined, onContentHeight: onContentHeight })) : declaration && app ? (_jsx(RowGill, { surfaceId: item.surfaceId, appHeader: {
340
+ name: app.displayName ?? "App",
341
+ icon: _jsx(DeclaredAppIcon, { icon: app.icon }),
342
+ }, declaration: declaration, params: item.params, size: item.size, paused: props.paused, transport: props.transport, onOpen: (target) => {
343
+ props.onOpen({
344
+ appId: app.appId,
345
+ intent: { kind: "navigate", params: target.params },
346
+ });
347
+ }, onConfigure: () => {
348
+ setConfiguration({ gill, itemId: item.id });
349
+ }, launch: props.launcherItems.find((app) => app.id === `app:${item.surfaceId}`), editHandle: editing ? _jsx("span", { "aria-hidden": "true" }) : undefined, onContentHeight: onContentHeight }, JSON.stringify(item.params ?? {}))) : null }), controls] }, item.id));
278
350
  }) })] }));
279
351
  }
@@ -0,0 +1,19 @@
1
+ import { type WidgetChoice } from "./widget-picker.js";
2
+ import type { DesktopGill } from "../desktop-layout.js";
3
+ export type ArrangeStatus = "idle" | "saving" | "saved";
4
+ /**
5
+ * Arrange's floating controls. They live in the chrome layer, take no flow
6
+ * space, and stay above every window.
7
+ */
8
+ export declare function ArrangeToolbar({ phone, status, error, canWriteTeam, choices, saving, onChoose, onReset, onSaveTeam, onDone, }: {
9
+ phone: boolean;
10
+ status: ArrangeStatus;
11
+ error: string | null;
12
+ canWriteTeam: boolean;
13
+ choices: readonly WidgetChoice[];
14
+ saving: boolean;
15
+ onChoose: (gill: DesktopGill) => void;
16
+ onReset: () => Promise<void>;
17
+ onSaveTeam: () => void;
18
+ onDone: () => void;
19
+ }): import("react").ReactPortal | null;
@@ -0,0 +1,63 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useRef, useState } from "react";
3
+ import { createPortal } from "react-dom";
4
+ import { MoreHorizontal, Plus } from "lucide-react";
5
+ import { Button } from "@fungi.computer/caps/components/button";
6
+ import { ConfirmAction } from "@fungi.computer/caps/components/confirm-action";
7
+ import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, } from "@fungi.computer/caps/components/dialog";
8
+ import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "@fungi.computer/caps/components/dropdown-menu";
9
+ import { IconButton } from "@fungi.computer/caps/components/icon-button";
10
+ import { PopoverAnchor } from "@fungi.computer/caps/components/popover";
11
+ import { Status } from "@fungi.computer/caps/components/status";
12
+ import { Surface } from "@fungi.computer/caps/components/surface";
13
+ import { useLayer } from "@fungi.computer/maosaico";
14
+ import { WidgetPicker } from "./widget-picker.js";
15
+ /** Return focus to where Arrange was invoked, or the Layout menu. */
16
+ function restoreFocus(origin) {
17
+ if (origin instanceof HTMLElement && origin.isConnected) {
18
+ origin.focus();
19
+ return;
20
+ }
21
+ const layout = document.querySelector("[data-layout-menu]");
22
+ layout?.focus();
23
+ }
24
+ /**
25
+ * Arrange's floating controls. They live in the chrome layer, take no flow
26
+ * space, and stay above every window.
27
+ */
28
+ export function ArrangeToolbar({ phone, status, error, canWriteTeam, choices, saving, onChoose, onReset, onSaveTeam, onDone, }) {
29
+ const chrome = useLayer("chrome");
30
+ const [pickerOpen, setPickerOpen] = useState(false);
31
+ const [resetOpen, setResetOpen] = useState(false);
32
+ const origin = useRef(document.activeElement);
33
+ const done = useRef(onDone);
34
+ done.current = onDone;
35
+ const picker = useRef(pickerOpen);
36
+ picker.current = pickerOpen;
37
+ useEffect(() => {
38
+ const back = origin.current;
39
+ const onKey = (event) => {
40
+ if (event.key !== "Escape" || event.defaultPrevented)
41
+ return;
42
+ if (picker.current)
43
+ setPickerOpen(false);
44
+ else
45
+ done.current();
46
+ };
47
+ document.addEventListener("keydown", onKey);
48
+ return () => {
49
+ document.removeEventListener("keydown", onKey);
50
+ restoreFocus(back);
51
+ };
52
+ }, []);
53
+ if (!chrome)
54
+ return null;
55
+ return createPortal(_jsxs(Surface, { className: "tourtois-arrange", role: "toolbar", "aria-label": "Arranging desktop", "data-phone": phone ? "" : undefined, children: [_jsxs(PopoverAnchor, { className: "tourtois-arrange-add", children: [pickerOpen ? (_jsx(WidgetPicker, { choices: choices, disabled: saving, onChoose: onChoose })) : null, _jsxs(Button, { size: "sm", variant: "outline", "aria-expanded": pickerOpen, "aria-label": "Add widget", onClick: () => {
56
+ setPickerOpen(!pickerOpen);
57
+ }, children: [_jsx(Plus, { "aria-hidden": "true", size: 16 }), phone ? "Add" : "Add widget"] })] }), _jsxs(DropdownMenu, { modal: false, children: [_jsx(DropdownMenuTrigger, { render: _jsx(IconButton, { size: "sm", variant: "ghost", icon: _jsx(MoreHorizontal, {}), "aria-label": "More layout actions", title: "More layout actions" }) }), _jsxs(DropdownMenuContent, { container: chrome, align: "end", side: "top", children: [_jsx(DropdownMenuItem, { onSelect: () => {
58
+ setResetOpen(true);
59
+ }, children: "Reset layout\u2026" }), canWriteTeam ? (_jsx(DropdownMenuItem, { onSelect: onSaveTeam, children: "Save as Team default" })) : null] })] }), _jsx("span", { className: "tourtois-arrange-state", role: "status", "data-empty": error || status !== "idle" ? undefined : "", children: error ? (_jsx(Status, { glyph: "cross", tone: "error", label: error })) : status === "saving" ? (_jsx(Status, { glyph: "arc", tone: "info", label: "Saving\u2026" })) : status === "saved" ? (_jsx(Status, { glyph: "check", tone: "success", label: "Saved" })) : null }), _jsx(Button, { size: "sm", variant: "primary", "aria-label": "Done arranging", onClick: onDone, children: "Done" }), _jsx(Dialog, { open: resetOpen, onOpenChange: setResetOpen, children: _jsxs(DialogContent, { children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: "Reset layout" }), _jsx(DialogDescription, { children: "Your widgets go back to the default desktop." })] }), _jsx(ConfirmAction, { mode: "hold", label: "Reset layout", confirmLabel: "Hold to reset the layout", onConfirm: async () => {
60
+ await onReset();
61
+ setResetOpen(false);
62
+ } })] }) })] }), chrome);
63
+ }
@@ -0,0 +1,145 @@
1
+ /* Arrange mode edits in place: nothing here changes a tile's frame or the
2
+ flow around it. Visuals come from Caps; this file only places things. */
3
+ .tourtois-desktop-tile-body {
4
+ height: 100%;
5
+ min-width: 0;
6
+ }
7
+
8
+ /* The tile's own dashed ring, at the card's radius, drawn over its edge. */
9
+ .tourtois-desktop-stage[data-arranging] .tourtois-desktop-tile::after {
10
+ content: "";
11
+ position: absolute;
12
+ inset: 0;
13
+ border: 1px dashed var(--stipe-linework);
14
+ border-radius: var(--radius-box);
15
+ pointer-events: none;
16
+ }
17
+ /* Room for the overlay beside the title; only truncation changes. */
18
+ .tourtois-desktop-stage[data-arranging] .tourtois-gill-frame .caps-card-title {
19
+ padding-inline-end: 9rem;
20
+ }
21
+
22
+ .tourtois-arrange-controls {
23
+ position: absolute;
24
+ inset-block-start: var(--spacing-lg);
25
+ inset-inline-end: var(--spacing-md);
26
+ display: flex;
27
+ align-items: center;
28
+ gap: var(--spacing-2xs);
29
+ }
30
+
31
+ .tourtois-arrange {
32
+ position: absolute;
33
+ inset-inline: 0;
34
+ inset-block-end: calc(env(safe-area-inset-bottom, 0px) + 16px);
35
+ inline-size: max-content;
36
+ max-inline-size: calc(100vw - 32px);
37
+ margin-inline: auto;
38
+ box-sizing: border-box;
39
+ display: flex;
40
+ align-items: center;
41
+ gap: var(--spacing-sm);
42
+ padding: var(--spacing-xs) var(--spacing-sm);
43
+ pointer-events: auto;
44
+ }
45
+ .tourtois-arrange-add {
46
+ display: inline-flex;
47
+ }
48
+ .tourtois-arrange-state {
49
+ display: inline-flex;
50
+ align-items: center;
51
+ margin-inline-start: auto;
52
+ font-size: var(--text-xs);
53
+ }
54
+ .tourtois-arrange-state[data-empty] {
55
+ display: none;
56
+ }
57
+ /* Scroll room so the bar never hides the last widget; frames are untouched. */
58
+ .tourtois-desktop-stage[data-arranging] {
59
+ margin-block-end: 6rem;
60
+ }
61
+
62
+ .tourtois-widget-picker {
63
+ inline-size: min(22rem, calc(100vw - 32px));
64
+ inset-inline: 0 auto;
65
+ gap: var(--spacing-xs);
66
+ }
67
+ .tourtois-widget-list {
68
+ display: flex;
69
+ flex-direction: column;
70
+ min-block-size: 0;
71
+ }
72
+ .tourtois-widget-picker .caps-popover-option {
73
+ align-items: center;
74
+ }
75
+ .tourtois-widget-icon {
76
+ display: inline-flex;
77
+ inline-size: 1.5rem;
78
+ block-size: 1.5rem;
79
+ flex: none;
80
+ }
81
+ .tourtois-widget-icon > * {
82
+ inline-size: 100%;
83
+ block-size: 100%;
84
+ }
85
+ .tourtois-widget-text {
86
+ display: grid;
87
+ min-inline-size: 0;
88
+ flex: 1;
89
+ }
90
+ .tourtois-widget-text small,
91
+ .tourtois-widget-picker small {
92
+ color: var(--stipe-fg-muted);
93
+ font-size: var(--text-xs);
94
+ }
95
+ .tourtois-widget-none {
96
+ padding: var(--spacing-sm);
97
+ color: var(--stipe-fg-muted);
98
+ font-size: var(--text-sm);
99
+ }
100
+
101
+ /* Phone: a full-width bottom bar, with the picker rising from it. */
102
+ @media (max-width: 640px) {
103
+ .tourtois-arrange {
104
+ inset-block-end: 0;
105
+ inline-size: auto;
106
+ max-inline-size: none;
107
+ margin-inline: 0;
108
+ padding-block-end: calc(
109
+ env(safe-area-inset-bottom, 0px) + var(--spacing-xs)
110
+ );
111
+ }
112
+ .tourtois-arrange-add {
113
+ position: static;
114
+ }
115
+ .tourtois-widget-picker {
116
+ inline-size: auto;
117
+ inset-inline: 0;
118
+ max-block-size: 60vh;
119
+ inset-block-end: 100%;
120
+ margin-block-end: var(--spacing-xs);
121
+ }
122
+ /* Five touch targets and the title share one row: keep them tight. */
123
+ .tourtois-arrange-controls {
124
+ inset-block-start: var(--spacing-xl);
125
+ }
126
+ .tourtois-desktop-stage[data-arranging]
127
+ .tourtois-gill-frame
128
+ .caps-card-title {
129
+ padding-inline-end: 15rem;
130
+ }
131
+ }
132
+
133
+ .tourtois-widget-picker .caps-popover-option > small:last-child {
134
+ opacity: 0.7;
135
+ white-space: nowrap;
136
+ }
137
+
138
+ /* Each button's touch hit area reaches 7px past its face, so neighbours
139
+ need 14px between faces or one steals the other's edge. */
140
+ @media (max-width: 640px), (any-pointer: coarse) {
141
+ .tourtois-arrange-controls,
142
+ .tourtois-arrange-controls .tourtois-gill-sizes {
143
+ gap: var(--spacing-lg);
144
+ }
145
+ }
@@ -6,10 +6,15 @@ import { DataList, DataRow } from "@fungi.computer/caps/components/data-list";
6
6
  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
+ import { ExternalLink } from "lucide-react";
9
10
  import { GillFrame } from "./gill-frame.js";
11
+ import { FirstRunWelcome, useWelcome } from "./welcome.js";
12
+ import { LoadingState } from "@fungi.computer/caps/blocks/loading-state";
13
+ const installDocs = "https://docs.fungi.computer/oyster-quickstart/";
10
14
  /** Trusted shell Gill. Defaults to the same complete launchable set/order as the AppBar. */
11
15
  export function LauncherGill({ items, size = "M", onAllApps, loading = false, unavailable = false, onRetry, warnings = [], preferences, onPreference, editHandle, onContentHeight, }) {
12
16
  const [editing, setEditing] = useState(false);
17
+ const welcome = useWelcome();
13
18
  const stateFor = (id) => preferences.hidden.includes(id)
14
19
  ? "Hidden"
15
20
  : preferences.pinned.includes(id)
@@ -29,7 +34,7 @@ export function LauncherGill({ items, size = "M", onAllApps, loading = false, un
29
34
  const ready = !loading && !unavailable;
30
35
  return (_jsxs(GillFrame, { title: "Launcher", size: size, onContentHeight: onContentHeight, editHandle: editHandle ?? (_jsx(Button, { size: "xs", variant: "outline", "aria-expanded": editing, onClick: () => {
31
36
  setEditing(!editing);
32
- }, children: editing ? "Done" : "Edit launcher" })), children: [loading ? _jsx("p", { role: "status", children: "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: [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": "Team Apps", items: [
37
+ }, 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: [
33
38
  ...tiles,
34
39
  ...warnings,
35
40
  {
@@ -38,7 +43,9 @@ export function LauncherGill({ items, size = "M", onAllApps, loading = false, un
38
43
  icon: _jsx(Sigil, { name: "allApps" }),
39
44
  onSelect: onAllApps,
40
45
  },
41
- ], size: "lg" }), 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) => {
46
+ ], size: "lg" }), _jsx("div", { className: "tourtois-launcher-more", children: _jsxs(Button, { size: "sm", variant: "ghost", onClick: () => {
47
+ window.open(installDocs, "_blank", "noopener,noreferrer");
48
+ }, 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) => {
42
49
  const value = event.currentTarget.value;
43
50
  if (value !== "Pinned" &&
44
51
  value !== "Shown" &&
@@ -125,7 +125,11 @@ export function RowGill({ surfaceId, appHeader, declaration, params, size, pause
125
125
  ? `${response.title} isn't available on this preview. Open ${launch.label}.`
126
126
  : response.error }), recoveryParam && onConfigure ? (_jsxs(Button, { size: "sm", variant: "primary", onClick: onConfigure, children: ["Choose ", recoveryParam.label] })) : null, opensApp && launch ? (_jsxs(Button, { size: "sm", variant: "primary", onClick: () => {
127
127
  launch.onSelect();
128
- }, children: ["Open ", launch.label] })) : null] })) : null, response?.state === "empty" ? (_jsx(EmptyState, { variant: "hint", title: `No ${response.title} items yet`, description: `${response.title} items appear here when available.` })) : null, response?.state === "full" ? (_jsx(DataList, { "aria-label": `${response.title} rows`, density: "compact", children: response.rows.map((row) => (_jsx(DataRow, { children: row.open ? (_jsx(ActionRow, { density: "compact", label: row.title, description: detail(row), trailing: rowStatus(row), "aria-label": `Open: ${row.title}`, onClick: () => {
128
+ }, children: ["Open ", launch.label] })) : null] })) : null, response?.state === "empty" ? (_jsx(EmptyState, { variant: "quiet", title: response.emptyText ?? "Nothing here yet.", description: null, actions: launch &&
129
+ (response.action?.kind === "open" ||
130
+ response.emptyText === undefined) ? (_jsxs(Button, { size: "sm", variant: "outline", onClick: () => {
131
+ launch.onSelect();
132
+ }, children: ["Open ", launch.label] })) : null })) : null, response?.state === "full" ? (_jsx(DataList, { "aria-label": `${response.title} rows`, density: "compact", children: response.rows.map((row) => (_jsx(DataRow, { children: row.open ? (_jsx(ActionRow, { density: "compact", label: row.title, description: detail(row), trailing: rowStatus(row), "aria-label": `Open: ${row.title}`, onClick: () => {
129
133
  if (row.open)
130
134
  onOpen(row.open);
131
135
  } })) : (_jsxs(_Fragment, { children: [_jsxs("div", { className: "tourtois-gill-text-row", children: [_jsx("span", { children: row.title }), row.detail ? _jsx("small", { children: detail(row) }) : null] }), rowStatus(row)] })) }, row.id))) })) : null, pages.length > 1 ? (_jsx(Button, { size: "sm", variant: "ghost", disabled: paused, onClick: () => {
@@ -0,0 +1,70 @@
1
+ /* The first-run welcome: one compact card across the Launcher. */
2
+ .tourtois-welcome {
3
+ display: flex;
4
+ align-items: center;
5
+ gap: var(--spacing-lg);
6
+ padding: var(--spacing-md) var(--spacing-lg);
7
+ margin-block-end: var(--spacing-lg);
8
+ /* The App tiles sit 9px inside the Launcher; the card shares their left edge. */
9
+ margin-inline: calc(var(--spacing-sm) + 1px);
10
+ border: var(--border) solid
11
+ color-mix(in oklab, var(--color-base-content) 12%, transparent);
12
+ border-radius: var(--radius-box);
13
+ background: color-mix(in oklab, var(--color-base-100) 70%, transparent);
14
+ }
15
+ .tourtois-welcome-mascot {
16
+ display: block;
17
+ flex: none;
18
+ inline-size: 3rem;
19
+ block-size: 3rem;
20
+ }
21
+ .tourtois-welcome-text {
22
+ flex: 1;
23
+ min-inline-size: 0;
24
+ }
25
+ .tourtois-welcome-text h3 {
26
+ margin: 0;
27
+ font-size: var(--text-base);
28
+ font-weight: 600;
29
+ line-height: 1.3;
30
+ }
31
+ .tourtois-welcome-text p {
32
+ margin: 0;
33
+ color: var(--stipe-fg-muted);
34
+ font-size: var(--text-sm);
35
+ line-height: 1.4;
36
+ }
37
+ .tourtois-welcome-text .tourtois-welcome-hint {
38
+ margin-block-start: var(--spacing-2xs);
39
+ font-size: var(--text-xs);
40
+ }
41
+ .tourtois-welcome-actions {
42
+ display: flex;
43
+ flex: none;
44
+ align-items: center;
45
+ gap: var(--spacing-sm);
46
+ }
47
+ @media (max-width: 640px) {
48
+ .tourtois-welcome {
49
+ flex-wrap: wrap;
50
+ gap: var(--spacing-md);
51
+ }
52
+ .tourtois-welcome-text {
53
+ flex-basis: calc(100% - 4rem);
54
+ }
55
+ .tourtois-welcome-actions {
56
+ flex: 1 1 100%;
57
+ }
58
+ .tourtois-welcome-actions > * {
59
+ flex: 1;
60
+ }
61
+ }
62
+
63
+ /* The install guide is a quiet footer row under the grid, not an App tile. */
64
+ .tourtois-launcher-more {
65
+ display: flex;
66
+ justify-content: flex-end;
67
+ /* The ghost button's own padding would pull its text off the grid's edge. */
68
+ margin-inline-end: calc(-1 * (var(--spacing-md) + 1px));
69
+ margin-block-start: var(--spacing-sm);
70
+ }
@@ -0,0 +1,20 @@
1
+ import { type ReactNode } from "react";
2
+ import type { AppStorage } from "@fungi.computer/agar/storage";
3
+ import type { AppBarItem } from "@fungi.computer/caps/blocks/app-bar";
4
+ export type WelcomeState = Readonly<{
5
+ /** True only once storage has answered that this member has not dismissed it. */
6
+ visible: boolean;
7
+ dismiss: () => void;
8
+ }>;
9
+ /** The per-member first-run welcome, remembered in the member's own storage layer. */
10
+ export declare function WelcomeProvider({ teamId, storage, children, }: {
11
+ teamId: string;
12
+ storage: AppStorage;
13
+ children: ReactNode;
14
+ }): import("react/jsx-runtime").JSX.Element;
15
+ export declare const useWelcome: () => WelcomeState;
16
+ /** Says what this place is and points at the one thing to do next. */
17
+ export declare function FirstRunWelcome({ items, onDismiss, }: {
18
+ items: readonly AppBarItem[];
19
+ onDismiss: () => void;
20
+ }): import("react/jsx-runtime").JSX.Element | null;