Skip to content

fix(prompts): tracking a Query Fan-out sub-query doesn't refresh the All Prompts list #345

Closed

Description

@gkhngyk

Problem

On the Prompts page, clicking + (Track) on a row in the Query Fan-out tab does add the sub-query as a tracked prompt — but the All Prompts tab still shows the old list. A user who switches to All Prompts to confirm the addition doesn't see the new prompt and concludes it wasn't added. The prompt is there (a page reload or brand switch reveals it); only the in-memory list is stale.

Root cause (from the code)

The Prompts page is a client component that loads the All Prompts data once into local state, and the Query Fan-out tab refreshes only its own data after a track — the two never talk to each other.

  • The page holds allPrompts in useState and populates it in loadData(); every other mutating action on the page (analyze, refresh, etc.) calls await loadData() afterwards to re-sync. See web/src/app/[locale]/(dashboard)/dashboard/prompts/page.tsx — allPrompts / setAllPrompts, loadData, and the <QueryFanoutTab brandId={activeBrandId} /> render (which is passed no refresh callback).
  • The fan-out tab's track handler adds the prompt and then reloads only the fan-out aggregation (so its own row flips to Tracked ✓), but it has no way to tell the page to refresh allPrompts. See web/src/app/[locale]/(dashboard)/dashboard/prompts/_fanout-tab.tsx — handleTrack → trackFanoutQuery → await load().
  • trackFanoutQuery calls revalidatePath('/dashboard/prompts') (web/src/lib/actions/fanout.ts), but the page keeps its list in client useState, so path revalidation doesn't re-sync that in-memory state without a navigation/refresh.

Proposed change

Give the fan-out tab a way to trigger the page's existing refresh so the All Prompts list reflects the new prompt immediately:

  • Add an onTracked?: () => void (or onTracked?: () => Promise<void>) prop to QueryFanoutTab, called after a successful trackFanoutQuery.
  • Wire it at the render site to the page's loadData (mirrors how the analyze/refresh actions already re-sync): <QueryFanoutTab brandId={activeBrandId} onTracked={loadData} />.

That's the whole fix — no new data flow, just reusing the page's loadData. (Optionally, only re-fetch the prompt list rather than all page data if a lighter refresh is preferred.)

How to test

  1. Prompts → Query Fan-out, click + on an untracked sub-query → toast confirms, the row flips to Tracked ✓.
  2. Switch to All Prompts without reloading the page → the newly tracked sub-query now appears in the list (previously it did not until a manual reload).
  3. The KPI/"unanalyzed keywords" counts that derive from allPrompts also reflect the new prompt.

Notes

Activity

  1. added
    bug
    good first issue
    help wanted
    on Jul 6, 2026
  2. AyushSrivastava1818 commented on Jul 6, 2026

    @AyushSrivastava1818
    Contributor

    Can I work on this??

  3. gkhngyk commented on Jul 6, 2026

    @gkhngyk
    ContributorAuthor

    Thanks @AyushSrivastava1818 — assigned to you, it's all yours! 🎉 The fix is small: give QueryFanoutTab an onTracked prop and wire it to the page's existing loadData so the All Prompts list re-syncs after a track (details in the issue). Feel free to ask here if anything's unclear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

buggood first issuehelp wanted

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions