119e18c810
- Extract atlas/ into 15 focused modules (hook, event handler, tool policies, types, etc.) - Split auto-update-checker into checker/ and hook/ subdirectories with single-purpose files - Decompose session-recovery into separate recovery strategy files per error type - Extract todo-continuation-enforcer from monolith to directory with dedicated modules - Split background-task/tools.ts into individual tool creator files - Extract command-executor, tmux-utils into focused sub-modules - Split config/schema.ts into domain-specific schema files - Decompose cli/config-manager.ts into focused modules - Rollback skill-mcp-manager, model-availability, index.ts splits that broke tests - Fix all import path depths for moved files (../../ -> ../../../) - Add explicit type annotations to resolve TS7006 implicit any errors Typecheck: 0 errors Tests: 2359 pass, 5 fail (all pre-existing)
49 lines
1.2 KiB
TypeScript
49 lines
1.2 KiB
TypeScript
import { spawn } from "bun"
|
|
import { getTmuxPath } from "../../../tools/interactive-bash/tmux-path-resolver"
|
|
import { isInsideTmux } from "./environment"
|
|
|
|
function delay(milliseconds: number): Promise<void> {
|
|
return new Promise((resolve) => setTimeout(resolve, milliseconds))
|
|
}
|
|
|
|
export async function closeTmuxPane(paneId: string): Promise<boolean> {
|
|
const { log } = await import("../../logger")
|
|
|
|
if (!isInsideTmux()) {
|
|
log("[closeTmuxPane] SKIP: not inside tmux")
|
|
return false
|
|
}
|
|
|
|
const tmux = await getTmuxPath()
|
|
if (!tmux) {
|
|
log("[closeTmuxPane] SKIP: tmux not found")
|
|
return false
|
|
}
|
|
|
|
log("[closeTmuxPane] sending Ctrl+C for graceful shutdown", { paneId })
|
|
const ctrlCProc = spawn([tmux, "send-keys", "-t", paneId, "C-c"], {
|
|
stdout: "pipe",
|
|
stderr: "pipe",
|
|
})
|
|
await ctrlCProc.exited
|
|
|
|
await delay(250)
|
|
|
|
log("[closeTmuxPane] killing pane", { paneId })
|
|
|
|
const proc = spawn([tmux, "kill-pane", "-t", paneId], {
|
|
stdout: "pipe",
|
|
stderr: "pipe",
|
|
})
|
|
const exitCode = await proc.exited
|
|
const stderr = await new Response(proc.stderr).text()
|
|
|
|
if (exitCode !== 0) {
|
|
log("[closeTmuxPane] FAILED", { paneId, exitCode, stderr: stderr.trim() })
|
|
} else {
|
|
log("[closeTmuxPane] SUCCESS", { paneId })
|
|
}
|
|
|
|
return exitCode === 0
|
|
}
|