diff --git a/internal/tmux/tmux_test.go b/internal/tmux/tmux_test.go index 053d2c90..5823daf8 100644 --- a/internal/tmux/tmux_test.go +++ b/internal/tmux/tmux_test.go @@ -260,6 +260,12 @@ func TestEnsureSessionFresh_ZombieSession(t *testing.T) { } defer func() { _ = tm.KillSession(sessionName) }() + // Wait for shell to be ready - avoids flaky tests where the pane command + // is briefly something other than the shell during initialization + if err := tm.WaitForShellReady(sessionName, 2*time.Second); err != nil { + t.Fatalf("WaitForShellReady: %v", err) + } + // Verify it's a zombie (not running Claude/node) if tm.IsClaudeRunning(sessionName) { t.Skip("session unexpectedly has Claude running - can't test zombie case") @@ -332,6 +338,12 @@ func TestIsAgentRunning(t *testing.T) { } defer func() { _ = tm.KillSession(sessionName) }() + // Wait for shell to be ready - avoids flaky tests where the pane command + // is briefly something other than the shell during initialization + if err := tm.WaitForShellReady(sessionName, 2*time.Second); err != nil { + t.Fatalf("WaitForShellReady: %v", err) + } + // Get the current pane command (should be bash/zsh/etc) cmd, err := tm.GetPaneCommand(sessionName) if err != nil {