fix: restore auto-compact/auto-clear settings on server restart

Session recovery from screens created fresh Session objects with default
values, losing the auto-compact and auto-clear settings that were saved
to state.json. Now reads them back during recovery.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
arkon
2026-01-22 20:59:18 +01:00
co-authored by Claude Opus 4.5
parent 60f73fc5fe
commit 8501dcbec5
+18
View File
@@ -1971,6 +1971,24 @@ export class WebServer extends EventEmitter {
screenSession: screen // Pass the existing screen so startInteractive() can attach to it
});
// Restore auto-compact/auto-clear settings from state.json
const savedState = this.store.getSession(screen.sessionId);
if (savedState) {
if (savedState.autoCompactEnabled !== undefined || savedState.autoCompactThreshold !== undefined) {
session.setAutoCompact(
savedState.autoCompactEnabled ?? false,
savedState.autoCompactThreshold,
savedState.autoCompactPrompt
);
}
if (savedState.autoClearEnabled !== undefined || savedState.autoClearThreshold !== undefined) {
session.setAutoClear(
savedState.autoClearEnabled ?? false,
savedState.autoClearThreshold
);
}
}
this.sessions.set(session.id, session);
this.persistSessionState(session);
this.setupSessionListeners(session);