From bab002b927536e293097d20649738b1f3ebed43d Mon Sep 17 00:00:00 2001 From: Sheldon Finlay Date: Thu, 2 Apr 2026 09:14:43 -0400 Subject: [PATCH] fix: prevent Stop hook from killing sessions outside tmux MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit tmux display-message succeeds even outside tmux by falling back to the most recently created session (agent-loop). This caused the hook to match and kill interactive CC sessions. Fix: check $TMUX env var first — only set when actually inside tmux. --- lib/hooks.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/hooks.sh b/lib/hooks.sh index a39f637..84a6f60 100644 --- a/lib/hooks.sh +++ b/lib/hooks.sh @@ -16,7 +16,9 @@ SETTINGS_FILE="${PROJECT_ROOT}/.claude/settings.local.json" # The hook command checks we're inside the agent-loop tmux session before killing. # This prevents the hook from affecting other CC sessions open in the same project. -HOOK_COMMAND='tmux display-message -p "#{session_name}" 2>/dev/null | grep -q "^agent-loop$" && kill -INT $PPID || true' +# IMPORTANT: Must check $TMUX first — tmux display-message can succeed even outside +# tmux by falling back to the most recently created session, which would be agent-loop. +HOOK_COMMAND='[ -n "$TMUX" ] && tmux display-message -p "#{session_name}" 2>/dev/null | grep -q "^agent-loop$" && kill -INT $PPID || true' install_hooks() { if [ ! -f "$SETTINGS_FILE" ]; then