fix: don't wipe session state from state.json on server shutdown

cleanupSession() always called store.removeSession() which deleted the
session from state.json. On server stop, cleanupSession(id, false) was
called for all sessions - preserving screens but deleting their saved
state. On next restart, state.json was empty so nothing was restored.

Now only removes from state.json when killScreen=true (user explicitly
deleting a session), preserving state for recovery on restart.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
arkon
2026-01-22 21:22:07 +01:00
co-authored by Claude Opus 4.5
parent 35c2f4fb61
commit a006621cd0
+5 -1
View File
@@ -1390,7 +1390,11 @@ export class WebServer extends EventEmitter {
session.removeAllListeners();
await session.stop(killScreen);
this.sessions.delete(sessionId);
this.store.removeSession(sessionId);
// Only remove from state.json if we're also killing the screen.
// When killScreen=false (server shutdown), preserve state for recovery.
if (killScreen) {
this.store.removeSession(sessionId);
}
}
this.broadcast('session:deleted', { id: sessionId });