codeant-ai-for-open-source[bot] commented on code in PR #40434: URL: https://github.com/apache/superset/pull/40434#discussion_r3303528809
########## superset-frontend/src/core/navigation/index.ts: ########## @@ -0,0 +1,102 @@ +/** + * 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. + */ + +/** + * Host-internal implementation of the `navigation` namespace. + * + * Backed by browser location — no Redux dependency. + * The app shell calls `notifyPageChange(pathname)` whenever the route changes. + */ + +import type { navigation as navigationApi } from '@apache-superset/core'; +import { Disposable } from '../models'; + +type PageType = navigationApi.PageType; +type PageContext = navigationApi.PageContext; + +const listeners = new Set<(ctx: PageContext) => void>(); + +function derivePageType(pathname: string): PageType { + if (pathname.startsWith('/superset/dashboard/')) return 'dashboard'; + if (pathname.startsWith('/explore/')) return 'explore'; + if (pathname.startsWith('/superset/explore/')) return 'explore'; + if (pathname.startsWith('/chart/add')) return 'explore'; + if (pathname.startsWith('/sqllab/')) return 'sqllab'; + if (pathname.startsWith('/dataset/')) return 'dataset'; + if (pathname.startsWith('/superset/welcome/')) return 'home'; + return 'other'; +} + +function extractEntityId(pathname: string, pageType: PageType): number | null { + if (pageType === 'dashboard') { + const m = pathname.match(/\/superset\/dashboard\/(\d+)/); + return m ? parseInt(m[1], 10) : null; + } + if (pageType === 'dataset') { + const m = pathname.match(/\/dataset\/(\d+)/); + return m ? parseInt(m[1], 10) : null; + } + return null; Review Comment: **🟠 Architect Review — HIGH** Navigation `PageContext.entityId` is never populated for Explore routes: `extractEntityId` only handles `dashboard` and `dataset`, so `getCurrentPage()` and `onDidChangePage` always report `entityId: null` on Explore pages despite the contract documenting chart id as the focused entity. **Suggestion:** Extend navigation to derive the Explore chart id (e.g. from `slice_id`/permalink URL state) and update `notifyPageChange` to consider path plus query so `entityId` changes when the user switches charts in Explore. [Fix in Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=33b536e6e2df4eaabe586a3b63618760&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) | [Fix in VSCode Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=33b536e6e2df4eaabe586a3b63618760&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 an **Architect / Logical Review** comment left during a code review. These reviews are first-class, important findings — not optional suggestions. Do NOT dismiss this as a 'big architectural change' just because the title says architect review; most of these can be resolved with a small, localized fix once the intent is understood. **Path:** superset-frontend/src/core/navigation/index.ts **Line:** 46:55 **Comment:** *HIGH: Navigation `PageContext.entityId` is never populated for Explore routes: `extractEntityId` only handles `dashboard` and `dataset`, so `getCurrentPage()` and `onDidChangePage` always report `entityId: null` on Explore pages despite the contract documenting chart id as the focused entity. 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. If a suggested approach is provided above, use it as the authoritative instruction. If no explicit code suggestion is given, you MUST still draft and apply your own minimal, localized fix — do not punt back with 'no suggestion provided, review manually'. Keep the change as small as possible: add a guard clause, gate on a loading state, reorder an await, wrap in a conditional, etc. Do not refactor surrounding code or expand scope beyond the finding. 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> ########## superset-frontend/src/core/dataset/index.ts: ########## @@ -0,0 +1,62 @@ +/** + * 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. + */ + +/** + * Host-internal implementation of the `dataset` namespace. + * + * Dataset page components call `setCurrentDataset` to publish context as they + * load. Extensions consume the stable `DatasetContext` contract; they are + * isolated from the page's internal data-fetching implementation. + */ + +import type { dataset as datasetApi } from '@apache-superset/core'; +import { Disposable } from '../models'; + +type DatasetContext = datasetApi.DatasetContext; + +let currentDataset: DatasetContext | undefined; +const listeners = new Set<(ctx: DatasetContext) => void>(); + +/** + * Host-internal: called by the Dataset page when its entity loads or changes. + * Not part of the public `@apache-superset/core` API. + */ +export const setCurrentDataset = (ctx: DatasetContext | undefined): void => { + currentDataset = ctx; + if (ctx) { + listeners.forEach(fn => fn(ctx)); + } +}; Review Comment: **🔴 Architect Review — CRITICAL** The dataset namespace push store is never wired: `setCurrentDataset` has no call sites anywhere in the repo, so `dataset.getCurrentDataset()` always returns `undefined` and `onDidChangeDataset` never fires, even when viewing a Dataset page. **Suggestion:** Wire the Dataset page lifecycle to call `setCurrentDataset` with a populated `DatasetContext` on load and clear it on unmount/leave so `getCurrentDataset` and `onDidChangeDataset` reflect the actual page dataset. [Fix in Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=73e7b1a2d5ea49c69030d3d7d77278e4&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) | [Fix in VSCode Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=73e7b1a2d5ea49c69030d3d7d77278e4&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 an **Architect / Logical Review** comment left during a code review. These reviews are first-class, important findings — not optional suggestions. Do NOT dismiss this as a 'big architectural change' just because the title says architect review; most of these can be resolved with a small, localized fix once the intent is understood. **Path:** superset-frontend/src/core/dataset/index.ts **Line:** 40:45 **Comment:** *CRITICAL: The dataset namespace push store is never wired: `setCurrentDataset` has no call sites anywhere in the repo, so `dataset.getCurrentDataset()` always returns `undefined` and `onDidChangeDataset` never fires, even when viewing a Dataset page. 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. If a suggested approach is provided above, use it as the authoritative instruction. If no explicit code suggestion is given, you MUST still draft and apply your own minimal, localized fix — do not punt back with 'no suggestion provided, review manually'. Keep the change as small as possible: add a guard clause, gate on a loading state, reorder an await, wrap in a conditional, etc. Do not refactor surrounding code or expand scope beyond the finding. 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> -- 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]
