@fungi.computer/tourtois 0.15.2 → 0.15.3
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/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/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.15.
|
|
3
|
+
"version": "0.15.3",
|
|
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.21.
|
|
109
|
+
"@fungi.computer/oyster": "0.21.8",
|
|
110
110
|
"@cloudflare/workers-types": "5.20260828.1",
|
|
111
111
|
"@fungi.computer/forage": "0.3.5",
|
|
112
112
|
"@fungi.computer/mycelium": "0.3.8",
|