Skip to content

Unify date controls behind a single range picker - #749

Merged
wesm merged 3 commits into
mainfrom
worktree-async-leaping-wozniak
Jun 19, 2026
Merged

Unify date controls behind a single range picker#749
wesm merged 3 commits into
mainfrom
worktree-async-leaping-wozniak

Conversation

@cpcloud

@cpcloud cpcloud commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

The date controls had drifted into four different shapes across views — Analytics/Usage's preset + input selector, Activity's segmented control plus a separate prev/next navigator, Trends' inline labelled from/to plus a granularity group, and Insights' mode-coupled inputs. Same job, four costumes: three input heights, three preset vocabularies, two active-state styles.

This replaces all of them with one shared RangePicker: a popover trigger plus a segmented panel (Relative / Calendar / Custom). Every view renders the identical control. Behavior that isn't date selection (Activity's period stepping) lives inside the panel, so the toolbars look the same everywhere.

A small selection model (rangeSelection.ts) resolves any selection to the from/to or preset/anchor each store already consumes, so existing behavior is preserved rather than reimplemented:

  • Analytics and Usage keep rolling-vs-pinned windows, the "All" (earliest-session) preset, and URL persistence.
  • Activity keeps day/week/month period stepping (now inside the panel) and the future-step guard.
  • Trends keeps its granularity and normalize controls, relocated out of the date toolbar into the chart panel's header as a minimal "Group by" dropdown — they sat next to the picker and collided with its Calendar tab's day/week/month.
  • Insights keeps single-day selection (Calendar · Day, the common default) and its insight-type select; the bespoke mode-coupled date inputs are gone.

Out of scope by design: Analytics' chart granularity and Activity's bucket stay as their own controls. Folding every resolution toggle into one shared control is a possible follow-up.

Where to look: frontend/src/lib/components/shared/RangePicker.svelte (the control) and rangeSelection.ts (the selection model + date math). Each page's adapter is the small rangeSelection / applyRange block added to its *Page.svelte. DateRangeSelector, RangeControl, and RangeNavigator are deleted.

cpcloud added 2 commits June 19, 2026 11:24
Replace the four divergent date controls (DateRangeSelector, Activity's
RangeControl + RangeNavigator, and the inline Trends/Insights date inputs)
with one shared RangePicker: a popover trigger plus a tabbed panel offering
Relative windows, steppable Calendar periods, and a Custom range. Every view
now renders the same control.

A small selection model (rangeSelection.ts) resolves any selection to the
from/to or preset/anchor each store already consumes, so existing behavior
is preserved:

- Analytics and Usage keep rolling-vs-pinned windows and "All" semantics.
- Activity keeps day/week/month period stepping, now inside the panel.
- Trends keeps its granularity and normalize controls beside the picker.
- Insights keeps single-day selection (Calendar - Day) and its insight-type
  select, dropping the bespoke mode-coupled inputs.

The day/week/month resolution toggles (Analytics chart granularity, Trends
grouping, Activity bucket) are intentionally left as their own controls.
…th jitter

Address review findings on the unified range picker:

- Picking a Relative or Calendar preset while the popover is open now syncs
  the Custom tab's inputs and the calendar anchor, so switching to Custom
  edits the range just chosen instead of a stale seed from when it opened.
- commitCustom normalizes a reversed range (from > to) before emitting, so
  consumers and backend validation never receive to < from.

Also stabilize the trigger with a min-width and a flex label so the button no
longer resizes as the date label changes and shifts neighboring controls.
@roborev-ci

roborev-ci Bot commented Jun 19, 2026

Copy link
Copy Markdown

roborev: Combined Review (036d9ac)

No issues found.


Panel: ci_default_security | Synthesis: codex | Members: codex_default (codex/default, done, 6m51s), codex_security (codex/security, done, 14s) | Total: 7m5s

…ates

The Trends toolbar carried a day/week/month granularity bar right next to the
new date picker, whose Calendar tab also offers day/week/month -- two controls
with identical labels meaning different things (chart bucketing vs date span).

Move the granularity and the normalize toggle out of the date toolbar and into
the chart panel's header: a minimal "Group by" dropdown (bar-chart icon, opens
Day/Week/Month) plus the normalize checkbox. The top row is now only the date
scope, and how the chart is drawn lives where it acts -- matching how Analytics
places its own timeline granularity on the chart.
@roborev-ci

roborev-ci Bot commented Jun 19, 2026

Copy link
Copy Markdown

roborev: Combined Review (1cc32c6)

No issues found.


Panel: ci_default_security | Synthesis: codex | Members: codex_default (codex/default, done, 6m34s), codex_security (codex/security, done, 14s) | Total: 6m48s

@wesm
wesm merged commit 60dbb72 into main Jun 19, 2026
21 checks passed
@wesm
wesm deleted the worktree-async-leaping-wozniak branch June 19, 2026 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants