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: wrap OpenWorld health belts and cut grass/particle frame cost

[._.]/ Adam Eivy38ace41711dd
diff --git a/client/src/components/openworld/Building.jsx b/client/src/components/openworld/Building.jsx
index a5d6414879..f8a33421e2 100644
--- a/client/src/components/openworld/Building.jsx
+++ b/client/src/components/openworld/Building.jsx
@@ -9,7 +9,7 @@ import BuildingHologram from './BuildingHologram';
import BuildingWindows from './BuildingWindows';
import { computeRooftopKit } from '../../utils/openWorldRooftops';
import { buildingHasInteriorWindows } from '../../utils/openWorldInteriorWindows';
-import { computeAppMetrics, cpuTone } from '../../utils/openWorldAppMetrics';
+import { computeAppMetrics, buildingSignalTone } from '../../utils/openWorldAppMetrics';
// Rooftop fixture geometry/materials are module-scope singletons shared by every
// building — fixtures are tiny set dressing, so they keep fixed colors (the antenna
@@ -23,6 +23,9 @@ const ROOF_GEOMS = {
ac: new THREE.BoxGeometry(0.4, 0.22, 0.34),
dish: new THREE.SphereGeometry(0.24, 10, 6, 0, Math.PI * 2, 0, Math.PI / 2),
};
+const CONTACT_SHADOW_GEOM = new THREE.CircleGeometry(1, 16);
+const SMOKE_GEOM = new THREE.SphereGeometry(0.2, 6, 6);
+const SPARK_GEOM = new THREE.SphereGeometry(0.03, 4, 4);
// 0–3 deterministic fixtures (antenna/tank/AC/dish) on the roof, seeded by app name —
// the same determinism as the window textures, so a building keeps its roof forever.
@@ -471,62 +474,76 @@ function LowPolyFacade({ width, depth, height, bodyColor, edgeColor, dimMul, sur
);
}
-// Always-visible façade health indicator (Roadmap 1.1) - readable at any distance
-function BuildingHealthStrip({ width, height, depth, status, metrics, pm2Status, dimMul = 1, dayMix = 0, playback = false }) {
- const isPm2Errored = Object.values(pm2Status || {}).some((p) => p?.status === 'errored' || p?.status === 'error');
- const isErrored = status === 'errored' || isPm2Errored || (!playback && metrics?.unstableRestarts > 0);
- const isHot = !playback && metrics?.hasMetrics && cpuTone(metrics.cpuPercent) === 'hot';
- const isBusy = !playback && metrics?.hasMetrics && cpuTone(metrics.cpuPercent) === 'busy';
-
- const toneColor = isErrored
- ? '#f43f5e'
- : isHot
- ? '#ef4444'
- : isBusy
- ? '#f59e0b'
- : status === 'online'
- ? '#10b981'
- : '#64748b';
+// Always-visible health belt (Roadmap 1.1) — a thin status-colored band wrapping all
+// four façades so the LED reads from any orbit angle, not just the labeled front.
+function HealthBandMeshes({ width, height, depth, color, dimMul, opacity, bandRef }) {
+ const y = Math.max(0.4, height * 0.72);
+ return (
+ <group position={[0, y, 0]}>
+ <mesh>
+ <boxGeometry args={[width + 0.08, 0.07, depth + 0.08]} />
+ <meshBasicMaterial color="#0f172a" transparent opacity={0.78 * dimMul} />
+ </mesh>
+ <mesh ref={bandRef}>
+ <boxGeometry args={[width + 0.05, 0.038, depth + 0.05]} />
+ <meshBasicMaterial color={color} transparent opacity={opacity} toneMapped={false} />
+ </mesh>
+ </group>
+ );
+}
+function PulsingHealthBand({ width, height, depth, color, tone, dimMul }) {
const ref = useRef();
useFrame(({ clock }) => {
if (!ref.current) return;
const t = clock.getElapsedTime();
- if (isHot || isErrored) {
- ref.current.material.opacity = (0.55 + Math.sin(t * 6) * 0.35) * dimMul;
- } else if (isBusy) {
- ref.current.material.opacity = (0.6 + Math.sin(t * 2.5) * 0.2) * dimMul;
- } else {
- ref.current.material.opacity = (0.65 - dayMix * 0.2) * dimMul;
- }
+ const pulse = tone === 'busy'
+ ? 0.6 + Math.sin(t * 2.5) * 0.2
+ : 0.55 + Math.sin(t * 6) * 0.35;
+ ref.current.material.opacity = pulse * dimMul;
});
-
- const barWidth = Math.min(width * 0.65, 1.2);
- const barY = Math.max(0.4, height * 0.76);
-
return (
- <group position={[0, barY, depth / 2 + 0.03]}>
- {/* Background dark casing */}
- <mesh position={[0, 0, 0]}>
- <boxGeometry args={[barWidth + 0.06, 0.06, 0.015]} />
- <meshBasicMaterial color="#0f172a" transparent opacity={0.8 * dimMul} />
- </mesh>
- {/* LED active meter strip */}
- <mesh ref={ref} position={[0, 0, 0.01]}>
- <boxGeometry args={[barWidth, 0.035, 0.015]} />
- <meshBasicMaterial color={toneColor} transparent opacity={0.7 * dimMul} toneMapped={false} />
- </mesh>
- </group>
+ <HealthBandMeshes
+ width={width}
+ height={height}
+ depth={depth}
+ color={color}
+ dimMul={dimMul}
+ opacity={0.7 * dimMul}
+ bandRef={ref}
+ />
);
}
-// Stress smoke / sparks (Roadmap 1.2) - rises from rooftop when CPU is hot or app has errored
-function StressEffects({ height, metrics, status, pm2Status, dimMul = 1, playback = false }) {
- if (playback) return null;
+function BuildingHealthBand({ width, height, depth, color, tone = 'idle', pulsing = false, dimMul = 1, dayMix = 0 }) {
+ if (pulsing) {
+ return (
+ <PulsingHealthBand
+ width={width}
+ height={height}
+ depth={depth}
+ color={color}
+ tone={tone}
+ dimMul={dimMul}
+ />
+ );
+ }
+ return (
+ <HealthBandMeshes
+ width={width}
+ height={height}
+ depth={depth}
+ color={color}
+ dimMul={dimMul}
+ opacity={(0.62 - dayMix * 0.18) * dimMul}
+ />
+ );
+}
- const isPm2Errored = Object.values(pm2Status || {}).some((p) => p?.status === 'errored' || p?.status === 'error');
- const isHot = metrics?.hasMetrics && cpuTone(metrics.cpuPercent) === 'hot';
- const isErrored = status === 'errored' || isPm2Errored || (metrics?.unstableRestarts > 0);
+// Stress smoke / sparks (Roadmap 1.2) — rooftop plume for a hot CPU, sparks for a crash.
+// Parent mounts this only when smoke or sparks is actually on, so healthy buildings pay
+// no extra useFrame. Hooks always run (no early return) to satisfy the rules of hooks.
+function StressEffects({ height, smoke = false, sparks = false, dimMul = 1 }) {
const smokeRef = useRef();
const sparksRef = useRef();
@@ -539,9 +556,7 @@ function StressEffects({ height, metrics, status, pm2Status, dimMul = 1, playbac
puff.position.x = Math.sin(t * 1.5 + i * 2) * 0.15 * age;
puff.position.z = Math.cos(t * 1.2 + i * 2) * 0.15 * age;
puff.scale.setScalar(0.08 + age * 0.22);
- if (puff.material) {
- puff.material.opacity = (1 - age) * 0.45 * dimMul;
- }
+ if (puff.material) puff.material.opacity = (1 - age) * 0.45 * dimMul;
});
}
if (sparksRef.current) {
@@ -550,34 +565,26 @@ function StressEffects({ height, metrics, status, pm2Status, dimMul = 1, playbac
spark.position.y = age * 0.9;
spark.position.x = Math.sin(t * 8 + i * 4) * 0.25;
spark.position.z = Math.cos(t * 7 + i * 3) * 0.25;
- if (spark.material) {
- spark.material.opacity = (1 - age) * 0.8 * dimMul;
- }
+ if (spark.material) spark.material.opacity = (1 - age) * 0.8 * dimMul;
});
}
});
- if (!isHot && !isErrored) return null;
-
return (
<group position={[0, height + 0.1, 0]}>
- {/* Smoke puffs for persistent CPU spike */}
- {isHot && (
+ {smoke && (
<group ref={smokeRef}>
{[0, 1, 2].map((i) => (
- <mesh key={`smoke-${i}`}>
- <sphereGeometry args={[0.2, 6, 6]} />
+ <mesh key={`smoke-${i}`} geometry={SMOKE_GEOM}>
<meshBasicMaterial color="#64748b" transparent opacity={0.3} depthWrite={false} />
</mesh>
))}
</group>
)}
- {/* Sparks for recent crash / errored app */}
- {isErrored && (
+ {sparks && (
<group ref={sparksRef}>
{[0, 1, 2, 3].map((i) => (
- <mesh key={`spark-${i}`}>
- <sphereGeometry args={[0.03, 4, 4]} />
+ <mesh key={`spark-${i}`} geometry={SPARK_GEOM}>
<meshBasicMaterial color="#f59e0b" transparent opacity={0.8} toneMapped={false} depthWrite={false} />
</mesh>
))}
@@ -648,6 +655,15 @@ export default function Building({ app, position, agentCount, onClick, playSfx,
}, [app.name, app.id]);
const metrics = useMemo(() => computeAppMetrics(app), [app]);
+ const signal = useMemo(
+ () => buildingSignalTone({
+ status: app.overallStatus,
+ metrics,
+ pm2Status: app.pm2Status,
+ playback,
+ }),
+ [app.overallStatus, metrics, app.pm2Status, playback]
+ );
const boxGeom = useMemo(() => new THREE.BoxGeometry(width, height, depth), [width, height, depth]);
const edgesGeom = useMemo(() => new THREE.EdgesGeometry(boxGeom), [boxGeom]);
@@ -899,30 +915,27 @@ export default function Building({ app, position, agentCount, onClick, playSfx,
{displayName}
</OpenWorldLabel>
- {/* Always-visible façade health indicator (Roadmap 1.1) */}
+ {/* Always-visible wrapping health belt (Roadmap 1.1) */}
{!app.archived && (
- <BuildingHealthStrip
+ <BuildingHealthBand
width={width}
height={height}
depth={depth}
- status={app.overallStatus}
- metrics={metrics}
- pm2Status={app.pm2Status}
+ color={signal.color}
+ tone={signal.tone}
+ pulsing={signal.pulsing}
dimMul={dimMul}
dayMix={dayMix}
- playback={playback}
/>
)}
{/* Stress smoke / sparks on rooftop when CPU is hot or crashed (Roadmap 1.2) */}
- {!app.archived && (
+ {!app.archived && (signal.smoke || signal.sparks) && (
<StressEffects
height={height}
- metrics={metrics}
- status={app.overallStatus}
- pm2Status={app.pm2Status}
+ smoke={signal.smoke}
+ sparks={signal.sparks}
dimMul={dimMul}
- playback={playback}
/>
)}
@@ -949,6 +962,18 @@ export default function Building({ app, position, agentCount, onClick, playSfx,
</mesh>
)}
+ {/* Daytime contact shadow — grounds the tower on the meadow so it doesn't float. */}
+ {daytime && !app.archived && (
+ <mesh
+ geometry={CONTACT_SHADOW_GEOM}
+ rotation={[-Math.PI / 2, 0, 0]}
+ position={[0, 0.008, 0]}
+ scale={[Math.max(width, depth) * 0.82, Math.max(width, depth) * 0.82, 1]}
+ >
+ <meshBasicMaterial color="#0b1220" transparent opacity={0.26 * dimMul} depthWrite={false} />
+ </mesh>
+ )}
+
{/* Neon ground line accents (night only) */}
{!app.archived && showNightFx && (
<>
diff --git a/client/src/components/openworld/Building.test.jsx b/client/src/components/openworld/Building.test.jsx
index 09df78324e..a85bb886d4 100644
--- a/client/src/components/openworld/Building.test.jsx
+++ b/client/src/components/openworld/Building.test.jsx
@@ -108,4 +108,16 @@ describe('Building component', () => {
);
expect(container).toBeTruthy();
});
+
+ it('does not mount rooftop stress meshes for a calm healthy app', () => {
+ const { container } = render(
+ <Building
+ app={mockApp}
+ position={{ x: 0, z: 0 }}
+ agentCount={0}
+ />
+ );
+ const meshes = container.getElementsByTagName('mesh');
+ expect(meshes.length).toBeGreaterThan(0);
+ });
});
diff --git a/client/src/components/openworld/OpenWorldGrass.jsx b/client/src/components/openworld/OpenWorldGrass.jsx
index 6eed0e6673..054f0271e8 100644
--- a/client/src/components/openworld/OpenWorldGrass.jsx
+++ b/client/src/components/openworld/OpenWorldGrass.jsx
@@ -80,12 +80,16 @@ export default function OpenWorldGrass({ settings }) {
useLayoutEffect(() => {
writeMatrices(ref, blades);
+ if (typeof ref.current?.computeBoundingSphere === 'function') {
+ ref.current.computeBoundingSphere();
+ }
}, [blades, lowPoly]);
const onBeforeCompile = useMemo(() => (shader) => {
shader.uniforms.uGrassTime = timeUniformRef.current;
shader.vertexShader = `
uniform float uGrassTime;
+ varying float vBladeHeight;
` + shader.vertexShader;
shader.vertexShader = shader.vertexShader.replace(
'#include <begin_vertex>',
@@ -93,18 +97,29 @@ export default function OpenWorldGrass({ settings }) {
#include <begin_vertex>
// Cone geometry height 1 is centered at y=0, so base is at -0.5 and tip is at +0.5.
float bladeHeightNorm = clamp(position.y + 0.5, 0.0, 1.0);
+ vBladeHeight = bladeHeightNorm;
float sway = bladeHeightNorm * bladeHeightNorm;
-
- // Instance world position from 4th column of instanceMatrix
+
vec3 instPos = vec3(instanceMatrix[3][0], instanceMatrix[3][1], instanceMatrix[3][2]);
-
float gust = sin(uGrassTime * 0.75 + instPos.x * 0.05 + instPos.z * 0.04) * 0.32
+ sin(uGrassTime * 1.6 + instPos.x * 0.12) * 0.1;
-
+
transformed.x += gust * 0.38 * sway;
transformed.z += gust * 0.62 * sway;
`
);
+ shader.fragmentShader = `
+ varying float vBladeHeight;
+ ` + shader.fragmentShader;
+ shader.fragmentShader = shader.fragmentShader.replace(
+ '#include <color_fragment>',
+ `
+ #include <color_fragment>
+ vec3 bladeBase = diffuseColor.rgb * 0.52;
+ vec3 bladeTip = diffuseColor.rgb * 1.28 + vec3(0.06, 0.10, 0.01);
+ diffuseColor.rgb = mix(bladeBase, bladeTip, vBladeHeight);
+ `
+ );
}, []);
useFrame(({ clock }) => {
@@ -116,13 +131,14 @@ export default function OpenWorldGrass({ settings }) {
if (!lowPoly || blades.length === 0) return null;
return (
- <instancedMesh key={blades.length} ref={ref} args={[undefined, undefined, blades.length]} frustumCulled={false}>
+ <instancedMesh key={blades.length} ref={ref} args={[undefined, undefined, blades.length]}>
<coneGeometry args={[0.12, 1, 3]} />
<meshStandardMaterial
{...surface}
color={grassColor}
roughness={1}
metalness={0}
+ side={THREE.DoubleSide}
onBeforeCompile={onBeforeCompile}
/>
</instancedMesh>
diff --git a/client/src/components/openworld/OpenWorldParticles.jsx b/client/src/components/openworld/OpenWorldParticles.jsx
index 73b1d8d749..0a761cd4e6 100644
--- a/client/src/components/openworld/OpenWorldParticles.jsx
+++ b/client/src/components/openworld/OpenWorldParticles.jsx
@@ -2,6 +2,21 @@ import { Sparkles } from '@react-three/drei';
import { openWorldDayMix } from './openWorldConstants';
import { useOpenWorldPalette } from './OpenWorldPaletteContext';
+const NIGHT_LAYERS = [
+ { count: 120, scale: [50, 20, 50], size: 1.8, speed: 0.3, opacity: 0.3 },
+ { count: 50, scale: [40, 15, 40], size: 1.2, speed: 0.25, opacity: 0.2, color: '#ec4899' },
+ { count: 35, scale: [45, 15, 45], size: 1, speed: 0.2, opacity: 0.15, color: '#8b5cf6' },
+ { count: 25, scale: [35, 5, 35], size: 0.8, speed: 0.15, opacity: 0.12, color: '#f97316', position: [0, 2, 0] },
+ { count: 30, scale: [50, 8, 50], size: 0.6, speed: 0.1, opacity: 0.1, color: '#3b82f6', position: [0, 15, 0] },
+];
+
+function nightLayerCount(tier) {
+ if (tier === 'low') return 1;
+ if (tier === 'medium') return 2;
+ if (tier === 'ultra') return 5;
+ return 3;
+}
+
export default function OpenWorldParticles({ settings }) {
const { particles, lowPoly } = useOpenWorldPalette();
const density = settings?.particleDensity ?? 1.0;
@@ -11,12 +26,15 @@ export default function OpenWorldParticles({ settings }) {
if (density <= 0) return null;
+ const layers = NIGHT_LAYERS.slice(0, nightLayerCount(settings?.effectiveTier));
+ const pollenCount = settings?.effectiveTier === 'low' ? 28 : (lowPoly ? 70 : 40);
+
return (
<>
{/* Daylight meadow motes: soft golden pollen drifting in the sunlit breeze */}
{dayMix > 0.1 && (
<Sparkles
- count={scale(lowPoly ? 70 : 40)}
+ count={scale(pollenCount)}
scale={[60, 16, 60]}
size={1.4}
speed={0.2}
@@ -26,53 +44,20 @@ export default function OpenWorldParticles({ settings }) {
/>
)}
- {/* Night-time neon atmospheric dust */}
- {dayFade > 0.05 && (
- <>
- <Sparkles
- count={scale(120)}
- scale={[50, 20, 50]}
- size={1.8}
- speed={0.3}
- opacity={0.3 * dayFade}
- color={particles}
- />
- <Sparkles
- count={scale(50)}
- scale={[40, 15, 40]}
- size={1.2}
- speed={0.25}
- opacity={0.2 * dayFade}
- color="#ec4899"
- />
- <Sparkles
- count={scale(35)}
- scale={[45, 15, 45]}
- size={1}
- speed={0.2}
- opacity={0.15 * dayFade}
- color="#8b5cf6"
- />
- <Sparkles
- count={scale(25)}
- scale={[35, 5, 35]}
- size={0.8}
- speed={0.15}
- opacity={0.12 * dayFade}
- color="#f97316"
- position={[0, 2, 0]}
- />
- <Sparkles
- count={scale(30)}
- scale={[50, 8, 50]}
- size={0.6}
- speed={0.1}
- opacity={0.1 * dayFade}
- color="#3b82f6"
- position={[0, 15, 0]}
- />
- </>
- )}
+ {/* Night-time neon atmospheric dust — layer count follows the render tier so
+ a struggling GPU sheds sparkle systems before it sheds buildings. */}
+ {dayFade > 0.05 && layers.map((layer, i) => (
+ <Sparkles
+ key={i}
+ count={scale(layer.count)}
+ scale={layer.scale}
+ size={layer.size}
+ speed={layer.speed}
+ opacity={layer.opacity * dayFade}
+ color={layer.color ?? particles}
+ position={layer.position}
+ />
+ ))}
</>
);
}
diff --git a/client/src/components/openworld/OpenWorldParticles.test.jsx b/client/src/components/openworld/OpenWorldParticles.test.jsx
index 9f74d409af..3ceca55d23 100644
--- a/client/src/components/openworld/OpenWorldParticles.test.jsx
+++ b/client/src/components/openworld/OpenWorldParticles.test.jsx
@@ -26,4 +26,12 @@ describe('OpenWorldParticles', () => {
const sparkles = container.querySelectorAll('[data-testid="sparkles"]');
expect(sparkles.length).toBeGreaterThan(1);
});
+
+ it('keeps a single night sparkle system on the low render tier', () => {
+ const { container } = render(
+ <OpenWorldParticles settings={{ timeOfDay: 'sunset', effectiveTier: 'low' }} />
+ );
+ const sparkles = container.querySelectorAll('[data-testid="sparkles"]');
+ expect(sparkles.length).toBe(1);
+ });
});
diff --git a/client/src/components/openworld/OpenWorldStreetProps.jsx b/client/src/components/openworld/OpenWorldStreetProps.jsx
index 5fff26ba82..40dc8efc57 100644
--- a/client/src/components/openworld/OpenWorldStreetProps.jsx
+++ b/client/src/components/openworld/OpenWorldStreetProps.jsx
@@ -41,6 +41,9 @@ function writeMatrices(ref, placements, position, flat) {
if (ref.current.instanceMatrix) {
ref.current.instanceMatrix.needsUpdate = true;
}
+ if (typeof ref.current.computeBoundingSphere === 'function') {
+ ref.current.computeBoundingSphere();
+ }
}
const onSwayCompile = (shader) => {
@@ -68,7 +71,7 @@ function Instances({ placements, geometry, geometryArgs, position, flat = false,
}, [placements, position, flat]);
return (
- <instancedMesh ref={ref} args={[undefined, undefined, placements.length]} frustumCulled={false}>
+ <instancedMesh ref={ref} args={[undefined, undefined, placements.length]}>
{geometry === 'cylinder' && <cylinderGeometry args={geometryArgs} />}
{geometry === 'sphere' && <sphereGeometry args={geometryArgs} />}
{geometry === 'circle' && <circleGeometry args={geometryArgs} />}
diff --git a/client/src/utils/README.md b/client/src/utils/README.md
index 1ea82ff950..7b7c547c44 100644
--- a/client/src/utils/README.md
+++ b/client/src/utils/README.md
@@ -75,7 +75,7 @@ its tunable constants and placement helpers.
| `openWorldActivityHeatmap` | Calendar activity → per-tile heat levels (`computeActivityHeatmap`, `tileLevel`). |
| `openWorldAgentMotion` | Agent orbit/trail motion math (`computeAgentOrbit`, `computeAgentTrailPoints`, trail colors). |
| `openWorldAiCore` | AI-ops core: model tiers, beam thickness, and `computeAiCore` / `computeAiCoreBeams` from live AI status events. |
-| `openWorldAppMetrics` | Per-building live telemetry: aggregate an app's `pm2Status` CPU/memory/uptime/restarts into one snapshot (`computeAppMetrics`, `cpuTone`). |
+| `openWorldAppMetrics` | Per-building live telemetry: aggregate an app's `pm2Status` CPU/memory/uptime/restarts into one snapshot (`computeAppMetrics`, `cpuTone`, `hasPm2Error`, `buildingSignalTone` — façade LED / rooftop stress flags). |
| `openWorldArtifacts` | Earned-artifact milestones (level/goal/streak) → placed artifact descriptors (`computeArtifacts`). |
| `openWorldBackupVault` | Backup-vault health/alerting state and color (`computeBackupVault`, `vaultHealth`). |
| `openWorldChronotype` | Chronotype energy curve by hour → brightness/tempo modifiers (`computeChronotypeEnergy`). |
diff --git a/client/src/utils/openWorldAppMetrics.js b/client/src/utils/openWorldAppMetrics.js
index e8f57736df..327ba201b0 100644
--- a/client/src/utils/openWorldAppMetrics.js
+++ b/client/src/utils/openWorldAppMetrics.js
@@ -52,3 +52,38 @@ export function cpuTone(cpuPercent) {
if (cpuPercent >= 40) return 'busy';
return 'calm';
}
+
+const SIGNAL_COLORS = Object.freeze({
+ errored: '#f43f5e',
+ hot: '#ef4444',
+ busy: '#f59e0b',
+ online: '#10b981',
+ idle: '#64748b',
+});
+
+export function hasPm2Error(pm2Status) {
+ return Object.values(pm2Status || {}).some((p) => p?.status === 'errored' || p?.status === 'error');
+}
+
+/**
+ * Glanceable façade/rooftop signal for a building. Playback hides live CPU/restart
+ * atmosphere so a historical frame doesn't grow smoke from today's metrics; the
+ * snapshot's own `status` (and any PM2 error on that frame) still paints the LED.
+ */
+export function buildingSignalTone({ status, metrics, pm2Status, playback = false } = {}) {
+ const pm2Errored = hasPm2Error(pm2Status);
+ const errored = status === 'errored' || pm2Errored || (!playback && (metrics?.unstableRestarts || 0) > 0);
+ const cpu = !playback && metrics?.hasMetrics ? cpuTone(metrics.cpuPercent) : 'idle';
+ const hot = cpu === 'hot';
+ const busy = cpu === 'busy';
+ const tone = errored ? 'errored' : hot ? 'hot' : busy ? 'busy' : status === 'online' ? 'online' : 'idle';
+ // Playback keeps the snapshot LED color but drops live atmosphere (pulse/smoke/sparks)
+ // so a historical frame does not grow today's CPU plume.
+ return {
+ tone,
+ color: SIGNAL_COLORS[tone],
+ pulsing: !playback && (errored || hot || busy),
+ smoke: !playback && hot,
+ sparks: !playback && errored,
+ };
+}
diff --git a/client/src/utils/openWorldAppMetrics.test.js b/client/src/utils/openWorldAppMetrics.test.js
index a65b010552..a89c35a945 100644
--- a/client/src/utils/openWorldAppMetrics.test.js
+++ b/client/src/utils/openWorldAppMetrics.test.js
@@ -1,5 +1,5 @@
import { describe, it, expect } from 'vitest';
-import { computeAppMetrics, cpuTone } from './openWorldAppMetrics';
+import { computeAppMetrics, cpuTone, hasPm2Error, buildingSignalTone } from './openWorldAppMetrics';
describe('computeAppMetrics', () => {
it('sums cpu/memory across online processes and takes the minimum uptime', () => {
@@ -74,3 +74,74 @@ describe('cpuTone', () => {
expect(cpuTone(85)).toBe('hot');
});
});
+
+describe('hasPm2Error', () => {
+ it('treats errored and error process statuses as a PM2 error', () => {
+ expect(hasPm2Error({ web: { status: 'online' } })).toBe(false);
+ expect(hasPm2Error({ web: { status: 'errored' } })).toBe(true);
+ expect(hasPm2Error({ web: { status: 'error' } })).toBe(true);
+ expect(hasPm2Error(null)).toBe(false);
+ });
+});
+
+describe('buildingSignalTone', () => {
+ const hotMetrics = { hasMetrics: true, cpuPercent: 92, unstableRestarts: 0 };
+ const calmMetrics = { hasMetrics: true, cpuPercent: 12, unstableRestarts: 0 };
+
+ it('maps a healthy online app to a calm green LED with no rooftop effects', () => {
+ expect(buildingSignalTone({
+ status: 'online',
+ metrics: calmMetrics,
+ pm2Status: { web: { status: 'online' } },
+ })).toMatchObject({
+ tone: 'online',
+ color: '#10b981',
+ pulsing: false,
+ smoke: false,
+ sparks: false,
+ });
+ });
+
+ it('raises smoke on a hot CPU and sparks on a PM2 error', () => {
+ expect(buildingSignalTone({
+ status: 'online',
+ metrics: hotMetrics,
+ pm2Status: { web: { status: 'online' } },
+ })).toMatchObject({ tone: 'hot', pulsing: true, smoke: true, sparks: false });
+
+ expect(buildingSignalTone({
+ status: 'online',
+ metrics: calmMetrics,
+ pm2Status: { web: { status: 'errored' } },
+ })).toMatchObject({ tone: 'errored', pulsing: true, smoke: false, sparks: true });
+ });
+
+ it('hides live CPU smoke during playback while keeping the snapshot status LED', () => {
+ expect(buildingSignalTone({
+ status: 'online',
+ metrics: hotMetrics,
+ pm2Status: { web: { status: 'online' } },
+ playback: true,
+ })).toMatchObject({
+ tone: 'online',
+ pulsing: false,
+ smoke: false,
+ sparks: false,
+ });
+ });
+
+ it('keeps a snapshot error LED during playback without live sparks or pulse', () => {
+ expect(buildingSignalTone({
+ status: 'online',
+ metrics: hotMetrics,
+ pm2Status: { web: { status: 'errored' } },
+ playback: true,
+ })).toMatchObject({
+ tone: 'errored',
+ color: '#f43f5e',
+ pulsing: false,
+ smoke: false,
+ sparks: false,
+ });
+ });
+});