fix: server shutdown no longer kills tmux sessions — detach instead of cleanup

Previously, server.stop() called cleanupSession(killMux=false) for all sessions,
which still tore down session state, removed listeners, killed PTY processes via
node-pty SIGHUP, and broadcast session:deleted. This caused Claude sessions
running inside tmux to be disrupted during COM deploys.

Now server shutdown just persists state, removes listeners, and lets the Node.js
process exit naturally. The tmux sessions survive independently, and
restoreMuxSessions() finds them alive on restart.

Also adds defense-in-depth in session.stop(): when killMux=false, skip PTY kill
entirely (just null the reference). And adds 'detached' lifecycle event type for
accurate audit logging.
This commit is contained in:
arkon committed 2026-02-19 22:15:36 +01:00
1 parent c748aedcd2
commit 1b21e1b8d8
5 files changed
+77 -36

No files matched your search

+1
View File
@@ -84,6 +84,7 @@ export type LifecycleEventType =
| 'started' // PTY process launched (interactive/shell/prompt)
| 'exit' // PTY process exited (with exit code)
| 'deleted' // cleanupSession() called — session removed
| 'detached' // Server shutdown — PTY left alive in tmux for recovery
| 'recovered' // Session restored from tmux on server restart
| 'stale_cleaned' // Removed from state.json by cleanupStaleSessions()
| 'mux_died' // tmux session died (detected by reconciliation)