Description
Problem
The dashboard Add a new brand flow (/dashboard/brands/new) has no recovery path when topic suggestion fails — reported twice from internal use. This flow is what invited team members (manager role) always use, since the first-signup onboarding is only shown once per account; #443 hardened the onboarding page but never touched this one.
Two defects, verified in web/src/app/[locale]/(dashboard)/dashboard/brands/new/page.tsx:
- No retry when topic suggestion fails.
fetchTopicSuggestionscatches the error, fires a generic toast (Failed to generate topic suggestions) and leaves the user on step 3 with an empty suggestion list. There is no Try again button and no hint that custom topics can be typed manually. Since the "Looks good" button is (correctly) disabled with 0 selected topics, the step becomes a dead end. - The natural retry path creates a duplicate brand. Going Back to step 2 and pressing Continue calls
handleCreateBrand, which runscreateBrandunconditionally — even whencreatedBrandis already set. Every Back→Continue round-trip inserts another brand row.
Note the step-skipping side is already safe: step 3 requires ≥1 selected topic and step 4 requires ≥1 prompt before continuing. The problem is not that users can skip — it's that they can't move at all when the suggestion call fails.
Fix
Port the #443 treatment from the onboarding page to this flow:
- On topic-suggestion failure, show an inline error banner with a "Try again" button (same amber pattern as
web/src/app/[locale]/(onboarding)/dashboard/onboarding/page.tsx), plus copy pointing at the "Add custom topic" input as the manual fallback. Replace the toast-only handling. - Apply the same banner + Try again to the competitor-suggestion failure on step 5 for consistency (less severe today — the user can already add manually and finish — but it currently gets the same silent toast).
- Make Back→Continue idempotent: when
createdBrandis already set,handleCreateBrandmust not create a second brand — update the existing brand's fields (name, description, region, language, domains) if they changed, then advance to step 3.
Prompt generation (step 3 → 4) already has an implicit retry: the user stays on step 3 and can press "Looks good" again, and createTopics is idempotent (delete + insert). No change needed there beyond keeping the button enabled after failure.
Acceptance criteria
- Topic suggestion failure shows an inline banner with Try again; retrying re-runs the suggestion call without leaving the step, and manual topic entry is offered as a fallback.
- Competitor suggestion failure on step 5 gets the same banner + Try again.
- Back→Continue from step 2 never creates a second brand: the flow reuses (and updates) the brand created on the first pass.
- Step gating is unchanged: no advancing past step 3 with 0 topics or past step 4 with 0 prompts.
Activity