feat: persist respawn config and inner loop state across server restarts

- Add PersistedRespawnConfig type and respawnConfig field to ScreenSession
- Add innerLoopEnabled field to ScreenSession for Ralph Wiggum tracking
- Add updateRespawnConfig, clearRespawnConfig, updateInnerLoopEnabled methods to ScreenManager
- Save respawn config when enabled/updated via API endpoints
- Save inner loop enabled state when changed via API
- Restore respawn controllers and inner loop state on server startup

This ensures respawn continues working after claudeman restarts.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
arkon
2026-01-21 18:30:06 +01:00
co-authored by Claude Opus 4.5
parent 6bfc7f9027
commit e469b30ddb
3 changed files with 120 additions and 1 deletions
+28 -1
View File
@@ -19,7 +19,7 @@ import { spawn, execSync } from 'node:child_process';
import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'node:fs';
import { dirname, join } from 'node:path';
import { homedir } from 'node:os';
import { ScreenSession, ProcessStats, ScreenSessionWithStats, getErrorMessage } from './types.js';
import { ScreenSession, ProcessStats, ScreenSessionWithStats, PersistedRespawnConfig, getErrorMessage } from './types.js';
/** Path to persisted screen session metadata */
const SCREENS_FILE = join(homedir(), '.claudeman', 'screens.json');
@@ -570,6 +570,33 @@ export class ScreenManager extends EventEmitter {
}
}
// Update respawn config for a screen session (persisted across restarts)
updateRespawnConfig(sessionId: string, config: PersistedRespawnConfig | undefined): void {
const screen = this.screens.get(sessionId);
if (screen) {
screen.respawnConfig = config;
this.saveScreens();
}
}
// Clear respawn config when respawn is stopped
clearRespawnConfig(sessionId: string): void {
const screen = this.screens.get(sessionId);
if (screen && screen.respawnConfig) {
delete screen.respawnConfig;
this.saveScreens();
}
}
// Update inner loop (Ralph Wiggum) enabled state
updateInnerLoopEnabled(sessionId: string, enabled: boolean): void {
const screen = this.screens.get(sessionId);
if (screen) {
screen.innerLoopEnabled = enabled;
this.saveScreens();
}
}
// Check if screen is available on the system
static isScreenAvailable(): boolean {
try {