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]);
const graphData: GraphData = useMemo(() => {
const nodes = [];
const links = [];
const nodes: any[] = [];
const links: any[] = [];
agents.forEach((agent) => {
nodes.push({
@@ -138,15 +138,11 @@ export const ForceGraph = forwardRef<any, ForceGraphProps>(
}
};
// 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 (
<div ref={containerRef} className="w-full h-full relative">
@@ -180,6 +176,7 @@ export const ForceGraph = forwardRef<any, ForceGraphProps>(
d3AlphaDecay={0.03}
d3VelocityDecay={0.4}
warmupTicks={50}
onEngineStop={handleEngineStop}
/>
</div>
);