From 003fd1a741ae9d35ecb5eb7176495fbc80d52106 Mon Sep 17 00:00:00 2001 From: gastown/crew/diesel Date: Sun, 25 Jan 2026 12:25:36 -0800 Subject: [PATCH] fix(tmux): stabilize flaky tests with WaitForShellReady TestIsAgentRunning and TestEnsureSessionFresh_ZombieSession were flaky because they checked the pane command immediately after NewSession, before the shell had fully initialized. Added WaitForShellReady calls to wait for shell readiness before assertions. Closes: gt-jzwx Co-Authored-By: Claude Opus 4.5 --- internal/tmux/tmux_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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 {