fix: select claude pane on attach and restart tmux if dead

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
centdix
2026-02-22 14:41:22 +00:00
co-authored by Claude Opus 4.6
parent 98ac164ac8
commit c62ba73ce4
2 changed files with 10 additions and 0 deletions
+1
View File
@@ -65,6 +65,7 @@ export async function attach(
`tmux set-option -t "${gName}" mouse on`,
`tmux set-option -t "${gName}" set-clipboard on`,
`tmux select-window -t "${gName}:${windowTarget}"`,
`tmux select-pane -t "${gName}:${windowTarget}.0"`,
`stty rows ${rows} cols ${cols}`,
`exec tmux attach-session -t "${gName}"`,
].join(" && ");
+9
View File
@@ -142,10 +142,19 @@ function buildSandboxAgentCmd(env: Record<string, string>, agent: Agent): string
return `${envPrefix}workmux sandbox agent -- claude --dangerously-skip-permissions --append-system-prompt '"${innerEscaped}"'`;
}
function ensureTmux(): void {
const check = Bun.spawnSync(["tmux", "list-sessions"], { stdout: "pipe", stderr: "pipe" });
if (check.exitCode !== 0) {
Bun.spawnSync(["tmux", "new-session", "-d", "-s", "0"]);
console.log("[workmux] restarted tmux session");
}
}
export async function addWorktree(
branch: string,
opts?: { prompt?: string; profile?: Profile; agent?: Agent }
): Promise<string> {
ensureTmux();
const profile = opts?.profile ?? "full";
const agent = opts?.agent ?? "claude";
const args: string[] = ["workmux", "add", "-b"]; // -b = background (don't switch tmux)