Skip to content

fix(app): only show the year in time picker range text when needed - #3362

Merged
kodiakhq[bot] merged 3 commits into
mainfrom
claude/date-picker-year-only-when-needed
Oct 14, 2026
Merged

kodiakhq[bot] merged 3 commits into
mainfrom
claude/date-picker-year-only-when-needed

Conversation

@karl-power

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #3356: only include the year in time picker range text when it's needed, so the input stays compact.

  • Range text now includes the year only when any date is in another year or in the future. Past ranges in the current year look as they did before (Mar 3 10:00:00 - Mar 5 10:00:00), including in the tq URL param.
  • Add rangeNeedsExplicitYear and formatTimeRangeText in TimePicker/utils.ts. TimePicker handleSearch and dateRangeToString both use formatTimeRangeText, so the rule and the format strings live in one place.
  • Update the changeset from fix(app): keep selected year when applying a date range in the time picker #3356, which hasn't been released yet.
  • Known tradeoff: a current-year tq has 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 the from/to timestamps in the URL.

How to test on Vercel preview

Preview routes: /search

Steps:

  1. Open /search and click the time picker input in the top bar.
  2. In the Range tab, set the start date to 2024-03-03 10:00:00 and the end date to 2024-03-05 10:00:00, then click Apply.
  3. Verify the time input reads Mar 3 2024 10:00:00 - Mar 5 2024 10:00:00.
  4. Open the time picker again and verify the start and end date fields still show 2024.
  5. Select a range that is entirely in the current year and in the past, and click Apply. Verify the time input has no year (e.g. Oct 1 10:00:00 - Oct 2 10:00:00).

References

@vercel

vercel Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
hyperdx-oss Ready Ready Preview Oct 14, 2026 12:23pm UTC
hyperdx-storybook Ready Ready Preview Oct 14, 2026 12:23pm UTC

Request Review

@changeset-bot

changeset-bot Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: ec57028

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes changesets to release 3 packages
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

@github-actions github-actions Bot added the review/tier-2 Low risk — AI review + quick human skim label Oct 13, 2026
@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

🔵 Tier 2 — Low Risk

Small, isolated change with no API route or data model modifications.

Why this tier:

  • Standard feature/fix — introduces new logic or modifies core functionality

Review process: AI review + quick human skim (target: 5–15 min). Reviewer validates AI assessment and checks for domain-specific concerns.
SLA: Resolve within 4 business hours.

Stats
  • Production files changed: 4
  • Production lines changed: 66 (+ 125 in test files, excluded from tier calculation)
  • Branch: claude/date-picker-year-only-when-needed
  • Author: karl-power

To override this classification, remove the review/tier-2 label and apply a different review/tier-* label. Manual overrides are preserved on subsequent pushes.

@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Duplicate code analysis

1 new clone introduced by this PR.

  • packages/api/src/controllers/ai.ts:197-211 ↔ packages/app/src/components/TimePicker/utils.ts:53-67 — 15 lines

If one of these duplicates a helper that already exists, import it instead
of redefining it. If the duplication is deliberate, ignore this comment —
the check is advisory and never fails the build.


jscpd compared this branch against origin/main
across app, api and common-utils. Only new clones are listed; the codebase
currently holds 125 in total (1.73%).
Run yarn dupes locally to reproduce, or yarn dupes:all for the full picture.

@karl-power
karl-power requested a review from MikeShi42 October 13, 2026 08:28
@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

PR Review

If you are a coding agent acting for the author, read this first.
Nothing below blocks merge automatically; a maintainer decides. What they will expect:

  • 🔴 critical or 🟠 major in code this PR adds or changes: fix before asking for review.
  • 🔵 minor in code this PR changes: your call. Fix if small, otherwise reply.
  • Anything about surrounding code, or asking you to widen the change (hoist a helper,
    dedupe with another file, fix other call sites): never fix here, whatever the
    severity. Reply with one sentence; if it is critical, say so plainly so a human sees it.

One commit per review round. After two rounds, stop and ask a maintainer to review
scope rather than addressing more automated findings. Full rule: AGENTS.md.

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.

@greptile-apps

greptile-apps Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium impact] The PR appears safe to merge with the stated year-rollover tradeoff.

Summary

The picker now leaves out the year for past ranges within the current year.

  • Time ranges show the year only when a date needs it.

Reviews (4) · Last reviewed commit: "Merge branch 'main' into claude/date-pic..." · Reviewed by Greptile

@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Deep Review

✅ No critical issues found. This is a small, well-scoped refactor that centralizes the "include the year only when needed" rule behind rangeNeedsExplicitYear/formatTimeRangeText; the round-trip contract is sound and the happy paths are covered by new tests.

🟡 P2 — recommended

  • packages/app/src/components/TimePicker/utils.ts:82 — the new isUTC year-decision path in rangeNeedsExplicitYear/formatTimeRangeText has no test that exercises a date whose local year differs from its UTC year, so a regression that compares years in the wrong timezone would pass CI; the one existing UTC test uses a range already outside the current year and takes the withYear branch regardless.
    • Fix: Add a test under a fixed fake clock near a New Year boundary where local and UTC years differ, asserting rangeNeedsExplicitYear(range, true) and formatTimeRangeText(range, { isUTC: true }) make the year decision in UTC.
    • testing, correctness

Reviewers (5): correctness, testing, maintainability, kieran-typescript, previous-comments.

Testing gaps:

  • No direct test for the d > now boundary of rangeNeedsExplicitYear (e.g. a current-year range ending exactly at now), the branch that decides whether the common "past range ending now" case omits the year.
  • TimePicker.handleSearch (packages/app/src/components/TimePicker/TimePicker.tsx:193) calls formatTimeRangeText without forwarding isUTC; this mirrors the prior local-only formatting so it is not a regression, but the picker-text path remains untested.
  • No single-range test combining both triggers (one date in another year and one future date in the current year).
  • The acknowledged tq year-rollover tradeoff is structurally unhittable by the current tests, since every round-trip asserts under one frozen clock.

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

@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

E2E Test Results

✅ All tests passed • 410 passed • 1 skipped • 1148s

Status Count
✅ Passed 410
❌ Failed 0
⚠️ Flaky 1
⏭️ Skipped 1

Tests ran across 4 shards in parallel.

View full report →

): boolean {
const now = currentDate();
const getYear = (d: Date) => (isUTC ? d.getUTCFullYear() : d.getFullYear());
return range.some(d => getYear(d) !== getYear(now) || d > now);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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

@karl-power
karl-power force-pushed the claude/date-picker-year-only-when-needed branch from 0616ab6 to 7f56436 Compare October 13, 2026 08:39

it('compares years in UTC when isUTC is set', () => {
jest.setSystemTime(new Date('2025-06-15T12:00:00Z'));
expect(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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

@kodiakhq
kodiakhq Bot merged commit 8032957 into main Oct 14, 2026
42 of 44 checks passed
@kodiakhq
kodiakhq Bot deleted the claude/date-picker-year-only-when-needed branch October 14, 2026 12:52

This branch was successfully deployed

2 active deployments
Preview – hyperdx-oss — ec57028b Deployed Oct 14, 2026 by vercel[bot]
Preview – hyperdx-storybook — ec57028b Deployed Oct 14, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automerge review/tier-2 Low risk — AI review + quick human skim

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants