From 822f9536989ebe638ff8fab62c2cdd53c55d2a05 Mon Sep 17 00:00:00 2001 From: nikita Date: Sat, 4 Apr 2026 12:51:35 +0300 Subject: [PATCH] fix: forceGraph --- .../src/app/providers/layout/sidebar/sidebar.tsx | 4 ++-- .../src/modules/graph/components/ForceGraph.tsx | 13 +++++-------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/frontend/src/app/providers/layout/sidebar/sidebar.tsx b/frontend/src/app/providers/layout/sidebar/sidebar.tsx index 894824c..780fb40 100644 --- a/frontend/src/app/providers/layout/sidebar/sidebar.tsx +++ b/frontend/src/app/providers/layout/sidebar/sidebar.tsx @@ -56,8 +56,8 @@ export const Sidebar: React.FC = ({ }, [agents, searchQuery]); const graphData: GraphData = useMemo(() => { - const nodes = []; - const links = []; + const nodes: any[] = []; + const links: any[] = []; agents.forEach((agent) => { nodes.push({ diff --git a/frontend/src/modules/graph/components/ForceGraph.tsx b/frontend/src/modules/graph/components/ForceGraph.tsx index d80960b..7f239c1 100644 --- a/frontend/src/modules/graph/components/ForceGraph.tsx +++ b/frontend/src/modules/graph/components/ForceGraph.tsx @@ -138,15 +138,11 @@ export const ForceGraph = forwardRef( } }; - // Fit zoom on engine stop - useEffect(() => { - if (ref && typeof ref === "object" && ref.current) { - const timer = setTimeout(() => { - ref.current?.zoomToFit(400); - }, 100); - return () => clearTimeout(timer); + const handleEngineStop = () => { + if (typeof ref !== "function" && ref && "current" in ref && ref.current) { + ref.current.zoomToFit(400); } - }, [data, ref]); + }; return (
@@ -180,6 +176,7 @@ export const ForceGraph = forwardRef( d3AlphaDecay={0.03} d3VelocityDecay={0.4} warmupTicks={50} + onEngineStop={handleEngineStop} />
);