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-824]): add CyberCity seasonal decorations & easter eggs

[._.]/ Adam Eivyf99cf0a7800b
diff --git a/client/src/components/city/CityEasterEggs.jsx b/client/src/components/city/CityEasterEggs.jsx
new file mode 100644
index 0000000000..bec24a91d0
--- /dev/null
+++ b/client/src/components/city/CityEasterEggs.jsx
@@ -0,0 +1,71 @@
+import { useMemo, useRef } from 'react';
+import { useFrame } from '@react-three/fiber';
+import { Text } from '@react-three/drei';
+import { PIXEL_FONT_URL } from './cityConstants';
+import { computeEasterEggs, EGGS } from '../../utils/cityEasterEggs';
+
+// CyberCity's easter eggs (roadmap 3.5 follow-up, #824): rare, hidden emblems that only appear
+// when a special condition is met (a developer's date, a "leet" level, a palindrome streak, a
+// clean-sweep goal board). Tucked in a quiet far corner so they read as a discovery, not a
+// featured district. Each egg is a small glowing icosahedron with a tiny glyph label; they bob
+// in unison via a single per-frame group ref, gated on the quality dial (mirrors CityArtifacts).
+function Egg({ egg }) {
+ const { color, label, position } = egg;
+ const s = EGGS.size;
+
+ return (
+ <group position={position}>
+ <mesh rotation={[0, Math.PI / 6, 0]}>
+ <icosahedronGeometry args={[s, 0]} />
+ <meshStandardMaterial color={color} emissive={color} emissiveIntensity={0.9} metalness={0.6} roughness={0.2} toneMapped={false} />
+ </mesh>
+
+ <pointLight color={color} intensity={1.1} distance={8} />
+
+ {/* Tiny glyph so the egg hints at what it is without spelling it out. */}
+ <Text position={[0, s + 0.5, 0]} fontSize={0.45} color={color} anchorX="center" anchorY="middle" font={PIXEL_FONT_URL} maxWidth={6}>
+ {label}
+ </Text>
+ </group>
+ );
+}
+
+export default function CityEasterEggs({ date, character, goals, productivityData, settings }) {
+ // Resolve unlocked eggs from the data the city already has + an injected date (deterministic in
+ // the helper's tests). Default to the current moment for the live app only.
+ const cluster = useMemo(
+ () => computeEasterEggs({ date: date ?? new Date(), character, goals, productivityData }),
+ [date, character, goals, productivityData],
+ );
+
+ const groupRef = useRef();
+
+ // Honor the quality dial: drop the bob on the lowest preset, keep the static glow.
+ const animate = (settings?.particleDensity ?? 1) >= 0.5;
+
+ useFrame(({ clock }) => {
+ if (!animate || !groupRef.current) return;
+ const pulse = (Math.sin(clock.getElapsedTime() * 2) + 1) / 2; // 0..1, faster = rarer/twinkly
+ groupRef.current.position.y = pulse * 0.4;
+ groupRef.current.rotation.y = clock.getElapsedTime() * 0.3;
+ });
+
+ if (!cluster.hasData) return null;
+
+ const { base, eggs } = cluster;
+
+ return (
+ <group>
+ <group ref={groupRef}>
+ {eggs.map((egg) => (
+ <Egg key={egg.id} egg={egg} />
+ ))}
+ </group>
+
+ {/* A faint marker so a found cluster has a label, kept small to preserve the "hidden" feel. */}
+ <Text position={[base[0], 6, base[2]]} fontSize={0.7} color="#64748b" anchorX="center" anchorY="middle" font={PIXEL_FONT_URL} maxWidth={20}>
+ :)
+ </Text>
+ </group>
+ );
+}
diff --git a/client/src/components/city/CityScene.jsx b/client/src/components/city/CityScene.jsx
index f6e59c28b6..64f93c3a72 100644
--- a/client/src/components/city/CityScene.jsx
+++ b/client/src/components/city/CityScene.jsx
@@ -21,6 +21,8 @@ import CityHealthTower from './CityHealthTower';
import CityProductivityDistrict from './CityProductivityDistrict';
import CityGoalMonuments from './CityGoalMonuments';
import CityArtifacts from './CityArtifacts';
+import CitySeasonalDecor from './CitySeasonalDecor';
+import CityEasterEggs from './CityEasterEggs';
import CityVoiceMarker from './CityVoiceMarker';
import CityAiCore from './CityAiCore';
import CityDataRain from './CityDataRain';
@@ -90,6 +92,8 @@ export default function CityScene({ apps, agentMap, onBuildingClick, cosStatus,
<CityProductivityDistrict productivityData={productivityData} settings={settings} />
<CityGoalMonuments goals={goals} settings={settings} />
<CityArtifacts character={character} goals={goals} productivityData={productivityData} settings={settings} />
+ <CitySeasonalDecor settings={settings} />
+ <CityEasterEggs character={character} goals={goals} productivityData={productivityData} settings={settings} />
<CityVoiceMarker voiceState={voiceState} settings={settings} />
<CityAiCore aiActivity={aiActivity} settings={settings} />
<CityGround settings={settings} />
diff --git a/client/src/components/city/CitySeasonalDecor.jsx b/client/src/components/city/CitySeasonalDecor.jsx
new file mode 100644
index 0000000000..97b582ca56
--- /dev/null
+++ b/client/src/components/city/CitySeasonalDecor.jsx
@@ -0,0 +1,73 @@
+import { useMemo, useRef } from 'react';
+import { useFrame } from '@react-three/fiber';
+import { Text } from '@react-three/drei';
+import { PIXEL_FONT_URL } from './cityConstants';
+import { computeSeasonalDecor, SEASONAL_DECOR } from '../../utils/citySeasonalDecor';
+
+// CyberCity's seasonal decorations (roadmap 3.5 follow-up, #824): date-driven city dressing
+// that layers the active season's (or holiday's) palette onto a loose ring of glowing accent
+// props around the city's edge. The theme is resolved from a date passed in — a holiday window
+// (New Year, Halloween, …) overrides the broad season. Props bob/shimmer in unison via a single
+// per-frame group ref, gated on the quality dial (mirrors CityArtifacts / CityGoalMonuments).
+function Decoration({ decoration, color, accent }) {
+ const { position } = decoration;
+ const s = SEASONAL_DECOR.propSize;
+
+ return (
+ <group position={position}>
+ {/* A faceted, glowing prop — abstract enough to read for any season/holiday. */}
+ <mesh position={[0, s * 0.6, 0]} rotation={[0, Math.PI / 5, 0]}>
+ <coneGeometry args={[s * 0.5, s * 1.4, 5]} />
+ <meshStandardMaterial color={color} emissive={color} emissiveIntensity={0.55} metalness={0.4} roughness={0.3} toneMapped={false} />
+ </mesh>
+
+ {/* An accent orb crowns the prop — the holiday/season's secondary color. */}
+ <mesh position={[0, s * 1.5, 0]}>
+ <sphereGeometry args={[s * 0.28, 10, 10]} />
+ <meshStandardMaterial color={accent} emissive={accent} emissiveIntensity={0.8} toneMapped={false} />
+ </mesh>
+
+ <pointLight position={[0, s * 1.2, 0]} color={accent} intensity={0.7} distance={9} />
+ </group>
+ );
+}
+
+export default function CitySeasonalDecor({ date, settings }) {
+ // Resolve the active theme once per (date, calendar-day) — `date` is injected so the season is
+ // deterministic (and unit-testable in the helper). Default to the current moment for the live
+ // app; tests drive the pure helper directly, never this component's default.
+ const decor = useMemo(() => computeSeasonalDecor(date ?? new Date()), [date]);
+
+ const groupRef = useRef();
+
+ // Honor the quality dial: drop the bob/shimmer on the lowest preset, but keep the static glow
+ // so the seasonal dressing stays visible.
+ const animate = (settings?.particleDensity ?? 1) >= 0.5;
+
+ useFrame(({ clock }) => {
+ if (!animate || !groupRef.current) return;
+ const t = clock.getElapsedTime();
+ const pulse = (Math.sin(t * 1.1) + 1) / 2; // 0..1
+ groupRef.current.scale.setScalar(1 + pulse * 0.06);
+ groupRef.current.position.y = pulse * 0.6; // gentle bob
+ });
+
+ if (!decor.hasData) return null;
+
+ const { decorations, color, accent, label, base = [0, 0, 0] } = decor;
+
+ return (
+ <group>
+ <group ref={groupRef}>
+ {decorations.map((decoration) => (
+ <Decoration key={decoration.id} decoration={decoration} color={color} accent={accent} />
+ ))}
+ </group>
+
+ {/* Season/holiday banner high above the city center so it reads as ambient context. */}
+ <Text position={[base[0], 34, base[2]]} fontSize={1.6} color={color} anchorX="center" anchorY="middle" font={PIXEL_FONT_URL} maxWidth={40}>
+ {label}
+ </Text>
+ </group>
+ );
+}
diff --git a/client/src/utils/cityEasterEggs.js b/client/src/utils/cityEasterEggs.js
new file mode 100644
index 0000000000..41d4cd3be8
--- /dev/null
+++ b/client/src/utils/cityEasterEggs.js
@@ -0,0 +1,143 @@
+// Pure, deterministic helpers for CyberCity's "easter eggs" (roadmap 3.5 follow-up, #824):
+// hidden/rare artifacts that only appear when a special, non-obvious condition is met. Unlike
+// the earned-artifact trophies (cityArtifacts.js), which mark expected milestones, easter eggs
+// are surprises — a developer's date (Apr 1), a numerically-special level (the "leet" 13/42),
+// a palindrome streak, or an exact all-goals-complete state. Each is DERIVED from data the city
+// already has plus a caller-supplied date — nothing here calls `new Date()` so every condition
+// is unit-testable on a fixed day. No three.js / React imports (mirrors cityArtifacts.js).
+//
+// Easter eggs render as small, glowing, rare emblems tucked at the city's edge — found, not
+// announced. A given egg appears at most once (deduped by id) and the set is stable-ordered so
+// the placement doesn't reshuffle across refetches.
+
+import { hashString } from './hashString';
+
+// Placement: a tight cluster at the far -X / +Z corner, deliberately off in a quiet quadrant
+// away from the achievement hall (+X/-Z) so an egg reads as "hidden" rather than featured.
+export const EGGS = {
+ base: [-46, 0, 40],
+ spacing: 5,
+ columns: 2,
+ size: 1.1,
+};
+
+// Coerce to a finite number or null (the "absent" sentinel) so an absent field never collapses
+// into a real 0 (mirrors cityArtifacts.finiteOrNull).
+function finiteOrNull(value) {
+ return typeof value === 'number' && Number.isFinite(value) ? value : null;
+}
+
+// A number reads the same forwards and backwards (and is >= 10 so single digits don't trivially
+// qualify). Used by the palindrome-streak egg.
+function isPalindrome(n) {
+ if (!Number.isInteger(n) || n < 10) return false;
+ const s = String(n);
+ return s === [...s].reverse().join('');
+}
+
+// Each egg is { id, label, hint, color, test }. `test` is a pure predicate over the derived
+// context { date, level, completedGoals, totalGoals, bestStreak }. Ordered most-special first
+// for stable placement. Colors lean into rare/arcade neon (the city's accent palette).
+export const EASTER_EGGS = [
+ {
+ id: 'april-fools',
+ label: '?!',
+ hint: "APRIL FOOLS",
+ color: '#ec4899',
+ test: ({ date }) =>
+ !!date && typeof date.getMonth === 'function' && date.getMonth() + 1 === 4 && date.getDate() === 1,
+ },
+ {
+ id: 'leet',
+ label: '1337',
+ hint: 'LEET',
+ color: '#22c55e',
+ // The classic "elite" level. Exact match, not a threshold — it's a wink, not a milestone.
+ test: ({ level }) => level === 13,
+ },
+ {
+ id: 'answer',
+ label: '42',
+ hint: 'THE ANSWER',
+ color: '#3b82f6',
+ test: ({ level }) => level === 42,
+ },
+ {
+ id: 'palindrome-streak',
+ label: '⇄',
+ hint: 'PALINDROME STREAK',
+ color: '#a855f7',
+ test: ({ bestStreak }) => bestStreak !== null && isPalindrome(bestStreak),
+ },
+ {
+ id: 'clean-sweep',
+ label: '★',
+ hint: 'CLEAN SWEEP',
+ color: '#fcd34d',
+ // Every tracked goal completed (and there is at least one) — a rare, perfect board.
+ test: ({ completedGoals, totalGoals }) => totalGoals > 0 && completedGoals === totalGoals,
+ },
+];
+
+// Normalize the raw inputs into the flat predicate context. `level` and `bestStreak` are nullable
+// (absent → null, never 0) so an "exact value" egg can't false-fire on missing data. Goal counts
+// default to 0 (a missing list is just an empty board).
+export function eggContext({ date, character, goals, productivityData } = {}) {
+ const lvl = character?.level;
+ const level = Number.isFinite(lvl) && lvl >= 1 ? Math.floor(lvl) : null;
+
+ const list = Array.isArray(goals) ? goals : Array.isArray(goals?.goals) ? goals.goals : [];
+ const realGoals = list.filter((g) => g && typeof g === 'object');
+ const completedGoals = realGoals.filter((g) => g.status === 'completed').length;
+ const totalGoals = realGoals.length;
+
+ const streak = productivityData?.streak;
+ const bestStreak =
+ streak && typeof streak === 'object'
+ ? finiteOrNull(streak.longest) ?? finiteOrNull(streak.current)
+ : null;
+
+ return { date: date || null, level, completedGoals, totalGoals, bestStreak };
+}
+
+// Build the list of UNLOCKED egg descriptors. Deterministic, side-effect-free, stable order.
+export function unlockedEggs(inputs = {}) {
+ const ctx = eggContext(inputs);
+ return EASTER_EGGS.filter((egg) => egg.test(ctx)).map((egg) => ({
+ id: egg.id,
+ label: egg.label,
+ hint: egg.hint,
+ color: egg.color,
+ }));
+}
+
+// Place an egg descriptor into the corner cluster grid (left→right, wrapping toward +Z), seeded
+// per-id so the per-egg float phase differs. Mirrors cityArtifacts.placeArtifact.
+export function placeEgg(descriptor, index) {
+ const col = index % EGGS.columns;
+ const row = Math.floor(index / EGGS.columns);
+ const xOffset = (col - (EGGS.columns - 1) / 2) * EGGS.spacing;
+ const x = EGGS.base[0] + xOffset;
+ const z = EGGS.base[2] + row * EGGS.spacing;
+ const seed = hashString(descriptor.id);
+
+ return {
+ ...descriptor,
+ position: [x, EGGS.size + 0.6, z],
+ phase: (seed % 100) / 100,
+ };
+}
+
+// Full derived view-model for the easter-egg component. Inject the date so calendar eggs are
+// deterministic in tests. Nothing unlocked → empty cluster (`hasData: false`), never a crash.
+export function computeEasterEggs(inputs = {}) {
+ const descriptors = unlockedEggs(inputs);
+ const eggs = descriptors.map((d, i) => placeEgg(d, i));
+
+ return {
+ base: EGGS.base,
+ eggs,
+ total: eggs.length,
+ hasData: eggs.length > 0,
+ };
+}
diff --git a/client/src/utils/cityEasterEggs.test.js b/client/src/utils/cityEasterEggs.test.js
new file mode 100644
index 0000000000..9fb5121216
--- /dev/null
+++ b/client/src/utils/cityEasterEggs.test.js
@@ -0,0 +1,131 @@
+import { describe, it, expect } from 'vitest';
+import {
+ EGGS,
+ EASTER_EGGS,
+ eggContext,
+ unlockedEggs,
+ placeEgg,
+ computeEasterEggs,
+} from './cityEasterEggs';
+
+const on = (month, day) => new Date(2025, month - 1, day, 12, 0, 0);
+const completedGoals = (n) =>
+ Array.from({ length: n }, (_, i) => ({ id: `g-${i}`, status: 'completed' }));
+
+describe('eggContext', () => {
+ it('normalizes level to floored int >= 1, else null', () => {
+ expect(eggContext({ character: { level: 7.9 } }).level).toBe(7);
+ expect(eggContext({ character: { level: 0 } }).level).toBeNull();
+ expect(eggContext({}).level).toBeNull();
+ });
+
+ it('counts goals and total from a list or wrapper, ignoring junk entries', () => {
+ const ctx = eggContext({ goals: [{ status: 'completed' }, { status: 'active' }, null, 'x'] });
+ expect(ctx.completedGoals).toBe(1);
+ expect(ctx.totalGoals).toBe(2); // two real objects, junk dropped
+ });
+
+ it('prefers longest streak over current, else null (never 0 from absence)', () => {
+ expect(eggContext({ productivityData: { streak: { current: 2, longest: 11 } } }).bestStreak).toBe(11);
+ expect(eggContext({ productivityData: { streak: { current: 4 } } }).bestStreak).toBe(4);
+ expect(eggContext({}).bestStreak).toBeNull();
+ });
+});
+
+describe('unlockedEggs — conditions', () => {
+ it('unlocks nothing for an empty/default context', () => {
+ expect(unlockedEggs({})).toEqual([]);
+ });
+
+ it('unlocks the April Fools egg only on Apr 1', () => {
+ expect(unlockedEggs({ date: on(4, 1) }).map((e) => e.id)).toContain('april-fools');
+ expect(unlockedEggs({ date: on(4, 2) }).map((e) => e.id)).not.toContain('april-fools');
+ expect(unlockedEggs({ date: on(3, 1) }).map((e) => e.id)).not.toContain('april-fools');
+ });
+
+ it('unlocks the leet egg at exactly level 13 (not a threshold)', () => {
+ expect(unlockedEggs({ character: { level: 13 } }).map((e) => e.id)).toContain('leet');
+ expect(unlockedEggs({ character: { level: 14 } }).map((e) => e.id)).not.toContain('leet');
+ expect(unlockedEggs({ character: { level: 12 } }).map((e) => e.id)).not.toContain('leet');
+ });
+
+ it('unlocks the answer egg at exactly level 42', () => {
+ expect(unlockedEggs({ character: { level: 42 } }).map((e) => e.id)).toContain('answer');
+ expect(unlockedEggs({ character: { level: 41 } }).map((e) => e.id)).not.toContain('answer');
+ });
+
+ it('unlocks the palindrome-streak egg only for a palindromic best streak >= 10', () => {
+ expect(unlockedEggs({ productivityData: { streak: { longest: 22 } } }).map((e) => e.id)).toContain('palindrome-streak');
+ expect(unlockedEggs({ productivityData: { streak: { longest: 121 } } }).map((e) => e.id)).toContain('palindrome-streak');
+ expect(unlockedEggs({ productivityData: { streak: { longest: 23 } } }).map((e) => e.id)).not.toContain('palindrome-streak');
+ expect(unlockedEggs({ productivityData: { streak: { longest: 7 } } }).map((e) => e.id)).not.toContain('palindrome-streak'); // single digit
+ });
+
+ it('unlocks the clean-sweep egg only when all (>=1) goals are completed', () => {
+ expect(unlockedEggs({ goals: completedGoals(3) }).map((e) => e.id)).toContain('clean-sweep');
+ const mixed = [...completedGoals(2), { id: 'x', status: 'active' }];
+ expect(unlockedEggs({ goals: mixed }).map((e) => e.id)).not.toContain('clean-sweep');
+ expect(unlockedEggs({ goals: [] }).map((e) => e.id)).not.toContain('clean-sweep'); // empty board does not count
+ });
+
+ it('preserves the stable table order when several unlock at once', () => {
+ const ids = unlockedEggs({
+ date: on(4, 1),
+ character: { level: 13 },
+ goals: completedGoals(2),
+ }).map((e) => e.id);
+ // april-fools precedes leet precedes clean-sweep in EASTER_EGGS
+ expect(ids).toEqual(['april-fools', 'leet', 'clean-sweep']);
+ });
+
+ it('every egg descriptor carries an id, label, hint, and color', () => {
+ for (const egg of EASTER_EGGS) {
+ expect(typeof egg.id).toBe('string');
+ expect(typeof egg.label).toBe('string');
+ expect(typeof egg.hint).toBe('string');
+ expect(typeof egg.color).toBe('string');
+ expect(typeof egg.test).toBe('function');
+ }
+ });
+});
+
+describe('placeEgg', () => {
+ it('centers the first column on base.x and wraps toward +Z', () => {
+ const first = placeEgg({ id: 'a', color: '#fff' }, 0);
+ const wrapped = placeEgg({ id: 'b', color: '#fff' }, EGGS.columns);
+ expect(wrapped.position[0]).toBeCloseTo(first.position[0]); // same column
+ expect(wrapped.position[2]).toBe(EGGS.base[2] + EGGS.spacing); // one row toward +Z
+ });
+
+ it('attaches a deterministic 0..1 phase per id', () => {
+ const a = placeEgg({ id: 'leet', color: '#fff' }, 0);
+ const b = placeEgg({ id: 'leet', color: '#fff' }, 0);
+ expect(a.phase).toBe(b.phase);
+ expect(a.phase).toBeGreaterThanOrEqual(0);
+ expect(a.phase).toBeLessThanOrEqual(1);
+ });
+});
+
+describe('computeEasterEggs', () => {
+ it('handles an empty input as an empty cluster (no crash)', () => {
+ const vm = computeEasterEggs({});
+ expect(vm.eggs).toEqual([]);
+ expect(vm.total).toBe(0);
+ expect(vm.hasData).toBe(false);
+ expect(vm.base).toEqual(EGGS.base);
+ });
+
+ it('handles a fully-undefined call', () => {
+ expect(computeEasterEggs().hasData).toBe(false);
+ });
+
+ it('places one egg per unlocked condition', () => {
+ const vm = computeEasterEggs({ date: on(4, 1), character: { level: 13 } });
+ expect(vm.total).toBe(2);
+ expect(vm.hasData).toBe(true);
+ for (const e of vm.eggs) {
+ expect(e.position).toHaveLength(3);
+ expect(typeof e.color).toBe('string');
+ }
+ });
+});
diff --git a/client/src/utils/citySeasonalDecor.js b/client/src/utils/citySeasonalDecor.js
new file mode 100644
index 0000000000..746554b66f
--- /dev/null
+++ b/client/src/utils/citySeasonalDecor.js
@@ -0,0 +1,175 @@
+// Pure, deterministic helpers for CyberCity's "seasonal decorations" (roadmap 3.5 follow-up,
+// #824): date-driven city dressing that layers a holiday/seasonal theme onto the existing
+// districts. The active theme is DERIVED from a date passed in by the caller — nothing here
+// calls `new Date()` so the resolver is fully unit-testable for specific days (mirrors the
+// "inject the input" rule the rest of the city helpers follow). No three.js / React imports.
+//
+// A "season" is the broad quarter (winter/spring/summer/autumn); a "holiday" is a tighter
+// date window (e.g. the winter-holidays week, Halloween) that overrides the season's palette
+// and adds a few extra accent decorations. When no holiday matches, the broad season still
+// dresses the city with a subtle ambient palette + scattered decorations. There is always a
+// theme — the city is never undressed — but each theme is intentionally low-key so it reads
+// as seasonal flavor rather than clutter.
+
+import { hashString } from './hashString';
+
+// Decoration placement: a loose ring of accent props around the city center, well clear of the
+// building cluster and the achievement/goal districts. Deterministic seeded scatter so the
+// dressing doesn't reshuffle across refetches.
+export const SEASONAL_DECOR = {
+ ringRadius: 70, // distance from origin — outside the active districts
+ ringY: 0.5, // resting height of a ground decoration
+ count: 8, // decorations placed around the ring per theme
+ propSize: 2.2,
+};
+
+// Broad seasons keyed by an integer 0..3 the resolver computes from the month. Northern-
+// hemisphere mapping (the install's locale is its own concern; this is a flavor layer, not a
+// calendar API). Colors reuse PortOS Tailwind design tokens / the city's neon palette.
+export const SEASONS = {
+ winter: { id: 'winter', label: 'WINTER', color: '#3b82f6', accent: '#93c5fd', prop: 'crystal' }, // port-accent / icy
+ spring: { id: 'spring', label: 'SPRING', color: '#22c55e', accent: '#86efac', prop: 'bloom' }, // port-success / green
+ summer: { id: 'summer', label: 'SUMMER', color: '#f59e0b', accent: '#fcd34d', prop: 'beam' }, // port-warning / gold
+ autumn: { id: 'autumn', label: 'AUTUMN', color: '#f97316', accent: '#fdba74', prop: 'leaf' }, // orange
+};
+
+// Holiday windows — tighter date ranges that override the season palette and bump the glow.
+// Each entry is an inclusive [month, day] start .. [month, day] end window (1-based month).
+// `wrapsYear` marks a window that straddles Dec→Jan (e.g. New Year). Kept deliberately small and
+// culture-light; this is ambient dressing, not a comprehensive holiday calendar.
+export const HOLIDAYS = [
+ {
+ id: 'new-year',
+ label: 'NEW YEAR',
+ color: '#fcd34d',
+ accent: '#fde68a',
+ prop: 'firework',
+ start: [12, 31],
+ end: [1, 1],
+ wrapsYear: true,
+ },
+ {
+ id: 'winter-holidays',
+ label: 'WINTER HOLIDAYS',
+ color: '#ef4444',
+ accent: '#22c55e',
+ prop: 'lights',
+ start: [12, 20],
+ end: [12, 30],
+ },
+ {
+ id: 'spring-bloom',
+ label: 'SPRING BLOOM',
+ color: '#ec4899',
+ accent: '#f9a8d4',
+ prop: 'bloom',
+ start: [3, 20],
+ end: [3, 27],
+ },
+ {
+ id: 'midsummer',
+ label: 'MIDSUMMER',
+ color: '#f59e0b',
+ accent: '#fde68a',
+ prop: 'beam',
+ start: [6, 19],
+ end: [6, 25],
+ },
+ {
+ id: 'halloween',
+ label: 'HALLOWEEN',
+ color: '#f97316',
+ accent: '#a855f7',
+ prop: 'pumpkin',
+ start: [10, 25],
+ end: [10, 31],
+ },
+];
+
+// Map a 1-based month to a broad season id. Dec/Jan/Feb → winter, etc.
+function seasonForMonth(month) {
+ if (month === 12 || month === 1 || month === 2) return 'winter';
+ if (month >= 3 && month <= 5) return 'spring';
+ if (month >= 6 && month <= 8) return 'summer';
+ return 'autumn';
+}
+
+// True when (month, day) falls inside a holiday window. Handles a window that wraps the year
+// boundary (start month/day later than end month/day).
+function inHolidayWindow(month, day, holiday) {
+ const [sm, sd] = holiday.start;
+ const [em, ed] = holiday.end;
+ const afterStart = month > sm || (month === sm && day >= sd);
+ const beforeEnd = month < em || (month === em && day <= ed);
+ // A non-wrapping window is a simple AND; a year-wrapping window is an OR (after-start OR
+ // before-end), since the valid range spans the Dec→Jan seam.
+ return holiday.wrapsYear ? afterStart || beforeEnd : afterStart && beforeEnd;
+}
+
+// Resolve the active holiday for a date, or null. First match wins (HOLIDAYS is ordered most-
+// specific first so New Year beats the broader winter-holidays week on Dec 31). Accepts any
+// value with `.getMonth()` / `.getDate()`; a non-Date returns null (no holiday).
+export function resolveHoliday(date) {
+ if (!date || typeof date.getMonth !== 'function' || typeof date.getDate !== 'function') {
+ return null;
+ }
+ const month = date.getMonth() + 1; // getMonth() is 0-based
+ const day = date.getDate();
+ for (const h of HOLIDAYS) {
+ if (inHolidayWindow(month, day, h)) return h;
+ }
+ return null;
+}
+
+// Resolve the active broad season for a date. Returns the winter season as a safe default for a
+// non-Date input so the city always has a theme.
+export function resolveSeason(date) {
+ if (!date || typeof date.getMonth !== 'function') return SEASONS.winter;
+ return SEASONS[seasonForMonth(date.getMonth() + 1)];
+}
+
+// Place `count` decorations around the city ring, seeded by the theme id so the scatter is
+// stable per-theme but differs between themes. Decorations alternate slightly in radius so the
+// ring doesn't read as a perfect circle.
+export function placeDecorations(themeId, count = SEASONAL_DECOR.count) {
+ const decorations = [];
+ for (let i = 0; i < count; i += 1) {
+ const seed = hashString(`${themeId}-${i}`);
+ const angle = (i / count) * Math.PI * 2 + (seed % 30) / 100; // even spread + small jitter
+ const radius = SEASONAL_DECOR.ringRadius + ((seed >> 3) % 12) - 6; // ±6 radial jitter
+ const x = Math.cos(angle) * radius;
+ const z = Math.sin(angle) * radius;
+ decorations.push({
+ id: `${themeId}-decor-${i}`,
+ position: [Number(x.toFixed(3)), SEASONAL_DECOR.ringY, Number(z.toFixed(3))],
+ // Per-decoration phase so a shared shimmer driver can offset each one.
+ phase: (seed % 100) / 100,
+ });
+ }
+ return decorations;
+}
+
+// Full derived view-model for the seasonal-decor component. Inject the date so the season is
+// deterministic in tests. A holiday (when matched) supersedes the broad season for palette +
+// prop + label, but the season id is always carried so the component can still reason about the
+// time of year. There is always a theme → `hasData` is always true (the city is never undressed).
+export function computeSeasonalDecor(date) {
+ const season = resolveSeason(date);
+ const holiday = resolveHoliday(date);
+ const theme = holiday || season;
+ const decorations = placeDecorations(theme.id);
+
+ return {
+ season: season.id,
+ seasonLabel: season.label,
+ isHoliday: !!holiday,
+ themeId: theme.id,
+ label: theme.label,
+ color: theme.color,
+ accent: theme.accent,
+ prop: theme.prop,
+ decorations,
+ total: decorations.length,
+ hasData: true,
+ };
+}
diff --git a/client/src/utils/citySeasonalDecor.test.js b/client/src/utils/citySeasonalDecor.test.js
new file mode 100644
index 0000000000..efdde89308
--- /dev/null
+++ b/client/src/utils/citySeasonalDecor.test.js
@@ -0,0 +1,119 @@
+import { describe, it, expect } from 'vitest';
+import {
+ SEASONAL_DECOR,
+ SEASONS,
+ HOLIDAYS,
+ resolveSeason,
+ resolveHoliday,
+ placeDecorations,
+ computeSeasonalDecor,
+} from './citySeasonalDecor';
+
+// Build a Date for a fixed (month, day) — month is 1-based here for readability.
+const on = (month, day) => new Date(2025, month - 1, day, 12, 0, 0);
+
+describe('resolveSeason', () => {
+ it('maps months to the northern-hemisphere season', () => {
+ expect(resolveSeason(on(1, 15)).id).toBe('winter');
+ expect(resolveSeason(on(2, 15)).id).toBe('winter');
+ expect(resolveSeason(on(4, 15)).id).toBe('spring');
+ expect(resolveSeason(on(7, 15)).id).toBe('summer');
+ expect(resolveSeason(on(10, 15)).id).toBe('autumn');
+ expect(resolveSeason(on(12, 15)).id).toBe('winter');
+ });
+
+ it('defaults to winter for a non-Date input (city is never undressed)', () => {
+ expect(resolveSeason(null).id).toBe('winter');
+ expect(resolveSeason(undefined).id).toBe('winter');
+ expect(resolveSeason('nope').id).toBe('winter');
+ });
+});
+
+describe('resolveHoliday', () => {
+ it('matches a non-wrapping window inclusively', () => {
+ expect(resolveHoliday(on(10, 25))?.id).toBe('halloween');
+ expect(resolveHoliday(on(10, 31))?.id).toBe('halloween');
+ expect(resolveHoliday(on(10, 24))).toBeNull(); // day before the window
+ expect(resolveHoliday(on(11, 1))).toBeNull(); // day after
+ });
+
+ it('matches a year-wrapping window across the Dec→Jan seam', () => {
+ expect(resolveHoliday(on(12, 31))?.id).toBe('new-year');
+ expect(resolveHoliday(on(1, 1))?.id).toBe('new-year');
+ expect(resolveHoliday(on(1, 2))).toBeNull(); // out of the New Year window
+ });
+
+ it('lets a more-specific window win (New Year over winter-holidays on Dec 31)', () => {
+ // Dec 31 is inside the winter-holidays season feel, but New Year is listed first.
+ expect(resolveHoliday(on(12, 31))?.id).toBe('new-year');
+ // Dec 25 is only inside winter-holidays.
+ expect(resolveHoliday(on(12, 25))?.id).toBe('winter-holidays');
+ });
+
+ it('returns null when no holiday is active or input is not a Date', () => {
+ expect(resolveHoliday(on(2, 14))).toBeNull();
+ expect(resolveHoliday(null)).toBeNull();
+ expect(resolveHoliday('nope')).toBeNull();
+ });
+
+ it('every holiday window has a corresponding season (sanity on the table)', () => {
+ for (const h of HOLIDAYS) {
+ expect(typeof h.color).toBe('string');
+ expect(typeof h.label).toBe('string');
+ }
+ });
+});
+
+describe('placeDecorations', () => {
+ it('places the configured count by default', () => {
+ expect(placeDecorations('winter')).toHaveLength(SEASONAL_DECOR.count);
+ });
+
+ it('is deterministic for a given theme id (stable across calls)', () => {
+ expect(placeDecorations('summer')).toEqual(placeDecorations('summer'));
+ });
+
+ it('differs between theme ids', () => {
+ const a = placeDecorations('winter');
+ const b = placeDecorations('halloween');
+ expect(a[0].position).not.toEqual(b[0].position);
+ });
+
+ it('each decoration carries an id, a 3-tuple position, and a 0..1 phase', () => {
+ for (const d of placeDecorations('autumn')) {
+ expect(typeof d.id).toBe('string');
+ expect(d.position).toHaveLength(3);
+ expect(d.phase).toBeGreaterThanOrEqual(0);
+ expect(d.phase).toBeLessThanOrEqual(1);
+ }
+ });
+});
+
+describe('computeSeasonalDecor', () => {
+ it('always returns a theme (hasData is always true — the city is never undressed)', () => {
+ expect(computeSeasonalDecor(on(2, 14)).hasData).toBe(true);
+ expect(computeSeasonalDecor(null).hasData).toBe(true);
+ });
+
+ it('uses the season when no holiday is active', () => {
+ const vm = computeSeasonalDecor(on(7, 15)); // summer, no holiday
+ expect(vm.isHoliday).toBe(false);
+ expect(vm.themeId).toBe('summer');
+ expect(vm.label).toBe(SEASONS.summer.label);
+ expect(vm.season).toBe('summer');
+ });
+
+ it('overrides the season palette with a holiday when one is active', () => {
+ const vm = computeSeasonalDecor(on(10, 31)); // Halloween, season autumn
+ expect(vm.isHoliday).toBe(true);
+ expect(vm.themeId).toBe('halloween');
+ expect(vm.season).toBe('autumn'); // season still carried
+ expect(vm.color).toBe(HOLIDAYS.find((h) => h.id === 'halloween').color);
+ });
+
+ it('places one decoration per configured slot', () => {
+ const vm = computeSeasonalDecor(on(4, 15));
+ expect(vm.total).toBe(SEASONAL_DECOR.count);
+ expect(vm.decorations).toHaveLength(SEASONAL_DECOR.count);
+ });
+});