feat(onboarding): seed the catalog when the first artist is added in setup (chat#1889 row 8)
Matrix row 8 in chat#1889 — the fix for the dead end #1895 surfaced.
Why
/setup/artists added artists through useAddRosterArtist, which creates and enriches but never values. useAddSpotifyArtist — already used by the /artists dialog — also fire-and-forget kicks POST /api/valuation via runValuation when the account has no catalog yet. Its docstring has said so since chat#1867:
seeding the onboarding catalog in the background so the "Claim your catalog" step is already complete by the time the user reaches it
So the same artist added at /artists got a catalog and at /setup/artists did not. Verified live on a fresh account during #1895's review: two artists added through setup, both carrying real Spotify ids, GET /api/accounts/{id}/catalogs still []. With #1895 on prod that means every cold-start account now finishes setup on the "Claim your catalog" fallback, whose CTA lands on /catalogs → "No catalogs found." with no create affordance.
What changed
AddArtistFormadds throughuseAddSpotifyArtist, passing the whole Spotify result.useAddRosterArtistdeleted (and its test). Its enrichment duplicatedaddSpotifyArtist— identicalcreateRosterArtist→saveArtist({ image, profileUrls: { SPOTIFY } })— which predates chat#1892. One caller, so this is a swap that removes code.addSpotifyArtistenrichment is now non-fatal, carrying chat#1892's guard across. It awaitedsaveArtistbare, so a failedPATCHthrew past the create that had already succeeded: the caller reported failure over an existing artist and a retry duplicated it. This had to land with the swap or the swap would have reintroduced the defect chat#1892 just closed.
No api or docs change: this reuses POST /api/valuation (api#776) exactly as the /artists dialog already does, so there is no contract to write first.
Verification
TDD, red → green, two units:
# RED 1 — enrichment failure propagates
FAIL lib/artists/__tests__/addSpotifyArtist.test.ts > returns the created artist when enrichment fails
Error: Forbidden
# RED 2 — form still bound to the non-seeding hook
FAIL components/Onboarding/__tests__/AddArtistForm.test.tsx (2 failed)
# GREEN
pnpm exec vitest run components lib hooks
Test Files 72 passed (72)
Tests 271 passed (271)
pnpm exec tsc --noEmit → 13 errors, identical to main's baseline. eslint clean on all touched files.
Preview verification to follow on this PR.
Tracked in chat#1889 (matrix row 8).
Summary by cubic
Seeds the catalog when the first artist is added during setup by routing AddArtistForm through useAddSpotifyArtist, and adds a measuring state in /setup/valuation so onboarding no longer dead-ends (chat#1889 row 8). This mirrors the /artists dialog and kicks POST /api/valuation on first add.
-
Bug Fixes
- Seeding:
useAddSpotifyArtistnow runs valuation on the first artist added in setup, preventing empty-catalog onboarding paths. - Measuring:
/setup/valuationshows a “Measuring your catalog” state when a catalog exists but has no valuation yet, avoiding an endless skeleton and guiding users to/setup/tasks.
- Seeding:
-
Refactors
- Removed
useAddRosterArtist;AddArtistFormnow callsuseAddSpotifyArtistwith the full Spotify result. Tests updated. - Extracted
MeasuringCatalogPanelinto its own component and used it inSetupValuation.
- Removed
Summary by CodeRabbit
- New Features
- Onboarding now adds artists directly from Spotify selections, bringing in profile details and avatar when available.
- Added an intermediate “Measuring your catalog” screen for
/setup/valuationwhen measurements are still pending, with a link to setup tasks.
- Bug Fixes
- Artist addition no longer fails if Spotify enrichment (profile/avatar) temporarily errors; the base artist is still created for later repair.
- UI Improvements
- Updated valuation setup rendering so loading vs “not yet showing” states display the correct screens (skeleton only during loading, measuring panel otherwise).