fix: get_tmux_status now checks exit code for dead sessions

tmux list-windows returns exit code 1 + stderr "can't find session"
when the session doesn't exist. Previously this was ignored, causing
killed sessions to still show as online with empty windows.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-29 17:28:46 +08:00
co-authored by Claude Opus 4.7
parent a0651d6e3e
commit 4c71deb29d
+3
View File
@@ -100,6 +100,9 @@ def get_tmux_status(session_name: str) -> dict:
["tmux", "list-windows", "-t", session_name, "-F", "#{window_index}:#{window_name}:#{window_active}"],
capture_output=True, text=True, timeout=5
)
# Exit code non-zero means session doesn't exist
if result.returncode != 0 or "can't find session" in result.stderr.lower() or "no server running" in result.stderr.lower():
return {"running": False, "windows": [], "active_window": None}
windows = []
active_window = None
for line in result.stdout.strip().split("\n"):