@fungi.computer/tourtois 0.23.1 → 0.24.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -9,7 +9,23 @@ Tourtois is the shell of [Oyster](https://github.com/fungi-computer/oyster), the
9
9
  open App host that runs on your own Cloudflare account. When you sign in to an
10
10
  Oyster, Tourtois is what you see, and every other App opens inside it.
11
11
 
12
- ## What you can do
12
+ ## Quick start
13
+
14
+ In a Fungi monorepo checkout with dependencies installed, run the component
15
+ workbench from the root:
16
+
17
+ ```sh
18
+ pnpm workbench:prepare
19
+ pnpm exec ladle serve --port 61983
20
+ ```
21
+
22
+ Open
23
+ <http://localhost:61983/?story=desktop--workspace&mode=preview&theme=light>.
24
+ This is Tourtois's real UI with local fixture data (a sample Team desktop with
25
+ the launcher and a Grove window), not a live Oyster. To run Tourtois on a real
26
+ Oyster, see [Get it](#get-it).
27
+
28
+ ## Common tasks
13
29
 
14
30
  - Launch Apps from the **Launcher** on the desktop or from the top bar.
15
31
  - Arrange windows **Tiled** or **Floating** from the **Layout** menu: drag,
@@ -30,7 +46,9 @@ cross-origin frame, but Tourtois runs in the host's own page with your
30
46
  permissions there. Pick a shell you trust: it can do anything you can on that
31
47
  host.
32
48
 
33
- ## Get it
49
+ ## Reference
50
+
51
+ ### Get it
34
52
 
35
53
  Tourtois installs with the other starter Apps, first of all. On a deployed
36
54
  Oyster (see the
@@ -48,7 +66,7 @@ Oyster with `git push`, builds them on your Computer and installs them. Sign in
48
66
  at `$OYSTER_URL/login` with the owner key and your Oyster opens on Tourtois. Run
49
67
  `install-apps` again to update; each App keeps its data.
50
68
 
51
- ## Change it
69
+ ### Change it
52
70
 
53
71
  Every installed App is also a template you can fork on your own Oyster,
54
72
  including the desktop. Fork Tourtois into a Bonsai repository and clone it with
@@ -73,7 +91,7 @@ your forks with `--repositories <base URL>` and `--ref <branch or tag>`. The
73
91
  installer reads all seven starter Apps from that base, so fork them under one
74
92
  account.
75
93
 
76
- ## How a host mounts it
94
+ ### How a host mounts it
77
95
 
78
96
  A Tourtois Release ships `shell.js` beside its `index.html`. The host imports
79
97
  that module from its own origin and calls
@@ -89,7 +107,7 @@ page, also available without a shell; the changed Oyster and Tourtois ship
89
107
  together. Other Settings sections still use their existing host-backed ports:
90
108
  this repair does not frame Keys, MCP servers, Computers or the consent dialog.
91
109
 
92
- ## Agent tools
110
+ ### Agent tools
93
111
 
94
112
  Agents can arrange your desktop. Through Oyster's MCP endpoint, or at
95
113
  `POST $OYSTER_URL/apps/tourtois/methods/<name>` with a key (see
@@ -106,7 +124,7 @@ Each change names the revision it is based on, and a stale revision is refused
106
124
  rather than overwriting a newer arrangement. In a connected browser, an agent's
107
125
  change shows **Your Agent arranged the desktop** with **Undo** for ten seconds.
108
126
 
109
- ## Build and check
127
+ ### Build and check
110
128
 
111
129
  Tourtois is React and TypeScript. Windows and tiling come from
112
130
  [Maosaico](https://github.com/fungi-computer/maosaico) and the controls from
@@ -126,7 +144,7 @@ layout. [src/shell-module.ts](src/shell-module.ts) is the `mountShell` entry,
126
144
  can supply. The agent tools are in [backend/methods.ts](backend/methods.ts), and
127
145
  [package.json](package.json) declares what the shell asks of its host.
128
146
 
129
- ### Open windows and new versions
147
+ #### Open windows and new versions
130
148
 
131
149
  The directory refreshes every 15 seconds while the desktop is visible, as well
132
150
  as on host change notifications. A changed active Release leaves the existing
@@ -145,6 +163,6 @@ With the Tourtois workbench running, `pnpm test:window-new-version` exercises
145
163
  the directory change, footer action and reopen at desktop and phone widths.
146
164
  `test/window-status-bar.test.tsx` proves the Reload close veto.
147
165
 
148
- ## License
166
+ ### License
149
167
 
150
168
  MIT. See [LICENSE](LICENSE).
@@ -15,7 +15,7 @@ import { reconcileAppDirectory, reconcileAppWindowFromDirectory, } from "./app-d
15
15
  import { useAppDirectory } from "./app-directory.js";
16
16
  import { AppIcon } from "./app-icon.js";
17
17
  import { tileGap } from "./tile-gap.js";
18
- import { appForRole, composeOpenRequests, createAppLaunchDescriptor, attachWindowComputer, launchComputerId, launchForComputer, findOpenFileCommand, launchForRoleIntent, requireHandledNavigation, resolveFileEditorWindow, } from "./app-launch.js";
18
+ import { appForRole, composeOpenRequests, launchForSurfaceGill, createAppLaunchDescriptor, attachWindowComputer, launchComputerId, launchForComputer, findOpenFileCommand, launchForRoleIntent, requireHandledNavigation, resolveFileEditorWindow, } from "./app-launch.js";
19
19
  import { useAppSurfaceHost, } from "./app-surface.js";
20
20
  import { hasVisibleAppWindows, } from "./app-windows.js";
21
21
  import { desktopVisibility } from "./desktop-visibility.js";
@@ -26,7 +26,7 @@ import { ShellCommandDialogs, useShellCommands } from "./shell-commands.js";
26
26
  import { OwnSprite } from "./member-avatar.js";
27
27
  import { Desktop } from "./desktop/Desktop.js";
28
28
  import { useAppOpenUrlHandoff } from "./useAppOpenUrlHandoff.js";
29
- import { useAppWindowManager } from "./useAppWindowManager.js";
29
+ import { useAppTileMount, useAppWindowManager, } from "./useAppWindowManager.js";
30
30
  import { useWindowSession } from "./window-session.js";
31
31
  import { useDirectoryCommands } from "./useDirectoryCommands.js";
32
32
  const emptyAppBarLabel = (loading, failed) => {
@@ -93,7 +93,7 @@ export function AppWorkbench({ paneLayerRef, phone, teamId, teamName, initialCom
93
93
  const { activeId, focus, mode, order } = layout;
94
94
  const appSurfaceHost = useAppSurfaceHost();
95
95
  const selectionRefreshes = useRef(new Map());
96
- const appWindows = useAppWindowManager(appSurfaceHost, teamId, {
96
+ const shellEvents = {
97
97
  onNavigation: (input) => openNavigation(input),
98
98
  onAppOpen: (input) => openApp(input),
99
99
  onAppRole: (role) => {
@@ -105,7 +105,9 @@ export function AppWorkbench({ paneLayerRef, phone, teamId, teamName, initialCom
105
105
  onAppFocus: (launch) => {
106
106
  focus(launch.windowId);
107
107
  },
108
- });
108
+ };
109
+ const appWindows = useAppWindowManager(appSurfaceHost, teamId, shellEvents);
110
+ const mountAppTile = useAppTileMount(appSurfaceHost, teamId, shellEvents);
109
111
  const appProjection = useSyncExternalStore(appWindows.subscribe, appWindows.read, appWindows.read);
110
112
  useEffect(() => {
111
113
  for (const window of appProjection.windows)
@@ -641,7 +643,13 @@ export function AppWorkbench({ paneLayerRef, phone, teamId, teamName, initialCom
641
643
  ? createPortal(_jsx(Toaster, { id: WORKBENCH_NOTICES, position: "bottom-right", offset: 24, mobileOffset: 24, style: { fontFamily: "var(--font-sans)" }, closeButton: true }), noticeContainer)
642
644
  : 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: () => {
643
645
  setAppDialOpen(true);
644
- }, installing: installingApps(appsQuery.data), onRetryInstall: platform.retryInstall, paused: covered, apps: windowApps, needsUpdate: needsUpdate, onAppSettings: (app) => {
646
+ }, installing: installingApps(appsQuery.data), onRetryInstall: platform.retryInstall, mountSurface: (container, target, signal) => {
647
+ const app = windowApps.find((app) => app.surfaceId === target.surfaceId);
648
+ const launch = app ? launchFor(app) : null;
649
+ if (!launch)
650
+ return Promise.reject(new Error("The widget's App is unavailable."));
651
+ return mountAppTile(container, launchForSurfaceGill(launch, target, composeOpenRequests.request.generate()), signal);
652
+ }, paused: covered, apps: windowApps, needsUpdate: needsUpdate, onAppSettings: (app) => {
645
653
  setSettingsLocation({
646
654
  category: "apps",
647
655
  appKey: addressKey(app.address),
@@ -16,6 +16,21 @@ export type ComputerOption = Readonly<{
16
16
  computerId: string;
17
17
  name: string;
18
18
  }>;
19
+ /**
20
+ * The launch for one surface tile: the App's ordinary frame, owned by the tile
21
+ * rather than the App's window, told which Gill it renders through the
22
+ * existing navigate params.
23
+ */
24
+ export declare function launchForSurfaceGill(launch: AppLaunchDescriptor, target: Readonly<{
25
+ itemId: string;
26
+ gillId: string;
27
+ }>, requestId: string): AppLaunchDescriptor;
28
+ /**
29
+ * The command and focus scope of one mount. A window of an App is its surface;
30
+ * a surface tile has its own, so a tile and a window of the same App never
31
+ * share a command mount or a focus.
32
+ */
33
+ export declare function commandScopeOf(launch: Pick<AppLaunchDescriptor, "surfaceId" | "commandScope">): string;
19
34
  /** Build the owner-issued launch descriptor for one currently available surface. */
20
35
  export declare function createAppLaunchDescriptor(installation: AppDirectoryApp, homeComputerId: string | null, origin: string, computers: readonly ComputerOption[], computersUnavailable?: boolean): AppLaunchDescriptor | null;
21
36
  /**
@@ -37,6 +37,31 @@ export const composeOpenRequests = defineIdFamily({
37
37
  version: 1,
38
38
  kinds: { request: { prefix: "request" } },
39
39
  });
40
+ /**
41
+ * The launch for one surface tile: the App's ordinary frame, owned by the tile
42
+ * rather than the App's window, told which Gill it renders through the
43
+ * existing navigate params.
44
+ */
45
+ export function launchForSurfaceGill(launch, target, requestId) {
46
+ return {
47
+ ...launch,
48
+ windowId: "gill:" + target.itemId,
49
+ commandScope: "gill:" + target.itemId,
50
+ openRequest: {
51
+ kind: "navigate",
52
+ requestId,
53
+ params: [{ key: "gill", value: target.gillId }],
54
+ },
55
+ };
56
+ }
57
+ /**
58
+ * The command and focus scope of one mount. A window of an App is its surface;
59
+ * a surface tile has its own, so a tile and a window of the same App never
60
+ * share a command mount or a focus.
61
+ */
62
+ export function commandScopeOf(launch) {
63
+ return launch.commandScope ?? launch.surfaceId;
64
+ }
40
65
  /** Build the owner-issued launch descriptor for one currently available surface. */
41
66
  export function createAppLaunchDescriptor(installation, homeComputerId, origin, computers, computersUnavailable = false) {
42
67
  if (installation.availability !== "available" ||
@@ -10,6 +10,12 @@ export type AppLaunchDescriptor = Readonly<{
10
10
  title: string;
11
11
  href: string;
12
12
  openRequest: AppOpenRequest | null;
13
+ /**
14
+ * Names this mount's own command and focus scope when it is not the App's
15
+ * window, as a surface tile is not. Absent for a window, whose scope is its
16
+ * surface id.
17
+ */
18
+ commandScope?: string;
13
19
  /** Roles the App's Release declares; the shell's mark follows them. */
14
20
  roles: readonly string[];
15
21
  /** Digest-covered command declarations shown before the App is opened. */
@@ -45,6 +51,12 @@ export declare const hasVisibleAppWindows: (projection: Readonly<{
45
51
  title: string;
46
52
  href: string;
47
53
  openRequest: AppOpenRequest | null;
54
+ /**
55
+ * Names this mount's own command and focus scope when it is not the App's
56
+ * window, as a surface tile is not. Absent for a window, whose scope is its
57
+ * surface id.
58
+ */
59
+ commandScope?: string;
48
60
  /** Roles the App's Release declares; the shell's mark follows them. */
49
61
  roles: readonly string[];
50
62
  /** Digest-covered command declarations shown before the App is opened. */
@@ -6,6 +6,7 @@ import type { WorkbenchDirectory } from "@fungi.computer/nacre/workbench-directo
6
6
  import { type DesktopLayoutClient } from "../desktop-client.js";
7
7
  import type { InstallingApp } from "@fungi.computer/nacre/workbench-directory";
8
8
  import { type DesktopGillTransport } from "./row-gill.js";
9
+ import { type SurfaceMount } from "./surface-gill.js";
9
10
  export type DesktopProps = {
10
11
  phone: boolean;
11
12
  apps: WorkbenchDirectory["apps"];
@@ -24,6 +25,8 @@ export type DesktopProps = {
24
25
  installing?: readonly InstallingApp[] | undefined;
25
26
  onRetryInstall?: ((installationId: string) => Promise<void>) | undefined;
26
27
  onOpen: (target: AppOpenInput) => void;
28
+ /** Mount an App's own frame in a surface tile; the host owns its authority. */
29
+ mountSurface: SurfaceMount;
27
30
  computersForGill?: ((surfaceId: string) => readonly {
28
31
  computerId: string;
29
32
  name: string;
@@ -18,6 +18,7 @@ import { availableDesktopLayout, desktopPlacements, desktopBentoIntent, } from "
18
18
  import { ArrangeToolbar } from "./arrange-toolbar.js";
19
19
  import { LauncherGill } from "./launcher-gill.js";
20
20
  import { RowGill } from "./row-gill.js";
21
+ import { SurfaceGill } from "./surface-gill.js";
21
22
  const gap = 16;
22
23
  const rowHeight = 280;
23
24
  /** The App owns one canonical four-column layout, never breakpoint storage. */
@@ -367,6 +368,13 @@ function ArrangedDesktop({ owner, ...props }) {
367
368
  });
368
369
  }, onConfigure: () => {
369
370
  setConfiguration({ gill, itemId: item.id });
370
- }, 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));
371
+ }, launch: props.launcherItems.find((app) => app.id === `app:${item.surfaceId}`), editHandle: editing ? _jsx("span", { "aria-hidden": "true" }) : undefined, onContentHeight: onContentHeight }, JSON.stringify(item.params ?? {}))) : declaration?.view === "surface" && app ? (_jsx(SurfaceGill, { title: declaration.title, appHeader: {
372
+ name: app.displayName ?? "App",
373
+ icon: _jsx(DeclaredAppIcon, { icon: app.icon }),
374
+ }, size: item.size, target: {
375
+ itemId: item.id,
376
+ surfaceId: item.surfaceId,
377
+ gillId: item.gillId,
378
+ }, mount: props.mountSurface, editing: editing, editHandle: editing ? _jsx("span", { "aria-hidden": "true" }) : undefined })) : null }), controls] }, item.id));
371
379
  }) })] }));
372
380
  }
@@ -0,0 +1,33 @@
1
+ import { type ReactNode } from "react";
2
+ import type { AppGillDesktopSize } from "@fungi.computer/gills";
3
+ /** The placed surface tile whose App frame the host mounts. */
4
+ export type SurfaceTarget = Readonly<{
5
+ itemId: string;
6
+ surfaceId: string;
7
+ gillId: string;
8
+ }>;
9
+ /** A live App frame in a tile; disposing it releases the frame. */
10
+ export type SurfaceHandle = Readonly<{
11
+ dispose: () => void | Promise<void>;
12
+ }>;
13
+ /**
14
+ * Mount the App's own frame inside `container`, with the same authority as its
15
+ * window. Abort only while the mount is pending; afterwards call `dispose`.
16
+ */
17
+ export type SurfaceMount = (container: HTMLElement, target: SurfaceTarget, signal: AbortSignal) => Promise<SurfaceHandle>;
18
+ /**
19
+ * A surface Gill: the App renders itself in its tile. While arranging, a shield
20
+ * covers the frame so a drag over it never reaches the App's document.
21
+ */
22
+ export declare function SurfaceGill({ title, appHeader, size, target, mount, editing, editHandle, }: {
23
+ title: string;
24
+ appHeader: Readonly<{
25
+ name: string;
26
+ icon: ReactNode;
27
+ }>;
28
+ size: AppGillDesktopSize;
29
+ target: SurfaceTarget;
30
+ mount: SurfaceMount;
31
+ editing: boolean;
32
+ editHandle?: ReactNode;
33
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,53 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useRef, useState } from "react";
3
+ import { ResultState } from "@fungi.computer/caps/blocks/result-state";
4
+ import { Button } from "@fungi.computer/caps/components/button";
5
+ import { GillFrame } from "./gill-frame.js";
6
+ /**
7
+ * A surface Gill: the App renders itself in its tile. While arranging, a shield
8
+ * covers the frame so a drag over it never reaches the App's document.
9
+ */
10
+ export function SurfaceGill({ title, appHeader, size, target, mount, editing, editHandle, }) {
11
+ const slot = useRef(null);
12
+ const latest = useRef(mount);
13
+ latest.current = mount;
14
+ const [failed, setFailed] = useState(false);
15
+ const [attempt, setAttempt] = useState(0);
16
+ const { itemId, surfaceId, gillId } = target;
17
+ useEffect(() => {
18
+ const node = slot.current;
19
+ if (!node)
20
+ return;
21
+ setFailed(false);
22
+ const abort = new AbortController();
23
+ let handle;
24
+ latest.current(node, { itemId, surfaceId, gillId }, abort.signal).then((mounted) => {
25
+ handle = mounted;
26
+ if (abort.signal.aborted)
27
+ void release(mounted);
28
+ }, (cause) => {
29
+ if (abort.signal.aborted)
30
+ return;
31
+ console.error("Surface Gill could not be mounted", cause);
32
+ setFailed(true);
33
+ });
34
+ return () => {
35
+ if (handle)
36
+ void release(handle);
37
+ else
38
+ abort.abort();
39
+ handle = undefined;
40
+ };
41
+ }, [itemId, surfaceId, gillId, attempt]);
42
+ return (_jsx(GillFrame, { title: title, appHeader: appHeader, size: size, editHandle: editHandle, children: _jsxs("div", { className: "tourtois-surface-body", children: [_jsx("div", { ref: slot, className: "tourtois-surface-frame" }), failed ? (_jsx("div", { className: "tourtois-surface-failure", children: _jsx(ResultState, { tone: "failed", headingLevel: 3, title: "This widget could not open", description: `${appHeader.name} didn't start in its tile.`, actions: _jsx(Button, { size: "sm", variant: "outline", onClick: () => {
43
+ setAttempt((count) => count + 1);
44
+ }, children: "Try again" }) }) })) : null, editing ? (_jsx("div", { "data-surface-shield": "", className: "tourtois-surface-shield" })) : null] }) }));
45
+ }
46
+ async function release(handle) {
47
+ try {
48
+ await handle.dispose();
49
+ }
50
+ catch (cause) {
51
+ console.error("Surface Gill could not be released", cause);
52
+ }
53
+ }
@@ -7,7 +7,7 @@ import "@fungi.computer/parakeet/styles.css";
7
7
  import "./shell.css";
8
8
  import { AppError } from "@fungi.computer/agar";
9
9
  import { createQueryClient } from "@fungi.computer/agar/query";
10
- import { workbenchDirectorySchema } from "@fungi.computer/nacre/workbench-directory";
10
+ import { workbenchComputerDirectorySchema, workbenchDirectorySchema, } from "@fungi.computer/nacre/workbench-directory";
11
11
  import { toast } from "@fungi.computer/caps/components/toaster";
12
12
  import { QueryClientProvider } from "@tanstack/react-query";
13
13
  import * as S from "effect/Schema";
@@ -147,6 +147,30 @@ const modelKeys = {
147
147
  })), "The model could not be saved");
148
148
  },
149
149
  };
150
+ const directory = async () => workbenchDirectorySchema.parse(await json("/api/workbench/directory"));
151
+ /**
152
+ * The Computers a key can be limited to: the owner's fleet, page by page, or
153
+ * the one Computer a host without a fleet serves.
154
+ */
155
+ async function oysterComputerTargets() {
156
+ const current = await directory();
157
+ if (current.computerContext !== "owner-fleet")
158
+ return current.computer === undefined
159
+ ? []
160
+ : [{ id: current.computer.computerId, name: current.computer.name }];
161
+ const targets = [];
162
+ let offset = 0;
163
+ while (offset !== null) {
164
+ const page = workbenchComputerDirectorySchema.parse(await json(`/api/workbench/computers?${new URLSearchParams({
165
+ limit: "100",
166
+ offset: String(offset),
167
+ })}`));
168
+ for (const computer of page.computers)
169
+ targets.push({ id: computer.computerId, name: computer.name });
170
+ offset = page.nextOffset;
171
+ }
172
+ return targets;
173
+ }
150
174
  /** Owner-direct Keys custody; a plaintext secret comes back only once, on issue. */
151
175
  function createOysterKeysPort(oysterKeysWire) {
152
176
  const oysterKeysView = z.strictObject({
@@ -160,12 +184,12 @@ function createOysterKeysPort(oysterKeysWire) {
160
184
  return {
161
185
  scope: "oyster",
162
186
  expiry: "optional",
163
- options: (apps) => {
187
+ options: async (apps) => {
164
188
  const targets = apps.map((app) => ({
165
189
  id: app.installationId,
166
190
  name: app.displayName,
167
191
  }));
168
- return Promise.resolve([
192
+ return [
169
193
  {
170
194
  capability: "apps.read",
171
195
  label: "Read Apps",
@@ -182,11 +206,12 @@ function createOysterKeysPort(oysterKeysWire) {
182
206
  },
183
207
  {
184
208
  capability: "computer.use",
185
- label: "Use the Computer",
209
+ label: "Use Computers",
186
210
  icon: "computer",
187
- hint: "Files and commands",
211
+ hint: "Files and commands. Pick Computers to keep the key on them; all follows the Computer you select.",
212
+ targets: await oysterComputerTargets(),
188
213
  },
189
- ]);
214
+ ];
190
215
  },
191
216
  list: async () => oysterKeysView.parse(await json("/api/keys")),
192
217
  issue: async (draft) => {
@@ -208,7 +233,6 @@ function createOysterKeysPort(oysterKeysWire) {
208
233
  },
209
234
  };
210
235
  }
211
- const directory = async () => workbenchDirectorySchema.parse(await json("/api/workbench/directory"));
212
236
  const permissionFrameMessage = z.strictObject({
213
237
  type: z.literal("oyster.permissions"),
214
238
  event: z.enum(["accepted", "state"]),
@@ -6,6 +6,7 @@ import {} from "./platform-controls.js";
6
6
  import { parseMemberAvatar } from "./member-avatar.js";
7
7
  import * as z from "zod";
8
8
  import { appOpenInputSchema, } from "@fungi.computer/agar/apps";
9
+ import { commandScopeOf } from "./app-launch.js";
9
10
  import { workbenchDirectorySchema, workbenchComputerDirectorySchema, } from "@fungi.computer/nacre/workbench-directory";
10
11
  const teamIdentitySchema = z.strictObject({
11
12
  team: z.strictObject({
@@ -158,7 +159,8 @@ export function createTourtoisShell(workbench) {
158
159
  // child's Release-validated commands, so the menu bar and Cmd-K follow focus.
159
160
  const commands = createAppSurfaceCommandHost();
160
161
  const mount = async (container, launch, signal, { onAgentSessionSelection, onDeliveryPending, onComputerChoice, onNavigation, onAppOpen, onAppRole, onSelectionChanged, onNavigationState, onStatusItems, onToast, onFocus, }) => {
161
- const commandMount = commands.mount(launch.surfaceId, launch.commands);
162
+ const scope = commandScopeOf(launch);
163
+ const commandMount = commands.mount(scope, launch.commands);
162
164
  let resolveHandle = () => undefined;
163
165
  const handleReady = new Promise((resolve) => {
164
166
  resolveHandle = resolve;
@@ -199,7 +201,7 @@ export function createTourtoisShell(workbench) {
199
201
  },
200
202
  onFocus: (focused) => {
201
203
  if (focused) {
202
- commands.focus(launch.surfaceId);
204
+ commands.focus(scope);
203
205
  onFocus?.();
204
206
  }
205
207
  return Promise.resolve();
package/dist/shell.css CHANGED
@@ -864,6 +864,47 @@
864
864
  padding: 8px;
865
865
  }
866
866
 
867
+ /* A surface Gill's App fills its tile; the App scrolls itself. */
868
+ .tourtois-gill-body:has(> .tourtois-gill-content > .tourtois-surface-body) {
869
+ overflow: hidden;
870
+ }
871
+ .tourtois-gill-body:has(> .tourtois-gill-content > .tourtois-surface-body)
872
+ > .tourtois-gill-content {
873
+ height: 100%;
874
+ }
875
+ .tourtois-surface-body {
876
+ position: relative;
877
+ height: 100%;
878
+ min-height: 0;
879
+ }
880
+ .tourtois-surface-frame {
881
+ display: flex;
882
+ height: 100%;
883
+ min-height: 0;
884
+ }
885
+ .tourtois-surface-frame > iframe {
886
+ border: 0;
887
+ display: block;
888
+ flex: 1 1 auto;
889
+ height: 100%;
890
+ min-width: 0;
891
+ width: 100%;
892
+ }
893
+ /* While arranging, the tile is dragged: no pointer reaches the App's frame. */
894
+ .tourtois-surface-shield {
895
+ position: absolute;
896
+ inset: 0;
897
+ cursor: grab;
898
+ }
899
+ .tourtois-surface-failure {
900
+ position: absolute;
901
+ inset: 0;
902
+ display: grid;
903
+ place-items: center;
904
+ padding: var(--spacing-md);
905
+ background: var(--color-base-100);
906
+ }
907
+
867
908
  /* Touch controls share the title row; reserve their height before arranging so
868
909
  entering edit mode leaves the Gill content's viewport unchanged. */
869
910
  @media (max-width: 640px), (any-pointer: coarse) {
@@ -5,6 +5,69 @@ export type WindowEvents = Required<Pick<TourtoisAppMountEvents, "onNavigation"
5
5
  /** The App's own document took focus; raise its window. */
6
6
  onAppFocus: (launch: AppLaunchDescriptor) => void;
7
7
  };
8
+ /**
9
+ * Mount an App frame into a desktop tile through the same host mount the
10
+ * windows use. A tile has no window chrome, so it takes no status or
11
+ * navigation readouts. The returned function is stable per host and Team.
12
+ */
13
+ export declare function useAppTileMount(host: TourtoisAppSurfaceHost | null, teamId: string, events: WindowEvents): (container: Parameters<TourtoisAppSurfaceHost["mount"]>[0], launch: AppLaunchDescriptor, signal: AbortSignal) => Promise<Readonly<{
14
+ setVisibility: (visibility: "hidden" | "visible") => void | Promise<void>;
15
+ reconfigure: (launch: Readonly<{
16
+ windowId: string;
17
+ surfaceId: string;
18
+ installationId: string | null;
19
+ appId: string;
20
+ releaseId: string;
21
+ title: string;
22
+ href: string;
23
+ openRequest: import("@fungi.computer/agar").AppOpenRequest | null;
24
+ commandScope?: string;
25
+ roles: readonly string[];
26
+ commands: readonly Readonly<{
27
+ id: string;
28
+ title: string;
29
+ category: string;
30
+ description?: string | undefined;
31
+ sigil?: string | undefined;
32
+ projections?: Readonly<{
33
+ bindings?: (Readonly<{
34
+ order?: number | undefined;
35
+ }> & Readonly<{
36
+ values: readonly string[];
37
+ }>) | undefined;
38
+ agent?: (Readonly<{
39
+ order?: number | undefined;
40
+ }> & Readonly<{
41
+ keybind?: string | undefined;
42
+ }>) | undefined;
43
+ help?: Readonly<{
44
+ order?: number | undefined;
45
+ }> | undefined;
46
+ menu?: Readonly<{
47
+ order?: number | undefined;
48
+ }> | undefined;
49
+ palette?: Readonly<{
50
+ order?: number | undefined;
51
+ }> | undefined;
52
+ slash?: (Readonly<{
53
+ order?: number | undefined;
54
+ }> & Readonly<{
55
+ aliases: readonly string[];
56
+ }>) | undefined;
57
+ }> | undefined;
58
+ }>[];
59
+ computers?: readonly Readonly<{
60
+ computerId: string;
61
+ name: string;
62
+ }>[];
63
+ }>, signal?: AbortSignal) => void | Promise<void>;
64
+ requestClose?: () => boolean | Promise<boolean>;
65
+ requestBack?: () => boolean | Promise<boolean>;
66
+ requestForward?: () => boolean | Promise<boolean>;
67
+ activateNavigation?: (activation: import("@fungi.computer/agar").AppNavigationActivation) => boolean | Promise<boolean>;
68
+ activateStatus?: (action: import("@fungi.computer/agar").AppStatusAction) => boolean | Promise<boolean>;
69
+ dispose: () => void | Promise<void>;
70
+ }>>;
8
71
  /** One mounted host connection owns its windows, including StrictMode teardown. */
9
72
  export declare function useAppWindowManager(host: TourtoisAppSurfaceHost | null, teamId: string, events: WindowEvents): Readonly<{
10
73
  open: (launch: Readonly<{
@@ -16,6 +79,7 @@ export declare function useAppWindowManager(host: TourtoisAppSurfaceHost | null,
16
79
  title: string;
17
80
  href: string;
18
81
  openRequest: import("@fungi.computer/agar").AppOpenRequest | null;
82
+ commandScope?: string;
19
83
  roles: readonly string[];
20
84
  commands: readonly Readonly<{
21
85
  id: string;
@@ -70,6 +134,7 @@ export declare function useAppWindowManager(host: TourtoisAppSurfaceHost | null,
70
134
  title: string;
71
135
  href: string;
72
136
  openRequest: import("@fungi.computer/agar").AppOpenRequest | null;
137
+ commandScope?: string;
73
138
  roles: readonly string[];
74
139
  commands: readonly Readonly<{
75
140
  id: string;
@@ -118,6 +183,7 @@ export declare function useAppWindowManager(host: TourtoisAppSurfaceHost | null,
118
183
  title: string;
119
184
  href: string;
120
185
  openRequest: import("@fungi.computer/agar").AppOpenRequest | null;
186
+ commandScope?: string;
121
187
  roles: readonly string[];
122
188
  commands: readonly Readonly<{
123
189
  id: string;
@@ -165,6 +231,7 @@ export declare function useAppWindowManager(host: TourtoisAppSurfaceHost | null,
165
231
  title: string;
166
232
  href: string;
167
233
  openRequest: import("@fungi.computer/agar").AppOpenRequest | null;
234
+ commandScope?: string;
168
235
  roles: readonly string[];
169
236
  commands: readonly Readonly<{
170
237
  id: string;
@@ -213,6 +280,7 @@ export declare function useAppWindowManager(host: TourtoisAppSurfaceHost | null,
213
280
  title: string;
214
281
  href: string;
215
282
  openRequest: import("@fungi.computer/agar").AppOpenRequest | null;
283
+ commandScope?: string;
216
284
  roles: readonly string[];
217
285
  commands: readonly Readonly<{
218
286
  id: string;
@@ -270,6 +338,7 @@ export declare function useAppWindowManager(host: TourtoisAppSurfaceHost | null,
270
338
  title: string;
271
339
  href: string;
272
340
  openRequest: import("@fungi.computer/agar").AppOpenRequest | null;
341
+ commandScope?: string;
273
342
  roles: readonly string[];
274
343
  commands: readonly Readonly<{
275
344
  id: string;
@@ -1,37 +1,61 @@
1
- import { useEffect, useMemo, useRef } from "react";
1
+ import { useCallback, useEffect, useMemo, useRef } from "react";
2
2
  import { showAppToast } from "./app-toast.js";
3
3
  import { createAppWindowManager, } from "./app-windows.js";
4
+ /** One App frame mounted through the host, with the shell's shared event routing. */
5
+ function mountWithShellEvents(host, teamId, latest, container, launch, signal, projectionEvents) {
6
+ if (!host)
7
+ throw new Error("App host unavailable");
8
+ return host.mount(container, launch, signal, {
9
+ ...(projectionEvents.onDeliveryPending && {
10
+ onDeliveryPending: projectionEvents.onDeliveryPending,
11
+ }),
12
+ onAgentSessionSelection: (selection) => {
13
+ if (!host.reportAgentSessionSelection)
14
+ return Promise.reject(new Error("Hub Agent browser host unavailable"));
15
+ return Promise.resolve(host.reportAgentSessionSelection(teamId, launch.windowId, selection)).then(() => undefined);
16
+ },
17
+ onNavigation: (input) => latest.current.onNavigation(input),
18
+ onAppOpen: (input) => latest.current.onAppOpen(input),
19
+ onAppRole: (role) => latest.current.onAppRole(role),
20
+ onSelectionChanged: () => latest.current.onSelectionChanged(launch),
21
+ onFocus: () => {
22
+ latest.current.onAppFocus(launch);
23
+ },
24
+ ...(projectionEvents.onNavigationState && {
25
+ onNavigationState: projectionEvents.onNavigationState,
26
+ }),
27
+ ...(projectionEvents.onStatusItems && {
28
+ onStatusItems: projectionEvents.onStatusItems,
29
+ }),
30
+ onToast: showAppToast,
31
+ ...(projectionEvents.onComputerChoice && {
32
+ onComputerChoice: projectionEvents.onComputerChoice,
33
+ }),
34
+ });
35
+ }
36
+ /**
37
+ * Mount an App frame into a desktop tile through the same host mount the
38
+ * windows use. A tile has no window chrome, so it takes no status or
39
+ * navigation readouts. The returned function is stable per host and Team.
40
+ */
41
+ export function useAppTileMount(host, teamId, events) {
42
+ // A tile is not a window: it neither raises one nor replaces one when the
43
+ // App's selection changes. The shell's command focus follows the frame itself.
44
+ const latest = useRef(events);
45
+ latest.current = {
46
+ ...events,
47
+ onAppFocus: () => undefined,
48
+ onSelectionChanged: () => Promise.resolve(false),
49
+ };
50
+ return useCallback(async (container, launch, signal) => await mountWithShellEvents(host, teamId, latest, container, launch, signal, {}), [host, teamId]);
51
+ }
4
52
  /** One mounted host connection owns its windows, including StrictMode teardown. */
5
53
  export function useAppWindowManager(host, teamId, events) {
6
54
  const latest = useRef(events);
7
55
  latest.current = events;
8
56
  const manager = useMemo(() => createAppWindowManager({
9
57
  waitForAttachment: true,
10
- mount: async (container, launch, signal, projectionEvents) => {
11
- if (!host)
12
- throw new Error("App host unavailable");
13
- return await host.mount(container, launch, signal, {
14
- ...(projectionEvents.onDeliveryPending && {
15
- onDeliveryPending: projectionEvents.onDeliveryPending,
16
- }),
17
- onAgentSessionSelection: (selection) => {
18
- if (!host.reportAgentSessionSelection)
19
- return Promise.reject(new Error("Hub Agent browser host unavailable"));
20
- return Promise.resolve(host.reportAgentSessionSelection(teamId, launch.windowId, selection)).then(() => undefined);
21
- },
22
- onNavigation: (input) => latest.current.onNavigation(input),
23
- onAppOpen: (input) => latest.current.onAppOpen(input),
24
- onAppRole: (role) => latest.current.onAppRole(role),
25
- onSelectionChanged: () => latest.current.onSelectionChanged(launch),
26
- onFocus: () => {
27
- latest.current.onAppFocus(launch);
28
- },
29
- onNavigationState: projectionEvents.onNavigationState,
30
- onStatusItems: projectionEvents.onStatusItems,
31
- onToast: showAppToast,
32
- onComputerChoice: projectionEvents.onComputerChoice,
33
- });
34
- },
58
+ mount: async (container, launch, signal, projectionEvents) => await mountWithShellEvents(host, teamId, latest, container, launch, signal, projectionEvents),
35
59
  }), [host, teamId]);
36
60
  const setups = useRef(new Map());
37
61
  useEffect(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fungi.computer/tourtois",
3
- "version": "0.23.1",
3
+ "version": "0.24.1",
4
4
  "author": "Levi <levi@technomancy.dev>",
5
5
  "description": "Tourtois: the trusted desktop shell for Oyster and Fungi, with host-supplied Settings sections",
6
6
  "type": "module",
@@ -73,15 +73,15 @@
73
73
  "LICENSE"
74
74
  ],
75
75
  "dependencies": {
76
- "@fungi.computer/agar": "0.21.0",
76
+ "@fungi.computer/agar": "0.22.1",
77
77
  "@fungi.computer/cairn": "0.1.0",
78
- "@fungi.computer/caps": "0.12.0",
78
+ "@fungi.computer/caps": "0.12.1",
79
79
  "@fungi.computer/ear-tag": "0.1.0",
80
80
  "@fungi.computer/gills": "0.4.0",
81
81
  "@fungi.computer/maosaico": "0.1.2",
82
- "@fungi.computer/parakeet": "0.13.1",
83
- "@fungi.computer/puffball": "0.11.0",
84
- "@fungi.computer/shiitake": "0.20.2",
82
+ "@fungi.computer/parakeet": "0.13.3",
83
+ "@fungi.computer/puffball": "0.12.0",
84
+ "@fungi.computer/shiitake": "0.20.4",
85
85
  "@fungi.computer/sigils": "0.3.2",
86
86
  "@fungi.computer/sprite": "0.2.2",
87
87
  "@fungi.computer/sprite-zdog": "0.3.2",
@@ -96,16 +96,16 @@
96
96
  "lucide-react": "0.460.0",
97
97
  "react-dom": "18.3.1",
98
98
  "zod": "4.4.3",
99
- "@fungi.computer/nacre": "0.8.0"
99
+ "@fungi.computer/nacre": "0.8.2"
100
100
  },
101
101
  "peerDependencies": {
102
102
  "react": "^18.3.1 || ^19.2.0"
103
103
  },
104
104
  "devDependencies": {
105
- "@fungi.computer/oyster": "0.37.2",
105
+ "@fungi.computer/oyster": "0.38.1",
106
106
  "@cloudflare/workers-types": "5.20260828.1",
107
- "@fungi.computer/forage": "0.3.12",
108
- "@fungi.computer/mycelium": "0.4.5",
107
+ "@fungi.computer/forage": "0.3.13",
108
+ "@fungi.computer/mycelium": "0.4.6",
109
109
  "@ladle/react": "5.1.1",
110
110
  "@types/react": "18.3.3",
111
111
  "@vitejs/plugin-react": "6.1.1",
@@ -250,7 +250,7 @@
250
250
  "workbench:build": "ladle build --outDir ../../.botanical/tourtois-ladle",
251
251
  "test:overlay-layering": "node test/overlay-layering.browser.mjs",
252
252
  "test:window-new-version": "node test/window-new-version.browser.mjs",
253
- "test:workbench": "node test/workbench.browser.mjs && node test/desktop-gills.browser.mjs && node test/app-directory-isolation.browser.mjs && node test/workflows-launcher-icon.browser.mjs && node test/landing-bugs.browser.mjs && node test/show-desktop.browser.mjs && node test/window-stack.browser.mjs && node test/window-chrome-back.browser.mjs && node test/tile-backdrop.browser.mjs && node test/app-bar-menu.browser.mjs && node test/launcher-gill.browser.mjs && node test/desktop-storage.browser.mjs && node test/desktop-method-editing.browser.mjs && node test/arrange-layout-shift.browser.mjs && node test/phone-layout.browser.mjs && node test/phone-app-switcher.browser.mjs && node test/computer-choice.browser.mjs && node test/window-resize.browser.mjs && node test/window-session.browser.mjs",
253
+ "test:workbench": "node test/workbench.browser.mjs && node test/desktop-gills.browser.mjs && node test/app-directory-isolation.browser.mjs && node test/workflows-launcher-icon.browser.mjs && node test/landing-bugs.browser.mjs && node test/show-desktop.browser.mjs && node test/window-stack.browser.mjs && node test/window-chrome-back.browser.mjs && node test/tile-backdrop.browser.mjs && node test/app-bar-menu.browser.mjs && node test/launcher-gill.browser.mjs && node test/desktop-storage.browser.mjs && node test/desktop-method-editing.browser.mjs && node test/arrange-layout-shift.browser.mjs && node test/surface-gill.browser.mjs && node test/phone-layout.browser.mjs && node test/phone-app-switcher.browser.mjs && node test/computer-choice.browser.mjs && node test/window-resize.browser.mjs && node test/window-session.browser.mjs",
254
254
  "test": "pnpm run test:unit && pnpm run test:merge",
255
255
  "test:settings-icons": "node --import tsx ../../tooling/repository/scripts/workbench-proofs.mjs --output ../../.botanical/tourtois-ladle --origin-env TOURTOIS_WORKBENCH_URL test/settings-icons.browser.mjs",
256
256
  "format:check": "node ../../tooling/repository/scripts/format-package-check.mjs",