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

refactor([issue-1064]): recolor CyberCity in place, drop themeId remount

Adam Eivy021e90877fc9
diff --git a/client/src/components/city/CityBillboards.jsx b/client/src/components/city/CityBillboards.jsx
index 3a5a7fa76c..e310613bcb 100644
--- a/client/src/components/city/CityBillboards.jsx
+++ b/client/src/components/city/CityBillboards.jsx
@@ -1,4 +1,4 @@
-import { useRef, useMemo } from 'react';
+import { useRef, useMemo, useEffect } from 'react';
import { useFrame } from '@react-three/fiber';
import { Text } from '@react-three/drei';
import * as THREE from 'three';
@@ -52,6 +52,14 @@ function Billboard({ position, rotation, messages, color, width = 3.5, height =
const colorVec = useMemo(() => new THREE.Color(color), [color]);
+ // The scan-overlay shader material persists across a theme switch (no more full-scene
+ // remount), so push the new accent into its uColor uniform imperatively — the inline
+ // `uniforms` object isn't re-uploaded to an already-built material on re-render. The
+ // other billboard surfaces use declarative `color={color}` props, which R3F reconciles.
+ useEffect(() => {
+ if (scanRef.current) scanRef.current.uniforms.uColor.value.copy(colorVec);
+ }, [colorVec]);
+
useFrame(({ clock }) => {
if (!groupRef.current) return;
const t = clock.getElapsedTime();
diff --git a/client/src/components/city/CityVolumetricLights.jsx b/client/src/components/city/CityVolumetricLights.jsx
index 19e0622cd0..8cee6627eb 100644
--- a/client/src/components/city/CityVolumetricLights.jsx
+++ b/client/src/components/city/CityVolumetricLights.jsx
@@ -1,4 +1,4 @@
-import { useRef, useMemo } from 'react';
+import { useRef, useMemo, useEffect } from 'react';
import { useFrame } from '@react-three/fiber';
import * as THREE from 'three';
import { cityDayMix } from './cityConstants';
@@ -53,6 +53,16 @@ function LightBeam({ position, color, height = 15, radius = 2, intensity = 1, ph
const colorVec = useMemo(() => new THREE.Color(color), [color]);
+ // The shader material persists across a theme switch (no more full-scene remount),
+ // so push the new accent/intensity into its uniforms imperatively — re-rendering
+ // with a new `uniforms` object does not re-upload them to an already-built material.
+ useEffect(() => {
+ const mat = matRef.current;
+ if (!mat) return;
+ mat.uniforms.uColor.value.copy(colorVec);
+ mat.uniforms.uIntensity.value = intensity;
+ }, [colorVec, intensity]);
+
return (
<group position={position}>
<mesh geometry={coneGeom} position={[0, height / 2, 0]}>
diff --git a/client/src/pages/CyberCity.jsx b/client/src/pages/CyberCity.jsx
index ea0eb9f706..8ccdc308f2 100644
--- a/client/src/pages/CyberCity.jsx
+++ b/client/src/pages/CyberCity.jsx
@@ -321,14 +321,15 @@ function CyberCityInner() {
<CityPaletteProvider palette={cityPalette}>
<div className="relative w-full h-full cybercity-themed" style={{ background: sceneBackground, isolation: 'isolate' }}>
<CityScene
- // Remount the whole scene subtree on a theme switch so the ~8 components that
- // cache themed neon colors in useMemo / GPU uniforms (CityGround, CitySky,
- // CityBillboards, CityVolumetricLights, CityTraffic, CityLandscape, …) pick up
- // the new palette. The during-render singleton mutation is gone; the remount
- // remains as the (rare, user-initiated) refresh path. Threading the palette
- // into every cached dep array + imperative uniform update is the separable,
- // riskier half — tracked as a follow-up issue.
- key={cityPalette.themeId}
+ // A theme switch recolors the live scene in place — NO full-scene remount.
+ // Every themed surface either reads the palette fresh each render (declarative
+ // `color=` props, palette helper fns) or carries the palette value in its
+ // useMemo deps so it rebuilds on a new palette object (CityGround, CityLandscape,
+ // CityTraffic, CityNeonSigns, …). The two persistent GPU shader materials whose
+ // uniforms are set once at construction (CityBillboards scan overlay,
+ // CityVolumetricLights cones) push the new accent into their uColor uniform
+ // imperatively, mirroring CitySky's per-frame uniform updates. Dropping the old
+ // `key={cityPalette.themeId}` avoids the jarring full-scene rebuild flash.
palette={cityPalette}
background={sceneBackground}
apps={v('apps', apps)}