Repository navigation
Closed
Labels
enhancementNew feature or request
Description
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:
- Filter dropdown options are derived from the tree's fetch — the region and platform filter options are extracted from
insights.resultsafter the 1500-row load. Removing the fetch without replacing this source would empty the filters. - 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. - The CSV export is unaffected — it performs its own fetch (50k cap), verified.
Fix (in order)
- 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. - Remove the tree: the
PromptResultsGroupedcomponent and its sub-components,handleRefreshPrompt, theresultsstate and its 1500-row fetch (PROMPT_RESULTS_ROW_LIMIT), and the now-unused helpers inweb/src/app/[locale]/(dashboard)/dashboard/insights/grouping.ts(delete the file and its tests if nothing else imports it). - 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
resultsstate 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_resultsfetch 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.tsand unused imports removed,yarn lint/typecheckclean.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or request
Activity
feat(insights): remove the Prompt Results by Topic tree (#458) (#477)
feat(insights): Topic & Prompt Opportunities teaser cards (#459) (#479)