feat(home): land on Home, and make it worth landing on
Build & publish Arch package / arch-package (push) Successful in 2m3s
CI / check (push) Canceled after 10s
CI / e2e (push) Canceled after 0s
Search index maintenance / maintain-index (push) Canceled after 0s

The app opened on Tracks — an alphabetical list of everything, which is
the one entry point that is identical every time and therefore gives the
user nothing to start from. Home is listed first in the nav and is the
page built to answer 'what should I play' (H-8).

Two things had to be true before that was an improvement.

An album with no cover rendered as a small dim icon on a surface the
same colour as the page, so a shelf read as having holes in it, while
the Albums and Artists grids both drew a letter tile (H-9). It draws the
same tile now.

And a shelf that repeats the one above it is suppressed, the way an
empty one already is — 'On repeat' was 'Pick up where you left off'
reordered. The rule fires only when the shelf is not showing the whole
library: a repeat is a fault only if a different row was possible, and
measured against a fixed shelf size instead this let an 11-album library
keep three identical shelves while a 13-album one lost them.

The first two versions of that rule were wrong and the *existing* Go
tests caught both — it collapsed a four-album library to a single shelf.

Nine e2e specs assumed the app starts on Tracks and now navigate there,
and one new spec freezes the landing itself. Home's page-header action
is 'Shuffle suggestions': 'Shuffle' alone was two different controls
with one accessible name, which only became reachable together once a
cached Home was always in the tree.
This commit is contained in:
2026-08-12 11:42:26 -04:00
parent c13a920487
commit 862e8a0468
11 changed files with 271 additions and 8 deletions
+79
View File
@@ -257,3 +257,82 @@ func TestGetShelvesSkipsAlbumsTheLibraryNoLongerHas(t *testing.T) {
}
}
}
// A shelf has to be worth its own row.
//
// A library with one signal answers several questions with the same
// albums, so shelves render the same covers in different orders under
// different reasons and the page reads as repeating itself (H-9).
// Confirmed in the running app on the fixture library before this
// existed: "On repeat" was "Pick up where you left off" reordered.
//
// The library has to be bigger than one shelf for the rule to apply at
// all, which is the point: a repeat is only a fault if a different row
// was possible.
func TestGetShelvesOmitsAShelfThatRepeatsTheOneAboveIt(t *testing.T) {
db := database.NewTestDB(t)
albums := make([]library.Album, 0, 16)
// Four albums carry the whole play history, so "what you played
// last" and "what you play most" can only answer with those four.
for i := range 4 {
name := "Played " + string(rune('A'+i))
id := seed(t, db, name, "Solo", "", 50+i, "2026-08-1"+string(rune('0'+i))+" 00:00:00")
albums = append(albums, library.Album{ID: id, Name: name, ArtistName: "Solo"})
}
// …and ten more the user has never touched, so the library is
// larger than a single shelf and a different row was possible.
for i := range 10 {
name := "Quiet " + string(rune('A'+i))
id := seed(t, db, name, "Nobody", "", 0, "")
albums = append(albums, library.Album{ID: id, Name: name, ArtistName: "Nobody"})
}
svc := home.NewService(slog.Default(), db, fakeLibrary{albums: albums})
shelves, err := svc.GetShelves()
if err != nil {
t.Fatalf("GetShelves: %v", err)
}
// The first of a duplicate pair survives: the reason the user sees
// is the one that came first, not the one built last.
if !hasKind(shelves, home.KindRecentlyPlayed) {
t.Fatalf("expected a recently-played shelf, got %v", shelfKinds(shelves))
}
// And the page still has somewhere to start.
if len(shelves) < 2 {
t.Fatalf("suppression left %d shelves: %v", len(shelves), shelfKinds(shelves))
}
for i := 1; i < len(shelves); i++ {
above := shelves[i-1]
shared := 0
for _, a := range shelves[i].Albums {
for _, b := range above.Albums {
if a.ID == b.ID {
shared++
break
}
}
}
if len(shelves[i].Albums) < 3 {
continue
}
if ratio := float64(shared) / float64(len(shelves[i].Albums)); ratio >= 2.0/3.0 {
t.Errorf(
"shelf %q repeats %q (%d of %d albums)",
shelves[i].Kind, above.Kind, shared, len(shelves[i].Albums),
)
}
}
}