A modern platform for visual, flexible, and extensible graph-based investigations. For cybersecurity analysts and investigators.
feat: zustand
dextmorgn0cbc81681e69
diff --git a/src/app/investigations/[investigation_id]/left.tsx b/src/app/investigations/[investigation_id]/left.tsxindex 17e547d6..62d0cd4b 100644--- a/src/app/investigations/[investigation_id]/left.tsx+++ b/src/app/investigations/[investigation_id]/left.tsx@@ -4,7 +4,7 @@ import { Skeleton } from '@/components/ui/skeleton';import { useIndividuals } from '@/lib/hooks/individuals/use-individuals';import { useInvestigationContext } from '@/components/contexts/investigation-provider';import { cn } from '@/lib/utils';-import { AtSignIcon, UserIcon } from 'lucide-react';+import { AtSignIcon, RotateCwIcon, UserIcon } from 'lucide-react';import { useEmails } from '@/lib/hooks/emails/use-emails';import {Accordion,@@ -12,24 +12,25 @@ import {AccordionItem,AccordionTrigger,} from "@/components/ui/accordion"+import { useFlowStore } from '@/components/contexts/use-flow-store';const Left = ({ investigation_id }: { investigation_id: string }) => {- const { individuals, isLoading, refetch } = useIndividuals(investigation_id)+ const { individuals, isLoading: isLoadingIndividuals, refetch: refetchIndividuals } = useIndividuals(investigation_id)const { emails, isLoading: isLoadingEmails, refetch: refetchEmails } = useEmails(investigation_id)- const { currentNode, setCurrentNode } = useInvestigationContext()+ const { currentNode, setCurrentNode } = useFlowStore()return (<div className='flex flex-col'>- <Accordion type="single" collapsible>- <AccordionItem value="item-1">- <AccordionTrigger className='mt-4 p-2 px-4 hover:bg-sidebar-accent text-sidebar-accent-foreground/60 hover:text-sidebar-accent-foreground text-sm rounded-none'>- Profiles</AccordionTrigger>+ <Accordion type="single" collapsible defaultValue='individuals'>+ <AccordionItem value="individuals">+ <AccordionTrigger className='p-2 px-4 hover:bg-sidebar-accent text-sidebar-accent-foreground/60 hover:text-sidebar-accent-foreground text-sm rounded-none'>+ Profiles {!isLoadingIndividuals && <>({individuals?.length})</>}</AccordionTrigger><AccordionContent>- {isLoading && <div className='flex flex-col gap-1'>- <Skeleton className='w-full h-[20px]' />- <Skeleton className='w-full h-[20px]' />- <Skeleton className='w-full h-[20px]' />+ {isLoadingIndividuals && <div className='flex flex-col gap-1'>+ <Skeleton className='w-full h-[20px] bg-foreground/10 rounded-none' />+ <Skeleton className='w-full h-[20px] bg-foreground/10 rounded-none' />+ <Skeleton className='w-full h-[20px] bg-foreground/10 rounded-none' /></div>}<ul>@@ -46,15 +47,15 @@ const Left = ({ investigation_id }: { investigation_id: string }) => {</AccordionContent></AccordionItem></Accordion>- <Accordion type="single" collapsible>- <AccordionItem value="item-1">+ <Accordion type="single" collapsible defaultValue='emails'>+ <AccordionItem value="emails"><AccordionTrigger className='p-2 px-4 hover:bg-sidebar-accent text-sidebar-accent-foreground/60 hover:text-sidebar-accent-foreground text-sm rounded-none'>- Emails</AccordionTrigger>+ Emails {!isLoadingEmails && <>({emails?.length})</>}</AccordionTrigger><AccordionContent>{isLoadingEmails && <div className='flex flex-col gap-1'>- <Skeleton className='w-full h-[20px]' />- <Skeleton className='w-full h-[20px]' />- <Skeleton className='w-full h-[20px]' />+ <Skeleton className='w-full h-[20px] bg-foreground/10 rounded-none' />+ <Skeleton className='w-full h-[20px] bg-foreground/10 rounded-none' />+ <Skeleton className='w-full h-[20px] bg-foreground/10 rounded-none' /></div>}<ul>@@ -71,7 +72,7 @@ const Left = ({ investigation_id }: { investigation_id: string }) => {</AccordionContent></AccordionItem></Accordion>- </div>+ </div >)}diff --git a/src/app/layout.tsx b/src/app/layout.tsxindex 0eab430c..2012734b 100644--- a/src/app/layout.tsx+++ b/src/app/layout.tsx@@ -42,7 +42,7 @@ export default function RootLayout({><Providers themeProps={{ attribute: "class", defaultTheme: "dark" }}><main>- <NextTopLoader />+ <NextTopLoader color="var(--primary)"/><TooltipProvider><ConfirmContextProvider>{children}diff --git a/src/components/contexts/use-flow-store.tsx b/src/components/contexts/use-flow-store.tsxnew file mode 100644index 00000000..8aa595c6--- /dev/null+++ b/src/components/contexts/use-flow-store.tsx@@ -0,0 +1,223 @@+import { create } from 'zustand';+import { addEdge, applyNodeChanges, applyEdgeChanges, getIncomers, getOutgoers } from '@xyflow/react';+import Dagre from '@dagrejs/dagre';+import { supabase } from '@/lib/supabase/client';+import {+ type Edge,+ type Node,+ type OnNodesChange,+ type OnEdgesChange,+} from '@xyflow/react';+import { getInvestigationData } from '@/lib/actions/investigations';++export type AppNode = Node;++export type AppState = {+ nodes: AppNode[];+ edges: Edge[];+ reloading: boolean;+ currentNode: string | null;+ onNodesChange: OnNodesChange<AppNode>;+ onEdgesChange: OnEdgesChange;+ setNodes: (nodes: AppNode[]) => void;+ setEdges: (edges: Edge[]) => void;+ highlightPath: (selectedNode: Node | null) => void;+ onLayout: (direct: string, fitView: () => void) => void,+ onConnect: (params: any, investigation_id?: string) => Promise<void>;+ onNodeClick: (_: React.MouseEvent, node: Node) => void;+ onPaneClick: (_: React.MouseEvent) => void,+ setCurrentNode: (nodeId: string | null) => void;+ updateNode: (nodeId: string, nodeData: Partial<Node>) => void;+ resetNodeStyles: () => void;+ refreshData: (Investigation_id: string, fitView: () => void) => void,+};+const getLayoutedElements = (nodes: any[], edges: any[], options: { direction: any; }) => {+ const g = new Dagre.graphlib.Graph().setDefaultEdgeLabel(() => ({}));+ g.setGraph({ rankdir: options.direction });++ edges.forEach((edge) => g.setEdge(edge.source, edge.target));+ nodes.forEach((node) =>+ g.setNode(node.id, {+ ...node,+ width: node.measured?.width ?? 0,+ height: node.measured?.height ?? 0,+ }),+ );+ Dagre.layout(g);+ return {+ nodes: nodes.map((node) => {+ const position = g.node(node.id);+ const x = position.x - (node.measured?.width ?? 0) / 2;+ const y = position.y - (node.measured?.height ?? 0) / 2;+ return { ...node, position: { x, y } };+ }),+ edges,+ };+};+const createStore = (initialNodes: AppNode[] = [], initialEdges: Edge[] = []) => {+ return create<AppState>((set, get) => ({+ nodes: initialNodes,+ edges: initialEdges,+ currentNode: null,+ reloading: false,+ onNodesChange: (changes) => {+ set({+ nodes: applyNodeChanges(changes, get().nodes),+ });+ },+ onEdgesChange: (changes) => {+ set({+ edges: applyEdgeChanges(changes, get().edges),+ });+ },+ setCurrentNode: (nodeId: string | null) => {+ set({ currentNode: nodeId });+ },+ onConnect: async (params: any, investigation_id?: string) => {+ if (!investigation_id) return;+ try {+ // Insertion dans Supabase+ await supabase+ .from("relationships")+ .upsert({+ individual_a: params.source,+ individual_b: params.target,+ investigation_id: investigation_id,+ relation_type: "relation"+ });+ set({+ edges: addEdge(+ { ...params, label: "relation", type: "custom" },+ get().edges+ )+ });+ } catch (error) {+ console.error('Error creating relationship:', error);+ }+ },+ updateNode: (nodeId: string, nodeData: Partial<Node>) => {+ set({+ nodes: get().nodes.map(node =>+ node.id === nodeId+ ? { ...node, ...nodeData }+ : node+ )+ });+ },+ setNodes: (nodes) => {+ set({ nodes });+ },+ setEdges: (edges) => {+ set({ edges });+ },+ resetNodeStyles: () => {+ set({+ nodes: get().nodes.map(node => ({+ ...node,+ disabled: false,+ draggable: true,+ data: {+ ...node.data,+ forceToolbarVisible: false+ },+ style: {+ ...node.style,+ opacity: 1,+ },+ })),+ });+ set({+ edges: get().edges.map(edge => ({+ ...edge,+ animated: false, // Désactive l'animation+ style: {+ ...edge.style,+ stroke: "#b1b1b750",+ opacity: 1,+ },+ })),+ });+ },+ onNodeClick: (_event: any, node: { id: string; }) => {+ set({ currentNode: node.id });+ get().resetNodeStyles()+ },+ onPaneClick: (_envent: any) => {+ set({ currentNode: null });+ get().resetNodeStyles()++ },+ onLayout: (direction = 'TB', fitView: () => void) => {+ const { nodes, edges } = getLayoutedElements(get().nodes, get().edges, { direction });+ set({ nodes });+ set({ edges })+ fitView()+ },+ highlightPath: (selectedNode: Node | null) => {+ if (!selectedNode) {+ set({+ nodes: get().nodes.map((node) => ({+ ...node,+ style: { ...node.style, opacity: 1 },+ })),+ edges: get().edges.map((edge) => ({+ ...edge,+ animated: false,+ style: { ...edge.style, stroke: "#b1b1b750", opacity: 1 },+ }))+ });+ return;+ }+ const nodes = get().nodes;+ const edges = get().edges;+ const allIncomers = getIncomers(selectedNode, nodes, edges);+ const allOutgoers = getOutgoers(selectedNode, nodes, edges);+ const incomerIds = new Set(allIncomers.map((node) => node.id));+ const outgoerIds = new Set(allOutgoers.map((node) => node.id));+ set({+ nodes: nodes.map((node) => {+ const highlight = node.id === selectedNode.id || incomerIds.has(node.id) || outgoerIds.has(node.id);+ return {+ ...node,+ disabled: !highlight,+ draggable: highlight,+ style: {+ ...node.style,+ opacity: highlight ? 1 : 0.25,+ },+ };+ }),+ edges: edges.map((edge) => {+ const animatedIn =+ incomerIds.has(edge.source) && (incomerIds.has(edge.target) || selectedNode.id === edge.target);+ const animatedOut =+ outgoerIds.has(edge.target) && (outgoerIds.has(edge.source) || selectedNode.id === edge.source);+ const animated = animatedIn || animatedOut;+ return {+ ...edge,+ animated,+ style: {+ ...edge.style,+ stroke: animated ? "var(--primary)" : "#b1b1b750",+ opacity: animated ? 1 : 0.25,+ },+ };+ })+ });+ },+ refreshData: async (investigation_id: string, fitView: () => void) => {+ set({ reloading: true });+ try {+ const { nodes: newNodes, edges: newEdges } = await getInvestigationData(investigation_id);+ set({ nodes: newNodes, edges: newEdges });+ get().onLayout('LR', fitView);+ } catch (error) {+ console.error('Error refreshing data:', error);+ set({ reloading: false });+ } finally {+ set({ reloading: false });+ }+ },+ }))+}+export const useFlowStore = createStore();diff --git a/src/components/investigations/graph.tsx b/src/components/investigations/graph.tsxindex 05c43999..49f8db7f 100644--- a/src/components/investigations/graph.tsx+++ b/src/components/investigations/graph.tsx@@ -1,34 +1,25 @@"use client"import Dagre from '@dagrejs/dagre';-import React, { useCallback, useEffect, useRef, useState } from 'react';+import React, { useCallback, useEffect, useState } from 'react';import {ReactFlow,ReactFlowProvider,Panel,- useNodesState,- useEdgesState,useReactFlow,Background,- addEdge,ColorMode,MiniMap,- Node,} from '@xyflow/react';import '@xyflow/react/dist/style.css';-import { supabase } from '@/lib/supabase/client';import IndividualNode from './nodes/individual';import PhoneNode from './nodes/phone';-// import CustomEdge from './custom-edge';import IpNode from './nodes/ip_address';import EmailNode from './nodes/email';-import SocialNode from './nodes/social'-import AddressNode from './nodes/physical_address'+import SocialNode from './nodes/social';+import AddressNode from './nodes/physical_address';import { AlignCenterHorizontal, AlignCenterVertical, MaximizeIcon, ZoomInIcon, ZoomOutIcon, RotateCwIcon } from 'lucide-react';import { useTheme } from 'next-themes';import NewActions from './new-actions';-import { getIncomers, getOutgoers } from "@xyflow/react";-import { EdgeBase } from '@xyflow/system';-import { useInvestigationContext } from '@/components/contexts/investigation-provider';import FloatingEdge from './floating-edge';import FloatingConnectionLine from './floating-connection';import { useParams } from 'next/navigation';@@ -38,254 +29,72 @@ import { TooltipTrigger } from '@radix-ui/react-tooltip';import { Card } from '@/components/ui/card';import { getInvestigationData } from '@/lib/actions/investigations';import { cn } from '@/lib/utils';+import { useInvestigationContext } from '@/components/contexts/investigation-provider';+import { useFlowStore } from '../contexts/use-flow-store';const edgeTypes = {"custom": FloatingEdge-}-const nodeTypes = { individual: IndividualNode, phone: PhoneNode, ip: IpNode, email: EmailNode, social: SocialNode, address: AddressNode };-const getLayoutedElements = (nodes: any[], edges: any[], options: { direction: any; }) => {- const g = new Dagre.graphlib.Graph().setDefaultEdgeLabel(() => ({}));- g.setGraph({ rankdir: options.direction });-- edges.forEach((edge) => g.setEdge(edge.source, edge.target));- nodes.forEach((node) =>- g.setNode(node.id, {- ...node,- width: node.measured?.width ?? 0,- height: node.measured?.height ?? 0,- }),- );-- Dagre.layout(g);-- return {- nodes: nodes.map((node) => {- const position = g.node(node.id);- // We are shifting the dagre node position (anchor=center center) to the top left- // so it matches the React Flow node anchor point (top left).- const x = position.x - (node.measured?.width ?? 0) / 2;- const y = position.y - (node.measured?.height ?? 0) / 2;-- return { ...node, position: { x, y } };- }),- edges,- };};-const LayoutFlow = ({ initialNodes, initialEdges, theme }: { initialNodes: any, initialEdges: any, theme: ColorMode }) => {- const { fitView, zoomIn, zoomOut, addNodes, getNodes, getEdges, setCenter, getNode, updateNode } = useReactFlow();- const [nodes, setNodes, onNodesChange] = useNodesState(initialNodes);- const [edges, setEdges, onEdgesChange] = useEdgesState(initialEdges);- const { investigation_id } = useParams()- const [loading, setLoading] = useState(false)- const { currentNode, setCurrentNode, settings } = useInvestigationContext()- const ref = useRef(null);-- // const edgeTypes = useMemo(() => ({- // 'custom': settings.floatingEdges ? FloatingEdge : CustomEdge,- // }), [settings.floatingEdges]);-- const getAllIncomers = useCallback((node: any, nodes: any[], edges: EdgeBase[], prevIncomers = []) => {- const incomers = getIncomers(node, nodes, edges);- const result = incomers.reduce(- (memo, incomer) => {- memo.push(incomer);- //@ts-ignore- if ((prevIncomers.findIndex(n => n.id == incomer.id) == -1)) {- prevIncomers.push(incomer as never);-- getAllIncomers(incomer, nodes, edges, prevIncomers).forEach((foundNode: { id: any; }) => {- memo.push(foundNode);- //@ts-ignore- if ((prevIncomers.findIndex(n => n.id == foundNode.id) == -1)) {- prevIncomers.push(incomer as never);-- }- });- }- return memo;- },- []- );- return result;- }, [])-- const getAllOutgoers = useCallback((node: any, nodes: any[], edges: EdgeBase[], prevOutgoers: any = []) => {- const outgoers = getOutgoers(node, nodes, edges);- return outgoers.reduce(- (memo, outgoer) => {- memo.push(outgoer);- if ((prevOutgoers.findIndex((n: any) => n.id == outgoer.id) == -1)) {- prevOutgoers.push(outgoer);- getAllOutgoers(outgoer, nodes, edges, prevOutgoers).forEach((foundNode: { id: any; }) => {- memo.push(foundNode);- if ((prevOutgoers.findIndex((n: any) => n.id == foundNode.id) == -1)) {- prevOutgoers.push(foundNode);- }- });- }- return memo;- },- []- )- }, [])-- const highlightPath = useCallback(- (selectedNode: Node | null) => {- if (!selectedNode) {- setNodes((nodes) =>- nodes.map((node) => ({- ...node,- style: { ...node.style, opacity: 1 },- })),- )- setEdges((edges) =>- edges.map((edge) => ({- ...edge,- animated: false,- style: { ...edge.style, stroke: "#b1b1b750", opacity: 1 },- })),- )- return- }- const nodes = getNodes()- const edges = getEdges()- const allIncomers = getIncomers(selectedNode, nodes, edges)- const allOutgoers = getOutgoers(selectedNode, nodes, edges)- const incomerIds = new Set(allIncomers.map((node) => node.id))- const outgoerIds = new Set(allOutgoers.map((node) => node.id))- setNodes((prevNodes) =>- prevNodes.map((node) => {- const highlight = node.id === selectedNode.id || incomerIds.has(node.id) || outgoerIds.has(node.id)- return {- ...node,- disabled: !highlight,- draggable: highlight,- style: {- ...node.style,- opacity: highlight ? 1 : 0.25,- },- }- }),- )- setEdges((prevEdges) =>- prevEdges.map((edge) => {- const animatedIn =- incomerIds.has(edge.source) && (incomerIds.has(edge.target) || selectedNode.id === edge.target)- const animatedOut =- outgoerIds.has(edge.target) && (outgoerIds.has(edge.source) || selectedNode.id === edge.source)- const animated = animatedIn || animatedOut- return {- ...edge,- animated,- style: {- ...edge.style,- stroke: animated ? "var(--primary)" : "#b1b1b750",- opacity: animated ? 1 : 0.25,- },- }- }),- )- },- [getNodes, getEdges, setNodes, setEdges],- )-- const resetNodeStyles = useCallback(() => {- setNodes((nodes) =>- nodes.map((node) => ({- ...node,- disabled: false,- draggable: true,- data: {- ...node.data,- forceToolbarVisible: false- },- style: {- ...node.style,- opacity: 1,- },- })),- )- setEdges((edges) =>- edges.map((edge) => ({- ...edge,- animated: false, // Désactive l'animation- style: {- ...edge.style,- stroke: "#b1b1b750",- opacity: 1,- },- })),- )- }, [setNodes, setEdges])+const nodeTypes = {+ individual: IndividualNode,+ phone: PhoneNode,+ ip: IpNode,+ email: EmailNode,+ social: SocialNode,+ address: AddressNode+};- const onLayout = useCallback(- (direction: any) => {- const layouted = getLayoutedElements(nodes, edges, { direction });- setNodes([...layouted.nodes]);- setEdges([...layouted.edges]);- window.requestAnimationFrame(() => {- fitView();- });- },- [nodes, edges],- );- const onConnect = useCallback(- async (params: any) => {- if (!investigation_id) return- await supabase.from("relationships")- .upsert({ individual_a: params.source, individual_b: params.target, investigation_id: investigation_id, relation_type: "relation" })- setEdges((els) => addEdge({ ...params, label: "relation", type: "custom" }, els))- },- [setEdges],- );+const LayoutFlow = ({ theme }: { theme: ColorMode }) => {+ const { fitView, zoomIn, zoomOut, addNodes, getNode, setCenter } = useReactFlow();+ const { investigation_id } = useParams();+ const { settings } = useInvestigationContext();- const onNodeClick = useCallback(- (_: React.MouseEvent, node: Node) => {- setCurrentNode(node.id)- },- [],- )+ const {+ nodes,+ edges,+ onNodesChange,+ onEdgesChange,+ onConnect,+ onLayout,+ onNodeClick,+ onPaneClick,+ currentNode,+ resetNodeStyles,+ refreshData,+ reloading+ } = useFlowStore();useEffect(() => {- resetNodeStyles()+ resetNodeStyles();if (currentNode) {- const internalNode = getNode(currentNode)- if (!internalNode) return- updateNode(internalNode.id, { ...internalNode, zIndex: 5000, data: { ...internalNode.data, forceToolbarVisible: true }, style: { ...internalNode.style, opacity: 1 } })- //@ts-ignore- setCenter(internalNode?.position.x + (internalNode?.measured?.width / 2), internalNode?.position.y + (internalNode?.measured?.height / 2) + 20, { duration: 1000, zoom: 1.5 })- highlightPath(internalNode);+ const internalNode = getNode(currentNode);+ if (!internalNode) return;+ useFlowStore.getState().updateNode(internalNode.id, {+ ...internalNode,+ zIndex: 5000,+ data: { ...internalNode.data, forceToolbarVisible: true },+ style: { ...internalNode.style, opacity: 1 }+ });+ const nodeWidth = internalNode.measured?.width ?? 0;+ const nodeHeight = internalNode.measured?.height ?? 0;+ setCenter(+ internalNode.position.x + (nodeWidth / 2),+ internalNode.position.y + (nodeHeight / 2) + 20,+ { duration: 1000, zoom: 1.5 }+ );+ useFlowStore.getState().highlightPath(internalNode);}- }, [currentNode, highlightPath, setCenter, resetNodeStyles]);-- const onPaneClick = useCallback(- () => {- setCurrentNode(null)- resetNodeStyles()- },- [resetNodeStyles],- )+ }, [currentNode, getNode, setCenter]);useEffect(() => {- onLayout('LR')- }, [initialNodes, initialEdges])-- const handleRefresh = useCallback(- async () => {- setLoading(true);- const { nodes: newNodes, edges: newEdges } = await getInvestigationData(investigation_id as string);- setNodes([...newNodes]);- setEdges([...newEdges]);- onLayout('LR');- setLoading(false);- }, []);+ onLayout('LR', fitView);+ }, []);return (<div className='h-[calc(100vh_-_48px)]'><ReactFlowcolorMode={theme}- ref={ref}nodes={nodes}edges={edges}onNodesChange={onNodesChange}@@ -295,24 +104,15 @@ const LayoutFlow = ({ initialNodes, initialEdges, theme }: { initialNodes: any,onPaneClick={onPaneClick}minZoom={0.1}connectionLineComponent={FloatingConnectionLine as any}- // edgesUpdatable={!isLocked}- // edgesFocusable={!isLocked}- // nodesDraggable={!isLocked}- // nodesConnectable={!isLocked}- // nodesFocusable={!isLocked}- // elementsSelectable={!isLocked}fitView- proOptions={{- hideAttribution: true- }}+ proOptions={{ hideAttribution: true }}nodeTypes={nodeTypes}- // @ts-ignoreedgeTypes={edgeTypes}><Panel position="top-left" className='flex items-center gap-1'><Tooltip><TooltipTrigger asChild>- <Button size="icon" variant="outline" onClick={() => onLayout('TB')}>+ <Button size="icon" variant="outline" onClick={() => onLayout('TB', fitView)}><AlignCenterVertical className='h-4 w-4' /></Button></TooltipTrigger>@@ -322,7 +122,7 @@ const LayoutFlow = ({ initialNodes, initialEdges, theme }: { initialNodes: any,</Tooltip><Tooltip><TooltipTrigger asChild>- <Button size="icon" variant="outline" onClick={() => onLayout('LR')}>+ <Button size="icon" variant="outline" onClick={() => onLayout('LR', fitView)}><AlignCenterHorizontal className='h-4 w-4' /></Button></TooltipTrigger>@@ -331,26 +131,29 @@ const LayoutFlow = ({ initialNodes, initialEdges, theme }: { initialNodes: any,</TooltipContent></Tooltip></Panel>+<Panel position="top-right" className='flex items-center gap-1'><div className='flex flex-col items-end gap-2'><div className='flex gap-1 items-center'>- <Button size="icon" disabled={loading} variant="outline" onClick={handleRefresh}>- <RotateCwIcon className={cn('h-4 w-4', loading && 'animate-spin')} />+ <Button size="icon" disabled={reloading} variant="outline" onClick={() => refreshData(investigation_id as string, fitView)}>+ <RotateCwIcon className={cn('h-4 w-4', reloading && 'animate-spin')} /></Button><NewActions addNodes={addNodes} /></div>- {currentNode &&+ {currentNode && (<Card>- {/* @ts-ignore */}- {getNode(currentNode)?.data?.label}- </Card>}+ <>+ {getNode(currentNode)?.data?.label}+ </>+ </Card>+ )}</div></Panel>+<Panel position="bottom-left" className='flex flex-col items-center gap-1'><Tooltip><TooltipTrigger asChild>- {/* @ts-ignore */}- <Button size="icon" variant="outline" onClick={fitView}>+ <Button size="icon" variant="outline" onClick={() => fitView()}><MaximizeIcon className='h-4 w-4' /></Button></TooltipTrigger>@@ -360,8 +163,7 @@ const LayoutFlow = ({ initialNodes, initialEdges, theme }: { initialNodes: any,</Tooltip><Tooltip><TooltipTrigger asChild>- {/* @ts-ignore */}- <Button size="icon" variant="outline" onClick={zoomIn}>+ <Button size="icon" variant="outline" onClick={() => zoomIn()}><ZoomInIcon className='h-4 w-4' /></Button></TooltipTrigger>@@ -371,8 +173,7 @@ const LayoutFlow = ({ initialNodes, initialEdges, theme }: { initialNodes: any,</Tooltip><Tooltip><TooltipTrigger asChild>- {/* @ts-ignore */}- <Button size="icon" variant="outline" onClick={zoomOut}>+ <Button size="icon" variant="outline" onClick={() => zoomOut()}><ZoomOutIcon className='h-4 w-4' /></Button></TooltipTrigger>@@ -381,6 +182,7 @@ const LayoutFlow = ({ initialNodes, initialEdges, theme }: { initialNodes: any,</TooltipContent></Tooltip></Panel>+<Background />{settings.showMiniMap && <MiniMap pannable />}</ReactFlow>@@ -388,20 +190,29 @@ const LayoutFlow = ({ initialNodes, initialEdges, theme }: { initialNodes: any,);};-export default function (props: any) {- const [mounted, setMounted] = useState(false)- const { resolvedTheme } = useTheme()+export default function Graph({ initialNodes, initialEdges }: { initialNodes: any, initialEdges: any }) {+ const [mounted, setMounted] = useState(false);+ const { resolvedTheme } = useTheme();+ useEffect(() => {+ setMounted(true);+ }, []);+useEffect(() => {- setMounted(true)- }, [])+ useFlowStore.setState({ nodes: initialNodes, edges: initialEdges });+ setMounted(true);+ }, [initialNodes, initialEdges]);if (!mounted) {- return <div className='h-[calc(100vh_-_48px)] w-full flex items-center justify-center'>Loading...- </div>+ return (+ <div className='h-[calc(100vh_-_48px)] w-full flex items-center justify-center'>+ Loading...+ </div>+ );}+return (<ReactFlowProvider>- <LayoutFlow {...props} theme={resolvedTheme} />+ <LayoutFlow theme={resolvedTheme as ColorMode} /></ReactFlowProvider>);}\ No newline at end of filediff --git a/src/components/investigations/nodes/email.tsx b/src/components/investigations/nodes/email.tsxindex 6657a643..ab6a537a 100644--- a/src/components/investigations/nodes/email.tsx+++ b/src/components/investigations/nodes/email.tsx@@ -20,10 +20,12 @@ import {ContextMenuTrigger,} from "@/components/ui/context-menu"import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip"+import { useFlowStore } from "@/components/contexts/use-flow-store"function EmailNode({ data }: any) {const { handleDeleteNode, loading } = useNodeContext()- const { settings, currentNode } = useInvestigationContext()+ const { settings } = useInvestigationContext()+ const { currentNode } = useFlowStore()const { handleOpenSearchModal } = useSearchContext()const showContent = useStore(zoomSelector)diff --git a/src/components/investigations/nodes/individual.tsx b/src/components/investigations/nodes/individual.tsxindex dc943263..ff5e4b50 100644--- a/src/components/investigations/nodes/individual.tsx+++ b/src/components/investigations/nodes/individual.tsx@@ -39,9 +39,11 @@ import {User,Zap,} from "lucide-react"+import { useFlowStore } from "@/components/contexts/use-flow-store"function Custom(props: any) {- const { settings, handleOpenIndividualModal, currentNode } = useInvestigationContext()+ const { settings, handleOpenIndividualModal } = useInvestigationContext()+ const { currentNode } = useFlowStore()const { setOpenAddNodeModal, handleDuplicateNode, handleDeleteNode, loading } = useNodeContext()const { handleOpenSearchModal } = useSearchContext()const { handleOpenChat } = useChatContext()diff --git a/src/components/investigations/nodes/ip_address.tsx b/src/components/investigations/nodes/ip_address.tsxindex 5e29f7a4..c63273f6 100644--- a/src/components/investigations/nodes/ip_address.tsx+++ b/src/components/investigations/nodes/ip_address.tsx@@ -20,10 +20,12 @@ import {ContextMenuTrigger,} from "@/components/ui/context-menu"import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip"+import { useFlowStore } from "@/components/contexts/use-flow-store"function IpNode({ data }: any) {const { handleDeleteNode, loading } = useNodeContext()- const { settings, currentNode } = useInvestigationContext()+ const { settings } = useInvestigationContext()+ const { currentNode } = useFlowStore()const { handleOpenSearchModal } = useSearchContext()const showContent = useStore(zoomSelector)diff --git a/src/components/investigations/nodes/phone.tsx b/src/components/investigations/nodes/phone.tsxindex 71cd40b6..7f3770fe 100644--- a/src/components/investigations/nodes/phone.tsx+++ b/src/components/investigations/nodes/phone.tsx@@ -20,10 +20,12 @@ import {ContextMenuTrigger,} from "@/components/ui/context-menu"import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip"+import { useFlowStore } from "@/components/contexts/use-flow-store"function PhoneNode({ data }: any) {const { handleDeleteNode, loading } = useNodeContext()- const { settings, currentNode } = useInvestigationContext()+ const { settings } = useInvestigationContext()+ const { currentNode } = useFlowStore()const { handleOpenSearchModal } = useSearchContext()const showContent = useStore(zoomSelector)diff --git a/src/components/investigations/nodes/physical_address.tsx b/src/components/investigations/nodes/physical_address.tsxindex 4d4bd49d..08e95164 100644--- a/src/components/investigations/nodes/physical_address.tsx+++ b/src/components/investigations/nodes/physical_address.tsx@@ -20,10 +20,12 @@ import {ContextMenuTrigger,} from "@/components/ui/context-menu"import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip"+import { useFlowStore } from "@/components/contexts/use-flow-store"function AddressNode({ data }: any) {const { handleDeleteNode, loading } = useNodeContext()- const { settings, currentNode } = useInvestigationContext()+ const { settings } = useInvestigationContext()+ const { currentNode } = useFlowStore()const { handleOpenSearchModal } = useSearchContext()const showContent = useStore(zoomSelector)diff --git a/src/components/investigations/nodes/social.tsx b/src/components/investigations/nodes/social.tsxindex 2c605a4a..227f08f0 100644--- a/src/components/investigations/nodes/social.tsx+++ b/src/components/investigations/nodes/social.tsx@@ -21,10 +21,12 @@ import {} from "@/components/ui/context-menu"import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip"import { usePlatformIcons } from "@/lib/hooks/use-platform-icons"+import { useFlowStore } from "@/components/contexts/use-flow-store"function SocialNode({ data }: any) {const { handleDeleteNode, loading } = useNodeContext()- const { settings, currentNode } = useInvestigationContext()+ const { settings } = useInvestigationContext()+ const { currentNode } = useFlowStore()const platformsIcons = usePlatformIcons()const { handleOpenSearchModal } = useSearchContext()const showContent = useStore(zoomSelector)