Clear tmux scrollback on handoff
Adds ClearHistory method to tmux package and calls it before respawn-pane during handoff. This resets copy-mode display from [0/N] to [0/0] for a clean session start. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -137,10 +137,17 @@ func runHandoff(cmd *cobra.Command, args []string) error {
|
||||
|
||||
// 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
|
||||
fmt.Printf("%s Warning: could not clear history: %v\n", style.Dim.Render("⚠"), err)
|
||||
}
|
||||
|
||||
// Use exec to respawn the pane - this kills us and restarts
|
||||
return t.RespawnPane(pane, restartCmd)
|
||||
}
|
||||
@@ -395,6 +402,7 @@ func handoffRemoteSession(t *tmux.Tmux, targetSession, restartCmd string) error
|
||||
|
||||
// Dry run mode
|
||||
if handoffDryRun {
|
||||
fmt.Printf("Would execute: tmux clear-history -t %s\n", targetPane)
|
||||
fmt.Printf("Would execute: tmux respawn-pane -k -t %s %s\n", targetPane, restartCmd)
|
||||
if handoffWatch {
|
||||
fmt.Printf("Would execute: tmux switch-client -t %s\n", targetSession)
|
||||
@@ -402,6 +410,12 @@ func handoffRemoteSession(t *tmux.Tmux, targetSession, restartCmd string) error
|
||||
return nil
|
||||
}
|
||||
|
||||
// Clear scrollback history before respawn (resets copy-mode from [0/N] to [0/0])
|
||||
if err := t.ClearHistory(targetPane); err != nil {
|
||||
// Non-fatal - continue with respawn even if clear fails
|
||||
fmt.Printf("%s Warning: could not clear history: %v\n", style.Dim.Render("⚠"), err)
|
||||
}
|
||||
|
||||
// Respawn the remote session's pane
|
||||
if err := t.RespawnPane(targetPane, restartCmd); err != nil {
|
||||
return fmt.Errorf("respawning pane: %w", err)
|
||||
|
||||
Reference in New Issue
Block a user