Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

address review (self): dispose trail geometry on replace, assert trail Y

[._.]/ Adam Eivy31398e428d0c
diff --git a/client/src/components/city/AgentEntity.jsx b/client/src/components/city/AgentEntity.jsx
index 7c8b244582..67e85ce05e 100644
--- a/client/src/components/city/AgentEntity.jsx
+++ b/client/src/components/city/AgentEntity.jsx
@@ -1,4 +1,4 @@
-import { useRef, useMemo } from 'react';
+import { useRef, useMemo, useEffect } from 'react';
import { useFrame } from '@react-three/fiber';
import { Sparkles } from '@react-three/drei';
import * as THREE from 'three';
@@ -44,6 +44,10 @@ export default function AgentEntity({ agent, position, index = 0, settings }) {
return geom;
}, [color, trailSamples]);
+ // Dispose the geometry's GPU buffers when it's replaced (color/quality change)
+ // or on unmount — the imperative geometry isn't reclaimed automatically.
+ useEffect(() => () => trailGeom.dispose(), [trailGeom]);
+
useFrame(({ clock }) => {
const t = clock.getElapsedTime();
const p = computeAgentOrbit(t, { index });
diff --git a/client/src/utils/cityAgentMotion.test.js b/client/src/utils/cityAgentMotion.test.js
index 6c8103bccd..e646bf458b 100644
--- a/client/src/utils/cityAgentMotion.test.js
+++ b/client/src/utils/cityAgentMotion.test.js
@@ -97,6 +97,7 @@ describe('computeAgentTrailPoints', () => {
const pts = computeAgentTrailPoints(t, opts, 8, AGENT_MOTION.trailSeconds);
const last = pts.length - 3;
expect(pts[last]).toBeCloseTo(tail.x, 6);
+ expect(pts[last + 1]).toBeCloseTo(tail.y, 6);
expect(pts[last + 2]).toBeCloseTo(tail.z, 6);
});