feat(onboarding): seed the catalog when the first artist is added in setup (chat#1889 row 8)

Merged
SW
4mo ago
+83-197

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

  • AddArtistForm adds through useAddSpotifyArtist, passing the whole Spotify result.
  • useAddRosterArtist deleted (and its test). Its enrichment duplicated addSpotifyArtist — identical createRosterArtist → saveArtist({ image, profileUrls: { SPOTIFY } }) — which predates chat#1892. One caller, so this is a swap that removes code.
  • addSpotifyArtist enrichment is now non-fatal, carrying chat#1892's guard across. It awaited saveArtist bare, so a failed PATCH threw 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: useAddSpotifyArtist now runs valuation on the first artist added in setup, preventing empty-catalog onboarding paths.
    • Measuring: /setup/valuation shows a “Measuring your catalog” state when a catalog exists but has no valuation yet, avoiding an endless skeleton and guiding users to /setup/tasks.
  • Refactors

    • Removed useAddRosterArtist; AddArtistForm now calls useAddSpotifyArtist with the full Spotify result. Tests updated.
    • Extracted MeasuringCatalogPanel into its own component and used it in SetupValuation.

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/valuation when 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).