@@ -1424,18 +1424,44 @@ const NetworkView: React.FC = () => {
14241424 setSelectedLink ( null )
14251425 } }
14261426 onSelectLog = { ( logEntry ) => {
1427- // Highlight the corresponding nodes in the graph
1428- const srcNode = nodes . find ( n =>
1427+ // First, find the source and destination nodes
1428+ const srcNode = nodes . find ( n =>
14291429 n . ips ?. includes ( logEntry . srcIP ) || n . ip === logEntry . srcIP || n . displayName === logEntry . srcDevice
14301430 )
1431- const dstNode = nodes . find ( n =>
1431+ const dstNode = nodes . find ( n =>
14321432 n . ips ?. includes ( logEntry . dstIP ) || n . ip === logEntry . dstIP || n . displayName === logEntry . dstDevice
14331433 )
1434-
1435- if ( srcNode ) {
1434+
1435+ // Try to find the corresponding link/edge between these nodes
1436+ if ( srcNode && dstNode ) {
1437+ const matchingLink = links . find ( link => {
1438+ const linkSourceId = typeof link . source === 'string' ? link . source : link . source . id
1439+ const linkTargetId = typeof link . target === 'string' ? link . target : link . target . id
1440+
1441+ // Check both directions (src->dst or dst->src)
1442+ return (
1443+ ( linkSourceId === srcNode . id && linkTargetId === dstNode . id ) ||
1444+ ( linkSourceId === dstNode . id && linkTargetId === srcNode . id )
1445+ )
1446+ } )
1447+
1448+ if ( matchingLink ) {
1449+ // Select the link/edge instead of a node
1450+ setSelectedLink ( matchingLink )
1451+ setSelectedNode ( null )
1452+ } else {
1453+ // If no link found, fall back to selecting the source node
1454+ setSelectedNode ( srcNode )
1455+ setSelectedLink ( null )
1456+ }
1457+ } else if ( srcNode ) {
1458+ // Only source node found
14361459 setSelectedNode ( srcNode )
1460+ setSelectedLink ( null )
14371461 } else if ( dstNode ) {
1462+ // Only destination node found
14381463 setSelectedNode ( dstNode )
1464+ setSelectedLink ( null )
14391465 }
14401466 } }
14411467 />
0 commit comments