Repository navigation
feat(web): one date range control across Visibility, Citations and Prompts - #722
Merged
Merged
Conversation
…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.
5 of 10 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
DateRangeFilteris 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.
allis deliberately absentThe Query Fan-out tab aggregates raw rows in the client behind a hard 90-day, 50,000-row cap with a
truncatedflag. 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, andgetQueryFanoutre-clamps independently because it is reachable on its own.Schema drift found and closed
prompt_visibility_summariesneeded 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 inschema_migrations, and a body missing the-- #155comment 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
00055drops 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 featurefix— Bug fixchore— Maintenance / dependenciesdocs— Documentation onlyrefactor— Code change that neither fixes a bug nor adds a featuretest— Adding or updating testsHow to test
?range=7d; the default stays out of the URL.?range=7still resolves.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:checkandyarn buildall pass locally. The Next.js production build was run before committing —tscalone does not catch what CI'swebjob does.Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/)yarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)supabase/schema.sqlregenerated viabash supabase/build-schema.sh