(agentId: string, pollInterval = DEFAULT_POLL_INTERVAL)
| 188 | * Hook to get iteration count - lightweight alternative when you just need the count |
| 189 | */ |
| 190 | export function useIterationCount(agentId: string, pollInterval = DEFAULT_POLL_INTERVAL): number { |
| 191 | const [count, setCount] = useState(0); |
| 192 | const lastCountRef = useRef(0); |
| 193 | |
| 194 | useEffect(() => { |
| 195 | const fetchCount = () => { |
| 196 | const iterations = IterationStore.getIterationsForAgent(agentId); |
| 197 | if (iterations.length !== lastCountRef.current) { |
| 198 | lastCountRef.current = iterations.length; |
| 199 | setCount(iterations.length); |
| 200 | } |
| 201 | }; |
| 202 | |
| 203 | fetchCount(); |
| 204 | const interval = setInterval(fetchCount, pollInterval); |
| 205 | return () => clearInterval(interval); |
| 206 | }, [agentId, pollInterval]); |
| 207 | |
| 208 | return count; |
| 209 | } |
nothing calls this directly
no test coverage detected