Skip to content

feat(insights): show the answer's query fan-out on the prompt result detail page #361

Closed

Description

@gkhngyk

Summary

The prompt result detail page (/dashboard/insights/[id]) shows a single AI answer — its response and the citations for that answer. We now also capture the observed query fan-out per result (prompt_results.search_queries, from #332/#341): the sub-queries the engine actually ran to build that specific answer. Surface it on this page, under the Citations section, so a user reading one answer can see exactly which sub-queries produced it.

Today the fan-out is only shown aggregated brand-wide in the Query Fan-out tab (#333). This adds the per-answer view where it's most contextual.

What to change

1. Carry search_queries through to the result type — web/src/lib/actions/tracking.ts

  • getPromptResultById already does select('*'), so search_queries is fetched from the DB — it's just dropped by mapResultRow.
  • Add a searchQueries field to the PromptResult type (array of { query: string; engine?: string; source_platform: string }), and map it in mapResultRow: searchQueries: (row.search_queries as …) ?? [].

2. Render a "Query fan-out" section — web/src/app/[locale]/(dashboard)/dashboard/insights/[id]/page.tsx

  • Below the existing Citations block, add a Query fan-out section, rendered only when result.searchQueries.length > 0.
  • List each observed sub-query with its engine/source chip (reuse PLATFORM_LABELS[source_platform] ?? source_platform; keep Perplexity's engine label if present). Read-only.

Explicit non-goals (v1)

Notes

How to test

  1. Open a result detail page (/dashboard/insights/[id]) for a Copilot or Perplexity answer that has fan-out → a Query fan-out section appears under Citations listing the observed sub-queries with their engine chips.
  2. A ChatGPT / Google answer (no fan-out) shows no fan-out section — no empty block.
  3. The response and citations are unchanged.

Activity

  1. added
    enhancement
    good first issue
    help wanted
    on Jul 7, 2026
  2. waynedeng01 commented on Jul 7, 2026

    @waynedeng01
    Contributor

    Hi, I'd like to work on this. I'll keep the change focused on carrying search_queries into PromptResult and rendering the query fan-out below Citations with the requested platform/engine labels.

  3. Maqbool61 commented on Jul 7, 2026

    @Maqbool61
    Contributor

    Hi @gkhngyk 👋 — I'd like to take this one. Here's my exact plan after reading the code:

    web/src/types/index.ts
    Add searchQueries to PromptResult:

    searchQueries?: { query: string; engines: string[] }[];

    web/src/lib/actions/tracking.ts — mapResultRow
    Map the new field:

    searchQueries: (row.search_queries as { query: string; engines: string[] }[] | null) ?? [],

    web/src/app/[locale]/(dashboard)/dashboard/insights/[id]/page.tsx
    Add a new Card section after Citations, only when result.searchQueries?.length > 0:

    • Section heading "Query fan-out" with a Network icon from lucide-react
    • Each sub-query as a row: query text on the left + engine chips on the right using the existing PLATFORM_LABELS map already in the file
    • Same visual pattern as the Citations card

    No new dependencies, no backend changes, no aggregation. Three file touches total.

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

    enhancementgood first issuehelp wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions