A modern platform for visual, flexible, and extensible graph-based investigations. For cybersecurity analysts and investigators.
feat: remove cosmograph
dextmorgnf7901b710cc6
diff --git a/flowsint-app/package.json b/flowsint-app/package.jsonindex c291e8c6..b6bfff9f 100644--- a/flowsint-app/package.json+++ b/flowsint-app/package.json@@ -15,7 +15,6 @@"preview": "vite preview"},"dependencies": {- "@cosmograph/react": "^1.4.2","@dagrejs/dagre": "^1.1.4","@hookform/resolvers": "^5.0.1","@lukemorales/query-key-factory": "^1.3.4",diff --git a/flowsint-app/src/components/graphs/graph.tsx b/flowsint-app/src/components/graphs/graph.tsxdeleted file mode 100644index 22c088a4..00000000--- a/flowsint-app/src/components/graphs/graph.tsx+++ /dev/null@@ -1,277 +0,0 @@-import { useCallback, useEffect, memo, lazy, Suspense, useRef, useState } from 'react'-import { Cosmograph, CosmographProvider, useCosmograph } from '@cosmograph/react'-import { useGraphStore } from '@/stores/graph-store'-import { useNodesDisplaySettings } from '@/stores/node-display-settings'-import Loader from '@/components/shared/loader'-import { useGraphControls } from '@/stores/graph-controls-store'-// @ts-ignore-import { type CosmosInputNode } from '@cosmograph/cosmos'-import { ResizablePanel, ResizablePanelGroup } from '../ui/resizable'-import EmptyState from './empty-state'--const CosmographTimeline = lazy(() =>- import('@cosmograph/react').then((module) => ({ default: module.CosmographTimeline }))-)-const useCosmographLoader = (nodes: any[], edges: any[]) => {- const [isCosmographReady, setIsCosmographReady] = useState(true)- const [loadingStage, setLoadingStage] = useState<'importing' | 'rendering' | 'ready'>('ready')- const cosmograph = useCosmograph()- const dataVersionRef = useRef(0)-- useEffect(() => {- dataVersionRef.current += 1- setIsCosmographReady(false)- setLoadingStage('importing')- if (!cosmograph?.cosmograph || nodes.length === 0) {- setIsCosmographReady(true)- setLoadingStage('ready')- return- }- if (edges.length === 0) {- setIsCosmographReady(true)- setLoadingStage('ready')- return- }- setLoadingStage('rendering')- }, [cosmograph?.cosmograph, nodes.length, edges.length])-- const handleSimulationStart = useCallback(() => {- if (edges.length > 0) {- setLoadingStage('rendering')- setIsCosmographReady(false)- }- }, [edges.length])-- const handleSimulationEnd = useCallback(() => {- setLoadingStage('ready')- setIsCosmographReady(true)- }, [])-- return { isCosmographReady, loadingStage, handleSimulationStart, handleSimulationEnd }-}--// Composant de loader personnalisé pour Cosmograph-const CosmographLoader = memo(({ stage }: { stage: string }) => (- <div className="absolute inset-0 bg-background/80 backdrop-blur-sm flex flex-col items-center justify-center z-50">- <Loader />- <div className="mt-4 text-sm text-muted-foreground">- {stage === 'importing' && 'Importing graph data...'}- {stage === 'simulating' && 'Running simulation...'}- {stage === 'rendering' && 'Rendering graph...'}- </div>- </div>-))-CosmographLoader.displayName = 'CosmographLoader'--const GRAPH_CONFIG = {- // simulationCenter: 0.2,- useQuadtree: true,- simulationDecay: 100,- simulationGravity: 0.25,- // simulationLinkSpring: 2,- simulationRepulsion: 2,- // simulationRepulsionTheta: 1.15,- linkStrength: 1,- simulationLinkDistance: 0.1,- nodeSizeScale: 0.2,- // simulationLinkDistance: 6,- backgroundColor: 'transparent' as const-}--const GraphContent = memo(() => {- const nodes = useGraphStore((s) => s.nodes)- const edges = useGraphStore((s) => s.edges)- // const currentNode = useGraphStore(s => s.currentNode)- const { isCosmographReady, loadingStage, handleSimulationStart, handleSimulationEnd } =- useCosmographLoader(nodes, edges)- const clearSelectedNodes = useGraphStore((s) => s.clearSelectedNodes)- const toggleNodeSelection = useGraphStore((s) => s.toggleNodeSelection)- const colors = useNodesDisplaySettings((s) => s.colors)- const getSize = useNodesDisplaySettings((s) => s.getSize)- const getIcon = useNodesDisplaySettings((s) => s.getIcon)- const setActions = useGraphControls((s) => s.setActions)-- const cosmograph = useCosmograph()- const actionsSetRef = useRef(false)- const instanceId = useRef('cosmograph-main') // Add instance-specific ID-- const handleLabelClick = useCallback(- (node: any, event: MouseEvent) => {- const multiSelect = event.ctrlKey || event.shiftKey || event.altKey- toggleNodeSelection(node, multiSelect)- // cosmograph?.cosmograph?.zoomToNode(node)- },- [toggleNodeSelection, cosmograph?.cosmograph]- )-- //@ts-ignore- const handleNodeClick = useCallback(- (clickedNode?: any, index?: number, nodePosition?: [number, number], event?: MouseEvent) => {- if (!clickedNode) {- clearSelectedNodes()- return- }- if (event) {- const multiSelect = event.ctrlKey || event.shiftKey || event.altKey- toggleNodeSelection(clickedNode, multiSelect)- // cosmograph?.cosmograph?.zoomToNode(clickedNode)- } else {- // cosmograph?.cosmograph?.zoomToNode(clickedNode)- }- },- [toggleNodeSelection, clearSelectedNodes, cosmograph?.cosmograph]- )-- // Fonctions de style stables- const nodeColorFunction = useCallback(- (n: CosmosInputNode & { data?: { type?: string } }) =>- colors[n.data?.type as keyof typeof colors] || '#000000',- [colors]- )-- const nodeSizeFunction = useCallback((n: any) => getSize(n.data?.type), [getSize])-- const nodeLabelFunction = useCallback((n: any) => `${getIcon(n.data.type)} ${n.label}`, [getIcon])-- // Fit view to all nodes on first render- //@ts-ignore- useEffect(() => {- if (cosmograph?.cosmograph && isCosmographReady) {- const timeoutId = setTimeout(() => {- cosmograph.cosmograph?.fitView(500)- }, 100)-- return () => clearTimeout(timeoutId)- }- }, [cosmograph?.cosmograph, isCosmographReady])-- useEffect(() => {- if (cosmograph?.cosmograph && !actionsSetRef.current) {- const actions = {- zoomIn: () => {- const current = cosmograph.cosmograph?.getZoomLevel()- const zoomLevel = current ? current * 1.5 : 1.5- cosmograph.cosmograph?.setZoomLevel(zoomLevel, 200)- },- zoomToFit: () => {- cosmograph.cosmograph?.fitView(200)- },- zoomOut: () => {- const current = cosmograph.cosmograph?.getZoomLevel()- const zoomLevel = current ? current * 0.5 : 0.5- cosmograph.cosmograph?.setZoomLevel(zoomLevel, 200)- }- }-- setActions(actions)- cosmograph.cosmograph.restart()- actionsSetRef.current = true- }-- // Cleanup: reset actions when component unmounts- return () => {- if (actionsSetRef.current) {- setActions({- zoomIn: () => {},- zoomOut: () => {},- zoomToFit: () => {}- })- actionsSetRef.current = false- }- }- }, [cosmograph?.cosmograph, setActions, instanceId.current])-- //@ts-ignore- // useEffect(() => {- // if (currentNode && cosmograph?.cosmograph && isCosmographReady) {- // const timeoutId = setTimeout(() => {- // cosmograph.cosmograph?.zoomToNode(currentNode)- // cosmograph.cosmograph?.focusNode(currentNode)- // }, 100)-- // return () => clearTimeout(timeoutId)- // }- // }, [currentNode, cosmograph?.cosmograph, isCosmographReady])-- return (- <div className="relative h-full w-full">- <Cosmograph- {...GRAPH_CONFIG}- onSimulationStart={handleSimulationStart}- onSimulationEnd={handleSimulationEnd}- onLabelClick={handleLabelClick}- onClick={handleNodeClick}- nodeSize={nodeSizeFunction}- nodeColor={nodeColorFunction}- nodeLabelColor={nodeColorFunction}- nodeLabelAccessor={nodeLabelFunction}- />- {!isCosmographReady && nodes.length > 0 && <CosmographLoader stage={loadingStage} />}- </div>- )-})-GraphContent.displayName = 'GraphContent'--const TimelinePanel = memo(() => {- const handleAnimationPlay = useCallback(() => {}, [])-- const dateAccessor = useCallback((d: any) => d.data.created_at, [])-- return (- <Suspense- fallback={- <div className="h-full flex items-center justify-center text-sm text-muted-foreground">- Loading timeline...- </div>- }- >- <CosmographTimeline- className="!bg-background !h-full"- // @ts-ignore- accessor={dateAccessor}- animationSpeed={20}- showAnimationControls- onAnimationPlay={handleAnimationPlay}- />- </Suspense>- )-})-TimelinePanel.displayName = 'TimelinePanel'--const GraphProvider = memo(- ({ nodes, edges, children }: { nodes: any[]; edges: any[]; children: React.ReactNode }) => {- return (- <CosmographProvider nodes={nodes} links={edges}>- {children}- </CosmographProvider>- )- }-)-GraphProvider.displayName = 'GraphProvider'--const Graph = memo(() => {- const nodes = useGraphStore((s) => s.filteredNodes)- const edges = useGraphStore((s) => s.filteredEdges)-- if (!nodes.length) {- return <EmptyState />- }- return (- <div className="relative h-full grow w-full flex flex-col bg-background min-h-0">- <GraphProvider nodes={nodes} edges={edges}>- <ResizablePanelGroup direction="vertical" className="flex-1 min-h-0 h-full flex flex-col">- <ResizablePanel defaultSize={75} minSize={30} className="flex-grow min-h-0 inset-shadow">- <GraphContent />- </ResizablePanel>- {/* <ResizableHandle /> */}- {/* <ResizablePanel defaultSize={25} minSize={10} className="flex-grow h-full min-h-0 inset-shadow">- <TimelinePanel />- </ResizablePanel> */}- </ResizablePanelGroup>- </GraphProvider>- </div>- )-})-Graph.displayName = 'Graph'--export default Graphdiff --git a/flowsint-app/src/components/graphs/index.tsx b/flowsint-app/src/components/graphs/index.tsxindex c112cbd5..4c3ba0f4 100644--- a/flowsint-app/src/components/graphs/index.tsx+++ b/flowsint-app/src/components/graphs/index.tsx@@ -19,10 +19,7 @@ import GraphMain from './graph-main'import Settings, { KeyboardShortcuts } from './settings'import { type GraphNode, type GraphEdge } from '@/types'import { MergeDialog } from './merge-nodes'-import { useGraphSettingsStore } from '@/stores/graph-settings-store'const RelationshipsTable = lazy(() => import('@/components/table/relationships-view'))-const Graph = lazy(() => import('./graph'))-// const Wall = lazy(() => import('./wall/wall'))// Separate component for the drag overlayconst DragOverlay = memo(({ isDragging }: { isDragging: boolean }) => (@@ -47,14 +44,11 @@ interface GraphPanelProps {const GraphPanel = ({ graphData, isLoading }: GraphPanelProps) => {const handleOpenFormModal = useGraphStore((s) => s.handleOpenFormModal)- const nodes = useGraphStore((s) => s.nodes)const view = useGraphControls((s) => s.view)- const settings = useGraphSettingsStore((s) => s.settings)const updateGraphData = useGraphStore((s) => s.updateGraphData)const setFilters = useGraphStore((s) => s.setFilters)const filters = useGraphStore((s) => s.filters)const { actionItems, isLoading: isLoadingActionItems } = useActionItems()- const NODE_COUNT_THRESHOLD = settings?.general?.graphViewerThreshold?.value || 1000const { sketch } = useLoaderData({from: '/_auth/dashboard/investigations/$investigationId/$type/$id'@@ -138,23 +132,12 @@ const GraphPanel = ({ graphData, isLoading }: GraphPanelProps) => {</div>}>- {nodes?.length > NODE_COUNT_THRESHOLD ? (- <>- {view === 'table' && <NodesTable />}- {['force', 'hierarchy'].includes(view) && <Graph />}- {view === 'map' && <MapPanel />}- {view === 'relationships' && <RelationshipsTable />}- </>- ) : (- <>- {/* {view === "hierarchy" && <Wall isLoading={false} isRefetching={false} />} */}- {/* {view === "force" && <GraphMain />} */}- {['force', 'hierarchy'].includes(view) && <GraphMain />}- {view === 'table' && <NodesTable />}- {view === 'map' && <MapPanel />}- {view === 'relationships' && <RelationshipsTable />}- </>- )}+ <>+ {['force', 'hierarchy'].includes(view) && <GraphMain />}+ {view === 'table' && <NodesTable />}+ {view === 'map' && <MapPanel />}+ {view === 'relationships' && <RelationshipsTable />}+ </></Suspense><DragOverlay isDragging={isDraggingOver} /><div className="absolute z-21 left-3 top-3 right-3">diff --git a/flowsint-app/src/stores/graph-settings-store.ts b/flowsint-app/src/stores/graph-settings-store.tsindex 883d9d94..06e8ff69 100644--- a/flowsint-app/src/stores/graph-settings-store.ts+++ b/flowsint-app/src/stores/graph-settings-store.ts@@ -10,23 +10,6 @@ const DEFAULT_SETTINGS = {value: true,description: 'Display Flo, your AI assistant.'},- // showMinimap: {- // type: "boolean",- // value: true,- // description: "Display the MiniMap on the graph panel."- // },- graphViewerThreshold: {- type: 'select',- value: 800,- options: [- { value: 100, label: '100' },- { value: 400, label: '400' },- { value: 800, label: '800' },- { value: 2000, label: '2000' }- ],- description:- 'Threshold to switch from general graph to less interactive but more performant) viewer.'- }},graph: {nodeSize: {