Repository navigation
Description
Problem
The Topics page shows how existing topics perform but never suggests what to monitor next. The only AI topic suggestions in the product run ephemerally during onboarding (/api/topics/suggest) and are discarded; the "similar topics" list on the Prompts page is volume-derived keyword clusters, not curated topic ideas. Internal feedback asked for topic suggestions on the Topics page, above the leaderboard.
Design
Mirror the prompt-suggestions architecture (persisted, generated on demand — never on page load):
Data
- New
topic_suggestionstable mirroringprompt_suggestions(brand_id, name, optional rationale, status: suggested/added/dismissed, created_at). Needs a DB migration — follow the repo's migration workflow (numbered file insupabase/migrations/+ applied to the hosted project). - Server: reuse the existing
/api/topics/suggestgeneration (same endpoint onboarding uses, which already haswithRetryfrom fix(onboarding): retry LLM suggestion calls and fall back to manual entry #443), but persist results and exclude topics the brand already has and previously dismissed suggestions.
UI (web/src/app/[locale]/(dashboard)/dashboard/topics/page.tsx)
- A compact Topic Suggestions card between the KPI row and the Topic leaderboard, with a stable
id="topic-opportunities"anchor. Keep it to ~5 visible suggestions — the leaderboard is the page's main content and must stay prominent. - Empty state: a Generate suggestions button (the
SuggestionsCardon the Prompts page is the pattern reference —web/src/app/[locale]/(dashboard)/dashboard/prompts/_suggestions-card.tsx). No LLM call ever happens on page load. - Per suggestion: Add (creates the topic) and Dismiss.
⚠️ Use the singularcreateTopicaction — NOT the pluralcreateTopics, which deletes all of the brand's topics before inserting and would wipe existing data. - Role gate: generation/add/dismiss for admin/manager only (
canManage).
Coordination
- Insights: Topic & Prompt Opportunities teaser cards in place of the removed results tree #459's "Topic Opportunities" teaser on the Insights page currently links to the Prompts page's similar-topics section. Once this card exists, the Topics page becomes the canonical home: update that link target to
/dashboard/topics#topic-opportunities(leave a comment on Insights: Topic & Prompt Opportunities teaser cards in place of the removed results tree #459 if it isn't implemented yet).
Acceptance criteria
- Suggestions are generated only on explicit user action, persisted, and survive reloads; already-tracked topics and dismissed suggestions never reappear.
- Add creates exactly one topic (existing topics untouched) and moves the suggestion to added state; Dismiss hides it permanently.
- The card renders between KPIs and leaderboard, capped at ~5 items, with the
topic-opportunitiesanchor scrollable from a cold page load. - No LLM or generation calls in the Topics page load path.
- Members without write access see the suggestions read-only at most, with no generate/add/dismiss controls.
Getting started
See CONTRIBUTING.md for setup. From web/, yarn lint, yarn typecheck and yarn format:check must pass; server changes must pass yarn lint/test from server/. Comment here to claim the issue before opening a PR — the migration + server + web scope makes this a larger piece; feel free to ask questions on approach first.
Activity
feat(topics): persisted AI topic suggestions on the Topics page (#497)