feat(valuation): one-click Run Valuation button on every no-valuation surface

Merged
SW
3mo ago
+337-26

Implements the shared-button row of #1973. Merge order: docs#305 → api#844 → this (the re-run surface relies on api#844's idempotent claims; the button itself works against today's API).

What this does

  • useRunValuation resolves the runnable roster artist (selected artist with a linked Spotify profile, else the first that has one) and POSTs /api/valuation under the signed-in account; invalidates catalogs / catalog-measurements / runs on success so every surface settles without a refresh.
  • RunValuationButton: one click, no wizard hop. Disabled while the run is in flight — a double click cannot start two runs (server-side idempotency via api#844 backstops it). Failure renders the API's error string verbatim (runValuation now throws body.error instead of a generic HTTP message) — per the live incident where "No releases found for this Spotify artist" was the diagnostic for a wrong-duplicate profile link. No runnable artist → the /setup/artists route (nothing to run against).
  • Surfaces: /catalogs empty state (personal scope only — a run always lands on the calling account), the measuring panel's "Been waiting a while?" escape (the stranded-state fix from #1973's original scope), the zero-stream panel (safe re-run), and the home greeting via HomeValuationCta — a signed-in account with a runnable artist and no catalog gets the button in place instead of a bounce to the marketing funnel it already finished.

Verification (local)

  • TDD red→green: getArtistSpotifyId (extraction incl. normalized/query-string links, non-artist links, no socials) and runValuation (verbatim API error, non-JSON fallback, parsed result). Full chat suite 98 files / 424 tests green; tsc --noEmit 0 errors; eslint clean.

Preview verification (one-click run from each surface, double-click prevention, verbatim 404 error render) to follow as a PR comment with screenshots.

Part of #1973.

🤖 Generated with Claude Code


Summary by cubic

Adds a one-click Run Valuation button across no-valuation surfaces so users start a valuation in place. Previously these linked to the funnel; now one click runs for the selected or first Spotify‑linked artist, respects the selected organization, prevents double submits, and surfaces API errors verbatim. Part of #1973.

  • Surfaces: Catalogs empty state in both personal and organization scopes, Measuring panel (“Been waiting a while?”), Zero‑stream panel (safe re‑run via API idempotency), and the home greeting via HomeValuationCta (button only when signed in, has a runnable artist, and no catalog; otherwise links to the funnel).
  • Org ownership: Selected organization is sent to POST /api/valuation so resulting catalogs belong to the org, not the personal account.
  • UX/a11y: RunValuationButton disables during flight with aria-busy, hides while the roster resolves to avoid setup-route flashes, and routes to /setup/artists when no runnable artist exists; error strings render verbatim.
  • API client and cache: runValuation now returns the parsed result and throws the API’s error string; update any callers expecting void. On success, invalidate catalogs, catalog-measurements, and runs.
  • Rollout/QA: Ship after idempotent claims are live. Verify org-owned runs, button shows on both empty-catalog views, double-click prevention, error rendering, and no route flash while the roster loads.

Summary by CodeRabbit

  • New Features
    • Added options to run or rerun valuations from catalog and onboarding screens.
    • Added valuation actions to the home experience when an account is ready.
    • Added progress feedback, error messages, and guidance when setup is required.
    • Valuations now support organization-specific context and refresh related results automatically.
  • Bug Fixes
    • Improved handling of valuation failures with clearer messages.
    • Reused existing linked artist information to run valuations consistently.