@@ -19,7 +19,6 @@ const (
1919 ScreenConnecting
2020 ScreenDashboard
2121 ScreenOverview
22- ScreenError
2322)
2423
2524type Model struct {
@@ -33,7 +32,7 @@ type Model struct {
3332 sysInfos map [string ]* SystemInfo
3433 lastUpdates map [string ]time.Time
3534 updateInterval time.Duration
36- err error
35+ failedHosts map [ string ] error
3736 width int
3837 height int
3938 sshOnExit string
@@ -138,6 +137,7 @@ func InitialModel(hosts []SSHHost, updateInterval time.Duration) Model {
138137 clients : make (map [string ]* SSHClient ),
139138 sysInfos : make (map [string ]* SystemInfo ),
140139 lastUpdates : make (map [string ]time.Time ),
140+ failedHosts : make (map [string ]error ),
141141 updateInterval : updateInterval ,
142142 }
143143}
@@ -204,6 +204,8 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
204204 }
205205 }
206206 if len (m .selectedHosts ) > 0 {
207+ m .failedHosts = make (map [string ]error )
208+
207209 hasConnections := len (m .clients ) > 0
208210
209211 if hasConnections {
@@ -259,8 +261,23 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
259261
260262 case ConnectedMsg :
261263 if msg .err != nil {
262- m .err = fmt .Errorf ("failed to connect to %s: %w" , msg .hostName , msg .err )
263- m .screen = ScreenError
264+ m .failedHosts [msg .hostName ] = msg .err
265+
266+ for i , h := range m .selectedHosts {
267+ if h .Name == msg .hostName {
268+ m .selectedHosts = append (m .selectedHosts [:i ], m .selectedHosts [i + 1 :]... )
269+ break
270+ }
271+ }
272+
273+ if len (m .selectedHosts ) == 0 {
274+ m .screen = ScreenHostList
275+ m .updateListSelection ()
276+ } else {
277+ if m .currentHostIdx >= len (m .selectedHosts ) {
278+ m .currentHostIdx = len (m .selectedHosts ) - 1
279+ }
280+ }
264281 return m , nil
265282 }
266283 m .clients [msg .hostName ] = msg .client
@@ -309,6 +326,14 @@ func (m Model) View() string {
309326 switch m .screen {
310327 case ScreenHostList :
311328 listView := m .list .View ()
329+ if len (m .failedHosts ) > 0 {
330+ failedNames := make ([]string , 0 , len (m .failedHosts ))
331+ for hostName := range m .failedHosts {
332+ failedNames = append (failedNames , hostName )
333+ }
334+ warning := fmt .Sprintf ("\n ⚠ Failed to connect: %s" , strings .Join (failedNames , ", " ))
335+ listView += lipgloss .NewStyle ().Foreground (lipgloss .Color ("208" )).Render (warning )
336+ }
312337 if len (m .selectedHosts ) > 0 {
313338 selectedNames := make ([]string , len (m .selectedHosts ))
314339 for i , h := range m .selectedHosts {
@@ -343,9 +368,6 @@ func (m Model) View() string {
343368
344369 case ScreenOverview :
345370 return m .renderOverview ()
346-
347- case ScreenError :
348- return renderError (m .err )
349371 }
350372
351373 return ""
@@ -433,11 +455,6 @@ var (
433455 headerStyle = lipgloss .NewStyle ().
434456 Bold (true ).
435457 Foreground (lipgloss .Color ("63" ))
436-
437- errorStyle = lipgloss .NewStyle ().
438- Bold (true ).
439- Foreground (lipgloss .Color ("196" )).
440- Padding (1 , 2 )
441458)
442459
443460func renderProgressBar (percent float64 , width int , color lipgloss.Color ) string {
@@ -513,10 +530,6 @@ func (m Model) renderConnectingProgress() string {
513530 return b .String ()
514531}
515532
516- func renderError (err error ) string {
517- return errorStyle .Render (fmt .Sprintf ("Error: %v\n \n Press 'q' to quit" , err ))
518- }
519-
520533func (m Model ) renderOverview () string {
521534 var b strings.Builder
522535
0 commit comments