feat(ui): group factory rigs by category in the rig sidebar

The rig-library sidebar now presents shipped starter rigs under their
FactoryRigCategory headers (Shoegaze Walls, Dreampop, Classic, Ambient,
Experimental) in fixed catalog order, with the user's own rigs under a
"My Rigs" header. Starter rows show a "Starter rig" subtitle and are not
reorderable; user rows keep drag-to-reorder and Move Up/Down (now scoped to
the user's own rigs). Grouping is presentational, so it stays correct
regardless of underlying library order.

Adds FactoryRigLibrary.category(for:) and rigs(in:) with tests.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-08-09 13:53:56 -07:00
parent 2c970aa344
commit fba32ff0aa
3 changed files with 139 additions and 36 deletions
@@ -61,6 +61,24 @@ struct FactoryRigLibraryTests {
#expect(!FactoryRigLibrary.isFactory(UUID()))
}
@Test func categoryLookupAndGroupingCoverEveryRigOnce() {
for rig: FactoryRig in FactoryRigLibrary.all {
#expect(FactoryRigLibrary.category(for: rig.id) == rig.category,
"\(rig.name) category lookup mismatch")
}
#expect(FactoryRigLibrary.category(for: UUID()) == nil, "a random id has no category")
// Each category grouping contains only its own rigs, in catalog order.
for category: FactoryRigCategory in FactoryRigCategory.allCases {
let rigs: [FactoryRig] = FactoryRigLibrary.rigs(in: category)
#expect(rigs.allSatisfy { $0.category == category })
}
// Grouping by every category partitions the catalog exactly (no rig lost or duplicated).
let grouped: [FactoryRig] = FactoryRigCategory.allCases.flatMap { FactoryRigLibrary.rigs(in: $0) }
#expect(grouped.count == FactoryRigLibrary.all.count, "grouping dropped or duplicated a rig")
}
// MARK: - Seeding entries
@Test func makeEntriesMatchesCatalogAndIsStable() throws {