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

fix: review round 2 — reserve borough focus headroom for hologram/agents (#2593)

Adam Eivy35e2463885a7
diff --git a/client/src/utils/cityFocusCamera.js b/client/src/utils/cityFocusCamera.js
index b5a95fc960..1c266104d2 100644
--- a/client/src/utils/cityFocusCamera.js
+++ b/client/src/utils/cityFocusCamera.js
@@ -19,6 +19,12 @@ export const BOROUGH_GROUND_RADIUS = 4.5;
// Empty space left around the framed borough (1 = edge-to-edge, 1.35 = 35% margin).
const FRAMING_MARGIN = 1.35;
+// Extra vertical reach above the tower for the things that float over it — the building hologram
+// (~tower + 1.8) and the stacked AgentEntity markers — so a borough with several active agents
+// isn't clipped above the frame. A fixed cushion (the pure math only knows the tower `height`, not
+// the live agent count) that comfortably covers a typical stack.
+const BOROUGH_TOP_CLEARANCE = 3.0;
+
// How far above the horizon the focus camera sits (~40°). Keeps the shot looking slightly down onto
// the borough like the overview, without going full top-down.
const PITCH_RAD = (40 * Math.PI) / 180;
@@ -48,9 +54,10 @@ export function computeFocusCamera({ building, aspect = 1, fovDeg = CITY_CAMERA_
const safeAspect = Number.isFinite(aspect) && aspect > 0 ? aspect : 1;
const safeFov = Number.isFinite(fovDeg) && fovDeg > 0 ? fovDeg : CITY_CAMERA_FOV_DEG;
- // Bounding radius: the wider of the borough's ground footprint and half its tower height, so both
- // a tall skinny tower and a short wide cluster stay fully in frame.
- const radius = Math.max(BOROUGH_GROUND_RADIUS, height * 0.6) * FRAMING_MARGIN;
+ // Bounding radius: the wider of the borough's ground footprint and half its tower height (plus the
+ // hologram/agent clearance above), so a tall skinny tower, a short wide cluster, and a
+ // many-agent borough all stay fully in frame.
+ const radius = Math.max(BOROUGH_GROUND_RADIUS, height * 0.6 + BOROUGH_TOP_CLEARANCE) * FRAMING_MARGIN;
// Usable viewport fraction once the HUD safe area is subtracted, clamped to a floor.
const right = clamp01(hudSafe?.right ?? 0);
diff --git a/client/src/utils/cityFocusCamera.test.js b/client/src/utils/cityFocusCamera.test.js
index 9d491cbba4..08056f1bb9 100644
--- a/client/src/utils/cityFocusCamera.test.js
+++ b/client/src/utils/cityFocusCamera.test.js
@@ -31,6 +31,12 @@ describe('computeFocusCamera', () => {
expect(tallB.radius).toBeGreaterThan(shortB.radius);
});
+ it('reserves headroom above the tower for the hologram / floating agents', () => {
+ const { target, radius } = computeFocusCamera({ building, aspect: 1.6 });
+ // The framed sphere reaches well above the tower top so agent markers are not clipped.
+ expect(target[1] + radius).toBeGreaterThan(building.height + 3);
+ });
+
it('uses the borough ground radius floor for short buildings', () => {
const { radius } = computeFocusCamera({ building: { x: 0, z: 0, height: 1 }, aspect: 1.6 });
expect(radius).toBeGreaterThanOrEqual(BOROUGH_GROUND_RADIUS);