mirror of
https://github.com/bendtherules/opencode-multi-model.git
synced 2026-08-19 00:33:20 +00:00
fix: streamline tmux session termination and cleanup logic
This commit is contained in:
+8
-8
@@ -53,6 +53,11 @@ export async function closeMultiModel(options: CloseSessionOptions): Promise<Clo
|
|||||||
// Check if session exists
|
// Check if session exists
|
||||||
const { ok: sessionExists } = await runCommand(["tmux", "has-session", "-t", options.sessionName]);
|
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
|
// Get list of worktrees for this session before killing tmux
|
||||||
const worktrees = await getWorktreesForSession(options.sessionName);
|
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;
|
let cleanupPerformed = false;
|
||||||
|
|
||||||
// Cleanup worktrees and optionally branches
|
// 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);
|
const worktreeBase = getSessionPath(options.sessionName);
|
||||||
try {
|
try {
|
||||||
await runCommand(["rmdir", worktreeBase]);
|
await runCommand(["rm", "-rf", worktreeBase]);
|
||||||
} catch {
|
} catch {
|
||||||
// Ignore errors if directory not empty
|
// Ignore errors
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanupPerformed = worktreesRemoved.length > 0;
|
cleanupPerformed = worktreesRemoved.length > 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user