codeant-ai-for-open-source[bot] commented on code in PR #46082:
URL: https://github.com/apache/superset/pull/46082#discussion_r4504217520


##########
superset-frontend/src/components/CalendarRangePicker/CalendarRangePicker.tsx:
##########
@@ -0,0 +1,113 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { useMemo, FC } from 'react';
+import type { Dayjs } from 'dayjs';
+import { t } from '@apache-superset/core/translation';
+import { styled, css } from '@apache-superset/core/theme';
+import { RangePicker } from '@superset-ui/core/components';
+import type { CalendarRangePickerProps } from './types';
+import {
+  parseRangeValue,
+  formatRangeValue,
+  DEFAULT_DATE_FORMAT,
+} from './utils';
+
+const StyledRangePicker = styled(RangePicker)`
+  ${({ theme }) => css`
+    width: 100%;
+    border-radius: ${theme.borderRadius}px;
+
+    .ant-picker-input > input {
+      font-size: ${theme.fontSize}px;
+    }
+
+    &.ant-picker {
+      border-color: ${theme.colorBorder};
+      &:hover {
+        border-color: ${theme.colorPrimaryHover || theme.colorPrimary};
+      }
+      &.ant-picker-focused {
+        border-color: ${theme.colorPrimary};
+        box-shadow: 0 0 0 2px ${theme.controlOutline};
+      }
+    }
+
+    @media (max-width: ${theme.breakpoints?.xs ?? 768}px) {
+      .ant-picker-panels {
+        flex-direction: column;
+      }
+    }
+  `}
+`;
+
+export const CalendarRangePicker: FC<CalendarRangePickerProps> = ({
+  value,
+  onChange,
+  disabled = false,
+  placeholder,
+  format = DEFAULT_DATE_FORMAT,
+  clearValue = '',
+  allowClear = true,
+  inclusiveEndDate = true,
+  className,
+  style,
+  'data-test': dataTest = 'calendar-range-picker',
+  autoFocus = false,
+  size,
+  status,
+  disabledDate,
+  id,
+}) => {
+  const dayjsValue = useMemo(
+    () => parseRangeValue(value, format),
+    [value, format],
+  );
+
+  const handleChange = (dates: [Dayjs | null, Dayjs | null] | null) => {
+    const formatted = formatRangeValue(dates, format, clearValue);

Review Comment:
   **Suggestion:** `inclusiveEndDate` is never applied here, so the selected 
end is serialized at midnight; Superset treats `until` as exclusive and drops 
records from that final day.
   
   **Assessment:** ๐ŸŸ  `Major` ยท ๐Ÿ” `Occurrence: Often` ยท ๐Ÿท๏ธ `Incomplete 
implementation`
   
   [![Use CodeAnt 
Skill](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/use-codeant-skill-flat-v2.svg)](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
 [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=13242a3a636149568d236f4d999d85cd&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=13242a3a636149568d236f4d999d85cd&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   <details>
   <summary><b>Prompt for AI Agent ๐Ÿค– </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** 
superset-frontend/src/components/CalendarRangePicker/CalendarRangePicker.tsx
   **Line:** 83:83
   **Comment:**
        *Incomplete Implementation: `inclusiveEndDate` is never applied here, 
so the selected end is serialized at midnight; Superset treats `until` as 
exclusive and drops records from that final day.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F46082&comment_hash=dc83063dee2233f938a3b659d6fe7fc3ef8af6d9c8b6629bcd98b78548f62ebd&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F46082&comment_hash=dc83063dee2233f938a3b659d6fe7fc3ef8af6d9c8b6629bcd98b78548f62ebd&reaction=dislike'>๐Ÿ‘Ž</a>



##########
superset-frontend/src/components/CalendarRangePicker/utils.ts:
##########
@@ -0,0 +1,137 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { extendedDayjs } from '@superset-ui/core/utils/dates';
+import { NO_TIME_RANGE, SEPARATOR } from '@superset-ui/core';
+import type { Dayjs } from 'dayjs';
+
+export const DEFAULT_DATE_FORMAT = 'YYYY-MM-DD';
+
+export const parseSingleDate = (
+  dateStr?: string | null,
+  format: string = DEFAULT_DATE_FORMAT,
+): Dayjs | null => {
+  if (!dateStr || typeof dateStr !== 'string') {
+    return null;
+  }
+  const trimmed = dateStr.trim();
+  if (!trimmed) {
+    return null;
+  }
+
+  // 1. Strict parsing with configured format (handles DEFAULT_DATE_FORMAT and 
custom formats)
+  if (format) {
+    const strictParsed = extendedDayjs(trimmed, format, true);
+    if (strictParsed.isValid()) {
+      return strictParsed;
+    }
+  }
+
+  // 2. Strict ISO parsing for datetime strings (with T or space before time)
+  if (trimmed.includes('T') || 
/^\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}/.test(trimmed)) {
+    const isoParsed = extendedDayjs(trimmed);
+    if (isoParsed.isValid()) {
+      // Prevent rollover in ISO strings (e.g., 2026-02-31T00:00:00 or 
non-leap 2026-02-29)
+      const match = trimmed.match(/^(\d{4})-(\d{2})-(\d{2})/);
+      if (match) {
+        const y = parseInt(match[1], 10);
+        const m = parseInt(match[2], 10);
+        const d = parseInt(match[3], 10);
+        if (
+          isoParsed.year() !== y ||
+          isoParsed.month() + 1 !== m ||
+          isoParsed.date() !== d
+        ) {
+          return null;
+        }

Review Comment:
   **Suggestion:** `extendedDayjs` interprets an ISO offset as a browser-local 
instant, so this comparison rejects valid timestamps that cross midnight 
locally and leaves their range blank.
   
   **Assessment:** ๐ŸŸ  `Major` ยท ๐Ÿ” `Occurrence: Sometimes` ยท ๐Ÿท๏ธ `Incorrect 
condition logic`
   
   [![Use CodeAnt 
Skill](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/use-codeant-skill-flat-v2.svg)](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
 [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=6a47b34fe42f409ba9753578671fd6bf&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=6a47b34fe42f409ba9753578671fd6bf&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   <details>
   <summary><b>Prompt for AI Agent ๐Ÿค– </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset-frontend/src/components/CalendarRangePicker/utils.ts
   **Line:** 55:61
   **Comment:**
        *Incorrect Condition Logic: `extendedDayjs` interprets an ISO offset as 
a browser-local instant, so this comparison rejects valid timestamps that cross 
midnight locally and leaves their range blank.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F46082&comment_hash=018e725a655dee701513547b5a9a1d70c9ae839225a234b89e9938c0f34a3777&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F46082&comment_hash=018e725a655dee701513547b5a9a1d70c9ae839225a234b89e9938c0f34a3777&reaction=dislike'>๐Ÿ‘Ž</a>



##########
superset-frontend/src/components/CalendarRangePicker/utils.ts:
##########
@@ -0,0 +1,137 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { extendedDayjs } from '@superset-ui/core/utils/dates';
+import { NO_TIME_RANGE, SEPARATOR } from '@superset-ui/core';
+import type { Dayjs } from 'dayjs';
+
+export const DEFAULT_DATE_FORMAT = 'YYYY-MM-DD';
+
+export const parseSingleDate = (
+  dateStr?: string | null,
+  format: string = DEFAULT_DATE_FORMAT,
+): Dayjs | null => {
+  if (!dateStr || typeof dateStr !== 'string') {
+    return null;
+  }
+  const trimmed = dateStr.trim();
+  if (!trimmed) {
+    return null;
+  }
+
+  // 1. Strict parsing with configured format (handles DEFAULT_DATE_FORMAT and 
custom formats)
+  if (format) {
+    const strictParsed = extendedDayjs(trimmed, format, true);
+    if (strictParsed.isValid()) {
+      return strictParsed;
+    }
+  }
+
+  // 2. Strict ISO parsing for datetime strings (with T or space before time)
+  if (trimmed.includes('T') || 
/^\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}/.test(trimmed)) {
+    const isoParsed = extendedDayjs(trimmed);
+    if (isoParsed.isValid()) {
+      // Prevent rollover in ISO strings (e.g., 2026-02-31T00:00:00 or 
non-leap 2026-02-29)
+      const match = trimmed.match(/^(\d{4})-(\d{2})-(\d{2})/);
+      if (match) {
+        const y = parseInt(match[1], 10);
+        const m = parseInt(match[2], 10);
+        const d = parseInt(match[3], 10);
+        if (
+          isoParsed.year() !== y ||
+          isoParsed.month() + 1 !== m ||
+          isoParsed.date() !== d
+        ) {
+          return null;
+        }
+      }
+      return isoParsed;
+    }
+  }
+
+  // 3. Fallback: if a custom format was provided, try strict 
DEFAULT_DATE_FORMAT as standard fallback
+  if (format !== DEFAULT_DATE_FORMAT) {
+    const standardParsed = extendedDayjs(trimmed, DEFAULT_DATE_FORMAT, true);
+    if (standardParsed.isValid()) {
+      return standardParsed;
+    }
+  }
+
+  return null;
+};
+
+export const parseRangeValue = (
+  value?: string | null,
+  format: string = DEFAULT_DATE_FORMAT,
+): [Dayjs | null, Dayjs | null] | null => {
+  if (!value || typeof value !== 'string') {
+    return null;
+  }
+
+  const trimmed = value.trim();
+  if (!trimmed || trimmed === NO_TIME_RANGE) {
+    return null;
+  }
+
+  // Dangling colons at start or end represent malformed/partial inputs
+  if (trimmed.startsWith(':') || trimmed.endsWith(':')) {
+    return null;
+  }

Review Comment:
   **Suggestion:** ` : 2020-07-17T00:00:00` is a valid open-ended Superset 
range, but this guard rejects it before parsing, so the picker displays no 
bound.
   
   **Assessment:** ๐ŸŸ  `Major` ยท ๐Ÿ” `Occurrence: Sometimes` ยท ๐Ÿท๏ธ `Api mismatch`
   
   [![Use CodeAnt 
Skill](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/use-codeant-skill-flat-v2.svg)](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
 [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=a97a45676bec4216a931745a30d2c37c&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=a97a45676bec4216a931745a30d2c37c&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   <details>
   <summary><b>Prompt for AI Agent ๐Ÿค– </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset-frontend/src/components/CalendarRangePicker/utils.ts
   **Line:** 91:94
   **Comment:**
        *Api Mismatch: ` : 2020-07-17T00:00:00` is a valid open-ended Superset 
range, but this guard rejects it before parsing, so the picker displays no 
bound.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F46082&comment_hash=e50667242ec92c5ec82271c30b159cd8ff2bfff85ab262c49796167cd5e7858e&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F46082&comment_hash=e50667242ec92c5ec82271c30b159cd8ff2bfff85ab262c49796167cd5e7858e&reaction=dislike'>๐Ÿ‘Ž</a>



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

  • [PR] feat(f... FrancescoCastaldi (via GitHub) via notifications
    • Re: [P... netlify[bot] (via GitHub) via notifications
    • Re: [P... codeant-ai-for-open-source[bot] (via GitHub) via notifications
    • Re: [P... codeant-ai-for-open-source[bot] (via GitHub) via notifications

Reply via email to