@fungi.computer/tourtois 0.10.0 → 0.12.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.
@@ -1,19 +1,20 @@
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 { createPortal } from "react-dom";
5
- import { arrangeBento, useLayer, useMaosaicoBento, } from "@fungi.computer/maosaico";
3
+ import { useEffect, useRef, useState, useSyncExternalStore } from "react";
4
+ import { arrangeBento, useMaosaicoBento } from "@fungi.computer/maosaico";
5
+ import { Alert } from "@fungi.computer/caps/components/alert";
6
6
  import { EmptyState } from "@fungi.computer/caps/blocks/empty-state";
7
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 { Select } from "@fungi.computer/caps/components/select";
11
+ import { toast } from "@fungi.computer/caps/components/toaster";
12
12
  import { Badge } from "@fungi.computer/caps/components/badge";
13
13
  import { Sigil } from "@fungi.computer/sigils";
14
14
  import { DeclaredAppIcon } from "../app-icon.js";
15
15
  import { createDesktopLayoutClient, } from "../desktop-client.js";
16
16
  import { availableDesktopLayout, desktopPlacements, desktopBentoIntent, } from "../desktop-layout.js";
17
+ import { ArrangeToolbar } from "./arrange-toolbar.js";
17
18
  import { LauncherGill } from "./launcher-gill.js";
18
19
  import { RowGill } from "./row-gill.js";
19
20
  const gap = 16;
@@ -63,9 +64,9 @@ export function Desktop(props) {
63
64
  owner.invalidate();
64
65
  readCatalog.current = catalog;
65
66
  }, [owner, catalog]);
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: () => {
67
- setRetry((value) => value + 1);
68
- }, children: "Retry" })] })) : null, !owner && !error ? (_jsx(LoadingState, { message: "Loading your 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] }));
69
70
  }
70
71
  /** One plain line per refusal; the raw code goes to the console only. */
71
72
  function refusalMessage(code) {
@@ -82,30 +83,6 @@ function refusalMessage(code) {
82
83
  return "Couldn't save that change. Try again.";
83
84
  }
84
85
  }
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] }));
108
- }
109
86
  function ArrangedDesktop({ owner, ...props }) {
110
87
  const snapshot = useSyncExternalStore(owner.subscribe, owner.get, owner.get);
111
88
  const catalog = snapshot.widgets;
@@ -114,6 +91,7 @@ function ArrangedDesktop({ owner, ...props }) {
114
91
  const [configuration, setConfiguration] = useState(null);
115
92
  const [error, setError] = useState(null);
116
93
  const [saving, setSaving] = useState(false);
94
+ const [saved, setSaved] = useState(false);
117
95
  const stage = useRef(null);
118
96
  const [width, setWidth] = useState(0);
119
97
  const [contentHeights, setContentHeights] = useState(new Map());
@@ -164,6 +142,8 @@ function ArrangedDesktop({ owner, ...props }) {
164
142
  if (result.kind !== "accepted")
165
143
  console.error("Desktop change refused", result.code);
166
144
  setError(result.kind === "accepted" ? null : refusalMessage(result.code));
145
+ if (result.kind === "accepted")
146
+ setSaved(true);
167
147
  return result.kind === "accepted";
168
148
  }
169
149
  catch (cause) {
@@ -242,24 +222,44 @@ function ArrangedDesktop({ owner, ...props }) {
242
222
  onSelect: () => undefined,
243
223
  })),
244
224
  ];
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: () => {
246
- onEditingChange(false);
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) => {
248
- const gill = catalog[Number(event.currentTarget.value)];
249
- const size = gill?.sizes[0];
250
- if (gill && size && (gill.params?.length ?? 0) > 0)
251
- setConfiguration({ gill });
252
- else if (gill && size)
253
- void save("layout.place", {
254
- surfaceId: gill.surfaceId,
255
- gillId: gill.gillId,
256
- size,
257
- });
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: () => {
259
- void save("layout.reset", {});
260
- }, children: "Reset layout" }), snapshot.canWriteTeam ? (_jsx(Button, { size: "sm", variant: "outline", disabled: saving, onClick: () => {
261
- void save("layout.set", { layout: snapshot.layout }, "team");
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: () => {
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: () => {
263
263
  setConfiguration(null);
264
264
  }, onSave: (params) => {
265
265
  if (configuration.itemId !== undefined)
@@ -281,7 +281,7 @@ function ArrangedDesktop({ owner, ...props }) {
281
281
  })
282
282
  : Promise.resolve(false);
283
283
  } }, configuration.itemId ??
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: () => {
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
285
  const size = launcherGill?.sizes.includes("M")
286
286
  ? "M"
287
287
  : launcherGill?.sizes[0];
@@ -293,12 +293,12 @@ function ArrangedDesktop({ owner, ...props }) {
293
293
  });
294
294
  else
295
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) => {
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) => {
297
297
  const frame = binding.frames.get(item.id);
298
298
  const gill = catalog.find((gill) => gill.surfaceId === item.surfaceId && gill.gillId === item.gillId);
299
299
  if (!frame || !gill)
300
300
  return null;
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: () => {
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: () => {
302
302
  void save("layout.resize", { id: item.id, size });
303
303
  } }, size))) }), _jsx("span", { title: onlyLauncher && isLauncher(item)
304
304
  ? "Your desktop needs one Launcher"
@@ -312,23 +312,40 @@ function ArrangedDesktop({ owner, ...props }) {
312
312
  };
313
313
  const app = props.apps.find((app) => app.surfaceId === item.surfaceId);
314
314
  const declaration = app?.gills.find((declaration) => declaration.id === item.gillId);
315
- 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: {
316
316
  left: frame.x,
317
317
  top: frame.y,
318
318
  width: frame.width,
319
319
  height: frame.height,
320
- }, 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) => {
321
- void save("layout.launcher", { appId: id, state });
322
- }, editHandle: controls, onContentHeight: onContentHeight })) : declaration && app ? (_jsx(RowGill, { surfaceId: item.surfaceId, appHeader: {
323
- name: app.displayName ?? "App",
324
- icon: _jsx(DeclaredAppIcon, { icon: app.icon }),
325
- }, declaration: declaration, params: item.params, size: item.size, paused: props.paused, transport: props.transport, onOpen: (target) => {
326
- props.onOpen({
327
- appId: app.appId,
328
- intent: { kind: "navigate", params: target.params },
329
- });
330
- }, onConfigure: () => {
331
- setConfiguration({ gill, itemId: item.id });
332
- }, 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, 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
+ 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));
333
350
  }) })] }));
334
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
+ }
@@ -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;
@@ -6,10 +6,19 @@ 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";
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";
9
14
  import { GillFrame } from "./gill-frame.js";
15
+ import { FirstRunWelcome, useWelcome } from "./welcome.js";
16
+ import { LoadingState } from "@fungi.computer/caps/blocks/loading-state";
17
+ const installDocs = "https://docs.fungi.computer/oyster-quickstart/";
10
18
  /** Trusted shell Gill. Defaults to the same complete launchable set/order as the AppBar. */
11
- 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, }) {
12
20
  const [editing, setEditing] = useState(false);
21
+ const welcome = useWelcome();
13
22
  const stateFor = (id) => preferences.hidden.includes(id)
14
23
  ? "Hidden"
15
24
  : preferences.pinned.includes(id)
@@ -20,17 +29,41 @@ export function LauncherGill({ items, size = "M", onAllApps, loading = false, un
20
29
  ...shown.filter((item) => stateFor(item.id) === "Pinned"),
21
30
  ...shown.filter((item) => stateFor(item.id) !== "Pinned"),
22
31
  ];
23
- const tiles = ordered.map((item) => ({
24
- id: item.id,
25
- label: item.label,
26
- icon: item.icon,
27
- 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,
28
60
  }));
29
61
  const ready = !loading && !unavailable;
30
62
  return (_jsxs(GillFrame, { title: "Launcher", size: size, onContentHeight: onContentHeight, editHandle: editHandle ?? (_jsx(Button, { size: "xs", variant: "outline", "aria-expanded": editing, onClick: () => {
31
63
  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: [
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: [
33
65
  ...tiles,
66
+ ...pendingTiles,
34
67
  ...warnings,
35
68
  {
36
69
  id: "all-apps",
@@ -38,7 +71,9 @@ export function LauncherGill({ items, size = "M", onAllApps, loading = false, un
38
71
  icon: _jsx(Sigil, { name: "allApps" }),
39
72
  onSelect: onAllApps,
40
73
  },
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) => {
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: () => {
75
+ window.open(installDocs, "_blank", "noopener,noreferrer");
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) => {
42
77
  const value = event.currentTarget.value;
43
78
  if (value !== "Pinned" &&
44
79
  value !== "Shown" &&
@@ -47,3 +82,21 @@ export function LauncherGill({ items, size = "M", onAllApps, loading = false, un
47
82
  onPreference(item.id, value);
48
83
  }, children: [_jsx("option", { value: "Shown", children: "Shown" }), _jsx("option", { value: "Pinned", children: "Pinned" }), _jsx("option", { value: "Hidden", children: "Hidden" })] })] }) }, item.id))) })) : null] })) : null] }));
49
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
+ }
@@ -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: () => {