@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,4 +1,4 @@
1
- import type { AgentAccessOperation, AppPermissionOutcome, ComputerAccessOperation } from "@fungi.computer/agar";
1
+ import type { AgentAccessOperation, AppPermissionOutcome, AppPermissionRequest, ComputerAccessOperation } from "@fungi.computer/agar";
2
2
  import type { AppAgentPermission, AppComputerPermission } from "@fungi.computer/nacre/app-directory";
3
3
  export declare const consentableAgentOperations: (requested: readonly AgentAccessOperation[], declared: readonly string[]) => readonly AgentAccessOperation[];
4
4
  export declare const consentableComputerOperations: (requested: readonly ComputerAccessOperation[], declared: readonly string[]) => readonly ComputerAccessOperation[];
@@ -9,10 +9,18 @@ export declare function consentedAgentPermission(current: AppAgentPermission, of
9
9
  * access; a real Computer selection is the owner's choice and never widened.
10
10
  */
11
11
  export declare function consentedComputerPermission(current: AppComputerPermission | null, offered: readonly ComputerAccessOperation[]): AppComputerPermission | "covered" | "customize";
12
+ /** Every right the request names, in plain words, in a stable order. */
13
+ export declare function plainRights(request: {
14
+ agents: readonly AgentAccessOperation[];
15
+ computers: readonly ComputerAccessOperation[];
16
+ others?: AppPermissionRequest | undefined;
17
+ }): readonly string[];
12
18
  export type AppAccessRequest = Readonly<{
13
19
  appName: string;
14
20
  agents: readonly AgentAccessOperation[];
15
21
  computers: readonly ComputerAccessOperation[];
22
+ /** Git, Workflow, event and generation rights asked for in the same request. */
23
+ others?: AppPermissionRequest | undefined;
16
24
  /** A host refusal is visible and cannot be converted into an Allow. */
17
25
  refusal?: Readonly<{
18
26
  code: string;
@@ -22,7 +30,7 @@ export type AppAccessRequest = Readonly<{
22
30
  allow: () => Promise<boolean>;
23
31
  settle: (outcome: AppPermissionOutcome) => void;
24
32
  }>;
25
- /** One-click host consent for the rights a default App declared. */
33
+ /** One-click host consent: one sheet listing every right in plain words. */
26
34
  export declare function AppAccessConsent({ request, }: {
27
35
  request: AppAccessRequest | null;
28
36
  }): import("react/jsx-runtime").JSX.Element;
@@ -1,8 +1,8 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Button } from "@fungi.computer/caps/components/button";
3
3
  import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogTitle, } from "@fungi.computer/caps/components/dialog";
4
- import { WindowFrame, WindowHeader, } from "@fungi.computer/caps/components/window";
5
- import { useState } from "react";
4
+ import { WindowFrame } from "@fungi.computer/caps/components/window";
5
+ import { useRef, useState } from "react";
6
6
  const directoryOperations = ["agent.list"];
7
7
  const sessionOperations = ["agent.read", "agent.send", "agent.manage"];
8
8
  const agentOperations = [
@@ -67,25 +67,42 @@ const rightNames = {
67
67
  "computer.writeFile": "change their files",
68
68
  "computer.execute": "run commands on them",
69
69
  };
70
- const describe = (offered) => {
71
- const rights = [...agentOperations, ...computerOperations]
72
- .filter((operation) => offered.includes(operation))
73
- .map((operation) => rightNames[operation]);
74
- const last = rights.at(-1) ?? "";
75
- return rights.length < 2
76
- ? last
77
- : `${rights.slice(0, -1).join(", ")} and ${last}`;
70
+ /** Plain words for the Git, Workflow, event and generation rights. */
71
+ const otherRightNames = {
72
+ "git.repository": "save its work in Git repositories",
73
+ "workflow.publish": "publish workflows",
74
+ "workflow.arm": "let workflows start on their own",
75
+ "workflow.run": "run workflows",
76
+ "app.events.emit": "send events to your other Apps",
77
+ "llm.generation": "write with an AI model",
78
+ "media.generation": "make images and videos",
79
+ "media.share": "share what it makes",
78
80
  };
79
- const resources = (request, agent, computer) => [
80
- request.agents.length > 0 ? agent : null,
81
- request.computers.length > 0 ? computer : null,
82
- ]
83
- .filter((resource) => resource !== null)
84
- .join(" and ");
85
- /** One-click host consent for the rights a default App declared. */
81
+ /** Every right the request names, in plain words, in a stable order. */
82
+ export function plainRights(request) {
83
+ const others = request.others;
84
+ const named = [
85
+ ...(others?.git ?? []),
86
+ ...(others?.workflows ?? []),
87
+ ...(others?.events ?? []),
88
+ ...(others?.generation ?? []),
89
+ ];
90
+ const agentRights = agentOperations
91
+ .filter((operation) => request.agents.includes(operation))
92
+ .map((operation) => rightNames[operation]);
93
+ const computerRights = computerOperations
94
+ .filter((operation) => request.computers.includes(operation))
95
+ .map((operation) => rightNames[operation]);
96
+ const otherRights = Object.entries(otherRightNames)
97
+ .filter(([operation]) => named.includes(operation))
98
+ .map(([, words]) => words);
99
+ return [...agentRights, ...computerRights, ...otherRights];
100
+ }
101
+ /** One-click host consent: one sheet listing every right in plain words. */
86
102
  export function AppAccessConsent({ request, }) {
87
103
  const [saving, setSaving] = useState(false);
88
104
  const [failed, setFailed] = useState(false);
105
+ const approve = useRef(null);
89
106
  const settle = (outcome) => {
90
107
  setSaving(false);
91
108
  setFailed(false);
@@ -94,28 +111,20 @@ export function AppAccessConsent({ request, }) {
94
111
  return (_jsx(Dialog, { open: request !== null, onOpenChange: (next) => {
95
112
  if (!next && !saving)
96
113
  settle("declined");
97
- }, children: _jsxs(DialogContent, { render: _jsx(WindowFrame, { floating: true }), keepMounted: false, className: "tourtois-app-consent", children: [_jsx(WindowHeader, { title: "App access" }), _jsxs("div", { className: "tourtois-app-consent-body", children: [_jsx(DialogTitle, { children: request
98
- ? `Let ${request.appName} work with your ${resources(request, "Agents", "Computers")}?`
99
- : "" }), _jsx(DialogDescription, { children: request
100
- ? `${request.appName} can ${describe([...request.agents, ...request.computers])} for every ${resources(request, "Agent", "Computer")} in this Oyster. You can change this later in System Settings.`
101
- : "" }), request?.refusal !== undefined ? (_jsx("p", { role: "alert", "data-refusal-code": request.refusal.code, children: request.refusal.message })) : null, failed ? (_jsx("p", { role: "alert", children: "Access could not be saved. Try again." })) : null, _jsxs(DialogFooter, { children: [_jsx(Button, { variant: "ghost", disabled: saving, onClick: () => {
102
- settle("customize");
103
- }, children: "Customize\u2026" }), _jsx(Button, { variant: "ghost", disabled: saving, onClick: () => {
104
- settle("declined");
105
- }, children: "Not now" }), _jsx(Button, { disabled: saving || request === null || request.refusal !== undefined, onClick: () => {
106
- if (request === null || request.refusal !== undefined)
107
- return;
108
- setSaving(true);
109
- setFailed(false);
110
- void request.allow().then((saved) => {
111
- if (saved)
112
- settle("granted");
113
- else {
114
- settle("declined");
115
- }
116
- }, () => {
117
- setSaving(false);
118
- setFailed(true);
119
- });
120
- }, children: saving ? "Allowing…" : "Allow" })] })] })] }) }));
114
+ }, children: _jsx(DialogContent, { render: _jsx(WindowFrame, { floating: true }), keepMounted: false, className: "tourtois-app-consent", initialFocus: approve, children: _jsxs("div", { className: "tourtois-app-consent-body", children: [_jsx(DialogTitle, { children: request ? `Approve ${request.appName}'s permissions?` : "" }), _jsx(DialogDescription, { children: request ? `${request.appName} would like to:` : "" }), request !== null ? (_jsx("ul", { className: "tourtois-app-consent-rights text-sm", children: plainRights(request).map((right) => (_jsx("li", { children: right }, right))) })) : null, _jsx("p", { className: "text-sm", children: "You can change this later in System Settings." }), request?.refusal !== undefined ? (_jsx("p", { role: "alert", "data-refusal-code": request.refusal.code, children: request.refusal.message })) : null, failed ? (_jsx("p", { role: "alert", children: "Access could not be saved. Try again." })) : null, _jsxs(DialogFooter, { className: "tourtois-app-consent-footer", children: [_jsx(Button, { variant: "ghost", size: "sm", disabled: saving, onClick: () => {
115
+ settle("customize");
116
+ }, children: "Customize\u2026" }), _jsxs("div", { className: "tourtois-app-consent-decision", children: [_jsx(Button, { variant: "ghost", disabled: saving, onClick: () => {
117
+ settle("declined");
118
+ }, children: "Not now" }), _jsx(Button, { ref: approve, disabled: saving || request === null || request.refusal !== undefined, onClick: () => {
119
+ if (request === null || request.refusal !== undefined)
120
+ return;
121
+ setSaving(true);
122
+ setFailed(false);
123
+ void request.allow().then((saved) => {
124
+ settle(saved ? "granted" : "declined");
125
+ }, () => {
126
+ setSaving(false);
127
+ setFailed(true);
128
+ });
129
+ }, children: saving ? "Approving…" : "Approve" })] })] })] }) }) }));
121
130
  }
package/dist/AppPane.d.ts CHANGED
@@ -8,7 +8,7 @@ export declare function FocusedWindowControls({ app, onOpenSettings, onOpenPermi
8
8
  onOpenPermissions: () => void;
9
9
  projection: AppWindowProjection;
10
10
  }): import("react/jsx-runtime").JSX.Element | null;
11
- export declare function AppPane({ projection, nextLaunch, icon, manager, onError, index, focusWindow, afterHide, onBack, onSelectComputer, }: {
11
+ export declare function AppPane({ projection, nextLaunch, icon, manager, onError, index, focusWindow, afterHide, onBack, onSelectComputer, onChooseComputer, }: {
12
12
  projection: AppWindowProjection;
13
13
  nextLaunch?: AppLaunchDescriptor | null;
14
14
  icon: string | null | undefined;
@@ -20,6 +20,8 @@ export declare function AppPane({ projection, nextLaunch, icon, manager, onError
20
20
  onBack: (id: string) => void;
21
21
  /** The person chose another of this window's offered Computers. */
22
22
  onSelectComputer: (windowId: string, computerId: string) => void;
23
+ /** No Computer is granted: open the App's permissions to grant one. */
24
+ onChooseComputer: (surfaceId: string) => void;
23
25
  }): import("react/jsx-runtime").JSX.Element;
24
26
  /**
25
27
  * One window's status bar, owned by the shell like its title bar: the
@@ -31,7 +33,7 @@ export declare function AppPane({ projection, nextLaunch, icon, manager, onError
31
33
  * a shorter notice takes precedence over Inkcap's low-value file count, never
32
34
  * over the App's save state. Desktop presentation stays unchanged.
33
35
  */
34
- export declare function WindowStatusBar({ projection, onSelectComputer, onAction, surface, computerPickerOpen, onComputerPickerOpenChange, onReload, }: {
36
+ export declare function WindowStatusBar({ projection, onSelectComputer, onAction, surface, computerPickerOpen, onComputerPickerOpenChange, onReload, onChooseComputer, }: {
35
37
  projection: AppWindowProjection;
36
38
  onSelectComputer: (computerId: string) => void;
37
39
  onAction: (action: AppStatusAction) => void;
@@ -41,4 +43,6 @@ export declare function WindowStatusBar({ projection, onSelectComputer, onAction
41
43
  onComputerPickerOpenChange?: (open: boolean) => void;
42
44
  /** Uses the window manager's ordinary, veto-respecting replacement. */
43
45
  onReload?: (() => void) | undefined;
46
+ /** With no Computer granted, the chip that opens the App's permissions. */
47
+ onChooseComputer?: (() => void) | undefined;
44
48
  }): import("react/jsx-runtime").JSX.Element | null;
package/dist/AppPane.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { Alert } from "@fungi.computer/caps/components/alert";
2
+ import { LoadingState } from "@fungi.computer/caps/blocks/loading-state";
3
+ import { ResultState } from "@fungi.computer/caps/blocks/result-state";
3
4
  import { Button } from "@fungi.computer/caps/components/button";
4
5
  import { IconButton } from "@fungi.computer/caps/components/icon-button";
5
6
  import { AppStatusBar, AppStatusItem, StatusBarChip, StatusBarPicker, } from "@fungi.computer/caps/blocks/app-status-bar";
@@ -15,6 +16,7 @@ import { AppIcon } from "./app-icon.js";
15
16
  import { useWindowMotion } from "./use-window-motion.js";
16
17
  import { backHint } from "./shell-commands.js";
17
18
  import { createAppWindowManager, } from "./app-windows.js";
19
+ import { useDismissOverlays } from "./layers.js";
18
20
  import { launchComputerId } from "./app-launch.js";
19
21
  /**
20
22
  * The App's own path, commands and state, when it publishes them; an App
@@ -43,25 +45,27 @@ function headerContent(navigation, popover, activate) {
43
45
  content = { ...content, status: navigation.status };
44
46
  return content;
45
47
  }
46
- const windowStatusLabel = (projection) => {
47
- if (projection.status === "error")
48
- return describeAppError(projection.error).message;
49
- if (projection.status === "loading")
50
- return `${projection.launch.title} opening…`;
51
- if (projection.status === "getting-ready")
52
- return "Getting ready…";
53
- return projection.launch.title;
54
- };
55
48
  /** The focused window's App-level settings; its Computer lives in its status bar. */
56
49
  export function FocusedWindowControls({ app, onOpenSettings, onOpenPermissions, projection, }) {
57
50
  if (!app)
58
51
  return null;
59
52
  return (_jsxs("div", { className: "tourtois-focused-controls", role: "group", "aria-label": `${projection.launch.title} settings`, children: [_jsx(IconButton, { size: "responsive", "aria-label": `Permissions for ${projection.launch.title}`, title: "App permissions", icon: _jsx(ShieldCheck, {}), onClick: onOpenPermissions }), _jsx(IconButton, { size: "responsive", "aria-label": `Settings for ${projection.launch.title}`, title: "App settings", icon: _jsx(Settings, {}), onClick: onOpenSettings })] }));
60
53
  }
61
- export function AppPane({ projection, nextLaunch, icon, manager, onError, index, focusWindow, afterHide, onBack, onSelectComputer, }) {
54
+ /** The window's failure card: what happened, what to try, one primary way out. */
55
+ function WindowFailure({ projection, onReopen, }) {
56
+ const { title: appTitle } = projection.launch;
57
+ const lost = projection.error instanceof AppError &&
58
+ projection.error.code === "DISCONNECTED";
59
+ const described = describeAppError(projection.error);
60
+ return (_jsx(ResultState, { className: "tourtois-window-failure", tone: "failed", headingLevel: 3, title: lost ? "This App lost its connection" : described.title, description: _jsxs(_Fragment, { children: [lost ? `${appTitle} stopped answering.` : described.message, _jsx("span", { className: "tourtois-window-failure-note", children: "A request may have finished even if its reply did not arrive, so check before repeating it." })] }), actions: _jsxs(_Fragment, { children: [_jsxs(Button, { type: "button", variant: "primary", onClick: onReopen, children: ["Reopen ", appTitle] }), _jsx(Button, { type: "button", variant: "outline", onClick: () => {
61
+ window.location.reload();
62
+ }, children: "Reload workspace" })] }) }));
63
+ }
64
+ export function AppPane({ projection, nextLaunch, icon, manager, onError, index, focusWindow, afterHide, onBack, onSelectComputer, onChooseComputer, }) {
62
65
  const containerRef = useRef(null);
63
66
  const popover = useLayer("popover");
64
67
  const [computerPickerOpen, setComputerPickerOpen] = useState(false);
68
+ const dismissOthers = useDismissOverlays();
65
69
  useEffect(() => {
66
70
  if (projection.launch.computers === undefined)
67
71
  return;
@@ -176,14 +180,16 @@ export function AppPane({ projection, nextLaunch, icon, manager, onError, index,
176
180
  onError("App could not be minimized.");
177
181
  });
178
182
  }, onClose: close }) }) }), projection.status === "loading" ||
179
- projection.status === "getting-ready" ? (_jsxs("div", { className: "tourtois-app-loading", role: "status", children: [_jsx(AppIcon, { roles: projection.launch.roles, icon: icon }), _jsxs("div", { children: [_jsx("strong", { children: projection.status === "getting-ready"
180
- ? "Getting ready…"
181
- : `Opening ${projection.launch.title}…` }), _jsx("span", { children: "Preparing this App for your workspace." })] })] })) : null, projection.status === "error" ? (_jsx("div", { className: "tourtois-window-status", children: _jsx(Alert, { tone: "warning", title: projection.error instanceof AppError &&
182
- projection.error.code === "DISCONNECTED"
183
- ? "This App lost its connection."
184
- : windowStatusLabel(projection), description: "Check your connection and the host before reloading. A request may have completed even if its reply did not arrive; check its result before repeating it.", children: _jsx("div", { style: { marginTop: "var(--spacing-md)" }, children: _jsx(Button, { type: "button", variant: "outline", onClick: () => {
185
- window.location.reload();
186
- }, children: "Reload workspace" }) }) }) })) : null, _jsx(WindowBody, { ref: containerRef, className: "tourtois-pane-body", hidden: projection.status === "error" }), _jsx(WindowStatusBar, { projection: projection, onReload: nextLaunch && nextLaunch.releaseId !== projection.launch.releaseId
183
+ projection.status === "getting-ready" ? (_jsx(LoadingState, { className: "tourtois-app-loading", framed: false, icon: _jsx(AppIcon, { roles: projection.launch.roles, icon: icon }), variant: projection.status === "getting-ready" ? "square" : "line", message: projection.status === "getting-ready"
184
+ ? `Getting ${projection.launch.title} ready…`
185
+ : `Opening ${projection.launch.title}…`, detail: "Preparing this App for your workspace." })) : null, projection.status === "error" ? (_jsx("div", { className: "tourtois-window-status", children: _jsx(WindowFailure, { projection: projection, onReopen: () => {
186
+ void manager
187
+ .replace(projection.windowId, projection.launch)
188
+ .catch((cause) => {
189
+ console.error("App reopen failed", cause);
190
+ onError("App could not be reopened.");
191
+ });
192
+ } }) })) : null, _jsx(WindowBody, { ref: containerRef, className: "tourtois-pane-body", hidden: projection.status === "error" }), _jsx(WindowStatusBar, { projection: projection, onReload: nextLaunch && nextLaunch.releaseId !== projection.launch.releaseId
187
193
  ? () => {
188
194
  void manager
189
195
  .replace(projection.windowId, nextLaunch)
@@ -192,7 +198,13 @@ export function AppPane({ projection, nextLaunch, icon, manager, onError, index,
192
198
  onError("App could not be reloaded.");
193
199
  });
194
200
  }
195
- : undefined, computerPickerOpen: computerPickerOpen, onComputerPickerOpenChange: setComputerPickerOpen, onSelectComputer: (computerId) => {
201
+ : undefined, onChooseComputer: () => {
202
+ onChooseComputer(projection.launch.surfaceId);
203
+ }, computerPickerOpen: computerPickerOpen, onComputerPickerOpenChange: (open) => {
204
+ if (open)
205
+ dismissOthers();
206
+ setComputerPickerOpen(open);
207
+ }, onSelectComputer: (computerId) => {
196
208
  onSelectComputer(projection.windowId, computerId);
197
209
  }, surface: () => containerRef.current, onAction: (action) => {
198
210
  void manager
@@ -213,7 +225,7 @@ export function AppPane({ projection, nextLaunch, icon, manager, onError, index,
213
225
  * a shorter notice takes precedence over Inkcap's low-value file count, never
214
226
  * over the App's save state. Desktop presentation stays unchanged.
215
227
  */
216
- export function WindowStatusBar({ projection, onSelectComputer, onAction, surface, computerPickerOpen, onComputerPickerOpenChange, onReload, }) {
228
+ export function WindowStatusBar({ projection, onSelectComputer, onAction, surface, computerPickerOpen, onComputerPickerOpenChange, onReload, onChooseComputer, }) {
217
229
  const popover = useLayer("popover");
218
230
  const [phone, setPhone] = useState(false);
219
231
  useEffect(() => {
@@ -231,7 +243,10 @@ export function WindowStatusBar({ projection, onSelectComputer, onAction, surfac
231
243
  const { computers, title } = projection.launch;
232
244
  const items = projection.statusItems;
233
245
  if (computers === undefined && items.length === 0 && !onReload)
234
- return null;
246
+ // While the App opens, an empty bar holds the footer's height so the
247
+ // window does not jump when the readouts arrive.
248
+ return projection.status === "loading" ||
249
+ projection.status === "getting-ready" ? (_jsx(AppStatusBar, { "aria-hidden": "true", className: "tourtois-window-status-bar" })) : null;
235
250
  const anchorFor = (key) => {
236
251
  const origin = surface?.()?.getBoundingClientRect();
237
252
  if (!origin)
@@ -245,12 +260,17 @@ export function WindowStatusBar({ projection, onSelectComputer, onAction, surfac
245
260
  const render = (item) => (_jsx(WindowStatusItem, { item: item, container: popover, onAction: onAction, anchorFor: anchorFor }, item.id));
246
261
  const end = items.filter((item) => item.end === true);
247
262
  const start = items.filter((item) => item.end !== true &&
248
- !(phone &&
249
- projection.launch.appId === "inkcap" &&
250
- item.kind === "text" &&
251
- item.id === "documents"));
263
+ !(phone && item.kind === "text" && item.priority === "low"));
252
264
  const appReadouts = end.length === 0 ? undefined : end.map(render);
253
- return (_jsx(AppStatusBar, { className: "tourtois-window-status-bar", "aria-label": `${title} status`, attachment: computers === undefined ? undefined : (_jsx(StatusBarPicker, { ...(computerPickerOpen === undefined
265
+ // Zero Computers: a chip to grant one. One is not a choice, so the picker
266
+ // appears from two.
267
+ let attachment;
268
+ if (computers === undefined || computers.length === 1)
269
+ attachment = undefined;
270
+ else if (computers.length === 0)
271
+ attachment = (_jsx(StatusBarChip, { label: "Choose Computer", onClick: onChooseComputer }));
272
+ else
273
+ attachment = (_jsx(StatusBarPicker, { ...(computerPickerOpen === undefined
254
274
  ? {}
255
275
  : { open: computerPickerOpen }), ...(onComputerPickerOpenChange === undefined
256
276
  ? {}
@@ -258,7 +278,8 @@ export function WindowStatusBar({ projection, onSelectComputer, onAction, surfac
258
278
  id: computer.computerId,
259
279
  label: computer.name,
260
280
  })), value: launchComputerId(projection.launch.href), emptyMessage: "No Computers are granted to this App", disabled: projection.status === "loading" ||
261
- projection.status === "getting-ready", onSelect: onSelectComputer })), end: onReload ? (_jsxs("span", { className: phone
281
+ projection.status === "getting-ready", onSelect: onSelectComputer }));
282
+ return (_jsx(AppStatusBar, { className: "tourtois-window-status-bar", "aria-label": `${title} status`, attachment: attachment, end: onReload ? (_jsxs("span", { className: phone
262
283
  ? "flex min-w-0 items-center gap-xs"
263
284
  : "flex min-w-0 flex-wrap items-center gap-xs", children: [appReadouts, _jsxs(AppStatusItem, { children: [_jsx("span", { role: "status", children: phone ? "Update ready" : "New version available" }), _jsx(StatusBarChip, { label: "Reload", "aria-label": `Reload ${title}`, onClick: onReload })] })] })) : (appReadouts), children: start.length === 0 ? undefined : start.map(render) }));
264
285
  }
@@ -45,6 +45,8 @@ function announceFloating(tiled, projection) {
45
45
  toasterId: "workbench-notices",
46
46
  });
47
47
  }
48
+ /** The trial's starter Apps that are still being set up, if the host says so. */
49
+ const installingApps = (directory) => directory?.installing;
48
50
  /** Windows cover the desktop, so Show desktop runs before arranging it. */
49
51
  function arrangeDesktop(hide, arrange, onFailure) {
50
52
  const hiding = hide();
@@ -587,7 +589,7 @@ export function AppWorkbench({ paneLayerRef, phone, teamId, teamName, initialCom
587
589
  ? createPortal(_jsx(Toaster, { id: "workbench-notices", position: "bottom-right", offset: 24, mobileOffset: 24, style: { fontFamily: "var(--font-sans)" }, closeButton: true }), noticeContainer)
588
590
  : null, _jsxs("div", { className: "relative min-h-0 flex-1", children: [_jsx(MaosaicoRegion, { layer: "desktop", style: { position: "absolute", inset: 0 }, "data-desktop-visibility": visibility, ref: desktopRef, "aria-hidden": covered ? true : undefined, children: _jsx(Desktop, { phone: phone, editing: desktopEditing, onEditingChange: setDesktopEditing, onOwner: receiveDesktopOwner, launcherItems: launchableItems, onAllApps: () => {
589
591
  setAppDialOpen(true);
590
- }, paused: covered, apps: windowApps, needsUpdate: needsUpdate, onAppSettings: (app) => {
592
+ }, installing: installingApps(appsQuery.data), onRetryInstall: platform.retryInstall, paused: covered, apps: windowApps, needsUpdate: needsUpdate, onAppSettings: (app) => {
591
593
  setSettingsLocation({
592
594
  category: "apps",
593
595
  appKey: addressKey(app.address),
@@ -607,7 +609,7 @@ export function AppWorkbench({ paneLayerRef, phone, teamId, teamName, initialCom
607
609
  const app = directory.find((item) => item.surfaceId === projection.launch.surfaceId);
608
610
  return (_jsx(AppPane, { index: index, focusWindow: focusWindow, afterHide: afterHide, onBack: goBack, manager: appWindows, projection: projection, nextLaunch: app ? launchFor(app, projection.launch) : null, icon: app?.icon, onError: setAppStatus, onSelectComputer: (windowId, computerId) => {
609
611
  void selectWindowComputer(windowId, computerId);
610
- } }, projection.windowId));
612
+ }, onChooseComputer: openAppPermissions }, projection.windowId));
611
613
  }), extraPanes?.({ activeId, order, focus }), layout.snapPreview && (_jsx(WindowSnapPreview, { "data-snap-side": layout.snapPreview.side, style: {
612
614
  left: layout.snapPreview.frame.x,
613
615
  top: layout.snapPreview.frame.y,
@@ -15,7 +15,7 @@ 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" }), 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: () => {
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, { "data-layout-menu": true, 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
20
  setLayoutOpen(false);
21
21
  }, children: "Tiled" }), _jsx(DropdownMenuCheckboxItem, { checked: !tiled, onCheckedChange: () => {
@@ -5,6 +5,7 @@ import { useQuery } from "@tanstack/react-query";
5
5
  import { MaosaicoRoot } from "@fungi.computer/maosaico";
6
6
  import { useEffect, useRef, useState } from "react";
7
7
  import { AppWorkbench } from "./AppWorkbench.js";
8
+ import { WelcomeProvider } from "./desktop/welcome.js";
8
9
  function useWorkbenchBounds() {
9
10
  const ref = useRef(null);
10
11
  const [bounds, setBounds] = useState({ height: 0, width: 0 });
@@ -35,5 +36,5 @@ export function TeamTourtois({ children, teamId, teamName, extraLaunchers, setti
35
36
  });
36
37
  return (_jsx("main", { className: "tourtois-shell", "data-tourtois-shell": true, children: _jsxs(TourtoisLayers, { children: [_jsx("div", { className: "tourtois-workbench", children: _jsx(MaosaicoRoot, { bounds: bounds, containerRef: paneLayerRef, tiling: tiled || phone
37
38
  ? { mainSize: Math.max(0, Math.min(640, bounds.width)), gap: 8 }
38
- : undefined, children: _jsx(AppWorkbench, { paneLayerRef: paneLayerRef, phone: phone, teamId: teamId, teamName: teamName ?? teamId, initialComputerId: data?.[0]?.computerId ?? null, computers: data ?? [], computersUnavailable: isLoading || isError, onLayoutChange: phone ? undefined : setTiled, platform: platform, desktopStorage: desktopStorage, desktopMethods: desktopMethods, gills: gills, ...(extraLaunchers ? { extraLaunchers } : {}), ...(settingsLaunchers ? { settingsLaunchers } : {}), ...(systemMenuItems ? { systemMenuItems } : {}), directoryReader: directoryReader, ...(takeAppOpenRequest ? { takeAppOpenRequest } : {}) }) }) }), children] }) }));
39
+ : undefined, children: _jsx(WelcomeProvider, { teamId: teamId, storage: desktopStorage, children: _jsx(AppWorkbench, { paneLayerRef: paneLayerRef, phone: phone, teamId: teamId, teamName: teamName ?? teamId, initialComputerId: data?.[0]?.computerId ?? null, computers: data ?? [], computersUnavailable: isLoading || isError, onLayoutChange: phone ? undefined : setTiled, platform: platform, desktopStorage: desktopStorage, desktopMethods: desktopMethods, gills: gills, ...(extraLaunchers ? { extraLaunchers } : {}), ...(settingsLaunchers ? { settingsLaunchers } : {}), ...(systemMenuItems ? { systemMenuItems } : {}), directoryReader: directoryReader, ...(takeAppOpenRequest ? { takeAppOpenRequest } : {}) }) }) }) }), children] }) }));
39
40
  }
@@ -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: [_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 })] }));
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", { className: "tourtois-windows-label", 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, { appsLabel: "Apps", ...props, windows: collapsed ? [] : props.windows })] }));
12
12
  }
@@ -105,6 +105,15 @@ export declare function useAppDirectory(teamId: string, directoryReader: () => P
105
105
  appId: string | null;
106
106
  displayName: string;
107
107
  }[] | undefined;
108
+ installing?: {
109
+ installationId: string;
110
+ displayName: string;
111
+ state: "failed" | "installing" | "needs-runtime";
112
+ reason?: {
113
+ code: "unknown" | "build_failed" | "network" | "unsupported";
114
+ message: string;
115
+ } | undefined;
116
+ }[] | undefined;
108
117
  }, Error>;
109
118
  apps: {
110
119
  address: {
@@ -15,7 +15,10 @@ export function useAppDirectory(teamId, directoryReader) {
15
15
  // is refused. Every directory read costs the host a Registry read, and
16
16
  // explicit mutations already invalidate this query, so the poll is a slow
17
17
  // backstop. React Query pauses it while the page is hidden.
18
- refetchInterval: 60_000,
18
+ // While a trial installs its starter Apps the list changes, so poll quickly.
19
+ refetchInterval: (current) => current.state.data?.installing?.some((entry) => entry.state === "installing")
20
+ ? 3_000
21
+ : 60_000,
19
22
  });
20
23
  return {
21
24
  query,
package/dist/chrome.css CHANGED
@@ -131,23 +131,9 @@
131
131
  }
132
132
  }
133
133
 
134
- /* App status actions: flat chips on the picker's surface that keep their
135
- size, show a pressed or open state, and go icon-only on a phone. */
136
- .tourtois-status-chip {
137
- flex: none;
138
- max-width: none;
139
- }
140
- .tourtois-status-chip[aria-pressed="true"],
141
- .tourtois-status-chip[aria-expanded="true"] {
142
- background: var(--color-base-300);
143
- }
144
- @media (max-width: 640px) {
145
- .tourtois-status-chip:has(> svg) .tourtois-status-chip-label {
146
- position: absolute;
147
- width: 1px;
148
- height: 1px;
149
- overflow: hidden;
150
- clip-path: inset(50%);
151
- white-space: nowrap;
134
+ /* On the narrowest phones the bar keeps its icons; the tab's name is its tooltip. */
135
+ @media (max-width: 420px) {
136
+ .tourtois-windows-label {
137
+ display: none;
152
138
  }
153
139
  }
@@ -4,6 +4,7 @@ import type { AppStorage } from "@fungi.computer/agar/storage";
4
4
  import type { AppBarItem } from "@fungi.computer/caps/blocks/app-bar";
5
5
  import type { WorkbenchDirectory } from "@fungi.computer/nacre/workbench-directory";
6
6
  import { type DesktopLayoutClient } from "../desktop-client.js";
7
+ import type { InstallingApp } from "@fungi.computer/nacre/workbench-directory";
7
8
  import { type DesktopGillTransport } from "./row-gill.js";
8
9
  export type DesktopProps = {
9
10
  phone: boolean;
@@ -19,6 +20,9 @@ export type DesktopProps = {
19
20
  unavailable: boolean;
20
21
  onRetryApps: () => void;
21
22
  onAllApps: () => void;
23
+ /** Starter Apps a trial is still setting up, or could not set up. */
24
+ installing?: readonly InstallingApp[] | undefined;
25
+ onRetryInstall?: ((installationId: string) => Promise<void>) | undefined;
22
26
  onOpen: (target: AppOpenInput) => void;
23
27
  computersForGill?: ((surfaceId: string) => readonly {
24
28
  computerId: string;