Prewarm Codex Live with safe fallback

Return after a durable starting record, overlap app-server initialization with page startup, dynamically reclaim generation after worker failure, and cap hard-crash leases at 15 seconds.\n\nAI-assisted: OpenAI Codex.
This commit is contained in:
Paul Bakaus
2026-07-12 21:11:50 -07:00
parent 6f3076051f
commit 6ed43ca682
9 changed files with 170 additions and 24 deletions
+12 -2
View File
@@ -296,12 +296,22 @@ export function generationIsCanceled(eventId, { cwd = process.cwd() } = {}) {
}
export function codexWorkerStateIsOwned(state, cwd) {
return state?.owner === CODEX_WORKER_OWNER
&& canonicalPath(state?.cwd) === canonicalPath(cwd)
return codexWorkerOwnerMatches(state, cwd)
&& typeof state?.threadId === 'string'
&& state.threadId.length > 0;
}
export function codexWorkerProcessStateIsOwned(state, cwd) {
return codexWorkerOwnerMatches(state, cwd)
&& Number.isInteger(state?.pid)
&& state.pid > 0;
}
function codexWorkerOwnerMatches(state, cwd) {
return state?.owner === CODEX_WORKER_OWNER
&& canonicalPath(state?.cwd) === canonicalPath(cwd);
}
function canonicalPath(value) {
if (!value || typeof value !== 'string') return null;
const resolved = path.resolve(value);