Skip to content

refactor: store the time display setting as a time zone - #3447

Merged
karl-power merged 1 commit into
timezone-selectorfrom
claude/hdx-5741-timezone-preference
Oct 23, 2026
Merged

karl-power merged 1 commit into
timezone-selectorfrom
claude/hdx-5741-timezone-preference

Conversation

@karl-power

Copy link
Copy Markdown
Contributor

Summary

Replaces the "Use UTC time" preference with a timeZone preference, so a follow-up PR can turn the switch into a time zone selector. Nothing changes on screen.

  • UserPreferences.isUTC becomes timeZone: local (follows the browser) or an IANA name such as Etc/UTC. Stored settings convert once on load (true → Etc/UTC, false → local) and isUTC is dropped.
  • useDisplayTimeZone reads the new preference. A zone the browser doesn't recognise falls back to local.
  • useFormatTime, the results table and the sidebar UTC badge now read the zone from useDisplayTimeZone instead of isUTC.
  • The results table's date column header and the sidebar badge show the zone's short name (UTC, PDT, GMT+9). For UTC this is the same text as before.
  • The "Use UTC time" switch stays and writes timeZone.
  • New packages/app/src/timeZone.ts holds the local value, zone validation and the short name helper.
  • formatDate loses its isUTC option. Its only other caller, the alert message template in packages/api, passes timeZone: UTC_TIME_ZONE.

How to test

Preview routes: /search

Steps:

  1. Open the user menu at the bottom of the sidebar, click "User Preferences", and turn on "Use UTC time". Close the modal.
  2. Verify the sidebar shows a "UTC" badge next to the logo, and the results table's timestamp column header ends with "(UTC)".
  3. Open "User Preferences" again and turn off "Use UTC time". Close the modal.
  4. Verify the "UTC" badge is gone and the timestamp column header ends with "(Local)".

References

  • Linear Issue: HDX-5741

@karl-power
karl-power added this pull request to stack #3448 October 23, 2026 10:30
@vercel

vercel Bot commented Oct 23, 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 23, 2026 12:15pm UTC
hyperdx-storybook Ready Ready Preview Oct 23, 2026 12:15pm UTC

Request Review

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

E2E Test Results

✅ All tests passed • 458 passed • 1 skipped • 1394s

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

Tests ran across 4 shards in parallel.

View full report →

@changeset-bot

changeset-bot Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 80f234d

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

This PR includes changesets to release 4 packages
Name Type
@hyperdx/common-utils Patch
@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

@github-actions github-actions Bot added the review/tier-3 Standard — full human review required label Oct 23, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🟡 Tier 3 — Standard

Introduces new logic, modifies core functionality, or touches areas with non-trivial risk.

Why this tier:

  • Cross-layer change: touches frontend (packages/app) + backend (packages/api) + shared utils (packages/common-utils)

Additional context: touches background tasks or the delivery pipeline lightly (10 lines, under the 30-line bar for Tier 4)

Review process: Full human review — logic, architecture, edge cases.
SLA: First-pass feedback within 1 business day.

Stats
  • Production files changed: 9
  • Production lines changed: 189 (+ 125 in test files, excluded from tier calculation)
  • Branch: claude/hdx-5741-timezone-preference
  • Author: karl-power

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

@github-actions

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.

@github-actions

github-actions Bot commented Oct 23, 2026 •

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

@greptile-apps

greptile-apps Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no new blocking issues were found.

Summary

Replaces isUTC with timeZone, converts saved settings, and moves time display code to the shared zone preference.

  • Saved time settings now use a time-zone value.
  • App dates and labels follow the saved time zone.
  • Date formatting callers now pass a time zone directly.

Reviews (2) · Last reviewed commit: "refactor: store the time display setting..." · Reviewed by Greptile

@github-actions

Copy link
Copy Markdown
Contributor

Deep Review

✅ No critical issues found.

This is a contained, well-tested refactor: UserPreferences.isUTC becomes a timeZone string (local or an IANA name), stored settings migrate once on load, and formatDate drops its isUTC option. All in-repo callers of formatDate and every reader of userPreferences.isUTC were updated, so there is no dangling caller or build break. The localStorage migration is idempotent and self-heals non-string timeZone values back to local, and the UTC/local on-screen output is preserved.

🟡 P2 -- recommended

  • packages/common-utils/src/core/utils.ts:790 -- formatDate removes the public isUTC option from an exported @hyperdx/common-utils API under a patch-level changeset, so any external consumer still passing { isUTC: true } silently falls back to local-zone formatting rather than UTC.
    • Fix: Confirm no out-of-repo consumer relies on isUTC, or classify the option removal as a breaking change in the changeset.
  • packages/app/src/timeZone.ts:19 -- New zone helpers lack direct coverage for edge inputs: resolveTimeZonePreference on an empty or invalid non-local string and getTimeZoneShortName's ?? timeZone fallback when no timeZoneName part is produced.
    • Fix: Add unit tests for the empty-string/invalid-zone passthrough and the short-name fallback branch.
🔵 P3 nitpicks (3)
  • packages/app/src/components/DBRowTable.tsx:615 -- The "short name or Local" derivation is duplicated between the results-table date header and the sidebar badge in AppNav.tsx:510.
    • Fix: Extract a single displayZoneLabel(timeZone) helper in timeZone.ts and call it from both sites.
  • packages/app/src/timeZone.ts:33 -- getTimeZoneShortName defaults to new Date(), so for a DST zone the column header/badge abbreviation reflects "now" rather than the dates actually displayed (not reachable through the current UI, which only exposes local/Etc/UTC, but relevant once the zone selector lands).
    • Fix: Pass a representative date from the displayed range, or document that the label tracks the current instant.
  • packages/app/src/timeZone.ts:28 -- timeZonePreferenceFromIsUTC(isUTC: unknown) has no explicit return type.
    • Fix: Annotate the return as : string.

Reviewers (7): correctness, testing, maintainability, project-standards, kieran-typescript, api-contract, adversarial.

Testing gaps: resolveTimeZonePreference empty-string/invalid-string inputs and getTimeZoneShortName fallback branch are exercised only indirectly; timeZonePreferenceFromIsUTC is covered only via the migration tests.

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

@jordan-simonovski jordan-simonovski 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.

LGTM

Replace the isUTC user preference with timeZone: "local" or an IANA
name. Stored settings convert once on load (true -> Etc/UTC, false ->
local) and the old field is dropped.

- useDisplayTimeZone reads timeZone; unrecognised zones fall back to
  local
- useFormatTime, the results table, and the sidebar badge read the zone
  from it; the table header and badge show its short name
- The "Use UTC time" switch writes timeZone until it becomes a time zone
  selector
- Remove the isUTC option from formatDate
@karl-power
karl-power force-pushed the claude/hdx-5741-timezone-preference branch from 005c776 to 80f234d Compare October 23, 2026 12:10
@karl-power
karl-power merged commit ce6654d into main Oct 23, 2026
29 checks passed
kodiakhq Bot pushed a commit that referenced this pull request Nov 4, 2026
## Summary

Adds a time zone selector to the time picker on the search and dashboard pages. It overrides the User Preferences time zone for that page only and is kept in the `tz` URL param.

- `TimeZoneOverrideProvider` reads `tz`; `useDisplayTimeZone` prefers it over the user setting, so everything on the page switches together. Unknown values are ignored.
- The picker input shows the zone in use (e.g. `UTC-7`), highlighted when it isn't the browser's. The popover ends with the selector plus "Default", "UTC" and "Local" buttons; User Preferences gets "UTC" and "Local".
- Short zone labels are UTC offsets instead of abbreviations (`UTC-7`, not `PDT`). The selector shows the offset on each option and the selected value, and searches by it.
- Links from charts and tables to Search and other dashboards carry `tz`. External links don't.

The override isn't saved with saved searches or dashboards.

### Screenshots or video

<img width="529" height="243" alt="Screenshot 2026-10-30 at 10 39 50" src="https://github.com/user-attachments/assets/5cab281b-441d-48f0-9ae9-74d2c51abad7" />


<img width="664" height="319" alt="Screenshot 2026-10-30 at 10 40 02" src="https://github.com/user-attachments/assets/1822d592-ab3a-4597-b84f-78ba141d5349" />


### How to test on Vercel preview

**Preview routes:** /search, /dashboards

**Steps:**

1. On /search, click the time picker input (`data-testid="time-picker-input"`), click the "Time zone" field (`data-testid="time-picker-time-zone-select"`), type "tokyo" and click "Asia/Tokyo".
2. Verify the badge (`data-testid="time-picker-time-zone"`) shows "UTC+9" and the URL contains `tz=Asia%2FTokyo`.
3. Open the time picker, click "Default" (`data-testid="time-picker-time-zone-default"`), and verify `tz` is no longer in the URL.
4. On /dashboards, open any dashboard, repeat step 1, and verify the badge shows "UTC+9".

### References

- Linear Issue: Closes HDX-5741
- Related PRs: #3445, #3447, #3449

This branch was successfully deployed

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

Labels

review/tier-3 Standard — full human review required

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants