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
19 changes: 19 additions & 0 deletions coordinator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"bytes"
"encoding/json"
"errors"
"fmt"
"io/fs"
"os"
"path/filepath"
"regexp"
Expand Down Expand Up @@ -888,6 +890,23 @@ func TestNoAutomaticRestartDuringCoordinatorSetUp(t *testing.T) {
}
}

func TestFirstRunRefreshIsNoFailure(t *testing.T) {
coordinatorFixture(t)
m := initialModel(nil, "", nil)
res, _ := m.Update(refreshMsg{err: fmt.Errorf("scan: %w", fs.ErrNotExist)})
if res.(model).refreshFailed {
t.Error("no folder yet, nothing to list: not a failure")
}
m = initialModel(buildItems([]Conversation{{SessionID: "a", Title: "x"}}), "", nil)
if res, _ := m.Update(refreshMsg{err: fmt.Errorf("scan: %w", fs.ErrNotExist)}); !res.(model).refreshFailed {
t.Error("a folder that vanished under a list still is")
}
m = initialModel(nil, "", nil)
if res, _ := m.Update(refreshMsg{err: errors.New("disk on fire")}); !res.(model).refreshFailed {
t.Error("any other error still is")
}
}

func TestEnterOnAnEmptyListWaitsForTheSetUp(t *testing.T) {
coordinatorFixture(t)
m := initialModel(nil, "", nil)
Expand Down
2 changes: 1 addition & 1 deletion parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ func TestRefreshNote(t *testing.T) {
if m = res.(model); m.refreshNote() != " · refreshing…" {
t.Errorf("in-flight scan should say refreshing, got %q", m.refreshNote())
}
res, _ = m.Update(refreshMsg{err: os.ErrNotExist})
res, _ = m.Update(refreshMsg{err: os.ErrPermission})
if m = res.(model); !strings.HasPrefix(m.refreshNote(), " · refresh failed") {
t.Errorf("failed scan should say so, got %q", m.refreshNote())
}
Expand Down
4 changes: 3 additions & 1 deletion ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io/fs"
"maps"
"os"
"path/filepath"
Expand Down Expand Up @@ -1096,7 +1097,8 @@ func (m model) update(msg tea.Msg) (tea.Model, tea.Cmd) {

case refreshMsg:
m.refreshStarted = time.Time{}
m.refreshFailed = msg.err != nil
// No projects folder yet on a first run is an empty list, not a failure.
m.refreshFailed = msg.err != nil && !(errors.Is(msg.err, fs.ErrNotExist) && len(m.items) == 0)
m.live = msg.live // liveness is independent of the list, never stale-dropped
// Delete/prune/rename prompts hold an index into m.filtered, so don't
// reshuffle it under them; and a scan that started before a delete,
Expand Down
Loading