From 9b5c88979569dcc0f72b2d2191121cf338053783 Mon Sep 17 00:00:00 2001 From: Steve Yegge Date: Wed, 7 Jan 2026 18:20:09 -0800 Subject: [PATCH] fix(costs): detect tmux session without TMUX env var The TMUX environment variable is not inherited when Claude Code runs bash commands, even though we are inside a tmux session. This caused the Stop hook's 'gt costs record' to fail with: Error: --session flag required Fix: Remove the early return that checked TMUX env var. The tmux display-message command will naturally fail if we're not in tmux, so the check was unnecessary and harmful. Fixes: hq-to0lr Co-Authored-By: Claude Opus 4.5 --- internal/cmd/costs.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/internal/cmd/costs.go b/internal/cmd/costs.go index a8cd4e18..7568055e 100644 --- a/internal/cmd/costs.go +++ b/internal/cmd/costs.go @@ -664,12 +664,9 @@ func deriveSessionName() string { // detectCurrentTmuxSession returns the current tmux session name if running inside tmux. // Uses `tmux display-message -p '#S'` which prints the session name. +// Note: We don't check TMUX env var because it may not be inherited when Claude Code +// runs bash commands, even though we are inside a tmux session. func detectCurrentTmuxSession() string { - // Check if we're inside tmux - if os.Getenv("TMUX") == "" { - return "" - } - cmd := exec.Command("tmux", "display-message", "-p", "#S") output, err := cmd.Output() if err != nil {