fix: forceGraph
ci-front / build (push) Successful in 2m18s

This commit is contained in:
nikita
2026-04-04 12:51:35 +03:00
parent e7f1ea2386
commit 822f953698
2 changed files with 7 additions and 10 deletions
@@ -56,8 +56,8 @@ export const Sidebar: React.FC<SidebarProps> = ({
}, [agents, searchQuery]); }, [agents, searchQuery]);
const graphData: GraphData = useMemo(() => { const graphData: GraphData = useMemo(() => {
const nodes = []; const nodes: any[] = [];
const links = []; const links: any[] = [];
agents.forEach((agent) => { agents.forEach((agent) => {
nodes.push({ nodes.push({
@@ -138,15 +138,11 @@ export const ForceGraph = forwardRef<any, ForceGraphProps>(
} }
}; };
// Fit zoom on engine stop const handleEngineStop = () => {
useEffect(() => { if (typeof ref !== "function" && ref && "current" in ref && ref.current) {
if (ref && typeof ref === "object" && ref.current) { ref.current.zoomToFit(400);
const timer = setTimeout(() => {
ref.current?.zoomToFit(400);
}, 100);
return () => clearTimeout(timer);
} }
}, [data, ref]); };
return ( return (
<div ref={containerRef} className="w-full h-full relative"> <div ref={containerRef} className="w-full h-full relative">
@@ -180,6 +176,7 @@ export const ForceGraph = forwardRef<any, ForceGraphProps>(
d3AlphaDecay={0.03} d3AlphaDecay={0.03}
d3VelocityDecay={0.4} d3VelocityDecay={0.4}
warmupTicks={50} warmupTicks={50}
onEngineStop={handleEngineStop}
/> />
</div> </div>
); );