Skip to content

feat(prompts): "Query Fanouts by Prompts" — group the fan-out by prompt with expandable rows #350

Closed

Description

@gkhngyk

Summary

Add a second view to the Query Fan-out tab — Query Fanouts by Prompts — that shows the same observed fan-out data, but grouped by the prompt it came from instead of one flat list. At the top is a table of the brand's prompts; clicking the expand arrow on a prompt reveals the sub-queries that prompt's answers actually ran.

It's the same data as the "High frequency" list (#349), just pivoted: instead of "sub-query → which prompts sourced it", this is "prompt → which sub-queries it fanned out into".

What to change

  • A Query Fanouts by Prompts table: one row per prompt (that has any observed fan-out), showing the prompt text and a count of its distinct sub-queries.
  • Each row is expandable via a chevron/arrow; expanding reveals that prompt's sub-queries, reusing the same columns as the flat table (sub-query, engine chip, times searched, +/Tracked).
  • Empty state when a brand has no fan-out yet (same clear notice as the flat view).

Where

  • web/src/app/[locale]/(dashboard)/dashboard/prompts/_fanout-tab.tsx — the grouped/expandable table.
  • web/src/lib/actions/fanout.ts — the data can be derived from the existing getQueryFanout result (each subQuery already carries its sourcedPrompts, so invert sub-query→prompts into prompt→sub-queries client-side), or add a dedicated getQueryFanoutByPrompt(brandId, { days }) action if a server-shaped grouping is cleaner. Either way, no new columns — the sub-query rows reuse the existing shape.

Layout

Notes

How to test

  1. /dashboard/prompts?tab=fanout → By prompt view: a table of prompts that produced fan-out, each with its sub-query count.
  2. Click a prompt's expand arrow → its observed sub-queries appear (engine, times searched, +/Tracked), matching what the flat "High frequency" list shows for the same sub-queries.
  3. A prompt with no fan-out isn't listed; a brand with no fan-out shows the empty state.
  4. Tracking a sub-query from inside an expanded prompt works the same as from the flat list.

Activity

  1. added
    enhancement
    help wanted
    on Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementhelp wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions