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([issue-824]): tick seasonal/egg themes over day boundaries and offset bobs per item

[._.]/ Adam Eivyff99d96afce6
diff --git a/client/src/components/city/CityEasterEggs.jsx b/client/src/components/city/CityEasterEggs.jsx
index bec24a91d0..915a2b026c 100644
--- a/client/src/components/city/CityEasterEggs.jsx
+++ b/client/src/components/city/CityEasterEggs.jsx
@@ -1,6 +1,7 @@
import { useMemo, useRef } from 'react';
import { useFrame } from '@react-three/fiber';
import { Text } from '@react-three/drei';
+import { useTimeTick } from '../../hooks/useTimeTick';
import { PIXEL_FONT_URL } from './cityConstants';
import { computeEasterEggs, EGGS } from '../../utils/cityEasterEggs';
@@ -8,59 +9,62 @@ import { computeEasterEggs, EGGS } from '../../utils/cityEasterEggs';
// 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;
+// (each on its own phase offset) gated on the quality dial (mirrors CityArtifacts).
+function Egg({ egg, animate }) {
+ const { color, label, position, phase } = egg;
const s = EGGS.size;
+ const ref = useRef();
+
+ // Per-egg twinkle/bob, offset by the descriptor's stable phase so eggs don't pulse in lockstep.
+ useFrame(({ clock }) => {
+ if (!animate || !ref.current) return;
+ const t = clock.getElapsedTime();
+ const pulse = (Math.sin(t * 2 + phase * Math.PI * 2) + 1) / 2; // 0..1, faster = twinkly
+ ref.current.position.y = pulse * 0.4;
+ ref.current.rotation.y = t * 0.3;
+ });
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>
+ <group ref={ref}>
+ <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} />
+ <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>
+ {/* 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>
</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.
+ // Re-resolve unlocked eggs as real time advances so calendar eggs (e.g. April 1) turn over at the
+ // day boundary while CyberCity stays open — an hourly tick is plenty and battery-friendly (shared
+ // singleton timer, paused while hidden). An explicit `date` prop still wins for callers/tests.
+ const tick = useTimeTick(3600000);
const cluster = useMemo(
- () => computeEasterEggs({ date: date ?? new Date(), character, goals, productivityData }),
- [date, character, goals, productivityData],
+ () => computeEasterEggs({ date: date ?? new Date(tick), character, goals, productivityData }),
+ [date, tick, 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>
+ {eggs.map((egg) => (
+ <Egg key={egg.id} egg={egg} animate={animate} />
+ ))}
{/* 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}>
diff --git a/client/src/components/city/CitySeasonalDecor.jsx b/client/src/components/city/CitySeasonalDecor.jsx
index 97b582ca56..fd3f58e908 100644
--- a/client/src/components/city/CitySeasonalDecor.jsx
+++ b/client/src/components/city/CitySeasonalDecor.jsx
@@ -1,68 +1,73 @@
import { useMemo, useRef } from 'react';
import { useFrame } from '@react-three/fiber';
import { Text } from '@react-three/drei';
+import { useTimeTick } from '../../hooks/useTimeTick';
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;
+// props around the city's edge. The theme is resolved from a date — a holiday window
+// (New Year, Halloween, …) overrides the broad season. Props bob/shimmer (each on its own
+// phase offset) gated on the quality dial (mirrors CityArtifacts / CityGoalMonuments).
+function Decoration({ decoration, color, accent, animate }) {
+ const { position, phase } = decoration;
const s = SEASONAL_DECOR.propSize;
+ const ref = useRef();
+
+ // Per-decoration bob, offset by the descriptor's stable phase so the ring doesn't pulse in
+ // lockstep. Gated on the quality dial; the static glow remains when animation is off.
+ useFrame(({ clock }) => {
+ if (!animate || !ref.current) return;
+ const pulse = (Math.sin(clock.getElapsedTime() * 1.1 + phase * Math.PI * 2) + 1) / 2; // 0..1
+ ref.current.scale.setScalar(1 + pulse * 0.06);
+ ref.current.position.y = pulse * 0.6;
+ });
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>
+ <group ref={ref}>
+ {/* 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>
+ {/* 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} />
+ <pointLight position={[0, s * 1.2, 0]} color={accent} intensity={0.7} distance={9} />
+ </group>
</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();
+ // Re-resolve the theme as real time advances so the dressing turns over at midnight / a holiday
+ // boundary while CyberCity stays open — an hourly tick is plenty for a calendar-day theme and is
+ // battery-friendly (shared singleton timer, paused while the tab is hidden). An explicit `date`
+ // prop still wins for callers/tests; the pure helper is what the unit tests exercise directly.
+ const tick = useTimeTick(3600000);
+ const decor = useMemo(
+ () => computeSeasonalDecor(date ?? new Date(tick)),
+ [date, tick],
+ );
- // Honor the quality dial: drop the bob/shimmer on the lowest preset, but keep the static glow
- // so the seasonal dressing stays visible.
+ // Honor the quality dial: drop the bob/shimmer on the lowest preset, keep the static glow.
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;
+ const { decorations, color, accent, label, base } = decor;
return (
<group>
- <group ref={groupRef}>
- {decorations.map((decoration) => (
- <Decoration key={decoration.id} decoration={decoration} color={color} accent={accent} />
- ))}
- </group>
+ {decorations.map((decoration) => (
+ <Decoration key={decoration.id} decoration={decoration} color={color} accent={accent} animate={animate} />
+ ))}
{/* 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}>
diff --git a/client/src/utils/citySeasonalDecor.js b/client/src/utils/citySeasonalDecor.js
index 746554b66f..c0900fdd10 100644
--- a/client/src/utils/citySeasonalDecor.js
+++ b/client/src/utils/citySeasonalDecor.js
@@ -17,6 +17,7 @@ import { hashString } from './hashString';
// building cluster and the achievement/goal districts. Deterministic seeded scatter so the
// dressing doesn't reshuffle across refetches.
export const SEASONAL_DECOR = {
+ base: [0, 0, 0], // ring is centered on the city origin; banner anchors here
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
@@ -160,6 +161,7 @@ export function computeSeasonalDecor(date) {
const decorations = placeDecorations(theme.id);
return {
+ base: SEASONAL_DECOR.base,
season: season.id,
seasonLabel: season.label,
isHoliday: !!holiday,
diff --git a/client/src/utils/citySeasonalDecor.test.js b/client/src/utils/citySeasonalDecor.test.js
index efdde89308..52ec832484 100644
--- a/client/src/utils/citySeasonalDecor.test.js
+++ b/client/src/utils/citySeasonalDecor.test.js
@@ -56,10 +56,20 @@ describe('resolveHoliday', () => {
expect(resolveHoliday('nope')).toBeNull();
});
- it('every holiday window has a corresponding season (sanity on the table)', () => {
+ it('every holiday entry has well-formed window tuples + palette fields', () => {
for (const h of HOLIDAYS) {
expect(typeof h.color).toBe('string');
+ expect(typeof h.accent).toBe('string');
expect(typeof h.label).toBe('string');
+ expect(typeof h.prop).toBe('string');
+ for (const tuple of [h.start, h.end]) {
+ expect(tuple).toHaveLength(2);
+ const [month, day] = tuple;
+ expect(month).toBeGreaterThanOrEqual(1);
+ expect(month).toBeLessThanOrEqual(12);
+ expect(day).toBeGreaterThanOrEqual(1);
+ expect(day).toBeLessThanOrEqual(31);
+ }
}
});
});
@@ -111,9 +121,10 @@ describe('computeSeasonalDecor', () => {
expect(vm.color).toBe(HOLIDAYS.find((h) => h.id === 'halloween').color);
});
- it('places one decoration per configured slot', () => {
+ it('places one decoration per configured slot and carries the ring base', () => {
const vm = computeSeasonalDecor(on(4, 15));
expect(vm.total).toBe(SEASONAL_DECOR.count);
expect(vm.decorations).toHaveLength(SEASONAL_DECOR.count);
+ expect(vm.base).toEqual(SEASONAL_DECOR.base);
});
});