A modern platform for visual, flexible, and extensible graph-based investigations. For cybersecurity analysts and investigators.
refctor(app): use of hasmaps for nodes and edges + use only ids for current types
dextmorgn9d61be4d04b7
diff --git a/flowsint-app/src/components/layout/root.layout.tsx b/flowsint-app/src/components/layout/root.layout.tsxindex 6aa636d1..64279898 100644--- a/flowsint-app/src/components/layout/root.layout.tsx+++ b/flowsint-app/src/components/layout/root.layout.tsx@@ -28,8 +28,8 @@ export default function RootLayout({ children }: LayoutProps) {const closePanel = useLayoutStore((s) => s.closePanel)const openPanel = useLayoutStore((s) => s.openPanel)const closeDetails = useLayoutStore((s) => s.closeDetails)- const currentNode = useGraphStore((s) => s.currentNode)- const currentEdge = useGraphStore((s) => s.currentEdge)+ const currentNode = useGraphStore((s) => s.getCurrentNode())+ const currentEdge = useGraphStore((s) => s.getCurrentEdge())const { id, type } = useParams({ strict: false })// Set up keyboard shortcut for chat panel@@ -65,7 +65,7 @@ export default function RootLayout({ children }: LayoutProps) {minSize={16}maxSize={40}onCollapse={closeDetails}- onExpand={() => {}} // No auto-open here+ onExpand={() => { }} // No auto-open herecollapsible={true}collapsedSize={2}>@@ -90,7 +90,7 @@ export default function RootLayout({ children }: LayoutProps) {minSize={16}maxSize={40}onCollapse={closeDetails}- onExpand={() => {}} // No auto-open here+ onExpand={() => { }} // No auto-open herecollapsible={true}collapsedSize={2}>@@ -98,19 +98,19 @@ export default function RootLayout({ children }: LayoutProps) {// Both node and edge: show both in a vertical split<ResizablePanelGroup direction="vertical" className="h-full"><ResizablePanel defaultSize={70} minSize={30}>- <DetailsPanel node={currentNode} />+ <DetailsPanel /></ResizablePanel><ResizableHandle withHandle /><ResizablePanel defaultSize={30} minSize={20}>- <EdgeDetailsPanel edge={currentEdge} />+ <EdgeDetailsPanel /></ResizablePanel></ResizablePanelGroup>) : hasNode ? (// Only node- <DetailsPanel node={currentNode} />+ <DetailsPanel />) : (// Only edge- <EdgeDetailsPanel edge={currentEdge} />+ <EdgeDetailsPanel />)}</ResizablePanel></>diff --git a/flowsint-app/src/components/sketches/add-item-dialog.tsx b/flowsint-app/src/components/sketches/add-item-dialog.tsxindex c92a21c2..21d896bf 100644--- a/flowsint-app/src/components/sketches/add-item-dialog.tsx+++ b/flowsint-app/src/components/sketches/add-item-dialog.tsx@@ -23,7 +23,7 @@ import { useGraphControls } from '@/stores/graph-controls-store'export default function AddItemDialog() {const handleOpenFormModal = useGraphStore((state) => state.handleOpenFormModal)const currentNodeType = useGraphStore((state) => state.currentNodeType)- const setCurrentNode = useGraphStore((state) => state.setCurrentNode)+ const setCurrentNodeId = useGraphStore((state) => state.setCurrentNodeId)const relatedNodeToAdd = useGraphStore((state) => state.relatedNodeToAdd)const setRelatedNodeToAdd = useGraphStore((state) => state.setRelatedNodeToAdd)const openMainDialog = useGraphStore((state) => state.openMainDialog)@@ -128,8 +128,8 @@ export default function AddItemDialog() {}}// Set current node optimistically- if (setCurrentNode) {- setCurrentNode(nodeWithTempId)+ if (setCurrentNodeId) {+ setCurrentNodeId(nodeWithTempId.id)}setActiveTab('entities')// Close dialogs immediately for better UXdiff --git a/flowsint-app/src/components/sketches/details-panel/details-panel.tsx b/flowsint-app/src/components/sketches/details-panel/details-panel.tsxindex b22d3c03..6eeb96ef 100644--- a/flowsint-app/src/components/sketches/details-panel/details-panel.tsx+++ b/flowsint-app/src/components/sketches/details-panel/details-panel.tsx@@ -10,22 +10,22 @@ import { useParams } from '@tanstack/react-router'import NeighborsGraph from './neighbors'import Relationships from './relationships'import { ResizablePanelGroup, ResizablePanel, ResizableHandle } from '../../ui/resizable'-import { GraphNode } from '@/types'import { useGraphStore } from '@/stores/graph-store'import { Badge } from '@/components/ui/badge'import DOMPurify from 'dompurify'import { useIcon } from '@/hooks/use-icon'-const DetailsPanel = memo(({ node }: { node: GraphNode | null }) => {+const DetailsPanel = memo(() => {const { id: sketchId } = useParams({ strict: false })- const nodes = useGraphStore((s) => s.nodes)+ const nodesLength = useGraphStore((s) => s.nodesLength)+ const node = useGraphStore((s) => s.getCurrentNode())const NodeIcon = useIcon(node?.data?.type || 'default')- const setCurrentNode = useGraphStore((s) => s.setCurrentNode)- node = nodes.find((n) => n.id === node?.id) || null+ const setCurrentNodeId = useGraphStore((s) => s.setCurrentNodeId)const handleClose = useCallback(() => {- setCurrentNode(null)+ setCurrentNodeId(null)}, [])+if (!node) {return (<div className="flex flex-col items-center justify-center h-full text-center p-8">@@ -73,7 +73,7 @@ const DetailsPanel = memo(({ node }: { node: GraphNode | null }) => {</TooltipContent></Tooltip></TooltipProvider>- <NodeActions node={node} />+ {node && <NodeActions node={node} />}</div></div><div className="px-4 pt-4 pb-4 border-b">@@ -116,7 +116,7 @@ const DetailsPanel = memo(({ node }: { node: GraphNode | null }) => {<ResizablePanel defaultSize={40} minSize={25}><div className="h-full w-full p-3"><NeighborsGraph- nodeLength={nodes.length}+ nodeLength={nodesLength}sketchId={sketchId as string}nodeId={node.id}/>@@ -125,7 +125,7 @@ const DetailsPanel = memo(({ node }: { node: GraphNode | null }) => {<ResizableHandle /><ResizablePanel defaultSize={30} minSize={20}><Relationships- nodeLength={nodes.length}+ nodeLength={nodesLength}sketchId={sketchId as string}nodeId={node.id}/>diff --git a/flowsint-app/src/components/sketches/details-panel/edge-details-panel.tsx b/flowsint-app/src/components/sketches/details-panel/edge-details-panel.tsxindex 6fa7169d..4f33382c 100644--- a/flowsint-app/src/components/sketches/details-panel/edge-details-panel.tsx+++ b/flowsint-app/src/components/sketches/details-panel/edge-details-panel.tsx@@ -8,25 +8,21 @@ import { useIcon } from '@/hooks/use-icon'import { useConfirm } from '@/components/use-confirm-dialog'import { sketchService } from '@/api/sketch-service'import { CopyButton } from '@/components/copy'-import { GraphEdge } from '@/types'import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip'import { cn } from '@/lib/utils'import { Badge } from '@/components/ui/badge'import { Input } from '@/components/ui/input'-const EdgeDetailsPanel = memo(({ edge }: { edge: GraphEdge | null }) => {+const EdgeDetailsPanel = memo(() => {const { id: sketchId } = useParams({ strict: false })- const edges = useGraphStore((s) => s.edges)const nodes = useGraphStore((s) => s.nodes)- const setCurrentNode = useGraphStore((s) => s.setCurrentNode)- const setCurrentEdge = useGraphStore((s) => s.setCurrentEdge)+ const setCurrentNodeId = useGraphStore((s) => s.setCurrentNodeId)+ const setCurrentEdgeId = useGraphStore((s) => s.setCurrentEdgeId)const removeEdges = useGraphStore((s) => s.removeEdges)const updateEdge = useGraphStore((s) => s.updateEdge)const { confirm } = useConfirm()const labelRef = useRef<HTMLInputElement>(null)-- // Get fresh edge data from store- edge = edges.find((e) => e.id === edge?.id) || null+ const edge = useGraphStore((s) => s.getCurrentEdge())// Find source and target nodesconst sourceNode = edge ? nodes.find((n) => n.id === edge.source) : null@@ -86,7 +82,7 @@ const EdgeDetailsPanel = memo(({ edge }: { edge: GraphEdge | null }) => {}// Close panel- setCurrentEdge(null)+ setCurrentEdgeId(null)// Optimistic delete + API call with toasttoast.promise(@@ -103,19 +99,19 @@ const EdgeDetailsPanel = memo(({ edge }: { edge: GraphEdge | null }) => {error: 'Failed to delete relationship.'})- }, [edge, sketchId, confirm, removeEdges, setCurrentEdge])+ }, [edge, sketchId, confirm, removeEdges, setCurrentEdgeId])const handleJumpToSource = useCallback(() => {if (sourceNode) {- setCurrentNode(sourceNode)+ setCurrentNodeId(sourceNode.id)}- }, [sourceNode, setCurrentNode])+ }, [sourceNode, setCurrentNodeId])const handleJumpToTarget = useCallback(() => {if (targetNode) {- setCurrentNode(targetNode)+ setCurrentNodeId(targetNode.id)}- }, [targetNode, setCurrentNode])+ }, [targetNode, setCurrentNodeId])if (!edge) {return (diff --git a/flowsint-app/src/components/sketches/details-panel/node-editor-modal.tsx b/flowsint-app/src/components/sketches/details-panel/node-editor-modal.tsxindex d37c16d2..22937a92 100644--- a/flowsint-app/src/components/sketches/details-panel/node-editor-modal.tsx+++ b/flowsint-app/src/components/sketches/details-panel/node-editor-modal.tsx@@ -5,7 +5,7 @@ import { Input } from '@/components/ui/input'import { Label } from '@/components/ui/label'import { Textarea } from '@/components/ui/textarea'import { Badge } from '@/components/ui/badge'-import { Edit3, Save, X, Hash, Type, FileText, Check, Loader2 } from 'lucide-react'+import { Edit3, Save, X, Type, FileText, Check, Loader2 } from 'lucide-react'import type { NodeData } from '@/types'import { useGraphStore } from '@/stores/graph-store'import { MapFromAddress } from '../../map/map'@@ -18,11 +18,10 @@ import { useMutation, useQueryClient } from '@tanstack/react-query'import { queryKeys } from '@/api/query-keys'export const NodeEditorModal: React.FC = () => {- const currentNode = useGraphStore((state) => state.currentNode)+ const currentNode = useGraphStore((state) => state.getCurrentNode())const openNodeEditorModal = useGraphStore((state) => state.openNodeEditorModal)const setOpenNodeEditorModal = useGraphStore((state) => state.setOpenNodeEditorModal)const updateNode = useGraphStore((state) => state.updateNode)- const setCurrentNode = useGraphStore((state) => state.setCurrentNode)const { id: sketchId } = useParams({ strict: false })const IconComponent = useIcon(currentNode?.data.type as string,@@ -58,16 +57,8 @@ export const NodeEditorModal: React.FC = () => {},onSuccess: (result, variables) => {if (result.status === 'node updated' && currentNode) {- // Update the local store+ // Update the local store (this also updates the hashmap)updateNode(currentNode.id, formData)- setCurrentNode({- ...currentNode,- data: {- ...currentNode.data,- ...formData- }- })-// Invalidate related queriesif (sketchId) {queryClient.invalidateQueries({diff --git a/flowsint-app/src/components/sketches/details-panel/relationships.tsx b/flowsint-app/src/components/sketches/details-panel/relationships.tsxindex 31d3e1ce..73f83158 100644--- a/flowsint-app/src/components/sketches/details-panel/relationships.tsx+++ b/flowsint-app/src/components/sketches/details-panel/relationships.tsx@@ -76,8 +76,7 @@ const VirtualizedList = memo(({ relationships }: { relationships: Relation[] })firstItem: virtualItems[0],parentRefCurrent: parentRef.current})- const totalSize- = virtualizer.getTotalSize()+ const totalSize = virtualizer.getTotalSize()return (<div ref={parentRef} className="h-full py-1.5 overflow-auto">@@ -127,16 +126,15 @@ const VirtualizedList = memo(({ relationships }: { relationships: Relation[] })</div></div>)-}-)+})export default Relationshipsconst RelationshipItem = memo(({ node }: { node: GraphNode }) => {- const setCurrentNode = useGraphStore((s) => s.setCurrentNode)+ const setCurrentNodeId = useGraphStore((s) => s.setCurrentNodeId)const handleClick = useCallback(() => {- setCurrentNode(node)- }, [setCurrentNode, node])+ setCurrentNodeId(node.id)+ }, [setCurrentNodeId, node.id])return (<buttonclassName="w-full h-full text-left hover:underline cursor-pointer flex items-center"diff --git a/flowsint-app/src/components/sketches/graph/actions/node-actions.tsx b/flowsint-app/src/components/sketches/graph/actions/node-actions.tsxindex 019f5b0f..61c5030a 100644--- a/flowsint-app/src/components/sketches/graph/actions/node-actions.tsx+++ b/flowsint-app/src/components/sketches/graph/actions/node-actions.tsx@@ -20,7 +20,7 @@ const NodeActions = memo(const removeNodes = useGraphStore((s) => s.removeNodes)const toggleNodeSelection = useGraphStore((s) => s.toggleNodeSelection)const openChat = useLayoutStore((s) => s.openChat)- const setCurrentNode = useGraphStore((s) => s.setCurrentNode)+ const setCurrentNodeId = useGraphStore((s) => s.setCurrentNodeId)const setOpenNodeEditorModal = useGraphStore((s) => s.setOpenNodeEditorModal)const settings = useGraphSettingsStore((s) => s.settings)@@ -46,12 +46,11 @@ const NodeActions = memo(const handleEditNode = useCallback((e: React.MouseEvent) => {e.stopPropagation()- const typedNode = node as GraphNode- setCurrentNode(typedNode)+ setCurrentNodeId(node.id)setOpenNodeEditorModal(true)setMenu?.(null)},- [node, setCurrentNode, setOpenNodeEditorModal]+ [node, setCurrentNodeId, setOpenNodeEditorModal])// Delete node@@ -96,7 +95,7 @@ const NodeActions = memo(<p>Add relation</p></TooltipContent></Tooltip>- {Boolean(settings?.general?.showFlow?.value) &&+ {Boolean(settings?.general?.showFlow?.value) && (<Tooltip><TooltipTrigger asChild><div>@@ -113,7 +112,8 @@ const NodeActions = memo(<TooltipContent><p>Ask AI</p></TooltipContent>- </Tooltip>}+ </Tooltip>+ )}<Tooltip><TooltipTrigger asChild><div>diff --git a/flowsint-app/src/components/sketches/graph/components/graph-main.tsx b/flowsint-app/src/components/sketches/graph/components/graph-main.tsxindex 78a2a005..44f1bdba 100644--- a/flowsint-app/src/components/sketches/graph/components/graph-main.tsx+++ b/flowsint-app/src/components/sketches/graph/components/graph-main.tsx@@ -12,10 +12,10 @@ const GraphMain = () => {const filteredNodes = useGraphStore((s) => s.filteredNodes)const filteredEdges = useGraphStore((s) => s.filteredEdges)const toggleNodeSelection = useGraphStore((s) => s.toggleNodeSelection)- const setCurrentNode = useGraphStore((s) => s.setCurrentNode)+ const setCurrentNodeId = useGraphStore((s) => s.setCurrentNodeId)const clearSelectedNodes = useGraphStore((s) => s.clearSelectedNodes)const clearSelectedEdges = useGraphStore((s) => s.clearSelectedEdges)- const setCurrentEdge = useGraphStore((s) => s.setCurrentEdge)+ const setCurrentEdgeId = useGraphStore((s) => s.setCurrentEdgeId)const selectedNodes = useGraphStore(s => s.selectedNodes)const selectedEdges = useGraphStore(s => s.selectedEdges)@@ -31,22 +31,22 @@ const GraphMain = () => {if (isMultiSelect) {toggleNodeSelection(node, true)} else {- setCurrentNode(node)+ setCurrentNodeId(node.id)clearSelectedNodes()}},- [toggleNodeSelection, setCurrentNode, clearSelectedNodes]+ [toggleNodeSelection, setCurrentNodeId, clearSelectedNodes])const handleBackgroundClick = useCallback(() => {- setCurrentNode(null)+ setCurrentNodeId(null)clearSelectedNodes()clearSelectedEdges()- setCurrentEdge(null)+ setCurrentEdgeId(null)setNodeMenu(null)setEdgeMenu(null)setBackgroundMenu(null)- }, [setCurrentNode, clearSelectedNodes, clearSelectedEdges, setCurrentEdge])+ }, [setCurrentNodeId, clearSelectedNodes, clearSelectedEdges, setCurrentEdgeId])const onNodeContextMenu = useCallback((node: any, event: MouseEvent) => {if (!containerRef.current || !node) returndiff --git a/flowsint-app/src/components/sketches/graph/context-menu/node-context-menu.tsx b/flowsint-app/src/components/sketches/graph/context-menu/node-context-menu.tsxindex f9501305..1eb0181b 100644--- a/flowsint-app/src/components/sketches/graph/context-menu/node-context-menu.tsx+++ b/flowsint-app/src/components/sketches/graph/context-menu/node-context-menu.tsx@@ -7,7 +7,15 @@ import { Button } from '@/components/ui/button'import { Input } from '@/components/ui/input'import { Tabs, TabsList, TabsTrigger, TabsContent } from '@/components/ui/tabs'import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'-import { FileCode2, Search, Info, Zap, BadgeCheck, BadgeAlert, SquareArrowOutUpRight } from 'lucide-react'+import {+ FileCode2,+ Search,+ Info,+ Zap,+ BadgeCheck,+ BadgeAlert,+ SquareArrowOutUpRight+} from 'lucide-react'import { Enricher, Flow, GraphNode } from '@/types'import { useLaunchFlow } from '@/hooks/use-launch-flow'import { useLaunchEnricher } from '@/hooks/use-launch-enricher'@@ -95,10 +103,13 @@ export default function ContextMenu({setMenu(null)}- const handleOpenNodeDetails = useCallback((e: React.MouseEvent) => {- e.stopPropagation()- toggleNodeSelection(node, false)- }, [toggleNodeSelection, node])+ const handleOpenNodeDetails = useCallback(+ (e: React.MouseEvent) => {+ e.stopPropagation()+ toggleNodeSelection(node, false)+ },+ [toggleNodeSelection, node]+ )return (<BaseContextMenu@@ -111,7 +122,7 @@ export default function ContextMenu({{...props}>{/* Header with title and action buttons */}- <div className="px-3 py-2 border-b gap-1 border-border flex items-center justify-between flex-shrink-0">+ <div className="px-3 py-2 border-b gap-1 border-border flex items-center justify-between shrink-0"><div className="flex text-xs items-center gap-1 truncate"><span className="block truncate">{node.data.label}</span> -{' '}<span className="block">{node.data.type}</span>@@ -120,7 +131,7 @@ export default function ContextMenu({</div>{/* Tabs */}- <div className="px-3 py-2 border-b border-border flex-shrink-0">+ <div className="px-3 py-2 border-b border-border shrink-0"><Tabs value={activeTab} onValueChange={setActiveTab} className="w-full"><TabsList className="w-full h-9"><TabsTrigger value="enrichers" className="flex-1" onClick={(e) => e.stopPropagation()}>@@ -140,7 +151,7 @@ export default function ContextMenu({{/* Enrichers Tab */}<TabsContent value="enrichers" className="flex-1 flex flex-col min-h-0 mt-0">{/* Enrichers Search */}- <div className="px-3 py-2 border-b border-border flex-shrink-0">+ <div className="px-3 py-2 border-b border-border shrink-0"><div className="relative"><Search className="absolute left-2 top-1/2 transform -translate-y-1/2 h-3 w-3 text-muted-foreground" /><Input@@ -182,7 +193,14 @@ export default function ContextMenu({<Zap className="h-4 w-4 text-muted-foreground flex-shrink-0" /><div className="flex-1 min-w-0"><p className="text-sm font-medium flex gap-1 items-center truncate">- <span>{enricher.wobblyType ? <BadgeAlert className='h-3 w-3 text-orange-400' /> : <BadgeCheck className='h-3 w-3 text-green-400' />} </span> {enricher.name || '(Unnamed enricher)'}+ <span>+ {enricher.wobblyType ? (+ <BadgeAlert className="h-3 w-3 text-orange-400" />+ ) : (+ <BadgeCheck className="h-3 w-3 text-green-400" />+ )}{' '}+ </span>{' '}+ {enricher.name || '(Unnamed enricher)'}</p>{enricher.description && (<p className="text-xs text-muted-foreground truncate">@@ -252,7 +270,14 @@ export default function ContextMenu({<FileCode2 className="h-4 w-4 text-muted-foreground flex-shrink-0" /><div className="flex-1 min-w-0"><p className="flex items-center gap-1 text-sm font-medium truncate">- <span>{flow.wobblyType ? <BadgeAlert className='h-3 w-3 text-orange-400' /> : <BadgeCheck className='h-3 w-3 text-green-400' />} </span> {flow.name || '(Unnamed flow)'}+ <span>+ {flow.wobblyType ? (+ <BadgeAlert className="h-3 w-3 text-orange-400" />+ ) : (+ <BadgeCheck className="h-3 w-3 text-green-400" />+ )}{' '}+ </span>{' '}+ {flow.name || '(Unnamed flow)'}</p>{flow.description && (<p className="text-xs text-muted-foreground truncate">{flow.description}</p>@@ -276,7 +301,7 @@ export default function ContextMenu({</TabsContent></Tabs>- <div className='border-t p-1'>+ <div className="border-t p-1"><SubActions node={node} handleOpenNodeDetails={handleOpenNodeDetails} /></div></BaseContextMenu>@@ -289,12 +314,14 @@ type SubActionsProps = {}const SubActions = memo(({ node, handleOpenNodeDetails }: SubActionsProps) => {return (- <div className='flex'>- <CopyButton size={"icon"} content={node?.data?.label} />- <Button onClick={handleOpenNodeDetails} size={'icon'} className='h-7 w-7' variant="ghost"><SquareArrowOutUpRight className='!h-3.5 !w-3.5 opacity-50' /></Button>- </div>)-}-)+ <div className="flex">+ <CopyButton size={'icon'} content={node?.data?.label} />+ <Button onClick={handleOpenNodeDetails} size={'icon'} className="h-7 w-7" variant="ghost">+ <SquareArrowOutUpRight className="!h-3.5 !w-3.5 opacity-50" />+ </Button>+ </div>+ )+})const InfoButton = ({ description }: { description?: string }) => {if (!description) return nulldiff --git a/flowsint-app/src/components/sketches/graph/hooks/use-graph-events.ts b/flowsint-app/src/components/sketches/graph/hooks/use-graph-events.tsindex a5d7888e..ff6615f6 100644--- a/flowsint-app/src/components/sketches/graph/hooks/use-graph-events.ts+++ b/flowsint-app/src/components/sketches/graph/hooks/use-graph-events.ts@@ -12,7 +12,7 @@ interface UseGraphEventsParams {graphRef: React.RefObject<any>edgeMap: Map<string, GraphEdge>toggleEdgeSelection: (edge: GraphEdge, multi: boolean) => void- setCurrentEdge: (edge: GraphEdge) => void+ setCurrentEdgeId: (edgeId: string | null) => voidclearSelectedEdges: () => voidsaveAllNodePositions: (nodes: any[]) => void}@@ -28,7 +28,7 @@ export const useGraphEvents = ({graphRef,edgeMap,toggleEdgeSelection,- setCurrentEdge,+ setCurrentEdgeId,clearSelectedEdges,saveAllNodePositions}: UseGraphEventsParams) => {@@ -76,11 +76,11 @@ export const useGraphEvents = ({if (isMultiSelect) {toggleEdgeSelection(fullEdge, true)} else {- setCurrentEdge(fullEdge)+ setCurrentEdgeId(fullEdge.id)clearSelectedEdges()}},- [toggleEdgeSelection, setCurrentEdge, clearSelectedEdges, edgeMap]+ [toggleEdgeSelection, setCurrentEdgeId, clearSelectedEdges, edgeMap])const handleBackgroundClick = useCallback(() => {diff --git a/flowsint-app/src/components/sketches/graph/index.tsx b/flowsint-app/src/components/sketches/graph/index.tsxindex 6bf38f24..af89d611 100644--- a/flowsint-app/src/components/sketches/graph/index.tsx+++ b/flowsint-app/src/components/sketches/graph/index.tsx@@ -79,22 +79,22 @@ const GraphViewer: React.FC<GraphViewerProps> = ({const setImportModalOpen = useGraphSettingsStore((s) => s.setImportModalOpen)const {- currentNode,+ currentNodeId,currentEdge,selectedNodes,selectedEdges,toggleEdgeSelection,- setCurrentEdge,+ setCurrentEdgeId,clearSelectedEdges,setOpenMainDialog} = useGraphStore(useShallow((s) => ({- currentNode: s.currentNode,- currentEdge: s.currentEdge,+ currentNodeId: s.currentNodeId,+ currentEdge: s.getCurrentEdge(),selectedNodes: s.selectedNodes,selectedEdges: s.selectedEdges,toggleEdgeSelection: s.toggleEdgeSelection,- setCurrentEdge: s.setCurrentEdge,+ setCurrentEdgeId: s.setCurrentEdgeId,clearSelectedEdges: s.clearSelectedEdges,setOpenMainDialog: s.setOpenMainDialog}))@@ -103,7 +103,6 @@ const GraphViewer: React.FC<GraphViewerProps> = ({const { theme } = useTheme()const selectedNodeIds = useMemo(() => new Set(selectedNodes.map((n) => n.id)), [selectedNodes])- const currentNodeId = currentNode?.idconst selectedNodeIdsRef = useRef(selectedNodeIds)useEffect(() => {@@ -229,7 +228,7 @@ const GraphViewer: React.FC<GraphViewerProps> = ({graphRef,edgeMap,toggleEdgeSelection,- setCurrentEdge,+ setCurrentEdgeId,clearSelectedEdges,saveAllNodePositions})@@ -251,7 +250,12 @@ const GraphViewer: React.FC<GraphViewerProps> = ({graphRef.current.zoomToFit(400)}}- }, [])+ }, [sketchId])++ // reset hasPerformedInitialZoom on sketch change+ useEffect(() => {+ if (hasPerformedInitialZoom.current) hasPerformedInitialZoom.current = false+ }, [sketchId])const handleZoomToFitLocal = useCallback(() => {if (typeof graphRef.current.zoomToFit === 'function') {@@ -364,7 +368,15 @@ const GraphViewer: React.FC<GraphViewerProps> = ({autoColorLinksByNodeType})},- [forceSettings, theme, highlightLinks, highlightNodes, selectedEdges, currentEdge, autoColorLinksByNodeType]+ [+ forceSettings,+ theme,+ highlightLinks,+ highlightNodes,+ selectedEdges,+ currentEdge,+ autoColorLinksByNodeType+ ])if (!nodes.length) {diff --git a/flowsint-app/src/components/sketches/graph/panels/nodes-panel.tsx b/flowsint-app/src/components/sketches/graph/panels/nodes-panel.tsxindex 459b0f2a..b227dfae 100644--- a/flowsint-app/src/components/sketches/graph/panels/nodes-panel.tsx+++ b/flowsint-app/src/components/sketches/graph/panels/nodes-panel.tsx@@ -26,7 +26,7 @@ const ITEM_HEIGHT = 40const NodeRenderer = memo(({node,- setCurrentNode,+ setCurrentNodeId,onCheckboxChange,isNodeChecked,isCurrent,@@ -34,7 +34,7 @@ const NodeRenderer = memo(autoZoomOnCurrentNode}: {node: any- setCurrentNode: (node: GraphNode) => void+ setCurrentNodeId: (nodeId: string | null) => voidonCheckboxChange: (node: GraphNode, checked: boolean) => voidisNodeChecked: (nodeId: string) => booleanisCurrent: (nodeId: string) => boolean@@ -42,14 +42,14 @@ const NodeRenderer = memo(autoZoomOnCurrentNode: boolean}) => {const handleClick = useCallback(() => {- setCurrentNode(node)+ setCurrentNodeId(node.id)// Auto-zoom if enabled and node has coordinatesif (autoZoomOnCurrentNode && node?.x !== undefined && node?.y !== undefined) {setTimeout(() => {centerOnNode(node.x, node.y)}, 200)}- }, [node, setCurrentNode, centerOnNode, autoZoomOnCurrentNode])+ }, [node, setCurrentNodeId, centerOnNode, autoZoomOnCurrentNode])const handleCheckboxChange = useCallback((checked: boolean) => {@@ -90,7 +90,7 @@ const NodeRenderer = memo(const VirtualizedItem = memo(({node,- setCurrentNode,+ setCurrentNodeId,onCheckboxChange,isNodeChecked,isCurrent,@@ -99,7 +99,7 @@ const VirtualizedItem = memo(}: {index: numbernode: GraphNode- setCurrentNode: (node: GraphNode) => void+ setCurrentNodeId: (nodeId: string | null) => voidonCheckboxChange: (node: GraphNode, checked: boolean) => voidisNodeChecked: (nodeId: string) => booleanisCurrent: (nodeId: string) => boolean@@ -110,7 +110,7 @@ const VirtualizedItem = memo(<NodeRenderernode={node}isCurrent={isCurrent}- setCurrentNode={setCurrentNode}+ setCurrentNodeId={setCurrentNodeId}onCheckboxChange={onCheckboxChange}isNodeChecked={isNodeChecked}centerOnNode={centerOnNode}@@ -121,8 +121,8 @@ const VirtualizedItem = memo()const NodesPanel = memo(({ nodes, isLoading }: { nodes: GraphNode[]; isLoading?: boolean }) => {- const currentNode = useGraphStore((state) => state.currentNode)- const setCurrentNode = useGraphStore((state) => state.setCurrentNode)+ const currentNodeId = useGraphStore((state) => state.currentNodeId)+ const setCurrentNodeId = useGraphStore((state) => state.setCurrentNodeId)const setSelectedNodes = useGraphStore((state) => state.setSelectedNodes)const selectedNodes = useGraphStore((state) => state.selectedNodes || [])const centerOnNode = useGraphControls((state) => state.centerOnNode)@@ -194,9 +194,9 @@ const NodesPanel = memo(({ nodes, isLoading }: { nodes: GraphNode[]; isLoading?:const isCurrent = useCallback((nodeId: string) => {- return currentNode?.id === nodeId+ return currentNodeId === nodeId},- [currentNode]+ [currentNodeId])const handleCheckAll = useCallback(@@ -361,7 +361,7 @@ const NodesPanel = memo(({ nodes, isLoading }: { nodes: GraphNode[]; isLoading?:index={virtualItem.index}node={node}isCurrent={isCurrent}- setCurrentNode={setCurrentNode}+ setCurrentNodeId={setCurrentNodeId}onCheckboxChange={handleCheckboxChange}isNodeChecked={isNodeChecked}centerOnNode={centerOnNode}diff --git a/flowsint-app/src/components/sketches/selectors/lasso.tsx b/flowsint-app/src/components/sketches/selectors/lasso.tsxindex d4c2a167..6244eba6 100644--- a/flowsint-app/src/components/sketches/selectors/lasso.tsx+++ b/flowsint-app/src/components/sketches/selectors/lasso.tsx@@ -48,7 +48,7 @@ export function Lasso({}) {const setSelectedNodes = useGraphStore((s) => s.setSelectedNodes)const selectedNodes = useGraphStore((s) => s.selectedNodes)- const setCurrentNode = useGraphStore((s) => s.setCurrentNode)+ const setCurrentNodeId = useGraphStore((s) => s.setCurrentNodeId)const canvasRef = useRef<HTMLCanvasElement>(null)const ctxRef = useRef<CanvasRenderingContext2D | null>(null)const pointRef = useRef<[number, number][]>([])@@ -134,7 +134,7 @@ export function Lasso({function handlePointerUp(e: PointerEvent) {canvasRef.current?.releasePointerCapture(e.pointerId)pointRef.current = []- if (selectedNodes.length === 1) setCurrentNode(selectedNodes[0])+ if (selectedNodes.length === 1) setCurrentNodeId(selectedNodes[0].id)ctxRef.current?.clearRect(0, 0, width, height)}diff --git a/flowsint-app/src/components/sketches/selectors/rectangle.tsx b/flowsint-app/src/components/sketches/selectors/rectangle.tsxindex 436ad80c..6cbc3389 100644--- a/flowsint-app/src/components/sketches/selectors/rectangle.tsx+++ b/flowsint-app/src/components/sketches/selectors/rectangle.tsx@@ -31,7 +31,7 @@ export function Rectangle({}) {const setSelectedNodes = useGraphStore((s) => s.setSelectedNodes)const selectedNodes = useGraphStore((s) => s.selectedNodes)- const setCurrentNode = useGraphStore((s) => s.setCurrentNode)+ const setCurrentNodeId = useGraphStore((s) => s.setCurrentNodeId)const canvasRef = useRef<HTMLCanvasElement>(null)const ctxRef = useRef<CanvasRenderingContext2D | null>(null)const startPointRef = useRef<[number, number] | null>(null)@@ -127,7 +127,7 @@ export function Rectangle({function handlePointerUp(e: PointerEvent) {canvasRef.current?.releasePointerCapture(e.pointerId)startPointRef.current = null- if (selectedNodes.length === 1) setCurrentNode(selectedNodes[0])+ if (selectedNodes.length === 1) setCurrentNodeId(selectedNodes[0].id)ctxRef.current?.clearRect(0, 0, width, height)}diff --git a/flowsint-app/src/components/table/columns.tsx b/flowsint-app/src/components/table/columns.tsxindex d6fda263..866d1bda 100644--- a/flowsint-app/src/components/table/columns.tsx+++ b/flowsint-app/src/components/table/columns.tsx@@ -155,17 +155,16 @@ export const columns: ColumnDef<GraphNode>[] = [)},cell: ({ row }) => {- const setCurrentNode = useGraphStore((s) => s.setCurrentNode)+ const setCurrentNodeId = useGraphStore((s) => s.setCurrentNodeId)// const IconComponent = useIcon(row.original.data.type)const setOpenNodeEditorModal = useGraphStore((s) => s.setOpenNodeEditorModal)const openEdit = useCallback((e: React.MouseEvent) => {e.stopPropagation()- const typedNode = row.original as GraphNode- setCurrentNode(typedNode)+ setCurrentNodeId(row.original.id)setOpenNodeEditorModal(true)},- [row.original, setCurrentNode, setOpenNodeEditorModal]+ [row.original, setCurrentNodeId, setOpenNodeEditorModal])return (diff --git a/flowsint-app/src/components/table/nodes-view.tsx b/flowsint-app/src/components/table/nodes-view.tsxindex 05614d1c..c6e0eb42 100644--- a/flowsint-app/src/components/table/nodes-view.tsx+++ b/flowsint-app/src/components/table/nodes-view.tsx@@ -138,15 +138,15 @@ export default function NodesTable({ nodes }: NodesTableProps) {const [searchQuery, setSearchQuery] = useState('')const [selectedType, setSelectedType] = useState<string>('all')const parentRef = useRef<HTMLDivElement>(null)- const setCurrentNode = useGraphStore((s) => s.setCurrentNode)+ const setCurrentNodeId = useGraphStore((s) => s.setCurrentNodeId)const selectedNodes = useGraphStore((s) => s.selectedNodes)const setSelectedNodes = useGraphStore((s) => s.setSelectedNodes)const onNodeClick = useCallback((node: GraphNode) => {- setCurrentNode(node)+ setCurrentNodeId(node.id)},- [setCurrentNode]+ [setCurrentNodeId])// Filter nodes based on search and typediff --git a/flowsint-app/src/components/table/relationships-view.tsx b/flowsint-app/src/components/table/relationships-view.tsxindex 81d50db6..26255626 100644--- a/flowsint-app/src/components/table/relationships-view.tsx+++ b/flowsint-app/src/components/table/relationships-view.tsx@@ -128,7 +128,7 @@ export default function RelationshipsTable() {const [searchQuery, setSearchQuery] = useState('')const [selectedType, setSelectedType] = useState<string>('all')const parentRef = useRef<HTMLDivElement>(null)- const setCurrentNode = useGraphStore((s) => s.setCurrentNode)+ const setCurrentNodeId = useGraphStore((s) => s.setCurrentNodeId)const selectedEdges = useGraphStore((s) => s.selectedEdges)const setSelectedEdges = useGraphStore((s) => s.setSelectedEdges)const removeEdges = useGraphStore((s) => s.removeEdges)@@ -138,11 +138,11 @@ export default function RelationshipsTable() {const onNodeClick = useCallback((node: GraphNode) => {- setCurrentNode(node)+ setCurrentNodeId(node.id)// setOpenNodeEditorModal(true)},[- setCurrentNode+ setCurrentNodeId// setOpenNodeEditorModal])diff --git a/flowsint-app/src/stores/graph-store.ts b/flowsint-app/src/stores/graph-store.tsindex 2cffd411..fae4b226 100644--- a/flowsint-app/src/stores/graph-store.ts+++ b/flowsint-app/src/stores/graph-store.ts@@ -10,6 +10,8 @@ interface GraphState {edges: GraphEdge[]filteredNodes: GraphNode[]filteredEdges: GraphEdge[]+ nodesMapping: Map<string, GraphNode>+ edgesMapping: Map<string, GraphEdge>setNodes: (nodes: GraphNode[]) => voidsetEdges: (edges: GraphEdge[]) => voidaddNode: (newNode: Partial<GraphNode>) => GraphNode@@ -23,12 +25,15 @@ interface GraphState {reset: () => void// === Selection & Current ===- currentNode: GraphNode | null- currentEdge: GraphEdge | null+ currentNodeId: GraphNode['id'] | null+ currentEdgeId: GraphEdge['id'] | nullselectedNodes: GraphNode[]selectedEdges: GraphEdge[]- setCurrentNode: (node: GraphNode | null) => void- setCurrentEdge: (edge: GraphEdge | null) => void+ getNode: (nodeId: GraphNode['id']) => GraphNode | null+ getCurrentNode: () => GraphNode | null | undefined+ getCurrentEdge: () => GraphEdge | null | undefined+ setCurrentNodeId: (nodeId: GraphNode['id'] | null) => void+ setCurrentEdgeId: (edgeId: GraphEdge['id'] | null) => voidsetSelectedNodes: (nodes: GraphNode[]) => voidsetSelectedEdges: (edges: GraphEdge[]) => voidclearSelectedNodes: () => void@@ -100,6 +105,8 @@ export const useGraphStore = create<GraphState>()(edges: [],filteredNodes: [],filteredEdges: [],+ nodesMapping: new Map(),+ edgesMapping: new Map(),getNodesLength: () => get().nodes.length,getEdgesLength: () => get().edges.length,@@ -107,90 +114,111 @@ export const useGraphStore = create<GraphState>()(const { filters, edges } = get()const filteredNodes = computeFilteredNodes(nodes, filters)const filteredEdges = computeFilteredEdges(edges, filteredNodes)- set({ nodes, filteredNodes, filteredEdges })+ // update HashMap+ const nodesMapping = new Map(nodes.map((node) => [node.id, node]))+ set({ nodes, filteredNodes, filteredEdges, nodesMapping })},setEdges: (edges) => {const { filters, nodes } = get()const filteredNodes = computeFilteredNodes(nodes, filters)const filteredEdges = computeFilteredEdges(edges, filteredNodes)- set({ edges, filteredNodes, filteredEdges })+ const edgesMapping = new Map(edges.map((edge) => [edge.id, edge]))+ set({ edges, filteredNodes, filteredEdges, edgesMapping })},addNode: (newNode) => {- const { nodes, edges, filters } = get()+ const { nodes, nodesMapping, edges, filters } = get()const nodeWithId: GraphNode = {id: newNode.id || `node-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`,position: { x: 0, y: 0 },...newNode} as GraphNode- const newNodes = [...nodes, nodeWithId]- const filteredNodes = computeFilteredNodes(newNodes, filters)+ nodes.push(nodeWithId)+ nodesMapping.set(nodeWithId.id, nodeWithId)+ const filteredNodes = computeFilteredNodes(nodes, filters)const filteredEdges = computeFilteredEdges(edges, filteredNodes)- set({ nodes: newNodes, currentNode: nodeWithId, filteredNodes, filteredEdges })+ set({+ nodes,+ currentNodeId: nodeWithId.id,+ filteredNodes,+ filteredEdges+ })return nodeWithId},addEdge: (newEdge) => {- const { edges, nodes, filters } = get()+ const { edges, edgesMapping, nodes, filters } = get()const edgeWithId: GraphEdge = {id: newEdge.id || `edge-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`,...newEdge} as GraphEdge- const newEdges = [...edges, edgeWithId]+ edges.push(edgeWithId)+ edgesMapping.set(edgeWithId.id, edgeWithId)const filteredNodes = computeFilteredNodes(nodes, filters)- const filteredEdges = computeFilteredEdges(newEdges, filteredNodes)- set({ edges: newEdges, filteredNodes, filteredEdges })+ const filteredEdges = computeFilteredEdges(edges, filteredNodes)+ set({ edges, filteredNodes, filteredEdges, edgesMapping })return edgeWithId},removeNodes: (nodeIds: string[]) => {- const { nodes, edges, filters } = get()- const newNodes = nodes.filter((n) => !nodeIds.includes(n.id))- const newEdges = edges.filter(- (e) => !nodeIds.includes(e.source) && !nodeIds.includes(e.target)- )+ const { nodes, nodesMapping, edges, filters } = get()++ const nodeIdsSet = new Set(nodeIds)+ const newNodes = nodes.filter((n) => !nodeIdsSet.has(n.id))+ const newEdges = edges.filter((e) => !nodeIdsSet.has(e.source) && !nodeIdsSet.has(e.target))+const filteredNodes = computeFilteredNodes(newNodes, filters)const filteredEdges = computeFilteredEdges(newEdges, filteredNodes)+ // update HashMap+ deleteKeys(nodesMapping, nodeIdsSet)set({ nodes: newNodes, edges: newEdges, filteredNodes, filteredEdges })},removeEdges: (edgeIds: string[]) => {- const { edges, nodes, filters } = get()- const newEdges = edges.filter((e) => !edgeIds.includes(e.id))+ const { edges, edgesMapping, nodes, filters } = get()+ const edgeIdsSet = new Set(edgeIds)+ const newEdges = edges.filter((e) => !edgeIdsSet.has(e.id))const filteredNodes = computeFilteredNodes(nodes, filters)const filteredEdges = computeFilteredEdges(newEdges, filteredNodes)- set({ edges: newEdges, filteredNodes, filteredEdges })+ deleteKeys(edgesMapping, edgeIdsSet)+ set({ edges: newEdges, filteredNodes, filteredEdges, edgesMapping })},updateGraphData: (nodes, edges) => {const { filters } = get()const filteredNodes = computeFilteredNodes(nodes, filters)const filteredEdges = computeFilteredEdges(edges, filteredNodes)- set({ nodes, edges, filteredNodes, filteredEdges })+ const nodesMapping = new Map(nodes.map((node) => [node.id, node]))+ const edgesMapping = new Map(edges.map((edge) => [edge.id, edge]))+ set({ nodes, edges, filteredNodes, filteredEdges, nodesMapping, edgesMapping })},updateNode: (nodeId, updates) => {- const { nodes, edges, filters } = get()+ const { nodes, edges, filters, nodesMapping } = get()const updatedNodes = nodes.map((node) =>node.id === nodeId ? { ...node, data: { ...node.data, ...updates } } : node)const filteredNodes = computeFilteredNodes(updatedNodes, filters)const filteredEdges = computeFilteredEdges(edges, filteredNodes)- set({ nodes: updatedNodes, filteredNodes, filteredEdges })+ const node = nodesMapping.get(nodeId)+ if (node) nodesMapping.set(nodeId, { ...node, data: { ...node.data, ...updates } })+ set({ nodes: updatedNodes, filteredNodes, filteredEdges, nodesMapping })},updateEdge: (edgeId, updates) => {- const { edges, nodes, filters } = get()+ const { edges, edgesMapping, nodes, filters } = get()const updatedEdges = edges.map((edge) =>edge.id === edgeId ? ({ ...edge, ...updates } as GraphEdge) : edge)const filteredNodes = computeFilteredNodes(nodes, filters)const filteredEdges = computeFilteredEdges(updatedEdges, filteredNodes)- set({ edges: updatedEdges, filteredNodes, filteredEdges })+ const edge = edgesMapping.get(edgeId)+ if (edge) edgesMapping.set(edgeId, { ...edge, ...updates } as GraphEdge)+ set({ edges: updatedEdges, filteredNodes, filteredEdges, edgesMapping })},replaceNode: (oldId, newData) => {- const { nodes, edges, filters, currentNode } = get()+ const { nodes, edges, filters, nodesMapping, setCurrentNodeId } = get()// Update the node's ID and data.idconst updatedNodes = nodes.map((node) =>node.id === oldId ? { ...node, id: newData.id, data: newData } : node@@ -207,60 +235,63 @@ export const useGraphStore = create<GraphState>()(})const filteredNodes = computeFilteredNodes(updatedNodes, filters)const filteredEdges = computeFilteredEdges(updatedEdges, filteredNodes)- // Update currentNode if it matches the old ID- const updatedCurrentNode =- currentNode?.id === oldId- ? { ...currentNode, id: newData.id, data: newData }- : currentNode+ // Update nodesMapping+ nodesMapping.delete(oldId)+ const newNode = updatedNodes.find((n) => n.id === newData.id)+ if (newNode) nodesMapping.set(newData.id, newNode)+ // Update edgesMapping+ const newEdgesMapping = new Map(updatedEdges.map((edge) => [edge.id, edge]))+ setCurrentNodeId(newData.id)set({nodes: updatedNodes,edges: updatedEdges,filteredNodes,filteredEdges,- currentNode: updatedCurrentNode+ nodesMapping,+ edgesMapping: newEdgesMapping})},// === Selection & Current ===- currentNode: null,- currentEdge: null,+ currentNodeId: null,+ currentEdgeId: null,selectedNodes: [],selectedEdges: [],- setCurrentNode: (node) => {- const { currentNode } = get()- // Only update if the node is actually different- if (currentNode?.id !== node?.id) {- set({ currentNode: node })- }+ getNode: (nodeId: GraphNode['id']) => {+ return get().nodesMapping.get(nodeId) || null},- setCurrentNodeFromId: (nodeId) => {- const { currentNode, nodes } = get()- // Only update if the node is actually different- if (currentNode?.id !== nodeId) {- const node = nodes.find((n) => n.id === nodeId)- if (node) {- set({ currentNode: node })- return node- }- }- return null+ getCurrentNode: () => {+ const { currentNodeId, nodesMapping } = get()+ return currentNodeId ? nodesMapping.get(currentNodeId) : null},- setCurrentEdge: (edge) => {- const { currentEdge } = get()- // Only update if the edge is actually different- if (currentEdge?.id !== edge?.id) {- set({ currentEdge: edge })+ getCurrentEdge: () => {+ const { currentEdgeId, edgesMapping } = get()+ return currentEdgeId ? edgesMapping.get(currentEdgeId) : null+ },+ setCurrentNodeId: (nodeId: GraphNode['id'] | null) => {+ set({ currentNodeId: nodeId })+ },+ setCurrentEdgeId: (edgeId: GraphEdge['id'] | null) => {+ set({ currentEdgeId: edgeId })+ },+ setCurrentNodeFromId: (nodeId: string) => {+ const { nodesMapping } = get()+ const node = nodesMapping.get(nodeId)+ if (node) {+ set({ currentNodeId: nodeId })+ return node}+ return null},setSelectedNodes: (nodes) => set({ selectedNodes: nodes }),setSelectedEdges: (edges) => set({ selectedEdges: edges }),clearSelectedNodes: () => set({ selectedNodes: [] }),clearSelectedEdges: () => set({ selectedEdges: [] }),toggleNodeSelection: (node, multiSelect = false) => {- const { selectedNodes, currentNode } = get()+ const { selectedNodes, currentNodeId } = get()const isSelected = selectedNodes.some((n) => n.id === node.id)let newSelected: GraphNode[]- let newCurrentNode = currentNode+ let newCurrentNodeId = currentNodeIdif (multiSelect) {newSelected = isSelected@@ -268,9 +299,9 @@ export const useGraphStore = create<GraphState>()(: [...selectedNodes, node]} else {newSelected = isSelected && selectedNodes.length === 1 ? [] : [node]- // Only update currentNode if it's actually different+ // Only update currentNodeId if it's actually differentif (!multiSelect) {- newCurrentNode = isSelected ? null : node+ newCurrentNodeId = isSelected ? null : node.id}}@@ -278,12 +309,12 @@ export const useGraphStore = create<GraphState>()(const hasSelectionChanges =newSelected.length !== selectedNodes.length ||newSelected.some((n, i) => n.id !== selectedNodes[i]?.id)- const hasCurrentNodeChanges = newCurrentNode?.id !== currentNode?.id+ const hasCurrentNodeChanges = newCurrentNodeId !== currentNodeIdif (hasSelectionChanges || hasCurrentNodeChanges) {set({selectedNodes: newSelected,- currentNode: newCurrentNode+ currentNodeId: newCurrentNodeId})}},@@ -328,10 +359,10 @@ export const useGraphStore = create<GraphState>()(// === Action Type for Edit form ===handleEdit: (node) => {- const { currentNode, openNodeEditorModal } = get()+ const { currentNodeId, openNodeEditorModal } = get()// Only update if the node is actually different- if (currentNode?.id !== node.id) {- set({ currentNode: node, openNodeEditorModal: true })+ if (currentNodeId !== node.id) {+ set({ currentNodeId: node.id, openNodeEditorModal: true })} else if (!openNodeEditorModal) {// Only open modal if it's not already openset({ openNodeEditorModal: true })@@ -417,8 +448,8 @@ export const useGraphStore = create<GraphState>()(reset: () => {set({- currentNode: null,- currentEdge: null,+ currentNodeId: null,+ currentEdgeId: null,selectedNodes: [],selectedEdges: [],relatedNodeToAdd: null,@@ -442,3 +473,7 @@ export const useGraphStore = create<GraphState>()(}))++function deleteKeys<T>(map: Map<string, T>, keys: Iterable<string>) {+ for (const key of keys) map.delete(key)+}