Skip to content

feat(web): one date range control across Visibility, Citations and Prompts - #722

Merged
gkhngyk merged 3 commits into
mainfrom
feature/713-shared-date-range
Aug 13, 2026
Merged

gkhngyk merged 3 commits into
mainfrom
feature/713-shared-date-range

Conversation

@gkhngyk

@gkhngyk gkhngyk commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Summary

The date range control appeared in three shapes and three places. Visibility and Citations were not merely similar — their markup was identical and duplicated, the same segmented buttons and class strings copied into two files. Prompts carried a third variant: different padding, different inactive colour, no label, positioned opposite the tab bar rather than among the filters, and offering only 7/30/90.

Extracting one DateRangeFilter is what stops a fourth copy appearing on the next page, so "make Prompts match" does not mean pasting the CSS a third time. 116 lines removed, 68 added; the preset vocabulary is shared with the control rather than redeclared per page.

Prompts now offers 24h, 7d, 30d, 90d and a custom range, opens on 24h like the other two, and threads a real from/to range through both of its tabs instead of a bare day count.

all is deliberately absent

The Query Fan-out tab aggregates raw rows in the client behind a hard 90-day, 50,000-row cap with a truncated flag. An unbounded option would silently mean "90 days" there — the same silent truncation filed as #721 — so the control offers what both tabs can honestly report. A custom range is clamped to the same 90 days, and getQueryFanout re-clamps independently because it is reachable on its own.

Schema drift found and closed

prompt_visibility_summaries needed an upper bound for the custom range. While adding it, the hosted database turned out to already carry a three-argument version that no migration in this repo produced — no row in schema_migrations, and a body missing the -- #155 comment that migration 00040 wrote. Repo files build the two-argument form; production had three.

Nothing was broken by it, and no data is affected, but a fresh install would have produced a function the new code cannot call — the same class of gap as #709. Migration 00055 drops both signatures conditionally and recreates the function, so it applies cleanly to production and to a clean database, and the file is the single definition again.

Related issue

Closes #713

Type of change

  • feat — New feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

How to test

  1. Visibility and Citations — the control looks and sits exactly as before; Custom still reveals From/To beside the other filters. The Citations URL detail page uses the same bar.
  2. Prompts — opens on 24h with a "Date Range" label, in a filter bar under the tabs, matching the other two pages.
  3. Switch presets — the table reloads and the URL gains ?range=7d; the default stays out of the URL.
  4. Custom — enter a From/To; data scopes to it. An empty custom form fetches nothing, because the clamp would otherwise silently mean "the last 90 days". A From earlier than 90 days is clamped.
  5. Insights tab on Prompts — the control disappears (keyword volume estimates carry no date dimension).
  6. Query Fan-out — the control applies there too.
  7. An old link of the form ?range=7 still resolves.
  8. CSV export — headers carry the preset (runs_24h, runs_custom); at the default range the header row is byte-identical to before.

yarn typecheck, yarn lint (6 pre-existing warnings, 0 errors), yarn format:check and yarn build all pass locally. The Next.js production build was run before committing — tsc alone does not catch what CI's web job does.

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/)
  • supabase/schema.sql regenerated via bash supabase/build-schema.sh
  • Changes are focused — one concern per PR

…d Prompts

The same control appeared in three shapes and three places. Visibility and
Citations were not merely similar — their markup was identical and
duplicated, the same segmented buttons and the same class strings copied into
two files. Prompts carried a third variant with different padding, different
inactive colour, no label, and a position opposite the tab bar rather than
among the filters.

Extracting one component is what stops a fourth copy appearing on the next
page, so "make Prompts match" does not mean pasting the CSS a third time. All
three now render the same block, and the preset vocabulary is shared with the
control rather than redeclared per page.

Which presets a page offers stays the page's own decision, passed in. Prompts
keeps 7/30/90 rather than gaining 24h, because the omission was deliberate:
its table scores each prompt over the window, and a single day yields one or
two runs per prompt, so the column would read zero for most rows (#686).
Parity means the same shape, label and position — not pretending every page
answers the same question. Prompts' data path still takes a day count; two
one-line helpers translate between that and the control's preset ids.

The control stays outside the tab panels on Prompts because the range governs
both All Prompts and Query Fan-out, and stays hidden on Insights, where
keyword volume estimates carry no date dimension and a range would be a
control that changes nothing.

Closes #713
The shared control landed with Prompts still offering only 7/30/90, which
left the option lists different even though the shape and placement matched.
Prompts now offers 24h, 7d, 30d, 90d and a custom range, opens on 24h like
Visibility and Citations, and threads a real from/to range through both tabs
instead of a bare day count.

`all` is deliberately still absent. The Query Fan-out tab aggregates raw rows
in the client behind a hard 90-day, 50,000-row cap, so an unbounded option
would silently mean "90 days" there — the same silent truncation just filed
as #721. A custom range is clamped to the same 90 days, and the fan-out
action re-clamps independently because it is reachable on its own.

prompt_visibility_summaries gains the upper bound it needs. Both signatures
are dropped conditionally: the hosted database already carried a
three-argument version that no migration in this repo produced, so an
unconditional drop of the two-argument form would fail there while succeeding
on a fresh install. The file is the single definition of the function again.

An empty custom form fetches nothing, since the clamp would otherwise make it
mean "the last 90 days", which is not what a blank form is asking for. Export
headers carry the preset rather than a day count, so a 24h or custom export
cannot be misread as 30-day data, and links using the old `?range=7` shape
still resolve.
… button floating

AI Traffic Analytics held a fourth copy of the same control — its own preset
list, its own DatePreset type, and the same segmented markup as the three
pages this branch already merged. It was missed when the work was scoped,
and it appeared before the shared component had even landed, which is the
argument for the component rather than against it.

The Export CSV button sat visibly above the segmented control because the
header row centred it: the range control is two rows tall, its label above
its buttons, so centring a one-row button against it lifts the button off the
baseline. The row is now items-end, matching the filter bars on the other
pages, and the range comes first so the reading order is the same everywhere.
@gkhngyk
gkhngyk merged commit 9b9e2fd into main Aug 13, 2026
4 checks passed
@gkhngyk
gkhngyk deleted the feature/713-shared-date-range branch August 13, 2026 23:46
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.

Design: one shared date range control across Visibility, Citations and Prompts

1 participant