Skip to content

fix(new-webui): Drop timezone from Dates returned by antd's DatePicker.RangePicker to match timezone (UTC) shown in search results (fixes #1085).#1053

Merged
davemarco merged 10 commits into
y-scope:mainfrom
davemarco:timeRangefix
Jul 8, 2025

Conversation

@davemarco

@davemarco davemarco commented Jun 30, 2025

Copy link
Copy Markdown
Contributor

Description

@kirkrodrigues mentioned a bug that the range picker is not accurately selecting dates.

PR fixes this issue by dropping any timezone offset supplied by antd range picker.

PR also drops showNow options since it selects the time in the local timezone. This does not work for our design since the whole in UI is in utc.

Checklist

  • The PR satisfies the contribution guidelines.
  • This is a breaking change and that has been indicated in the PR title, OR this isn't a
    breaking change.
  • Necessary docs have been updated, OR no docs need to be updated.

Validation performed

tested the submitted timestamp in utc is the same when (1) using the selector, and (2) when clearing the timestamp first then using the selector.

Summary by CodeRabbit

  • Bug Fixes
    • Updated the date range picker in the custom time range selection to prevent clearing the selection and hide the "now" button, ensuring consistent timezone handling.

@coderabbitai

coderabbitai Bot commented Jun 30, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

The update modifies the TimeRangeInput component’s DatePicker.RangePicker by removing the showNow property and enabling the allowClear property to allow clearing the date range. The selected date range is explicitly converted to UTC before updating the time range, ensuring consistent timezone handling.

Changes

File(s) Change Summary
components/webui/client/src/pages/SearchPage/SearchControls/TimeRangeInput/index.tsx Converted selected date range to UTC in handleRangePickerChange; removed showNow; enabled allowClear in RangePicker.

Suggested reviewers

  • junhaoliao

Possibly related PRs


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7cf41ed and 6d0841d.

📒 Files selected for processing (1)
  • components/webui/client/src/pages/SearchPage/SearchControls/TimeRangeInput/index.tsx (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.{cpp,hpp,java,js,jsx,tpp,ts,tsx}`: - Prefer `false == ` rather than `!`.

**/*.{cpp,hpp,java,js,jsx,tpp,ts,tsx}: - Prefer false == <expression> rather than !<expression>.

⚙️ Source: CodeRabbit Configuration File

List of files the instruction was applied to:

  • components/webui/client/src/pages/SearchPage/SearchControls/TimeRangeInput/index.tsx
🧠 Learnings (2)
📓 Common learnings
Learnt from: gibber9809
PR: y-scope/clp#504
File: components/core/src/clp_s/search/kql/CMakeLists.txt:29-29
Timestamp: 2024-10-22T15:36:04.655Z
Learning: When reviewing pull requests, focus on the changes within the PR and avoid commenting on issues outside the scope of the PR.
Learnt from: junhaoliao
PR: y-scope/clp#596
File: components/log-viewer-webui/client/src/api/query.js:16-23
Timestamp: 2024-11-21T15:51:33.203Z
Learning: In `components/log-viewer-webui/client/src/api/query.js`, the `ExtractJsonResp` type definition is accurate as-is and does not require modification. When suggesting changes to type definitions, ensure they align with the server-side definitions, referencing the source code if necessary.
components/webui/client/src/pages/SearchPage/SearchControls/TimeRangeInput/index.tsx (3)
Learnt from: junhaoliao
PR: y-scope/clp#937
File: components/log-viewer-webui/client/src/AntdApp.tsx:16-24
Timestamp: 2025-05-29T20:33:40.653Z
Learning: In components/log-viewer-webui React codebase: Return type annotations (like `: JSX.Element`) are unnecessary and not preferred for React components in JSX/TSX files.
Learnt from: junhaoliao
PR: y-scope/clp#596
File: components/log-viewer-webui/client/src/api/query.js:16-23
Timestamp: 2024-11-21T15:51:33.203Z
Learning: In `components/log-viewer-webui/client/src/api/query.js`, the `ExtractJsonResp` type definition is accurate as-is and does not require modification. When suggesting changes to type definitions, ensure they align with the server-side definitions, referencing the source code if necessary.
Learnt from: junhaoliao
PR: y-scope/clp#596
File: components/log-viewer-webui/client/src/api/query.js:35-41
Timestamp: 2024-11-19T19:52:43.429Z
Learning: For internal APIs in `components/log-viewer-webui/client/src/api/query.js`, runtime validation of parameters may not be necessary since the APIs are not exposed to end users, and JsDoc type annotations may be sufficient.
🔇 Additional comments (1)
components/webui/client/src/pages/SearchPage/SearchControls/TimeRangeInput/index.tsx (1)

49-53: Make sure the Day.js UTC plugin is actually loaded

.utc() is available only when the utc plugin is extended.
This file imports bare dayjs; if the plugin isn’t extended in a global bootstrap, these calls will throw at run-time.

+import utc from "dayjs/plugin/utc";
+dayjs.extend(utc);

Add once in a suitable top-level module (or here if nowhere else) and verify tests.
Otherwise keep the call behind a guard or replace with dayjs(dates[0]).toDate()-style conversion.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@davemarco davemarco requested a review from hoophalab June 30, 2025 16:20
@davemarco davemarco marked this pull request as ready for review June 30, 2025 16:21
@davemarco davemarco requested a review from a team as a code owner June 30, 2025 16:21

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ca90fec and 548a5c4.

📒 Files selected for processing (1)
  • components/webui/client/src/pages/SearchPage/SearchControls/TimeRangeInput/index.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.{cpp,hpp,java,js,jsx,tpp,ts,tsx}`: - Prefer `false == ` rather than `!`.

**/*.{cpp,hpp,java,js,jsx,tpp,ts,tsx}: - Prefer false == <expression> rather than !<expression>.

⚙️ Source: CodeRabbit Configuration File

List of files the instruction was applied to:

  • components/webui/client/src/pages/SearchPage/SearchControls/TimeRangeInput/index.tsx
🧠 Learnings (2)
📓 Common learnings
Learnt from: gibber9809
PR: y-scope/clp#504
File: components/core/src/clp_s/search/kql/CMakeLists.txt:29-29
Timestamp: 2024-10-22T15:36:04.655Z
Learning: When reviewing pull requests, focus on the changes within the PR and avoid commenting on issues outside the scope of the PR.
components/webui/client/src/pages/SearchPage/SearchControls/TimeRangeInput/index.tsx (1)
Learnt from: junhaoliao
PR: y-scope/clp#937
File: components/log-viewer-webui/client/src/AntdApp.tsx:16-24
Timestamp: 2025-05-29T20:33:40.653Z
Learning: In components/log-viewer-webui React codebase: Return type annotations (like `: JSX.Element`) are unnecessary and not preferred for React components in JSX/TSX files.

Comment on lines +71 to +76

// `ShowNow` and `allowClear` options are disabled since they set the timezone
// of the range picker to the local timezone.
allowClear={false}
className={styles["rangePicker"] || ""}
showNow={true}
showNow={false}

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.

🧹 Nitpick (assertive)

Minor wording & redundancy nitpick

  1. The explanatory comment uses ShowNow, but the prop is showNow; updating the casing will avoid confusion for future readers.
  2. showNow already defaults to false in antd’s RangePicker, so the explicit showNow={false} is technically redundant. Removing it would shorten the JSX without altering behaviour.
-                    // `ShowNow` and `allowClear` options are disabled since they set the timezone
-                    //  of the range picker to the local timezone.
+                    // `showNow` and `allowClear` are disabled because enabling either forces
+                    // the picker to adopt the local timezone.
                     allowClear={false}
-                    className={styles["rangePicker"] || ""}
-                    showNow={false}
+                    className={styles["rangePicker"] || ""}

Optional clean-up only; functional change is not required.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// `ShowNow` and `allowClear` options are disabled since they set the timezone
// of the range picker to the local timezone.
allowClear={false}
className={styles["rangePicker"] || ""}
showNow={true}
showNow={false}
// `showNow` and `allowClear` are disabled because enabling either forces
// the picker to adopt the local timezone.
allowClear={false}
className={styles["rangePicker"] || ""}
🤖 Prompt for AI Agents
In
components/webui/client/src/pages/SearchPage/SearchControls/TimeRangeInput/index.tsx
around lines 71 to 76, update the comment to use the correct prop casing
"showNow" instead of "ShowNow" to avoid confusion, and remove the explicit
showNow={false} prop since it defaults to false in antd's RangePicker, thereby
simplifying the JSX without changing behavior.

@kirkrodrigues kirkrodrigues self-requested a review June 30, 2025 21:03
@kirkrodrigues

Copy link
Copy Markdown
Member

however, the "allowClear" and "now" options reset the timezone to the local timezone.

How'd you figure that out?

@davemarco

davemarco commented Jul 3, 2025

Copy link
Copy Markdown
Contributor Author

however, the "allowClear" and "now" options reset the timezone to the local timezone.

How'd you figure that out?

I tested. If you look at logs from the UI in the console. You will see that the submitted timestamp is 4 hours off (after you clear it). The now option was also using my local time, and not the utc time.

…meRangeInput/index.tsx

Co-authored-by: kirkrodrigues <2454684+kirkrodrigues@users.noreply.github.com>
@davemarco davemarco requested a review from kirkrodrigues July 3, 2025 21:13
@kirkrodrigues

Copy link
Copy Markdown
Member

Entering a timestamp by typing also seems to trigger the issue. Any ideas how we could fix/mitigate that as well?

@davemarco

davemarco commented Jul 4, 2025

Copy link
Copy Markdown
Contributor Author

Entering a timestamp by typing also seems to trigger the issue. Any ideas how we could fix/mitigate that as well?

This is kind of annoying. Maybe we do a gross manipulation (i think the timeline does something like this) when updating the state ? I think you can use utc(true) and it will drop the existing offset. The manipulation should have no effect if already in utc, and if not, it will force it to utc?

It dosent seem antd provides good support for timezones.

Originally i wanted to avoid this, and I thought setting the starting timestamp in utc was elegant fix, but it turns out it dosent work.

we will still have to drop "now" feature since it will be local time, but allow clear should be fine

@kirkrodrigues

Copy link
Copy Markdown
Member

Maybe we just keep the selector in the local timezone, and due a gross manipulation when submitting the query (i think the timeline does something like this)? I think you can use utc(true) and it will drop the existing offset. It dosent seem antd provides good support for timezones

Sounds reasonable for now.

@davemarco davemarco changed the title fix(new-webui): Remove options from range picker that set the timezone to local. fix(new-webui): Modify range picker to always output timestamps in UTC. Jul 4, 2025
@davemarco

Copy link
Copy Markdown
Contributor Author

@kirkrodrigues - i made the fix. It appears to work, overall it is not that messy.

@kirkrodrigues kirkrodrigues left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you update the PR description about why we removed showNow as well as the updated validation steps?

davemarco and others added 2 commits July 7, 2025 13:29
…meRangeInput/index.tsx

Co-authored-by: kirkrodrigues <2454684+kirkrodrigues@users.noreply.github.com>
@davemarco davemarco requested a review from kirkrodrigues July 7, 2025 19:42

@kirkrodrigues kirkrodrigues left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For the PR title, how about:

fix(new-webui): Drop timezone from `Date`s returned by antd's `DatePicker.RangePicker` to match timezone (UTC) shown in search results (fixes #1085).

@davemarco davemarco changed the title fix(new-webui): Modify range picker to always output timestamps in UTC. fix(new-webui): Drop timezone from Dates returned by antd's DatePicker.RangePicker to match timezone (UTC) shown in search results (fixes #1085). Jul 8, 2025
@davemarco davemarco changed the title fix(new-webui): Drop timezone from Dates returned by antd's DatePicker.RangePicker to match timezone (UTC) shown in search results (fixes #1085). fix(new-webui): Drop timezone from Date returned by antd's DatePicker.RangePicker to match timezone (UTC) shown in search results (fixes #1085). Jul 8, 2025
@davemarco davemarco changed the title fix(new-webui): Drop timezone from Date returned by antd's DatePicker.RangePicker to match timezone (UTC) shown in search results (fixes #1085). fix(new-webui): Drop timezone from Dates returned by antd's DatePicker.RangePicker to match timezone (UTC) shown in search results (fixes #1085). Jul 8, 2025
@davemarco davemarco merged commit 1126730 into y-scope:main Jul 8, 2025
10 checks passed
junhaoliao pushed a commit to junhaoliao/clp that referenced this pull request May 17, 2026
…cker.RangePicker` to match timezone (UTC) shown in search results (fixes y-scope#1085). (y-scope#1053)

Co-authored-by: Marco <david.marcovitch@yscope.com>
Co-authored-by: kirkrodrigues <2454684+kirkrodrigues@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants