fix issues TUI display reliability
Build and Publish / Metadata (push) Successful in 10s
Build and Publish / BuildAndDeployAmd64 (push) Successful in 2m0s

This commit is contained in:
mats committed 2026-09-24 11:11:29 +02:00
1 parent a96e95212a
commit f5015581a4
5 files changed
+84 -5

No files matched your search

+11 -2
View File
@@ -25,6 +25,9 @@ type model struct {
sc *scanner
cfg modelConfig
snap snapshot
// scanErr is kept separately so a failed refresh does not erase the last
// successful data from the display.
scanErr error
scanning bool
nextScanAt time.Time
@@ -79,7 +82,13 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m, cmd
case snapshotMsg:
m.snap = snapshot(msg)
snap := snapshot(msg)
if snap.Err != nil {
m.scanErr = snap.Err
} else {
m.snap = snap
m.scanErr = nil
}
m.scanning = false
m.nextScanAt = time.Now().Add(m.cfg.Interval)
return m, nil
@@ -90,6 +99,6 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
func (m model) View() string {
return renderSnapshot(m.snap, snapshotOptions{
Width: m.width, Height: m.height, Title: m.cfg.Title, BaseURL: m.cfg.BaseURL,
Scanning: m.scanning, NextScanAt: m.nextScanAt, Now: time.Now(),
Scanning: m.scanning, NextScanAt: m.nextScanAt, Now: time.Now(), ScanError: m.scanErr,
})
}