fix: detect stale tmux sessions on startInteractive/startShell

When Claude exits inside a tmux session, tmux destroys the session
(remain-on-exit is off), but the _muxSession reference persists.
On restart, startInteractive() treats it as a "restored session" and
tries to attach to the dead tmux — causing instant exit code 1.

Now checks tmux has-session before attaching. If the session is gone,
clears the stale reference and creates a fresh tmux session.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
arkonandClaude Opus 4.6 committed 2026-02-19 21:38:01 +01:00
1 parent cf0d9e7d83
commit dc6c65fd8b
5 files changed
+23 -5

No files matched your search

+4
View File
@@ -348,6 +348,10 @@ export class TmuxManager extends EventEmitter implements TerminalMultiplexer {
/**
* Check if a tmux session exists.
*/
muxSessionExists(muxName: string): boolean {
return this.sessionExists(muxName);
}
private sessionExists(muxName: string): boolean {
if (IS_TEST_MODE) return false;