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
+3 -3
View File
@@ -299,7 +299,7 @@ function ensureCodexWorker(cwd, liveConfig) {
if (!config.enabled) {
return { enabled: false, mode: 'foreground', codexOnly: true };
}
const out = runScript('live-codex-worker.mjs', ['--background'], { cwd });
const out = runScript('live-codex-worker.mjs', ['--background', '--no-wait'], { cwd });
const result = safeParse(out);
if (!result?.ok) {
const safeFallback = result?.fallback === 'foreground' && result?.terminated !== false;
@@ -315,7 +315,7 @@ function ensureCodexWorker(cwd, liveConfig) {
}
return {
enabled: true,
mode: 'dedicated-app-server',
mode: result.starting ? 'prewarming-app-server' : 'dedicated-app-server',
codexOnly: true,
pid: result.pid,
threadId: result.threadId,
@@ -324,7 +324,7 @@ function ensureCodexWorker(cwd, liveConfig) {
profile: result.profile,
delivery: result.delivery,
foregroundTypes: ['steer', 'manual_edit_apply', 'carbonize_cleanup', 'exit'],
foregroundPoll: 'live-poll.mjs --types=steer,manual_edit_apply,carbonize_cleanup,exit',
foregroundPoll: 'live-poll.mjs --types=steer,manual_edit_apply,carbonize_cleanup,exit --codex-worker-fallback',
logPath: result.logPath || null,
};
}