fix: persist respawn config across server restarts

- persistSessionState() now saves respawnEnabled based on config.enabled
  (user intent) instead of controller.state (running state)
- cleanupSession() saves respawn config BEFORE removing controller
- AiIdleChecker and AiPlanChecker constructors filter undefined values
  to prevent overwriting defaults (fixes "timed out after undefinedms")
- updateConfig() methods also filter undefined values

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
arkon
2026-01-25 07:42:05 +01:00
co-authored by Claude Opus 4.5
parent 8c17c54a3a
commit 4d1da8bb71
5 changed files with 43 additions and 9 deletions
+10 -2
View File
@@ -161,7 +161,11 @@ export class AiPlanChecker extends EventEmitter {
constructor(sessionId: string, config: Partial<AiPlanCheckConfig> = {}) {
super();
this.sessionId = sessionId;
this.config = { ...DEFAULT_PLAN_CHECK_CONFIG, ...config };
// Filter out undefined values to prevent overwriting defaults
const filteredConfig = Object.fromEntries(
Object.entries(config).filter(([, v]) => v !== undefined)
) as Partial<AiPlanCheckConfig>;
this.config = { ...DEFAULT_PLAN_CHECK_CONFIG, ...filteredConfig };
}
/** Get the current status */
@@ -295,7 +299,11 @@ export class AiPlanChecker extends EventEmitter {
/** Update configuration at runtime */
updateConfig(config: Partial<AiPlanCheckConfig>): void {
this.config = { ...this.config, ...config };
// Filter out undefined values to prevent overwriting existing config
const filteredConfig = Object.fromEntries(
Object.entries(config).filter(([, v]) => v !== undefined)
) as Partial<AiPlanCheckConfig>;
this.config = { ...this.config, ...filteredConfig };
if (config.enabled === false) {
this.disable('Disabled by config');
} else if (config.enabled === true && this._status === 'disabled') {