fix(tmux): defer subagent attach until pane focus

This commit is contained in:
Disaster-Terminator
2026-04-18 13:19:14 +08:00
committed by YeonGyu-Kim
parent 6e5a127f88
commit 688bb551b2
11 changed files with 245 additions and 15 deletions
@@ -0,0 +1,33 @@
import { getTmuxPath } from "../../../tools/interactive-bash/tmux-path-resolver"
import { log } from "../../logger"
import { runTmuxCommand } from "../runner"
import { isInsideTmux } from "./environment"
import { buildTmuxAttachCommand } from "./pane-command"
export async function activateTmuxPane(
paneId: string,
sessionId: string,
serverUrl: string,
directory: string,
): Promise<boolean> {
if (!isInsideTmux()) {
log("[activateTmuxPane] SKIP: not inside tmux", { paneId, sessionId })
return false
}
const tmux = await getTmuxPath()
if (!tmux) {
log("[activateTmuxPane] SKIP: tmux not found", { paneId, sessionId })
return false
}
const opencodeCmd = buildTmuxAttachCommand(serverUrl, sessionId, directory)
const result = await runTmuxCommand(tmux, ["respawn-pane", "-k", "-t", paneId, opencodeCmd])
if (result.exitCode !== 0) {
log("[activateTmuxPane] FAILED", { paneId, sessionId, exitCode: result.exitCode, stderr: result.stderr.trim() })
return false
}
log("[activateTmuxPane] SUCCESS", { paneId, sessionId })
return true
}