From f7e29236d1a93fb2eae8fd98468d5d29949e219f Mon Sep 17 00:00:00 2001 From: Steve Yegge Date: Thu, 25 Dec 2025 22:05:44 -0800 Subject: [PATCH] Fix dry-run bug in gt handoff - check before side effects (gt-sq0t3) --- internal/cmd/handoff.go | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/internal/cmd/handoff.go b/internal/cmd/handoff.go index ce11d192..bd2b5e71 100644 --- a/internal/cmd/handoff.go +++ b/internal/cmd/handoff.go @@ -123,6 +123,19 @@ func runHandoff(cmd *cobra.Command, args []string) error { return handoffRemoteSession(t, targetSession, restartCmd) } + // Handing off ourselves - print feedback then respawn + fmt.Printf("%s Handing off %s...\n", style.Bold.Render("🤝"), currentSession) + + // Dry run mode - show what would happen (BEFORE any side effects) + if handoffDryRun { + if handoffSubject != "" || handoffMessage != "" { + fmt.Printf("Would send handoff mail: subject=%q\n", handoffSubject) + } + fmt.Printf("Would execute: tmux clear-history -t %s\n", pane) + fmt.Printf("Would execute: tmux respawn-pane -k -t %s %s\n", pane, restartCmd) + return nil + } + // If subject/message provided, send handoff mail to self first if handoffSubject != "" || handoffMessage != "" { if err := sendHandoffMail(handoffSubject, handoffMessage); err != nil { @@ -133,16 +146,6 @@ func runHandoff(cmd *cobra.Command, args []string) error { } } - // Handing off ourselves - print feedback then respawn - fmt.Printf("%s Handing off %s...\n", style.Bold.Render("🤝"), currentSession) - - // Dry run mode - show what would happen - if handoffDryRun { - fmt.Printf("Would execute: tmux clear-history -t %s\n", pane) - fmt.Printf("Would execute: tmux respawn-pane -k -t %s %s\n", pane, restartCmd) - return nil - } - // Clear scrollback history before respawn (resets copy-mode from [0/N] to [0/0]) if err := t.ClearHistory(pane); err != nil { // Non-fatal - continue with respawn even if clear fails