Skip to content

Commit 4f59e6f

Browse files
danyelfclaude
andcommitted
fix(lineage): move impact-at-startup trigger into useLayoutEffect
The separate useEffect never triggered the CLL API call because actionGetCll.mutateAsync only runs inside the useLayoutEffect (gated on lineageGraph). Additionally, persist the CLL input to viewOptions so it survives effect re-fires from the lineageGraph cache patch. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Danyel Fisher <danyel@gmail.com>
1 parent 6938289 commit 4f59e6f

1 file changed

Lines changed: 21 additions & 22 deletions

File tree

js/packages/ui/src/components/lineage/LineageViewOss.tsx

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,24 @@ export function PrivateLineageView(
420420
setViewOptions(newViewOptions);
421421
}
422422

423-
const cllInput = viewOptions.column_level_lineage;
423+
// Auto-trigger impact analysis on first load when flag is set
424+
let cllInput = viewOptions.column_level_lineage;
425+
if (
426+
serverFlags?.impact_at_startup &&
427+
!impactAtStartupFired.current &&
428+
!cllInput
429+
) {
430+
impactAtStartupFired.current = true;
431+
changeAnalysisModeRef.current = true;
432+
setChangeAnalysisMode(true);
433+
cllInput = { change_analysis: true, no_upstream: true };
434+
// Persist to viewOptions so the CLL survives effect re-fires
435+
// (e.g. when the lineageGraph cache is patched with change data)
436+
setViewOptions((prev) => ({
437+
...prev,
438+
column_level_lineage: cllInput,
439+
}));
440+
}
424441

425442
let cll: ColumnLineageData | undefined;
426443
if (cllInput) {
@@ -501,12 +518,13 @@ export function PrivateLineageView(
501518
};
502519

503520
void t();
504-
// Intentionally only run when lineageGraph changes (initial load/refetch).
521+
// Runs when lineageGraph changes (initial load/refetch), and also when
522+
// impact_at_startup flag arrives (may load after lineageGraph).
505523
// viewOptions changes are handled separately by handleViewOptionsChanged.
506524
// Other dependencies (setNodes, setEdges, actionGetCll) are stable.
507525
// changeAnalysisModeRef is a ref to avoid stale closure issues.
508526
// eslint-disable-next-line react-hooks/exhaustive-deps
509-
}, [lineageGraph]);
527+
}, [lineageGraph, serverFlags?.impact_at_startup]);
510528

511529
const onNodeViewClosed = () => {
512530
setFocusedNodeId(undefined);
@@ -590,25 +608,6 @@ export function PrivateLineageView(
590608
}
591609
};
592610

593-
// Auto-trigger impact analysis once when flag is set and lineage is loaded
594-
// Separate from the main useLayoutEffect to avoid race with async serverFlags
595-
// biome-ignore lint/correctness/useExhaustiveDependencies: showColumnLevelLineage is not memoized; ref guard ensures single execution.
596-
useEffect(() => {
597-
if (
598-
serverFlags?.impact_at_startup &&
599-
lineageGraph &&
600-
!impactAtStartupFired.current
601-
) {
602-
impactAtStartupFired.current = true;
603-
changeAnalysisModeRef.current = true;
604-
setChangeAnalysisMode(true);
605-
showColumnLevelLineage({
606-
change_analysis: true,
607-
no_upstream: true,
608-
});
609-
}
610-
}, [serverFlags, lineageGraph]);
611-
612611
const resetColumnLevelLineage = async (previous?: boolean) => {
613612
if (previous) {
614613
if (cllHistory.length === 0) {

0 commit comments

Comments
 (0)