Skip to content

feat(prompts): date range filter on the prompt detail page - #496

Merged
gkhngyk merged 1 commit into
mainfrom
feature/prompt-detail-date-range
Jul 21, 2026
Merged

gkhngyk merged 1 commit into
mainfrom
feature/prompt-detail-date-range

Conversation

@gkhngyk

@gkhngyk gkhngyk commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds an insights-style date range filter to the prompt detail page (/dashboard/prompts/[id]), so a prompt can be inspected over the last 24h, week, month, etc. instead of all-time only.

  • Preset bar below the header: 24h / 7d / 30d / 90d / All / Custom (with From/To date inputs), identical look and getDateRange logic to the insights filter bar. Defaults to 30d so the detail page opens on the same window as insights.
  • Single filtered set: getPromptDetail accepts dateFrom/dateTo (via the expandDateToEndOfDay convention) and applies them to the results query — the KPI cards, Platform Results groups, and Top Sources tabs all derive from the same filtered results, so they always agree.
  • Refetch overlay: date changes reuse the insights pattern from feat(insights): refetch overlay while a filter change reloads data #494 — previous content stays mounted, dimmed under a floating spinner; the date bar stays outside the overlay so presets remain clickable mid-load. Skeleton renders on first load only.
  • Period-aware empty state: no results in the window shows "No results in the selected date range" with a one-click Show all data reset.
  • Last run badge pinned: lastCheckedAt now comes from a separate 1-row query for the prompt's true latest run, so it doesn't move or disappear when a narrow window is selected.

Related issue

—

Type of change

  • feat — New feature

How to test

  1. Open a prompt detail page for a prompt with tracking history; it loads with the 30d preset.
  2. Switch presets (24h → 90d → All): content dims under a spinner, then KPI values, platform groups, and Top Sources all update together.
  3. Pick Custom and set a From/To range — results are bounded to that range, inclusive of the To day.
  4. Pick a window with no runs: the Platform Results card shows the period-aware empty state; clicking Show all data jumps back to All. The Top Sources card hides when the window has no citations.
  5. The Last run badge shows the same timestamp regardless of the selected window.

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/)
  • yarn typecheck passes (run from web/)
  • yarn format:check passes (run from web/)
  • Changes are focused — one concern per PR

Adds the insights-style date preset bar (24h / 7d / 30d / 90d / All /
Custom, default 30d) to the prompt detail page. getPromptDetail accepts
dateFrom/dateTo and applies them to the results query, so the KPI cards,
Platform Results groups and the Top Sources tabs all follow the selected
window from a single filtered set. Date changes reuse the insights
refetch overlay (dimmed content + floating spinner) instead of a
skeleton flash, the empty state is period-aware with a one-click 'Show
all data' reset, and the Last run badge is pinned to the prompt's true
latest run so it doesn't move or empty out with the window.
@gkhngyk
gkhngyk merged commit e2ff657 into main Jul 21, 2026
4 checks passed
@gkhngyk
gkhngyk deleted the feature/prompt-detail-date-range branch July 21, 2026 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant