Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions internal/ui/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,10 @@ func (a App) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}
return a, nil
case output.ErrorEvent:
if a.headerLoading {
a.hideHeader = true
a.headerLoading = false
}
a.errorDisplay = a.errorDisplay.Show(msg)
a.spinner, _ = a.spinner.Stop()
return a, nil
Expand Down
39 changes: 39 additions & 0 deletions internal/ui/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,45 @@ func TestAppErrorEventStopsSpinner(t *testing.T) {
}
}

func TestAppErrorEventHidesLoadingHeader(t *testing.T) {
t.Parallel()

// When Docker is unavailable, the unhealthy ErrorEvent arrives before the
// label resolves, freezing the header dots mid-animation. Hiding the header
// in that window keeps the error the only thing on screen.
app := NewApp("dev", "", "", nil, withHeaderLoading())
if app.hideHeader {
t.Fatal("expected header to be visible while loading")
}

model, _ := app.Update(output.ErrorEvent{Title: "Docker is not available"})
app = model.(App)

if !app.hideHeader {
t.Fatal("expected header to be hidden after early ErrorEvent")
}
if app.headerLoading {
t.Fatal("expected headerLoading to be cleared after early ErrorEvent")
}
}

func TestAppErrorEventKeepsHeaderAfterLabelResolved(t *testing.T) {
t.Parallel()

// Once the label has resolved, the header is meaningful (e.g. "LocalStack
// Ultimate") and should stay visible even if a later error occurs.
app := NewApp("dev", "", "", nil, withHeaderLoading())
model, _ := app.Update(headerLabelMsg{label: "LocalStack Ultimate"})
app = model.(App)

model, _ = app.Update(output.ErrorEvent{Title: "Something went wrong"})
app = model.(App)

if app.hideHeader {
t.Fatal("expected header to remain visible after label resolved")
}
}

func TestAppSilentErrorDoesNotOverwriteErrorDisplay(t *testing.T) {
t.Parallel()

Expand Down
Loading