@fungi.computer/tourtois 0.15.2 → 0.16.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.
- package/dist/AppWorkbench.js +26 -3
- package/dist/ModelKeys.d.ts +8 -20
- package/dist/ModelKeys.js +23 -24
- package/dist/desktop-layout.d.ts +3 -3
- package/dist/window-session.d.ts +3 -1
- package/dist/window-session.js +38 -32
- package/package.json +4 -4
package/dist/AppWorkbench.js
CHANGED
|
@@ -82,6 +82,8 @@ function phoneShowDesktop(phone, covered, host, onFailure) {
|
|
|
82
82
|
export function AppWorkbench({ paneLayerRef, phone, teamId, teamName, initialComputerId, computers, computersUnavailable, extraPanes, initialFocusId, onLayoutChange, extraLaunchers = [], settingsLaunchers = [], settingsSections, systemMenuItems, directoryReader, takeAppOpenRequest, platform, desktopStorage, desktopMethods, gills, }) {
|
|
83
83
|
const setSettingsLocation = platform.openSettings;
|
|
84
84
|
const [appDialOpen, setAppDialOpen] = useState(false);
|
|
85
|
+
const appDialOpenRef = useRef(appDialOpen);
|
|
86
|
+
appDialOpenRef.current = appDialOpen;
|
|
85
87
|
// The Layout menu's "Arrange desktop" command and the desktop's own
|
|
86
88
|
// controls share one state: this is their common ancestor.
|
|
87
89
|
const [desktopEditing, setDesktopEditing] = useState(false);
|
|
@@ -478,6 +480,19 @@ export function AppWorkbench({ paneLayerRef, phone, teamId, teamName, initialCom
|
|
|
478
480
|
focusWindow,
|
|
479
481
|
onError: setAppStatus,
|
|
480
482
|
});
|
|
483
|
+
/** An App that is already open comes forward instead of opening twice. */
|
|
484
|
+
const bringForward = (windowId) => {
|
|
485
|
+
void appWindows
|
|
486
|
+
.restore(windowId)
|
|
487
|
+
.then(() => {
|
|
488
|
+
layout.zoom(null);
|
|
489
|
+
focusWindow(windowId);
|
|
490
|
+
})
|
|
491
|
+
.catch((cause) => {
|
|
492
|
+
console.error("App workbench operation failed", cause);
|
|
493
|
+
setAppStatus("App could not be restored.");
|
|
494
|
+
});
|
|
495
|
+
};
|
|
481
496
|
const launchApp = (installation, requestedLaunch) => {
|
|
482
497
|
const windowId = "app:" + installation.surfaceId;
|
|
483
498
|
const launch = requestedLaunch ?? launchFor(installation);
|
|
@@ -530,11 +545,14 @@ export function AppWorkbench({ paneLayerRef, phone, teamId, teamName, initialCom
|
|
|
530
545
|
label: installation.displayName ?? "App",
|
|
531
546
|
icon: _jsx(AppIcon, { roles: installation.roles, icon: installation.icon }),
|
|
532
547
|
onSelect: () => {
|
|
533
|
-
|
|
548
|
+
if (appProjection.windows.some((item) => item.windowId === windowId))
|
|
549
|
+
bringForward(windowId);
|
|
550
|
+
else
|
|
551
|
+
launchApp(installation);
|
|
534
552
|
},
|
|
535
553
|
};
|
|
536
554
|
});
|
|
537
|
-
const appLaunchers = launchableItems
|
|
555
|
+
const appLaunchers = [...launchableItems];
|
|
538
556
|
appLaunchers.push(...settingsLaunchers.map((launcher) => {
|
|
539
557
|
const item = {
|
|
540
558
|
id: launcher.id,
|
|
@@ -658,5 +676,10 @@ export function AppWorkbench({ paneLayerRef, phone, teamId, teamName, initialCom
|
|
|
658
676
|
name: app.displayName ?? "App",
|
|
659
677
|
roles: app.roles,
|
|
660
678
|
surfaceId: app.surfaceId,
|
|
661
|
-
})), onStatus: setAppStatus, finalFocus: () =>
|
|
679
|
+
})), onStatus: setAppStatus, finalFocus: () =>
|
|
680
|
+
// Ctrl K then O opens the App dial as this dialog closes; focus goes
|
|
681
|
+
// to its search so typing filters, not back to the launcher button.
|
|
682
|
+
appDialOpenRef.current
|
|
683
|
+
? document.querySelector(".caps-app-bar-launchers input[type='search']")
|
|
684
|
+
: document.querySelector(".caps-app-bar-launcher-button") })] }));
|
|
662
685
|
}
|
package/dist/ModelKeys.d.ts
CHANGED
|
@@ -1,21 +1,10 @@
|
|
|
1
1
|
import * as z from "zod";
|
|
2
|
-
|
|
3
|
-
readonly "cloudflare-workers-ai": "Cloudflare Workers AI";
|
|
4
|
-
readonly anthropic: "Anthropic";
|
|
5
|
-
readonly openai: "OpenAI";
|
|
6
|
-
readonly openrouter: "OpenRouter";
|
|
7
|
-
};
|
|
8
|
-
export type Provider = keyof typeof providers;
|
|
2
|
+
export type Provider = string;
|
|
9
3
|
/** Every stored key and every Agent with its persisted model choice. */
|
|
10
4
|
export declare const modelKeysViewSchema: z.ZodObject<{
|
|
11
5
|
keys: z.ZodArray<z.ZodObject<{
|
|
12
6
|
keyId: z.ZodString;
|
|
13
|
-
provider: z.
|
|
14
|
-
"cloudflare-workers-ai": "cloudflare-workers-ai";
|
|
15
|
-
anthropic: "anthropic";
|
|
16
|
-
openai: "openai";
|
|
17
|
-
openrouter: "openrouter";
|
|
18
|
-
}>;
|
|
7
|
+
provider: z.ZodString;
|
|
19
8
|
label: z.ZodString;
|
|
20
9
|
createdAt: z.ZodNumber;
|
|
21
10
|
validatedAt: z.ZodNumber;
|
|
@@ -25,12 +14,12 @@ export declare const modelKeysViewSchema: z.ZodObject<{
|
|
|
25
14
|
unknown: "unknown";
|
|
26
15
|
missing: "missing";
|
|
27
16
|
}>;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
17
|
+
providers: z.ZodArray<z.ZodObject<{
|
|
18
|
+
id: z.ZodString;
|
|
19
|
+
label: z.ZodString;
|
|
20
|
+
accountId: z.ZodBoolean;
|
|
21
|
+
}, z.core.$strict>>;
|
|
22
|
+
catalogs: z.ZodRecord<z.ZodString & z.core.$partial, z.ZodArray<z.ZodObject<{
|
|
34
23
|
id: z.ZodString;
|
|
35
24
|
name: z.ZodString;
|
|
36
25
|
input: z.ZodNumber;
|
|
@@ -86,4 +75,3 @@ export declare function ModelKeys({ port, focus, }: {
|
|
|
86
75
|
port: ModelKeysPort;
|
|
87
76
|
focus?: boolean;
|
|
88
77
|
}): import("react/jsx-runtime").JSX.Element;
|
|
89
|
-
export {};
|
package/dist/ModelKeys.js
CHANGED
|
@@ -11,18 +11,13 @@ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
|
11
11
|
import { useCallback, useMemo, useState } from "react";
|
|
12
12
|
import * as z from "zod";
|
|
13
13
|
import { SettingsItem } from "./settings-item.js";
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
};
|
|
20
|
-
const providerSchema = z.
|
|
21
|
-
"cloudflare-workers-ai",
|
|
22
|
-
"anthropic",
|
|
23
|
-
"openai",
|
|
24
|
-
"openrouter",
|
|
25
|
-
]);
|
|
14
|
+
/** A provider the host offers; the host owns the list and the client only shows it. */
|
|
15
|
+
const providerChoiceSchema = z.strictObject({
|
|
16
|
+
id: z.string().min(1),
|
|
17
|
+
label: z.string().min(1),
|
|
18
|
+
accountId: z.boolean(),
|
|
19
|
+
});
|
|
20
|
+
const providerSchema = z.string().min(1);
|
|
26
21
|
/** One stored key as the host lists it; the secret never comes back. */
|
|
27
22
|
const modelKeySchema = z.strictObject({
|
|
28
23
|
keyId: z.string().min(1),
|
|
@@ -44,6 +39,7 @@ const agentChoiceSchema = z.strictObject({
|
|
|
44
39
|
export const modelKeysViewSchema = z.strictObject({
|
|
45
40
|
keys: z.array(modelKeySchema),
|
|
46
41
|
models: z.enum(["ready", "missing", "unknown"]),
|
|
42
|
+
providers: z.array(providerChoiceSchema).min(1),
|
|
47
43
|
catalogs: z.partialRecord(providerSchema, z.array(z.strictObject({
|
|
48
44
|
id: z.string().min(1),
|
|
49
45
|
name: z.string().min(1),
|
|
@@ -57,6 +53,8 @@ export const modelKeysViewSchema = z.strictObject({
|
|
|
57
53
|
choice: agentChoiceSchema.nullable(),
|
|
58
54
|
})),
|
|
59
55
|
});
|
|
56
|
+
/** Provider label from the host's list; an unlisted provider shows its id. */
|
|
57
|
+
const providerLabel = (providers, id) => providers.find((choice) => choice.id === id)?.label ?? id;
|
|
60
58
|
const queryKey = ["tourtois", "model-keys"];
|
|
61
59
|
const defaultSource = "default";
|
|
62
60
|
/**
|
|
@@ -83,9 +81,9 @@ export function ModelKeys({ port, focus = false, }) {
|
|
|
83
81
|
const agents = view.data?.agents ?? [];
|
|
84
82
|
// A fresh form after each stored key, so the key field empties.
|
|
85
83
|
const [formKey, setFormKey] = useState(0);
|
|
86
|
-
return (_jsxs("section", { ref: focusSetup, className: "tourtois-settings-stack tourtois-model-keys", "aria-label": "Model keys", children: [_jsx(SectionHeading, { children: "Model keys" }), _jsx("p", { className: "tourtois-settings-lede", children: "Bring your own provider API key. It is checked with the provider, sealed on this instance and never shown again. Each Agent can run on any key." }), view.isPending ? _jsx("p", { children: "Loading model keys\u2026" }) : null, view.isError ? (_jsxs("div", { role: "status", className: "tourtois-settings-notice", children: [_jsx("p", { children: "Model keys could not be loaded." }), _jsx(Button, { size: "sm", variant: "outline", onClick: () => void view.refetch(), children: "Retry" })] })) : null, view.isSuccess ? (_jsxs(_Fragment, { children: [_jsxs(DataList, { "aria-label": "Model keys", children: [keys.length === 0 ? (_jsx(DataRow, { className: "tourtois-settings-empty", children: "No model keys yet." })) : null, keys.map((key) => (_jsx(DataRow, { children: _jsx(SettingsItem, { icon: _jsx(Sigil, { name: "restricted" }), title: key.label, detail: _jsx("p", { children: providers
|
|
84
|
+
return (_jsxs("section", { ref: focusSetup, className: "tourtois-settings-stack tourtois-model-keys", "aria-label": "Model keys", children: [_jsx(SectionHeading, { children: "Model keys" }), _jsx("p", { className: "tourtois-settings-lede", children: "Bring your own provider API key. It is checked with the provider, sealed on this instance and never shown again. Each Agent can run on any key." }), view.isPending ? _jsx("p", { children: "Loading model keys\u2026" }) : null, view.isError ? (_jsxs("div", { role: "status", className: "tourtois-settings-notice", children: [_jsx("p", { children: "Model keys could not be loaded." }), _jsx(Button, { size: "sm", variant: "outline", onClick: () => void view.refetch(), children: "Retry" })] })) : null, view.isSuccess ? (_jsxs(_Fragment, { children: [_jsxs(DataList, { "aria-label": "Model keys", children: [keys.length === 0 ? (_jsx(DataRow, { className: "tourtois-settings-empty", children: "No model keys yet." })) : null, keys.map((key) => (_jsx(DataRow, { children: _jsx(SettingsItem, { icon: _jsx(Sigil, { name: "restricted" }), title: key.label, detail: _jsx("p", { children: providerLabel(view.data.providers, key.provider) }), actions: _jsx(KeycapButton, { density: "compact", tone: "destructive", label: "Remove", "aria-label": `Remove ${key.label}`, disabled: remove.isPending, onClick: () => {
|
|
87
85
|
remove.mutate(key.keyId);
|
|
88
|
-
} }) }) }, key.keyId)))] }), remove.isError ? (_jsx("p", { role: "alert", children: "The model key could not be removed." })) : null, _jsx(AddModelKey, { onAdd: async (draft) => {
|
|
86
|
+
} }) }) }, key.keyId)))] }), remove.isError ? (_jsx("p", { role: "alert", children: "The model key could not be removed." })) : null, _jsx(AddModelKey, { providers: view.data.providers, onAdd: async (draft) => {
|
|
89
87
|
await port.addKey(draft);
|
|
90
88
|
await refresh();
|
|
91
89
|
setFormKey((current) => current + 1);
|
|
@@ -106,18 +104,19 @@ export function ModelKeys({ port, focus = false, }) {
|
|
|
106
104
|
: "Model unavailable for tools")), disconnected || selectedKey === undefined
|
|
107
105
|
? ""
|
|
108
106
|
: ` · ${selectedKey.label}`] }, agent.agentId));
|
|
109
|
-
})] }), agents.length > 0 ? (_jsx(ChooseAgentModel, { agents: agents, keys: keys, catalogs: view.data.catalogs, models: view.data.models, onChoose: async (agentId, draft) => {
|
|
107
|
+
})] }), agents.length > 0 ? (_jsx(ChooseAgentModel, { agents: agents, keys: keys, providers: view.data.providers, catalogs: view.data.catalogs, models: view.data.models, onChoose: async (agentId, draft) => {
|
|
110
108
|
await port.chooseModel(agentId, draft);
|
|
111
109
|
await refresh();
|
|
112
110
|
} }, keys.map((key) => key.keyId).join(":"))) : null] })) : null] }));
|
|
113
111
|
}
|
|
114
|
-
function AddModelKey({ onAdd, }) {
|
|
112
|
+
function AddModelKey({ providers, onAdd, }) {
|
|
113
|
+
const needsAccountId = (provider) => providers.find((choice) => choice.id === provider)?.accountId === true;
|
|
115
114
|
const schema = useMemo(() => z.object({
|
|
116
115
|
provider: providerSchema.meta(field({
|
|
117
116
|
label: "Provider",
|
|
118
117
|
icon: _jsx(Sigil, { name: "internet" }),
|
|
119
118
|
kind: "select",
|
|
120
|
-
options: providers,
|
|
119
|
+
options: Object.fromEntries(providers.map((choice) => [choice.id, choice.label])),
|
|
121
120
|
})),
|
|
122
121
|
label: z
|
|
123
122
|
.string()
|
|
@@ -148,19 +147,19 @@ function AddModelKey({ onAdd, }) {
|
|
|
148
147
|
help: "Sealed on this instance and never shown again.",
|
|
149
148
|
kind: "secret",
|
|
150
149
|
})),
|
|
151
|
-
}), []);
|
|
150
|
+
}), [providers]);
|
|
152
151
|
const add = useMutation({ mutationFn: onAdd });
|
|
153
152
|
const model = useSchemaForm({
|
|
154
153
|
schema,
|
|
155
154
|
defaultValues: {
|
|
156
|
-
provider: "
|
|
155
|
+
provider: providers[0]?.id ?? "",
|
|
157
156
|
label: "",
|
|
158
157
|
apiKey: "",
|
|
159
158
|
accountId: "",
|
|
160
159
|
},
|
|
161
160
|
onSubmit: async (value) => {
|
|
162
161
|
try {
|
|
163
|
-
if (value.provider
|
|
162
|
+
if (needsAccountId(value.provider) &&
|
|
164
163
|
!/^[a-f0-9]{32}$/u.test(value.accountId))
|
|
165
164
|
return {
|
|
166
165
|
kind: "refused",
|
|
@@ -173,7 +172,7 @@ function AddModelKey({ onAdd, }) {
|
|
|
173
172
|
label: value.label,
|
|
174
173
|
apiKey: value.apiKey,
|
|
175
174
|
};
|
|
176
|
-
await add.mutateAsync(value.provider
|
|
175
|
+
await add.mutateAsync(needsAccountId(value.provider)
|
|
177
176
|
? { ...draft, accountId: value.accountId }
|
|
178
177
|
: draft);
|
|
179
178
|
return { kind: "saved" };
|
|
@@ -188,11 +187,11 @@ function AddModelKey({ onAdd, }) {
|
|
|
188
187
|
}
|
|
189
188
|
},
|
|
190
189
|
});
|
|
191
|
-
return (_jsx(SchemaForm, { model: model, layout: "columns", "aria-label": "Add model key", disabled: add.isPending, footer: _jsx(FormFooter, { divider: false, error: model.error, children: _jsx(Button, { type: "submit", children: add.isPending ? "Checking…" : "Add model key" }) }), children: _jsx(model.form.Subscribe, { selector: (state) => state.values.provider, children: (provider) => (_jsx(FormFields, { model: model, names: provider
|
|
190
|
+
return (_jsx(SchemaForm, { model: model, layout: "columns", "aria-label": "Add model key", disabled: add.isPending, footer: _jsx(FormFooter, { divider: false, error: model.error, children: _jsx(Button, { type: "submit", children: add.isPending ? "Checking…" : "Add model key" }) }), children: _jsx(model.form.Subscribe, { selector: (state) => state.values.provider, children: (provider) => (_jsx(FormFields, { model: model, names: needsAccountId(provider)
|
|
192
191
|
? ["provider", "label", "accountId", "apiKey"]
|
|
193
192
|
: ["provider", "label", "apiKey"], layout: "columns" })) }) }));
|
|
194
193
|
}
|
|
195
|
-
function ChooseAgentModel({ agents, keys, catalogs, models, onChoose, }) {
|
|
194
|
+
function ChooseAgentModel({ agents, keys, providers, catalogs, models, onChoose, }) {
|
|
196
195
|
const schema = useMemo(() => z.object({
|
|
197
196
|
agentId: z.string().meta(field({
|
|
198
197
|
label: "Agent",
|
|
@@ -252,7 +251,7 @@ function ChooseAgentModel({ agents, keys, catalogs, models, onChoose, }) {
|
|
|
252
251
|
model.form.setFieldValue("modelId", "");
|
|
253
252
|
}, children: [_jsx("option", { value: defaultSource, children: models === "missing"
|
|
254
253
|
? "Instance default — not connected"
|
|
255
|
-
: "Instance default model" }), keys.map((key) => (_jsxs("option", { value: key.keyId, children: [key.label, " (", providers
|
|
254
|
+
: "Instance default model" }), keys.map((key) => (_jsxs("option", { value: key.keyId, children: [key.label, " (", providerLabel(providers, key.provider), ")"] }, key.keyId)))] })) }), _jsx(model.form.Subscribe, { selector: (state) => state.values.source, children: (source) => {
|
|
256
255
|
const key = keys.find((item) => item.keyId === source);
|
|
257
256
|
if (key === undefined)
|
|
258
257
|
return null;
|
package/dist/desktop-layout.d.ts
CHANGED
|
@@ -88,15 +88,15 @@ export declare const desktopArrangeResultSchema: z.ZodDiscriminatedUnion<[z.ZodO
|
|
|
88
88
|
code: z.ZodEnum<{
|
|
89
89
|
invalid: "invalid";
|
|
90
90
|
owner_required: "owner_required";
|
|
91
|
+
too_large: "too_large";
|
|
92
|
+
quota_exceeded: "quota_exceeded";
|
|
93
|
+
conflict: "conflict";
|
|
91
94
|
unknown_gill: "unknown_gill";
|
|
92
95
|
unknown_app: "unknown_app";
|
|
93
96
|
size_not_allowed: "size_not_allowed";
|
|
94
97
|
unknown_item: "unknown_item";
|
|
95
98
|
last_launcher: "last_launcher";
|
|
96
99
|
too_many: "too_many";
|
|
97
|
-
conflict: "conflict";
|
|
98
|
-
too_large: "too_large";
|
|
99
|
-
quota_exceeded: "quota_exceeded";
|
|
100
100
|
params_invalid: "params_invalid";
|
|
101
101
|
}>;
|
|
102
102
|
}, z.core.$strict>], "kind">;
|
package/dist/window-session.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import type
|
|
2
|
+
import { type AppStorage } from "@fungi.computer/agar/storage";
|
|
3
3
|
import type { AppDirectoryApp } from "./app-launch.js";
|
|
4
4
|
import type { AppLaunchDescriptor, AppWindowManager } from "./app-windows.js";
|
|
5
5
|
/** The member's own storage key for the windows they had open. */
|
|
@@ -21,6 +21,7 @@ export declare const windowSessionSchema: z.ZodObject<{
|
|
|
21
21
|
width: z.ZodNumber;
|
|
22
22
|
height: z.ZodNumber;
|
|
23
23
|
}, z.core.$strip>;
|
|
24
|
+
minimized: z.ZodDefault<z.ZodBoolean>;
|
|
24
25
|
}, z.core.$strip>>;
|
|
25
26
|
}, z.core.$strip>;
|
|
26
27
|
export type WindowSession = z.infer<typeof windowSessionSchema>;
|
|
@@ -47,6 +48,7 @@ export declare function restorableLaunches<App extends Readonly<{
|
|
|
47
48
|
}>, Launch>(session: WindowSession, apps: readonly App[], launchFor: (app: App) => Launch | null): readonly Readonly<{
|
|
48
49
|
launch: Launch;
|
|
49
50
|
frame: WindowPlacement;
|
|
51
|
+
minimized: boolean;
|
|
50
52
|
}>[];
|
|
51
53
|
/** Reads and writes the session through the member's storage layer. */
|
|
52
54
|
export declare function createWindowSessionStore(storage: AppStorage): {
|
package/dist/window-session.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
+
import { AppStorageError } from "@fungi.computer/agar/storage";
|
|
3
4
|
/** The member's own storage key for the windows they had open. */
|
|
4
5
|
export const windowSessionKey = "windows";
|
|
5
6
|
const frameSchema = z.object({
|
|
@@ -12,9 +13,13 @@ export const windowSessionSchema = z.object({
|
|
|
12
13
|
tiled: z.boolean(),
|
|
13
14
|
/** The focused window's surface, raised last so it stays on top. */
|
|
14
15
|
active: z.string().nullable(),
|
|
15
|
-
/** Open windows in tiling order
|
|
16
|
+
/** Open windows in tiling order, minimized ones included. */
|
|
16
17
|
windows: z
|
|
17
|
-
.array(z.object({
|
|
18
|
+
.array(z.object({
|
|
19
|
+
surfaceId: z.string().min(1),
|
|
20
|
+
frame: frameSchema,
|
|
21
|
+
minimized: z.boolean().default(false),
|
|
22
|
+
}))
|
|
18
23
|
.max(16),
|
|
19
24
|
});
|
|
20
25
|
const windowIdFor = (surfaceId) => "app:" + surfaceId;
|
|
@@ -27,20 +32,16 @@ export const cascade = (index) => ({
|
|
|
27
32
|
});
|
|
28
33
|
/** Pure projection of the live desktop into the stored shape. */
|
|
29
34
|
export function windowSessionFrom(snapshot) {
|
|
30
|
-
const windows = snapshot.windows.
|
|
31
|
-
|
|
32
|
-
:
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
frame: {
|
|
36
|
-
...(snapshot.frames.get(item.windowId) ?? cascade(index)),
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
]);
|
|
35
|
+
const windows = snapshot.windows.map((item, index) => ({
|
|
36
|
+
surfaceId: item.surfaceId,
|
|
37
|
+
frame: { ...(snapshot.frames.get(item.windowId) ?? cascade(index)) },
|
|
38
|
+
minimized: item.status === "minimized",
|
|
39
|
+
}));
|
|
40
40
|
const active = snapshot.windows.find((item) => item.windowId === snapshot.activeWindowId);
|
|
41
41
|
return windowSessionSchema.parse({
|
|
42
42
|
tiled: snapshot.tiled,
|
|
43
|
-
active: active &&
|
|
43
|
+
active: active &&
|
|
44
|
+
windows.some((item) => item.surfaceId === active.surfaceId && !item.minimized)
|
|
44
45
|
? active.surfaceId
|
|
45
46
|
: null,
|
|
46
47
|
windows: windows.slice(0, 16),
|
|
@@ -51,7 +52,9 @@ export function restorableLaunches(session, apps, launchFor) {
|
|
|
51
52
|
return session.windows.flatMap((saved) => {
|
|
52
53
|
const app = apps.find((item) => item.surfaceId === saved.surfaceId && !item.roles.includes("dashboard"));
|
|
53
54
|
const launch = app ? launchFor(app) : null;
|
|
54
|
-
return launch
|
|
55
|
+
return launch
|
|
56
|
+
? [{ launch, frame: saved.frame, minimized: saved.minimized }]
|
|
57
|
+
: [];
|
|
55
58
|
});
|
|
56
59
|
}
|
|
57
60
|
/** Reads and writes the session through the member's storage layer. */
|
|
@@ -66,27 +69,28 @@ export function createWindowSessionStore(storage) {
|
|
|
66
69
|
return parsed.success ? parsed.data : null;
|
|
67
70
|
},
|
|
68
71
|
save(session) {
|
|
72
|
+
const attempt = async () => {
|
|
73
|
+
const result = await storage.write({
|
|
74
|
+
key: windowSessionKey,
|
|
75
|
+
scope: "member",
|
|
76
|
+
basedOn: revision,
|
|
77
|
+
value: session,
|
|
78
|
+
});
|
|
79
|
+
revision = result.revision;
|
|
80
|
+
};
|
|
69
81
|
const write = async () => {
|
|
70
82
|
try {
|
|
71
|
-
|
|
72
|
-
key: windowSessionKey,
|
|
73
|
-
scope: "member",
|
|
74
|
-
basedOn: revision,
|
|
75
|
-
value: session,
|
|
76
|
-
});
|
|
77
|
-
revision = result.revision;
|
|
83
|
+
await attempt();
|
|
78
84
|
}
|
|
79
85
|
catch (cause) {
|
|
80
|
-
//
|
|
81
|
-
//
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
throw cause;
|
|
86
|
+
// Another tab saved first. This tab's state is the current one, so
|
|
87
|
+
// take the stored revision and save over it once; anything else is a
|
|
88
|
+
// real failure.
|
|
89
|
+
if (!(cause instanceof AppStorageError) || cause.code !== "conflict")
|
|
90
|
+
throw cause;
|
|
91
|
+
const resolved = await storage.read(windowSessionKey);
|
|
92
|
+
revision = resolved.member?.revision ?? null;
|
|
93
|
+
await attempt();
|
|
90
94
|
}
|
|
91
95
|
};
|
|
92
96
|
// Each save waits for the previous one to settle, then runs; the caller
|
|
@@ -125,12 +129,14 @@ export function useWindowSession(input) {
|
|
|
125
129
|
const launches = restorableLaunches(session, current.apps, current.launchFor);
|
|
126
130
|
for (const { launch, frame } of launches)
|
|
127
131
|
seeds.current.set(launch.windowId, frame);
|
|
128
|
-
for (const { launch } of launches) {
|
|
132
|
+
for (const { launch, minimized } of launches) {
|
|
129
133
|
if (current.manager
|
|
130
134
|
.read()
|
|
131
135
|
.windows.some((item) => item.windowId === launch.windowId))
|
|
132
136
|
continue;
|
|
133
137
|
await current.manager.open(launch);
|
|
138
|
+
if (minimized)
|
|
139
|
+
await current.manager.minimize(launch.windowId);
|
|
134
140
|
}
|
|
135
141
|
const active = session.active && windowIdFor(session.active);
|
|
136
142
|
if (active &&
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fungi.computer/tourtois",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
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",
|
|
@@ -79,11 +79,11 @@
|
|
|
79
79
|
"dependencies": {
|
|
80
80
|
"@fungi.computer/agar": "0.10.0",
|
|
81
81
|
"@fungi.computer/cairn": "0.1.0",
|
|
82
|
-
"@fungi.computer/caps": "0.11.
|
|
82
|
+
"@fungi.computer/caps": "0.11.3",
|
|
83
83
|
"@fungi.computer/ear-tag": "0.1.0",
|
|
84
84
|
"@fungi.computer/gills": "0.3.0",
|
|
85
85
|
"@fungi.computer/maosaico": "0.1.2",
|
|
86
|
-
"@fungi.computer/parakeet": "0.11.
|
|
86
|
+
"@fungi.computer/parakeet": "0.11.21",
|
|
87
87
|
"@fungi.computer/puffball": "0.5.5",
|
|
88
88
|
"@fungi.computer/shiitake": "0.13.1",
|
|
89
89
|
"@fungi.computer/sigils": "0.3.1",
|
|
@@ -106,7 +106,7 @@
|
|
|
106
106
|
"react": "^18.3.1 || ^19.2.0"
|
|
107
107
|
},
|
|
108
108
|
"devDependencies": {
|
|
109
|
-
"@fungi.computer/oyster": "0.
|
|
109
|
+
"@fungi.computer/oyster": "0.22.0",
|
|
110
110
|
"@cloudflare/workers-types": "5.20260828.1",
|
|
111
111
|
"@fungi.computer/forage": "0.3.5",
|
|
112
112
|
"@fungi.computer/mycelium": "0.3.8",
|