@fungi.computer/tourtois 0.30.10 → 0.31.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.
@@ -85,7 +85,7 @@ export declare function useAppDirectory(teamId: string, directoryReader: () => P
85
85
  authorityVersion: number;
86
86
  declaredOperationsDigest: import("@fungi.computer/puffball").Sha256Digest;
87
87
  approvedGrants: readonly Readonly<{
88
- capability: "approvals" | "agent.list" | "agent.manage" | "agent.rename" | "agent.avatar" | "agent.instructions" | "agent.toolPolicy" | "agent.stop" | "agent.read" | "agent.send" | "computer.list" | "computer.readFile" | "computer.writeFile" | "computer.execute" | "llm.generation" | "media.generation" | "media.share" | "games:servers" | "git.repository" | "apps.open" | "apps.call" | "app.storage" | "app.events.emit" | "team.workbenchHost" | "marketplace.browse" | "marketplace.purchase" | "workflow.run" | "workflow.publish" | "workflow.arm" | "world" | "channels.read" | "channels.personal.manage";
88
+ capability: "approvals" | "agent.list" | "agent.manage" | "agent.rename" | "agent.avatar" | "agent.instructions" | "agent.toolPolicy" | "agent.extensions" | "agent.stop" | "agent.read" | "agent.send" | "computer.list" | "computer.readFile" | "computer.writeFile" | "computer.execute" | "llm.generation" | "media.generation" | "media.share" | "games:servers" | "git.repository" | "apps.open" | "apps.call" | "app.storage" | "app.events.emit" | "team.workbenchHost" | "marketplace.browse" | "marketplace.purchase" | "workflow.run" | "workflow.publish" | "workflow.arm" | "world" | "channels.read" | "channels.personal.manage";
89
89
  capabilityApproved: true;
90
90
  operations: readonly string[];
91
91
  fingerprints: Readonly<Record<string, string>>;
@@ -113,7 +113,7 @@ export declare function useAppDirectory(teamId: string, directoryReader: () => P
113
113
  artifactDigest: import("@fungi.computer/puffball").Sha256Digest;
114
114
  digest: import("@fungi.computer/puffball").Sha256Digest;
115
115
  capabilities: readonly Readonly<{
116
- capability: "approvals" | "agent.list" | "agent.manage" | "agent.rename" | "agent.avatar" | "agent.instructions" | "agent.toolPolicy" | "agent.stop" | "agent.read" | "agent.send" | "computer.list" | "computer.readFile" | "computer.writeFile" | "computer.execute" | "llm.generation" | "media.generation" | "media.share" | "games:servers" | "git.repository" | "apps.open" | "apps.call" | "app.storage" | "app.events.emit" | "team.workbenchHost" | "marketplace.browse" | "marketplace.purchase" | "workflow.run" | "workflow.publish" | "workflow.arm" | "world" | "channels.read" | "channels.personal.manage";
116
+ capability: "approvals" | "agent.list" | "agent.manage" | "agent.rename" | "agent.avatar" | "agent.instructions" | "agent.toolPolicy" | "agent.extensions" | "agent.stop" | "agent.read" | "agent.send" | "computer.list" | "computer.readFile" | "computer.writeFile" | "computer.execute" | "llm.generation" | "media.generation" | "media.share" | "games:servers" | "git.repository" | "apps.open" | "apps.call" | "app.storage" | "app.events.emit" | "team.workbenchHost" | "marketplace.browse" | "marketplace.purchase" | "workflow.run" | "workflow.publish" | "workflow.arm" | "world" | "channels.read" | "channels.personal.manage";
117
117
  operations: readonly string[];
118
118
  fingerprints: Readonly<Record<string, string>>;
119
119
  }>[];
@@ -230,7 +230,7 @@ export declare function useAppDirectory(teamId: string, directoryReader: () => P
230
230
  authorityVersion: number;
231
231
  declaredOperationsDigest: import("@fungi.computer/puffball").Sha256Digest;
232
232
  approvedGrants: readonly Readonly<{
233
- capability: "approvals" | "agent.list" | "agent.manage" | "agent.rename" | "agent.avatar" | "agent.instructions" | "agent.toolPolicy" | "agent.stop" | "agent.read" | "agent.send" | "computer.list" | "computer.readFile" | "computer.writeFile" | "computer.execute" | "llm.generation" | "media.generation" | "media.share" | "games:servers" | "git.repository" | "apps.open" | "apps.call" | "app.storage" | "app.events.emit" | "team.workbenchHost" | "marketplace.browse" | "marketplace.purchase" | "workflow.run" | "workflow.publish" | "workflow.arm" | "world" | "channels.read" | "channels.personal.manage";
233
+ capability: "approvals" | "agent.list" | "agent.manage" | "agent.rename" | "agent.avatar" | "agent.instructions" | "agent.toolPolicy" | "agent.extensions" | "agent.stop" | "agent.read" | "agent.send" | "computer.list" | "computer.readFile" | "computer.writeFile" | "computer.execute" | "llm.generation" | "media.generation" | "media.share" | "games:servers" | "git.repository" | "apps.open" | "apps.call" | "app.storage" | "app.events.emit" | "team.workbenchHost" | "marketplace.browse" | "marketplace.purchase" | "workflow.run" | "workflow.publish" | "workflow.arm" | "world" | "channels.read" | "channels.personal.manage";
234
234
  capabilityApproved: true;
235
235
  operations: readonly string[];
236
236
  fingerprints: Readonly<Record<string, string>>;
@@ -258,7 +258,7 @@ export declare function useAppDirectory(teamId: string, directoryReader: () => P
258
258
  artifactDigest: import("@fungi.computer/puffball").Sha256Digest;
259
259
  digest: import("@fungi.computer/puffball").Sha256Digest;
260
260
  capabilities: readonly Readonly<{
261
- capability: "approvals" | "agent.list" | "agent.manage" | "agent.rename" | "agent.avatar" | "agent.instructions" | "agent.toolPolicy" | "agent.stop" | "agent.read" | "agent.send" | "computer.list" | "computer.readFile" | "computer.writeFile" | "computer.execute" | "llm.generation" | "media.generation" | "media.share" | "games:servers" | "git.repository" | "apps.open" | "apps.call" | "app.storage" | "app.events.emit" | "team.workbenchHost" | "marketplace.browse" | "marketplace.purchase" | "workflow.run" | "workflow.publish" | "workflow.arm" | "world" | "channels.read" | "channels.personal.manage";
261
+ capability: "approvals" | "agent.list" | "agent.manage" | "agent.rename" | "agent.avatar" | "agent.instructions" | "agent.toolPolicy" | "agent.extensions" | "agent.stop" | "agent.read" | "agent.send" | "computer.list" | "computer.readFile" | "computer.writeFile" | "computer.execute" | "llm.generation" | "media.generation" | "media.share" | "games:servers" | "git.repository" | "apps.open" | "apps.call" | "app.storage" | "app.events.emit" | "team.workbenchHost" | "marketplace.browse" | "marketplace.purchase" | "workflow.run" | "workflow.publish" | "workflow.arm" | "world" | "channels.read" | "channels.personal.manage";
262
262
  operations: readonly string[];
263
263
  fingerprints: Readonly<Record<string, string>>;
264
264
  }>[];
@@ -1,7 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { type AppStorage } from "@fungi.computer/agar/storage";
3
3
  import type { AppDirectoryApp } from "./app-launch.js";
4
- import type { AppLaunchDescriptor, AppWindowManager } from "./app-windows.js";
4
+ import type { AppLaunchDescriptor } from "./app-windows.js";
5
5
  /** The member's own storage key for the windows they had open. */
6
6
  export declare const windowSessionKey = "windows";
7
7
  declare const frameSchema: z.ZodObject<{
@@ -41,6 +41,14 @@ export type WindowSessionSnapshot = Readonly<{
41
41
  export declare const cascade: (index: number) => WindowPlacement;
42
42
  /** Pure projection of the live desktop into the stored shape. */
43
43
  export declare function windowSessionFrom(snapshot: WindowSessionSnapshot): WindowSession;
44
+ /**
45
+ * The session to store while the stored windows are still reopening. A reopen
46
+ * waits for each App to get ready, so a save that held back until the restore
47
+ * ended lost whatever the person opened meanwhile if the page reloaded first.
48
+ * Storing the windows not back yet beside the open ones keeps both: stored
49
+ * order first, then the new windows, with open windows at their current frame.
50
+ */
51
+ export declare function sessionWhileRestoring(current: WindowSession, stored: WindowSession): WindowSession;
44
52
  /** Launches for the stored windows whose Apps are still installed, in order. */
45
53
  export declare function restorableLaunches<App extends Readonly<{
46
54
  surfaceId: string;
@@ -79,11 +87,25 @@ export declare function createWindowSessionStore(storage: AppStorage): {
79
87
  load(): Promise<WindowSession | null>;
80
88
  save(session: WindowSession): Promise<void>;
81
89
  };
82
- export type WindowSessionInput = Readonly<{
90
+ /** The part of an App the restore reads to find its stored window. */
91
+ export type RestorableApp = Readonly<{
92
+ surfaceId: string;
93
+ roles: readonly string[];
94
+ }>;
95
+ export type WindowSessionInput<App extends RestorableApp = AppDirectoryApp> = Readonly<{
83
96
  storage: AppStorage;
84
- manager: AppWindowManager;
85
- apps: readonly AppDirectoryApp[] | undefined;
86
- launchFor: (app: AppDirectoryApp) => AppLaunchDescriptor | null;
97
+ /** What the restore needs of the window manager. */
98
+ manager: Readonly<{
99
+ read: () => Readonly<{
100
+ windows: readonly Readonly<{
101
+ windowId: string;
102
+ }>[];
103
+ }>;
104
+ open: (launch: AppLaunchDescriptor) => Promise<void>;
105
+ minimize: (windowId: string) => Promise<void>;
106
+ }>;
107
+ apps: readonly App[] | undefined;
108
+ launchFor: (app: App) => AppLaunchDescriptor | null;
87
109
  snapshot: Omit<WindowSessionSnapshot, "frames">;
88
110
  interacting: boolean;
89
111
  /** A phone is always tiled, so it neither reads nor overwrites the choice. */
@@ -99,7 +121,7 @@ export type WindowSessionInput = Readonly<{
99
121
  * Restore the member's windows once the App directory is known, then keep
100
122
  * the stored session current. Frames seed panes as they register.
101
123
  */
102
- export declare function useWindowSession(input: WindowSessionInput): {
124
+ export declare function useWindowSession<App extends RestorableApp>(input: WindowSessionInput<App>): {
103
125
  reportFrame: (windowId: string, frame: WindowPlacement) => void;
104
126
  seedFrame: (windowId: string) => WindowPlacement | undefined;
105
127
  };
@@ -47,6 +47,33 @@ export function windowSessionFrom(snapshot) {
47
47
  windows: windows.slice(0, 16),
48
48
  });
49
49
  }
50
+ /**
51
+ * The session to store while the stored windows are still reopening. A reopen
52
+ * waits for each App to get ready, so a save that held back until the restore
53
+ * ended lost whatever the person opened meanwhile if the page reloaded first.
54
+ * Storing the windows not back yet beside the open ones keeps both: stored
55
+ * order first, then the new windows, with open windows at their current frame.
56
+ */
57
+ export function sessionWhileRestoring(current, stored) {
58
+ const open = new Map(current.windows.map((item) => [item.surfaceId, item]));
59
+ const storedIds = new Set(stored.windows.map((item) => item.surfaceId));
60
+ const merged = [
61
+ ...stored.windows.map((item) => open.get(item.surfaceId) ?? item),
62
+ ...current.windows.filter((item) => !storedIds.has(item.surfaceId)),
63
+ ];
64
+ // Over the limit, the windows not back yet go first; the open ones stay.
65
+ for (let index = 0; merged.length > 16 && index < merged.length;) {
66
+ if (open.has(merged[index]?.surfaceId ?? ""))
67
+ index += 1;
68
+ else
69
+ merged.splice(index, 1);
70
+ }
71
+ return windowSessionSchema.parse({
72
+ tiled: current.tiled,
73
+ active: current.active ?? stored.active,
74
+ windows: merged.slice(0, 16),
75
+ });
76
+ }
50
77
  /** Launches for the stored windows whose Apps are still installed, in order. */
51
78
  export function restorableLaunches(session, apps, launchFor) {
52
79
  return session.windows.flatMap((saved) => {
@@ -132,6 +159,10 @@ export function useWindowSession(input) {
132
159
  const seeds = useRef(new Map());
133
160
  const [store] = useState(() => createWindowSessionStore(input.storage));
134
161
  const [restored, setRestored] = useState(false);
162
+ // The stored session is known; saving starts here, not when the restore ends.
163
+ const [loaded, setLoaded] = useState(false);
164
+ // The stored windows, until their reopening has finished.
165
+ const pendingStored = useRef(null);
135
166
  const started = useRef(false);
136
167
  const preferredTiled = useRef(true);
137
168
  const ready = input.apps !== undefined;
@@ -142,6 +173,8 @@ export function useWindowSession(input) {
142
173
  void (async () => {
143
174
  try {
144
175
  const session = await store.load();
176
+ pendingStored.current = session;
177
+ setLoaded(true);
145
178
  const current = latest.current;
146
179
  if (!session || !current.apps)
147
180
  return;
@@ -159,6 +192,8 @@ export function useWindowSession(input) {
159
192
  latest.current.onError("Your open windows could not be restored.");
160
193
  }
161
194
  finally {
195
+ pendingStored.current = null;
196
+ setLoaded(true);
162
197
  setRestored(true);
163
198
  }
164
199
  })();
@@ -182,12 +217,15 @@ export function useWindowSession(input) {
182
217
  frames: new Map([...seeds.current, ...reported]),
183
218
  tiled: phone ? preferredTiled.current : snapshot.tiled,
184
219
  });
185
- const body = JSON.stringify(session);
186
- const pending = useRef(session);
187
- pending.current = session;
220
+ // Until the stored windows are back, store them beside the open ones.
221
+ const stored = restored ? null : pendingStored.current;
222
+ const toSave = stored ? sessionWhileRestoring(session, stored) : session;
223
+ const body = JSON.stringify(toSave);
224
+ const pending = useRef(toSave);
225
+ pending.current = toSave;
188
226
  const saved = useRef(null);
189
227
  useEffect(() => {
190
- if (!restored || interacting || saved.current === body)
228
+ if (!loaded || interacting || saved.current === body)
191
229
  return;
192
230
  const timer = setTimeout(() => {
193
231
  saved.current = body;
@@ -200,7 +238,7 @@ export function useWindowSession(input) {
200
238
  return () => {
201
239
  clearTimeout(timer);
202
240
  };
203
- }, [body, interacting, restored, store]);
241
+ }, [body, interacting, loaded, store]);
204
242
  return {
205
243
  reportFrame,
206
244
  seedFrame: (windowId) => seeds.current.get(windowId),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fungi.computer/tourtois",
3
- "version": "0.30.10",
3
+ "version": "0.31.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",
@@ -77,15 +77,15 @@
77
77
  "LICENSE"
78
78
  ],
79
79
  "dependencies": {
80
- "@fungi.computer/agar": "0.25.1",
80
+ "@fungi.computer/agar": "0.27.0",
81
81
  "@fungi.computer/cairn": "0.1.0",
82
- "@fungi.computer/caps": "0.12.7",
82
+ "@fungi.computer/caps": "0.12.8",
83
83
  "@fungi.computer/ear-tag": "0.1.0",
84
84
  "@fungi.computer/gills": "0.4.0",
85
85
  "@fungi.computer/maosaico": "0.1.2",
86
- "@fungi.computer/parakeet": "0.16.11",
87
- "@fungi.computer/puffball": "0.13.1",
88
- "@fungi.computer/shiitake": "0.22.0",
86
+ "@fungi.computer/parakeet": "0.17.0",
87
+ "@fungi.computer/puffball": "0.15.0",
88
+ "@fungi.computer/shiitake": "0.22.2",
89
89
  "@fungi.computer/sigils": "0.3.2",
90
90
  "@fungi.computer/sprite": "0.2.2",
91
91
  "@fungi.computer/sprite-zdog": "0.3.2",
@@ -100,16 +100,16 @@
100
100
  "lucide-react": "0.460.0",
101
101
  "react-dom": "18.3.1",
102
102
  "zod": "4.4.3",
103
- "@fungi.computer/nacre": "0.8.8"
103
+ "@fungi.computer/nacre": "0.9.1"
104
104
  },
105
105
  "peerDependencies": {
106
106
  "react": "^18.3.1 || ^19.2.0"
107
107
  },
108
108
  "devDependencies": {
109
- "@fungi.computer/oyster": "0.54.0",
109
+ "@fungi.computer/oyster": "0.56.0",
110
110
  "@cloudflare/workers-types": "5.20260828.1",
111
- "@fungi.computer/forage": "0.4.1",
112
- "@fungi.computer/mycelium": "0.4.9",
111
+ "@fungi.computer/forage": "0.5.1",
112
+ "@fungi.computer/mycelium": "0.4.11",
113
113
  "@ladle/react": "5.1.1",
114
114
  "@types/react": "18.3.3",
115
115
  "@vitejs/plugin-react": "6.1.1",