Skip to content

Insights: remove the Prompt Results by Topic tree (superseded by Topics / Prompts pages) #458

Closed

Description

@gkhngyk

Problem

The "Prompt Results by Topic" tree at the bottom of the Insights page is a raw result browser (Topic → Prompt → Platform → runs) left over from before the dedicated pages existed. Today everything it offers has a proper home:

  • topic-level view → Topics page
  • prompt list + metrics → Prompts page
  • per-platform runs and links to individual result details (/dashboard/insights/{id}) → prompt detail page (/dashboard/prompts/[id], which already links each run to the result detail)

Meanwhile the section is the heaviest part of the product's most-visited page: it fetches up to 1500 rows (PROMPT_RESULTS_ROW_LIMIT) on every Insights load, for a section at the bottom of the page. Internal feedback flagged it for removal; on review we agree.

What's entangled (verified in code)

web/src/app/[locale]/(dashboard)/dashboard/insights/page.tsx:

  1. Filter dropdown options are derived from the tree's fetch — the region and platform filter options are extracted from insights.results after the 1500-row load. Removing the fetch without replacing this source would empty the filters.
  2. The tree's per-prompt "Refresh results" button only re-reads that prompt's rows from the DB into the tree's own state (handleRefreshPrompt → getPromptResults) — it does not trigger tracking. It is intrinsic to the section and dies with it; nothing needs relocating.
  3. The CSV export is unaffected — it performs its own fetch (50k cap), verified.

Fix (in order)

  1. Re-source the filter options: replace the derive-from-results logic with a cheap dedicated query for the brand's distinct regions and platforms in prompt_results (or derive from the brand's prompt configuration, which already knows its platforms/regions). Options must not regress: same values as today for the same brand.
  2. Remove the tree: the PromptResultsGrouped component and its sub-components, handleRefreshPrompt, the results state and its 1500-row fetch (PROMPT_RESULTS_ROW_LIMIT), and the now-unused helpers in web/src/app/[locale]/(dashboard)/dashboard/insights/grouping.ts (delete the file and its tests if nothing else imports it).
  3. The empty/no-results page state ("No results for the …") must keep working — it should key off the summary/KPI data rather than the removed results state if it doesn't already.

Acceptance criteria

  • Insights renders without the tree; KPI cards, competitor comparison, trend charts, SoV and CSV export all unchanged.
  • Region/platform filter dropdowns offer the same options as before for the same brand.
  • The 1500-row prompt_results fetch is gone from the Insights load path (visible in the network tab).
  • Individual results remain reachable: Prompts → prompt detail → run → result detail.
  • No dead code left: grouping.ts and unused imports removed, yarn lint/typecheck clean.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions