Skip to content

refactor(lineage): replace LineageProvider with Lineage component + useLineageStore - #33921

Merged
chirag-madlani merged 42 commits into
mainfrom
refactor-lineage-provider
Sep 29, 2026
Merged

chirag-madlani merged 42 commits into
mainfrom
refactor-lineage-provider

Conversation

@chirag-madlani

@chirag-madlani chirag-madlani commented Sep 24, 2026 •

Copy link
Copy Markdown
Collaborator

Describe your changes:

LineageProvider was a 2476-line context provider that bundled seven concerns (data loading, graph state, edit mutations, filters, expand/collapse, selection/drawer, export) into one context value with ~30 memo deps. Because hot arrays (nodes, edges, entityLineage) sat next to stable handlers, every graph mutation re-rendered all 9 consumers.

This PR deletes the provider and replaces it with:

  • useLineageStore slices (graph, data, entity + ReactFlow, filters, UI) — consumers subscribe via single-field selectors or useShallow, so each re-renders only on its own slice.
  • <Lineage /> orchestrator (components/Lineage/Lineage/Lineage.tsx) — props-driven (entity, entityType, entityFqn, isPlatformLineage), holds the effects/callbacks from the old provider verbatim, mirrors local graph/data/entity state into the store.
  • LineageHandlersContext — a small context with only 10 stable handlers that need React-tree access (ELK relayout, refs, JSX in node data, transactional REST, router).
  • <LineageOverlays /> — drawer, delete modal, add-pipeline modal, breadcrumbs; reads modal/drawer state from the store.
  • Pure handlers in utils/Lineage/handlers/ — onColumnMouseEnter, onPaneClick, onEdgeClick, onAddPipelineClick, onColumnEdgeRemove, exportLineageData.

No hook returns JSX; rendering roots are <Lineage /> and <LineageOverlays /> only.

Type of change:

  • Improvement

High-level design:

Approach. Split by concern: state moves to the existing Zustand store; handlers that are genuinely pure move to utils/Lineage/handlers/; handlers with React-tree dependencies stay in <Lineage /> behind a tiny context. Rejected alternatives: prop-drilling (custom nodes are rendered by ReactFlow, so props can't reach them) and pushing imperative handlers into Zustand (they close over router/refs/async state).

Why <Lineage /> is still large. Early attempts to extract the data-loader and several handlers into standalone hooks/functions dropped live behavior (ELK relayout, domain-scoped query filter, LOAD_MORE pagination, handleLineageTracing, transactional edge removal, data.label JSX for new nodes, platform-view fetch branches). Those attempts were reverted and <Lineage /> was built by copy-and-trim so effect and callback bodies stay verbatim. The external API is what changed; internal logic is preserved.

Consumers migrated: CustomNode.utils, CanvasEdgeRenderer (hot path, two independent single-field selectors), LineageControlButtons, CustomNodeV1, CustomControls, LineageSearchSelect, LineageTable, LineageMap.

Mount points: EntityLineageTab and PlatformLineage now render <Lineage />. The pre-existing canvas Lineage default import is aliased to LineageComponent in both files to avoid a name clash.

Type moves: LineagePlatformView / LineageTimeRange → hooks/lineage/types.ts; EntityLineageResponse → interface/lineage.interface.ts (removes two no-hook-ui-imports suppressions in useLineageStore).

Deleted: context/LineageProvider/LineageProvider.tsx, .interface.tsx, .test.tsx. No references to useLineageProvider, LineageContext, or context/LineageProvider remain.

Known carry-overs (intentionally out of scope):

  • 30 react-hooks/exhaustive-deps warnings in Lineage.tsx, copied verbatim from the old provider. Fixing them changes effect cadence, so they need their own audit.
  • One no-hook-ui-imports suppression for ExploreQuickFilterField. Moving that type touches unrelated components/Explore/** callers.

Tests:

Use cases covered

  • Entity lineage tab and platform lineage mount through <Lineage /> and push entity context into the store
  • Lineage fetch on mount with correct params; dedupe on repeated mode switches; impact_analysis → lineage refetch
  • loadChildNodesHandler fetches and merges the child subtree
  • onNodeClick opens the drawer, selects the node, and traces the connected path
  • updateEntityData syncs entity context to the store synchronously
  • Delete modal renders from store state and confirms through the handler

Unit tests

  • I added unit tests for the new/changed logic.
  • Files added/updated:
    • hooks/useLineageStore.test.ts — all new slices and actions
    • utils/Lineage/handlers/{columnInteractions,nodeMutations,edgeMutations,exportHandler}.test.ts
    • components/Lineage/LineageOverlays/LineageOverlays.test.tsx
    • components/Lineage/Lineage/Lineage.test.tsx, Lineage.integration.test.tsx
    • Mocks updated to selector-aware useLineageStore / useLineageHandlers in: CustomNode.utils, CanvasEdgeRenderer, LineageControlButtons, CustomNodeV1, CustomControls, LineageSearchSelect, LineageTable, PlatformLineage, PipelineDetails, ContainerPage tests

Backend integration tests

  • Not applicable (no backend API changes).

Ingestion integration tests

  • Not applicable (no ingestion changes).

Playwright (UI) tests

  • No new specs. This PR should not change behavior, so existing lineage Playwright specs are the regression gate.

Manual testing performed

  • Pending: entity lineage tab load, platform lineage (service/domain/data product), edit mode add/remove edge, Delete/Backspace under edit mode, node expand/collapse, time filter + fullscreen URL params, export, tour walkthrough.

UI screen recording / screenshots:

Pending. No visual change is expected; a smoke recording will be attached before merge.

Checklist:

  • I have read the CONTRIBUTING document.

  • My PR title is Fixes <issue-number>: <short explanation>

  • My PR is linked to a GitHub issue via Fixes #<issue-number> above.

  • I have commented on my code, particularly in hard-to-understand areas.

  • For UI changes: I attached a screen recording and/or screenshots above.

  • I have added tests (unit / integration / Playwright as applicable) and listed them above.

  • I have added tests around the new logic.

🤖 Generated with Claude Code

RetriggerConfidence Score: 0/5

The PR is not safe to merge until lineage edits persist and the migrated graph, filter, time, and data-quality paths share working state.

Findings

  1. P1 Edge edits are not saved ▶
  2. P1 Quick filters are ignored ▶
  3. P1 Lineage redraw cannot run ▶
Summary

The PR replaces the lineage provider with a store-backed orchestrator, a small handlers context, extracted overlays, and migrated consumers.

  • Several migrated consumers now read state that the orchestrator does not keep synchronized, affecting filters, time ranges, and data-quality tracing.
  • The extracted drawer loses its edge-update callback, and the orchestrator's retained redraw path has no React Flow instance.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Controls[Lineage controls] --> Store[useLineageStore]
  Store --> Scene[LineageMap scene fetch]
  Orchestrator[Lineage orchestrator local state] --> Legacy[Lineage fetch and export]
  Orchestrator --> Mirrors[Graph and entity mirrors]
  Mirrors --> Store
  Store --> Overlays[LineageOverlays]
  Store --> Nodes[CustomNodeV1]
  Orchestrator --> Handlers[LineageHandlersContext]
Loading

Reviews (1) · Last reviewed commit: "chore(playwright): auto-refresh impact-m..."

Adds one-way mirror useEffect blocks so provider-owned graph/data/entity/
filters/ui state is published into useLineageStore while the provider is
mounted. Lets consumers migrate to store selectors ahead of the Phase E
mount swap, with no change to provider behavior.
Extracts onEdgeClick, onAddPipelineClick, onColumnEdgeRemove — all
pure Zustand store reads/writes. Defers onConnect (REST call plus
local useMapBasedNodesEdges/entityLineage state, not store-backed)
and onEdgeDetailsUpdate (REST call plus local edges/entityLineage
state and the local updateEdge closure) to LineageHandlersContext.
Copy-and-trim LineageProvider.tsx into the new components/Lineage/Lineage
orchestrator: props replace useFqn()/URL-derived entity context, the
LineageContext wrapper and Task 6 store-mirror effects are removed, and
inline overlay JSX (drawer, delete modal, add-pipeline modal, breadcrumbs)
is replaced by <LineageOverlays />. A new LineageHandlersContext exposes
the 10 handlers that need React-tree access. LineageProvider.tsx is
untouched.
LineageProvider.tsx/.interface.tsx/.test.tsx are fully superseded by the
Lineage component + useLineageStore/useLineageStore.test.ts. Move
LineagePlatformView/LineageTimeRange to hooks/lineage/types.ts and
EntityLineageResponse to interface/lineage.interface.ts so the lineage
store no longer needs the no-hook-ui-imports eslint suppression for it.
Item 1 (dead reactFlowInstance plumbing in Lineage.tsx) was skipped: the
local reactFlowInstance useState is still read at onNodeDrop's
reactFlowInstance?.project(...) call, which is wired into the exposed
LineageHandlersValue context (onNodeDrop). Deleting the declaration
would break that reference, so it was left in place pending a
separate, scoped decision on the onNodeDrop/drag-and-drop path.
@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically.

Maintainers can bypass this check by adding the skip-pr-checks label.

@github-actions github-actions Bot added safe to test Add this label to run secure Github workflows on PRs UI UI specific issues labels Sep 24, 2026
chirag-madlani and others added 5 commits September 25, 2026 22:57
…ider

# Conflicts:
#	openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityLineage/CustomNode.utils.tsx
- Move EdgeDetails/NodeData/LineageData/LineageNodeData/LineagePagingInfo/
  CSVExportResponse into interface/lineage.interface (re-exported from their old
  homes) so rest/lineageAPI no longer imports UI modules.
- Import QueryField/QueryFilter and ExploreQuickFilterField types from the
  interface layer instead of pages/components; drops two store suppressions.
- Break the Lineage.interface <-> NodeChildren.interface runtime cycle with
  type-only imports.
- Resolve exhaustive-deps: add stable deps; wrap onNodeDrop, onEntitySelect,
  selectLoadMoreNode, removeEdgeHandler and removeColumnEdge in useCallback;
  call narrow-trigger effects (redraw, platform-view refetch, DQ fetch, URL
  sync, updateEntityData) through latest refs so their firing cadence is
  unchanged; read selectedQuickFilters via getState in the impact-level effects.
- Use the theme-adapting text-utility-brand-600 class for the depth label.
…ider

# Conflicts:
#	.github/playwright/impact-map.generated.json
#	openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityExportModalProvider/EntityExportModalProvider.interface.ts
#	openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityLineage/CustomControls.component.tsx
#	openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityLineage/NodeChildren/NodeChildren.interface.ts
#	openmetadata-ui/src/main/resources/ui/src/components/Lineage/Lineage.interface.ts
#	openmetadata-ui/src/main/resources/ui/src/components/Lineage/Lineage/Lineage.tsx
#	openmetadata-ui/src/main/resources/ui/src/components/Lineage/LineageMap/LineageMap.component.tsx
#	openmetadata-ui/src/main/resources/ui/src/components/LineageTable/LineageTable.interface.ts
#	openmetadata-ui/src/main/resources/ui/src/components/LineageTable/LineageTable.tsx
#	openmetadata-ui/src/main/resources/ui/src/context/LineageProvider/LineageProvider.interface.tsx
#	openmetadata-ui/src/main/resources/ui/src/context/LineageProvider/LineageProvider.test.tsx
#	openmetadata-ui/src/main/resources/ui/src/interface/lineage.interface.ts
#	openmetadata-ui/src/main/resources/ui/src/pages/PlatformLineage/PlatformLineage.tsx
#	openmetadata-ui/src/main/resources/ui/src/rest/lineageAPI.ts
#	openmetadata-ui/src/main/resources/ui/src/utils/EntityLineageNodeUtils.ts
@github-actions

Copy link
Copy Markdown
Contributor

🔄 Playwright impact map auto-refreshed

This PR touched specs or UI source that changed the source→spec routing map. I regenerated .github/playwright/impact-map.generated.json and pushed the diff to this branch.

- source entries: 804 → 804
- 1 added, 1 removed, 0 changed spec-list

New source→spec entries:
  openmetadata-ui/src/main/resources/ui/src/components/Lineage/LineageOverlays/LineageOverlays.tsx

Removed source→spec entries:
  openmetadata-ui/src/main/resources/ui/src/context/LineageProvider/LineageProvider.tsx

What is this file? It is the auto-generated half of Playwright's PR planner. It routes "if source X changes, run specs Y" by walking spec imports and cross-referencing getByTestId strings. Hand-authored routing in impact-map.json always wins on conflict.

What if I want to regenerate locally instead? Run this before pushing your next change to skip the bot commit:

python3 .github/scripts/generate_playwright_impact_map.py
git add .github/playwright/impact-map.generated.json
git commit --amend --no-edit  # or a separate commit

The page test mocked the Lineage canvas but not the new <Lineage /> wrapper, so
it rendered the real orchestrator and LineageOverlays' breadcrumbs, which call a
RouterUtils helper the test's partial mock doesn't provide.
@gitar-bot

gitar-bot Bot commented Sep 28, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 4 closed / 4 findings

🟡 Medium risk · Lineage state, edits, filters, and rendering are refactored across UI consumers.

Refactors the 2476-line LineageProvider into a store-backed orchestrator (<Lineage />), extracted handlers context, and <LineageOverlays />, splitting concerns across Zustand slices so consumers re-render only on their own state changes. Quick filters, time range URL persistence, edge drawer mutations, and data-quality tracing paths have been restored and now flow through the store correctly.

✅ 4 closed
✅ Bug: Quick filters no longer reach Lineage fetch/export queryFilter

📄 openmetadata-ui/src/main/resources/ui/src/components/Lineage/Lineage/Lineage.tsx:534 📄 openmetadata-ui/src/main/resources/ui/src/components/Lineage/Lineage/Lineage.tsx:592-595 📄 openmetadata-ui/src/main/resources/ui/src/components/Lineage/Lineage/Lineage.tsx:2106-2117 📄 openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityLineage/CustomControls.component.tsx:136-144
Lineage.tsx now declares const [selectedQuickFilters] = useState([]) with no setter. queryFilter (line ~556) is built from that local value, and it drives onPlatformViewUpdate, the fetch effect deps, and export. Consumers such as CustomControls and LineageTable now write filters to useLineageStore.setSelectedQuickFilters, and nothing copies that store value back into <Lineage />. The old provider state was the single source of truth. Now queryFilter is always the empty-filter query, so applying a quick filter never refetches or filters lineage, and exports ignore the filters too. Fix: read selectedQuickFilters from the store with a selector and drop the local state.

✅ Bug: Time filter changes are ignored; URL is no longer read or written

📄 openmetadata-ui/src/main/resources/ui/src/components/Lineage/Lineage/Lineage.tsx:547-554 📄 openmetadata-ui/src/main/resources/ui/src/components/Lineage/Lineage/Lineage.tsx:2106-2117 📄 openmetadata-ui/src/main/resources/ui/src/hooks/useLineageStore.ts:474 📄 openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityLineage/CustomControls.component.tsx:630-635 📄 openmetadata-ui/src/main/resources/ui/src/utils/Lineage/handlers/exportHandler.ts:27-37
The old provider's setTimeFilter updated local state and wrote lineageStartTime/lineageEndTime into the URL. Now LineageTimeFilter calls the store's setTimeFilter, which only does set({ timeFilter }). <Lineage /> keeps its own const [timeFilter] = useState(...), seeded once from the URL and never updated, and every fetch uses that value (getLineageFetchKey, getLineageDataByFQN, the effect deps at ~2115). Three things break. Picking a time range never refetches. The range is never persisted to the URL. And the store's timeFilter starts as {} even when the URL has params, so the control shows empty while the data is actually filtered, and exportLineageData exports without the time range. Fix: seed the store from the URL on mount, read timeFilter from the store in <Lineage />, and bring back the URL write, either in the store action or through a handler exposed from <Lineage />.

✅ Bug: Edge drawer edits never reach onEdgeDetailsUpdate

📄 openmetadata-ui/src/main/resources/ui/src/components/Lineage/Lineage/Lineage.tsx:1941-1944 📄 openmetadata-ui/src/main/resources/ui/src/components/Lineage/Lineage/Lineage.tsx:2241-2251 📄 openmetadata-ui/src/main/resources/ui/src/components/Lineage/LineageOverlays/LineageOverlays.tsx:138-144
onEdgeDetailsUpdate is defined in <Lineage /> and put into LineageHandlersContext, but nothing that renders EdgeInfoDrawer ever calls it. overlayHandlers doesn't pass it to LineageOverlays, and LineageOverlays renders <EdgeInfoDrawer ... onClose={onCloseDrawer} /> with no onEdgeDetailsUpdate prop. The drawer calls onEdgeDetailsUpdate?.(...) when you save a description, SQL query or column edit. With no prop, that call does nothing: updateLineageEdge is never sent and nothing is saved. Fix: add onEdgeDetailsUpdate to LineageOverlaysHandlers, pass it through here, and forward it to EdgeInfoDrawer.

✅ Bug: Data-quality lineage kept in local state, never published to store

📄 openmetadata-ui/src/main/resources/ui/src/components/Lineage/Lineage/Lineage.tsx:535-536 📄 openmetadata-ui/src/main/resources/ui/src/components/Lineage/Lineage/Lineage.tsx:565 📄 openmetadata-ui/src/main/resources/ui/src/components/Lineage/Lineage/Lineage.tsx:725-739 📄 openmetadata-ui/src/main/resources/ui/src/components/Lineage/Lineage/Lineage.tsx:2170-2182 📄 openmetadata-ui/src/main/resources/ui/src/components/Lineage/Lineage/Lineage.tsx:2199-2203 📄 openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityLineage/CustomNodeV1.component.tsx:204 📄 openmetadata-ui/src/main/resources/ui/src/components/Entity/EntityLineage/CustomNodeV1.component.tsx:281
fetchDataQualityLineage saves its response with a local useState setter (setDataQualityLineage), and dqHighlightedEdges is also computed into local state. The mirror effects at the end of <Lineage /> copy nodes, edges, entityLineage, loading, status, init and the entity context to the store, but not these two values. CustomNodeV1 now reads useLineageStore((s) => s.dataQualityLineage), and nothing in the codebase writes that field. So when DQ is enabled, nodes never show their data-quality failure indicator, and the DQ API call does nothing visible. Fix: write both values to the store (useLineageStore.setState({ dataQualityLineage, dqHighlightedEdges })), either where they are fetched or in a mirror effect.

Review coverage

📋 Rules No rules evaluated

🧪 Functional validation Not enabled · Set up

🤖 Auto-approval Not enabled · Set up

Options

Display: compact → Counting what did not apply, without listing it.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@sonarqubecloud

Copy link
Copy Markdown

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe to test Add this label to run secure Github workflows on PRs UI UI specific issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants