fix: add screens.json fallback for respawn recovery

state.json is now the primary source for session recovery, but
screens.json is used as a fallback for respawn config since it was
the proven working path before. This provides double-redundancy:
both files would need to be lost for respawn state to disappear.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
arkon
2026-01-22 21:23:59 +01:00
co-authored by Claude Opus 4.5
parent a006621cd0
commit 024425e979
+26
View File
@@ -2030,6 +2030,32 @@ export class WebServer extends EventEmitter {
}
}
// Fallback: restore respawn from screens.json if state.json didn't have it
if (!this.respawnControllers.has(session.id) && screen.respawnConfig?.enabled) {
try {
const controller = new RespawnController(session, {
idleTimeoutMs: screen.respawnConfig.idleTimeoutMs,
updatePrompt: screen.respawnConfig.updatePrompt,
interStepDelayMs: screen.respawnConfig.interStepDelayMs,
enabled: true,
sendClear: screen.respawnConfig.sendClear,
sendInit: screen.respawnConfig.sendInit,
kickstartPrompt: screen.respawnConfig.kickstartPrompt,
});
this.respawnControllers.set(session.id, controller);
this.setupRespawnListeners(session.id, controller);
controller.start();
if (screen.respawnConfig.durationMinutes && screen.respawnConfig.durationMinutes > 0) {
this.setupTimedRespawn(session.id, screen.respawnConfig.durationMinutes);
}
console.log(`[Server] Restored respawn controller from screens.json for session ${session.id}`);
} catch (err) {
console.error(`[Server] Failed to restore respawn from screens.json for session ${session.id}:`, err);
}
}
// Fallback: restore Ralph state from state-inner.json if not already set
if (!session.ralphTracker.enabled) {
const ralphState = this.store.getRalphState(screen.sessionId);