codeant-ai-for-open-source[bot] commented on code in PR #40912:
URL: https://github.com/apache/superset/pull/40912#discussion_r3493582393
##########
superset-frontend/src/dashboard/components/Header/useHeaderActionsDropdownMenu.tsx:
##########
@@ -234,6 +235,23 @@ export const useHeaderActionsMenu = ({
});
}
+ // View lineage (available in both view and edit mode; lineage is
+ // read-only information about the dashboard's upstream assets)
+ if (dashboardId) {
+ menuItems.push(
+ createModalMenuItem(
+ MenuKeys.ViewLineage,
+ <LineageModal
+ entityType="dashboard"
+ entityId={dashboardId}
+ triggerNode={
+ <div data-test="view-lineage-menu-item">{t('View lineage')}</div>
+ }
+ />,
+ ),
+ );
Review Comment:
**Suggestion:** This menu item mounts `LineageModal` directly inside the
dropdown label, which triggers lineage API fetching as soon as the actions menu
is rendered/opened, even when the user never clicks “View lineage”. This
introduces unnecessary backend calls on every menu open; defer
mounting/fetching until the lineage action is actually selected (for example by
lazy-mounting the modal content or passing a skip flag tied to modal open
state). [performance]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ❌ Dashboard actions dropdown always calls dashboard lineage endpoint.
- ⚠️ Extra network latency when opening dashboard actions menu.
- ⚠️ Unnecessary load on /api/v1/dashboard/:id/lineage service.
```
</details>
<details>
<summary><b>Steps of Reproduction ✅ </b></summary>
```mdx
1. Open any dashboard so the Header component from
`superset-frontend/src/dashboard/components/Header/index.tsx` is rendered;
at lines 69-99
in the 471-730 segment, `Header` calls `useHeaderActionsMenu` to obtain
`menu`, and at
lines 107-119 it passes that `menu` as `additionalActionsMenu` into
`PageHeaderWithActions`, wiring it to the actions dropdown.
2. Inside `useHeaderActionsMenu`
(`superset-frontend/src/dashboard/components/Header/useHeaderActionsDropdownMenu.tsx`,
lines 204-207), the hook builds a `Menu` instance whose `items` array is
populated in the
`menu` useMemo; when the actions dropdown opens, this `Menu` and all its
`label` React
nodes are rendered.
3. In that same file, the new "View lineage" item is added when
`dashboardId` is truthy
(lines 238-253): the code pushes a menu item via `createModalMenuItem` with
`label` set to
a `LineageModal` component configured for the current dashboard
(`entityType="dashboard"`,
`entityId={dashboardId}`), meaning `LineageModal` mounts immediately
whenever the dropdown
menu is rendered.
4. The `LineageModal` implementation in
`superset-frontend/src/features/lineage/LineageModal.tsx` (lines 35-45) calls
`useDashboardLineage(entityType === 'dashboard' ? entityId : '')`, and
`useDashboardLineage` in
`superset-frontend/src/hooks/apiResources/lineage.ts` (lines
147-150) forwards to
`useApiV1Resource('/api/v1/dashboard/${idOrSlug}/lineage', skip ||
isEmptyId(idOrSlug))`; with a non-empty `dashboardId` and `skip` defaulting
to false, this
issues a request to `/api/v1/dashboard/:id/lineage` as soon as the menu
renders, even if
the user never clicks the "View lineage" item.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=af197de883264f768702d16355f758a9&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=af197de883264f768702d16355f758a9&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/components/Header/useHeaderActionsDropdownMenu.tsx
**Line:** 241:252
**Comment:**
*Performance: This menu item mounts `LineageModal` directly inside the
dropdown label, which triggers lineage API fetching as soon as the actions menu
is rendered/opened, even when the user never clicks “View lineage”. This
introduces unnecessary backend calls on every menu open; defer
mounting/fetching until the lineage action is actually selected (for example by
lazy-mounting the modal content or passing a skip flag tied to modal open
state).
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%2F40912&comment_hash=3dea91ff2c2db32dc78ec1949ec7047ab02a764a1ea661ffd9b84e3885f04098&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40912&comment_hash=3dea91ff2c2db32dc78ec1949ec7047ab02a764a1ea661ffd9b84e3885f04098&reaction=dislike'>👎</a>
##########
superset-frontend/src/explore/components/useExploreAdditionalActionsMenu/index.tsx:
##########
@@ -1077,6 +1079,23 @@ export const useExploreAdditionalActionsMenu = (
onClick: () => setIsDropdownVisible(false),
});
+ // View lineage
+ if (slice?.slice_id) {
+ menuItems.push({
+ key: MENU_KEYS.VIEW_LINEAGE,
+ label: (
+ <LineageModal
+ entityType="chart"
+ entityId={slice.slice_id}
+ triggerNode={
+ <div data-test="view-lineage-menu-item">{t('View lineage')}</div>
+ }
+ />
+ ),
+ onClick: () => setIsDropdownVisible(false),
+ });
Review Comment:
**Suggestion:** This item also mounts `LineageModal` eagerly in the dropdown
menu, so opening the actions menu starts a lineage fetch even if the lineage
option is never clicked. That creates unnecessary API traffic and latency; make
the lineage modal/data load lazy on actual lineage action invocation.
[performance]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ❌ Chart actions dropdown always calls chart lineage endpoint.
- ⚠️ Extra latency when opening Explore chart actions menu.
- ⚠️ Unnecessary load on /api/v1/chart/:id/lineage service.
```
</details>
<details>
<summary><b>Steps of Reproduction ✅ </b></summary>
```mdx
1. In the Explore chart view, `ExploreChartHeader` from
`superset-frontend/src/explore/components/ExploreChartHeader/index.tsx` calls
`useExploreAdditionalActionsMenu` at lines 200-211 to obtain `[menu,
isDropdownVisible,
setIsDropdownVisible, streamingExportState]`, and then passes `menu` as
`additionalActionsMenu` plus `menuDropdownProps` to `PageHeaderWithActions`
at lines
110-120, wiring it to the chart actions dropdown.
2. The `useExploreAdditionalActionsMenu` hook in
`superset-frontend/src/explore/components/useExploreAdditionalActionsMenu/index.tsx`
constructs a `Menu` inside a `useMemo` (lines 654-655 and 1144-1151), and
populates
`menuItems` with various actions; when the chart actions dropdown is opened,
this `Menu`
and all of its `label` components are rendered.
3. After adding the "View query" item (lines 1061-1080), the hook appends a
"View lineage"
menu item when `slice?.slice_id` is defined (lines 1083-1097 in the PR
diff), setting
`label` to a `LineageModal` instance configured for the current chart
(`entityType="chart"`, `entityId={slice.slice_id}`) and closing the dropdown
on click,
which causes `LineageModal` to mount as soon as the dropdown menu renders.
4. As in the dashboard case, `LineageModal` in
`superset-frontend/src/features/lineage/LineageModal.tsx` (lines 35-44) calls
`useChartLineage(entityType === 'chart' ? entityId : '')`, and
`useChartLineage` in
`superset-frontend/src/hooks/apiResources/lineage.ts` (lines 136-139) invokes
`useApiV1Resource('/api/v1/chart/${idOrUuid}/lineage', skip ||
isEmptyId(idOrUuid))`; with
a valid `slice_id` and `skip` defaulting to false, opening the chart actions
dropdown
triggers an immediate request to `/api/v1/chart/:id/lineage` even when the
user never
chooses the lineage option.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=06edd2c1820f435094fd002d8012f173&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=06edd2c1820f435094fd002d8012f173&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/explore/components/useExploreAdditionalActionsMenu/index.tsx
**Line:** 1084:1096
**Comment:**
*Performance: This item also mounts `LineageModal` eagerly in the
dropdown menu, so opening the actions menu starts a lineage fetch even if the
lineage option is never clicked. That creates unnecessary API traffic and
latency; make the lineage modal/data load lazy on actual lineage action
invocation.
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%2F40912&comment_hash=a7017cd4a9564459205f14ff30f011ee2e2a874bb19249e2f877ff22e8867e1a&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40912&comment_hash=a7017cd4a9564459205f14ff30f011ee2e2a874bb19249e2f877ff22e8867e1a&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]