From b43a67eb1a036f74eacf4ab35463b25e384bddf9 Mon Sep 17 00:00:00 2001 From: zxr Date: Tue, 30 Sep 2025 11:27:32 +0800 Subject: [PATCH] feat: auto ping after sshm turn on. --- internal/ui/tui.go | 6 ++++++ internal/ui/update.go | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/internal/ui/tui.go b/internal/ui/tui.go index cdc44a1..3fce8d3 100644 --- a/internal/ui/tui.go +++ b/internal/ui/tui.go @@ -152,6 +152,12 @@ func RunInteractiveMode(hosts []config.SSHHost, configFile, currentVersion strin // Start the application in alt screen mode for clean output p := tea.NewProgram(m, tea.WithAltScreen()) + + // Send initial command to start auto-ping when the program starts + go func() { + p.Send(autoPingMsg{}) + }() + _, err := p.Run() if err != nil { return fmt.Errorf("error running TUI: %w", err) diff --git a/internal/ui/update.go b/internal/ui/update.go index f633212..8e521ce 100644 --- a/internal/ui/update.go +++ b/internal/ui/update.go @@ -20,6 +20,7 @@ type ( versionCheckMsg *version.UpdateInfo versionErrorMsg error errorMsg string + autoPingMsg struct{} ) // startPingAllCmd creates a command to ping all hosts concurrently @@ -145,6 +146,10 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } return m, nil + case autoPingMsg: + // Handle auto-ping on startup - start pinging all hosts + return m, m.startPingAllCmd() + case versionCheckMsg: // Handle version check result if msg != nil {