()
| 25 | |
| 26 | useEffect(() => { |
| 27 | const fetchIterations = () => { |
| 28 | const latest = IterationStore.getIterationsForAgent(agentId); |
| 29 | |
| 30 | // Quick check: length changed? |
| 31 | if (latest.length !== lastLengthRef.current) { |
| 32 | lastLengthRef.current = latest.length; |
| 33 | setIterations(latest); |
| 34 | return; |
| 35 | } |
| 36 | |
| 37 | // Deeper check: last iteration content changed? |
| 38 | if (latest.length > 0) { |
| 39 | const last = latest[latest.length - 1]; |
| 40 | const updateKey = `${last.id}-${last.modelResponse?.length || 0}-${last.tools.length}`; |
| 41 | |
| 42 | if (updateKey !== lastUpdateRef.current) { |
| 43 | lastUpdateRef.current = updateKey; |
| 44 | setIterations(latest); |
| 45 | } |
| 46 | } |
| 47 | }; |
| 48 | |
| 49 | // Initial fetch |
| 50 | fetchIterations(); |
no test coverage detected