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


##########
superset-frontend/src/dashboard/actions/hydrate.test.ts:
##########
@@ -0,0 +1,276 @@
+/**
+ * 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 { HYDRATE_DASHBOARD, hydrateDashboard } from './hydrate';
+import {
+  DASHBOARD_ROOT_TYPE,
+  TABS_TYPE,
+  TAB_TYPE,
+} from '../util/componentTypes';
+import { DASHBOARD_ROOT_ID } from '../util/constants';
+
+/**
+ * Regression guard for the follow-up to PR #39417 / PR #41832: the default
+ * active-tab path must be seeded into `dashboardState.activeTabs` at hydration
+ * time, so every first-render consumer (filter bar, share menus, permalink
+ * utilities, screenshot download) reads the dashboard's real default tab path
+ * instead of an empty array.
+ *
+ * Before this change, hydrate seeded `activeTabs: activeTabs ||
+ * dashboardState?.activeTabs || []` (hydrate.ts). With no permalink, no stored
+ * state and no directPathToChild, that resolved to `[]`, and the live `Tabs`
+ * component only populated the value from a post-mount effect. These tests
+ * assert the seeded default path and fail without the hydration-time seeding.
+ */
+
+const layoutItem = (
+  id: string,
+  type: string,
+  children: string[],
+  parents: string[],
+) => ({ id, type, children, parents, meta: {} });
+
+const buildDashboard = (
+  positionData: Record<string, unknown>,
+  title = 'Test dashboard',
+) => ({
+  id: 1,
+  dashboard_title: title,
+  css: '',
+  published: true,
+  changed_on: '2024-01-01T00:00:00.000Z',
+  owners: [],
+  metadata: {},
+  position_data: positionData,
+});
+
+const hydrate = (
+  positionData: Record<string, unknown>,
+  overrides: {
+    activeTabs?: string[] | null;
+    dashboardState?: Record<string, unknown>;
+  } = {},
+) => {
+  const dispatch = jest.fn((action: unknown) => action);
+  const getState = () =>
+    ({
+      user: { roles: {}, userId: 1 },
+      common: { conf: {} },
+      dashboardState: overrides.dashboardState ?? {},
+    }) as any;

Review Comment:
   **Suggestion:** Replace this `any` cast with an explicit state type for the 
mocked return value so `getState` is strongly typed. [custom_rule]
   
   **Severity Level:** Minor ๐Ÿงน
   <details>
   <summary><b>Why it matters? โญ </b></summary>
   
   The rule prohibits new or changed TypeScript code that uses `any`. This line 
casts the mocked `getState()` return value to `any`, so the suggestion 
correctly identifies a real violation in the final file.
   </details>
   <details>
   <summary><b>Rule source ๐Ÿ“– </b></summary>
   
   .cursor/rules/dev-standard.mdc (line 16)
   </details>
   
   [![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=8480373a042449b7afdf80fbf63d5614&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=8480373a042449b7afdf80fbf63d5614&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent ๐Ÿค– </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset-frontend/src/dashboard/actions/hydrate.test.ts
   **Line:** 75:75
   **Comment:**
        *Custom Rule: Replace this `any` cast with an explicit state type for 
the mocked return value so `getState` is strongly typed.
   
   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%2F42075&comment_hash=ae516294074be9ad0e6f96f576817f35f964591e8a231e973d828ed019f2d585&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42075&comment_hash=ae516294074be9ad0e6f96f576817f35f964591e8a231e973d828ed019f2d585&reaction=dislike'>๐Ÿ‘Ž</a>



##########
superset-frontend/src/dashboard/actions/hydrate.test.ts:
##########
@@ -0,0 +1,276 @@
+/**
+ * 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 { HYDRATE_DASHBOARD, hydrateDashboard } from './hydrate';
+import {
+  DASHBOARD_ROOT_TYPE,
+  TABS_TYPE,
+  TAB_TYPE,
+} from '../util/componentTypes';
+import { DASHBOARD_ROOT_ID } from '../util/constants';
+
+/**
+ * Regression guard for the follow-up to PR #39417 / PR #41832: the default
+ * active-tab path must be seeded into `dashboardState.activeTabs` at hydration
+ * time, so every first-render consumer (filter bar, share menus, permalink
+ * utilities, screenshot download) reads the dashboard's real default tab path
+ * instead of an empty array.
+ *
+ * Before this change, hydrate seeded `activeTabs: activeTabs ||
+ * dashboardState?.activeTabs || []` (hydrate.ts). With no permalink, no stored
+ * state and no directPathToChild, that resolved to `[]`, and the live `Tabs`
+ * component only populated the value from a post-mount effect. These tests
+ * assert the seeded default path and fail without the hydration-time seeding.
+ */
+
+const layoutItem = (
+  id: string,
+  type: string,
+  children: string[],
+  parents: string[],
+) => ({ id, type, children, parents, meta: {} });
+
+const buildDashboard = (
+  positionData: Record<string, unknown>,
+  title = 'Test dashboard',
+) => ({
+  id: 1,
+  dashboard_title: title,
+  css: '',
+  published: true,
+  changed_on: '2024-01-01T00:00:00.000Z',
+  owners: [],
+  metadata: {},
+  position_data: positionData,
+});
+
+const hydrate = (
+  positionData: Record<string, unknown>,
+  overrides: {
+    activeTabs?: string[] | null;
+    dashboardState?: Record<string, unknown>;
+  } = {},
+) => {
+  const dispatch = jest.fn((action: unknown) => action);
+  const getState = () =>
+    ({
+      user: { roles: {}, userId: 1 },
+      common: { conf: {} },
+      dashboardState: overrides.dashboardState ?? {},
+    }) as any;
+  const action = (
+    hydrateDashboard({
+      history: { replace: jest.fn() },
+      dashboard: buildDashboard(positionData),
+      charts: [],
+      dataMask: {},
+      activeTabs: overrides.activeTabs ?? null,
+      chartStates: null,
+    } as any) as any

Review Comment:
   **Suggestion:** Remove these `any` casts and type the `hydrateDashboard` 
input/output with the appropriate action/thunk interfaces. [custom_rule]
   
   **Severity Level:** Minor ๐Ÿงน
   <details>
   <summary><b>Why it matters? โญ </b></summary>
   
   This code uses `any` twice in the thunk invocation, which directly violates 
the no-`any` TypeScript rule for changed code. The issue is present in the 
final file and the suggestion is valid.
   </details>
   <details>
   <summary><b>Rule source ๐Ÿ“– </b></summary>
   
   .cursor/rules/dev-standard.mdc (line 16)
   </details>
   
   [![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=a972b004f3274cb4b5c1a8a71138bc9b&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=a972b004f3274cb4b5c1a8a71138bc9b&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent ๐Ÿค– </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset-frontend/src/dashboard/actions/hydrate.test.ts
   **Line:** 84:84
   **Comment:**
        *Custom Rule: Remove these `any` casts and type the `hydrateDashboard` 
input/output with the appropriate action/thunk interfaces.
   
   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%2F42075&comment_hash=de68530dc50ebc2761e95980217fd0609e9ee248a2af7110d19a511aba6c0947&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42075&comment_hash=de68530dc50ebc2761e95980217fd0609e9ee248a2af7110d19a511aba6c0947&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]

Reply via email to