Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(data-modeling): open lineage zoomed in on the current model (#123504)

Thiago Salvatorecefd941a15e1
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 953c56231b0d..05ccc3ec2fc7 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -7253,13 +7253,13 @@ snapshots:
products-data-catalog-metric-lineage--being-prepared--light:
hash: v1.k794b7964.1d9442bec79157ff586c1e1baefa06a6af93faf873f16f0b1d145aad2f94b330.AkvoCIqxZnaGvJ-bwA5Wxrs6uAmv4WJOugLfPcxxTvo
products-data-catalog-metric-lineage--graph--dark:
- hash: v1.k794b7964.71fb48afd8ce495d228c8bba2b25b0bc3894eae6b8b5a56b9744555e57fe858b.fe8Bfnxy0APkolSNvTzirsO6ShGEL6Nk9rRE8ASIXOM
+ hash: v1.k794b7964.51013454b87a130b110bc70f120eaf5a33ffe6df8417526e1335f199a3eeb7e2.mOH07Ta25FyqcfK_wO-AmP5pf_nfmckzujvkgf4KzOI
products-data-catalog-metric-lineage--graph--light:
- hash: v1.k794b7964.3c5961c5fdc49fbdf0d005c6430b96724d2b5e4795b90794759a79e398aeec44.FL9fwEsPu_LOsSQG0EnlCubZge2SARjABAy5G8jySdw
+ hash: v1.k794b7964.ef1ca2740a03cf952ae4f93882a20d78c643176aad74904e359ae3f608f7a4f9.pXp--BDgcGDpx67Dg8FfZ-p46ltHivB4bVIGtZGbI_c
products-data-catalog-metric-lineage--lineage-issue--dark:
- hash: v1.k794b7964.860d27733af3926c8bb4ebcbc5a687b149ab482f097e67af410450ecc90d21d9.n7Othr89yht04LnSFImmVTHCL4HFXOOY8uZMv8Tw8yw
+ hash: v1.k794b7964.656696196efedb0fd7093c25d810981b4ac7fcf3e44ebdc1e7c6f585e92a4791.Axds5QVAA2WSMtEov4q_cQFozEmzGVStnlS8R26Seig
products-data-catalog-metric-lineage--lineage-issue--light:
- hash: v1.k794b7964.6bbe1a96007edab5e52972199fd7ba58eb0931e882094e407e2021884ce7c389.vC05kGuAQq00QGnj-QKpGRfLXCETP75jDc00YDpn-Nw
+ hash: v1.k794b7964.cdbb822d7a19b6b84e41aa130a1b876153996391677919dce8e83d4ac81c00a0.A9HF3dyrwj1jB6fak5kLLkIprCiiROYA8-uGze0CWsE
products-data-catalog-metric-lineage--load-failed--dark:
hash: v1.k794b7964.dbaf9c756de48bf854da4200cd90a2a6f9eb1c9dd579c41313ea106fc952d014.EJZNZnR7SS9VqjxWGF2ewZNdCXKG7n3iCC_muZiwZng
products-data-catalog-metric-lineage--load-failed--light:
@@ -7289,9 +7289,9 @@ snapshots:
products-data-modeling-lineage-graph--canvas--light:
hash: v1.k794b7964.abbc2578ede8d828962ca36072f7f3192b2f595879d2df310d2b8304da15c9dc.8xbTQ8AJrMZhoqk4vMGuUxKW1IBiljeLpuubCXYKCkM
products-data-modeling-lineage-graph--dark-mode--dark:
- hash: v1.k794b7964.dbaa1992239d54c653a2132b63857ca77420a178b662c000fb93e7fded648a19.XVks3zJgtqjlm24-mHsgMx3boV8KNZNtXN5dcph4LWw
+ hash: v1.k794b7964.0bba727c1ca42bcb0a8790ab3bb1c109959965d16796e53db4069776e4fc39bc.vAO2RugmtkrEI-DUd14pzqt_rxrjKWNFKT6K47DG_a0
products-data-modeling-lineage-graph--dark-mode--light:
- hash: v1.k794b7964.bc8a6b5f4e177299e6b7ca346135a43ecbd3048405692bb1e75a8747f695c12d.Cg73TPpnrS5uZDxIKIWiV4BhszAzKFH_dSHExM_kkJM
+ hash: v1.k794b7964.facc72132f63867ab73701992d6db307415345b73a0c22f226bb44046a328535.slTtGwJP220QDkrOFSZ5qeYFZzTEWTqDGxYwS1bgumw
products-data-modeling-lineage-graph--draggable-nodes--dark:
hash: v1.k794b7964.07a5ee7f200d2b6b0f19c1c2295c0351810959cb4782ffdf368616f76bcea019.pM9SXd5270zePRVh34lXqpalGz5Wz_WDdO_5uEi232g
products-data-modeling-lineage-graph--draggable-nodes--light:
@@ -7301,9 +7301,9 @@ snapshots:
products-data-modeling-lineage-graph--empty-state--light:
hash: v1.k794b7964.5c6a3999ee44ecbce5db4d57dba01765e599c0c1874eab79eb80e71956d85fd7.AHbnj5yPLIkfMm6oHanSnhhQVEoBO0o5BcRYmK9DSgY
products-data-modeling-lineage-graph--full--dark:
- hash: v1.k794b7964.383e6a0dce4bc3b4c36013f3e7cbdb228f99b895be125717b107d01f4f74e119.LEg7PFAKIqwZEDD7ikj6SwaSOB7AJk1yQTz-UW4tynw
+ hash: v1.k794b7964.c0687eeeb97ce418ef48b89f1a639aeb0996b6cfcc170e0ca91e7791136d47a9.cDYR7Z4N1Ee0qlWdoMriZEp70Z8sE0hHWniBQ2S_ycA
products-data-modeling-lineage-graph--full--light:
- hash: v1.k794b7964.e7ba7f94326fd36a1000cc9e226bf688e1f0273aee518eb6aed0d8acba822fa9.QANk7QxBUcwb091vmyWrc_h5hbS3BF2pZ1UYgXbgMIM
+ hash: v1.k794b7964.31d0e40635d2dc6f8f417ebc5385ab28d68573f95da6eca9f44dc98ea3fb330b.AJfVSDKAq2TPHuiejnhVXMf8sGu_K6Bgdm9HNzRIMXo
products-data-modeling-lineage-graph--loading--dark:
hash: v1.k794b7964.0e48330c3af8b4788b41e6938d6957d7db3f2fac227302133d4482dde3f4e84f.1_ZYFp5H2cK3OTMZ8UrEjcgHn36LPpbKeEo0Zy1BRPk
products-data-modeling-lineage-graph--loading--light:
@@ -7529,9 +7529,9 @@ snapshots:
products-data-modeling-node-detail-scene--paginated-columns--light:
hash: v1.k794b7964.b31c476c47d1978ff552fddbfcb77ad263c0c8f22dcbcc44b60e70e4653ac060.JNntlPiJsIrZcnvJLXSh7lRKeUdb7PKpKtQR-SLODAg
products-data-modeling-node-detail-scene--post-hog-table--dark:
- hash: v1.k794b7964.4c6319ac95438cae6bdb4708f9e5df00ae41cdd530f5a6b627c874b539c370d2._qHdJB0ZxCNXW61GVlt-oRucyXgt-_H-hKbJ3pdoFik
+ hash: v1.k794b7964.7d56e07025e9880943429dc254d50ef80a3de15b68828f6c18195873bffe8b10.--fqtn3db5JGeZaXVPI-Ha331NTs7paA3SGE47kitNo
products-data-modeling-node-detail-scene--post-hog-table--light:
- hash: v1.k794b7964.c474db9b0735159cb759321ed76d03fac43af5ac42dde55863cef1b3c163e689.glgHI4jLj4ilKS3-W2jB8DXoKMNI9b8XQR53C7SpR6I
+ hash: v1.k794b7964.f6ada3c96b3c194bd4b4f98f16aadc1073e5e34a2a52876b19a4bd57739b56e4.6K8XdVUSHhMJ57PbPsI0aQzVAROz0dZilxs0nPoXvLw
products-data-modeling-node-detail-scene--suspended-with-run-history--dark:
hash: v1.k794b7964.8777021fae0861f86ccd00ee197d14fcacf12d0ae1ba8a8fe7b38f20591cbc41.r_GyHK2h2ozRGIYXoZ3N4CAlJMClpccnfeC5TEgiDOo
products-data-modeling-node-detail-scene--suspended-with-run-history--light:
@@ -7541,9 +7541,9 @@ snapshots:
products-data-modeling-node-detail-scene--view--light:
hash: v1.k794b7964.e743a0848352753df7ab1cbbc6538044d9de0a387f319617de876b210d4bce47.n2hUpnRhsVX_Bo6mGpZaqgJ9kw0dbt46jONG85BMNdU
products-data-modeling-node-detail-scene--warehouse-table--dark:
- hash: v1.k794b7964.1cd6cfb29f1510ee23c7bd3c54e8fd139f64e2c62796c85f2159f104562f56ab.8NkVqssgmL3BJGQBcZdXzZ_iGrYklaxHo_JUtIkinWQ
+ hash: v1.k794b7964.be58922f69d26ddd9efddb1b1e43a3d8de95472703f74b19a959fe48285a9200.JJ2OsKi210rpYYCKb7ekK_ILlI2s28umWtPmPbhctjI
products-data-modeling-node-detail-scene--warehouse-table--light:
- hash: v1.k794b7964.254f0dedf4549ed79a68ceffee8b9b282b640b7dde34ecff7bdc162d6491cf57.aMoarvIJfKXR52h0_DhZNgWn6qXQULONaWXR1h43G50
+ hash: v1.k794b7964.ab08f887631042e5e621e933edf8ce7293e18faeac2d27d9115eb89362e6386f.sIE7j7MMgZZENRhOIvsoK8ySfu9caxb7CU75zvzu4f4
products-data-modeling-views-list--actions--dark:
hash: v1.k794b7964.eceb80b180d692b6f616365ea7269d24bb6f084128cbfafc661cf6159dc281ec.FagEpfMfYMDwAJaH7ctNLBVSS-sThFgcTnQ8Ghwk8wI
products-data-modeling-views-list--actions--light:
diff --git a/products/data_modeling/frontend/lineage/LineageGraph.stories.tsx b/products/data_modeling/frontend/lineage/LineageGraph.stories.tsx
index 066f7c8aa620..f77841f13e58 100644
--- a/products/data_modeling/frontend/lineage/LineageGraph.stories.tsx
+++ b/products/data_modeling/frontend/lineage/LineageGraph.stories.tsx
@@ -197,6 +197,9 @@ export const Full: Story = {
render: () => (
<LineageGraph nodes={GRAPH_NODES} edges={GRAPH_EDGES} currentNodeId="4" variant="full" showControls />
),
+ play: async ({ canvasElement }) => {
+ await expectNodeCentered(canvasElement, '4', 'The current node must be centered when the lineage opens')
+ },
}
export const Canvas: Story = {
diff --git a/products/data_modeling/frontend/lineage/LineageGraph.tsx b/products/data_modeling/frontend/lineage/LineageGraph.tsx
index 498736b37457..825b71f9266c 100644
--- a/products/data_modeling/frontend/lineage/LineageGraph.tsx
+++ b/products/data_modeling/frontend/lineage/LineageGraph.tsx
@@ -34,6 +34,8 @@ export type { LineageVariant, LineageNodeState, LineageNodeCallbacks } from './L
const EMPTY_NODES: DataModelingNode[] = []
const EMPTY_EDGES: DataModelingEdge[] = []
+const FOCUSED_NODES_MAX_ZOOM = 2
+const CURRENT_NODE_MAX_ZOOM = 1
export interface LineageGraphProps {
nodes: DataModelingNode[]
@@ -76,8 +78,11 @@ function LineageGraphContent(props: LineageGraphProps): JSX.Element {
const nodesMeasured = useNodesMeasured()
const { isDarkModeOn } = useValues(themeLogic)
const [selectedNodeId, setSelectedNodeId] = useState<string | null>(null)
- const { currentNodeId, nodeState, nodeCallbacks, onNodeClick, nodeOpenUrl, focusNodeIds, searchFocusRequest } =
- props
+ const { currentNodeId, nodeState, nodeCallbacks, onNodeClick, nodeOpenUrl, searchFocusRequest } = props
+ const focusNodeIds = useMemo(
+ () => props.focusNodeIds ?? (currentNodeId ? new Set([currentNodeId]) : null),
+ [props.focusNodeIds, currentNodeId]
+ )
const { layout } = useValues(
lineageGraphLogic({
nodes: props.loading ? EMPTY_NODES : props.nodes,
@@ -218,7 +223,7 @@ function LineageGraphContent(props: LineageGraphProps): JSX.Element {
return
}
fittedLayout.current = layout
- if ((focusNodeIds !== null && focusNodeIds !== undefined) || searchFocusRequest) {
+ if (focusNodeIds || searchFocusRequest) {
return
}
void fitView({
@@ -256,14 +261,24 @@ function LineageGraphContent(props: LineageGraphProps): JSX.Element {
focusNodeIds.size > 0 ? decoratedNodes.filter((node) => focusNodeIds.has(node.id)) : decoratedNodes
if (nodes.length > 0) {
fittedFocus.current = { focusNodeIds, layout }
+ const focusedNodesMaxZoom = props.focusNodeIds ? FOCUSED_NODES_MAX_ZOOM : CURRENT_NODE_MAX_ZOOM
void fitView({
nodes,
padding: 0.2,
duration: 400,
- maxZoom: focusNodeIds.size > 0 ? 2 : undefined,
+ maxZoom: focusNodeIds.size > 0 ? focusedNodesMaxZoom : undefined,
})
}
- }, [decoratedNodes, fitView, viewportInitialized, nodesMeasured, focusNodeIds, layout, props.loading])
+ }, [
+ decoratedNodes,
+ fitView,
+ viewportInitialized,
+ nodesMeasured,
+ focusNodeIds,
+ layout,
+ props.focusNodeIds,
+ props.loading,
+ ])
useEffect(() => {
if (!searchFocusRequest) {
diff --git a/products/data_modeling/frontend/nodeDetail/NodeDetailLineage.tsx b/products/data_modeling/frontend/nodeDetail/NodeDetailLineage.tsx
index 758bdff35b4f..6f83698e096c 100644
--- a/products/data_modeling/frontend/nodeDetail/NodeDetailLineage.tsx
+++ b/products/data_modeling/frontend/nodeDetail/NodeDetailLineage.tsx
@@ -49,10 +49,6 @@ export function NodeDetailLineage({ id }: { id: string }): JSX.Element {
: node
)
}, [lineageGraph, effectiveLastRunAt, effectiveLastRunStatus])
- const focusNodeIds = useMemo(
- () => (lineageGraph?.currentNodeId ? new Set([lineageGraph.currentNodeId]) : null),
- [lineageGraph?.currentNodeId]
- )
if (!lineageGraphLoading && lineageGraphError) {
return (
@@ -86,7 +82,6 @@ export function NodeDetailLineage({ id }: { id: string }): JSX.Element {
nodes={nodes}
edges={lineageGraph?.edges ?? []}
currentNodeId={lineageGraph?.currentNodeId}
- focusNodeIds={focusNodeIds}
loading={lineageGraphLoading}
loadingCenter={lineageGraphLoading && node ? { name: node.name, type: node.type } : undefined}
variant="full"
@@ -131,7 +126,6 @@ export function NodeDetailLineage({ id }: { id: string }): JSX.Element {
nodes={nodes}
edges={lineageGraph?.edges ?? []}
currentNodeId={lineageGraph?.currentNodeId}
- focusNodeIds={focusNodeIds}
variant="full"
interactive
nodesDraggable