@fungi.computer/tourtois 0.10.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,145 @@
1
+ /* Arrange mode edits in place: nothing here changes a tile's frame or the
2
+ flow around it. Visuals come from Caps; this file only places things. */
3
+ .tourtois-desktop-tile-body {
4
+ height: 100%;
5
+ min-width: 0;
6
+ }
7
+
8
+ /* The tile's own dashed ring, at the card's radius, drawn over its edge. */
9
+ .tourtois-desktop-stage[data-arranging] .tourtois-desktop-tile::after {
10
+ content: "";
11
+ position: absolute;
12
+ inset: 0;
13
+ border: 1px dashed var(--stipe-linework);
14
+ border-radius: var(--radius-box);
15
+ pointer-events: none;
16
+ }
17
+ /* Room for the overlay beside the title; only truncation changes. */
18
+ .tourtois-desktop-stage[data-arranging] .tourtois-gill-frame .caps-card-title {
19
+ padding-inline-end: 9rem;
20
+ }
21
+
22
+ .tourtois-arrange-controls {
23
+ position: absolute;
24
+ inset-block-start: var(--spacing-lg);
25
+ inset-inline-end: var(--spacing-md);
26
+ display: flex;
27
+ align-items: center;
28
+ gap: var(--spacing-2xs);
29
+ }
30
+
31
+ .tourtois-arrange {
32
+ position: absolute;
33
+ inset-inline: 0;
34
+ inset-block-end: calc(env(safe-area-inset-bottom, 0px) + 16px);
35
+ inline-size: max-content;
36
+ max-inline-size: calc(100vw - 32px);
37
+ margin-inline: auto;
38
+ box-sizing: border-box;
39
+ display: flex;
40
+ align-items: center;
41
+ gap: var(--spacing-sm);
42
+ padding: var(--spacing-xs) var(--spacing-sm);
43
+ pointer-events: auto;
44
+ }
45
+ .tourtois-arrange-add {
46
+ display: inline-flex;
47
+ }
48
+ .tourtois-arrange-state {
49
+ display: inline-flex;
50
+ align-items: center;
51
+ margin-inline-start: auto;
52
+ font-size: var(--text-xs);
53
+ }
54
+ .tourtois-arrange-state[data-empty] {
55
+ display: none;
56
+ }
57
+ /* Scroll room so the bar never hides the last widget; frames are untouched. */
58
+ .tourtois-desktop-stage[data-arranging] {
59
+ margin-block-end: 6rem;
60
+ }
61
+
62
+ .tourtois-widget-picker {
63
+ inline-size: min(22rem, calc(100vw - 32px));
64
+ inset-inline: 0 auto;
65
+ gap: var(--spacing-xs);
66
+ }
67
+ .tourtois-widget-list {
68
+ display: flex;
69
+ flex-direction: column;
70
+ min-block-size: 0;
71
+ }
72
+ .tourtois-widget-picker .caps-popover-option {
73
+ align-items: center;
74
+ }
75
+ .tourtois-widget-icon {
76
+ display: inline-flex;
77
+ inline-size: 1.5rem;
78
+ block-size: 1.5rem;
79
+ flex: none;
80
+ }
81
+ .tourtois-widget-icon > * {
82
+ inline-size: 100%;
83
+ block-size: 100%;
84
+ }
85
+ .tourtois-widget-text {
86
+ display: grid;
87
+ min-inline-size: 0;
88
+ flex: 1;
89
+ }
90
+ .tourtois-widget-text small,
91
+ .tourtois-widget-picker small {
92
+ color: var(--stipe-fg-muted);
93
+ font-size: var(--text-xs);
94
+ }
95
+ .tourtois-widget-none {
96
+ padding: var(--spacing-sm);
97
+ color: var(--stipe-fg-muted);
98
+ font-size: var(--text-sm);
99
+ }
100
+
101
+ /* Phone: a full-width bottom bar, with the picker rising from it. */
102
+ @media (max-width: 640px) {
103
+ .tourtois-arrange {
104
+ inset-block-end: 0;
105
+ inline-size: auto;
106
+ max-inline-size: none;
107
+ margin-inline: 0;
108
+ padding-block-end: calc(
109
+ env(safe-area-inset-bottom, 0px) + var(--spacing-xs)
110
+ );
111
+ }
112
+ .tourtois-arrange-add {
113
+ position: static;
114
+ }
115
+ .tourtois-widget-picker {
116
+ inline-size: auto;
117
+ inset-inline: 0;
118
+ max-block-size: 60vh;
119
+ inset-block-end: 100%;
120
+ margin-block-end: var(--spacing-xs);
121
+ }
122
+ /* Five touch targets and the title share one row: keep them tight. */
123
+ .tourtois-arrange-controls {
124
+ inset-block-start: var(--spacing-xl);
125
+ }
126
+ .tourtois-desktop-stage[data-arranging]
127
+ .tourtois-gill-frame
128
+ .caps-card-title {
129
+ padding-inline-end: 15rem;
130
+ }
131
+ }
132
+
133
+ .tourtois-widget-picker .caps-popover-option > small:last-child {
134
+ opacity: 0.7;
135
+ white-space: nowrap;
136
+ }
137
+
138
+ /* Each button's touch hit area reaches 7px past its face, so neighbours
139
+ need 14px between faces or one steals the other's edge. */
140
+ @media (max-width: 640px), (any-pointer: coarse) {
141
+ .tourtois-arrange-controls,
142
+ .tourtois-arrange-controls .tourtois-gill-sizes {
143
+ gap: var(--spacing-lg);
144
+ }
145
+ }
@@ -6,10 +6,15 @@ import { DataList, DataRow } from "@fungi.computer/caps/components/data-list";
6
6
  import { Select } from "@fungi.computer/caps/components/select";
7
7
  import { EmptyState } from "@fungi.computer/caps/blocks/empty-state";
8
8
  import { Sigil } from "@fungi.computer/sigils";
9
+ import { ExternalLink } from "lucide-react";
9
10
  import { GillFrame } from "./gill-frame.js";
11
+ import { FirstRunWelcome, useWelcome } from "./welcome.js";
12
+ import { LoadingState } from "@fungi.computer/caps/blocks/loading-state";
13
+ const installDocs = "https://docs.fungi.computer/oyster-quickstart/";
10
14
  /** Trusted shell Gill. Defaults to the same complete launchable set/order as the AppBar. */
11
15
  export function LauncherGill({ items, size = "M", onAllApps, loading = false, unavailable = false, onRetry, warnings = [], preferences, onPreference, editHandle, onContentHeight, }) {
12
16
  const [editing, setEditing] = useState(false);
17
+ const welcome = useWelcome();
13
18
  const stateFor = (id) => preferences.hidden.includes(id)
14
19
  ? "Hidden"
15
20
  : preferences.pinned.includes(id)
@@ -29,7 +34,7 @@ export function LauncherGill({ items, size = "M", onAllApps, loading = false, un
29
34
  const ready = !loading && !unavailable;
30
35
  return (_jsxs(GillFrame, { title: "Launcher", size: size, onContentHeight: onContentHeight, editHandle: editHandle ?? (_jsx(Button, { size: "xs", variant: "outline", "aria-expanded": editing, onClick: () => {
31
36
  setEditing(!editing);
32
- }, children: editing ? "Done" : "Edit launcher" })), children: [loading ? _jsx("p", { role: "status", children: "Loading Apps\u2026" }) : null, unavailable ? (_jsxs("p", { role: "alert", children: ["App directory unavailable.", " ", onRetry ? (_jsx(Button, { size: "sm", variant: "ghost", onClick: onRetry, children: "Retry" })) : null] })) : null, ready ? (_jsxs(_Fragment, { children: [items.length === 0 ? (_jsx(EmptyState, { variant: "hint", title: "No Apps available", description: "Installed launchable Apps appear here." })) : null, items.length > 0 && shown.length === 0 ? (_jsx("p", { children: "No Apps shown. Edit the launcher to show them again." })) : null, _jsx(AppGrid, { "aria-label": "Team Apps", items: [
37
+ }, children: editing ? "Done" : "Edit launcher" })), children: [loading ? _jsx(LoadingState, { message: "Loading Apps\u2026" }) : null, unavailable ? (_jsxs("p", { role: "alert", children: ["App directory unavailable.", " ", onRetry ? (_jsx(Button, { size: "sm", variant: "ghost", onClick: onRetry, children: "Retry" })) : null] })) : null, ready ? (_jsxs(_Fragment, { children: [welcome.visible ? (_jsx(FirstRunWelcome, { items: items, onDismiss: welcome.dismiss })) : null, items.length === 0 ? (_jsx(EmptyState, { variant: "hint", title: "No Apps available", description: "Installed launchable Apps appear here." })) : null, items.length > 0 && shown.length === 0 ? (_jsx("p", { children: "No Apps shown. Edit the launcher to show them again." })) : null, _jsx(AppGrid, { "aria-label": "Apps", items: [
33
38
  ...tiles,
34
39
  ...warnings,
35
40
  {
@@ -38,7 +43,9 @@ export function LauncherGill({ items, size = "M", onAllApps, loading = false, un
38
43
  icon: _jsx(Sigil, { name: "allApps" }),
39
44
  onSelect: onAllApps,
40
45
  },
41
- ], size: "lg" }), editing ? (_jsx(DataList, { "aria-label": "Launcher preferences", children: items.map((item) => (_jsx(DataRow, { children: _jsxs("div", { className: "tourtois-launcher-preference", children: [_jsx("span", { "aria-hidden": "true", className: "grid size-6 place-items-center [&_svg]:size-full", children: item.icon ?? _jsx(Sigil, { name: "installApps" }) }), _jsx("div", { className: "tourtois-launcher-preference-identity", children: _jsx("span", { children: item.label }) }), _jsxs(Select, { "aria-label": `Launcher state for ${item.label}`, value: stateFor(item.id), onChange: (event) => {
46
+ ], size: "lg" }), _jsx("div", { className: "tourtois-launcher-more", children: _jsxs(Button, { size: "sm", variant: "ghost", onClick: () => {
47
+ window.open(installDocs, "_blank", "noopener,noreferrer");
48
+ }, children: ["More Apps", _jsx(ExternalLink, { "aria-hidden": "true", size: 14 })] }) }), editing ? (_jsx(DataList, { "aria-label": "Launcher preferences", children: items.map((item) => (_jsx(DataRow, { children: _jsxs("div", { className: "tourtois-launcher-preference", children: [_jsx("span", { "aria-hidden": "true", className: "grid size-6 place-items-center [&_svg]:size-full", children: item.icon ?? _jsx(Sigil, { name: "installApps" }) }), _jsx("div", { className: "tourtois-launcher-preference-identity", children: _jsx("span", { children: item.label }) }), _jsxs(Select, { "aria-label": `Launcher state for ${item.label}`, value: stateFor(item.id), onChange: (event) => {
42
49
  const value = event.currentTarget.value;
43
50
  if (value !== "Pinned" &&
44
51
  value !== "Shown" &&
@@ -125,7 +125,11 @@ export function RowGill({ surfaceId, appHeader, declaration, params, size, pause
125
125
  ? `${response.title} isn't available on this preview. Open ${launch.label}.`
126
126
  : response.error }), recoveryParam && onConfigure ? (_jsxs(Button, { size: "sm", variant: "primary", onClick: onConfigure, children: ["Choose ", recoveryParam.label] })) : null, opensApp && launch ? (_jsxs(Button, { size: "sm", variant: "primary", onClick: () => {
127
127
  launch.onSelect();
128
- }, children: ["Open ", launch.label] })) : null] })) : null, response?.state === "empty" ? (_jsx(EmptyState, { variant: "hint", title: `No ${response.title} items yet`, description: `${response.title} items appear here when available.` })) : null, response?.state === "full" ? (_jsx(DataList, { "aria-label": `${response.title} rows`, density: "compact", children: response.rows.map((row) => (_jsx(DataRow, { children: row.open ? (_jsx(ActionRow, { density: "compact", label: row.title, description: detail(row), trailing: rowStatus(row), "aria-label": `Open: ${row.title}`, onClick: () => {
128
+ }, children: ["Open ", launch.label] })) : null] })) : null, response?.state === "empty" ? (_jsx(EmptyState, { variant: "quiet", title: response.emptyText ?? "Nothing here yet.", description: null, actions: launch &&
129
+ (response.action?.kind === "open" ||
130
+ response.emptyText === undefined) ? (_jsxs(Button, { size: "sm", variant: "outline", onClick: () => {
131
+ launch.onSelect();
132
+ }, children: ["Open ", launch.label] })) : null })) : null, response?.state === "full" ? (_jsx(DataList, { "aria-label": `${response.title} rows`, density: "compact", children: response.rows.map((row) => (_jsx(DataRow, { children: row.open ? (_jsx(ActionRow, { density: "compact", label: row.title, description: detail(row), trailing: rowStatus(row), "aria-label": `Open: ${row.title}`, onClick: () => {
129
133
  if (row.open)
130
134
  onOpen(row.open);
131
135
  } })) : (_jsxs(_Fragment, { children: [_jsxs("div", { className: "tourtois-gill-text-row", children: [_jsx("span", { children: row.title }), row.detail ? _jsx("small", { children: detail(row) }) : null] }), rowStatus(row)] })) }, row.id))) })) : null, pages.length > 1 ? (_jsx(Button, { size: "sm", variant: "ghost", disabled: paused, onClick: () => {
@@ -0,0 +1,70 @@
1
+ /* The first-run welcome: one compact card across the Launcher. */
2
+ .tourtois-welcome {
3
+ display: flex;
4
+ align-items: center;
5
+ gap: var(--spacing-lg);
6
+ padding: var(--spacing-md) var(--spacing-lg);
7
+ margin-block-end: var(--spacing-lg);
8
+ /* The App tiles sit 9px inside the Launcher; the card shares their left edge. */
9
+ margin-inline: calc(var(--spacing-sm) + 1px);
10
+ border: var(--border) solid
11
+ color-mix(in oklab, var(--color-base-content) 12%, transparent);
12
+ border-radius: var(--radius-box);
13
+ background: color-mix(in oklab, var(--color-base-100) 70%, transparent);
14
+ }
15
+ .tourtois-welcome-mascot {
16
+ display: block;
17
+ flex: none;
18
+ inline-size: 3rem;
19
+ block-size: 3rem;
20
+ }
21
+ .tourtois-welcome-text {
22
+ flex: 1;
23
+ min-inline-size: 0;
24
+ }
25
+ .tourtois-welcome-text h3 {
26
+ margin: 0;
27
+ font-size: var(--text-base);
28
+ font-weight: 600;
29
+ line-height: 1.3;
30
+ }
31
+ .tourtois-welcome-text p {
32
+ margin: 0;
33
+ color: var(--stipe-fg-muted);
34
+ font-size: var(--text-sm);
35
+ line-height: 1.4;
36
+ }
37
+ .tourtois-welcome-text .tourtois-welcome-hint {
38
+ margin-block-start: var(--spacing-2xs);
39
+ font-size: var(--text-xs);
40
+ }
41
+ .tourtois-welcome-actions {
42
+ display: flex;
43
+ flex: none;
44
+ align-items: center;
45
+ gap: var(--spacing-sm);
46
+ }
47
+ @media (max-width: 640px) {
48
+ .tourtois-welcome {
49
+ flex-wrap: wrap;
50
+ gap: var(--spacing-md);
51
+ }
52
+ .tourtois-welcome-text {
53
+ flex-basis: calc(100% - 4rem);
54
+ }
55
+ .tourtois-welcome-actions {
56
+ flex: 1 1 100%;
57
+ }
58
+ .tourtois-welcome-actions > * {
59
+ flex: 1;
60
+ }
61
+ }
62
+
63
+ /* The install guide is a quiet footer row under the grid, not an App tile. */
64
+ .tourtois-launcher-more {
65
+ display: flex;
66
+ justify-content: flex-end;
67
+ /* The ghost button's own padding would pull its text off the grid's edge. */
68
+ margin-inline-end: calc(-1 * (var(--spacing-md) + 1px));
69
+ margin-block-start: var(--spacing-sm);
70
+ }
@@ -0,0 +1,20 @@
1
+ import { type ReactNode } from "react";
2
+ import type { AppStorage } from "@fungi.computer/agar/storage";
3
+ import type { AppBarItem } from "@fungi.computer/caps/blocks/app-bar";
4
+ export type WelcomeState = Readonly<{
5
+ /** True only once storage has answered that this member has not dismissed it. */
6
+ visible: boolean;
7
+ dismiss: () => void;
8
+ }>;
9
+ /** The per-member first-run welcome, remembered in the member's own storage layer. */
10
+ export declare function WelcomeProvider({ teamId, storage, children, }: {
11
+ teamId: string;
12
+ storage: AppStorage;
13
+ children: ReactNode;
14
+ }): import("react/jsx-runtime").JSX.Element;
15
+ export declare const useWelcome: () => WelcomeState;
16
+ /** Says what this place is and points at the one thing to do next. */
17
+ export declare function FirstRunWelcome({ items, onDismiss, }: {
18
+ items: readonly AppBarItem[];
19
+ onDismiss: () => void;
20
+ }): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,61 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { createContext, useCallback, useContext, useMemo, } from "react";
3
+ import { useQuery, useQueryClient } from "@tanstack/react-query";
4
+ import { z } from "zod";
5
+ import { Button } from "@fungi.computer/caps/components/button";
6
+ import { Keycap } from "@fungi.computer/caps/components/keycap";
7
+ import { ShiitakeAvatar } from "@fungi.computer/parakeet/agent-head";
8
+ const welcomeKey = "welcome";
9
+ const dismissedSchema = z.object({ dismissed: z.literal(true) });
10
+ const hidden = { visible: false, dismiss: () => undefined };
11
+ const WelcomeContext = createContext(hidden);
12
+ /** The per-member first-run welcome, remembered in the member's own storage layer. */
13
+ export function WelcomeProvider({ teamId, storage, children, }) {
14
+ const client = useQueryClient();
15
+ const queryKey = useMemo(() => ["tourtois", "welcome", teamId], [teamId]);
16
+ const { data } = useQuery({
17
+ queryKey,
18
+ queryFn: async () => {
19
+ const resolved = await storage.read(welcomeKey);
20
+ return {
21
+ revision: resolved.member?.revision ?? null,
22
+ dismissed: dismissedSchema.safeParse(resolved.member?.value).success,
23
+ };
24
+ },
25
+ });
26
+ const dismiss = useCallback(() => {
27
+ client.setQueryData(queryKey, {
28
+ revision: data?.revision ?? null,
29
+ dismissed: true,
30
+ });
31
+ void storage
32
+ .write({
33
+ key: welcomeKey,
34
+ scope: "member",
35
+ basedOn: data?.revision ?? null,
36
+ value: { dismissed: true },
37
+ })
38
+ .catch((cause) => {
39
+ console.error("Welcome dismissal was not saved", cause);
40
+ });
41
+ }, [client, data?.revision, queryKey, storage]);
42
+ const value = useMemo(() => ({ visible: data !== undefined && !data.dismissed, dismiss }), [data, dismiss]);
43
+ return (_jsx(WelcomeContext.Provider, { value: value, children: children }));
44
+ }
45
+ export const useWelcome = () => useContext(WelcomeContext);
46
+ const isMac = () => /Mac|iPhone|iPad/u.test(navigator.userAgent);
47
+ /** Starters are matched by their App id in the launcher's `app:<surface>` ids. */
48
+ const starter = (items, appId) => items.find((item) => item.id === `app:${appId}`);
49
+ /** Says what this place is and points at the one thing to do next. */
50
+ export function FirstRunWelcome({ items, onDismiss, }) {
51
+ const hello = starter(items, "hello");
52
+ const first = starter(items, "grove") ?? items.find((item) => item !== hello);
53
+ if (!first && !hello)
54
+ return null;
55
+ const lead = first ?? hello;
56
+ if (!lead)
57
+ return null;
58
+ return (_jsxs("section", { className: "tourtois-welcome", "aria-labelledby": "tourtois-welcome-title", children: [_jsx("span", { className: "tourtois-welcome-mascot", "aria-hidden": "true", children: _jsx(ShiitakeAvatar, { className: "h-full w-full", state: { activity: "idle", expression: "normal" } }) }), _jsxs("div", { className: "tourtois-welcome-text", children: [_jsx("h3", { id: "tourtois-welcome-title", children: "This is your Oyster" }), _jsx("p", { children: "Apps open here as windows." }), _jsxs("p", { className: "tourtois-welcome-hint", children: [_jsx(Keycap, { size: "hint", children: isMac() ? "⌘" : "Ctrl" }), " ", _jsx(Keycap, { size: "hint", children: "K" }), " then ", _jsx(Keycap, { size: "hint", children: "O" }), " ", "opens any App"] })] }), _jsxs("div", { className: "tourtois-welcome-actions", children: [_jsxs(Button, { size: "sm", variant: "primary", onClick: () => {
59
+ lead.onSelect();
60
+ }, children: ["Open ", lead.label] }), _jsx(Button, { size: "sm", variant: "ghost", onClick: onDismiss, children: "Not now" })] })] }));
61
+ }
@@ -0,0 +1,19 @@
1
+ import { type ReactNode } from "react";
2
+ import type { DesktopGill } from "../desktop-layout.js";
3
+ /** One placeable widget, with the App that owns it. */
4
+ export type WidgetChoice = Readonly<{
5
+ gill: DesktopGill;
6
+ appName: string;
7
+ /** Already on the desktop; still choosable, listed after the rest. */
8
+ placed: boolean;
9
+ icon: ReactNode;
10
+ }>;
11
+ /**
12
+ * A floating, searchable list of widgets. It never takes the page's focus
13
+ * away from its search box and stays open so several can be added in a row.
14
+ */
15
+ export declare function WidgetPicker({ choices, disabled, onChoose, }: {
16
+ choices: readonly WidgetChoice[];
17
+ disabled: boolean;
18
+ onChoose: (gill: DesktopGill) => void;
19
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,40 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ import { Input } from "@fungi.computer/caps/components/input";
4
+ import { Popover, PopoverOption, } from "@fungi.computer/caps/components/popover";
5
+ /**
6
+ * A floating, searchable list of widgets. It never takes the page's focus
7
+ * away from its search box and stays open so several can be added in a row.
8
+ */
9
+ export function WidgetPicker({ choices, disabled, onChoose, }) {
10
+ const [query, setQuery] = useState("");
11
+ const [active, setActive] = useState(0);
12
+ const needle = query.trim().toLowerCase();
13
+ const shown = choices
14
+ .filter((choice) => `${choice.gill.title} ${choice.appName}`.toLowerCase().includes(needle))
15
+ .sort((a, b) => Number(a.placed) - Number(b.placed));
16
+ const current = Math.min(active, Math.max(0, shown.length - 1));
17
+ const choose = (choice) => {
18
+ if (choice && !disabled)
19
+ onChoose(choice.gill);
20
+ };
21
+ return (_jsxs(Popover, { open: true, side: "top", className: "tourtois-widget-picker", "aria-label": "Add widget", children: [_jsx(Input, { autoFocus: true, "aria-label": "Search widgets", placeholder: "Search widgets", value: query, onChange: (event) => {
22
+ setQuery(event.currentTarget.value);
23
+ setActive(0);
24
+ }, onKeyDown: (event) => {
25
+ if (event.key === "ArrowDown") {
26
+ event.preventDefault();
27
+ setActive(Math.min(shown.length - 1, current + 1));
28
+ }
29
+ else if (event.key === "ArrowUp") {
30
+ event.preventDefault();
31
+ setActive(Math.max(0, current - 1));
32
+ }
33
+ else if (event.key === "Enter") {
34
+ event.preventDefault();
35
+ choose(shown[current]);
36
+ }
37
+ } }), _jsxs("div", { role: "listbox", "aria-label": "Widgets", className: "tourtois-widget-list", children: [shown.map((choice, index) => (_jsxs(PopoverOption, { active: index === current, "aria-label": `${choice.gill.title}, ${choice.appName}`, onClick: () => {
38
+ choose(choice);
39
+ }, children: [_jsx("span", { "aria-hidden": "true", className: "tourtois-widget-icon", children: choice.icon }), _jsxs("span", { className: "tourtois-widget-text", children: [_jsx("span", { children: choice.gill.title }), _jsx("small", { children: choice.appName })] }), choice.placed ? _jsx("small", { children: "On desktop" }) : null] }, `${choice.gill.surfaceId}:${choice.gill.gillId}`))), shown.length === 0 ? (_jsx("p", { className: "tourtois-widget-none", children: "No widgets match." })) : null] })] }));
40
+ }
@@ -148,8 +148,9 @@ export function initialDesktopLayout(catalog, inboxSurfaceId) {
148
148
  id: "launcher",
149
149
  surfaceId: "tourtois",
150
150
  gillId: "launcher",
151
- size: "M",
152
- col: inbox ? 2 : 0,
151
+ // Alone, the Launcher is the desktop: wide and centred in four columns.
152
+ size: inbox ? "M" : "L",
153
+ col: inbox ? 2 : 1,
153
154
  row: 0,
154
155
  },
155
156
  ],
package/dist/layers.d.ts CHANGED
@@ -1,4 +1,9 @@
1
1
  import { type ReactNode } from "react";
2
+ /**
3
+ * Close every transient popover through the overlay dismiss channel. A window
4
+ * bar calls this as one of its popovers opens, so two never stack.
5
+ */
6
+ export declare function useDismissOverlays(): () => void;
2
7
  /** Tourtois composes Caps portal destinations with Maosaico's ordered roots. */
3
8
  export declare function TourtoisLayers({ children }: {
4
9
  children?: ReactNode;
package/dist/layers.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { OverlayRoot } from "@fungi.computer/caps/components/overlay-root";
3
3
  import { MaosaicoLayers, useLayer } from "@fungi.computer/maosaico";
4
- import { useMemo } from "react";
4
+ import { createContext, useContext, useMemo } from "react";
5
5
  function OverlayContainers({ children, subscribeDismiss, }) {
6
6
  const popover = useLayer("popover");
7
7
  const dialog = useLayer("dialog");
@@ -10,6 +10,14 @@ function OverlayContainers({ children, subscribeDismiss, }) {
10
10
  const containers = useMemo(() => ({ popover, dialog, toast, tooltip }), [popover, dialog, toast, tooltip]);
11
11
  return (_jsx(OverlayRoot, { containers: containers, subscribeDismiss: subscribeDismiss, children: children }));
12
12
  }
13
+ const DismissContext = createContext(() => undefined);
14
+ /**
15
+ * Close every transient popover through the overlay dismiss channel. A window
16
+ * bar calls this as one of its popovers opens, so two never stack.
17
+ */
18
+ export function useDismissOverlays() {
19
+ return useContext(DismissContext);
20
+ }
13
21
  /** Tourtois composes Caps portal destinations with Maosaico's ordered roots. */
14
22
  export function TourtoisLayers({ children }) {
15
23
  const dismissal = useMemo(() => {
@@ -27,5 +35,5 @@ export function TourtoisLayers({ children }) {
27
35
  },
28
36
  };
29
37
  }, []);
30
- return (_jsx(MaosaicoLayers, { onDismiss: dismissal.dismiss, children: _jsx(OverlayContainers, { subscribeDismiss: dismissal.subscribe, children: children }) }));
38
+ return (_jsx(MaosaicoLayers, { onDismiss: dismissal.dismiss, children: _jsx(DismissContext.Provider, { value: dismissal.dismiss, children: _jsx(OverlayContainers, { subscribeDismiss: dismissal.subscribe, children: children }) }) }));
31
39
  }
@@ -14,6 +14,7 @@ import { z } from "zod";
14
14
  import { useEffect, useRef, useState } from "react";
15
15
  import { createRoot } from "react-dom/client";
16
16
  import { connectionAddedSchema, connectionsViewSchema, connectionToolsSchema, createPlatformControls, PlatformControlsView, } from "./platform-controls.js";
17
+ import { createOysterSetupPort, oysterSetupSchema } from "./oyster-setup.js";
17
18
  import { modelKeysViewSchema } from "./ModelKeys.js";
18
19
  import { settingsLocationSchema } from "./settings-routes.js";
19
20
  import { OysterComputers, createOysterComputersPort, } from "./OysterComputers.js";
@@ -281,6 +282,25 @@ export const mountPlatformControls = (root, input) => {
281
282
  const computers = () => (_jsx(OysterComputers, { teamId: input.teamId, port: computersPort, onChanged: controls.changed }));
282
283
  const websitesPort = createOysterWebsiteChannelsPort(new URL(window.location.origin));
283
284
  const channels = () => (_jsx(WebsiteChannels, { port: websitesPort, copy: oysterWebsiteCopy }));
285
+ const setup = createOysterSetupPort({
286
+ readFacts: async () => oysterSetupSchema.parse(await json("/api/setup")),
287
+ openSettings: (location) => {
288
+ controls.openSettings(location, { restoreFocus: false });
289
+ },
290
+ subscribeSettingsClosed: controls.subscribeSettingsClosed,
291
+ });
292
+ // A key added or removed changes what is ready before Settings closes.
293
+ const trackedModelKeys = {
294
+ ...modelKeys,
295
+ addKey: async (draft) => {
296
+ await modelKeys.addKey(draft);
297
+ setup.changed();
298
+ },
299
+ removeKey: async (keyId) => {
300
+ await modelKeys.removeKey(keyId);
301
+ setup.changed();
302
+ },
303
+ };
284
304
  const client = createQueryClient();
285
305
  const settings = createRoot(root);
286
306
  settings.render(_jsx(QueryClientProvider, { client: client, children: _jsx(PlatformControlsView, { teamId: input.teamId, controls: controls, data: {
@@ -289,13 +309,14 @@ export const mountPlatformControls = (root, input) => {
289
309
  computers,
290
310
  channels,
291
311
  keys,
292
- modelKeys,
312
+ modelKeys: trackedModelKeys,
293
313
  requestAppAccess,
294
314
  appPermissions: OysterAppPermissions,
295
315
  } }) }));
296
316
  return Promise.resolve({
297
317
  controls: {
298
318
  ...controls,
319
+ setup,
299
320
  parseSettings: (value) => S.decodeUnknownSync(S.Json)(settingsLocationSchema.parse(value)),
300
321
  openSettings: (value, options) => {
301
322
  controls.openSettings(settingsLocationSchema.parse(value), options);
@@ -0,0 +1,41 @@
1
+ import type { AppSetup, SetupNeed } from "@fungi.computer/agar";
2
+ import type { WorkbenchSetupPort } from "@fungi.computer/nacre/workbench";
3
+ import { z } from "zod";
4
+ import type { SettingsLocation } from "./settings-routes.js";
5
+ /** The owner-direct `/api/setup` reply, decoded before any App sees it. */
6
+ export declare const oysterSetupSchema: z.ZodObject<{
7
+ models: z.ZodEnum<{
8
+ missing: "missing";
9
+ ready: "ready";
10
+ unknown: "unknown";
11
+ }>;
12
+ media: z.ZodEnum<{
13
+ missing: "missing";
14
+ ready: "ready";
15
+ unknown: "unknown";
16
+ }>;
17
+ git: z.ZodEnum<{
18
+ missing: "missing";
19
+ ready: "ready";
20
+ unknown: "unknown";
21
+ }>;
22
+ terminal: z.ZodEnum<{
23
+ missing: "missing";
24
+ ready: "ready";
25
+ unknown: "unknown";
26
+ "exec-only": "exec-only";
27
+ }>;
28
+ }, z.core.$strict>;
29
+ /** Where each need is fixed in this host's Settings. */
30
+ export declare function settingsForNeed(need: SetupNeed): SettingsLocation;
31
+ export type OysterSetupDeps = Readonly<{
32
+ /** The host facts, already decoded with `oysterSetupSchema`. */
33
+ readFacts(): Promise<AppSetup>;
34
+ openSettings(location: SettingsLocation): void;
35
+ /** Settings closing is when a freshly added key becomes visible. */
36
+ subscribeSettingsClosed(listener: () => void): () => void;
37
+ }>;
38
+ /** The setup port: facts read live, plus the Settings page for each need. */
39
+ export declare function createOysterSetupPort(deps: OysterSetupDeps): WorkbenchSetupPort & Readonly<{
40
+ changed(): void;
41
+ }>;
@@ -0,0 +1,39 @@
1
+ import { z } from "zod";
2
+ const state = z.enum(["ready", "missing", "unknown"]);
3
+ /** The owner-direct `/api/setup` reply, decoded before any App sees it. */
4
+ export const oysterSetupSchema = z.strictObject({
5
+ models: state,
6
+ media: state,
7
+ git: state,
8
+ terminal: z.enum(["ready", "exec-only", "missing", "unknown"]),
9
+ });
10
+ /** Where each need is fixed in this host's Settings. */
11
+ export function settingsForNeed(need) {
12
+ // Models and media both come from a key; git and a runtime from Computers.
13
+ return need === "model" || need === "media"
14
+ ? { category: "keys" }
15
+ : { category: "computers" };
16
+ }
17
+ /** The setup port: facts read live, plus the Settings page for each need. */
18
+ export function createOysterSetupPort(deps) {
19
+ const listeners = new Set();
20
+ const changed = () => {
21
+ for (const listener of listeners)
22
+ listener();
23
+ };
24
+ deps.subscribeSettingsClosed(changed);
25
+ return {
26
+ read: () => deps.readFacts(),
27
+ subscribe: (listener) => {
28
+ listeners.add(listener);
29
+ return () => {
30
+ listeners.delete(listener);
31
+ };
32
+ },
33
+ open: (need) => {
34
+ deps.openSettings(settingsForNeed(need));
35
+ return Promise.resolve("opened");
36
+ },
37
+ changed,
38
+ };
39
+ }
@@ -225,7 +225,14 @@ export function PlatformControlsView({ teamId, controls, data, }) {
225
225
  },
226
226
  };
227
227
  const requestAppAccess = data.requestAppAccess;
228
- return controls.attach(requestAppAccess === undefined
228
+ const refreshAfterGrant = async (outcome) => {
229
+ const settled = await outcome;
230
+ // The admitted App re-reads its grants and context without a reload.
231
+ if (settled === "granted")
232
+ controls.changed();
233
+ return settled;
234
+ };
235
+ const ask = requestAppAccess === undefined
229
236
  ? async (target, input) => {
230
237
  const current = await data.directory();
231
238
  const app = current.apps.find((candidate) => candidate.surfaceId === target.surfaceId);
@@ -251,7 +258,9 @@ export function PlatformControlsView({ teamId, controls, data, }) {
251
258
  });
252
259
  return outcome === "customize" ? openSettings() : outcome;
253
260
  }
254
- : (target, input) => requestAppAccess(target, input, dialog));
261
+ : (target, input) => requestAppAccess(target, input, dialog);
262
+ const attached = controls.attach((target, input) => refreshAfterGrant(ask(target, input)));
263
+ return attached;
255
264
  }, [controls, data]);
256
265
  const settings = (_jsxs(_Fragment, { children: [_jsx(RouterProvider, { router: controls.router }), _jsx(AppAccessConsent, { request: consent }), _jsx(DeferredSystemSettings, { location: location, sections: controls.sections, onNavigate: (next) => {
257
266
  controls.navigate(next);