gestalt-mobile 0.65.2 → 0.65.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.
|
@@ -561,9 +561,43 @@ export class CodexSessionRuntime {
|
|
|
561
561
|
const processes = await this.inspectChildProcesses(writer.session, thread);
|
|
562
562
|
if (!current())
|
|
563
563
|
return false;
|
|
564
|
-
if (thread.status === 'notLoaded'
|
|
565
|
-
recordedProcesses.
|
|
566
|
-
|
|
564
|
+
if (thread.status === 'notLoaded') {
|
|
565
|
+
const unresolved = recordedProcesses.filter((p) => p.ownerThreadId === thread.id && ['running', 'detached-active'].includes(p.state));
|
|
566
|
+
// Closing the old runtime can leave a stale running projection. Unloaded
|
|
567
|
+
// alone is not exit evidence; require the exact durable command result.
|
|
568
|
+
if (unresolved.length) {
|
|
569
|
+
if (unresolved.some((p) => !p.itemId))
|
|
570
|
+
return false;
|
|
571
|
+
const result = await resource.process.rpc.request('thread/read', {
|
|
572
|
+
threadId: thread.id,
|
|
573
|
+
includeTurns: true,
|
|
574
|
+
});
|
|
575
|
+
const history = asRecord(asRecord(result)?.thread);
|
|
576
|
+
if (!current() || history?.id !== thread.id)
|
|
577
|
+
return false;
|
|
578
|
+
const turns = history.turns;
|
|
579
|
+
if (!Array.isArray(turns) || turns.length > 10_000)
|
|
580
|
+
return false;
|
|
581
|
+
const completed = new Map();
|
|
582
|
+
for (const turn of turns) {
|
|
583
|
+
const items = asRecord(turn)?.items;
|
|
584
|
+
if (!Array.isArray(items) || items.length > 10_000)
|
|
585
|
+
return false;
|
|
586
|
+
for (const candidate of items) {
|
|
587
|
+
const item = asRecord(candidate);
|
|
588
|
+
const itemId = boundedString(item?.id, 256);
|
|
589
|
+
const processId = boundedString(item?.processId, 256);
|
|
590
|
+
if (item?.type === 'commandExecution' &&
|
|
591
|
+
itemId &&
|
|
592
|
+
processId &&
|
|
593
|
+
['completed', 'failed', 'declined'].includes(String(item.status)))
|
|
594
|
+
completed.set(itemId, processId);
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
if (unresolved.some((p) => completed.get(p.itemId) !== p.processId))
|
|
598
|
+
return false;
|
|
599
|
+
}
|
|
600
|
+
}
|
|
567
601
|
if (thread.status !== 'notLoaded')
|
|
568
602
|
await this.interruptExecutor(writer.session, thread.id);
|
|
569
603
|
for (const process of processes) {
|