Skip to content

Topics: persisted AI topic suggestions between the KPI row and the leaderboard #463

Closed

Description

@gkhngyk

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_suggestions table mirroring prompt_suggestions (brand_id, name, optional rationale, status: suggested/added/dismissed, created_at). Needs a DB migration — follow the repo's migration workflow (numbered file in supabase/migrations/ + applied to the hosted project).
  • Server: reuse the existing /api/topics/suggest generation (same endpoint onboarding uses, which already has withRetry from 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 SuggestionsCard on 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 singular createTopic action — NOT the plural createTopics, 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

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-opportunities anchor 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

  1. added
    enhancement
    help wanted
    on Jul 17, 2026
  2. self-assigned this
    on Jul 18, 2026
  3. added a commit that references this issue on Jul 21, 2026
    af75ce5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementhelp wanted

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions