Skip to content

fix(app): keep selected year when applying a date range in the time picker - #3356

Merged
kodiakhq[bot] merged 3 commits into
mainfrom
claude/fix-date-picker-year
Oct 13, 2026
Merged

kodiakhq[bot] merged 3 commits into
mainfrom
claude/fix-date-picker-year

Conversation

@karl-power

@karl-power karl-power commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes the time picker resetting a selected past year to the current one after applying a range.

  • The picker turned the selected dates into text without a year (Mar 3 10:00:00 - Mar 5 10:00:00), then re-parsed that text with chrono-node, which guesses the year. Only ranges in the current year (and not in the future) came back correctly.
  • Always write the year into range text (Mar 3 2024 10:00:00), in both TimePicker handleSearch and dateRangeToString, using the existing formatDate withYear format. This also covers the year in the tq URL param.
  • Add round-trip tests (formatDate/dateRangeToString → parseTimeRangeInput) for past year, year boundary, current year, a future range, and both 12h and 24h clocks.
  • The range text is about 10 characters longer (e.g. Mar 3 2026 10:00:00 - Mar 5 2026 10:00:00) in the fixed 350px input.

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 and the year does not change to the current year.
  4. Open the time picker again and verify the start and end date fields still show 2024.
  5. Set the range to 2026-03-15 10:00:00 - 2026-03-25 10:00:00, click Apply, and verify the full text, including the end time, is visible in the input without clipping.

Support issue

https://github.com/ClickHouse/support-escalation/issues/8863

@changeset-bot

changeset-bot Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 602ac39

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@hyperdx/app Patch
@hyperdx/api Patch
@hyperdx/otel-collector Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel

vercel Bot commented Oct 12, 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 13, 2026 8:16am UTC
hyperdx-storybook Ready Ready Preview Oct 13, 2026 8:16am UTC

Request Review

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

github-actions Bot commented Oct 12, 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: 2
  • Production lines changed: 13 (+ 84 in test files, excluded from tier calculation)
  • Branch: claude/fix-date-picker-year
  • 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

Copy link
Copy Markdown
Contributor

Duplicate code analysis

No new duplicate code introduced by this PR.


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.75%).
Run yarn dupes locally to reproduce, or yarn dupes:all for the full picture.

Comment thread packages/app/src/timeQuery.ts Resolved
@github-actions

github-actions Bot commented Oct 12, 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.

2 finding(s): 🔴 0 critical · 🟠 0 major · 🔵 2 minor

1 posted as inline comment(s) on the changed lines. 1 listed below.

Findings outside the changed lines

1 minor
  • 🔵 packages/app/src/components/TimePicker/__tests__/utils.test.ts:137 — The test that claims to mirror TimePicker.handleSearch never runs handleSearch → The test writes its own formatDate(..., {format:'withYear'}) expression, so it would still pass if TimePicker.handleSearch went back to 'MMM d HH:mm:ss'. Once handleSearch uses the shared helper, call that helper here. Or render TimePicker, apply a 2024 range, and assert on the input value and the onSearch argument.

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 12, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable failure was found in the year-formatting change.

Summary

The time picker now includes both years when it writes a date range, so parsing no longer has to guess them.

  • Time range text keeps the selected year when dates are applied.

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

@github-actions

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Deep Review

✅ No critical issues found.

The change is a sound, well-scoped fix: writing an explicit year into the range text makes chrono-node treat the year as certain on re-parse, which correctly bypasses the "inferred year" shift-back path in normalizeParsedDate. The future-range round-trip (a selection past the 1-day future-clamp window) is verified by the new tests and does not regress. TypeScript narrowing after the if (!from || !to) return; guard makes the removed d && guard genuinely redundant, and the local-time (isUTC defaulted) behavior in handleSearch matches the prior format() path, so there is no timezone regression on the happy path.

🟡 P2 -- recommended

  • packages/app/src/__tests__/timeQuery.test.ts:47 -- the year-preservation fix changed the isUTC: true path of dateRangeToString too, but every new round-trip test only exercises the local (isUTC=false) path, so a regression in the UTC round-trip (dateRangeToString(range, true) → parseTimeRangeInput(text, true)) would not be caught.
    • Fix: Add a round-trip case asserting parseTimeRangeInput(dateRangeToString([start, end], true), true) equals [start, end] for a range crossing a year boundary in a timezone where the local and UTC calendar years differ.
    • testing, previous-comments
🔵 P3 nitpicks (2)
  • packages/app/src/components/TimePicker/TimePicker.tsx:195 -- handleSearch and dateRangeToString independently build the same withYear range string that must stay identical for the format→re-parse round-trip to work, so drift in one (clock, separator) would silently break parsing of the other's output.

    • Fix: Extract a single shared range-formatting helper and call it from both sites so the format shape is defined once.
    • maintainability
  • packages/app/src/__tests__/timeQuery.test.ts:33 -- the formats in UTC when isUTC is set test asserts only a hardcoded string, so when the CI runner's timezone is UTC the isUTC=true and isUTC=false branches emit identical text and the test would still pass if the UTC branch were broken.

    • Fix: Assert dateRangeToString(range, true) !== dateRangeToString(range, false) (or pick an instant/TZ where local and UTC hours differ) so the assertion actually distinguishes the UTC branch.
    • testing

Reviewers (6): correctness, testing, maintainability, project-standards, kieran-typescript, previous-comments.

Testing gaps: parseTimeRangeInput is never invoked with isUTC=true in any new test, leaving cross-year UTC round-tripping unverified; the prior Greptile comment raised the same UTC-coverage concern.

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 12, 2026 •

Copy link
Copy Markdown
Contributor

E2E Test Results

✅ All tests passed • 407 passed • 1 skipped • 1356s

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

Tests ran across 4 shards in parallel.

View full report →

}
const formatStr =
timeFormat === '24h' ? 'MMM d HH:mm:ss' : 'MMM d h:mm:ss a';
const rangeStr = [from, to]

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 — Range-to-text formatting is still written out in two places, which is why this bug needed two fixes

handleSearch builds formatDate(d, {format:'withYear', clock}).join(' - ') by hand, and dateRangeToString in packages/app/src/timeQuery.ts:37 builds the same string. Add an optional clock parameter to dateRangeToString and call it here, so the range format has one source of truth and the next format change can't miss one copy.

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 requested review from a team and knudtty and removed request for a team October 12, 2026 13:42
@MikeShi42

Copy link
Copy Markdown
Contributor

Does this make the time range picker more verbose? I'm wondering for the user, how often do we really need to be showing the year, especially since the time input wraps now and can chew up a lot of screen real estate.

@MikeShi42 MikeShi42 left a comment •

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.

just caught up on the original feedback that spawned this, my preference is that we keep the year out of the output format if the time is this year. if any of the range is not this year, we can explicitly show the year.

this isn't blocking - but I think quite useful and makes sure the date picker stays compact for 99% of the time.

@kodiakhq
kodiakhq Bot merged commit 72ed406 into main Oct 13, 2026
29 checks passed
@kodiakhq
kodiakhq Bot deleted the claude/fix-date-picker-year branch October 13, 2026 08:22
kodiakhq Bot pushed a commit that referenced this pull request Oct 14, 2026
…3362)

## 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 #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

- Related PRs: #3356

This branch was successfully deployed

2 active deployments
Preview – hyperdx-oss — 98449d23 Deployed Oct 13, 2026 by vercel[bot]
Preview – hyperdx-storybook — 98449d23 Deployed Oct 13, 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