gestalt-mobile 0.69.0 → 0.70.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.
@@ -167,6 +167,7 @@ export class CodexSessionRuntime {
167
167
  void _legacyRequestTimeoutMs;
168
168
  }
169
169
  sessions = new Map();
170
+ historyShutdown = new AbortController();
170
171
  historyReads = new Map();
171
172
  childTopologyReads = new Map();
172
173
  writerAcquisitions = new Map();
@@ -345,6 +346,7 @@ export class CodexSessionRuntime {
345
346
  }
346
347
  /** Releases all relay-owned app-server children during graceful shutdown. */
347
348
  stopAll() {
349
+ this.cancelHistoryReads();
348
350
  // Exit delivery can already be queued when shutdown begins. Declare the
349
351
  // shared intent for every owner before closing any process.
350
352
  const resources = [...this.sessions.values()];
@@ -358,6 +360,8 @@ export class CodexSessionRuntime {
358
360
  this.retrieval?.release?.(resource.sessionId);
359
361
  }
360
362
  async drainReleases() {
363
+ if (this.historyShutdown.signal.aborted)
364
+ await Promise.allSettled([...this.historyReads.values()]);
361
365
  await Promise.allSettled([...this.liveResources.values()].flatMap((resources) => [...resources].map((resource) => {
362
366
  resource.beginExplicitShutdown();
363
367
  resource.dispose();
@@ -826,12 +830,32 @@ export class CodexSessionRuntime {
826
830
  process.close();
827
831
  }
828
832
  }
833
+ /** Unblock HTTP history requests before the server waits for them to drain. */
834
+ cancelHistoryReads() {
835
+ this.historyShutdown.abort(new Error('CODEX_APP_SERVER_CLOSED'));
836
+ }
837
+ async historyUntilShutdown(read) {
838
+ const signal = this.historyShutdown.signal;
839
+ signal.throwIfAborted();
840
+ let cancel;
841
+ const cancelled = new Promise((_, reject) => {
842
+ cancel = () => reject(signal.reason);
843
+ signal.addEventListener('abort', cancel, { once: true });
844
+ });
845
+ try {
846
+ return await Promise.race([read(), cancelled]);
847
+ }
848
+ finally {
849
+ signal.removeEventListener('abort', cancel);
850
+ }
851
+ }
829
852
  async readHistory(session) {
830
853
  if (!session.threadId)
831
854
  throw new Error('CODEX_THREAD_ID_MISSING');
855
+ this.historyShutdown.signal.throwIfAborted();
832
856
  const owned = this.sessions.get(session.id);
833
857
  if (owned)
834
- return this.decodeHistory(owned.process, session.threadId, owned);
858
+ return this.historyUntilShutdown(() => this.decodeHistory(owned.process, session.threadId, owned));
835
859
  const existing = this.historyReads.get(session.id);
836
860
  if (existing)
837
861
  return existing;
@@ -1255,14 +1279,19 @@ export class CodexSessionRuntime {
1255
1279
  cwd: this.readerCwd ?? session.workspacePath,
1256
1280
  });
1257
1281
  try {
1258
- await process.rpc.request('initialize', {
1259
- clientInfo: { name: 'gestalt-mobile', version: '0.1.0' },
1260
- capabilities: { experimentalApi: true },
1282
+ return await this.historyUntilShutdown(async () => {
1283
+ await process.rpc.request('initialize', {
1284
+ clientInfo: { name: 'gestalt-mobile', version: '0.1.0' },
1285
+ capabilities: { experimentalApi: true },
1286
+ });
1287
+ return this.decodeHistory(process, session.threadId);
1261
1288
  });
1262
- return await this.decodeHistory(process, session.threadId);
1263
1289
  }
1264
1290
  finally {
1265
- process.close();
1291
+ if (this.historyShutdown.signal.aborted && process.closeAndWait)
1292
+ await process.closeAndWait();
1293
+ else
1294
+ process.close();
1266
1295
  }
1267
1296
  }
1268
1297
  async decodeHistory(process, threadId, resource) {
@@ -205,6 +205,11 @@ export class FilesystemWorkspaceFiles {
205
205
  const root = await this.canonicalDirectory(rootPath);
206
206
  if (!root)
207
207
  return { kind: 'unreadable' };
208
+ if (input.directory === '.gestalt' && /\.org$/i.test(input.filename)) {
209
+ const directory = await this.createDirectory(root, { directory: '', name: '.gestalt' });
210
+ if (directory.kind !== 'available' && directory.kind !== 'conflict')
211
+ return directory;
212
+ }
208
213
  const parent = await anchoredDirectory(root, input.directory);
209
214
  if (!parent)
210
215
  return { kind: 'invalid-destination' };
@@ -119,6 +119,18 @@ export class FilesystemWorkspacePlanCatalog {
119
119
  return { kind: 'missing' };
120
120
  return this.readFromWorkspace(workspace, planName);
121
121
  }
122
+ /** Downloads the original Org text through the same bounded, confined reader as the viewer. */
123
+ async readSource(workspacePath, planName) {
124
+ if (!isPlanPath(planName))
125
+ return { kind: 'missing' };
126
+ const workspace = await this.workspace(workspacePath);
127
+ if (!workspace)
128
+ return { kind: 'missing' };
129
+ const candidate = await this.readCandidate(workspace, planName);
130
+ return candidate.kind === 'readable'
131
+ ? { kind: 'available', source: candidate.source }
132
+ : candidate;
133
+ }
122
134
  /** Reuses the exact viewer reader without trusting its cached preview or sourcePath. */
123
135
  async readExecution(workspacePath, planName) {
124
136
  if (!isPlanPath(planName))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gestalt-mobile",
3
- "version": "0.69.0",
3
+ "version": "0.70.0",
4
4
  "description": "Mobile-first web relay for durable Codex development sessions",
5
5
  "keywords": [
6
6
  "codex",