: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(data-warehouse): filter DAG canvas to search matches instead of dimming (#73926)
Jovan Sakovic88dfec9070f4
diff --git a/frontend/src/scenes/data-warehouse/scene/dataModelingLogic.ts b/frontend/src/scenes/data-warehouse/scene/dataModelingLogic.tsindex cdcacab74a84..ff1e2aaad532 100644--- a/frontend/src/scenes/data-warehouse/scene/dataModelingLogic.ts+++ b/frontend/src/scenes/data-warehouse/scene/dataModelingLogic.ts@@ -140,6 +140,7 @@ export interface dataModelingLogicValues {reactFlowWrapper: RefObject<HTMLDivElement> | nullrunningNodeIds: Set<string>savedViewport: Viewport | null+ searchMatchedNodeIds: Set<string> | nullsearchTerm: stringselectedDag: DataModelingDAG | nullselectedDagId: string | null@@ -371,14 +372,21 @@ export interface dataModelingLogicMeta {lastRunAt: string | nullstatus: DataModelingJobStatus}- >+ >,+ searchMatchedNodeIds: Set<string> | null) => Node[]- enrichedEdges: (edges: Edge[], hoveredNodeId: string | null) => Edge[]+ enrichedEdges: (edges: Edge[], hoveredNodeId: string | null, searchMatchedNodeIds: Set<string> | null) => Edge[]highlightedNodeIds: (nodes: Node[],edges: Edge[]) => (baseName: string, mode: 'all' | 'downstream' | 'upstream') => Set<string>parsedSearch: (debouncedSearchTerm: string) => ParsedSearch+ searchMatchedNodeIds: (+ nodes: Node[],+ debouncedSearchTerm: string,+ parsedSearch: ParsedSearch,+ highlightedNodeIds: (baseName: string, mode: 'all' | 'downstream' | 'upstream') => Set<string>+ ) => Set<string> | nullfilteredNodes: (dataModelingNodes: DataModelingNode[], searchTerm: string) => DataModelingNode[]selectedDag: (dags: DataModelingDAG[], selectedDagId: string | null) => DataModelingDAG | nullavailableDagIds: (filteredNodes: DataModelingNode[]) => string[]@@ -701,7 +709,13 @@ export const dataModelingLogic = kea<dataModelingLogicType>([{ resultEqualityCheck: equal },],enrichedNodes: [- (s) => [s.nodes, s.runningNodeIds, s.highlightedNodeType, s.latestJobMetadataByNodeId],+ (s) => [+ s.nodes,+ s.runningNodeIds,+ s.highlightedNodeType,+ s.latestJobMetadataByNodeId,+ s.searchMatchedNodeIds,+ ],(nodes: Node[],runningNodeIds: Set<string>,@@ -712,17 +726,23 @@ export const dataModelingLogic = kea<dataModelingLogicType>([lastRunAt: string | nullstatus: DataModelingJobStatus}- >+ >,+ searchMatchedNodeIds: Set<string> | null): Node[] => {- return nodes.map((node) => {+ const visibleNodes = searchMatchedNodeIds+ ? nodes.filter((node) => searchMatchedNodeIds.has(node.id))+ : nodes+ return visibleNodes.map((node) => {const isRunning = runningNodeIds.has(node.id)const isTypeHighlighted = highlightedNodeType !== null && highlightedNodeType === node.data.type+ const isSearchMatch = searchMatchedNodeIds !== nullconst metadata = latestJobMetadataByNodeId[node.id]const lastJobStatus = metadata?.status ?? node.data.lastJobStatusconst lastRunAt = metadata?.lastRunAt ?? node.data.lastRunAtif (node.data.isRunning === isRunning &&node.data.isTypeHighlighted === isTypeHighlighted &&+ node.data.isSearchMatch === isSearchMatch &&node.data.lastJobStatus === lastJobStatus &&node.data.lastRunAt === lastRunAt) {@@ -734,6 +754,7 @@ export const dataModelingLogic = kea<dataModelingLogicType>([...node.data,isRunning,isTypeHighlighted,+ isSearchMatch,lastJobStatus,lastRunAt,},@@ -746,12 +767,17 @@ export const dataModelingLogic = kea<dataModelingLogicType>([},],enrichedEdges: [- (s) => [s.edges, s.hoveredNodeId],- (edges: Edge[], hoveredNodeId: string | null): Edge[] => {+ (s) => [s.edges, s.hoveredNodeId, s.searchMatchedNodeIds],+ (edges: Edge[], hoveredNodeId: string | null, searchMatchedNodeIds: Set<string> | null): Edge[] => {+ const visibleEdges = searchMatchedNodeIds+ ? edges.filter(+ (edge) => searchMatchedNodeIds.has(edge.source) && searchMatchedNodeIds.has(edge.target)+ )+ : edgesif (!hoveredNodeId) {- return edges+ return visibleEdges}- return edges.map((edge) => {+ return visibleEdges.map((edge) => {const isConnected = edge.source === hoveredNodeId || edge.target === hoveredNodeIdif (!isConnected) {return edge@@ -808,6 +834,25 @@ export const dataModelingLogic = kea<dataModelingLogicType>([(s) => [s.debouncedSearchTerm],(debouncedSearchTerm: string): ParsedSearch => parseSearchTerm(debouncedSearchTerm),],+ /** Node ids to show on the graph canvas for the active search — null means no filter (show everything) */+ searchMatchedNodeIds: [+ (s) => [s.nodes, s.debouncedSearchTerm, s.parsedSearch, s.highlightedNodeIds],+ (+ nodes: Node[],+ debouncedSearchTerm: string,+ parsedSearch: ParsedSearch,+ highlightedNodeIds: (baseName: string, mode: 'upstream' | 'downstream' | 'all') => Set<string>+ ): Set<string> | null => {+ if (debouncedSearchTerm.length === 0) {+ return null+ }+ if (parsedSearch.mode !== 'search') {+ return highlightedNodeIds(parsedSearch.baseName, parsedSearch.mode)+ }+ const lowerBaseName = parsedSearch.baseName.toLowerCase()+ return new Set(nodes.filter((n) => n.data.name.toLowerCase().includes(lowerBaseName)).map((n) => n.id))+ },+ ],filteredNodes: [(s) => [s.dataModelingNodes, s.searchTerm],(dataModelingNodes: DataModelingNode[], searchTerm: string): DataModelingNode[] => {diff --git a/frontend/src/scenes/data-warehouse/scene/modeling/GraphView.tsx b/frontend/src/scenes/data-warehouse/scene/modeling/GraphView.tsxindex ca9bdd2e2ed4..6df5744d08da 100644--- a/frontend/src/scenes/data-warehouse/scene/modeling/GraphView.tsx+++ b/frontend/src/scenes/data-warehouse/scene/modeling/GraphView.tsx@@ -22,7 +22,7 @@ import { DataModelingNodeType } from '~/types'import { NODE_TYPE_TAG_SETTINGS } from 'products/data_modeling/frontend/lineage/nodeStyles'-import { dataModelingLogic, parseSearchTerm } from '../dataModelingLogic'+import { dataModelingLogic } from '../dataModelingLogic'import { REACT_FLOW_NODE_TYPES } from './Node'import { CreateModelNodeType, Edge, ElkDirection, Node } from './types'@@ -157,8 +157,7 @@ export function NodeTypePanel(): JSX.Element {function GraphViewContent(): JSX.Element {const { isDarkModeOn } = useValues(themeLogic)- const { enrichedNodes, enrichedEdges, highlightedNodeIds, debouncedSearchTerm, savedViewport } =- useValues(dataModelingLogic)+ const { enrichedNodes, enrichedEdges, debouncedSearchTerm, savedViewport } = useValues(dataModelingLogic)const { onEdgesChange, onNodesChange, setReactFlowInstance, setReactFlowWrapper } = useActions(dataModelingLogic)const reactFlowWrapper = useRef<HTMLDivElement>(null)@@ -173,26 +172,15 @@ function GraphViewContent(): JSX.Element {}, [setReactFlowWrapper])useEffect(() => {+ // enrichedNodes is already filtered down to the search matches, so fit to whatever remainsif (debouncedSearchTerm.length > 0 && enrichedNodes.length > 0) {- const { baseName, mode } = parseSearchTerm(debouncedSearchTerm)- let matchingNodes: Node[]- if (mode !== 'search') {- const highlightedIds = highlightedNodeIds(baseName, mode)- matchingNodes = enrichedNodes.filter((n: Node) => highlightedIds.has(n.id))- } else {- matchingNodes = enrichedNodes.filter((n: Node) =>- n.data.name.toLowerCase().includes(baseName.toLowerCase())- )- }- if (matchingNodes.length > 0) {- reactFlowInstance.fitView({- nodes: matchingNodes,- duration: 400,- maxZoom: 1,- })- }+ reactFlowInstance.fitView({+ nodes: enrichedNodes,+ duration: 400,+ maxZoom: 1,+ })}- }, [debouncedSearchTerm, enrichedNodes, reactFlowInstance, highlightedNodeIds])+ }, [debouncedSearchTerm, enrichedNodes, reactFlowInstance])return (<div ref={reactFlowWrapper} className="relative w-full border rounded-lg overflow-hidden h-[calc(100vh-17rem)]">diff --git a/frontend/src/scenes/data-warehouse/scene/modeling/Node.tsx b/frontend/src/scenes/data-warehouse/scene/modeling/Node.tsxindex e40740114561..6e98f4d18496 100644--- a/frontend/src/scenes/data-warehouse/scene/modeling/Node.tsx+++ b/frontend/src/scenes/data-warehouse/scene/modeling/Node.tsx@@ -11,7 +11,7 @@ import type { NodeData } from './types'const NodeComponent = React.memo(function NodeComponent(props: { id: string; data: NodeData }): JSX.Element {const { runNode, materializeNode, setHoveredNodeId } = useActions(dataModelingLogic)- const { layoutDirection, highlightedNodeIds, debouncedSearchTerm, parsedSearch } = useValues(dataModelingLogic)+ const { layoutDirection } = useValues(dataModelingLogic)const { id } = propsconst {@@ -22,22 +22,13 @@ const NodeComponent = React.memo(function NodeComponent(props: { id: string; datdownstreamCount,isRunning,isTypeHighlighted,+ isSearchMatch,lastJobStatus,lastRunAt,syncInterval,userTag,} = props.data- const isSearchMatch = ((): boolean | undefined => {- if (debouncedSearchTerm.length === 0) {- return undefined- }- if (parsedSearch.mode !== 'search') {- return highlightedNodeIds(parsedSearch.baseName, parsedSearch.mode).has(id)- }- return name.toLowerCase().includes(parsedSearch.baseName.toLowerCase())- })()-const handleNodeClick = useCallback((): void => {if (type === 'endpoint') {const versionMatch = name.match(/^(.+)_v(\d+)$/)@@ -69,8 +60,7 @@ const NodeComponent = React.memo(function NodeComponent(props: { id: string; datdirection: layoutDirection,state: {isRunning: isRunning ?? false,- isHighlighted: (isTypeHighlighted ?? false) || isSearchMatch === true,- isDimmed: isSearchMatch === false,+ isHighlighted: (isTypeHighlighted ?? false) || (isSearchMatch ?? false),},callbacks: {onClick: handleNodeClick,diff --git a/products/data_modeling/frontend/lineage/LineageNode.tsx b/products/data_modeling/frontend/lineage/LineageNode.tsxindex f00787780e8b..880239844799 100644--- a/products/data_modeling/frontend/lineage/LineageNode.tsx+++ b/products/data_modeling/frontend/lineage/LineageNode.tsx@@ -33,8 +33,6 @@ export type LineageNodeShape = Pick<export interface LineageNodeState {isCurrent?: booleanisRunning?: boolean- /** Dimmed when a search is active and this node is not a match */- isDimmed?: boolean/** Ringed when a search or type filter highlights this node */isHighlighted?: boolean}@@ -194,7 +192,6 @@ export function LineageNode({ data }: { data: LineageNodeData }): JSX.Element {)}// eslint-disable-next-line react/forbid-dom-propsstyle={{- opacity: state.isDimmed ? 0.5 : 1,borderColor: state.isCurrent ? color : undefined,}}onMouseEnter={handleMouseEnter}