fix: streamline tmux session termination and cleanup logic

This commit is contained in:
2026-03-20 08:34:38 +05:30
parent 29e32ca0f1
commit d34401bc0e
+8 -8
View File
@@ -53,6 +53,11 @@ export async function closeMultiModel(options: CloseSessionOptions): Promise<Clo
// Check if session exists
const { ok: sessionExists } = await runCommand(["tmux", "has-session", "-t", options.sessionName]);
// Kill tmux session if it exists
if (sessionExists) {
await runCommand(["tmux", "kill-session", "-t", options.sessionName]);
}
// Get list of worktrees for this session before killing tmux
const worktrees = await getWorktreesForSession(options.sessionName);
@@ -71,11 +76,6 @@ export async function closeMultiModel(options: CloseSessionOptions): Promise<Clo
}
}
// Kill tmux session if it exists
if (sessionExists) {
await runCommand(["tmux", "kill-session", "-t", options.sessionName]);
}
let cleanupPerformed = false;
// Cleanup worktrees and optionally branches
@@ -106,12 +106,12 @@ export async function closeMultiModel(options: CloseSessionOptions): Promise<Clo
}
}
// Also remove the base directory if empty
// Also remove the base directory
const worktreeBase = getSessionPath(options.sessionName);
try {
await runCommand(["rmdir", worktreeBase]);
await runCommand(["rm", "-rf", worktreeBase]);
} catch {
// Ignore errors if directory not empty
// Ignore errors
}
cleanupPerformed = worktreesRemoved.length > 0;