Fix dry-run bug in gt handoff - check before side effects (gt-sq0t3)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user