Repository navigation
fix(app): only show the year in time picker range text when needed - #3362
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
| Name | Type |
|---|---|
| @hyperdx/app | Patch |
| @hyperdx/api | Patch |
| @hyperdx/otel-collector | Patch |
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR
🔵 Tier 2 — Low RiskSmall, isolated change with no API route or data model modifications. Why this tier:
Review process: AI review + quick human skim (target: 5–15 min). Reviewer validates AI assessment and checks for domain-specific concerns. Stats
|
Duplicate code analysis1 new clone introduced by this PR.
If one of these duplicates a helper that already exists, import it instead jscpd compared this branch against |
PR Review
1 finding(s): 🔴 0 critical · 🟠 0 major · 🔵 1 minor 1 posted as inline comment(s) on the changed lines. Severity is the reviewer's own estimate and is used for ordering, not filtering. No finding blocks merge automatically; a maintainer decides. |
|
Deep Review✅ No critical issues found. This is a small, well-scoped refactor that centralizes the "include the year only when needed" rule behind 🟡 P2 — recommended
Reviewers (5): correctness, testing, maintainability, kieran-typescript, previous-comments. Testing gaps:
No finding blocks merge automatically. A maintainer will expect P0/P1 findings in code this PR changes to be fixed; P2/P3 are your call -- fix or reply. Never fix findings about surrounding code here; reply instead. Do not widen the PR. How to respond |
E2E Test Results✅ All tests passed • 410 passed • 1 skipped • 1148s
Tests ran across 4 shards in parallel. |
| ): boolean { | ||
| const now = currentDate(); | ||
| const getYear = (d: Date) => (isUTC ? d.getUTCFullYear() : d.getFullYear()); | ||
| return range.some(d => getYear(d) !== getYear(now) || d > now); |
There was a problem hiding this comment.
🔵 minor — Some past current-year ranges drop the year but don't round-trip near Dec 31
rangeNeedsExplicitYear assumes a yearless date always comes back in the current year. It doesn't. chrono 2.x (findYearClosestToRef) picks whichever year puts the date nearest to now, and normalizeParsedDate then clamps anything up to 1 day ahead to now. Example: on Dec 31 2026 at 20:00, the range Jan 1 2026 10:00 – Jan 2 2026 10:00 is formatted as Jan 1 10:00:00 - Jan 2 10:00:00. On re-parse, the start becomes Jan 1 2027, which is within a day, so it is clamped to now. The end becomes Jan 2 2027 and is shifted back to 2026. After the swap, tq and the picker seed read Jan 2 – Dec 31 2026. Suggested fix: format without the year, run the text through parseTimeRangeInput, and fall back to withYear if the dates differ. That ties the rule to the parser instead of a hand-written copy of its rules. Also add a round-trip test with the system time set to Dec 31. Today every test fixes the clock at June 15.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
0616ab6 to
7f56436
Compare
|
|
||
| it('compares years in UTC when isUTC is set', () => { | ||
| jest.setSystemTime(new Date('2025-06-15T12:00:00Z')); | ||
| expect( |
There was a problem hiding this comment.
🔵 minor — The UTC tests for rangeNeedsExplicitYear and formatTimeRangeText still pass if isUTC is ignored
The start date 2024-12-31T23:00Z falls in 2024 in UTC and in every timezone west of UTC, so the result is true with or without isUTC. CI runs in UTC, and nothing in the jest config sets TZ, so CI can't tell the difference. Also, no round-trip test calls formatTimeRangeText(range, { isUTC: true }) and then parseTimeRangeInput(text, true), even though UTC is the path dateRangeToString takes for UTC users. Fix: pin a non-UTC TZ for this case, for example with a date-fns-tz/TZ override, using a date whose UTC year and local year differ (such as 2025-01-01T02:00Z under TZ=America/Los_Angeles with now = 2025-06-15Z). Then add { isUTC: true } ranges to the round-trip it.each.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
Summary
Follow-up to #3356: only include the year in time picker range text when it's needed, so the input stays compact.
Mar 3 10:00:00 - Mar 5 10:00:00), including in thetqURL param.rangeNeedsExplicitYearandformatTimeRangeTextinTimePicker/utils.ts.TimePickerhandleSearchanddateRangeToStringboth useformatTimeRangeText, so the rule and the format strings live in one place.tqhas no year, so after Jan 1 it is re-parsed into the new year. This only affects the displayed text and the picker form seed. The search itself uses thefrom/totimestamps in the URL.How to test on Vercel preview
Preview routes: /search
Steps:
2024-03-03 10:00:00and the end date to2024-03-05 10:00:00, then click Apply.Mar 3 2024 10:00:00 - Mar 5 2024 10:00:00.Oct 1 10:00:00 - Oct 2 10:00:00).References