gestalt-mobile 0.71.0 → 0.71.1

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.
@@ -55,6 +55,8 @@ class SessionResource {
55
55
  explicitShutdown = false;
56
56
  pendingRequests = new Map();
57
57
  threadId;
58
+ /** Only locally created roots are known empty, until any root turn is attempted or observed. */
59
+ historyKnownEmpty = false;
58
60
  pendingThreadName;
59
61
  writtenThreadName;
60
62
  capabilities = new Map();
@@ -218,6 +220,7 @@ export class CodexSessionRuntime {
218
220
  if (resource.retrieval)
219
221
  this.retrieval?.bound?.(resource.retrieval, startedThreadId);
220
222
  await this.verifyRetrieval(resource, session, true, beforeThreadStart);
223
+ resource.historyKnownEmpty = true;
221
224
  await this.scratch?.associateProviderThread(session, 'codex', resource.threadId);
222
225
  assertCurrent();
223
226
  this.sessions.set(session.id, resource);
@@ -435,6 +438,8 @@ export class CodexSessionRuntime {
435
438
  throw new Error('CODEX_SESSION_NOT_RUNNING');
436
439
  if (mayStart && !mayStart())
437
440
  throw new Error('CODEX_TURN_START_CANCELLED');
441
+ // Fence before the RPC: an uncertain or failed response may still have started a turn.
442
+ resource.historyKnownEmpty = false;
438
443
  const result = decodeTurnStart(await resource.process.rpc.request('turn/start', {
439
444
  threadId: session.threadId,
440
445
  input: [
@@ -1295,8 +1300,32 @@ export class CodexSessionRuntime {
1295
1300
  }
1296
1301
  }
1297
1302
  async decodeHistory(process, threadId, resource) {
1298
- const response = await process.rpc.request('thread/read', { threadId, includeTurns: true });
1303
+ let response;
1304
+ try {
1305
+ response = await process.rpc.request('thread/read', { threadId, includeTurns: true });
1306
+ }
1307
+ catch (error) {
1308
+ // Untouched roots may not have a rollout yet. Never infer empty history
1309
+ // from a generic provider failure, a restored thread, or a thread's age.
1310
+ const unmaterialized = error instanceof CodexJsonRpcError &&
1311
+ ((error.code === -32601 && error.message === 'list_turns is not supported yet') ||
1312
+ (error.code === -32600 &&
1313
+ error.message ===
1314
+ `thread ${threadId} is not materialized yet; includeTurns is unavailable before first user message`));
1315
+ const knownEmpty = () => resource?.historyKnownEmpty === true &&
1316
+ resource.active &&
1317
+ resource.threadId === threadId &&
1318
+ this.sessions.get(resource.sessionId) === resource;
1319
+ if (!unmaterialized || !knownEmpty())
1320
+ throw error;
1321
+ const metadata = await process.rpc.request('thread/read', { threadId, includeTurns: false });
1322
+ const thread = asRecord(asRecord(metadata)?.thread);
1323
+ if (!knownEmpty() || thread?.id !== threadId || asRecord(thread.status)?.type !== 'idle')
1324
+ throw error;
1325
+ return { turns: [], activeTurnId: null };
1326
+ }
1299
1327
  if (resource) {
1328
+ resource.historyKnownEmpty = false;
1300
1329
  for (const [childId, model] of decodeSpawnedAgentModels(response))
1301
1330
  resource.spawnedAgentModels.set(childId, model);
1302
1331
  }
@@ -1368,6 +1397,7 @@ export class CodexSessionRuntime {
1368
1397
  }
1369
1398
  const replacementThreadId = await this.startThread(resource.process, session, resource.skillsConfig, resource.modelConfig);
1370
1399
  result = rebindMissingRollout(session, error, replacementThreadId, now);
1400
+ resource.historyKnownEmpty = true;
1371
1401
  }
1372
1402
  resource.threadId = result.session.threadId;
1373
1403
  if (resource.retrieval)
@@ -1556,6 +1586,9 @@ export class CodexSessionRuntime {
1556
1586
  const notificationUnsubscribe = process.rpc.onNotification((notification) => {
1557
1587
  if (!resource.active)
1558
1588
  return;
1589
+ if (notification.method === 'turn/started' &&
1590
+ asRecord(notification.params)?.threadId === resource.threadId)
1591
+ resource.historyKnownEmpty = false;
1559
1592
  this.retrieval?.observe?.(session.id, notification);
1560
1593
  // Internal evidence may only be constructed by this resource's tracker.
1561
1594
  if (notification.method === 'gestalt/mcpStartup')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gestalt-mobile",
3
- "version": "0.71.0",
3
+ "version": "0.71.1",
4
4
  "description": "Mobile-first web relay for durable Codex development sessions",
5
5
  "keywords": [
6
6
  "codex",