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

feat([issue-705]): add goal monuments to CyberCity (roadmap 2.7)

[._.]/ Adam Eivyec3a7af2288a
diff --git a/client/src/components/city/CityGoalMonuments.jsx b/client/src/components/city/CityGoalMonuments.jsx
new file mode 100644
index 0000000000..3cfce7885e
--- /dev/null
+++ b/client/src/components/city/CityGoalMonuments.jsx
@@ -0,0 +1,121 @@
+import { useMemo, useRef } from 'react';
+import { useFrame } from '@react-three/fiber';
+import { Text } from '@react-three/drei';
+import { PIXEL_FONT_URL } from './cityConstants';
+import { computeGoalMonuments, MONUMENTS } from '../../utils/cityGoalMonuments';
+
+// CyberCity's goal monuments (roadmap 2.7): each life goal is a structure in a
+// northeast monument district (a row centered around [30,0,-40]). Active goals are
+// construction sites — a solid built base topped by a translucent scaffold cage whose
+// fill tracks progress. Completed goals are polished, fully-built monuments that shimmer.
+// Stalled (active-but-quiet) and abandoned goals read dim. Goals past the cap fold into
+// an overflow marker. Mirrors CityBackupVault / CityHealthTower.
+function Monument({ monument, shimmerRef, isShimmer }) {
+ const { height, width, color, opacity, intensity, built, completeness, position } = monument;
+ // The "built" portion rises from the ground; the remaining height is scaffold.
+ const builtHeight = Math.max(0.4, height * (built ? 1 : completeness));
+ const scaffoldHeight = Math.max(0, height - builtHeight);
+
+ return (
+ <group position={position}>
+ {/* Plinth */}
+ <mesh position={[0, 0.2, 0]}>
+ <boxGeometry args={[width * 1.4, 0.4, width * 1.4]} />
+ <meshStandardMaterial color="#0a0e16" emissive={color} emissiveIntensity={0.1 * intensity + 0.04} metalness={0.6} roughness={0.5} />
+ </mesh>
+
+ {/* Built portion — solid structure; completed monuments shimmer via ref */}
+ <mesh ref={isShimmer ? shimmerRef : undefined} position={[0, 0.4 + builtHeight / 2, 0]}>
+ <boxGeometry args={[width, builtHeight, width]} />
+ <meshStandardMaterial
+ color={built ? '#0d1a12' : '#0c1424'}
+ emissive={color}
+ emissiveIntensity={intensity}
+ metalness={built ? 0.7 : 0.4}
+ roughness={built ? 0.35 : 0.6}
+ transparent={opacity < 1}
+ opacity={opacity}
+ toneMapped={false}
+ />
+ </mesh>
+
+ {/* Scaffold cage over the still-unbuilt portion of a construction site */}
+ {scaffoldHeight > 0.3 && (
+ <mesh position={[0, 0.4 + builtHeight + scaffoldHeight / 2, 0]}>
+ <boxGeometry args={[width * 1.05, scaffoldHeight, width * 1.05]} />
+ <meshStandardMaterial color={color} emissive={color} emissiveIntensity={intensity * 0.5} wireframe transparent opacity={opacity * 0.6} toneMapped={false} />
+ </mesh>
+ )}
+
+ {/* Title + progress label above the structure */}
+ <Text position={[0, height + 1.4, 0]} fontSize={0.7} color={color} anchorX="center" anchorY="middle" font={PIXEL_FONT_URL} maxWidth={9} fillOpacity={opacity}>
+ {monument.title}
+ </Text>
+ <Text position={[0, height + 0.7, 0]} fontSize={0.55} color="#94a3b8" anchorX="center" anchorY="middle" font={PIXEL_FONT_URL} maxWidth={9} fillOpacity={opacity}>
+ {built ? 'COMPLETE' : `${Math.round(monument.progress)}%`}
+ </Text>
+ </group>
+ );
+}
+
+export default function CityGoalMonuments({ goals, settings }) {
+ // The API returns `{ goals: [...] }`; accept either the wrapper or a bare array.
+ const list = Array.isArray(goals) ? goals : goals?.goals;
+ const district = useMemo(() => computeGoalMonuments(list), [list]);
+ const shimmerRef = useRef();
+
+ // Honor the quality dial: drop the completed-monument shimmer on the lowest preset,
+ // but keep the static glow so each goal's status stays legible.
+ const animate = (settings?.particleDensity ?? 1) >= 0.5;
+
+ // Pick the first completed monument to carry the shimmer (one per-frame ref mutation).
+ const shimmerIndex = useMemo(
+ () => district.monuments.findIndex((m) => m.built),
+ [district.monuments],
+ );
+
+ useFrame(({ clock }) => {
+ if (!animate || !shimmerRef.current || shimmerIndex < 0) return;
+ const base = district.monuments[shimmerIndex].intensity;
+ const pulse = (Math.sin(clock.getElapsedTime() * 1.6) + 1) / 2; // 0..1
+ shimmerRef.current.material.emissiveIntensity = base + pulse * 0.5;
+ });
+
+ if (!district.hasData) return null;
+
+ const { base, monuments, overflow, total, completedCount } = district;
+
+ return (
+ <group>
+ {monuments.map((monument, i) => (
+ <Monument
+ key={monument.id}
+ monument={monument}
+ shimmerRef={shimmerRef}
+ isShimmer={i === shimmerIndex}
+ />
+ ))}
+
+ {/* Overflow marker — "+N MORE" past the end of the row */}
+ {overflow && (
+ <group position={overflow.position}>
+ <mesh position={[0, MONUMENTS.minHeight / 2, 0]}>
+ <boxGeometry args={[MONUMENTS.baseWidth, MONUMENTS.minHeight, MONUMENTS.baseWidth]} />
+ <meshStandardMaterial color="#0c1424" emissive="#64748b" emissiveIntensity={0.2} metalness={0.5} roughness={0.6} />
+ </mesh>
+ <Text position={[0, MONUMENTS.minHeight + 1, 0]} fontSize={0.6} color="#94a3b8" anchorX="center" anchorY="middle" font={PIXEL_FONT_URL} maxWidth={9}>
+ {`+${overflow.count} MORE`}
+ </Text>
+ </group>
+ )}
+
+ {/* District title behind the row */}
+ <Text position={[base[0], 16, base[2] - 3]} fontSize={1.4} color="#22c55e" anchorX="center" anchorY="middle" font={PIXEL_FONT_URL} maxWidth={30}>
+ GOALS
+ </Text>
+ <Text position={[base[0], 15, base[2] - 3]} fontSize={0.8} color="#94a3b8" anchorX="center" anchorY="middle" font={PIXEL_FONT_URL} maxWidth={30}>
+ {`${completedCount}/${total} ACHIEVED`}
+ </Text>
+ </group>
+ );
+}
diff --git a/client/src/components/city/CityScene.jsx b/client/src/components/city/CityScene.jsx
index d00db92c60..7af5816793 100644
--- a/client/src/components/city/CityScene.jsx
+++ b/client/src/components/city/CityScene.jsx
@@ -18,6 +18,7 @@ import CityFederationHorizon from './CityFederationHorizon';
import CityBackupVault from './CityBackupVault';
import CityTaskQueue from './CityTaskQueue';
import CityHealthTower from './CityHealthTower';
+import CityGoalMonuments from './CityGoalMonuments';
import CityVoiceMarker from './CityVoiceMarker';
import CityAiCore from './CityAiCore';
import CityDataRain from './CityDataRain';
@@ -30,7 +31,7 @@ import CitySky from './CitySky';
import PlayerController from './PlayerController';
import CameraTransition from './CameraTransition';
-export default function CityScene({ apps, agentMap, onBuildingClick, cosStatus, reviewCounts, instances, backupStatus, cosTasks, healthMetrics, voiceState, aiActivity, productivityData, settings, playSfx, keysRef, dimmedAppIds }) {
+export default function CityScene({ apps, agentMap, onBuildingClick, cosStatus, reviewCounts, instances, backupStatus, cosTasks, healthMetrics, voiceState, aiActivity, productivityData, goals, settings, playSfx, keysRef, dimmedAppIds }) {
const [positions, setPositions] = useState(null);
const [proximityApp, setProximityApp] = useState(null);
const [transitioning, setTransitioning] = useState(false);
@@ -82,6 +83,7 @@ export default function CityScene({ apps, agentMap, onBuildingClick, cosStatus,
<CityBackupVault backupStatus={backupStatus} settings={settings} />
<CityTaskQueue cosTasks={cosTasks} settings={settings} />
<CityHealthTower healthMetrics={healthMetrics} settings={settings} />
+ <CityGoalMonuments goals={goals} settings={settings} />
<CityVoiceMarker voiceState={voiceState} settings={settings} />
<CityAiCore aiActivity={aiActivity} settings={settings} />
<CityGround settings={settings} />
diff --git a/client/src/pages/CyberCity.jsx b/client/src/pages/CyberCity.jsx
index 404fa6de43..a478f463db 100644
--- a/client/src/pages/CyberCity.jsx
+++ b/client/src/pages/CyberCity.jsx
@@ -68,6 +68,13 @@ function CyberCityInner() {
60_000,
);
+ // Life goals drive the goal-monument district. Same pattern as productivityData —
+ // `useAutoRefetch` keeps the last-good snapshot on transient failures.
+ const { data: goalsData } = useAutoRefetch(
+ () => api.getGoals({ silent: true }),
+ 120_000,
+ );
+
const handleBuildingClick = useCallback((app) => {
if (app?.id) {
navigate(`/apps/${app.id}`);
@@ -112,6 +119,7 @@ function CyberCityInner() {
voiceState={voiceState}
aiActivity={aiActivity}
productivityData={productivityData}
+ goals={goalsData}
settings={settings}
playSfx={playSfx}
keysRef={keysRef}
diff --git a/client/src/utils/cityGoalMonuments.js b/client/src/utils/cityGoalMonuments.js
new file mode 100644
index 0000000000..f4ca76e279
--- /dev/null
+++ b/client/src/utils/cityGoalMonuments.js
@@ -0,0 +1,158 @@
+// Pure, deterministic helpers for CyberCity's "goal monuments" (roadmap 2.7): each
+// life goal renders as a structure in a northeast monument district. Active goals are
+// construction sites (scaffolded/partial towers whose build completeness tracks
+// progress); completed goals are polished, fully-built monuments that shimmer; stalled
+// goals (active but with no recent progress) and abandoned goals read dim. The goal
+// list is capped to a sensible row; the rest are summarized by an overflow marker. No
+// three.js / React imports so the topology is unit-testable (mirrors cityFederation.js
+// / cityHealthTower.js).
+
+export const MONUMENTS = {
+ // Northeast monument district — a row centered around [30, 0, -40], clear of the
+ // vault (x≈-34), task-queue (x≈+34), voice ([0,0,-40]), health ([48,0,28]),
+ // AI core ([0,0,0]), and productivity district (SW).
+ base: [30, 0, -40], // center of the row
+ spacing: 9, // x-distance between adjacent monuments
+ z: -40, // shared depth of the row
+ maxMonuments: 8, // cap; goals beyond this fold into an overflow marker
+ minHeight: 2, // floor height so even a 0%-progress site reads as a small structure
+ fullHeight: 12, // height of a completed (100%) monument
+ baseWidth: 2.4,
+};
+
+// Status → visual treatment. `dim` collapses opacity + glow so stalled/abandoned goals
+// recede; `built` flags a finished monument (drives the polished material + shimmer).
+const STATUS_STYLES = {
+ completed: { color: '#22c55e', opacity: 1, intensity: 0.7, dim: false, built: true }, // port-success
+ active: { color: '#3b82f6', opacity: 0.92, intensity: 0.4, dim: false, built: false }, // port-accent — under construction
+ stalled: { color: '#f59e0b', opacity: 0.55, intensity: 0.18, dim: true, built: false }, // port-warning, dimmed
+ abandoned: { color: '#64748b', opacity: 0.32, intensity: 0.08, dim: true, built: false }, // slate, dimmed
+};
+
+const DEFAULT_STYLE = STATUS_STYLES.active;
+
+const clamp01 = (n) => Math.max(0, Math.min(1, n));
+
+// Days since the most recent progressHistory entry (or createdAt as a fallback).
+// Returns null when there's nothing to measure from, so callers can distinguish
+// "no signal" from a real recency.
+export function daysSinceLastProgress(goal, now = Date.now()) {
+ const history = Array.isArray(goal?.progressHistory) ? goal.progressHistory : [];
+ let latest = null;
+ for (const entry of history) {
+ const t = entry?.date ? Date.parse(entry.date) : NaN;
+ if (Number.isFinite(t) && (latest === null || t > latest)) latest = t;
+ }
+ if (latest === null) {
+ const created = goal?.createdAt ? Date.parse(goal.createdAt) : NaN;
+ if (Number.isFinite(created)) latest = created;
+ }
+ if (latest === null) return null;
+ return Math.max(0, (now - latest) / (1000 * 60 * 60 * 24));
+}
+
+// Derive the *effective* status used for visualization. The stored status enum is
+// active | completed | abandoned (server: goalStatusEnum). "stalled" is a derived
+// state — an active, not-yet-complete goal with no progress in STALL_DAYS — so the
+// monument visibly dims when a goal goes quiet. Threshold is conservative.
+export const STALL_DAYS = 45;
+
+export function effectiveGoalStatus(goal, now = Date.now()) {
+ const raw = goal?.status;
+ if (raw === 'completed') return 'completed';
+ if (raw === 'abandoned') return 'abandoned';
+ // Treat anything else as active for styling purposes.
+ const progress = Number.isFinite(goal?.progress) ? goal.progress : 0;
+ if (progress >= 100) return 'completed';
+ const idleDays = daysSinceLastProgress(goal, now);
+ if (idleDays !== null && idleDays >= STALL_DAYS) return 'stalled';
+ return 'active';
+}
+
+// Build completeness 0..1: completed monuments are always fully built; everything else
+// tracks `progress` (clamped). A present-but-zero progress reads as a 1-floor stub, not
+// nothing, so a freshly-created goal still shows on the row.
+export function buildCompleteness(goal, status) {
+ if (status === 'completed') return 1;
+ const progress = Number.isFinite(goal?.progress) ? goal.progress : 0;
+ return clamp01(progress / 100);
+}
+
+// Map one goal to its placed monument view-model. `index` is the slot in the row (0-based);
+// `count` is how many monuments are actually placed, so the row is centered on MONUMENTS.base.
+export function placeMonument(goal, index, count, now = Date.now()) {
+ const status = effectiveGoalStatus(goal, now);
+ const style = STATUS_STYLES[status] || DEFAULT_STYLE;
+ const completeness = buildCompleteness(goal, status);
+ const height = MONUMENTS.minHeight + completeness * (MONUMENTS.fullHeight - MONUMENTS.minHeight);
+
+ // Center the row: slot 0 sits at the leftmost, the middle slot aligns with base.x.
+ const offset = (index - (count - 1) / 2) * MONUMENTS.spacing;
+ const x = MONUMENTS.base[0] + offset;
+
+ return {
+ id: goal?.id || `goal-${index}`,
+ title: typeof goal?.title === 'string' && goal.title ? goal.title : 'Untitled Goal',
+ status,
+ progress: Number.isFinite(goal?.progress) ? clamp01(goal.progress / 100) * 100 : 0,
+ completeness, // 0..1 — fraction of the monument that is "built"
+ color: style.color,
+ opacity: style.opacity,
+ intensity: style.intensity,
+ dim: style.dim,
+ built: style.built,
+ height,
+ width: MONUMENTS.baseWidth,
+ position: [x, 0, MONUMENTS.z],
+ };
+}
+
+// Full derived view-model for the component. `goals` is the raw goals list (the API
+// returns `{ goals: [...] }`; callers should pass `data?.goals`). A missing / non-array
+// input yields an empty district rather than a crash. Goals beyond MONUMENTS.maxMonuments
+// fold into an `overflow` marker placed just past the end of the row.
+export function computeGoalMonuments(goals, now = Date.now()) {
+ const list = Array.isArray(goals) ? goals.filter((g) => g && typeof g === 'object') : [];
+
+ // Stable ordering so the row doesn't reshuffle across refetches: completed first
+ // (trophies up front), then active, then stalled, then abandoned; ties broken by id.
+ const order = { completed: 0, active: 1, stalled: 2, abandoned: 3 };
+ const ranked = list
+ .map((goal) => ({ goal, status: effectiveGoalStatus(goal, now) }))
+ .sort((a, b) => {
+ const sa = order[a.status] ?? 9;
+ const sb = order[b.status] ?? 9;
+ if (sa !== sb) return sa - sb;
+ return String(a.goal?.id || '').localeCompare(String(b.goal?.id || ''));
+ });
+
+ const visible = ranked.slice(0, MONUMENTS.maxMonuments);
+ const overflowCount = Math.max(0, ranked.length - visible.length);
+
+ const monuments = visible.map(({ goal }, index) =>
+ placeMonument(goal, index, visible.length, now)
+ );
+
+ // Overflow marker sits one slot past the right end of the row.
+ let overflow = null;
+ if (overflowCount > 0) {
+ const offset = (visible.length - (visible.length - 1) / 2) * MONUMENTS.spacing;
+ overflow = {
+ count: overflowCount,
+ position: [MONUMENTS.base[0] + offset, 0, MONUMENTS.z],
+ };
+ }
+
+ const completedCount = ranked.filter((r) => r.status === 'completed').length;
+ const activeCount = ranked.filter((r) => r.status === 'active').length;
+
+ return {
+ base: MONUMENTS.base,
+ monuments,
+ overflow,
+ total: ranked.length,
+ completedCount,
+ activeCount,
+ hasData: ranked.length > 0,
+ };
+}
diff --git a/client/src/utils/cityGoalMonuments.test.js b/client/src/utils/cityGoalMonuments.test.js
new file mode 100644
index 0000000000..d4f8796581
--- /dev/null
+++ b/client/src/utils/cityGoalMonuments.test.js
@@ -0,0 +1,183 @@
+import { describe, it, expect } from 'vitest';
+import {
+ MONUMENTS,
+ STALL_DAYS,
+ daysSinceLastProgress,
+ effectiveGoalStatus,
+ buildCompleteness,
+ placeMonument,
+ computeGoalMonuments,
+} from './cityGoalMonuments';
+
+const NOW = Date.parse('2026-06-03T00:00:00Z');
+const daysAgo = (d) => new Date(NOW - d * 24 * 60 * 60 * 1000).toISOString();
+
+const goal = (over = {}) => ({
+ id: 'goal-1',
+ title: 'Run a marathon',
+ status: 'active',
+ progress: 50,
+ createdAt: daysAgo(10),
+ progressHistory: [{ date: daysAgo(5), value: 50 }],
+ ...over,
+});
+
+describe('daysSinceLastProgress', () => {
+ it('measures from the most recent progressHistory entry', () => {
+ const g = goal({ progressHistory: [{ date: daysAgo(3), value: 20 }, { date: daysAgo(10), value: 5 }] });
+ expect(daysSinceLastProgress(g, NOW)).toBeCloseTo(3, 1);
+ });
+
+ it('falls back to createdAt when no history', () => {
+ const g = goal({ progressHistory: [], createdAt: daysAgo(7) });
+ expect(daysSinceLastProgress(g, NOW)).toBeCloseTo(7, 1);
+ });
+
+ it('returns null when there is no usable date', () => {
+ expect(daysSinceLastProgress({ progressHistory: [] }, NOW)).toBeNull();
+ expect(daysSinceLastProgress(null, NOW)).toBeNull();
+ expect(daysSinceLastProgress({ progressHistory: [{ date: 'nope' }] }, NOW)).toBeNull();
+ });
+});
+
+describe('effectiveGoalStatus', () => {
+ it('maps stored completed/abandoned through unchanged', () => {
+ expect(effectiveGoalStatus(goal({ status: 'completed' }), NOW)).toBe('completed');
+ expect(effectiveGoalStatus(goal({ status: 'abandoned' }), NOW)).toBe('abandoned');
+ });
+
+ it('treats progress >= 100 as completed even if stored active', () => {
+ expect(effectiveGoalStatus(goal({ status: 'active', progress: 100 }), NOW)).toBe('completed');
+ });
+
+ it('derives stalled for an active goal with no progress past the threshold', () => {
+ const stale = goal({ progressHistory: [{ date: daysAgo(STALL_DAYS + 5), value: 50 }] });
+ expect(effectiveGoalStatus(stale, NOW)).toBe('stalled');
+ });
+
+ it('keeps a recently-progressed active goal active', () => {
+ const fresh = goal({ progressHistory: [{ date: daysAgo(2), value: 50 }] });
+ expect(effectiveGoalStatus(fresh, NOW)).toBe('active');
+ });
+
+ it('defaults to active for an unknown/missing status', () => {
+ expect(effectiveGoalStatus({ progressHistory: [{ date: daysAgo(1) }] }, NOW)).toBe('active');
+ });
+});
+
+describe('buildCompleteness', () => {
+ it('is always 1 for a completed monument', () => {
+ expect(buildCompleteness(goal({ progress: 12 }), 'completed')).toBe(1);
+ });
+
+ it('tracks progress/100 for active, clamped', () => {
+ expect(buildCompleteness(goal({ progress: 40 }), 'active')).toBeCloseTo(0.4);
+ expect(buildCompleteness(goal({ progress: 250 }), 'active')).toBe(1);
+ expect(buildCompleteness(goal({ progress: -5 }), 'active')).toBe(0);
+ });
+
+ it('treats missing progress as 0 (a floor stub), not a crash', () => {
+ expect(buildCompleteness({}, 'active')).toBe(0);
+ });
+});
+
+describe('placeMonument', () => {
+ it('maps status to color/opacity/dim/built', () => {
+ const completed = placeMonument(goal({ status: 'completed' }), 0, 1, NOW);
+ expect(completed.built).toBe(true);
+ expect(completed.dim).toBe(false);
+ expect(completed.completeness).toBe(1);
+ expect(completed.height).toBeCloseTo(MONUMENTS.fullHeight);
+
+ const abandoned = placeMonument(goal({ status: 'abandoned' }), 0, 1, NOW);
+ expect(abandoned.dim).toBe(true);
+ expect(abandoned.built).toBe(false);
+ expect(abandoned.opacity).toBeLessThan(completed.opacity);
+ });
+
+ it('progress drives height between min and full', () => {
+ const half = placeMonument(goal({ status: 'active', progress: 50, progressHistory: [{ date: daysAgo(1) }] }), 0, 1, NOW);
+ expect(half.height).toBeGreaterThan(MONUMENTS.minHeight);
+ expect(half.height).toBeLessThan(MONUMENTS.fullHeight);
+ });
+
+ it('centers a single monument on base.x', () => {
+ const only = placeMonument(goal(), 0, 1, NOW);
+ expect(only.position[0]).toBeCloseTo(MONUMENTS.base[0]);
+ expect(only.position[2]).toBe(MONUMENTS.z);
+ });
+
+ it('lays out a row centered around base.x with consistent spacing', () => {
+ const a = placeMonument(goal(), 0, 3, NOW);
+ const b = placeMonument(goal(), 1, 3, NOW);
+ const c = placeMonument(goal(), 2, 3, NOW);
+ expect(b.position[0]).toBeCloseTo(MONUMENTS.base[0]); // middle slot on center
+ expect(b.position[0] - a.position[0]).toBeCloseTo(MONUMENTS.spacing);
+ expect(c.position[0] - b.position[0]).toBeCloseTo(MONUMENTS.spacing);
+ });
+
+ it('falls back to a title and id without crashing', () => {
+ const m = placeMonument({}, 2, 5, NOW);
+ expect(m.title).toBe('Untitled Goal');
+ expect(m.id).toBe('goal-2');
+ });
+});
+
+describe('computeGoalMonuments', () => {
+ it('handles missing / non-array input as an empty district', () => {
+ for (const bad of [null, undefined, 'nope', 42, {}]) {
+ const vm = computeGoalMonuments(bad, NOW);
+ expect(vm.monuments).toEqual([]);
+ expect(vm.overflow).toBeNull();
+ expect(vm.hasData).toBe(false);
+ expect(vm.total).toBe(0);
+ }
+ });
+
+ it('places one monument per goal up to the cap', () => {
+ const goals = Array.from({ length: 4 }, (_, i) => goal({ id: `g-${i}` }));
+ const vm = computeGoalMonuments(goals, NOW);
+ expect(vm.monuments).toHaveLength(4);
+ expect(vm.overflow).toBeNull();
+ expect(vm.total).toBe(4);
+ expect(vm.hasData).toBe(true);
+ });
+
+ it('caps at maxMonuments and folds the rest into an overflow marker', () => {
+ const goals = Array.from({ length: MONUMENTS.maxMonuments + 3 }, (_, i) => goal({ id: `g-${i}` }));
+ const vm = computeGoalMonuments(goals, NOW);
+ expect(vm.monuments).toHaveLength(MONUMENTS.maxMonuments);
+ expect(vm.overflow).not.toBeNull();
+ expect(vm.overflow.count).toBe(3);
+ expect(vm.overflow.position[2]).toBe(MONUMENTS.z);
+ expect(vm.total).toBe(MONUMENTS.maxMonuments + 3);
+ });
+
+ it('orders completed monuments before active before stalled before abandoned', () => {
+ const goals = [
+ goal({ id: 'ab', status: 'abandoned' }),
+ goal({ id: 'co', status: 'completed' }),
+ goal({ id: 'st', progressHistory: [{ date: daysAgo(STALL_DAYS + 1) }] }),
+ goal({ id: 'ac', progressHistory: [{ date: daysAgo(1) }] }),
+ ];
+ const vm = computeGoalMonuments(goals, NOW);
+ expect(vm.monuments.map((m) => m.status)).toEqual(['completed', 'active', 'stalled', 'abandoned']);
+ });
+
+ it('reports completed / active counts', () => {
+ const goals = [
+ goal({ id: 'a', status: 'completed' }),
+ goal({ id: 'b', status: 'completed' }),
+ goal({ id: 'c', progressHistory: [{ date: daysAgo(1) }] }),
+ ];
+ const vm = computeGoalMonuments(goals, NOW);
+ expect(vm.completedCount).toBe(2);
+ expect(vm.activeCount).toBe(1);
+ });
+
+ it('skips null / non-object entries without crashing', () => {
+ const vm = computeGoalMonuments([null, goal({ id: 'ok' }), 'bad', 42], NOW);
+ expect(vm.monuments).toHaveLength(1);
+ expect(vm.monuments[0].id).toBe('ok');
+ });
+});