From 4c71deb29d98c78ad4d4b41bc7eaee3beb4b903c Mon Sep 17 00:00:00 2001 From: wusumac <736139669@qq.com> Date: Fri, 29 May 2026 17:28:46 +0800 Subject: [PATCH] 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 --- server.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/server.py b/server.py index 0938e2c..65d8ef7 100644 --- a/server.py +++ b/server.py @@ -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"):