feat: a list from the cache says how old it is while it reloads
CI / Checks (pull_request) Successful in 24s
PR title / Conventional title (pull_request) Successful in 2s

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
kebandClaude Opus 5.5 committed 2026-10-11 13:35:11 +02:00
1 parent 9b0329e9da
commit 4d6db97d54
4 files changed
+60 -2

No files matched your search

+7
View File
@@ -34,6 +34,9 @@ type List[T any] struct {
Empty string // shown when loaded with no items
Loading bool
Err error
// Age says how old the items are ("2h ago") while they reload, by
// the counter.
Age string
item Item[T]
items []T
@@ -88,6 +91,7 @@ func (l *List[T]) SetError(err error) {
func (l *List[T]) Refresh() {
l.Loading = true
l.Err = nil
l.Age = ""
}
func (l *List[T]) SetLoading() {
@@ -369,6 +373,9 @@ func (l List[T]) View(st styles.Styles, focused bool, spin string) string {
if len(l.visible) > 0 {
counter = fmt.Sprintf("%d of %d", l.cursor+1, len(l.visible))
}
if l.Loading && l.Age != "" && len(l.items) > 0 {
counter = "cached " + l.Age + " · " + counter
}
return BoxCounted(st, title, "", counter, body, l.w, l.h, focused)
}