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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix([issue-819]): surface deep descendants and root overflow in goal-tree view
[._.]/ Adam Eivy3aad3ff9a582
diff --git a/client/src/components/city/CityGoalMonuments.jsx b/client/src/components/city/CityGoalMonuments.jsxindex 7e876628d5..a56c4ef9d3 100644--- a/client/src/components/city/CityGoalMonuments.jsx+++ b/client/src/components/city/CityGoalMonuments.jsx@@ -2,7 +2,7 @@ import { useMemo, useRef } from 'react';import { useFrame } from '@react-three/fiber';import { Text, Line } from '@react-three/drei';import { PIXEL_FONT_URL } from './cityConstants';-import { computeGoalMonuments, computeGoalForest, MONUMENTS } from '../../utils/cityGoalMonuments';+import { computeGoalMonuments, computeGoalForest, MONUMENTS, FOREST } from '../../utils/cityGoalMonuments';// CyberCity's goal monuments (roadmap 2.7): each life goal is a structure in a// northeast monument district. Active goals are construction sites — a built base topped@@ -22,15 +22,15 @@ function MonumentBody({ monument, shimmerRef, isShimmer }) {const { height, width, color, opacity, intensity, built, completeness, segments } = monument;// Milestone floors: one box per milestone, solid+emissive when done, wireframe scaffold- // when pending. The highest done floor carries the shimmer for completed monuments.+ // when pending. The top floor carries the shimmer — shimmer is only ever assigned to a+ // completed (built) monument, so all its floors render solid and the topmost is the apex.if (segments && segments.length > 0) {- const lastDoneIdx = segments.reduce((acc, s, i) => (s.done ? i : acc), -1);return (<>{segments.map((seg, i) => {const doneFloor = seg.done || built;const floorH = Math.max(0.15, seg.segHeight * 0.86); // gap between floors- const carriesShimmer = isShimmer && (built ? i === segments.length - 1 : i === lastDoneIdx);+ const carriesShimmer = isShimmer && i === segments.length - 1;return (<meshkey={seg.id}@@ -109,7 +109,9 @@ function Monument({ monument, shimmerRef, isShimmer }) {}// Goal-tree hierarchy: root spires + child rings + apex links. Used when goals form a-// parent→child structure; otherwise the flat row renders instead.+// parent→child structure; otherwise the flat row renders instead. The layout shows two+// visible levels; a child's deeper sub-tree is summarized by a "+N UNDER" badge and roots+// past the cap fold into a "+N MORE GOALS" marker, so nothing is silently dropped.function GoalForest({ forest, shimmerRef, shimmerId }) {return (<group>@@ -117,7 +119,14 @@ function GoalForest({ forest, shimmerRef, shimmerId }) {<group key={cluster.spire.id}><Monument monument={cluster.spire} shimmerRef={shimmerRef} isShimmer={cluster.spire.id === shimmerId} />{cluster.children.map((child) => (- <Monument key={child.id} monument={child} shimmerRef={shimmerRef} isShimmer={child.id === shimmerId} />+ <group key={child.id}>+ <Monument monument={child} shimmerRef={shimmerRef} isShimmer={child.id === shimmerId} />+ {child.descendantCount > 0 && (+ <Text position={[child.position[0], child.height + 1.9, child.position[2]]} fontSize={0.42} color="#64748b" anchorX="center" anchorY="middle" font={PIXEL_FONT_URL} maxWidth={9}>+ {`+${child.descendantCount} UNDER`}+ </Text>+ )}+ </group>))}{cluster.links.map((link) => (<Line@@ -136,6 +145,25 @@ function GoalForest({ forest, shimmerRef, shimmerId }) {)}</group>))}++ {/* Root overflow — top-level goal trees past the cap, mirroring the flat row's marker */}+ {forest.rootOverflow > 0 && forest.clusters.length > 0 && (+ <Text+ position={[+ forest.clusters[forest.clusters.length - 1].spire.position[0] + FOREST.clusterSpacing / 2,+ MONUMENTS.minHeight + 2,+ forest.base[2],+ ]}+ fontSize={0.6}+ color="#94a3b8"+ anchorX="center"+ anchorY="middle"+ font={PIXEL_FONT_URL}+ maxWidth={12}+ >+ {`+${forest.rootOverflow} MORE GOALS`}+ </Text>+ )}</group>);}diff --git a/client/src/utils/cityGoalMonuments.js b/client/src/utils/cityGoalMonuments.jsindex 4f0307bcf3..0a2f997876 100644--- a/client/src/utils/cityGoalMonuments.js+++ b/client/src/utils/cityGoalMonuments.js@@ -257,6 +257,21 @@ export function buildGoalForest(goals) {return { roots, byId };}+// Total number of goals nested under a forest node (its children, grandchildren, …),+// excluding the node itself. The forest layout renders only two visible levels (root spire+// + child ring), so a node's deeper descendants are summarized by this count rather than+// drawn — nothing is silently dropped. Guarded against the (server-prevented) cycle case+// via a visited set so a hand-corrupted parentId loop can't recurse forever.+export function countDescendants(node, seen = new Set()) {+ if (!node || seen.has(node)) return 0;+ seen.add(node);+ let total = 0;+ for (const child of node.children || []) {+ total += 1 + countDescendants(child, seen);+ }+ return total;+}+// Full hierarchy view-model. Returns root spires (each a placed monument with extra// height) plus their child monuments arranged in a ring, and `links` joining each child// apex-ward to its root. Roots are ordered completed→active→stalled→abandoned (same as the@@ -296,6 +311,9 @@ export function computeGoalForest(goals, now = Date.now()) {const cz = clusterZ + Math.sin(angle) * FOREST.childRadius; // +z = toward the camera/frontconst m = placeMonument(child.goal, 0, 1, now, [cx, 0, cz]);m.parentId = node.goal.id;+ // Deeper descendants aren't drawn (the layout is two levels); surface their count so+ // a grandchild-bearing sub-goal advertises its sub-tree instead of hiding it.+ m.descendantCount = countDescendants(child);return m;});diff --git a/client/src/utils/cityGoalMonuments.test.js b/client/src/utils/cityGoalMonuments.test.jsindex e86790f6e8..2c34de3ff6 100644--- a/client/src/utils/cityGoalMonuments.test.js+++ b/client/src/utils/cityGoalMonuments.test.js@@ -11,6 +11,7 @@ import {isMilestoneDone,computeMilestoneSegments,buildGoalForest,+ countDescendants,computeGoalForest,} from './cityGoalMonuments';@@ -303,6 +304,38 @@ describe('buildGoalForest', () => {const { roots } = buildGoalForest([null, 'x', { parentId: 'p' }, goal({ id: 'ok' })]);expect(roots.map((r) => r.goal.id)).toEqual(['ok']);});++ it('nests grandchildren under children (multi-level)', () => {+ const { roots } = buildGoalForest([+ goal({ id: 'root', parentId: null }),+ goal({ id: 'child', parentId: 'root' }),+ goal({ id: 'grand', parentId: 'child' }),+ ]);+ expect(roots).toHaveLength(1);+ const child = roots[0].children[0];+ expect(child.goal.id).toBe('child');+ expect(child.children.map((g) => g.goal.id)).toEqual(['grand']);+ });+});++describe('countDescendants', () => {+ const forestOf = (goals) => buildGoalForest(goals).roots[0];++ it('counts children and grandchildren, excluding the node itself', () => {+ const root = forestOf([+ goal({ id: 'root', parentId: null }),+ goal({ id: 'c1', parentId: 'root' }),+ goal({ id: 'c2', parentId: 'root' }),+ goal({ id: 'g1', parentId: 'c1' }),+ goal({ id: 'g2', parentId: 'c1' }),+ ]);+ expect(countDescendants(root)).toBe(4); // c1, c2, g1, g2+ });++ it('is 0 for a leaf', () => {+ const root = forestOf([goal({ id: 'solo', parentId: null })]);+ expect(countDescendants(root)).toBe(0);+ });});describe('computeGoalForest', () => {@@ -351,6 +384,17 @@ describe('computeGoalForest', () => {expect(vm.rootCount).toBe(FOREST.maxRoots + 2);});+ it('surfaces a descendant count on a child that has its own sub-tree (no silent drop)', () => {+ const vm = computeGoalForest([+ goal({ id: 'apex', parentId: null }),+ goal({ id: 'child', parentId: 'apex', progressHistory: [{ date: daysAgo(1) }] }),+ goal({ id: 'grand1', parentId: 'child' }),+ goal({ id: 'grand2', parentId: 'child' }),+ ], NOW);+ const child = vm.clusters[0].children.find((c) => c.id === 'child');+ expect(child.descendantCount).toBe(2); // grand1 + grand2, summarized not dropped+ });+it('caps children per root and reports childOverflow', () => {const goals = [goal({ id: 'apex', parentId: null })];for (let i = 0; i < FOREST.maxChildren + 3; i++) goals.push(goal({ id: `c${i}`, parentId: 'apex' }));