fix: tmux remain-on-exit prevents session loss when Claude exits

Previously, when Claude exited inside tmux (exitCode=0 or crash), tmux
destroyed the entire session — losing buffer, history, and causing crash
loops on restart attempts. Now:

- Set remain-on-exit on for all tmux sessions
- Detect dead panes via #{pane_dead} instead of assuming session is gone
- Respawn dead panes with tmux respawn-pane -k (preserves session)
- Applied to both startInteractive and startShell paths

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
arkon
2026-02-19 22:37:45 +01:00
co-authored by Claude Opus 4.6
parent 1b21e1b8d8
commit db3893d608
5 changed files with 114 additions and 7 deletions
+6
View File
@@ -158,4 +158,10 @@ export interface TerminalMultiplexer extends EventEmitter {
/** Check if a multiplexer session actually exists (process-level check, not just tracked) */
muxSessionExists(muxName: string): boolean;
/** Check if the pane in a session is dead (command exited but remain-on-exit keeps it alive) */
isPaneDead(muxName: string): boolean;
/** Respawn a dead pane with a fresh command. Returns the new PID or null on failure. */
respawnPane(sessionId: string, workingDir: string, mode: 'claude' | 'shell', niceConfig?: NiceConfig, model?: string): Promise<number | null>;
}