MCPcopy Create free account
hub / github.com/Roy3838/Observer / fetchIterations

Function fetchIterations

app/src/hooks/useIterations.ts:27–47  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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();

Callers 1

useIterationsFunction · 0.85

Calls 1

getIterationsForAgentMethod · 0.80

Tested by

no test coverage detected