From 5b39be8eb230d2a405e21ff3caf11e91cf687a99 Mon Sep 17 00:00:00 2001 From: Tyler Koenig Date: Thu, 4 Jun 2026 12:34:10 -0400 Subject: [PATCH] fix(tui): broken tick chain after form/dialog + retries off-by-one Update() routed form and confirm-delete states before handling time.Time ticks, so those handlers swallowed the tick command and permanently broke the refresh loop. After opening any form or delete dialog, the TUI stopped auto-refreshing until restarted. Move time.Time and WindowSizeMsg handling before state dispatch so ticks always fire regardless of view state. Also fix fmtRetries off-by-one: FailureCount=1 displayed as 0/N instead of 1/N due to an erroneous subtract-one. --- internal/tui/format.go | 6 +----- internal/tui/update.go | 11 +++++++---- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/internal/tui/format.go b/internal/tui/format.go index 3c87f1d..a2e553d 100644 --- a/internal/tui/format.go +++ b/internal/tui/format.go @@ -110,11 +110,7 @@ func fmtSSL(site models.Site) string { } func fmtRetries(site models.Site) string { - retriesDone := site.FailureCount - 1 - if retriesDone < 0 { - retriesDone = 0 - } - dispCount := retriesDone + dispCount := site.FailureCount if dispCount > site.MaxRetries { dispCount = site.MaxRetries } diff --git a/internal/tui/update.go b/internal/tui/update.go index 2f5514c..3488460 100644 --- a/internal/tui/update.go +++ b/internal/tui/update.go @@ -10,6 +10,13 @@ import ( ) func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { + switch msg := msg.(type) { + case tea.WindowSizeMsg: + return m.handleResize(msg) + case time.Time: + return m.handleTick(msg) + } + if m.state == stateConfirmDelete { return m.handleConfirmDelete(msg) } @@ -18,10 +25,6 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } switch msg := msg.(type) { - case tea.WindowSizeMsg: - return m.handleResize(msg) - case time.Time: - return m.handleTick(msg) case tea.MouseMsg: return m.handleMouse(msg) case tea.KeyMsg: